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.
This commit is contained in:
Tobias Christiansen 2021-08-31 18:25:27 +02:00 committed by Andreas Kling
parent 7e2028a3cd
commit c9e6afe6a8
Notes: sideshowbarker 2024-07-18 04:58:17 +09:00
2 changed files with 15 additions and 2 deletions

View file

@ -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; };

View file

@ -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;