1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:37:45 +00:00

PixelPaint: Add "Apply Mask" action

This commit adds a "Apply Mask" action which merges the active layer
mask with the layer bitmap. The option is only displayed if the active
layer is masked.
This commit is contained in:
Tim Ledbetter 2023-02-25 06:46:18 +00:00 committed by Andreas Kling
parent 062c9efa88
commit 799d570afc
4 changed files with 20 additions and 0 deletions

View file

@ -774,6 +774,13 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
}));
m_layer_menu->add_action(*m_delete_mask_action);
m_apply_mask_action = GUI::Action::create(
"Apply Mask", create_layer_mask_callback("Apply Mask", [&](Layer* active_layer) {
VERIFY(active_layer->is_masked());
active_layer->apply_mask();
}));
m_layer_menu->add_action(*m_apply_mask_action);
m_layer_menu->add_separator();
m_layer_menu->add_action(GUI::Action::create(
@ -1137,6 +1144,7 @@ void MainWidget::set_mask_actions_for_layer(Layer* layer)
if (!layer) {
m_add_mask_action->set_visible(true);
m_delete_mask_action->set_visible(false);
m_apply_mask_action->set_visible(false);
m_add_mask_action->set_enabled(false);
return;
}
@ -1146,6 +1154,7 @@ void MainWidget::set_mask_actions_for_layer(Layer* layer)
auto masked = layer->is_masked();
m_add_mask_action->set_visible(!masked);
m_delete_mask_action->set_visible(masked);
m_apply_mask_action->set_visible(masked);
}
void MainWidget::open_image(FileSystemAccessClient::File file)