summaryrefslogtreecommitdiff
path: root/Servers/WindowServer
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-29 00:47:49 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-29 00:47:49 +0100
commit7b2dd7e116c81b586d793a2b7b98100fe28388d7 (patch)
tree417a6be2fd5aa434790b73cf69eb357d891449ce /Servers/WindowServer
parent19d4f4c7b54c0de0e6d13122b05f29f4810782ac (diff)
downloadserenity-7b2dd7e116c81b586d793a2b7b98100fe28388d7.zip
LibDraw+LibGUI: Allow changing individual colors in a Palette
Palette is now a value wrapper around a NonnullRefPtr<PaletteImpl>. A new function, set_color(ColorRole, Color) implements a simple copy-on-write mechanism so that we're sharing the PaletteImpl in the common case, but allowing you to create custom palettes if you like, by getting a GWidget's palette, modifying it, and then assigning the modified palette to the widget via GWidget::set_palette(). Use this to make PaintBrush show its palette colors once again. Fixes #943.
Diffstat (limited to 'Servers/WindowServer')
-rw-r--r--Servers/WindowServer/WSButton.cpp2
-rw-r--r--Servers/WindowServer/WSMenu.cpp2
-rw-r--r--Servers/WindowServer/WSMenuManager.cpp2
-rw-r--r--Servers/WindowServer/WSWindowFrame.cpp2
-rw-r--r--Servers/WindowServer/WSWindowManager.cpp4
-rw-r--r--Servers/WindowServer/WSWindowManager.h6
-rw-r--r--Servers/WindowServer/WSWindowSwitcher.cpp2
-rw-r--r--Servers/WindowServer/main.cpp2
8 files changed, 11 insertions, 11 deletions
diff --git a/Servers/WindowServer/WSButton.cpp b/Servers/WindowServer/WSButton.cpp
index 0c6d749d41..507add13b4 100644
--- a/Servers/WindowServer/WSButton.cpp
+++ b/Servers/WindowServer/WSButton.cpp
@@ -18,7 +18,7 @@ WSButton::~WSButton()
void WSButton::paint(Painter& painter)
{
- auto& palette = WSWindowManager::the().palette();
+ auto palette = WSWindowManager::the().palette();
PainterStateSaver saver(painter);
painter.translate(relative_rect().location());
StylePainter::paint_button(painter, rect(), palette, ButtonStyle::Normal, m_pressed, m_hovered);
diff --git a/Servers/WindowServer/WSMenu.cpp b/Servers/WindowServer/WSMenu.cpp
index 3711e5949d..d6de3f6852 100644
--- a/Servers/WindowServer/WSMenu.cpp
+++ b/Servers/WindowServer/WSMenu.cpp
@@ -126,7 +126,7 @@ WSWindow& WSMenu::ensure_menu_window()
void WSMenu::draw()
{
- auto& palette = WSWindowManager::the().palette();
+ auto palette = WSWindowManager::the().palette();
m_theme_index_at_last_paint = WSWindowManager::the().theme_index();
ASSERT(menu_window());
diff --git a/Servers/WindowServer/WSMenuManager.cpp b/Servers/WindowServer/WSMenuManager.cpp
index 3eb0fa67c7..f80a143ecb 100644
--- a/Servers/WindowServer/WSMenuManager.cpp
+++ b/Servers/WindowServer/WSMenuManager.cpp
@@ -33,7 +33,7 @@ bool WSMenuManager::is_open(const WSMenu& menu) const
void WSMenuManager::draw()
{
auto& wm = WSWindowManager::the();
- auto& palette = wm.palette();
+ auto palette = wm.palette();
auto menubar_rect = this->menubar_rect();
if (m_needs_window_resize) {
diff --git a/Servers/WindowServer/WSWindowFrame.cpp b/Servers/WindowServer/WSWindowFrame.cpp
index da968a28a1..3fd3ae86d6 100644
--- a/Servers/WindowServer/WSWindowFrame.cpp
+++ b/Servers/WindowServer/WSWindowFrame.cpp
@@ -153,7 +153,7 @@ void WSWindowFrame::paint(Painter& painter)
if (m_window.type() != WSWindowType::Normal)
return;
- auto& palette = WSWindowManager::the().palette();
+ auto palette = WSWindowManager::the().palette();
auto& window = m_window;
auto titlebar_rect = title_bar_rect();
diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp
index 37e0e7fe7b..33b468fb26 100644
--- a/Servers/WindowServer/WSWindowManager.cpp
+++ b/Servers/WindowServer/WSWindowManager.cpp
@@ -42,7 +42,7 @@ WSWindowManager& WSWindowManager::the()
return *s_the;
}
-WSWindowManager::WSWindowManager(const Palette& palette)
+WSWindowManager::WSWindowManager(const PaletteImpl& palette)
: m_palette(palette)
{
s_the = this;
@@ -133,7 +133,7 @@ WSWindowManager::WSWindowManager(const Palette& palette)
auto new_theme = load_system_theme(theme.path);
ASSERT(new_theme);
set_system_theme(*new_theme);
- m_palette = Palette::create_with_shared_buffer(*new_theme);
+ m_palette = PaletteImpl::create_with_shared_buffer(*new_theme);
HashTable<WSClientConnection*> notified_clients;
for_each_window([&](WSWindow& window) {
if (window.client()) {
diff --git a/Servers/WindowServer/WSWindowManager.h b/Servers/WindowServer/WSWindowManager.h
index 0600b88fd8..8a6f1324cf 100644
--- a/Servers/WindowServer/WSWindowManager.h
+++ b/Servers/WindowServer/WSWindowManager.h
@@ -51,10 +51,10 @@ class WSWindowManager : public CObject {
public:
static WSWindowManager& the();
- explicit WSWindowManager(const Palette&);
+ explicit WSWindowManager(const PaletteImpl&);
virtual ~WSWindowManager() override;
- const Palette& palette() const { return *m_palette; }
+ Palette palette() const { return Palette(*m_palette); }
RefPtr<CConfigFile> wm_config() const
{
@@ -286,7 +286,7 @@ private:
WeakPtr<WSButton> m_cursor_tracking_button;
WeakPtr<WSButton> m_hovered_button;
- NonnullRefPtr<Palette> m_palette;
+ NonnullRefPtr<PaletteImpl> m_palette;
RefPtr<CConfigFile> m_wm_config;
diff --git a/Servers/WindowServer/WSWindowSwitcher.cpp b/Servers/WindowServer/WSWindowSwitcher.cpp
index 2c6622a90d..6436bea5a5 100644
--- a/Servers/WindowServer/WSWindowSwitcher.cpp
+++ b/Servers/WindowServer/WSWindowSwitcher.cpp
@@ -71,7 +71,7 @@ void WSWindowSwitcher::on_key_event(const WSKeyEvent& event)
void WSWindowSwitcher::draw()
{
- auto& palette = WSWindowManager::the().palette();
+ auto palette = WSWindowManager::the().palette();
Painter painter(*m_switcher_window->backing_store());
painter.fill_rect({ {}, m_rect.size() }, palette.window());
painter.draw_rect({ {}, m_rect.size() }, palette.threed_shadow2());
diff --git a/Servers/WindowServer/main.cpp b/Servers/WindowServer/main.cpp
index c12a53d496..1f6849f8b1 100644
--- a/Servers/WindowServer/main.cpp
+++ b/Servers/WindowServer/main.cpp
@@ -26,7 +26,7 @@ int main(int, char**)
auto theme = load_system_theme(String::format("/res/themes/%s.ini", theme_name.characters()));
ASSERT(theme);
set_system_theme(*theme);
- auto palette = Palette::create_with_shared_buffer(*theme);
+ auto palette = PaletteImpl::create_with_shared_buffer(*theme);
WSEventLoop loop;