From 2e3233d74e16f90a6ae916935dc65ea53b4364de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Fri, 30 Nov 2007 01:21:19 +0000 Subject: [PATCH] Propagate set_ui_color() up to the DesktopSettingsPrivate class. Still needs code to save the values. Also needs a way to access them from Decorator::UIColor(), but the DesktopSettings passed to the ctor can't be cached. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23024 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/DesktopSettings.cpp | 38 ++++++++++++++++++++++++ src/servers/app/DesktopSettings.h | 4 +++ src/servers/app/DesktopSettingsPrivate.h | 2 ++ src/servers/app/ServerApp.cpp | 20 +++++++++++++ 4 files changed, 64 insertions(+) diff --git a/src/servers/app/DesktopSettings.cpp b/src/servers/app/DesktopSettings.cpp index 384acf0403..79ff437fe5 100644 --- a/src/servers/app/DesktopSettings.cpp +++ b/src/servers/app/DesktopSettings.cpp @@ -478,6 +478,29 @@ DesktopSettingsPrivate::WorkspacesMessage(int32 index) const } +void +DesktopSettingsPrivate::SetUIColor(color_which which, const rgb_color color) +{ + // + int32 index = color_which_to_index(which); + if (index < 0 || index >= kNumColors) + return; + fShared.colors[index] = color; + Save(kAppearanceSettings); +} + + +rgb_color +DesktopSettingsPrivate::UIColor(color_which which) const +{ + static const rgb_color invalidColor = {0, 0, 0, 0}; + int32 index = color_which_to_index(which); + if (index < 0 || index >= kNumColors) + return invalidColor; + return fShared.colors[index]; +} + + // #pragma mark - read access @@ -563,6 +586,13 @@ DesktopSettings::WorkspacesMessage(int32 index) const } +rgb_color +DesktopSettings::UIColor(color_which which) const +{ + return fSettings->UIColor(which); +} + + // #pragma mark - write access @@ -633,3 +663,11 @@ LockedDesktopSettings::SetShowAllDraggers(bool show) fSettings->SetShowAllDraggers(show); } + +void +LockedDesktopSettings::SetUIColor(color_which which, const rgb_color color) +{ + fSettings->SetUIColor(which, color); +} + + diff --git a/src/servers/app/DesktopSettings.h b/src/servers/app/DesktopSettings.h index 4e326a0ecc..c928664c15 100644 --- a/src/servers/app/DesktopSettings.h +++ b/src/servers/app/DesktopSettings.h @@ -50,6 +50,8 @@ class DesktopSettings { int32 WorkspacesCount() const; const BMessage* WorkspacesMessage(int32 index) const; + rgb_color UIColor(color_which which) const; + protected: DesktopSettingsPrivate* fSettings; }; @@ -70,6 +72,8 @@ class LockedDesktopSettings : public DesktopSettings { void SetShowAllDraggers(bool show); + void SetUIColor(color_which which, const rgb_color color); + private: Desktop* fDesktop; }; diff --git a/src/servers/app/DesktopSettingsPrivate.h b/src/servers/app/DesktopSettingsPrivate.h index 11893aace6..2a3f78d01d 100644 --- a/src/servers/app/DesktopSettingsPrivate.h +++ b/src/servers/app/DesktopSettingsPrivate.h @@ -52,6 +52,8 @@ class DesktopSettingsPrivate { void SetWorkspacesMessage(int32 index, BMessage& message); const BMessage* WorkspacesMessage(int32 index) const; + void SetUIColor(color_which which, const rgb_color color); + rgb_color UIColor(color_which which) const; private: void _SetDefaults(); status_t _Load(); diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 62e8a9fc8f..6aa188be0c 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -2274,6 +2274,26 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) break; } + case AS_SET_UI_COLOR: + { + STRACE(("ServerApp %s: Set UI Color\n", Signature())); + // Attached Data: + // 1) color_which which + // 2) rgb_color color + color_which which; + rgb_color color; + + link.Read(&which); + if (link.Read(&color) == B_OK) { + LockedDesktopSettings settings(fDesktop); + settings.SetUIColor(which, color); + } + + fLink.StartMessage(B_OK); + fLink.Flush(); + break; + } + case AS_GET_ACCELERANT_INFO: { STRACE(("ServerApp %s: get accelerant info\n", Signature()));