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:
parent
7e2028a3cd
commit
c9e6afe6a8
Notes:
sideshowbarker
2024-07-18 04:58:17 +09:00
Author: https://github.com/TobyAsE Commit: https://github.com/SerenityOS/serenity/commit/c9e6afe6a8a Pull-request: https://github.com/SerenityOS/serenity/pull/9706 Reviewed-by: https://github.com/alimpfard ✅ Reviewed-by: https://github.com/mustafaquraish
2 changed files with 15 additions and 2 deletions
|
@ -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; };
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue