summaryrefslogtreecommitdiff
path: root/Userland/Applications/PixelPaint
diff options
context:
space:
mode:
authorTobias Christiansen <tobi@tobyase.de>2021-08-05 15:48:59 +0200
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-08-07 02:52:47 +0430
commit0ca085910ea5b7540522763d21ddec0358e49620 (patch)
tree624e416cbf41e0054921a736f12b1a183f7275ae /Userland/Applications/PixelPaint
parent193f1e01cf718be38ce3c764613db668781b12a5 (diff)
downloadserenity-0ca085910ea5b7540522763d21ddec0358e49620.zip
PixelPaint: Make Guides' visibility optional
Whether Guides are drawn or not is now controlled via the menu-entry View->Show Guides.
Diffstat (limited to 'Userland/Applications/PixelPaint')
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.cpp16
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.h2
-rw-r--r--Userland/Applications/PixelPaint/main.cpp10
3 files changed, 21 insertions, 7 deletions
diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp
index d6bb765397..080416be4e 100644
--- a/Userland/Applications/PixelPaint/ImageEditor.cpp
+++ b/Userland/Applications/PixelPaint/ImageEditor.cpp
@@ -83,13 +83,15 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
painter.draw_rect(enclosing_int_rect(image_rect_to_editor_rect(m_active_layer->relative_rect())).inflated(2, 2), Color::Black);
}
- for (auto& guide : m_guides) {
- if (guide.orientation() == Guide::Orientation::Horizontal) {
- int y_coordinate = (int)image_position_to_editor_position({ 0.0f, guide.offset() }).y();
- painter.draw_line({ 0, y_coordinate }, { rect().width(), y_coordinate }, Color::Cyan, 1, Gfx::Painter::LineStyle::Dashed, Color::LightGray);
- } else if (guide.orientation() == Guide::Orientation::Vertical) {
- int x_coordinate = (int)image_position_to_editor_position({ guide.offset(), 0.0f }).x();
- painter.draw_line({ x_coordinate, 0 }, { x_coordinate, rect().height() }, Color::Cyan, 1, Gfx::Painter::LineStyle::Dashed, Color::LightGray);
+ if (m_show_guides) {
+ for (auto& guide : m_guides) {
+ if (guide.orientation() == Guide::Orientation::Horizontal) {
+ int y_coordinate = (int)image_position_to_editor_position({ 0.0f, guide.offset() }).y();
+ painter.draw_line({ 0, y_coordinate }, { rect().width(), y_coordinate }, Color::Cyan, 1, Gfx::Painter::LineStyle::Dashed, Color::LightGray);
+ } else if (guide.orientation() == Guide::Orientation::Vertical) {
+ int x_coordinate = (int)image_position_to_editor_position({ guide.offset(), 0.0f }).x();
+ painter.draw_line({ x_coordinate, 0 }, { x_coordinate, rect().height() }, Color::Cyan, 1, Gfx::Painter::LineStyle::Dashed, Color::LightGray);
+ }
}
}
diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h
index 10e9fedf77..5c3f09f2fc 100644
--- a/Userland/Applications/PixelPaint/ImageEditor.h
+++ b/Userland/Applications/PixelPaint/ImageEditor.h
@@ -85,6 +85,7 @@ public:
Gfx::FloatPoint editor_position_to_image_position(Gfx::IntPoint const&) const;
NonnullRefPtrVector<Guide> const& guides() const { return m_guides; }
+ void toggle_guide_visibility() { m_show_guides = !m_show_guides; }
private:
explicit ImageEditor(NonnullRefPtr<Image>);
@@ -116,6 +117,7 @@ private:
OwnPtr<GUI::UndoStack> m_undo_stack;
NonnullRefPtrVector<Guide> m_guides;
+ bool m_show_guides { true };
Tool* m_active_tool { nullptr };
diff --git a/Userland/Applications/PixelPaint/main.cpp b/Userland/Applications/PixelPaint/main.cpp
index 7752df39a0..ee2c9b60b8 100644
--- a/Userland/Applications/PixelPaint/main.cpp
+++ b/Userland/Applications/PixelPaint/main.cpp
@@ -347,11 +347,21 @@ int main(int argc, char** argv)
},
window);
+ auto show_guides_action = GUI::Action::create_checkable(
+ "Show Guides", [&](auto&) {
+ if (auto* editor = current_image_editor()) {
+ editor->toggle_guide_visibility();
+ }
+ },
+ window);
+ show_guides_action->set_checked(true);
+
view_menu.add_action(zoom_in_action);
view_menu.add_action(zoom_out_action);
view_menu.add_action(reset_zoom_action);
view_menu.add_separator();
view_menu.add_action(add_guide_action);
+ view_menu.add_action(show_guides_action);
auto& tool_menu = window->add_menu("&Tool");
toolbox.for_each_tool([&](auto& tool) {