[haiku-commits] BRANCH looncraz-github.setviewuicolor [197e00b750cc] src/kits/interface src/servers/app src/preferences/appearance headers/os/interface src

  • From: looncraz-github.setviewuicolor <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 10 Dec 2015 17:31:57 +0100 (CET)

added 5 changesets to branch 'refs/remotes/looncraz-github/setviewuicolor'
old head: e500b5c67784f9f5e6d08982ca715669f664abdf
new head: 197e00b750ccd7840a0ad76c786e271c62c52afb
overview: https://github.com/looncraz/haiku/compare/e500b5c67784...197e00b750cc

----------------------------------------------------------------------------

ae31d18fec90: Style Cleanup

Thanks to Dario Casalinuovo for pointing these out!

bc7c087a2250: Proper encapsulation for DelayedMessageData

Use accessors for data members and make private.

cb3e2d51fc03: Move BColorMap into the private interface headers

This class may or may not be made public in the future, depending upon the
utility
gained by third party applications.

3704da924219: Protect Custom Colors for ColumnListView

Previously it was possible that system color changes would squash custom
colors
as set by the application.

197e00b750cc: Remove BColorMap, add BMessage::Add/Find/*Color()

By adding BMessage::*Color() methods BColorMap's primary purpose was usurped.

Its secondary capabilities have been replaced via the following changes:

Color changes occur during a single, long-held, fAllWindowsLock from the
Desktop
thread in the app_server.

Desktop thread now sends notices to clients directly.

void set_ui_colors(const BMessage* colors)
color_which which_ui_color(const char* name);
const char* ui_color_name(color_which which);

Appearance app now uses BMessages to store color states.

[ looncraz <looncraz@xxxxxxxxxxxx> ]

----------------------------------------------------------------------------

44 files changed, 427 insertions(+), 1454 deletions(-)
headers/os/app/Message.h | 16 +
headers/os/interface/ColorMap.h | 102 --
headers/os/interface/InterfaceDefs.h | 4 +
headers/private/interface/ColorMapPrivate.h | 82 --
headers/private/interface/ColumnListView.h | 6 +-
src/apps/aboutsystem/AboutSystem.cpp | 3 +-
src/apps/aboutsystem/Jamfile | 2 +-
src/apps/deskcalc/CalcView.cpp | 3 +-
src/apps/devices/PropertyListPlain.cpp | 4 +-
src/apps/haikudepot/ui/FeaturedPackagesView.cpp | 3 +-
src/apps/haikudepot/ui/PackageInfoView.cpp | 1 -
src/apps/mediaplayer/interface/DurationView.cpp | 3 +-
src/apps/overlayimage/Jamfile | 2 +
src/apps/overlayimage/OverlayView.cpp | 9 +-
src/kits/app/Application.cpp | 6 +-
src/kits/app/Message.cpp | 11 +
src/kits/interface/ChannelSlider.cpp | 5 +-
src/kits/interface/ColorMap.cpp | 1034 ------------------
src/kits/interface/ColumnListView.cpp | 22 +-
src/kits/interface/InterfaceDefs.cpp | 119 +-
src/kits/interface/Jamfile | 1 -
src/kits/interface/StatusBar.cpp | 7 +-
src/kits/interface/TextControl.cpp | 10 +-
src/kits/interface/View.cpp | 13 +-
src/kits/tracker/InfoWindow.cpp | 3 +-
src/preferences/appearance/APRView.cpp | 70 +-
src/preferences/appearance/APRView.h | 8 +-
.../appearance/AntialiasingSettingsView.cpp | 5 +-
src/preferences/appearance/Colors.cpp | 28 +
src/preferences/appearance/Colors.h | 2 +
.../datatranslations/DataTranslationsWindow.cpp | 4 +-
src/preferences/datatranslations/Jamfile | 2 +-
src/preferences/mail/ConfigWindow.cpp | 7 +-
src/preferences/mail/Jamfile | 2 +-
src/preferences/screen/MonitorView.cpp | 3 +-
src/servers/app/DelayedMessage.cpp | 83 +-
src/servers/app/DelayedMessage.h | 2 +-
src/servers/app/Desktop.cpp | 63 +-
src/servers/app/Desktop.h | 6 +-
src/servers/app/DesktopSettings.cpp | 81 +-
src/servers/app/DesktopSettings.h | 5 +-
src/servers/app/DesktopSettingsPrivate.h | 4 +-
src/servers/app/ServerApp.cpp | 34 -
src/servers/app/ServerWindow.cpp | 1 -

############################################################################

Commit: ae31d18fec90826946765fd7e2e033571dd9f055
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Sun Nov 29 17:34:52 2015 UTC

Style Cleanup

Thanks to Dario Casalinuovo for pointing these out!

----------------------------------------------------------------------------

diff --git a/src/kits/tracker/InfoWindow.cpp b/src/kits/tracker/InfoWindow.cpp
index 2e894e2..0b5bf10 100644
--- a/src/kits/tracker/InfoWindow.cpp
+++ b/src/kits/tracker/InfoWindow.cpp
@@ -320,7 +320,8 @@ BInfoWindow::~BInfoWindow()

BRect
BInfoWindow::InfoWindowRect(bool)
-{ // starting size of window
+{
+ // starting size of window
return BRect(70, 50, 385, 240);
}

diff --git a/src/preferences/appearance/AntialiasingSettingsView.cpp
b/src/preferences/appearance/AntialiasingSettingsView.cpp
index 36cedb6..99792a9 100644
--- a/src/preferences/appearance/AntialiasingSettingsView.cpp
+++ b/src/preferences/appearance/AntialiasingSettingsView.cpp
@@ -117,7 +117,6 @@ AntialiasingSettingsView::AntialiasingSettingsView(const
char* name)
#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
// subpixelAntialiasingDisabledLabel
// TODO: Replace with layout friendly constructor once available.
-// BRect textBounds = Bounds();
fSubpixelAntialiasingDisabledLabel
= new BTextView("unavailable label");
fSubpixelAntialiasingDisabledLabel->SetText(B_TRANSLATE(
diff --git a/src/preferences/mail/ConfigWindow.cpp
b/src/preferences/mail/ConfigWindow.cpp
index 7318058..fe71d1f 100644
--- a/src/preferences/mail/ConfigWindow.cpp
+++ b/src/preferences/mail/ConfigWindow.cpp
@@ -384,7 +384,8 @@ ConfigWindow::_BuildHowToView()
BFont font(be_plain_font);
float fontFactor = font.Size() / 12.0f;

- fHowToTextView->SetExplicitPreferredSize(BSize(300 * fontFactor,400 *
fontFactor));
+ fHowToTextView->SetExplicitPreferredSize(
+ BSize(300 * fontFactor,400 * fontFactor));

rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
fHowToTextView->SetFontAndColor(&font, B_FONT_ALL, &textColor);
diff --git a/src/servers/app/DelayedMessage.cpp
b/src/servers/app/DelayedMessage.cpp
index 98c9a5e..3dd751a 100644
--- a/src/servers/app/DelayedMessage.cpp
+++ b/src/servers/app/DelayedMessage.cpp
@@ -7,17 +7,17 @@
*/


+#include "DelayedMessage.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

-#include <LinkSender.h>
-#include <ServerProtocol.h>
-
#include <Autolock.h>
#include <String.h>

-#include "DelayedMessage.h"
+#include <LinkSender.h>
+#include <ServerProtocol.h>


// DelayedMessageSender constants
@@ -215,8 +215,7 @@ DelayedMessage::Attach(const void* data, size_t size)
if (fHandedOff)
return B_ERROR;

- if (data == NULL
- || size == 0)
+ if (data == NULL || size == 0)
return B_BAD_VALUE;

return fData->Attach(data, size);
diff --git a/src/servers/app/DelayedMessage.h b/src/servers/app/DelayedMessage.h
index 8740cc1..1faf355 100644
--- a/src/servers/app/DelayedMessage.h
+++ b/src/servers/app/DelayedMessage.h
@@ -34,7 +34,7 @@ enum {
};


-//! Convenient delay definitions.
+//! Convenient delay definitions.
enum {
DM_MINIMUM_DELAY = 500ULL,
DM_SHORT_DELAY = 1000ULL,

############################################################################

Commit: bc7c087a22505f2e9278a70eebf0a8abc0558af3
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Sun Nov 29 18:54:51 2015 UTC

Proper encapsulation for DelayedMessageData

Use accessors for data members and make private.

----------------------------------------------------------------------------

diff --git a/src/servers/app/DelayedMessage.cpp
b/src/servers/app/DelayedMessage.cpp
index 3dd751a..dd8139d 100644
--- a/src/servers/app/DelayedMessage.cpp
+++ b/src/servers/app/DelayedMessage.cpp
@@ -126,13 +126,33 @@ public:
bool
MergeData(DelayedMessageData* other);

bool IsValid() const;
- // Only valid after a successful CopyData()
+ // Only valid after a successful CopyData().

status_t Attach(const void*
data, size_t size);

bool Compare(Attachment*
one, Attachment* two,
int32
index);
-public:
+
+ void SetMerge(DMMergeMode
mode, uint32 mask);
+ void SendFailed(port_id
port);
+
+ void
SetFailureCallback(FailureCallback callback,
+ void*
data);
+
+ // Accessors.
+ int32& Code() {return fCode;}
+ const int32& Code() const {return fCode;}
+
+ bigtime_t& ScheduledTime() {return
fScheduledTime;}
+ const bigtime_t& ScheduledTime() const {return
fScheduledTime;}
+
+ AttachmentList& Attachments() {return
fAttachments;}
+ const AttachmentList& Attachments() const {return
fAttachments;}
+
+ PortList& Targets() {return
fTargets;}
+ const PortList& Targets() const {return
fTargets;}
+
+private:
// Data members.

int32 fCode;
@@ -142,7 +162,7 @@ public:
AttachmentList fAttachments;
PortList fTargets;

- uint32 fMergeMode;
+ DMMergeMode fMergeMode;
uint32 fMergeMask;

FailureCallback fFailureCallback;
@@ -188,8 +208,7 @@ DelayedMessage::SetMerge(DMMergeMode mode, uint32 match)
if (fData == NULL || fHandedOff)
return;

- fData->fMergeMode = mode;
- fData->fMergeMask = match;
+ fData->SetMerge(mode, match);
}


@@ -200,8 +219,7 @@ DelayedMessage::SetFailureCallback(void (*callback)(int32,
port_id, void*),
if (fData == NULL || fHandedOff)
return;

- fData->fFailureCallback = callback;
- fData->fFailureData = data;
+ fData->SetFailureCallback(callback, data);
}


@@ -480,6 +498,30 @@ DelayedMessageData::Compare(Attachment* one, Attachment*
two, int32 index)
}


+void
+DelayedMessageData::SetMerge(DMMergeMode mode, uint32 mask)
+{
+ fMergeMode = mode;
+ fMergeMask = mask;
+}
+
+
+void
+DelayedMessageData::SendFailed(port_id port)
+{
+ if (fFailureCallback != NULL)
+ fFailureCallback(fCode, port, fFailureData);
+}
+
+
+void
+DelayedMessageData::SetFailureCallback(FailureCallback callback, void* data)
+{
+ fFailureCallback = callback;
+ fFailureData = data;
+}
+
+
// #pragma mark -


@@ -512,7 +554,7 @@ ScheduledMessage::ScheduledTime() const
if (fData == NULL)
return 0;

- return fData->fScheduledTime;
+ return fData->ScheduledTime();
}


@@ -524,8 +566,8 @@ ScheduledMessage::SendMessage()
return 0;

int32 sent = 0;
- for (int32 index = 0; index < fData->fTargets.CountItems(); ++index) {
- port_id port = *(fData->fTargets.ItemAt(index));
+ for (int32 index = 0; index < fData->Targets().CountItems(); ++index) {
+ port_id port = *(fData->Targets().ItemAt(index));
status_t error = SendMessageToPort(port);

if (error == B_OK) {
@@ -533,8 +575,8 @@ ScheduledMessage::SendMessage()
continue;
}

- if (error != B_TIMED_OUT && fData->fFailureCallback != NULL)
- fData->fFailureCallback(fData->fCode, port,
fData->fFailureData);
+ if (error != B_TIMED_OUT)
+ fData->SendFailed(port);
}

return sent;
@@ -551,10 +593,10 @@ ScheduledMessage::SendMessageToPort(port_id port)
return B_BAD_VALUE;

BPrivate::LinkSender sender(port);
- if (sender.StartMessage(fData->fCode) != B_OK)
+ if (sender.StartMessage(fData->Code()) != B_OK)
return B_ERROR;

- AttachmentList& list = fData->fAttachments;
+ AttachmentList& list = fData->Attachments();
Attachment* attached = NULL;
status_t error = B_OK;

@@ -604,7 +646,7 @@ ScheduledMessage::operator<(const ScheduledMessage& other)
const
if (!IsValid() || !other.IsValid())
return false;

- return fData->fScheduledTime < other.fData->fScheduledTime;
+ return fData->ScheduledTime() < other.fData->ScheduledTime();
}



############################################################################

Commit: cb3e2d51fc03088c6a5752762e007ca4f1f82563
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Mon Dec 7 03:21:30 2015 UTC

Move BColorMap into the private interface headers

This class may or may not be made public in the future, depending upon the
utility
gained by third party applications.

----------------------------------------------------------------------------

diff --git a/headers/os/interface/ColorMap.h
b/headers/private/interface/ColorMap.h
similarity index 100%
rename from headers/os/interface/ColorMap.h
rename to headers/private/interface/ColorMap.h
diff --git a/src/apps/aboutsystem/AboutSystem.cpp
b/src/apps/aboutsystem/AboutSystem.cpp
index 73e260e..041e652 100644
--- a/src/apps/aboutsystem/AboutSystem.cpp
+++ b/src/apps/aboutsystem/AboutSystem.cpp
@@ -22,7 +22,6 @@
#include <AppFileInfo.h>
#include <Application.h>
#include <Bitmap.h>
-#include <ColorMap.h>
#include <DateTimeFormat.h>
#include <DurationFormat.h>
#include <File.h>
@@ -52,6 +51,7 @@

#include <AppMisc.h>
#include <AutoDeleter.h>
+#include <ColorMap.h>
#include <cpu_type.h>
#include <parsedate.h>
#include <system_revision.h>
diff --git a/src/apps/aboutsystem/Jamfile b/src/apps/aboutsystem/Jamfile
index ca23780..8b2354f 100644
--- a/src/apps/aboutsystem/Jamfile
+++ b/src/apps/aboutsystem/Jamfile
@@ -1,6 +1,6 @@
SubDir HAIKU_TOP src apps aboutsystem ;

-UsePrivateHeaders app libroot shared ;
+UsePrivateHeaders app interface libroot shared ;

Application AboutSystem :
AboutSystem.cpp
diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp
index 4e2b33a..46ae50c 100644
--- a/src/apps/deskcalc/CalcView.cpp
+++ b/src/apps/deskcalc/CalcView.cpp
@@ -26,7 +26,6 @@
#include <Beep.h>
#include <Bitmap.h>
#include <Catalog.h>
-#include <ColorMap.h>
#include <ControlLook.h>
#include <Clipboard.h>
#include <File.h>
@@ -40,6 +39,7 @@
#include <Region.h>
#include <Roster.h>

+#include <ColorMap.h>
#include <ExpressionParser.h>

#include "CalcApplication.h"
diff --git a/src/apps/devices/PropertyListPlain.cpp
b/src/apps/devices/PropertyListPlain.cpp
index bf6ce3e..3eaf1b3 100644
--- a/src/apps/devices/PropertyListPlain.cpp
+++ b/src/apps/devices/PropertyListPlain.cpp
@@ -9,7 +9,6 @@

#include "PropertyListPlain.h"

-#include <ColorMap.h>
#include <GridLayout.h>
#include <GridLayoutBuilder.h>
#include <GroupLayout.h>
@@ -20,6 +19,8 @@
#include <StringView.h>
#include <TextView.h>

+#include <ColorMap.h>
+
#include "Device.h"


diff --git a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp
b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp
index 5f2caab..d89275d 100644
--- a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp
+++ b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp
@@ -8,7 +8,6 @@
#include <stdio.h>

#include <Catalog.h>
-#include <ColorMap.h>
#include <Font.h>
#include <LayoutBuilder.h>
#include <Message.h>
@@ -16,6 +15,8 @@
#include <StringView.h>
#include <SpaceLayoutItem.h>

+#include <ColorMap.h>
+
#include "BitmapView.h"
#include "MainWindow.h"
#include "MarkupTextView.h"
diff --git a/src/apps/haikudepot/ui/PackageInfoView.cpp
b/src/apps/haikudepot/ui/PackageInfoView.cpp
index 4a127ee..174e398 100644
--- a/src/apps/haikudepot/ui/PackageInfoView.cpp
+++ b/src/apps/haikudepot/ui/PackageInfoView.cpp
@@ -14,7 +14,6 @@
#include <Button.h>
#include <CardLayout.h>
#include <Catalog.h>
-#include <ColorMap.h>
#include <ColumnListView.h>
#include <Font.h>
#include <GridView.h>
@@ -30,6 +29,7 @@
#include <TabView.h>
#include <Url.h>

+#include <ColorMap.h>
#include <package/hpkg/PackageReader.h>
#include <package/hpkg/NoErrorOutput.h>
#include <package/hpkg/PackageContentHandler.h>
diff --git a/src/apps/mediaplayer/interface/DurationView.cpp
b/src/apps/mediaplayer/interface/DurationView.cpp
index 7f4ddda..2181e25 100644
--- a/src/apps/mediaplayer/interface/DurationView.cpp
+++ b/src/apps/mediaplayer/interface/DurationView.cpp
@@ -6,9 +6,10 @@

#include "DurationView.h"

-#include <ColorMap.h>
#include <LayoutUtils.h>

+#include <ColorMap.h>
+
#include "DurationToString.h"


diff --git a/src/apps/overlayimage/Jamfile b/src/apps/overlayimage/Jamfile
index 3e29501..bcbcd34 100644
--- a/src/apps/overlayimage/Jamfile
+++ b/src/apps/overlayimage/Jamfile
@@ -1,5 +1,7 @@
SubDir HAIKU_TOP src apps overlayimage ;

+UsePrivateHeaders interface ;
+
Application OverlayImage :
OverlayApp.cpp
OverlayView.cpp
diff --git a/src/apps/overlayimage/OverlayView.cpp
b/src/apps/overlayimage/OverlayView.cpp
index be09d7b..7a1e8a4 100644
--- a/src/apps/overlayimage/OverlayView.cpp
+++ b/src/apps/overlayimage/OverlayView.cpp
@@ -14,12 +14,13 @@
#include "OverlayView.h"

#include <Catalog.h>
-#include <ColorMap.h>
#include <InterfaceDefs.h>
#include <Locale.h>
#include <String.h>
#include <TextView.h>

+#include <ColorMap.h>
+
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Main view"

diff --git a/src/kits/interface/ChannelSlider.cpp
b/src/kits/interface/ChannelSlider.cpp
index e118a91..821769f 100644
--- a/src/kits/interface/ChannelSlider.cpp
+++ b/src/kits/interface/ChannelSlider.cpp
@@ -12,13 +12,14 @@
#include <new>

#include <Bitmap.h>
-#include <ColorMap.h>
#include <ControlLook.h>
#include <Debug.h>
#include <PropertyInfo.h>
#include <Screen.h>
#include <Window.h>

+#include <ColorMap.h>
+

const static unsigned char
kVerticalKnobData[] = {
diff --git a/src/kits/interface/ColorMap.cpp b/src/kits/interface/ColorMap.cpp
index d644615..c0d31a6 100644
--- a/src/kits/interface/ColorMap.cpp
+++ b/src/kits/interface/ColorMap.cpp
@@ -12,10 +12,10 @@

#include <Application.h>
#include <Autolock.h>
-#include <ColorMap.h>
#include <Locker.h>
#include <StringList.h>

+#include <ColorMap.h>
#include <ColorMapPrivate.h>
#include <DefaultColors.h>
#include <DesktopLink.h>
diff --git a/src/kits/interface/StatusBar.cpp b/src/kits/interface/StatusBar.cpp
index 8a5d2c7..dbefd01 100644
--- a/src/kits/interface/StatusBar.cpp
+++ b/src/kits/interface/StatusBar.cpp
@@ -16,7 +16,6 @@
#include <stdlib.h>
#include <string.h>

-#include <ColorMap.h>
#include <ControlLook.h>
#include <Layout.h>
#include <LayoutUtils.h>
@@ -24,6 +23,7 @@
#include <Region.h>

#include <binary_compatibility/Interface.h>
+#include <ColorMap.h>

enum internalFlags {
kCustomBarColor = 1
diff --git a/src/kits/interface/TextControl.cpp
b/src/kits/interface/TextControl.cpp
index f0c53ae..921b931 100644
--- a/src/kits/interface/TextControl.cpp
+++ b/src/kits/interface/TextControl.cpp
@@ -17,7 +17,6 @@
#include <string.h>

#include <AbstractLayoutItem.h>
-#include <ColorMap.h>
#include <ControlLook.h>
#include <LayoutUtils.h>
#include <Message.h>
@@ -27,6 +26,7 @@

#include <binary_compatibility/Interface.h>
#include <binary_compatibility/Support.h>
+#include <ColorMap.h>

#include "TextInput.h"

diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp
index b1d686d..ea3e0d0 100644
--- a/src/kits/interface/View.cpp
+++ b/src/kits/interface/View.cpp
@@ -23,7 +23,6 @@
#include <Application.h>
#include <Bitmap.h>
#include <Button.h>
-#include <ColorMap.h>
#include <Cursor.h>
#include <File.h>
#include <GradientLinear.h>
@@ -54,6 +53,7 @@
#include <AppServerLink.h>
#include <binary_compatibility/Interface.h>
#include <binary_compatibility/Support.h>
+#include <ColorMap.h>
#include <MessagePrivate.h>
#include <MessageUtils.h>
#include <PortLink.h>
diff --git a/src/preferences/appearance/APRView.h
b/src/preferences/appearance/APRView.h
index f35eeea..115ea5e 100644
--- a/src/preferences/appearance/APRView.h
+++ b/src/preferences/appearance/APRView.h
@@ -14,7 +14,6 @@

#include <Button.h>
#include <ColorControl.h>
-#include <ColorMap.h>
#include <ListItem.h>
#include <ListView.h>
#include <Menu.h>
@@ -28,6 +27,7 @@
#include <StringView.h>
#include <View.h>

+#include <ColorMap.h>
#include <DecorInfo.h>


diff --git a/src/preferences/appearance/AntialiasingSettingsView.cpp
b/src/preferences/appearance/AntialiasingSettingsView.cpp
index 99792a9..4e97799 100644
--- a/src/preferences/appearance/AntialiasingSettingsView.cpp
+++ b/src/preferences/appearance/AntialiasingSettingsView.cpp
@@ -16,7 +16,6 @@

#include <Box.h>
#include <Catalog.h>
-#include <ColorMap.h>
#include <LayoutBuilder.h>
#include <Locale.h>
#include <MenuField.h>
@@ -27,6 +26,8 @@
#include <String.h>
#include <TextView.h>

+#include <ColorMap.h>
+
#include "APRWindow.h"

#undef B_TRANSLATION_CONTEXT
diff --git a/src/preferences/datatranslations/DataTranslationsWindow.cpp
b/src/preferences/datatranslations/DataTranslationsWindow.cpp
index 3a9f52c..e0195b5 100644
--- a/src/preferences/datatranslations/DataTranslationsWindow.cpp
+++ b/src/preferences/datatranslations/DataTranslationsWindow.cpp
@@ -21,7 +21,6 @@
#include <Bitmap.h>
#include <Box.h>
#include <Catalog.h>
-#include <ColorMap.h>
#include <ControlLook.h>
#include <Entry.h>
#include <GroupView.h>
@@ -37,6 +36,8 @@
#include <TranslationDefs.h>
#include <TranslatorRoster.h>

+#include <ColorMap.h>
+
#include "DataTranslations.h"
#include "DataTranslationsSettings.h"
#include "TranslatorListView.h"
diff --git a/src/preferences/datatranslations/Jamfile
b/src/preferences/datatranslations/Jamfile
index 8c2ef90..adc12d5 100644
--- a/src/preferences/datatranslations/Jamfile
+++ b/src/preferences/datatranslations/Jamfile
@@ -2,7 +2,7 @@ SubDir HAIKU_TOP src preferences datatranslations ;

UseLibraryHeaders lp_solve linprog alm ;

-UsePrivateHeaders shared ;
+UsePrivateHeaders interface shared ;

Preference DataTranslations :
DataTranslations.cpp
diff --git a/src/preferences/mail/ConfigWindow.cpp
b/src/preferences/mail/ConfigWindow.cpp
index fe71d1f..6515e36 100644
--- a/src/preferences/mail/ConfigWindow.cpp
+++ b/src/preferences/mail/ConfigWindow.cpp
@@ -23,7 +23,6 @@
#include <Button.h>
#include <Catalog.h>
#include <CheckBox.h>
-#include <ColorMap.h>
#include <ControlLook.h>
#include <Directory.h>
#include <Entry.h>
@@ -49,6 +48,7 @@
#include <TextControl.h>
#include <TextView.h>

+#include <ColorMap.h>
#include <MailPrivate.h>

#include "AutoConfigWindow.h"
diff --git a/src/preferences/mail/Jamfile b/src/preferences/mail/Jamfile
index 2c1250c..1aa9508 100644
--- a/src/preferences/mail/Jamfile
+++ b/src/preferences/mail/Jamfile
@@ -1,7 +1,7 @@
SubDir HAIKU_TOP src preferences mail ;

UsePublicHeaders [ FDirName add-ons mail_daemon ] ;
-UsePrivateHeaders mail ;
+UsePrivateHeaders interface mail ;

SubDirHdrs [ FDirName $(HAIKU_TOP) headers os add-ons mail_daemon ] ;

diff --git a/src/preferences/screen/MonitorView.cpp
b/src/preferences/screen/MonitorView.cpp
index c58b56b..9a56a61 100644
--- a/src/preferences/screen/MonitorView.cpp
+++ b/src/preferences/screen/MonitorView.cpp
@@ -15,11 +15,12 @@
#include <stdio.h>

#include <Catalog.h>
-#include <ColorMap.h>
#include <Locale.h>
#include <Roster.h>
#include <Screen.h>

+#include <ColorMap.h>
+
#include "Constants.h"

#undef B_TRANSLATION_CONTEXT
diff --git a/src/servers/app/Desktop.h b/src/servers/app/Desktop.h
index 7863037..b853730 100644
--- a/src/servers/app/Desktop.h
+++ b/src/servers/app/Desktop.h
@@ -16,7 +16,6 @@


#include <Autolock.h>
-#include <ColorMap.h>
#include <InterfaceDefs.h>
#include <List.h>
#include <Menu.h>
@@ -24,6 +23,7 @@
#include <Region.h>
#include <Window.h>

+#include <ColorMap.h>
#include <ServerProtocolStructs.h>

#include "CursorManager.h"
diff --git a/src/servers/app/DesktopSettings.h
b/src/servers/app/DesktopSettings.h
index 261ebf0..66aababc2 100644
--- a/src/servers/app/DesktopSettings.h
+++ b/src/servers/app/DesktopSettings.h
@@ -11,11 +11,11 @@
#define DESKTOP_SETTINGS_H


-#include <ColorMap.h>
#include <InterfaceDefs.h>
#include <Menu.h>
#include <Message.h>

+#include <ColorMap.h>
#include <ServerProtocolStructs.h>



############################################################################

Commit: 3704da924219f3f961ad2cd72bc815208553c13e
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Dec 9 20:05:59 2015 UTC

Protect Custom Colors for ColumnListView

Previously it was possible that system color changes would squash custom colors
as set by the application.

----------------------------------------------------------------------------

diff --git a/headers/private/interface/ColumnListView.h
b/headers/private/interface/ColumnListView.h
index 3e12300..5cfdf13 100644
--- a/headers/private/interface/ColumnListView.h
+++ b/headers/private/interface/ColumnListView.h
@@ -63,10 +63,10 @@ class RecursiveOutlineIterator;

} // ns BPrivate

-class BField;
-class BRow;
class BColumn;
class BColumnListView;
+class BField;
+class BRow;

enum LatchType {
B_NO_LATCH = 0,
@@ -353,6 +353,7 @@ public:
// Appearance (NEW STYLE)
void
SetColor(ColumnListViewColor colorIndex,

rgb_color color);
+ void ResetColors();
void
SetFont(ColumnListViewFont fontIndex,
const
BFont* font,
uint32
mask = B_FONT_ALL);
@@ -403,6 +404,7 @@ private:
BRect&
hScrollBarRect);

rgb_color
fColorList[B_COLOR_TOTAL];
+ bool fCustomColors;
BPrivate::TitleView* fTitleView;
BPrivate::OutlineView* fOutlineView;
BList fColumns;
diff --git a/src/kits/interface/ColumnListView.cpp
b/src/kits/interface/ColumnListView.cpp
index 26d5633..2c0ed08 100644
--- a/src/kits/interface/ColumnListView.cpp
+++ b/src/kits/interface/ColumnListView.cpp
@@ -1422,6 +1422,16 @@ BColumnListView::SetColor(ColumnListViewColor
colorIndex, const rgb_color color)
}

fColorList[colorIndex] = color;
+ fCustomColors = true;
+}
+
+
+void
+BColumnListView::ResetColors()
+{
+ fCustomColors = false;
+ _UpdateColors();
+ Invalidate();
}


@@ -1457,6 +1467,7 @@ void
BColumnListView::SetSelectionColor(rgb_color color)
{
fColorList[B_COLOR_SELECTION] = color;
+ fCustomColors = true;
}


@@ -1464,6 +1475,7 @@ void
BColumnListView::SetBackgroundColor(rgb_color color)
{
fColorList[B_COLOR_BACKGROUND] = color;
+ fCustomColors = true;
fOutlineView->Invalidate();
// repaint with new color
}
@@ -1473,6 +1485,7 @@ void
BColumnListView::SetEditColor(rgb_color color)
{
fColorList[B_COLOR_EDIT_BACKGROUND] = color;
+ fCustomColors = true;
}


@@ -1662,10 +1675,7 @@ BColumnListView::MessageReceived(BMessage* message)
return;
}
} else if (message->what == B_COLORS_UPDATED) {
- // TODO: This is inefficient, it would be more efficient to
- // go through the colors in the colormap message and update only
- // the colors that changed using the value already provided in
- // the message.
+ // Todo: Is it worthwhile to optimize this?
_UpdateColors();
}

@@ -2050,6 +2060,7 @@ BColumnListView::_Init()
if (bounds.Height() <= 0)
bounds.bottom = 100;

+ fCustomColors = false;
_UpdateColors();

BRect titleRect;
@@ -2085,6 +2096,9 @@ BColumnListView::_Init()
void
BColumnListView::_UpdateColors()
{
+ if (fCustomColors)
+ return;
+
fColorList[B_COLOR_BACKGROUND] = ui_color(B_LIST_BACKGROUND_COLOR);
fColorList[B_COLOR_TEXT] = ui_color(B_LIST_ITEM_TEXT_COLOR);
fColorList[B_COLOR_ROW_DIVIDER] = tint_color(

############################################################################

Commit: 197e00b750ccd7840a0ad76c786e271c62c52afb
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Thu Dec 10 16:23:35 2015 UTC

Remove BColorMap, add BMessage::Add/Find/*Color()

By adding BMessage::*Color() methods BColorMap's primary purpose was usurped.

Its secondary capabilities have been replaced via the following changes:

Color changes occur during a single, long-held, fAllWindowsLock from the Desktop
thread in the app_server.

Desktop thread now sends notices to clients directly.

void set_ui_colors(const BMessage* colors)
color_which which_ui_color(const char* name);
const char* ui_color_name(color_which which);

Appearance app now uses BMessages to store color states.

----------------------------------------------------------------------------

diff --git a/headers/os/app/Message.h b/headers/os/app/Message.h
index 7d7eab4..077da89 100644
--- a/headers/os/app/Message.h
+++ b/headers/os/app/Message.h
@@ -29,6 +29,7 @@ class BHandler;
class BString;
class BStringList;
struct entry_ref;
+struct rgb_color;


// Name lengths and Scripting specifiers
@@ -154,6 +155,7 @@ public:
status_t AddBool(const char*
name, bool value);
status_t AddFloat(const char*
name, float value);
status_t AddDouble(const char*
name, double value);
+ status_t AddColor(const char*
name, rgb_color value);
status_t AddPointer(const char*
name,
const
void* pointer);
status_t AddMessenger(const
char* name,
@@ -241,6 +243,10 @@ public:
double*
value) const;
status_t FindDouble(const char*
name, int32 index,
double*
value) const;
+ status_t FindColor(const char*
name,
+
rgb_color* value) const;
+ status_t FindColor(const char*
name, int32 index,
+
rgb_color* value) const;
status_t FindPointer(const char*
name,
void**
pointer) const;
status_t FindPointer(const char*
name, int32 index,
@@ -324,6 +330,10 @@ public:
status_t ReplaceDouble(const
char* name, double value);
status_t ReplaceDouble(const
char* name, int32 index,
double
value);
+ status_t ReplaceColor(const
char* name,
+
rgb_color value);
+ status_t ReplaceColor(const
char* name, int32 index,
+
rgb_color value);
status_t ReplacePointer(const
char* name,
const
void* pointer);
status_t ReplacePointer(const
char* name, int32 index,
@@ -379,6 +389,7 @@ public:
bool HasBool(const char*
name, int32 n = 0) const;
bool HasFloat(const char*
name, int32 n = 0) const;
bool HasDouble(const char*
name, int32 n = 0) const;
+ bool HasColor(const char*
name, int32 n = 0) const;
bool HasPointer(const char*
name, int32 n = 0) const;
bool HasMessenger(const
char* name,
int32 n
= 0) const;
@@ -446,6 +457,10 @@ public:
double
defaultValue) const;
double GetDouble(const char*
name, int32 index,
double
defaultValue) const;
+ rgb_color GetColor(const char*
name,
+
rgb_color defaultValue) const;
+ rgb_color GetColor(const char*
name, int32 index,
+
rgb_color defaultValue) const;
const char* GetString(const char*
name,
const
char* defaultValue = NULL) const;
const char* GetString(const char*
name, int32 index,
@@ -477,6 +492,7 @@ public:
status_t SetUInt32(const char*
name, uint32 value);
status_t SetInt64(const char*
name, int64 value);
status_t SetUInt64(const char*
name, uint64 value);
+ status_t SetColor(const char*
name, rgb_color value);
status_t SetPointer(const char*
name, const void* value);
status_t SetString(const char*
name, const char* string);
status_t SetString(const char*
name,
diff --git a/headers/os/interface/InterfaceDefs.h
b/headers/os/interface/InterfaceDefs.h
index 93dee79..99f15c2 100644
--- a/headers/os/interface/InterfaceDefs.h
+++ b/headers/os/interface/InterfaceDefs.h
@@ -11,6 +11,7 @@


class BBitmap;
+class BMessage;
class BPoint;
class BRect;

@@ -467,7 +468,10 @@ void set_accept_first_click(bool
acceptFirstClick);
bool accept_first_click();

rgb_color ui_color(color_which which);
+const char* ui_color_name(color_which which);
+color_which which_ui_color(const char* name);
void set_ui_color(const color_which& which, const rgb_color&
color);
+void set_ui_colors(const BMessage* colors);
rgb_color tint_color(rgb_color color, float tint);

extern "C" status_t _init_interface_kit_();
diff --git a/headers/private/interface/ColorMap.h
b/headers/private/interface/ColorMap.h
deleted file mode 100644
index 28a18b5..0000000
--- a/headers/private/interface/ColorMap.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2015 Haiku, Inc. All rights reserved.
- * Distributed under the terms of the MIT License.
- */
-#ifndef _B_COLOR_MAP
-#define _B_COLOR_MAP
-
-
-#include <Archivable.h>
-#include <InterfaceDefs.h>
-
-
-namespace BPrivate {
- class BColorMapData;
- class BColorMapPrivate;
-};
-
-
-class BColorMap : public BArchivable {
-public:
- BColorMap();
- BColorMap(const
BColorMap& other);
-
BColorMap(BMessage* from);
- virtual ~BColorMap();
-
- virtual status_t Archive(BMessage* into, bool
deep = true) const;
- static BArchivable* Instantiate(BMessage* archive);
-
- // Static methods
-
- static const BColorMap* DefaultColorMap();
- static const BColorMap* CurrentColorMap();
- static status_t SetUIColors(const BColorMap*
colorMap);
-
- static status_t Get(const BMessage* message,
int32 key,
-
rgb_color* color = NULL);
- static status_t Get(const BMessage* message,
color_which which,
-
rgb_color* color = NULL);
- static status_t Get(const BMessage* message,
- const
BString& key,
-
rgb_color* color = NULL);
-
- // Adding and removing colors.
- // Will fail if key currently in use
- status_t Add(int32 key,
rgb_color color);
- status_t Add(color_which which,
rgb_color color);
- status_t Add(const BString& key,
rgb_color color);
- status_t Add(const BColorMap&
ColorMap);
-
- // Will add if key not in use
- status_t Set(int32 key,
rgb_color color);
- status_t Set(color_which which,
rgb_color color);
- status_t Set(const BString& key,
rgb_color color);
- status_t Set(const BColorMap&
ColorMap);
-
- status_t Remove(int32 key);
- status_t Remove(color_which
which);
- status_t Remove(const BString&
key);
- status_t Remove(const BColorMap&
ColorMap);
-
- void MakeEmpty();
-
- // Retrieve colors
- status_t Get(int32 key,
rgb_color* color) const;
- status_t Get(color_which which,
rgb_color* color) const;
- status_t Get(const BString& key,
rgb_color* color) const;
-
- status_t GetNext(int32* index,
BString* key,
-
rgb_color* color);
- // Query
- bool HasColor(int32 key)
const;
- bool HasColor(color_which
which) const;
- bool HasColor(const BString&
key) const;
-
- status_t InitCheck() const;
- int32 CountColors() const;
- bool IsEmpty() const;
-
- void PrintToStream() const;
-
- // operators
- bool operator==(const
BColorMap& other) const;
- bool operator!=(const
BColorMap& other) const;
- BColorMap& operator=(const
BColorMap& other);
-
-private:
- friend class BPrivate::BColorMapPrivate;
- typedef BPrivate::BColorMapData* ColorMap;
-
- bool _GetDataAt(int32 index,
BString* key,
- const
void** data) const;
- void _Init(BMessage* from);
- status_t _InitCopyOnWrite();
- status_t _Set(const BMessage*
message);
- ColorMap _ShareData() const;
-
- ColorMap fData;
- status_t fInitStatus;
-};
-
-
-#endif // _B_COLOR_MAP
diff --git a/headers/private/interface/ColorMapPrivate.h
b/headers/private/interface/ColorMapPrivate.h
deleted file mode 100644
index c335f19..0000000
--- a/headers/private/interface/ColorMapPrivate.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2015, Haiku.
- * Distributed under the terms of the MIT License.
-*/
-#ifndef _B_COLORMAP_PRIVATE_H_
-#define _B_COLORMAP_PRIVATE_H_
-
-
-#include <ColorMap.h>
-#include <Locker.h>
-#include <Message.h>
-#include <Referenceable.h>
-
-
-namespace BPrivate {
-
-
-//! Shared data for BColorMap
-class BColorMapData : public BReferenceable, public BMessage, public BLocker {
-public:
- BColorMapData();
-
BColorMapData(BMessage* from);
-
BColorMapData(const BColorMapData& other);
- virtual ~BColorMapData();
-
- status_t Add(const BString& key,
rgb_color color);
- status_t Add(const BString& key,
const void* color);
- status_t Set(const BString& key,
rgb_color color);
- status_t Set(const BString& key,
const void* color);
-
- void Remove(const BString&
key);
- void RemoveAll();
-
- status_t Send(port_id port,
team_id team, int32 token,
-
bigtime_t timeout = B_INFINITE_TIMEOUT);
-
- // iteration interface for app_server use
- status_t GetNext(int32* cookie,
color_which* key,
-
rgb_color* color);
-
- void SetShared(bool shared);
- bool IsShared() const;
-private:
- bool fIsShared;
-};
-
-
-//! Data acquisition modes
-enum {
- B_CM_SHARE_DATA = 0, // Default - just acquire a reference
- // Copies are made if modifications are made to maps which share
- // data.
-
- B_CM_STEAL_DATA = 1, // Take the data, and reset the colormap
- // The given color map will get a new, clean, data object, and
- // the caller will take ownership of the acquired data.
-
- B_CM_COPY_DATA = 2 // Copy the data, release to destroy
copy
-};
-
-
-//! Provide direct read-only access to private BColorMap data
-class BColorMapPrivate {
-public:
- static BColorMapData* AcquireData(BColorMap& colorMap,
- int32
count = 1,
- uint32
mode = B_CM_SHARE_DATA);
- static void ReleaseData(BColorMapData* data,
- int32
count = 1,
- bool
ensureDestruction = false);
-
- // Update current colormap - if it exists
- static void Update(const BMessage* message);
- static void Update(const color_which& which,
- const
rgb_color& color);
-};
-
-
-}; // end namespace BPrivate
-
-
-#endif //_B_COLORMAP_PRIVATE_H_
diff --git a/src/apps/aboutsystem/AboutSystem.cpp
b/src/apps/aboutsystem/AboutSystem.cpp
index 041e652..93287c9 100644
--- a/src/apps/aboutsystem/AboutSystem.cpp
+++ b/src/apps/aboutsystem/AboutSystem.cpp
@@ -51,7 +51,6 @@

#include <AppMisc.h>
#include <AutoDeleter.h>
-#include <ColorMap.h>
#include <cpu_type.h>
#include <parsedate.h>
#include <system_revision.h>
@@ -672,7 +671,7 @@ AboutView::MessageReceived(BMessage* msg)
switch (msg->what) {
case B_COLORS_UPDATED:
{
- if (BColorMap::Get(msg, B_PANEL_TEXT_COLOR) == B_OK)
+ if (msg->HasColor(ui_color_name(B_PANEL_TEXT_COLOR)) ==
B_OK)
_AdjustTextColors();

break;
diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp
index 46ae50c..560e75d 100644
--- a/src/apps/deskcalc/CalcView.cpp
+++ b/src/apps/deskcalc/CalcView.cpp
@@ -39,7 +39,6 @@
#include <Region.h>
#include <Roster.h>

-#include <ColorMap.h>
#include <ExpressionParser.h>

#include "CalcApplication.h"
@@ -233,7 +232,7 @@ void
CalcView::MessageReceived(BMessage* message)
{
if (message->what == B_COLORS_UPDATED
- && BColorMap::Get(message, B_PANEL_BACKGROUND_COLOR) == B_OK) {
+ && message->HasColor(ui_color_name(B_PANEL_BACKGROUND_COLOR))) {
_Colorize();
return;
}
diff --git a/src/apps/devices/PropertyListPlain.cpp
b/src/apps/devices/PropertyListPlain.cpp
index 3eaf1b3..f8687d5 100644
--- a/src/apps/devices/PropertyListPlain.cpp
+++ b/src/apps/devices/PropertyListPlain.cpp
@@ -19,8 +19,6 @@
#include <StringView.h>
#include <TextView.h>

-#include <ColorMap.h>
-
#include "Device.h"


@@ -87,7 +85,8 @@ PropertyListPlain::MessageReceived(BMessage* message)
case B_COLORS_UPDATED:
{
rgb_color color;
- if (BColorMap::Get(message, B_PANEL_TEXT_COLOR, &color)
!= B_OK)
+ if
(message->FindColor(ui_color_name(B_PANEL_TEXT_COLOR), &color)
+ != B_OK)
break;

BTextView* view = NULL;
diff --git a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp
b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp
index d89275d..ffbb823 100644
--- a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp
+++ b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp
@@ -15,8 +15,6 @@
#include <StringView.h>
#include <SpaceLayoutItem.h>

-#include <ColorMap.h>
-
#include "BitmapView.h"
#include "MainWindow.h"
#include "MarkupTextView.h"
@@ -146,7 +144,7 @@ public:

case B_COLORS_UPDATED:
{
- if (BColorMap::Get(message,
B_LIST_ITEM_TEXT_COLOR) == B_OK)
+ if
(message->HasColor(ui_color_name(B_LIST_ITEM_TEXT_COLOR)))
_UpdateColors();
break;
}
diff --git a/src/apps/haikudepot/ui/PackageInfoView.cpp
b/src/apps/haikudepot/ui/PackageInfoView.cpp
index 174e398..4b4e86a 100644
--- a/src/apps/haikudepot/ui/PackageInfoView.cpp
+++ b/src/apps/haikudepot/ui/PackageInfoView.cpp
@@ -29,7 +29,6 @@
#include <TabView.h>
#include <Url.h>

-#include <ColorMap.h>
#include <package/hpkg/PackageReader.h>
#include <package/hpkg/NoErrorOutput.h>
#include <package/hpkg/PackageContentHandler.h>
diff --git a/src/apps/mediaplayer/interface/DurationView.cpp
b/src/apps/mediaplayer/interface/DurationView.cpp
index 2181e25..08c15f0 100644
--- a/src/apps/mediaplayer/interface/DurationView.cpp
+++ b/src/apps/mediaplayer/interface/DurationView.cpp
@@ -8,8 +8,6 @@

#include <LayoutUtils.h>

-#include <ColorMap.h>
-
#include "DurationToString.h"


@@ -52,7 +50,7 @@ void
DurationView::MessageReceived(BMessage* message)
{
if (message->what == B_COLORS_UPDATED
- && BColorMap::Get(message, B_PANEL_TEXT_COLOR) == B_OK)
+ && message->HasColor(ui_color_name(B_PANEL_TEXT_COLOR)))
_UpdateTextColor();

BStringView::MessageReceived(message);
diff --git a/src/apps/overlayimage/OverlayView.cpp
b/src/apps/overlayimage/OverlayView.cpp
index 7a1e8a4..0e7c33d 100644
--- a/src/apps/overlayimage/OverlayView.cpp
+++ b/src/apps/overlayimage/OverlayView.cpp
@@ -19,7 +19,6 @@
#include <String.h>
#include <TextView.h>

-#include <ColorMap.h>

#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Main view"
@@ -124,10 +123,9 @@ OverlayView::MessageReceived(BMessage *msg)
case B_COLORS_UPDATED:
{
rgb_color color;
- if (BColorMap::Get(msg, B_PANEL_TEXT_COLOR, &color) !=
B_OK)
- break;
-
- fText->SetFontAndColor(be_plain_font, B_FONT_ALL,
&color);
+ if (msg->FindColor(ui_color_name(B_PANEL_TEXT_COLOR),
&color)
+ == B_OK)
+ fText->SetFontAndColor(be_plain_font,
B_FONT_ALL, &color);
break;
}
default:
diff --git a/src/kits/app/Application.cpp b/src/kits/app/Application.cpp
index e603788..c4a21d7 100644
--- a/src/kits/app/Application.cpp
+++ b/src/kits/app/Application.cpp
@@ -39,7 +39,6 @@
#include <AppServerLink.h>
#include <AutoLocker.h>
#include <BitmapPrivate.h>
-#include <ColorMapPrivate.h>
#include <DraggerPrivate.h>
#include <LaunchDaemonDefs.h>
#include <LaunchRoster.h>
@@ -1003,6 +1002,8 @@ BApplication::DispatchMessage(BMessage* message,
BHandler* handler)
return;
}

+ message->PrintToStream();
+
switch (message->what) {
case B_ARGV_RECEIVED:
_ArgvReceived(message);
@@ -1063,9 +1064,6 @@ BApplication::DispatchMessage(BMessage* message,
BHandler* handler)

case B_COLORS_UPDATED:
{
- // Update the current colormap (if we have one)
- BPrivate::BColorMapPrivate::Update(message);
-
AutoLocker<BLooperList> listLock(gLooperList);
if (!listLock.IsLocked())
break;
diff --git a/src/kits/app/Message.cpp b/src/kits/app/Message.cpp
index d182493..eac16f4 100644
--- a/src/kits/app/Message.cpp
+++ b/src/kits/app/Message.cpp
@@ -22,6 +22,7 @@
#include <AppMisc.h>
#include <BlockCache.h>
#include <Entry.h>
+#include <GraphicsDefs.h>
#include <MessageQueue.h>
#include <Messenger.h>
#include <Path.h>
@@ -735,6 +736,14 @@ BMessage::_PrintToStream(const char* indent) const
break;
}

+ case B_RGB_32_BIT_TYPE:
+ {
+ rgb_color* color = (rgb_color*)pointer;
+ printf("rgb_color(%u, %u, %u, %u)\n",
color->red,
+ color->green, color->blue,
color->alpha);
+ break;
+ }
+
default:
{
printf("(type = '%.4s')(size = %ld)\n",
(char*)&value,
@@ -2494,6 +2503,7 @@ DEFINE_FUNCTIONS(uint64, UInt64, B_UINT64_TYPE);
DEFINE_FUNCTIONS(bool, Bool, B_BOOL_TYPE);
DEFINE_FUNCTIONS(float, Float, B_FLOAT_TYPE);
DEFINE_FUNCTIONS(double, Double, B_DOUBLE_TYPE);
+DEFINE_FUNCTIONS(rgb_color, Color, B_RGB_32_BIT_TYPE);

#undef DEFINE_FUNCTIONS

@@ -2577,6 +2587,7 @@ DEFINE_SET_GET_FUNCTIONS(uint64, UInt64, B_UINT64_TYPE);
DEFINE_SET_GET_FUNCTIONS(bool, Bool, B_BOOL_TYPE);
DEFINE_SET_GET_FUNCTIONS(float, Float, B_FLOAT_TYPE);
DEFINE_SET_GET_FUNCTIONS(double, Double, B_DOUBLE_TYPE);
+DEFINE_SET_GET_FUNCTIONS(rgb_color, Color, B_RGB_32_BIT_TYPE);

#undef DEFINE_SET_GET_FUNCTION

diff --git a/src/kits/interface/ChannelSlider.cpp
b/src/kits/interface/ChannelSlider.cpp
index 821769f..bfe893e 100644
--- a/src/kits/interface/ChannelSlider.cpp
+++ b/src/kits/interface/ChannelSlider.cpp
@@ -18,8 +18,6 @@
#include <Screen.h>
#include <Window.h>

-#include <ColorMap.h>
-

const static unsigned char
kVerticalKnobData[] = {
@@ -183,8 +181,10 @@ BChannelSlider::MessageReceived(BMessage* message)
if (message->what == B_COLORS_UPDATED
&& fBacking != NULL && fBackingView != NULL) {
rgb_color color;
- if (BColorMap::Get(message, B_PANEL_BACKGROUND_COLOR, &color)
== B_OK
+ if (message->FindColor(ui_color_name(B_PANEL_BACKGROUND_COLOR),
&color)
+ == B_OK
&& fBacking->Lock()) {
+
if (fBackingView->LockLooper()) {
fBackingView->SetLowColor(color);
fBackingView->UnlockLooper();
diff --git a/src/kits/interface/ColorMap.cpp b/src/kits/interface/ColorMap.cpp
deleted file mode 100644
index c0d31a6..0000000
--- a/src/kits/interface/ColorMap.cpp
+++ /dev/null
@@ -1,1034 +0,0 @@
-/*
- * Copyright 2015, Haiku.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- * Joseph Groover <looncraz@xxxxxxxxxxxx>
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <Application.h>
-#include <Autolock.h>
-#include <Locker.h>
-#include <StringList.h>
-
-#include <ColorMap.h>
-#include <ColorMapPrivate.h>
-#include <DefaultColors.h>
-#include <DesktopLink.h>
-#include <MessagePrivate.h>
-#include <ServerProtocol.h>
-#include <ServerReadOnlyMemory.h>
-
-
-static BLocker be_global_colormap_lock;
-static BColorMap* be_default_colormap = NULL;
-static BColorMap* be_current_colormap = NULL;
-
-static const rgb_color kFailureColor = make_color(0, 0, 0, 0);
-
-
-BColorMap::BColorMap()
- :
- fData(NULL),
- fInitStatus(B_OK)
-{
- _Init(NULL);
-}
-
-
-BColorMap::BColorMap(const BColorMap& other)
- :
- fData(other._ShareData()),
- fInitStatus(B_OK)
-{
- if (fData == NULL)
- fInitStatus = B_BAD_VALUE;
-}
-
-
-BColorMap::BColorMap(BMessage* from)
- :
- fData(NULL),
- fInitStatus(B_OK)
-{
- _Init(from);
-}
-
-
-BColorMap::~BColorMap()
-{
- BAutolock _(be_global_colormap_lock);
- if (this == be_current_colormap)
- be_current_colormap = NULL;
- else if (this == be_default_colormap)
- be_default_colormap = NULL;
-
- // fData will delete itself when not used
- if (fData != NULL)
- fData->ReleaseReference();
-}
-
-
-// #pragma mark Archiving
-
-
-status_t
-BColorMap::Archive(BMessage* into, bool deep) const
-{
- if (InitCheck() != B_OK)
- return fInitStatus;
-
- if (into == NULL)
- return B_BAD_VALUE;
-
- return into->AddMessage("be:colormap", fData);
-}
-
-
-BArchivable*
-BColorMap::Instantiate(BMessage* archive)
-{
- return new(std::nothrow) BColorMap(archive);
-}
-
-
-// #pragma mark Static
-
-
-const BColorMap*
-BColorMap::DefaultColorMap()
-{
- BAutolock _(be_global_colormap_lock);
-
- if (be_default_colormap != NULL)
- return be_default_colormap;
-
- be_default_colormap = new(std::nothrow) BColorMap();
- if (be_default_colormap == NULL) {
- fprintf(stderr, "no memory!\n");
- return NULL;
- }
-
- for (int32 which = 1; which < kColorWhichLastContinuous + 1; ++which) {
- be_default_colormap->Add(which, BPrivate::kDefaultColors[
- color_which_to_index((color_which)which)]);
- }
-
- be_default_colormap->Add((int32)B_SUCCESS_COLOR,
-
BPrivate::kDefaultColors[color_which_to_index(B_SUCCESS_COLOR)]);
- be_default_colormap->Add((int32)B_FAILURE_COLOR,
-
BPrivate::kDefaultColors[color_which_to_index(B_FAILURE_COLOR)]);
-
- return be_default_colormap;
-}
-
-
-const BColorMap*
-BColorMap::CurrentColorMap()
-{
- if (be_app == NULL) {
- printf("BApplication object required to get current color
set!\n");
- return DefaultColorMap();
- }
-
- BAutolock _(be_global_colormap_lock);
-
- // set_ui_color will keep this up-to-date
- if (be_current_colormap != NULL)
- return be_current_colormap;
-
- be_current_colormap = new(std::nothrow) BColorMap();
- if (be_current_colormap == NULL) {
- fprintf(stderr, "no memory!\n");
- return NULL;
- }
-
- for (int32 which = 1; which < kColorWhichLastContinuous + 1; ++which)
- be_current_colormap->Add(which, ui_color((color_which)which));
-
- be_current_colormap->Add((int32)B_SUCCESS_COLOR,
- ui_color(B_SUCCESS_COLOR));
- be_current_colormap->Add((int32)B_FAILURE_COLOR,
- ui_color(B_FAILURE_COLOR));
-
- return be_current_colormap;
-}
-
-
-status_t
-BColorMap::SetUIColors(const BColorMap* colorMap)
-{
- if (colorMap == NULL || colorMap->CountColors() < 0)
- return B_BAD_VALUE;
-
- if (colorMap->CountColors() == 0)
- return B_OK;
-
- BPrivate::DesktopLink desktop;
- if (desktop.InitCheck() != B_OK)
- return B_ERROR;
-
- desktop.StartMessage(AS_SET_UI_COLORS);
- desktop.Attach<bool>(false);
- // false indicates that we aren't flushing Desktop's pending
colormap.
-
- // We do this by searching for known color_which values, rather than
- // iterating through the color-map, so maps can have erroneous entries
- // without us knowing or caring about them. It also has nice error
- // checking, performance, and security advantages - a color map with
- // 1,000+ false entries should not cause issues of any kind.
- rgb_color color;
- int32 count = 0;
- for (int32 key = 1; key <= kColorWhichLastContinuous; ++key) {
- if (colorMap->Get(key, &color) == B_OK) {
- ++count;
- desktop.Attach<color_which>((color_which)key);
- desktop.Attach<rgb_color>(color);
- }
- }
-
- // These colors have special key values
- if (colorMap->Get(B_FAILURE_COLOR, &color) == B_OK) {
- ++count;
- desktop.Attach<color_which>(B_FAILURE_COLOR);
- desktop.Attach<rgb_color>(color);
- }
-
- if (colorMap->Get(B_SUCCESS_COLOR, &color) == B_OK) {
- ++count;
- desktop.Attach<color_which>(B_SUCCESS_COLOR);
- desktop.Attach<rgb_color>(color);
- }
-
- // terminates reading
- desktop.Attach<color_which>(B_NO_COLOR);
- status_t error = desktop.Flush();
-
- if (error != B_OK)
- return error;
-
- return count > 0 ? B_OK : B_ERROR;
-}
-
-
-status_t
-BColorMap::Get(const BMessage* message, int32 key, rgb_color* color)
-{
- BString name;
- name << key;
- return BColorMap::Get(message, name, color);
-}
-
-
-status_t
-BColorMap::Get(const BMessage* message, color_which which, rgb_color* color)
-{
- return BColorMap::Get(message, (int32)which, color);
-}
-
-
-status_t
-BColorMap::Get(const BMessage* message, const BString& key, rgb_color* color)
-{
- if (message == NULL)
- return B_BAD_VALUE;
-
- const void* data = NULL;
- ssize_t size = 0;
- status_t error = message->FindData(key.String(), B_RGB_32_BIT_TYPE,
&data,
- &size);
-
- if (error == B_OK && color != NULL)
- *color = *(rgb_color*)data;
-
- return error;
-}
-
-
-// #pragma mark Add
-
-
-status_t
-BColorMap::Add(int32 key, rgb_color color)
-{
- BString name;
- name << key;
- return Add(name, color);
-}
-
-
-status_t
-BColorMap::Add(color_which which, rgb_color color)
-{
- return Add((int32)which, color);
-}
-
-
-status_t
-BColorMap::Add(const BString& key, rgb_color color)
-{
- status_t writeStatus = _InitCopyOnWrite();
- if (writeStatus != B_OK)
- return writeStatus;
-
- BAutolock _(fData);
-
- if (HasColor(key))
- return B_BAD_INDEX;
-
- return fData->Add(key, color);
-}
-
-
-status_t
-BColorMap::Add(const BColorMap& colorMap)
-{
- status_t writeStatus = _InitCopyOnWrite();
- if (writeStatus != B_OK)
- return writeStatus;
-
- BAutolock _(fData);
-
- // Technically not an error
- if (colorMap.CountColors() == 0)
- return B_OK;
-
- status_t error = B_OK;
- BString key;
- const void* data = NULL;
-
- for (int32 index = 0; index < colorMap.CountColors(); ++index) {
- if (!colorMap._GetDataAt(index, &key, &data))
- return B_BAD_DATA;
-
- error = fData->Add(key, data);
- if (error != B_OK)
- break;
- }
-
- return error;
-}
-
-
-// #pragma mark Set
-
-
-status_t
-BColorMap::Set(int32 key, rgb_color color)
-{
- BString name;
- name << key;
- return Set(name, color);
-}
-
-
-status_t
-BColorMap::Set(color_which which, rgb_color color)
-{
- return Set((int32)which, color);
-}
-
-
-status_t
-BColorMap::Set(const BString& key, rgb_color color)
-{
- status_t writeStatus = _InitCopyOnWrite();
- if (writeStatus != B_OK)
- return writeStatus;
-
- BAutolock _(fData);
-
- return fData->Set(key, color);
-}
-
-
-status_t
-BColorMap::Set(const BColorMap& colorMap)
-{
- status_t writeStatus = _InitCopyOnWrite();
- if (writeStatus != B_OK)
- return writeStatus;
-
- BAutolock _(fData);
-
- // Technically not an error
- if (colorMap.CountColors() == 0)
- return B_OK;
-
- BString key;
- const void* data = NULL;
-
- status_t error = B_OK;
- for (int32 index = 0; index < colorMap.CountColors(); ++index) {
- if (!colorMap._GetDataAt(index, &key, &data))
- return B_BAD_DATA;
-
- error = fData->Set(key, data);
-
- if (error != B_OK)
- break;
- }
-
- return error;
-}
-
-
-// #pragma mark Remove
-
-
-status_t
-BColorMap::Remove(int32 key)
-{
- BString name;
- name << key;
- return Remove(name);
-}
-
-
-status_t
-BColorMap::Remove(color_which which)
-{
- return Remove((int32)which);
-}
-
-
-status_t
-BColorMap::Remove(const BString& key)
-{
- status_t writeStatus = _InitCopyOnWrite();
- if (writeStatus != B_OK)
- return writeStatus;
-
- BAutolock _(fData);
-
- if (!HasColor(key))
- return B_BAD_VALUE;
-
- fData->Remove(key);
- return B_OK;
-}
-
-
-status_t
-BColorMap::Remove(const BColorMap& colorMap)
-{
- status_t writeStatus = _InitCopyOnWrite();
- if (writeStatus != B_OK)
- return writeStatus;
-
- BAutolock _(fData);
-
- if (colorMap.CountColors() == 0)
- return B_OK;
-
- BString key;
- const void* data = NULL;
-
- for (int32 index = 0; index < colorMap.CountColors(); ++index) {
- if (!colorMap._GetDataAt(index, &key, &data))
- return B_BAD_DATA;
-
- fData->Remove(key);
- }
-
- return B_OK;
-}
-
-
-void
-BColorMap::MakeEmpty()
-{
- if (fData != NULL && _InitCopyOnWrite() == B_OK) {
- BAutolock _(fData);
- fData->RemoveAll();
- }
-}
-
-
-// #pragma mark Retrieve
-
-
-status_t
-BColorMap::Get(int32 key, rgb_color* color) const
-{
- BString name;
- name << key;
- return Get(name, color);
-}
-
-
-status_t
-BColorMap::Get(color_which which, rgb_color* color) const
-{
- return Get((int32)which, color);
-}
-
-
-status_t
-BColorMap::Get(const BString& key, rgb_color* color) const
-{
- if (InitCheck() != B_OK)
- return fInitStatus;
-
- BAutolock _(fData);
-
- ssize_t size = 0;
- const void* data = NULL;
- status_t error = fData->FindData(key.String(), B_RGB_32_BIT_TYPE, &data,
- &size);
-
- if (error == B_OK && color != NULL && data != NULL)
- *color = *(rgb_color*)data;
-
- return error;
-}
-
-
-status_t
-BColorMap::GetNext(int32* index, BString* key, rgb_color* color)
-{
- if (index == NULL || key == NULL || *index < 0)
- return B_BAD_VALUE;
-
- if (InitCheck() != B_OK)
- return fInitStatus;
-
- BAutolock _(fData);
-
- const void* data = NULL;
- if (!_GetDataAt(*index, key, &data))
- return B_BAD_INDEX;
-
- if (color != NULL)
- *color = *(rgb_color*)data;
-
- return B_OK;
-}
-
-
-// #pragma mark Query
-
-
-bool
-BColorMap::HasColor(int32 key) const
-{
- BString name;
- name << key;
- return HasColor(name);
-}
-
-
-bool
-BColorMap::HasColor(color_which which) const
-{
- return HasColor((int32)which);
-}
-
-
-bool
-BColorMap::HasColor(const BString& key) const
-{
- if (InitCheck() != B_OK)
- return false;
-
- BAutolock _(fData);
-
- int32 color = 0;
- return fData->FindInt32(key.String(), &color) == B_OK;
-}
-
-
-status_t
-BColorMap::InitCheck() const
-{
- return fInitStatus;
-}
-
-
-int32
-BColorMap::CountColors() const
-{
- if (InitCheck() != B_OK)
- return 0;
-
- BAutolock _(fData);
-
- return fData->CountNames(B_RGB_32_BIT_TYPE);
-}
-
-
-bool
-BColorMap::IsEmpty() const
-{
- return CountColors() == 0;
-}
-
-
-void
-BColorMap::PrintToStream() const
-{
- if (fData == NULL) {
- printf("BColorMap: ERROR: NULL DATA!\n");
- return;
- }
-
- BAutolock _(fData);
-
- printf("BColorMap: %li colors {\n", CountColors());
-
- BString key;
- const rgb_color* color = NULL;
-
- if (fInitStatus != B_OK)
- printf("\tINIT FAILURE: %li\n", fInitStatus);
-
- for (int32 index = 0; index < CountColors(); ++index) {
- if (!_GetDataAt(index, &key, (const void**)&color)) {
- printf("\tError @ index %li\n", index);
- break;
- }
-
- if (color == NULL) {
- printf("\tNULL color data @ index %li\n", index);
- break;
- }
-
- printf("\t%-5li %-20s rgb_color(%3i, %3i, %3i, %3i)\n", index,
- key.String(), color->red, color->green, color->blue,
color->alpha);
- }
- printf("}\n");
-}
-
-
-// #pragma mark Operators
-
-
-bool
-BColorMap::operator==(const BColorMap& other) const
-{
- if (other.CountColors() != CountColors()
- || other.fData == NULL || fData == NULL)
- return false;
-
- // Do we use the same shared data?
- if (other.fData == fData)
- return true;
-
- // Important: the order of colors MUST NOT matter!
- BString key;
- const void* ourData = NULL;
- const void* otherData = NULL;
- ssize_t size = 0;
- int32 index = 0;
- while (_GetDataAt(index++, &key, &ourData)) {
- if (other.fData->FindData(key.String(), B_RGB_32_BIT_TYPE,
&otherData,
- &size) != B_OK
- || ourData == NULL || otherData == NULL ||
- *(rgb_color*)otherData != *(rgb_color*)ourData) {
- return false;
- }
- }
-
- return true;
-}
-
-
-bool
-BColorMap::operator!=(const BColorMap& other) const
-{
- return !(*this == other);
-}
-
-
-BColorMap&
-BColorMap::operator=(const BColorMap& other)
-{
- if (fData != NULL)
- fData->ReleaseReference();
-
- fData = other._ShareData();
- return *this;
-}
-
-
-// #pragma mark Private
-
-
-status_t
-BColorMap::_Set(const BMessage* message)
-{
- status_t writeStatus = _InitCopyOnWrite();
- if (writeStatus != B_OK)
- return writeStatus;
-
- BAutolock _(fData);
-
- int32 count = message->CountNames(B_RGB_32_BIT_TYPE);
- if (count == 0)
- return B_OK;
-
- const void* data = NULL;
- ssize_t size = 0;
- BString key;
-
- // We are only interested in the system color_which constants that this
- // message should contain.
- count = 0;
- for (int32 which = 1; which < kColorWhichLastContinuous + 1; ++which) {
- key.Truncate(0);
- key << which;
-
- if (message->FindData(key.String(), B_RGB_32_BIT_TYPE, &data,
- &size) == B_OK
- && fData->Set(key, data) == B_OK) {
- ++count;
- }
- }
-
- // B_SUCCESS_COLOR
- key.Truncate(0);
- key << B_SUCCESS_COLOR;
- if (message->FindData(key.String(), B_RGB_32_BIT_TYPE, &data,
- &size) == B_OK
- && fData->Set(key, data) == B_OK) {
- ++ count;
- }
-
- // B_FAILURE_COLOR
- key.Truncate(0);
- key << B_FAILURE_COLOR;
- if (message->FindData(key.String(), B_RGB_32_BIT_TYPE, &data,
- &size) == B_OK
- && fData->Set(key, data) == B_OK) {
- ++ count;
- }
-
- return count > 0 ? B_OK : B_ERROR;
-}
-
-
-bool
-BColorMap::_GetDataAt(int32 index, BString* keyOut, const void** data) const
-{
- if (index < 0 || index >= CountColors())
- return false;
-
- char* name = NULL;
- type_code type;
-
- if (fData->GetInfo(B_RGB_32_BIT_TYPE, index, &name, &type) != B_OK)
- return false;
-
- if (keyOut != NULL)
- *keyOut = name;
-
- if (data == NULL)
- return true;
-
- ssize_t size = 0;
- if (fData->FindData(name, B_RGB_32_BIT_TYPE, data, &size) != B_OK)
- return false;
-
- return true;
-}
-
-
-void
-BColorMap::_Init(BMessage* from)
-{
- BMessage archive;
-
- if (from == NULL)
- fData = new(std::nothrow) BPrivate::BColorMapData();
- else if (from->FindMessage("be:colormap", &archive) == B_OK)
- fData = new(std::nothrow) BPrivate::BColorMapData(&archive);
- else
- fData = new(std::nothrow) BPrivate::BColorMapData(from);
-
- if (fData == NULL)
- fInitStatus = B_NO_MEMORY;
-}
-
-
-status_t
-BColorMap::_InitCopyOnWrite()
-{
- // If we can't read, we can't copy for writing...
- if (InitCheck() != B_OK)
- return fInitStatus;
-
- BAutolock _(fData);
-
- if (fData->IsShared()) {
- BPrivate::BColorMapData* newData
- = new(std::nothrow) BPrivate::BColorMapData(*fData);
-
- if (newData == NULL)
- return B_NO_MEMORY;
-
- fData->ReleaseReference();
- fData = newData;
- return B_OK;
- }
-
- return B_OK;
-}
-
-
-BPrivate::BColorMapData*
-BColorMap::_ShareData() const
-{
- BPrivate
- ::BColorMapData* data = const_cast<BPrivate::BColorMapData*>(fData);
-
- data->AcquireReference();
- data->SetShared(true);
- return data;
-}
-
-
-// #pragma mark BColorMapData
-
-
-namespace BPrivate {
-
-
-BColorMapData::BColorMapData()
- :
- BMessage(B_COLORS_UPDATED),
- BLocker("BColorMapData", true),
- fIsShared(false)
-{
-}
-
-
-BColorMapData::BColorMapData(BMessage* message)
- :
- BMessage(*message),
- BLocker("BColorMapData", true),
- fIsShared(false)
-{
- what = B_COLORS_UPDATED;
-}
-
-
-BColorMapData::BColorMapData(const BColorMapData& other)
- :
- BMessage(other),
- BLocker("BColorMapData", true),
- fIsShared(false)
-{
- what = B_COLORS_UPDATED;
-}
-
-
-BColorMapData::~BColorMapData()
-{
-}
-
-
-status_t
-BColorMapData::Add(const BString& key, rgb_color color)
-{
- return Add(key, &color);
-}
-
-
-status_t
-BColorMapData::Add(const BString& key, const void* color)
-{
- if (key == "" || color == NULL)
- return B_BAD_VALUE;
-
- if (HasData(key.String(), B_RGB_32_BIT_TYPE))
- return B_BAD_INDEX;
-
- return AddData(key.String(), B_RGB_32_BIT_TYPE, color,
sizeof(rgb_color));
-}
-
-
-status_t
-BColorMapData::Set(const BString& key, rgb_color color)
-{
- return Set(key, &color);
-}
-
-
-status_t
-BColorMapData::Set(const BString& key, const void* color)
-{
- return SetData(key.String(), B_RGB_32_BIT_TYPE, color,
sizeof(rgb_color));
-}
-
-
-void
-BColorMapData::Remove(const BString& key)
-{
- RemoveName(key.String());
-}
-
-
-void
-BColorMapData::RemoveAll()
-{
- MakeEmpty();
-}
-
-
-status_t
-BColorMapData::Send(port_id port, team_id team, int32 token, bigtime_t timeout)
-{
- if (port < 0 || team < 0 || token == B_NULL_TOKEN)
- return B_BAD_VALUE;
-
- BMessenger reply;
- BMessage::Private messagePrivate(this);
-
- what = B_COLORS_UPDATED;
- return messagePrivate.SendMessage(port, team, token, timeout, false,
- reply);
-}
-
-
-status_t
-BColorMapData::GetNext(int32* cookie, color_which* key, rgb_color* color)
-{
- if (cookie == NULL || key == NULL || color == NULL)
- return B_BAD_VALUE;
-
- char* name = NULL;
- type_code type;
-
- status_t error = GetInfo(B_RGB_32_BIT_TYPE, *cookie, &name, &type);
-
- // increment no matter what, some errors may be ignored by the caller...
- *cookie = *cookie + 1;
-
- if (error != B_OK)
- return error;
-
- const void* data = NULL;
- ssize_t size = 0;
- error = FindData(name, B_RGB_32_BIT_TYPE, &data, &size);
-
- if (error != B_OK)
- return error;
-
- if (key != NULL)
- *key = (color_which)atoi(name);
-
- if (color != NULL)
- *color = *(rgb_color*)data;
-
- return B_OK;
-}
-
-
-void
-BColorMapData::SetShared(bool shared)
-{
- fIsShared = shared;
-}
-
-
-bool
-BColorMapData::IsShared() const
-{
- return fIsShared;
-}
-
-
-// #pragma mark BColorMapPrivate
-
-
-BColorMapData*
-BColorMapPrivate::AcquireData(BColorMap& colorMap, int32 times, uint32
mode)
-{
- if (times < 1)
- return NULL;
-
- BColorMapData* data = colorMap.fData;
- if (data != NULL) {
-
- // Lock the data so it doesn't change, and obtain a reference
so it
- // isn't deleted until we are done. The order here is
important.
- data->AcquireReference();
- BAutolock _(data);
-
- switch (mode) {
- case B_CM_SHARE_DATA:
- break;
- case B_CM_STEAL_DATA:
- {
- BColorMapData* newData = new(std::nothrow)
BColorMapData();
- if (newData == NULL)
- return NULL;
-
- data->ReleaseReference();
- colorMap.fData = newData;
- // release BColorMap's default reference
- break;
- }
- case B_CM_COPY_DATA:
- {
- data = new(std::nothrow)
BColorMapData(*colorMap.fData);
- // starts life with one reference, so
all is good!
-
- if (data == NULL)
- return NULL;
- break;
- }
- }
-
- // acquire the reference(s) (minus the one we already hold)
- // BReferenceable could probably use a facility for this...
- for (int32 count = 0; count < times - 1; ++count)
- data->AcquireReference();
- }
-
- return data;
-}
-
-
-void
-BColorMapPrivate::ReleaseData(BColorMapData* data, int32 times, bool destroy)
-{
- if (data != NULL) {
- if (destroy)
- times = data->ReleaseReference() - 1;
-
- for (int32 count = 0; count < times; ++count)
- data->ReleaseReference();
- }
-}
-
-
-void
-BColorMapPrivate::Update(const BMessage* message)
-{
- if (be_global_colormap_lock.Lock()) {
- if (be_current_colormap != NULL)
- be_current_colormap->_Set(message);
-
- be_global_colormap_lock.Unlock();
- }
-}
-
-
-void
-BColorMapPrivate::Update(const color_which& which, const rgb_color& color)
-{
- if (be_global_colormap_lock.Lock()) {
- if (be_current_colormap != NULL)
- be_current_colormap->Set(which, color);
-
- be_global_colormap_lock.Unlock();
- }
-}
-
-
-}; // end namespace BPrivate
diff --git a/src/kits/interface/InterfaceDefs.cpp
b/src/kits/interface/InterfaceDefs.cpp
index a279d0a..97017b3 100644
--- a/src/kits/interface/InterfaceDefs.cpp
+++ b/src/kits/interface/InterfaceDefs.cpp
@@ -38,7 +38,6 @@
#include <ApplicationPrivate.h>
#include <AppServerLink.h>
#include <ColorConversion.h>
-#include <ColorMapPrivate.h>
#include <DecorInfo.h>
#include <DefaultColors.h>
#include <DesktopLink.h>
@@ -117,6 +116,50 @@ static const rgb_color _kDefaultColors[kColorWhichCount] =
{
const rgb_color* BPrivate::kDefaultColors = &_kDefaultColors[0];


+static const char* kColorNames[kColorWhichCount] = {
+ "B_PANEL_BACKGROUND_COLOR",
+ "B_MENU_BACKGROUND_COLOR",
+ "B_WINDOW_TAB_COLOR",
+ "B_KEYBOARD_NAVIGATION_COLOR",
+ "B_DESKTOP_COLOR",
+ "B_MENU_SELECTED_BACKGROUND_COLOR",
+ "B_MENU_ITEM_TEXT_COLOR",
+ "B_MENU_SELECTED_ITEM_TEXT_COLOR",
+ "B_MENU_SELECTED_BORDER_COLOR",
+ "B_PANEL_TEXT_COLOR",
+ "B_DOCUMENT_BACKGROUND_COLOR",
+ "B_DOCUMENT_TEXT_COLOR",
+ "B_CONTROL_BACKGROUND_COLOR",
+ "B_CONTROL_TEXT_COLOR",
+ "B_CONTROL_BORDER_COLOR",
+ "B_CONTROL_HIGHLIGHT_COLOR",
+ "B_NAVIGATION_PULSE_COLOR",
+ "B_SHINE_COLOR",
+ "B_SHADOW_COLOR",
+ "B_TOOLTIP_BACKGROUND_COLOR",
+ "B_TOOLTIP_TEXT_COLOR",
+ "B_WINDOW_TEXT_COLOR",
+ "B_WINDOW_INACTIVE_TAB_COLOR",
+ "B_WINDOW_INACTIVE_TEXT_COLOR",
+ "B_WINDOW_BORDER_COLOR",
+ "B_WINDOW_INACTIVE_BORDER_COLOR",
+ "B_CONTROL_MARK_COLOR",
+ "B_LIST_BACKGROUND_COLOR",
+ "B_LIST_SELECTED_BACKGROUND_COLOR",
+ "B_LIST_ITEM_TEXT_COLOR",
+ "B_LIST_SELECTED_ITEM_TEXT_COLOR",
+ "B_SCROLL_BAR_THUMB_COLOR",
+ "B_LINK_TEXT_COLOR",
+ "B_LINK_HOVER_COLOR",
+ "B_LINK_VISITED_COLOR",
+ "B_LINK_ACTIVE_COLOR",
+ // 100...
+ "B_SUCCESS_COLOR",
+ "B_FAILURE_COLOR",
+ NULL
+};
+
+
namespace BPrivate {


@@ -1099,6 +1142,38 @@ ui_color(color_which which)
}


+const char*
+ui_color_name(color_which which)
+{
+ // Suppress warnings for B_NO_COLOR.
+ if (which == B_NO_COLOR)
+ return NULL;
+
+ int32 index = color_which_to_index(which);
+ if (index < 0 || index >= kColorWhichCount) {
+ fprintf(stderr, "ui_color_name(): unknown color_which %d\n",
which);
+ return NULL;
+ }
+
+ return kColorNames[index];
+}
+
+
+color_which
+which_ui_color(const char* name)
+{
+ if (name == NULL)
+ return B_NO_COLOR;
+
+ for (int32 index = 0; index < kColorWhichCount; ++index) {
+ if (!strcmp(kColorNames[index], name))
+ return index_to_color_which(index);
+ }
+
+ return B_NO_COLOR;
+}
+
+
void
set_ui_color(const color_which &which, const rgb_color &color)
{
@@ -1116,8 +1191,48 @@ set_ui_color(const color_which &which, const rgb_color
&color)
link.Attach<color_which>(which);
link.Attach<rgb_color>(color);
link.Flush();
+}
+
+
+void
+set_ui_colors(const BMessage* colors)
+{
+ if (colors == NULL)
+ return;
+
+ int32 count = 0;
+ int32 index = 0;
+ char* name = NULL;
+ type_code type;
+ rgb_color color;
+ color_which which = B_NO_COLOR;
+
+ BPrivate::DesktopLink desktop;
+ if (desktop.InitCheck() != B_OK)
+ return;
+
+ desktop.StartMessage(AS_SET_UI_COLORS);
+ desktop.Attach<bool>(false);
+
+ // Only colors with names that map to system colors will get through.
+ while (colors->GetInfo(B_RGB_32_BIT_TYPE, index, &name, &type) == B_OK)
{
+
+ which = which_ui_color(name);
+ ++index;
+
+ if (which == B_NO_COLOR || colors->FindColor(name, &color) !=
B_OK)
+ continue;
+
+ desktop.Attach<color_which>(which);
+ desktop.Attach<rgb_color>(color);
+ ++count;
+ }
+
+ if (count == 0)
+ return;

- BPrivate::BColorMapPrivate::Update(which, color);
+ desktop.Attach<color_which>(B_NO_COLOR);
+ desktop.Flush();
}



[ *** diff truncated: 765 lines dropped *** ]



Other related posts:

  • » [haiku-commits] BRANCH looncraz-github.setviewuicolor [197e00b750cc] src/kits/interface src/servers/app src/preferences/appearance headers/os/interface src - looncraz-github . setviewuicolor