Преглед изворни кода

PixelPaint: Allow toggling the active layer boundary display rect

Let the user opt out of painting a rectangle around the currently
active layer.
Andreas Kling пре 3 година
родитељ
комит
4bd4ce439a

+ 3 - 0
Base/home/anon/.config/PixelPaint.ini

@@ -7,3 +7,6 @@ Show=true
 
 [Guides]
 Show=true
+
+[ImageEditor]
+ShowActiveLayerBoundary=true

+ 10 - 1
Userland/Applications/PixelPaint/ImageEditor.cpp

@@ -101,7 +101,7 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
     painter.draw_rect(m_editor_image_rect.inflated(2, 2), Color::Black);
     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);
     }
 
@@ -700,4 +700,13 @@ Result<void, String> ImageEditor::save_project_to_fd_and_close(int fd) const
     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();
+}
+
 }

+ 5 - 0
Userland/Applications/PixelPaint/ImageEditor.h

@@ -107,6 +107,9 @@ public:
     bool pixel_grid_visibility() const { return m_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:
     explicit ImageEditor(NonnullRefPtr<Image>);
 
@@ -147,6 +150,8 @@ private:
     bool m_show_rulers { true };
     bool m_show_pixel_grid { true };
 
+    bool m_show_active_layer_boundary { true };
+
     Tool* m_active_tool { nullptr };
 
     Color m_primary_color { Color::Black };

+ 9 - 0
Userland/Applications/PixelPaint/MainWidget.cpp

@@ -381,6 +381,15 @@ void MainWidget::initialize_menubar(GUI::Window& window)
     m_show_rulers_action->set_checked(Config::read_bool("PixelPaint", "Rulers", "Show", true));
     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");
     m_toolbox->for_each_tool([&](auto& tool) {
         if (tool.action())

+ 1 - 0
Userland/Applications/PixelPaint/MainWidget.h

@@ -71,6 +71,7 @@ private:
     RefPtr<GUI::Action> m_add_guide_action;
     RefPtr<GUI::Action> m_show_guides_action;
     RefPtr<GUI::Action> m_show_rulers_action;
+    RefPtr<GUI::Action> m_show_active_layer_boundary_action;
 };
 
 }