mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-29 19:10:26 +00:00
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:
parent
472721b774
commit
db99e0917c
Notes:
sideshowbarker
2024-07-18 12:14:25 +09:00
Author: https://github.com/LepkoQQ Commit: https://github.com/SerenityOS/serenity/commit/db99e0917ce Pull-request: https://github.com/SerenityOS/serenity/pull/8055
3 changed files with 20 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue