* Removed ColorSet, it's no longer needed or used.

* The Decorator are temporarily using ui_color() - this needs to be changed
  to use the DesktopSettings (when the decorator stuff gets refactored); right
  now, the colors are fixed.
* Added B_WINDOW_TEXT_COLOR, B_WINDOW_INACTIVE_TAB_COLOR, and
  B_WINDOW_INACTIVE_TEXT_COLOR to the UI colors, B_WINDOW_TAB_COLOR is no
  longer deprecated. Note, however, that not every decorator may use these
  colors.
* Removed unused and wrong (ie. hard-coded paths) stuff from ServerConfig.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17236 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-04-26 09:03:28 +00:00
parent 649ddde05f
commit 23ae77aa56
17 changed files with 44 additions and 826 deletions

View File

@ -312,27 +312,31 @@ enum color_which {
B_NAVIGATION_PULSE_COLOR = 17,
B_SHINE_COLOR = 18,
B_SHADOW_COLOR = 19,
B_MENU_BACKGROUND_COLOR = 2,
B_MENU_SELECTED_BACKGROUND_COLOR = 6,
B_MENU_ITEM_TEXT_COLOR = 7,
B_MENU_SELECTED_ITEM_TEXT_COLOR = 8,
B_MENU_SELECTED_BORDER_COLOR = 9,
B_TOOLTIP_BACKGROUND_COLOR = 20,
B_TOOLTIP_TEXT_COLOR = 21,
B_SUCCESS_COLOR = 100,
B_FAILURE_COLOR = 101,
// Old name synonyms.
B_KEYBOARD_NAVIGATION_COLOR = B_NAVIGATION_BASE_COLOR,
B_MENU_SELECTION_BACKGROUND_COLOR = B_MENU_SELECTED_BACKGROUND_COLOR,
// These are deprecated -- do not use in new code. See BScreen for
// the replacement for B_DESKTOP_COLOR.
B_DESKTOP_COLOR = 5,
B_WINDOW_TAB_COLOR = 3,
B_WINDOW_TEXT_COLOR = 22,
B_WINDOW_INACTIVE_TAB_COLOR = 23,
B_WINDOW_INACTIVE_TEXT_COLOR = 24,
};
_IMPEXP_BE rgb_color ui_color(color_which which);

View File

@ -23,10 +23,11 @@ struct server_read_only_memory {
static inline int32
color_which_to_index(color_which which)
{
if (which <= B_TOOLTIP_TEXT_COLOR)
// NOTE: this must be kept in sync with InterfaceDefs.h color_which!
if (which <= B_WINDOW_INACTIVE_TEXT_COLOR)
return which - 1;
if (which >= B_SUCCESS_COLOR && which <= B_FAILURE_COLOR)
return which - B_SUCCESS_COLOR + B_TOOLTIP_TEXT_COLOR;
return which - B_SUCCESS_COLOR + B_WINDOW_INACTIVE_TEXT_COLOR;
return -1;
}

View File

@ -61,7 +61,7 @@ extern "C" const char B_NOTIFICATION_SENDER[] = "be:sender";
static const rgb_color _kDefaultColors[kNumColors] = {
{216, 216, 216, 255}, // B_PANEL_BACKGROUND_COLOR
{216, 216, 216, 255}, // B_MENU_BACKGROUND_COLOR
{255, 0, 203, 255}, // B_WINDOW_TAB_COLOR
{255, 203, 0, 255}, // B_WINDOW_TAB_COLOR
{0, 0, 229, 255}, // B_KEYBOARD_NAVIGATION_COLOR
{51, 102, 152, 255}, // B_DESKTOP_COLOR
{115, 120, 184, 255}, // B_MENU_SELECTED_BACKGROUND_COLOR
@ -80,6 +80,9 @@ static const rgb_color _kDefaultColors[kNumColors] = {
{0, 0, 0, 255}, // B_SHADOW_COLOR
{255, 255, 0, 255}, // B_TOOLTIP_BACKGROUND_COLOR
{0, 0, 0, 255}, // B_TOOLTIP_TEXT_COLOR
{0, 0, 0, 255}, // B_WINDOW_TEXT_COLOR
{232, 232, 232, 255}, // B_WINDOW_INACTIVE_TAB_COLOR
{80, 80, 80, 255}, // B_WINDOW_INACTIVE_TEXT_COLOR
// 100...
{0, 255, 0, 255}, // B_SUCCESS_COLOR
{255, 0, 0, 255}, // B_FAILURE_COLOR

View File

@ -12,7 +12,6 @@
#include "AppServer.h"
#include "BitmapManager.h"
#include "ColorSet.h"
#include "Desktop.h"
#include "FontManager.h"
#include "InputManager.h"
@ -37,9 +36,6 @@ port_id gAppServerPort;
static AppServer *sAppServer;
BTokenSpace gTokenSpace;
//! System-wide GUI color object
ColorSet gGUIColorSet;
/*!
\brief Constructor
@ -70,11 +66,6 @@ AppServer::AppServer()
gFontManager->Run();
// Load the GUI colors here and set the global set to the values contained therein. If this
// is not possible, set colors to the defaults
if (ColorSet::LoadColorSet(SERVER_SETTINGS_DIR COLOR_SETTINGS_NAME, &gGUIColorSet) != B_OK)
gGUIColorSet.SetToDefaults();
gScreenManager = new ScreenManager();
gScreenManager->Run();

View File

@ -22,7 +22,6 @@
class ServerApp;
class BitmapManager;
class ColorSet;
class Desktop;
using BPrivate::BTokenSpace;
@ -56,7 +55,6 @@ class AppServer : public MessageLooper {
};
extern BitmapManager *gBitmapManager;
extern ColorSet gGUIColorSet;
extern port_id gAppServerPort;
#endif /* APP_SERVER_H */

View File

@ -1,594 +0,0 @@
/*
* Copyright 2001-2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <bpmagic@columbus.rr.com>
* Stephan Aßmus <superstippi@gmx.de>
*/
/** Class for encapsulating GUI system colors */
#include <stdio.h>
#include <InterfaceDefs.h>
#include <Message.h>
#include <File.h>
#include <Entry.h>
#include <Directory.h>
#include <String.h>
#include "ColorSet.h"
#include "ServerConfig.h"
static void
set_rgb_color(rgb_color& color, uint8 red, uint8 green, uint8 blue)
{
color.red = red;
color.green = green;
color.blue = blue;
color.alpha = 255;
}
// #pragma mark -
ColorSet::ColorSet()
{
}
/*!
\brief Copy constructor which does a massive number of assignments
\param cs Color set to copy from
*/
ColorSet::ColorSet(const ColorSet &cs)
{
SetColors(cs);
}
/*!
\brief Overloaded assignment operator which does a massive number of assignments
\param cs Color set to copy from
\return The new values assigned to the color set
*/
ColorSet &
ColorSet::operator=(const ColorSet &cs)
{
SetColors(cs);
return *this;
}
/*!
\brief Copy function which handles assignments,
and, yes, *IT EVEN MAKES french fries!!*
\param cs Color set to copy from
*/
void
ColorSet::SetColors(const ColorSet &cs)
{
panel_background=cs.panel_background;
panel_text=cs.panel_text;
document_background=cs.document_background;
document_text=cs.document_text;
control_background=cs.control_background;
control_text=cs.control_text;
control_highlight=cs.control_highlight;
control_border=cs.control_border;
tooltip_background=cs.tooltip_background;
tooltip_text=cs.tooltip_text;
menu_background=cs.menu_background;
menu_selected_background=cs.menu_selected_background;
menu_text=cs.menu_text;
menu_selected_text=cs.menu_selected_text;
menu_selected_border=cs.menu_selected_border;
keyboard_navigation_base=cs.keyboard_navigation_base;
keyboard_navigation_pulse=cs.keyboard_navigation_pulse;
success=cs.success;
failure=cs.failure;
shine=cs.shine;
shadow=cs.shadow;
window_tab=cs.window_tab;
window_tab_text=cs.window_tab_text;
inactive_window_tab=cs.inactive_window_tab;
inactive_window_tab_text=cs.inactive_window_tab_text;
}
//! Prints all color set elements to stdout
void
ColorSet::PrintToStream(void) const
{
printf("panel_background "); PrintMember(panel_background);
printf("panel_text "); PrintMember(panel_text);
printf("document_background "); PrintMember(document_background);
printf("document_text "); PrintMember(document_text);
printf("control_background "); PrintMember(control_background);
printf("control_text "); PrintMember(control_text);
printf("control_highlight "); PrintMember(control_highlight);
printf("control_border "); PrintMember(control_border);
printf("tooltip_background "); PrintMember(tooltip_background);
printf("tooltip_text "); PrintMember(tooltip_text);
printf("menu_background "); PrintMember(menu_background);
printf("menu_selected_background "); PrintMember(menu_selected_background);
printf("menu_text "); PrintMember(menu_text);
printf("menu_selected_text "); PrintMember(menu_selected_text);
printf("menu_selected_border "); PrintMember(menu_selected_border);
printf("keyboard_navigation_base "); PrintMember(keyboard_navigation_base);
printf("keyboard_navigation_pulse "); PrintMember(keyboard_navigation_pulse);
printf("success "); PrintMember(success);
printf("failure "); PrintMember(failure);
printf("shine "); PrintMember(shine);
printf("shadow "); PrintMember(shadow);
printf("window_tab "); PrintMember(window_tab);
printf("window_tab_text "); PrintMember(window_tab_text);
printf("inactive_window_tab "); PrintMember(inactive_window_tab);
printf("inactive_window_tab_text "); PrintMember(inactive_window_tab_text);
}
/*!
\brief Assigns the default system colors to the passed ColorSet object
\param set The ColorSet object to set to defaults
*/
void
ColorSet::SetToDefaults(void)
{
#ifdef DEBUG_COLORSET
printf("Initializing color settings to defaults\n");
#endif
set_rgb_color(panel_background, 216, 216, 216);
set_rgb_color(panel_text, 0, 0, 0);
set_rgb_color(document_background, 255, 255, 255);
set_rgb_color(document_text, 0, 0, 0);
set_rgb_color(control_background, 245, 245, 245);
set_rgb_color(control_text, 0, 0, 0);
set_rgb_color(control_border, 0, 0, 0);
set_rgb_color(control_highlight, 102, 152, 203);
set_rgb_color(keyboard_navigation_base, 0, 0, 229);
set_rgb_color(keyboard_navigation_pulse, 0, 0, 0);
set_rgb_color(shine, 255, 255, 255);
set_rgb_color(shadow, 0, 0, 0);
set_rgb_color(menu_background, 216, 216, 216);
set_rgb_color(menu_selected_background, 115, 120, 184);
set_rgb_color(menu_text, 0, 0, 0);
set_rgb_color(menu_selected_text, 255, 255, 255);
set_rgb_color(menu_selected_border, 0, 0, 0);
set_rgb_color(tooltip_background, 255, 255, 0);
set_rgb_color(tooltip_text, 0, 0, 0);
set_rgb_color(success, 0, 255, 0);
set_rgb_color(failure, 255, 0, 0);
set_rgb_color(window_tab, 255, 203, 0);
set_rgb_color(window_tab_text, 0, 0, 0);
set_rgb_color(inactive_window_tab, 232, 232, 232);
set_rgb_color(inactive_window_tab_text, 80, 80, 80);
}
/*!
\brief Attaches the color set's members as data to the given BMessage
\param msg The message to receive the attributes
*/
bool
ColorSet::ConvertToMessage(BMessage *msg) const
{
if(!msg)
return false;
msg->MakeEmpty();
msg->AddData("Panel Background",(type_code)'RGBC',&panel_background,
sizeof(rgb_color) );
msg->AddData("Panel Text",(type_code)'RGBC',&panel_text,sizeof(rgb_color));
msg->AddData("Document Background",(type_code)'RGBC',&document_background,
sizeof(rgb_color));
msg->AddData("Document Text",(type_code)'RGBC',&document_text,sizeof(rgb_color));
msg->AddData("Control Background",(type_code)'RGBC',&control_background,
sizeof(rgb_color));
msg->AddData("Control Text",(type_code)'RGBC',&control_text,sizeof(rgb_color));
msg->AddData("Control Highlight",(type_code)'RGBC',&control_highlight,
sizeof(rgb_color));
msg->AddData("Control Border",(type_code)'RGBC',&control_border,sizeof(rgb_color));
msg->AddData("Tooltip Background",(type_code)'RGBC',&tooltip_background,
sizeof(rgb_color));
msg->AddData("Tooltip Text",(type_code)'RGBC',&tooltip_text,sizeof(rgb_color));
msg->AddData("Menu Background",(type_code)'RGBC',&menu_background,
sizeof(rgb_color));
msg->AddData("Selected Menu Item Background",(type_code)'RGBC',&menu_selected_background,
sizeof(rgb_color));
msg->AddData("Keyboard Navigation Base",(type_code)'RGBC',&keyboard_navigation_base,
sizeof(rgb_color));
msg->AddData("Keyboard Navigation Pulse",(type_code)'RGBC',
&keyboard_navigation_pulse,sizeof(rgb_color));
msg->AddData("Menu Item Text",(type_code)'RGBC',&menu_text,sizeof(rgb_color));
msg->AddData("Selected Menu Item Text",(type_code)'RGBC',&menu_selected_text,
sizeof(rgb_color));
msg->AddData("Selected Menu Item Border",(type_code)'RGBC',&menu_selected_border,
sizeof(rgb_color));
msg->AddData("Success",(type_code)'RGBC',&success,sizeof(rgb_color));
msg->AddData("Failure",(type_code)'RGBC',&failure,sizeof(rgb_color));
msg->AddData("Shine",(type_code)'RGBC',&shine,sizeof(rgb_color));
msg->AddData("Shadow",(type_code)'RGBC',&shadow,sizeof(rgb_color));
msg->AddData("Window Tab",(type_code)'RGBC',&window_tab,sizeof(rgb_color));
msg->AddData("Window Tab Text",(type_code)'RGBC',&window_tab_text,
sizeof(rgb_color));
msg->AddData("Inactive Window Tab",(type_code)'RGBC',&inactive_window_tab,
sizeof(rgb_color));
msg->AddData("Inactive Window Tab Text",(type_code)'RGBC',
&inactive_window_tab_text,sizeof(rgb_color));
return true;
}
/*!
\brief Assigns values to the color set's members based on values in the BMessage
\param msg The message containing the data for the color set's colors
*/
bool
ColorSet::ConvertFromMessage(const BMessage *msg)
{
if(!msg)
return false;
rgb_color *col;
ssize_t size;
BString str;
if(msg->FindData("Panel Background",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
panel_background=*col;
if(msg->FindData("Panel Text",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
panel_text=*col;
if(msg->FindData("Document Background",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
document_background=*col;
if(msg->FindData("Document Text",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
document_text=*col;
if(msg->FindData("Control Background",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
control_background=*col;
if(msg->FindData("Control Text",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
control_text=*col;
if(msg->FindData("Control Highlight",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
control_highlight=*col;
if(msg->FindData("Control Border",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
control_border=*col;
if(msg->FindData("Tooltip Background",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
tooltip_background=*col;
if(msg->FindData("Tooltip Text",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
tooltip_text=*col;
if(msg->FindData("Menu Background",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
menu_background=*col;
if(msg->FindData("Selected Menu Item Background",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
menu_selected_background=*col;
if(msg->FindData("Navigation Base",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
keyboard_navigation_base=*col;
if(msg->FindData("Navigation Pulse",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
keyboard_navigation_pulse=*col;
if(msg->FindData("Menu Item Text",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
menu_text=*col;
if(msg->FindData("Selected Menu Item Text",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
menu_selected_text=*col;
if(msg->FindData("Selected Menu Item Border",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
menu_selected_border=*col;
if(msg->FindData("Success",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
success=*col;
if(msg->FindData("Failure",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
failure=*col;
if(msg->FindData("Shine",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
shine=*col;
if(msg->FindData("Shadow",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
shadow=*col;
if(msg->FindData("Window Tab",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
window_tab=*col;
if(msg->FindData("Window Tab Text",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
window_tab_text=*col;
if(msg->FindData("Inactive Window Tab",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
inactive_window_tab=*col;
if(msg->FindData("Inactive Window Tab Text",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
inactive_window_tab_text=*col;
return true;
}
/*!
\brief Assigns a value to a named color member
\param string name of the color to receive the value
\param value An rgb_color which is the new value of the member
*/
status_t
ColorSet::SetColor(const char *string, rgb_color value)
{
if(!string)
return B_BAD_VALUE;
rgb_color *col=StringToMember(string);
if(!col)
return B_NAME_NOT_FOUND;
*col=value;
return B_OK;
}
/*!
\brief Obtains a color based on a specified string
\param string name of the color to obtain
\return The set's color or (0,0,0,0) if not found
*/
rgb_color
ColorSet::StringToColor(const char *string)
{
rgb_color *col=StringToMember(string);
if(!col)
{
rgb_color c;
return c;
}
return *col;
}
/*!
\brief Obtains the set's color member based on a specified string
\param string name of the color member to obtain
\return An RGBColor pointer or NULL if not found
*/
rgb_color *
ColorSet::StringToMember(const char *string)
{
if(!string)
return NULL;
if(strcmp(string,"Panel Background")==0)
return &panel_background;
if(strcmp(string,"Panel Text")==0)
return &panel_text;
if(strcmp(string,"Document Background")==0)
return &document_background;
if(strcmp(string,"Document Text")==0)
return &document_text;
if(strcmp(string,"Control Background")==0)
return &control_background;
if(strcmp(string,"Control Text")==0)
return &control_text;
if(strcmp(string,"Control Highlight")==0)
return &control_highlight;
if(strcmp(string,"Control Border")==0)
return &control_border;
if(strcmp(string,"Tooltip Background")==0)
return &tooltip_background;
if(strcmp(string,"Tooltip Text")==0)
return &tooltip_text;
if(strcmp(string,"Menu Background")==0)
return &menu_background;
if(strcmp(string,"Selected Menu Item Background")==0)
return &menu_selected_background;
if(strcmp(string,"Navigation Base")==0)
return &keyboard_navigation_base;
if(strcmp(string,"Navigation Pulse")==0)
return &keyboard_navigation_pulse;
if(strcmp(string,"Menu Item Text")==0)
return &menu_text;
if(strcmp(string,"Selected Menu Item Text")==0)
return &menu_selected_text;
if(strcmp(string,"Selected Menu Item Border")==0)
return &menu_selected_border;
if(strcmp(string,"Success")==0)
return &success;
if(strcmp(string,"Failure")==0)
return &failure;
if(strcmp(string,"Shine")==0)
return &shine;
if(strcmp(string,"Shadow")==0)
return &shadow;
if(strcmp(string,"Window Tab")==0)
return &window_tab;
if(strcmp(string,"Window Tab Text")==0)
return &window_tab_text;
if(strcmp(string,"Inactive Window Tab")==0)
return &inactive_window_tab;
if(strcmp(string,"Inactive Window Tab Text")==0)
return &inactive_window_tab_text;
return NULL;
}
rgb_color
ColorSet::AttributeToColor(int32 which)
{
switch(which)
{
case B_PANEL_BACKGROUND_COLOR:
{
return panel_background;
break;
}
case B_PANEL_TEXT_COLOR:
{
return panel_text;
break;
}
case B_DOCUMENT_BACKGROUND_COLOR:
{
return document_background;
break;
}
case B_DOCUMENT_TEXT_COLOR:
{
return document_text;
break;
}
case B_CONTROL_BACKGROUND_COLOR:
{
return control_background;
break;
}
case B_CONTROL_TEXT_COLOR:
{
return control_text;
break;
}
case B_CONTROL_BORDER_COLOR:
{
return control_border;
break;
}
case B_CONTROL_HIGHLIGHT_COLOR:
{
return control_highlight;
break;
}
case B_NAVIGATION_BASE_COLOR:
{
return keyboard_navigation_base;
break;
}
case B_NAVIGATION_PULSE_COLOR:
{
return keyboard_navigation_pulse;
break;
}
case B_SHINE_COLOR:
{
return shine;
break;
}
case B_SHADOW_COLOR:
{
return shadow;
break;
}
case B_MENU_BACKGROUND_COLOR:
{
return menu_background;
break;
}
case B_MENU_SELECTED_BACKGROUND_COLOR:
{
return menu_selected_background;
break;
}
case B_MENU_ITEM_TEXT_COLOR:
{
return menu_text;
break;
}
case B_MENU_SELECTED_ITEM_TEXT_COLOR:
{
return menu_selected_text;
break;
}
case B_MENU_SELECTED_BORDER_COLOR:
{
return menu_selected_border;
break;
}
case B_TOOLTIP_BACKGROUND_COLOR:
{
return tooltip_background;
break;
}
case B_TOOLTIP_TEXT_COLOR:
{
return tooltip_text;
break;
}
case B_SUCCESS_COLOR:
{
return success;
break;
}
case B_FAILURE_COLOR:
{
return failure;
break;
}
case B_WINDOW_TAB_COLOR:
{
return window_tab;
break;
}
// DANGER! DANGER, WILL ROBINSON!!
// These are magic numbers to work around compatibility difficulties while still keeping
// functionality. This __will__ break following R1
case 22:
{
return window_tab_text;
break;
}
case 23:
{
return inactive_window_tab;
break;
}
case 24:
{
return inactive_window_tab_text;
break;
}
default:
{
rgb_color c;
return c;
break;
}
}
}
void
ColorSet::PrintMember(const rgb_color &color) const
{
printf("rgb_color(%d, %d, %d, %d)", color.red,color.green,color.blue,color.alpha);
}
/*!
\brief Loads the saved system colors into a ColorSet
\param set the set to receive the system colors
\return B_OK if successful. See BFile for other error codes
*/
status_t
ColorSet::LoadColorSet(const char *path, ColorSet *set)
{
BFile file(path,B_READ_ONLY);
if (file.InitCheck()!=B_OK)
return file.InitCheck();
BMessage msg;
status_t status = msg.Unflatten(&file);
if (status != B_OK)
return status;
set->ConvertFromMessage(&msg);
return B_OK;
}
/*!
\brief Saves the saved system colors into a flattened BMessage
\param set ColorSet containing the colors to save
\return B_OK if successful. See BFile for other error codes
*/
status_t
ColorSet::SaveColorSet(const char *path, const ColorSet &set)
{
BFile file(path, B_READ_WRITE | B_ERASE_FILE | B_CREATE_FILE);
status_t status = file.InitCheck();
if (status != B_OK)
return status;
BMessage msg;
set.ConvertToMessage(&msg);
return msg.Flatten(&file);
}

View File

@ -1,85 +0,0 @@
/*
* Copyright 2001-2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <bpmagic@columbus.rr.com>
*/
#ifndef COLOR_SET_H
#define COLOR_SET_H
#include <InterfaceDefs.h>
#include <Locker.h>
#include <Message.h>
#include <String.h>
/*!
\class ColorSet ColorSet.h
\brief Encapsulates GUI system colors
*/
class ColorSet : public BLocker {
public:
ColorSet();
ColorSet(const ColorSet &cs);
ColorSet & operator=(const ColorSet &cs);
void SetColors(const ColorSet &cs);
void PrintToStream(void) const;
bool ConvertToMessage(BMessage *msg) const;
bool ConvertFromMessage(const BMessage *msg);
void SetToDefaults(void);
rgb_color StringToColor(const char *string);
rgb_color AttributeToColor(int32 which);
status_t SetColor(const char *string, rgb_color value);
static status_t LoadColorSet(const char *path, ColorSet *set);
static status_t SaveColorSet(const char *path, const ColorSet &set);
rgb_color panel_background,
panel_text,
document_background,
document_text,
control_background,
control_text,
control_highlight,
control_border,
tooltip_background,
tooltip_text,
menu_background,
menu_selected_background,
menu_text,
menu_selected_text,
menu_selected_border,
keyboard_navigation_base,
keyboard_navigation_pulse,
success,
failure,
shine,
shadow,
window_tab,
// Not all of these guys do exist in InterfaceDefs.h,
// but we keep them as part of the color set anyway -
// they're important nonetheless
window_tab_text,
inactive_window_tab,
inactive_window_tab_text;
private:
rgb_color *StringToMember(const char *string);
void PrintMember(const rgb_color &color) const;
};
#endif // COLOR_SET_H

View File

@ -396,7 +396,7 @@ CursorManager::SetDefaults()
cursorSet.AddCursor(B_CURSOR_RESIZE_NESW, default_resize_nesw_data);
cursorSet.AddCursor(B_CURSOR_RESIZE_NS, default_resize_ns_data);
cursorSet.AddCursor(B_CURSOR_RESIZE_EW, default_resize_ew_data);
#if 0
BDirectory dir;
if (dir.SetTo(CURSOR_SET_DIR) == B_ENTRY_NOT_FOUND)
create_directory(CURSOR_SET_DIR, 0777);
@ -406,6 +406,7 @@ CursorManager::SetDefaults()
cursorSet.Save(string.String(), B_CREATE_FILE | B_FAIL_IF_EXISTS);
SetCursorSet(string.String());
#endif
Unlock();
}

View File

@ -14,7 +14,6 @@
#include <Rect.h>
#include "AppServer.h"
#include "ColorSet.h"
#include "DefaultDecorator.h"
#include "Desktop.h"
#include "DesktopSettings.h"
@ -88,13 +87,8 @@ DecorInfo::Instantiate(Desktop* desktop, BRect rect, const char *title,
}
decorator->SetDriver(desktop->GetDrawingEngine());
gGUIColorSet.Lock();
decorator->SetColors(gGUIColorSet);
gGUIColorSet.Unlock();
decorator->SetTitle(title);
return decorator;
}
@ -111,6 +105,7 @@ DecorManager::DecorManager()
DecorInfo *defaultDecor = new DecorInfo(-1, "Default", NULL);
fDecorList.AddItem(defaultDecor);
#if 0
// Add any on disk
RescanDecorators();
@ -129,7 +124,7 @@ DecorManager::DecorManager()
fCurrentDecor = _FindDecor(itemtext.String());
}
}
#endif
if (!fCurrentDecor)
fCurrentDecor = (DecorInfo*)fDecorList.ItemAt(0L);
}

View File

@ -9,7 +9,6 @@
/** Base class for window decorators */
#include "ColorSet.h"
#include "Decorator.h"
#include "DrawingEngine.h"
@ -31,7 +30,6 @@
Decorator::Decorator(DesktopSettings& settings, BRect rect,
window_look look, uint32 flags)
:
_colors(new ColorSet()),
_driver(NULL),
fDrawState(),
@ -62,19 +60,6 @@ Decorator::Decorator(DesktopSettings& settings, BRect rect,
*/
Decorator::~Decorator()
{
delete _colors;
}
/*!
\brief Updates the decorator's color set
\param cset The color set to update from
*/
void
Decorator::SetColors(const ColorSet &cset)
{
_colors->SetColors(cset);
_SetColors();
}
@ -481,6 +466,16 @@ Decorator::DrawZoom(void)
_DrawZoom(_zoomrect);
}
RGBColor
Decorator::UIColor(color_which which)
{
// TODO: for now - calling ui_color() from within the app_server
// will always return the default colors (as there is no be_app)
return ui_color(which);
}
/*!
\brief Provides the number of characters that will fit in the given width
\param width Maximum number of pixels the title can be
@ -588,16 +583,3 @@ void
Decorator::_SetFocus()
{
}
/*!
\brief Hook function for when the color set is updated
This function is called after the decorator's color set is updated. Quite useful
if the decorator uses colors based on those in the system.
*/
void
Decorator::_SetColors()
{
}

View File

@ -15,7 +15,6 @@
#include <String.h>
#include <Window.h>
#include "ColorSet.h"
#include "DrawState.h"
class DesktopSettings;
@ -51,7 +50,6 @@ class Decorator {
window_look look, uint32 flags);
virtual ~Decorator();
void SetColors(const ColorSet &cset);
void SetDriver(DrawingEngine *driver);
void SetFont(ServerFont *font);
@ -86,8 +84,6 @@ class Decorator {
void SetFocus(bool focussed);
bool IsFocus()
{ return fIsFocused; };
ColorSet Colors()
{ return (_colors) ? *_colors : ColorSet(); }
virtual void GetFootprint(BRegion *region);
@ -111,7 +107,9 @@ class Decorator {
virtual void DrawTab();
virtual void DrawTitle();
virtual void DrawZoom();
RGBColor UIColor(color_which which);
protected:
int32 _ClipTitle(float width);
@ -133,9 +131,7 @@ class Decorator {
virtual void _DrawMinimize(BRect r);
virtual void _SetFocus();
virtual void _SetColors();
ColorSet* _colors;
DrawingEngine* _driver;
DrawState fDrawState;

View File

@ -921,10 +921,10 @@ DefaultDecorator::_SetFocus()
if (IsFocus() || ((fLook == B_FLOATING_WINDOW_LOOK || fLook == kLeftTitledWindowLook)
&& (fFlags & B_AVOID_FOCUS) != 0)) {
fButtonHighColor.SetColor(tint_color(_colors->window_tab,B_LIGHTEN_2_TINT));
fButtonLowColor.SetColor(tint_color(_colors->window_tab,B_DARKEN_1_TINT));
fTextColor = _colors->window_tab_text;
fTabColor = _colors->window_tab;
fTabColor = UIColor(B_WINDOW_TAB_COLOR);
fTextColor = UIColor(B_WINDOW_TEXT_COLOR);
fButtonHighColor.SetColor(tint_color(fTabColor.GetColor32(), B_LIGHTEN_2_TINT));
fButtonLowColor.SetColor(tint_color(fTabColor.GetColor32(), B_DARKEN_1_TINT));
// fFrameColors[0].SetColor(152, 152, 152);
// fFrameColors[1].SetColor(255, 255, 255);
@ -933,10 +933,10 @@ DefaultDecorator::_SetFocus()
// fFrameColors[4].SetColor(152, 152, 152);
// fFrameColors[5].SetColor(96, 96, 96);
} else {
fButtonHighColor.SetColor(tint_color(_colors->inactive_window_tab,B_LIGHTEN_2_TINT));
fButtonLowColor.SetColor(tint_color(_colors->inactive_window_tab,B_DARKEN_1_TINT));
fTextColor = _colors->inactive_window_tab_text;
fTabColor = _colors->inactive_window_tab;
fTabColor = UIColor(B_WINDOW_INACTIVE_TAB_COLOR);
fTextColor = UIColor(B_WINDOW_INACTIVE_TEXT_COLOR);
fButtonHighColor.SetColor(tint_color(fTabColor.GetColor32(), B_LIGHTEN_2_TINT));
fButtonLowColor.SetColor(tint_color(fTabColor.GetColor32(), B_DARKEN_1_TINT));
// fFrameColors[0].SetColor(152, 152, 152);
// fFrameColors[1].SetColor(255, 255, 255);

View File

@ -59,7 +59,7 @@ DesktopSettings::Private::_SetDefaults()
strlcpy(fMenuInfo.f_style, fPlainFont.Style(), B_FONT_STYLE_LENGTH);
fMenuInfo.font_size = fPlainFont.Size();
// TODO:
fMenuInfo.background_color.set_to(216, 216, 216); //gColorSet->menu_background;
fMenuInfo.background_color.set_to(216, 216, 216);
// look of the separator (R5: (0, 1, 2), default 0)
// TODO: we could just choose a nice one and remove the others

View File

@ -14,7 +14,6 @@ Server app_server :
AppServer.cpp
BitmapManager.cpp
ClientMemoryAllocator.cpp
ColorSet.cpp
CursorData.cpp
CursorManager.cpp
CursorSet.cpp

View File

@ -18,7 +18,6 @@
#include "AppServer.h"
#include "BitmapManager.h"
#include "ColorSet.h"
#include "CursorManager.h"
#include "CursorSet.h"
#include "Desktop.h"
@ -1001,51 +1000,6 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
break;
}
case AS_GET_UI_COLORS:
{
// Client application is asking for all the system colors at once
// using a ColorSet object
gGUIColorSet.Lock();
fLink.StartMessage(B_OK);
fLink.Attach<ColorSet>(gGUIColorSet);
fLink.Flush();
gGUIColorSet.Unlock();
break;
}
case AS_SET_UI_COLORS:
{
// Client application is asking to set all the system colors at once
// using a ColorSet object
// Attached data:
// 1) ColorSet new colors to use
gGUIColorSet.Lock();
link.Read<ColorSet>(&gGUIColorSet);
gGUIColorSet.Unlock();
fDesktop->BroadcastToAllApps(AS_UPDATE_COLORS);
break;
}
case AS_GET_UI_COLOR:
{
STRACE(("ServerApp %s: Get UI color\n", Signature()));
RGBColor color;
int32 whichColor;
link.Read<int32>(&whichColor);
gGUIColorSet.Lock();
color = gGUIColorSet.AttributeToColor(whichColor);
gGUIColorSet.Unlock();
fLink.StartMessage(B_OK);
fLink.Attach<rgb_color>(color.GetColor32());
fLink.Flush();
break;
}
/* font messages */
case AS_SET_SYSTEM_FONT:

View File

@ -25,33 +25,6 @@
// regular application. When running as the app_server, this is not used.
#define SERVER_SIGNATURE "application/x-vnd.haiku-app-server"
// ToDo: use find_directory() instead of absolute path names!
// Directory for all app_server-related settings. Must include ending slash.
#define SERVER_SETTINGS_DIR "/boot/home/config/settings/app_server/"
// Flattened list of usable fonts maintained by the server. The file is a
// flattened BMessage which is used for caching the names when obtained
// by the various font functions.
#define SERVER_FONT_LIST "/boot/home/config/settings/app_server/fontlist"
// Flattened list of BMessages containing data for each workspace
#define WORKSPACE_DATA_LIST "/boot/home/config/settings/app_server/workspace_settings"
// folder used to keep saved color sets for the UI - tab color, etc.
#define COLOR_SET_DIR "/boot/home/config/settings/color_sets/"
// folder used to keep saved cursor sets for the system
#define CURSOR_SET_DIR "/boot/home/config/settings/cursor_sets/"
// name of the file containing the current UI color settings
#define COLOR_SETTINGS_NAME "system_colors"
// name of the file containing the current system cursor settings
#define CURSOR_SETTINGS_NAME "system_cursors"
// name of the file containing the config data for the desktop
#define WORKSPACE_SETTINGS_NAME "workspace_data"
// Folder for additional window decorators
#define DECORATORS_DIR "/boot/home/config/add-ons/decorators/"

View File

@ -171,7 +171,7 @@ WorkspacesLayer::_DrawWindow(DrawingEngine* drawingEngine, const BRect& workspac
// ToDo: let decorator do this!
RGBColor yellow;
if (decorator != NULL)
yellow = decorator->Colors().window_tab;
yellow = decorator->UIColor(B_WINDOW_TAB_COLOR);
RGBColor frameColor(180, 180, 180);
RGBColor white(255, 255, 255);