summaryrefslogtreecommitdiff
path: root/Services/WindowServer
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2020-08-25 18:13:32 -0400
committerAndreas Kling <kling@serenityos.org>2020-08-26 08:53:14 +0200
commit208cb995babb13e0af07bb9d3219f0a9fe7bca7d (patch)
tree7f524134bd5878b99ce5612ac5a2c183558720fb /Services/WindowServer
parent1ab8939077ad2a1137a1808b902ebb66d0663a66 (diff)
downloadserenity-208cb995babb13e0af07bb9d3219f0a9fe7bca7d.zip
WindowServer+LibGfx: Move title bar button layout to WindowTheme
Diffstat (limited to 'Services/WindowServer')
-rw-r--r--Services/WindowServer/WindowFrame.cpp26
1 files changed, 3 insertions, 23 deletions
diff --git a/Services/WindowServer/WindowFrame.cpp b/Services/WindowServer/WindowFrame.cpp
index b12e0e8b63..b1cd459f29 100644
--- a/Services/WindowServer/WindowFrame.cpp
+++ b/Services/WindowServer/WindowFrame.cpp
@@ -261,29 +261,9 @@ void WindowFrame::notify_window_rect_changed(const Gfx::IntRect& old_rect, const
void WindowFrame::layout_buttons()
{
- auto palette = WindowManager::the().palette();
- int window_button_width = palette.window_title_button_width();
- int window_button_height = palette.window_title_button_height();
- int pos;
- if (m_window.type() == WindowType::Notification)
- pos = title_bar_rect().top() + 2;
- else
- pos = title_bar_text_rect().right() + 1;
-
- for (auto& button : m_buttons) {
- if (m_window.type() == WindowType::Notification) {
- // The button height & width have to be equal or it leaks out of its area
- Gfx::IntRect rect { 0, pos, window_button_height, window_button_height };
- rect.center_horizontally_within(title_bar_rect());
- button.set_relative_rect(rect);
- pos += window_button_height;
- } else {
- pos -= window_button_width;
- Gfx::IntRect rect { pos, 0, window_button_width, window_button_height };
- rect.center_vertically_within(title_bar_text_rect());
- button.set_relative_rect(rect);
- }
- }
+ auto button_rects = Gfx::WindowTheme::current().layout_buttons(to_theme_window_type(m_window.type()), m_window.rect(), WindowManager::the().palette(), m_buttons.size());
+ for (size_t i = 0; i < m_buttons.size(); i++)
+ m_buttons[i].set_relative_rect(button_rects[i]);
}
void WindowFrame::on_mouse_event(const MouseEvent& event)