summaryrefslogtreecommitdiff
path: root/Servers/WindowServer/WSWindowFrame.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-12 21:32:02 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-12 21:32:02 +0200
commit641893104ae28392c3b5c1502370982d060d67b7 (patch)
tree601caad7e002fc085830e5d43d6c3f30e0c605a3 /Servers/WindowServer/WSWindowFrame.cpp
parentdddf45f56367b6e9e3a6740fe9bf70d81b4d6b1a (diff)
downloadserenity-641893104ae28392c3b5c1502370982d060d67b7.zip
WindowServer: Add a maximize/unmaximize button to windows.
Diffstat (limited to 'Servers/WindowServer/WSWindowFrame.cpp')
-rw-r--r--Servers/WindowServer/WSWindowFrame.cpp47
1 files changed, 45 insertions, 2 deletions
diff --git a/Servers/WindowServer/WSWindowFrame.cpp b/Servers/WindowServer/WSWindowFrame.cpp
index 1b93161a14..32b0539d4e 100644
--- a/Servers/WindowServer/WSWindowFrame.cpp
+++ b/Servers/WindowServer/WSWindowFrame.cpp
@@ -42,6 +42,38 @@ static CharacterBitmap* s_minimize_button_bitmap;
static const int s_minimize_button_bitmap_width = 8;
static const int s_minimize_button_bitmap_height = 9;
+static const char* s_maximize_button_bitmap_data = {
+ " "
+ " "
+ " "
+ " ## "
+ " #### "
+ " ###### "
+ " "
+ " "
+ " "
+};
+
+static CharacterBitmap* s_maximize_button_bitmap;
+static const int s_maximize_button_bitmap_width = 8;
+static const int s_maximize_button_bitmap_height = 9;
+
+static const char* s_unmaximize_button_bitmap_data = {
+ " "
+ " ## "
+ " #### "
+ " ###### "
+ " "
+ " ###### "
+ " #### "
+ " ## "
+ " "
+};
+
+static CharacterBitmap* s_unmaximize_button_bitmap;
+static const int s_unmaximize_button_bitmap_width = 8;
+static const int s_unmaximize_button_bitmap_height = 9;
+
WSWindowFrame::WSWindowFrame(WSWindow& window)
: m_window(window)
{
@@ -51,14 +83,25 @@ WSWindowFrame::WSWindowFrame(WSWindow& window)
if (!s_minimize_button_bitmap)
s_minimize_button_bitmap = &CharacterBitmap::create_from_ascii(s_minimize_button_bitmap_data, s_minimize_button_bitmap_width, s_minimize_button_bitmap_height).leak_ref();
- m_buttons.append(make<WSButton>(*this, *s_close_button_bitmap, [this] {
+ if (!s_maximize_button_bitmap)
+ s_maximize_button_bitmap = &CharacterBitmap::create_from_ascii(s_maximize_button_bitmap_data, s_maximize_button_bitmap_width, s_maximize_button_bitmap_height).leak_ref();
+
+ if (!s_unmaximize_button_bitmap)
+ s_unmaximize_button_bitmap = &CharacterBitmap::create_from_ascii(s_unmaximize_button_bitmap_data, s_unmaximize_button_bitmap_width, s_unmaximize_button_bitmap_height).leak_ref();
+
+ m_buttons.append(make<WSButton>(*this, *s_close_button_bitmap, [this] (auto&) {
WSEvent close_request(WSEvent::WindowCloseRequest);
m_window.event(close_request);
}));
- m_buttons.append(make<WSButton>(*this, *s_minimize_button_bitmap, [this] {
+ m_buttons.append(make<WSButton>(*this, *s_minimize_button_bitmap, [this] (auto&) {
m_window.set_minimized(true);
}));
+
+ m_buttons.append(make<WSButton>(*this, *s_maximize_button_bitmap, [this] (auto& button) {
+ m_window.set_maximized(!m_window.is_maximized());
+ button.set_bitmap(m_window.is_maximized() ? *s_unmaximize_button_bitmap : *s_maximize_button_bitmap);
+ }));
}
WSWindowFrame::~WSWindowFrame()