mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
PaintBrush: Add "Delete layer" action to move tool context menu
This commit is contained in:
parent
b25c6ab884
commit
40a72883ff
3 changed files with 18 additions and 2 deletions
|
@ -104,4 +104,11 @@ void Image::move_layer_to_front(Layer& layer)
|
||||||
m_layers.append(layer);
|
m_layers.append(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Image::remove_layer(Layer& layer)
|
||||||
|
{
|
||||||
|
NonnullRefPtr<Layer> protector(layer);
|
||||||
|
auto index = index_of(layer);
|
||||||
|
m_layers.remove(index);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ public:
|
||||||
|
|
||||||
void move_layer_to_front(Layer&);
|
void move_layer_to_front(Layer&);
|
||||||
void move_layer_to_back(Layer&);
|
void move_layer_to_back(Layer&);
|
||||||
|
void remove_layer(Layer&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Image(const Gfx::Size&);
|
explicit Image(const Gfx::Size&);
|
||||||
|
|
|
@ -111,11 +111,19 @@ void MoveTool::on_context_menu(Layer& layer, GUI::ContextMenuEvent& event)
|
||||||
m_context_menu->add_action(GUI::CommonActions::make_move_to_front_action([this](auto&) {
|
m_context_menu->add_action(GUI::CommonActions::make_move_to_front_action([this](auto&) {
|
||||||
m_editor->image()->move_layer_to_front(*m_context_menu_layer);
|
m_editor->image()->move_layer_to_front(*m_context_menu_layer);
|
||||||
m_editor->layers_did_change();
|
m_editor->layers_did_change();
|
||||||
}));
|
}, m_editor));
|
||||||
m_context_menu->add_action(GUI::CommonActions::make_move_to_back_action([this](auto&) {
|
m_context_menu->add_action(GUI::CommonActions::make_move_to_back_action([this](auto&) {
|
||||||
m_editor->image()->move_layer_to_back(*m_context_menu_layer);
|
m_editor->image()->move_layer_to_back(*m_context_menu_layer);
|
||||||
m_editor->layers_did_change();
|
m_editor->layers_did_change();
|
||||||
}));
|
}, m_editor));
|
||||||
|
m_context_menu->add_separator();
|
||||||
|
m_context_menu->add_action(GUI::Action::create("Delete layer", Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png"), [this](auto&) {
|
||||||
|
m_editor->image()->remove_layer(*m_context_menu_layer);
|
||||||
|
// FIXME: This should not be done imperatively here. Perhaps a Image::Client interface that ImageEditor can implement?
|
||||||
|
if (m_editor->active_layer() == m_context_menu_layer)
|
||||||
|
m_editor->set_active_layer(nullptr);
|
||||||
|
m_editor->layers_did_change();
|
||||||
|
}, m_editor));
|
||||||
}
|
}
|
||||||
m_context_menu_layer = layer;
|
m_context_menu_layer = layer;
|
||||||
m_context_menu->popup(event.screen_position());
|
m_context_menu->popup(event.screen_position());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue