From c9e6afe6a8a18583766b6fa3c5669f8b9b028b94 Mon Sep 17 00:00:00 2001 From: Tobias Christiansen Date: Tue, 31 Aug 2021 18:25:27 +0200 Subject: [PATCH] PixelPaint: Allow initial values for the EditGuideDialog This way we can feed it the values if we wanted to change an existing Guide and handle the default as before. That we have to pass a String here is a bit ugly. --- .../Applications/PixelPaint/EditGuideDialog.cpp | 15 ++++++++++++++- .../Applications/PixelPaint/EditGuideDialog.h | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Userland/Applications/PixelPaint/EditGuideDialog.cpp b/Userland/Applications/PixelPaint/EditGuideDialog.cpp index 5e8b993c9c..816a9862cc 100644 --- a/Userland/Applications/PixelPaint/EditGuideDialog.cpp +++ b/Userland/Applications/PixelPaint/EditGuideDialog.cpp @@ -13,8 +13,10 @@ namespace PixelPaint { -EditGuideDialog::EditGuideDialog(GUI::Window* parent_window) +EditGuideDialog::EditGuideDialog(GUI::Window* parent_window, String const& offset, Guide::Orientation orientation) : Dialog(parent_window) + , m_offset(offset) + , m_orientation(orientation) { set_title("Create new Guide"); set_icon(parent_window->icon()); @@ -36,6 +38,17 @@ EditGuideDialog::EditGuideDialog(GUI::Window* parent_window) VERIFY(vertical_radio); VERIFY(cancel_button); + if (orientation == Guide::Orientation::Vertical) { + vertical_radio->set_checked(true); + m_is_vertical_checked = true; + } else if (orientation == Guide::Orientation::Horizontal) { + horizontal_radio->set_checked(true); + m_is_horizontal_checked = true; + } + + if (!offset.is_empty()) + offset_text_box->set_text(offset); + horizontal_radio->on_checked = [this](bool checked) { m_is_horizontal_checked = checked; }; vertical_radio->on_checked = [this](bool checked) { m_is_vertical_checked = checked; }; diff --git a/Userland/Applications/PixelPaint/EditGuideDialog.h b/Userland/Applications/PixelPaint/EditGuideDialog.h index 3f8d44fcc4..d662833eca 100644 --- a/Userland/Applications/PixelPaint/EditGuideDialog.h +++ b/Userland/Applications/PixelPaint/EditGuideDialog.h @@ -22,7 +22,7 @@ public: Optional offset_as_pixel(ImageEditor const&); private: - EditGuideDialog(GUI::Window* parent_window); + EditGuideDialog(GUI::Window* parent_window, String const& offset = {}, Guide::Orientation orientation = Guide::Orientation::Unset); String m_offset; Guide::Orientation m_orientation;