diff options
author | MacDue <macdue@dueutil.tech> | 2022-05-01 15:49:22 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-05-07 22:58:55 +0200 |
commit | e924aa338c4e927d735f4b3cde93debb0b572e58 (patch) | |
tree | bbe9424c57861c47d4b884ac03aff62cde644e1e /Userland | |
parent | 21c647dd7500bcc193cdc5934c26a845fcad1e97 (diff) | |
download | serenity-e924aa338c4e927d735f4b3cde93debb0b572e58.zip |
ThemeEditor: Center preview with center_window_group_within()
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/ThemeEditor/PreviewWidget.cpp | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/Userland/Applications/ThemeEditor/PreviewWidget.cpp b/Userland/Applications/ThemeEditor/PreviewWidget.cpp index 85505e6726..5c18c16fd5 100644 --- a/Userland/Applications/ThemeEditor/PreviewWidget.cpp +++ b/Userland/Applications/ThemeEditor/PreviewWidget.cpp @@ -100,33 +100,20 @@ void PreviewWidget::set_color_filter(OwnPtr<Gfx::ColorBlindnessFilter> color_fil void PreviewWidget::update_preview_window_locations() { - auto to_frame_rect = [&](Gfx::IntRect rect) { - return Gfx::WindowTheme::current().frame_rect_for_window( - Gfx::WindowTheme::WindowType::Normal, rect, preview_palette(), 0); - }; - constexpr int inactive_offset_x = -20; constexpr int inactive_offset_y = -20; constexpr int hightlight_offset_x = 140; - constexpr int hightlight_offset_y = 60; + constexpr int hightlight_offset_y = 80; m_active_window_rect = Gfx::IntRect(0, 0, 320, 220); m_inactive_window_rect = m_active_window_rect.translated(inactive_offset_x, inactive_offset_y); - auto active_frame = to_frame_rect(m_active_window_rect); - auto x_delta = m_active_window_rect.x() - active_frame.x(); - auto y_delta = m_active_window_rect.y() - active_frame.y(); - - // Center preview windows accounting for the window frames, - // which can vary in size depending on properties of the theme. - auto combind_frame_rect = active_frame.united(to_frame_rect(m_inactive_window_rect)).centered_within(frame_inner_rect()); - m_inactive_window_rect.set_x(combind_frame_rect.x() + x_delta); - m_inactive_window_rect.set_y(combind_frame_rect.y() + y_delta); - m_active_window_rect.set_x(m_inactive_window_rect.x() - inactive_offset_x); - m_active_window_rect.set_y(m_inactive_window_rect.y() - inactive_offset_y); - m_highlight_window_rect = Gfx::IntRect(0, 0, 160, 70) - .translated(m_active_window_rect.x(), m_active_window_rect.y()) - .translated(hightlight_offset_x, hightlight_offset_y) - .translated(x_delta, y_delta); + m_highlight_window_rect = Gfx::IntRect(m_active_window_rect.location(), { 160, 70 }).translated(hightlight_offset_x, hightlight_offset_y); + + Array<Window, 3> window_group { + m_active_window_rect, m_inactive_window_rect, m_highlight_window_rect + }; + + center_window_group_within(window_group, frame_inner_rect()); m_gallery->set_relative_rect(m_active_window_rect); } |