mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-07 00:19:27 +00:00
PixelPaint: Always animate marching ants during interactive selection
The Selection object now tracks whether there is an ongoing interactive selection (originating from one of the selection tools). If so it makes sure to pump the marching ants animation.
This commit is contained in:
parent
f54164e8ae
commit
068ca3a394
|
@ -25,6 +25,8 @@ void RectangleSelectTool::on_mousedown(Layer&, GUI::MouseEvent&, GUI::MouseEvent
|
|||
return;
|
||||
|
||||
m_selecting = true;
|
||||
m_editor->selection().begin_interactive_selection();
|
||||
|
||||
m_selection_start = image_event.position();
|
||||
m_selection_end = image_event.position();
|
||||
m_editor->update();
|
||||
|
@ -45,6 +47,8 @@ void RectangleSelectTool::on_mouseup(Layer&, GUI::MouseEvent&, GUI::MouseEvent&
|
|||
return;
|
||||
|
||||
m_selecting = false;
|
||||
m_editor->selection().end_interactive_selection();
|
||||
|
||||
m_editor->update();
|
||||
|
||||
auto rect_in_image = Gfx::IntRect::from_two_points(m_selection_start, m_selection_end);
|
||||
|
|
|
@ -23,7 +23,7 @@ Selection::Selection(ImageEditor& editor)
|
|||
m_marching_ants_timer = Core::Timer::create_repeating(80, [this] {
|
||||
++m_marching_ants_offset;
|
||||
m_marching_ants_offset %= marching_ant_length;
|
||||
if (!is_empty())
|
||||
if (!is_empty() || m_in_interactive_selection)
|
||||
m_editor.update();
|
||||
});
|
||||
m_marching_ants_timer->start();
|
||||
|
|
|
@ -27,11 +27,15 @@ public:
|
|||
|
||||
void draw_marching_ants(Gfx::Painter&, Gfx::IntRect 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;
|
||||
RefPtr<Core::Timer> m_marching_ants_timer;
|
||||
int m_marching_ants_offset { 0 };
|
||||
bool m_in_interactive_selection { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue