1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:17:35 +00:00

PixelPaint: Use Mask internally in Selection

While the external API has not changed, this will allow us to have
non-rectangular selections in the future.
This commit is contained in:
Davipb 2021-06-20 10:48:43 -03:00 committed by Andreas Kling
parent 0828c75e57
commit d922e35579
3 changed files with 80 additions and 21 deletions

View file

@ -9,6 +9,8 @@
#include <LibCore/Timer.h>
#include <LibGfx/Rect.h>
#include "Mask.h"
namespace PixelPaint {
class ImageEditor;
@ -18,24 +20,27 @@ class Selection {
public:
explicit Selection(ImageEditor&);
bool is_empty() const { return m_rect.is_empty(); }
bool is_empty() const { return m_mask.is_null(); }
void clear();
void set(Gfx::IntRect const& rect) { m_rect = rect; }
Gfx::IntRect bounding_rect() const { return m_rect; }
void set(Gfx::IntRect const& rect) { m_mask = Mask::full(rect); }
Gfx::IntRect bounding_rect() const { return m_mask.bounding_rect(); }
void paint(Gfx::Painter&);
void draw_marching_ants(Gfx::Painter&, Gfx::IntRect const&) const;
void draw_marching_ants(Gfx::Painter&, Mask const&) const;
void begin_interactive_selection() { m_in_interactive_selection = true; }
void end_interactive_selection() { m_in_interactive_selection = false; }
private:
ImageEditor& m_editor;
Gfx::IntRect m_rect;
Mask m_mask;
RefPtr<Core::Timer> m_marching_ants_timer;
int m_marching_ants_offset { 0 };
bool m_in_interactive_selection { false };
void draw_marching_ants_pixel(Gfx::Painter&, int x, int y) const;
};
}