PixelPaint: Add menu items for Select All and Clear Selection

We also need to update the image editor when clearing selection
otherwise the last state of the selection will be displayed until an
update happens.
This commit is contained in:
LepkoQQ 2021-06-14 22:26:15 +02:00 committed by Andreas Kling
parent 472721b774
commit db99e0917c
Notes: sideshowbarker 2024-07-18 12:14:25 +09:00
3 changed files with 20 additions and 1 deletions

View file

@ -56,4 +56,10 @@ void Selection::draw_marching_ants(Gfx::Painter& painter, Gfx::IntRect const& re
draw_pixel(rect.left(), y);
}
void Selection::clear()
{
m_rect = {};
m_editor.update();
}
}

View file

@ -19,7 +19,7 @@ public:
explicit Selection(ImageEditor&);
bool is_empty() const { return m_rect.is_empty(); }
void clear() { m_rect = {}; }
void clear();
void set(Gfx::IntRect const& rect) { m_rect = rect; }
Gfx::IntRect bounding_rect() const { return m_rect; }

View file

@ -207,6 +207,19 @@ int main(int argc, char** argv)
});
edit_menu.add_action(redo_action);
edit_menu.add_separator();
edit_menu.add_action(GUI::CommonActions::make_select_all_action([&](auto&) {
VERIFY(image_editor.image());
if (!image_editor.active_layer())
return;
image_editor.selection().set(image_editor.active_layer()->relative_rect());
}));
edit_menu.add_action(GUI::Action::create(
"Clear &Selection", { Mod_Ctrl | Mod_Shift, Key_A }, [&](auto&) {
image_editor.selection().clear();
},
window));
auto& view_menu = menubar->add_menu("&View");
auto zoom_in_action = GUI::CommonActions::make_zoom_in_action(