mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
PixelPaint: Allow toggling the active layer boundary display rect
Let the user opt out of painting a rectangle around the currently active layer.
This commit is contained in:
parent
85e5586a27
commit
4bd4ce439a
5 changed files with 28 additions and 1 deletions
|
@ -7,3 +7,6 @@ Show=true
|
||||||
|
|
||||||
[Guides]
|
[Guides]
|
||||||
Show=true
|
Show=true
|
||||||
|
|
||||||
|
[ImageEditor]
|
||||||
|
ShowActiveLayerBoundary=true
|
||||||
|
|
|
@ -101,7 +101,7 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
|
||||||
painter.draw_rect(m_editor_image_rect.inflated(2, 2), Color::Black);
|
painter.draw_rect(m_editor_image_rect.inflated(2, 2), Color::Black);
|
||||||
m_image->paint_into(painter, m_editor_image_rect);
|
m_image->paint_into(painter, m_editor_image_rect);
|
||||||
|
|
||||||
if (m_active_layer) {
|
if (m_active_layer && m_show_active_layer_boundary) {
|
||||||
painter.draw_rect(enclosing_int_rect(image_rect_to_editor_rect(m_active_layer->relative_rect())).inflated(2, 2), Color::Black);
|
painter.draw_rect(enclosing_int_rect(image_rect_to_editor_rect(m_active_layer->relative_rect())).inflated(2, 2), Color::Black);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -700,4 +700,13 @@ Result<void, String> ImageEditor::save_project_to_fd_and_close(int fd) const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageEditor::set_show_active_layer_boundary(bool show)
|
||||||
|
{
|
||||||
|
if (m_show_active_layer_boundary == show)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_show_active_layer_boundary = show;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,9 @@ public:
|
||||||
bool pixel_grid_visibility() const { return m_show_pixel_grid; }
|
bool pixel_grid_visibility() const { return m_show_pixel_grid; }
|
||||||
void set_pixel_grid_visibility(bool show_pixel_grid);
|
void set_pixel_grid_visibility(bool show_pixel_grid);
|
||||||
|
|
||||||
|
bool show_active_layer_boundary() const { return m_show_active_layer_boundary; }
|
||||||
|
void set_show_active_layer_boundary(bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ImageEditor(NonnullRefPtr<Image>);
|
explicit ImageEditor(NonnullRefPtr<Image>);
|
||||||
|
|
||||||
|
@ -147,6 +150,8 @@ private:
|
||||||
bool m_show_rulers { true };
|
bool m_show_rulers { true };
|
||||||
bool m_show_pixel_grid { true };
|
bool m_show_pixel_grid { true };
|
||||||
|
|
||||||
|
bool m_show_active_layer_boundary { true };
|
||||||
|
|
||||||
Tool* m_active_tool { nullptr };
|
Tool* m_active_tool { nullptr };
|
||||||
|
|
||||||
Color m_primary_color { Color::Black };
|
Color m_primary_color { Color::Black };
|
||||||
|
|
|
@ -381,6 +381,15 @@ void MainWidget::initialize_menubar(GUI::Window& window)
|
||||||
m_show_rulers_action->set_checked(Config::read_bool("PixelPaint", "Rulers", "Show", true));
|
m_show_rulers_action->set_checked(Config::read_bool("PixelPaint", "Rulers", "Show", true));
|
||||||
view_menu.add_action(*m_show_rulers_action);
|
view_menu.add_action(*m_show_rulers_action);
|
||||||
|
|
||||||
|
m_show_active_layer_boundary_action = GUI::Action::create_checkable(
|
||||||
|
"Show Active Layer &Boundary", [&](auto& action) {
|
||||||
|
Config::write_bool("PixelPaint", "ImageEditor", "ShowActiveLayerBoundary", action.is_checked());
|
||||||
|
if (auto* editor = current_image_editor())
|
||||||
|
editor->set_show_active_layer_boundary(action.is_checked());
|
||||||
|
});
|
||||||
|
m_show_active_layer_boundary_action->set_checked(Config::read_bool("PixelPaint", "ImageEditor", "ShowActiveLayerBoundary", true));
|
||||||
|
view_menu.add_action(*m_show_active_layer_boundary_action);
|
||||||
|
|
||||||
auto& tool_menu = window.add_menu("&Tool");
|
auto& tool_menu = window.add_menu("&Tool");
|
||||||
m_toolbox->for_each_tool([&](auto& tool) {
|
m_toolbox->for_each_tool([&](auto& tool) {
|
||||||
if (tool.action())
|
if (tool.action())
|
||||||
|
|
|
@ -71,6 +71,7 @@ private:
|
||||||
RefPtr<GUI::Action> m_add_guide_action;
|
RefPtr<GUI::Action> m_add_guide_action;
|
||||||
RefPtr<GUI::Action> m_show_guides_action;
|
RefPtr<GUI::Action> m_show_guides_action;
|
||||||
RefPtr<GUI::Action> m_show_rulers_action;
|
RefPtr<GUI::Action> m_show_rulers_action;
|
||||||
|
RefPtr<GUI::Action> m_show_active_layer_boundary_action;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue