mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 21:54:40 +03:00
PixelPaint: Add action to invert selection
This commit is contained in:
parent
295fcd639f
commit
d3353ee0e7
Notes:
sideshowbarker
2024-07-19 17:02:32 +09:00
Author: https://github.com/snooze6214 Commit: https://github.com/SerenityOS/serenity/commit/d3353ee0e7c Pull-request: https://github.com/SerenityOS/serenity/pull/15684 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/davidot ✅
BIN
Base/res/icons/pixelpaint/invert-selection.png
Normal file
BIN
Base/res/icons/pixelpaint/invert-selection.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 165 B |
@ -18,6 +18,7 @@ ErrorOr<IconBag> IconBag::try_create()
|
||||
icon_bag.close_image = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/close-tab.png"sv));
|
||||
icon_bag.edit_copy = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"sv));
|
||||
icon_bag.clear_selection = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/clear-selection.png"sv));
|
||||
icon_bag.invert_selection = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/invert-selection.png"sv));
|
||||
icon_bag.swap_colors = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/swap-colors.png"sv));
|
||||
icon_bag.default_colors = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/default-colors.png"sv));
|
||||
icon_bag.load_color_palette = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/load-color-palette.png"sv));
|
||||
|
@ -19,6 +19,7 @@ struct IconBag final {
|
||||
RefPtr<Gfx::Bitmap> close_image { nullptr };
|
||||
RefPtr<Gfx::Bitmap> edit_copy { nullptr };
|
||||
RefPtr<Gfx::Bitmap> clear_selection { nullptr };
|
||||
RefPtr<Gfx::Bitmap> invert_selection { nullptr };
|
||||
RefPtr<Gfx::Bitmap> swap_colors { nullptr };
|
||||
RefPtr<Gfx::Bitmap> default_colors { nullptr };
|
||||
RefPtr<Gfx::Bitmap> load_color_palette { nullptr };
|
||||
|
@ -365,6 +365,12 @@ void MainWidget::initialize_menubar(GUI::Window& window)
|
||||
VERIFY(editor);
|
||||
editor->image().selection().clear();
|
||||
}));
|
||||
m_edit_menu->add_action(GUI::Action::create(
|
||||
"&Invert Selection", g_icon_bag.invert_selection, [&](auto&) {
|
||||
auto* editor = current_image_editor();
|
||||
VERIFY(editor);
|
||||
editor->image().selection().invert();
|
||||
}));
|
||||
|
||||
m_edit_menu->add_separator();
|
||||
m_edit_menu->add_action(GUI::Action::create(
|
||||
|
@ -22,6 +22,13 @@ void Selection::clear()
|
||||
client->selection_did_change();
|
||||
}
|
||||
|
||||
void Selection::invert()
|
||||
{
|
||||
auto new_mask = Mask::full(m_image.rect());
|
||||
new_mask.subtract(m_mask);
|
||||
m_mask = new_mask;
|
||||
}
|
||||
|
||||
void Selection::merge(Mask const& mask, MergeMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
|
||||
bool is_empty() const { return m_mask.is_null(); }
|
||||
void clear();
|
||||
void invert();
|
||||
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(); }
|
||||
|
Loading…
Reference in New Issue
Block a user