mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:27:35 +00:00
PixelPaint: Expose more complex selection operations
Now that we use RectMask internally to store the selection, we can expose more powerful APIs to allow for better control over the image selection.
This commit is contained in:
parent
d922e35579
commit
22585e2845
4 changed files with 38 additions and 3 deletions
|
@ -18,13 +18,28 @@ class ImageEditor;
|
|||
// Coordinates are image-relative.
|
||||
class Selection {
|
||||
public:
|
||||
enum class MergeMode {
|
||||
Set,
|
||||
Add,
|
||||
Subtract,
|
||||
Intersect,
|
||||
__Count,
|
||||
};
|
||||
|
||||
explicit Selection(ImageEditor&);
|
||||
|
||||
bool is_empty() const { return m_mask.is_null(); }
|
||||
void clear();
|
||||
void set(Gfx::IntRect const& rect) { m_mask = Mask::full(rect); }
|
||||
void merge(Mask const&, MergeMode);
|
||||
void merge(Gfx::IntRect const& rect, MergeMode mode) { merge(Mask::full(rect), mode); }
|
||||
Gfx::IntRect bounding_rect() const { return m_mask.bounding_rect(); }
|
||||
|
||||
[[nodiscard]] bool is_selected(int x, int y) const { return m_mask.get(x, y) > 0; }
|
||||
[[nodiscard]] bool is_selected(Gfx::IntPoint const& point) const { return is_selected(point.x(), point.y()); }
|
||||
|
||||
[[nodiscard]] u8 get_selection_alpha(int x, int y) const { return m_mask.get(x, y); }
|
||||
[[nodiscard]] u8 get_selection_alpha(Gfx::IntPoint const& point) const { return get_selection_alpha(point.x(), point.y()); }
|
||||
|
||||
void paint(Gfx::Painter&);
|
||||
|
||||
void draw_marching_ants(Gfx::Painter&, Gfx::IntRect const&) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue