summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-05-13 14:19:18 +0100
committerLinus Groh <mail@linusgroh.de>2022-05-13 16:27:43 +0200
commitcd5210a87abf2960dfcaea0ec557663e6ecc4717 (patch)
treea0de18fda5393c20a1fdcb82972f6e11c2907e2e
parentcdffe556c8fcca034b10cf91f0b05c17d835bc7b (diff)
downloadserenity-cd5210a87abf2960dfcaea0ec557663e6ecc4717.zip
LibGUI: Make Dialog::ScreenPosition an enum class
-rw-r--r--Userland/Libraries/LibGUI/CommandPalette.h2
-rw-r--r--Userland/Libraries/LibGUI/Dialog.cpp20
-rw-r--r--Userland/Libraries/LibGUI/Dialog.h6
3 files changed, 14 insertions, 14 deletions
diff --git a/Userland/Libraries/LibGUI/CommandPalette.h b/Userland/Libraries/LibGUI/CommandPalette.h
index 5e1853c7ab..04a0429a62 100644
--- a/Userland/Libraries/LibGUI/CommandPalette.h
+++ b/Userland/Libraries/LibGUI/CommandPalette.h
@@ -20,7 +20,7 @@ public:
GUI::Action const* selected_action() const { return m_selected_action; }
private:
- explicit CommandPalette(GUI::Window& parent_window, ScreenPosition screen_position = CenterWithinParent);
+ explicit CommandPalette(GUI::Window& parent_window, ScreenPosition = ScreenPosition::CenterWithinParent);
virtual ~CommandPalette() override = default;
void collect_actions(GUI::Window& parent_window);
diff --git a/Userland/Libraries/LibGUI/Dialog.cpp b/Userland/Libraries/LibGUI/Dialog.cpp
index 7dcba9cd7f..f7ebd63b5f 100644
--- a/Userland/Libraries/LibGUI/Dialog.cpp
+++ b/Userland/Libraries/LibGUI/Dialog.cpp
@@ -35,7 +35,7 @@ Dialog::ExecResult Dialog::exec()
auto right_align = [this, desktop_rect](Gfx::Rect<int>& rect) { rect.set_x(desktop_rect.width() - width() - 12); };
switch (m_screen_position) {
- case CenterWithinParent:
+ case ScreenPosition::CenterWithinParent:
if (parent() && is<Window>(parent())) {
auto& parent_window = *static_cast<Window*>(parent());
if (parent_window.is_visible()) {
@@ -44,38 +44,38 @@ Dialog::ExecResult Dialog::exec()
}
}
[[fallthrough]]; // Fall back to `Center` if parent window is invalid or not visible
- case Center:
+ case ScreenPosition::Center:
window_rect.center_within(desktop_rect);
break;
- case CenterLeft:
+ case ScreenPosition::CenterLeft:
left_align(window_rect);
window_rect.center_vertically_within(desktop_rect);
break;
- case CenterRight:
+ case ScreenPosition::CenterRight:
right_align(window_rect);
window_rect.center_vertically_within(desktop_rect);
break;
- case TopLeft:
+ case ScreenPosition::TopLeft:
left_align(window_rect);
top_align(window_rect);
break;
- case TopCenter:
+ case ScreenPosition::TopCenter:
window_rect.center_horizontally_within(desktop_rect);
top_align(window_rect);
break;
- case TopRight:
+ case ScreenPosition::TopRight:
right_align(window_rect);
top_align(window_rect);
break;
- case BottomLeft:
+ case ScreenPosition::BottomLeft:
left_align(window_rect);
bottom_align(window_rect);
break;
- case BottomCenter:
+ case ScreenPosition::BottomCenter:
window_rect.center_horizontally_within(desktop_rect);
bottom_align(window_rect);
break;
- case BottomRight:
+ case ScreenPosition::BottomRight:
right_align(window_rect);
bottom_align(window_rect);
break;
diff --git a/Userland/Libraries/LibGUI/Dialog.h b/Userland/Libraries/LibGUI/Dialog.h
index 52146c8dc3..4f7b869932 100644
--- a/Userland/Libraries/LibGUI/Dialog.h
+++ b/Userland/Libraries/LibGUI/Dialog.h
@@ -22,7 +22,7 @@ public:
Yes = 3,
No = 4,
};
- enum ScreenPosition {
+ enum class ScreenPosition {
CenterWithinParent = 0,
Center = 1,
@@ -50,12 +50,12 @@ public:
virtual void close() override;
protected:
- explicit Dialog(Window* parent_window, ScreenPosition screen_position = CenterWithinParent);
+ explicit Dialog(Window* parent_window, ScreenPosition = ScreenPosition::CenterWithinParent);
private:
OwnPtr<Core::EventLoop> m_event_loop;
ExecResult m_result { ExecResult::Aborted };
- int m_screen_position { CenterWithinParent };
+ ScreenPosition m_screen_position { ScreenPosition::CenterWithinParent };
};
}