summaryrefslogtreecommitdiff
path: root/Libraries
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 /Libraries
parent1ab8939077ad2a1137a1808b902ebb66d0663a66 (diff)
downloadserenity-208cb995babb13e0af07bb9d3219f0a9fe7bca7d.zip
WindowServer+LibGfx: Move title bar button layout to WindowTheme
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGfx/ClassicWindowTheme.cpp28
-rw-r--r--Libraries/LibGfx/ClassicWindowTheme.h4
-rw-r--r--Libraries/LibGfx/WindowTheme.h2
3 files changed, 33 insertions, 1 deletions
diff --git a/Libraries/LibGfx/ClassicWindowTheme.cpp b/Libraries/LibGfx/ClassicWindowTheme.cpp
index ce4d26f2d4..bc16191067 100644
--- a/Libraries/LibGfx/ClassicWindowTheme.cpp
+++ b/Libraries/LibGfx/ClassicWindowTheme.cpp
@@ -177,4 +177,32 @@ IntRect ClassicWindowTheme::frame_rect_for_window(WindowType window_type, const
}
}
+Vector<IntRect> ClassicWindowTheme::layout_buttons(WindowType window_type, const IntRect& window_rect, const Palette& palette, size_t buttons) const
+{
+ int window_button_width = palette.window_title_button_width();
+ int window_button_height = palette.window_title_button_height();
+ int pos;
+ Vector<IntRect> button_rects;
+ if (window_type == WindowType::Notification)
+ pos = title_bar_rect(window_type, window_rect, palette).top() + 2;
+ else
+ pos = title_bar_text_rect(window_type, window_rect, palette).right() + 1;
+
+ for (size_t i = 0; i < buttons; i++) {
+ if (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(window_type, window_rect, palette));
+ button_rects.append(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(window_type, window_rect, palette));
+ button_rects.append(rect);
+ }
+ }
+ return button_rects;
+}
+
}
diff --git a/Libraries/LibGfx/ClassicWindowTheme.h b/Libraries/LibGfx/ClassicWindowTheme.h
index d27110b056..1a842ab15e 100644
--- a/Libraries/LibGfx/ClassicWindowTheme.h
+++ b/Libraries/LibGfx/ClassicWindowTheme.h
@@ -26,8 +26,8 @@
#pragma once
-#include <LibGfx/WindowTheme.h>
#include <LibGfx/Color.h>
+#include <LibGfx/WindowTheme.h>
namespace Gfx {
@@ -45,6 +45,8 @@ public:
virtual IntRect frame_rect_for_window(WindowType, const IntRect& window_rect, const Palette&) const override;
+ virtual Vector<IntRect> layout_buttons(WindowType, const IntRect& window_rect, const Palette&, size_t buttons) const override;
+
private:
struct FrameColors {
Color title_color;
diff --git a/Libraries/LibGfx/WindowTheme.h b/Libraries/LibGfx/WindowTheme.h
index d94d89621c..b6d137af71 100644
--- a/Libraries/LibGfx/WindowTheme.h
+++ b/Libraries/LibGfx/WindowTheme.h
@@ -59,6 +59,8 @@ public:
virtual IntRect frame_rect_for_window(WindowType, const IntRect& window_rect, const Palette&) const = 0;
+ virtual Vector<IntRect> layout_buttons(WindowType, const IntRect& window_rect, const Palette&, size_t buttons) const = 0;
+
protected:
WindowTheme() { }
};