summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTobias Christiansen <tobyase@serenityos.org>2021-08-31 18:25:27 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-01 13:46:44 +0200
commitc9e6afe6a8a18583766b6fa3c5669f8b9b028b94 (patch)
treedf99f336442594cdcaab57efbac373d3f69972e1 /Userland
parent7e2028a3cd336a942a5ddacce2f0bd5e636ad0bf (diff)
downloadserenity-c9e6afe6a8a18583766b6fa3c5669f8b9b028b94.zip
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.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/PixelPaint/EditGuideDialog.cpp15
-rw-r--r--Userland/Applications/PixelPaint/EditGuideDialog.h2
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<float> 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;