Set*UIColor, etc.

The inseparable changes necessary to support live color updating across the
system in a sane, safe, and performant manner.

BView gains:

HasSystemColors()
HasDefaultColors()
AdoptSystemColors()
AdoptParentColors()
AdoptViewColor(BView*)
SetViewUIColor(color_which, float tint)
SetHighUIColor(...
SetLowUIColor(...
ViewUIColor(float* tint)
HighUIColor(...
LowUIColor(...
DelayedInvalidate()

BWindow gains a simple helper method:
IsOffscreenWindow()

BMessage gains:

AddColor()
FindColor()
GetColor()
HasColor()            * allegedly this API is deprecated, but I implemented it anyway
ReplaceColor()
SetColor()

Previous private ColorTools methods are made public and moved into GraphicsDefs:

mix_color, blend_color, disable_color

These are fully compatible with BeOS dan0 R5.1 methods and are just code cleanup
of BeOS example code under the OpenTracker license.

In addition, four new colors are created:
B_LINK_TEXT_COLOR
B_LINK_HOVER_COLOR
B_LINK_ACTIVE_COLOR
B_LINK_VISITED_COLOR

These changes are documented in their proper user documentation files.

In addition, due to a history rewrite, B_FOLLOW_LEFT_TOP has been defined and
used in lieu of B_FOLLOW_TOP | B_FOLLOW_LEFT and is included in this commit.

On the app_server side, the following has changed:

Add DelayedMessage - a system by which messages can be sent at a scheduled time,
and can also be merged according to set rules.  A single thread is used to service the
message queue and multiple recipients can be set for each message.
Desktop gains the ability to add message ports to a DelayedMessage so that
said messages can target either all applications or all windows, as needed.

Desktop maintains a BMessage which is used to queue up all pending color changes
and the delayed messaging system is used to enact these changes after a short
period of time has passed.  This prevents abuse and allows the system to merge
repeated set_ui_color events into one event for client applications, improving
performance drastically.

In addition, B_COLORS_UPDATED is sent to the BApplication, which forwards the message
to each BWindow.  This is done to improve performance over having the app_server
independently informing each window.

Decorator changes are live now, which required some reworking.

Signed-off-by: Augustin Cavalier <[email protected]>
This commit is contained in:
looncraz
2016-01-04 06:48:22 -05:00
committed by Augustin Cavalier
parent a3212ce3e9
commit 7f9368cae5
75 changed files with 2982 additions and 454 deletions
+139 -1
View File
@@ -1078,6 +1078,7 @@
\since BeOS R3 \since BeOS R3
*/ */
/*! /*!
\fn status_t BMessage::AddFloat(const char* name, float aFloat) \fn status_t BMessage::AddFloat(const char* name, float aFloat)
\brief Convenience method to add a \c float to the label \a name. \brief Convenience method to add a \c float to the label \a name.
@@ -1118,6 +1119,26 @@
*/ */
/*!
\fn status_t BMessage::AddColor(const char* name, rgb_color aColor)
\brief Convenience method to add a \c rgb_color to the label \a name.
This method calls AddData() with the \c B_RGB_32_BIT_TYPE \a type.
\param name The label to associate the data with.
\param aColor The value to store in the message.
\returns A status code, \c B_OK on success or an error code.
\see AddColor() for a more detailed overview of the inner workings.
\see FindColor()
\see GetColor()
\see ReplaceColor()
\since Haiku R1
*/
/*! /*!
\fn status_t BMessage::AddPointer(const char* name, const void* aPointer) \fn status_t BMessage::AddPointer(const char* name, const void* aPointer)
\brief Convenience method to add a \c pointer to the label \a name. \brief Convenience method to add a \c pointer to the label \a name.
@@ -1807,6 +1828,48 @@
*/ */
/*!
\fn status_t BMessage::FindColor(const char* name, rgb_color* value)
\brief Find a color with the label \a name.
This is an overloaded version of
FindColor(const char*, int32, rgb_color*) const
where the data is sought at \a index \c 0.
\param name The label to which the data is associated.
\param value The object in which the data should be copied.
\returns A status code, \c B_OK on success or an error code.
\retval B_OK The object now contains the requested data.
\retval B_NAME_NOT_FOUND There is no field with this \a name.
\since Haiku R1
*/
/*!
\fn status_t BMessage::FindColor(const char* name, int32 index,
rgb_color* value) const
\brief Find a color at the label \a name at an \a index.
This method looks for the data with the \c B_RGB_32_BIT_TYPE, and copies
it into a provided buffer.
\param name The label to which the data is associated.
\param index The index from which the data should be copied.
\param value The object in which the data should be copied.
\returns A status code, \c B_OK on success or an error code.
\retval B_OK The object now contains the requested data.
\retval B_BAD_INDEX The \a index does not exist.
\retval B_NAME_NOT_FOUND There is no field with this \a name.
\see FindColor(const char*, rgb_color*) const
\since BeOS R3
*/
/*! /*!
\fn status_t BMessage::FindPointer(const char* name, void** pointer) const \fn status_t BMessage::FindPointer(const char* name, void** pointer) const
\brief Find a pointer at the label \a name. \brief Find a pointer at the label \a name.
@@ -1849,7 +1912,7 @@
\retval B_BAD_INDEX The \a index does not exist. \retval B_BAD_INDEX The \a index does not exist.
\retval B_NAME_NOT_FOUND There is no field with this \a name. \retval B_NAME_NOT_FOUND There is no field with this \a name.
\see FindPointer(const char*, double*) const \see FindPointer(const char*, void*) const
\since BeOS R3 \since BeOS R3
*/ */
@@ -2569,6 +2632,49 @@
*/ */
/*!
\fn status_t BMessage::ReplaceColor(const char* name, rgb_color aColot)
\brief Replace a color at the label \a name.
This method is an overloaded method of
ReplaceColor(const char*, int32, rgb_color).
It replaces the data at \a index \c 0.
\param name The name associated with the data to replace.
\param aColor Where to store in the message.
\returns A status code, \c B_OK on success or an error code.
\retval B_OK The operation succeeded.
\retval B_NAME_NOT_FOUND There is no field with this \a name.
\since Haiku R1
*/
/*!
\fn status_t BMessage::ReplaceColor(const char* name, int32 index,
rgb_color aColor)
\brief Replace a rgb_color at the label \a name at a specified
\a index.
The data at the specified \a name and \a index will be replaced, if it
matches the \c B_RGB_32_BIT_TYPE.
\param name The name associated with the data to replace.
\param index The index in the array to replace.
\param aColor Where to store in the message.
\returns A status code, \c B_OK on success or an error code.
\retval B_OK The operation succeeded.
\retval B_BAD_INDEX The index was out of range.
\retval B_NAME_NOT_FOUND There is no field with this \a name.
\see ReplaceColor(const char*, rgb_color)
\since Haiku R1
*/
/*! /*!
\fn status_t BMessage::ReplacePointer(const char* name, \fn status_t BMessage::ReplacePointer(const char* name,
const void* pointer) const void* pointer)
@@ -3513,6 +3619,38 @@ bool enabled = GetBool("enabled", false);
*/ */
/*!
\fn rgb_color BMessage::GetColor(const char* name, rgb_color defaultValue) const
\brief Return the rgb_color value from message with \a name, or
\a defaultValue if not found.
\param name The name of the item to retrieve.
\param defaultValue The value to use if the item specified by \a name
is not found.
\return The item with \a name, or \a defaultValue if not found.
\since Haiku R1
*/
/*!
\fn rgb_color BMessage::GetColor(const char* name, int32 index,
rgb_colorr defaultValue) const
\brief Return the rgb_color value from message with \a name and \a index, or
\a defaultValue if not found.
\param name The name of the item to retrieve.
\param index The index of the item to retrieve if there is more than one.
\param defaultValue The value to use if the item specified by \a name
is not found.
\return The item with \a name, or \a defaultValue if not found.
\since Haiku R1
*/
/*! /*!
\fn const char* BMessage::GetString(const char* name, \fn const char* BMessage::GetString(const char* name,
const char* defaultValue) const const char* defaultValue) const
+180 -9
View File
@@ -1,13 +1,14 @@
/* /*
* Copyright 2011-2014 Haiku, Inc. All rights reserved. * Copyright 2011-2015 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* John Scipione, [email protected] * John Scipione, [email protected]
* Joseph Groover, [email protected]
* *
* Corresponds to: * Corresponds to:
* headers/os/interface/View.h hrev47274 * headers/os/interface/View.h hrev497**
* src/kits/interface/View.cpp hrev47274 * src/kits/interface/View.cpp hrev497**
*/ */
@@ -523,6 +524,15 @@
*/ */
/*!
\var B_FOLLOW_LEFT_TOP
\brief The margins between the left and top sides of the view and the left
and top sides of its parent remain constant.
\since Haiku R1
*/
/*! /*!
\class BView \class BView
\ingroup interface \ingroup interface
@@ -596,12 +606,13 @@ if (Window()->LockLooper()) {
Each view has a ViewColor() that fills the frame rectangle before the Each view has a ViewColor() that fills the frame rectangle before the
view does any drawing of its own. The default view color is white, you may view does any drawing of its own. The default view color is white, you may
change the view color by calling SetViewColor(). A commonly used view color change the view color by calling SetViewColor() or, as of Haiku R1,
is \c B_PANEL_BACKGROUND_COLOR which is a grey color used as the view color SetViewUIColor(). A commonly used view color is \c B_PANEL_BACKGROUND_COLOR
of many Interface Kit classes. If you set the view color to which is a user-defined color used as the view color of most applications.
\c B_TRANSPARENT_COLOR then the Application Server won't erase the clipping If you set the view color to \c B_TRANSPARENT_COLOR then the Application Server
region of the view before updating, this should only be used if the view won't erase the clipping region of the view before updating, this should only
erases itself by drawing on every pixel in the clipping region. be used if the view erases itself by drawing on every pixel in the clipping
region.
If you want to set the view color of a view to be the same as its parent you If you want to set the view color of a view to be the same as its parent you
need to set it within the AttachedToWindow() method of the view like so: need to set it within the AttachedToWindow() method of the view like so:
@@ -614,6 +625,7 @@ SetViewColor(Parent()->ViewColor());
*/ */
/*! /*!
\fn BView::BView(const char* name, uint32 flags, BLayout* layout) \fn BView::BView(const char* name, uint32 flags, BLayout* layout)
\brief Layout constructor. \brief Layout constructor.
@@ -2057,6 +2069,59 @@ SetViewColor(Parent()->ViewColor());
*/ */
/*!
\fn bool BView::HasDefaultColors() const
\brief Tests if the view has any colors set.
\return Boolean value, true if colors are not set.
\since Haiku R1
*/
/*!
\fn bool BView::HasSystemColors() const
\brief Tests if the view is using system "panel" colors.
B_PANEL_BACKGROUND_COLOR for ViewUIColor()
B_PANEL_BACKGROUND_COLOR for LowUIColor()
B_PANEL_TEXT_COLOR for HighUIColor()
\return Boolean value, true if colors are as described.
\since Haiku R1
*/
/*!
\fn void BView::AdoptParentColors()
\brief Attempts to use the colors of any parent view.
Will adopt view, low, and high colors.
Should be called in AttachedToWindow() or AllAttached().
\since Haiku R1
*/
/*!
\fn void BView::AdoptSystemColors()
\brief Instructs view to use standard system "panel" colors.
B_PANEL_BACKGROUND_COLOR for ViewUIColor()
B_PANEL_BACKGROUND_COLOR for LowUIColor()
B_PANEL_TEXT_COLOR for HighUIColor()
\since Haiku R1
*/
/*!
\fn void BView::AdoptViewColors(BView* view)
\brief Attempts to use the colors of a given view.
Will adopt view, low, and high colors.
\since Haiku R1
*/
/*! /*!
\fn void BView::SetHighColor(rgb_color color) \fn void BView::SetHighColor(rgb_color color)
\brief Set the high color of the view. \brief Set the high color of the view.
@@ -2081,6 +2146,18 @@ SetViewColor(Parent()->ViewColor());
*/ */
/*!
\fn void BView::SetHighUIColor(color_which which, float tint)
\brief Set the high color of the view to a system constant.
The color will update live with user changes.
\param which The color_which constant to set.
\param tint Optional tint value to use.
\since Haiku R1
*/
/*! /*!
\fn rgb_color BView::HighColor() const \fn rgb_color BView::HighColor() const
\brief Return the current high color. \brief Return the current high color.
@@ -2094,6 +2171,20 @@ SetViewColor(Parent()->ViewColor());
*/ */
/*!
\fn color_which BView::HighUIColor(float* tint) const
\brief Return the current high color constant being used.
\param tint Optional float pointer in which to store the tint
value used to modify the system color constant.
\return The current high color constant.
\sa SetHighUIColor(color_which, float)
\since Haiku R1
*/
/*! /*!
\fn void BView::SetLowColor(rgb_color color) \fn void BView::SetLowColor(rgb_color color)
\brief Set the low color of the view. \brief Set the low color of the view.
@@ -2117,6 +2208,18 @@ SetViewColor(Parent()->ViewColor());
*/ */
/*!
\fn void BView::SetLowUIColor(color_which which, float tint)
\brief Set the low color of the view to a system constant.
The color will update live with user changes.
\param which The color_which constant to set.
\param tint Optional tint value to use.
\since Haiku R1
*/
/*! /*!
\fn rgb_color BView::LowColor() const \fn rgb_color BView::LowColor() const
\brief Return the current low color. \brief Return the current low color.
@@ -2130,6 +2233,20 @@ SetViewColor(Parent()->ViewColor());
*/ */
/*!
\fn color_which BView::LowUIColor(float* tint) const
\brief Return the current low color constant being used.
\param tint Optional float pointer in which to store the tint
value used to modify the system color constant.
\return The current low color constant.
\sa SetLowUIColor(color_which, float)
\since Haiku R1
*/
/*! /*!
\fn void BView::SetViewColor(rgb_color color) \fn void BView::SetViewColor(rgb_color color)
\brief Set the view color of the view. \brief Set the view color of the view.
@@ -2154,6 +2271,18 @@ SetViewColor(Parent()->ViewColor());
*/ */
/*!
\fn void BView::SetViewUIColor(color_which which, float tint)
\brief Set the view color of the view to a system constant.
The color will update live with user changes.
\param which The color_which constant to set.
\param tint Optional tint value to use.
\since Haiku R1
*/
/*! /*!
\fn rgb_color BView::ViewColor() const \fn rgb_color BView::ViewColor() const
\brief Return the current view color. \brief Return the current view color.
@@ -2167,6 +2296,20 @@ SetViewColor(Parent()->ViewColor());
*/ */
/*!
\fn color_which BView::ViewUIColor(float* tint) const
\brief Return the current view color constant being used.
\param tint Optional float pointer in which to store the tint
value used to modify the system color constant.
\return The current view color constant.
\sa SetViewUIColor(color_which, float)
\since Haiku R1
*/
/*! /*!
\fn void BView::ForceFontAliasing(bool enable) \fn void BView::ForceFontAliasing(bool enable)
\brief Turn anti-aliasing on and off when printing. \brief Turn anti-aliasing on and off when printing.
@@ -3696,6 +3839,34 @@ SetViewColor(Parent()->ViewColor());
*/ */
/*!
\fn void BView::DelayedInvalidate(bigtime_t delay)
\brief Sends a message to App Server to redraw the entire view after
a certain, minimum, delay. Repeated calls to this method may be
merged, but the view is guaranteed to be redrawn after the delay
given in the first call of this method.
\param delay The time, in microseconds, to wait until redrawing the view.
\since Haiku R1
*/
/*!
\fn void BView::DelayedInvalidate(bigtime_t delay, BRect invalRect)
\brief Sends a message to App Server to redraw the portion of the view
specified by \a invalRect after a certain, minimum, delay.
Repeated calls to this method may be merged, but the invalidated
rect is guaranteed to be redrawn after the minimum delay given
by the first call of this method.
\param delay The time, in microseconds, to wait until redrawing the view.
\param invalRect The rectangular area of the view to redraw.
\since Haiku R1
*/
/*! /*!
\fn void BView::InvertRect(BRect rect) \fn void BView::InvertRect(BRect rect)
\brief Inverts the colors within \a rect. \brief Inverts the colors within \a rect.
+15 -3
View File
@@ -1,13 +1,14 @@
/* /*
* Copyright 2011-2014 Haiku, Inc. All rights reserved. * Copyright 2011-2015 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* John Scipione, [email protected] * John Scipione, [email protected]
* Joseph Groover, [email protected]
* *
* Corresponds to: * Corresponds to:
* headers/os/interface/Window.h hrev45799 * headers/os/interface/Window.h hrev497**
* src/kits/interface/Window.cpp hrev45799 * src/kits/interface/Window.cpp hrev497**
*/ */
@@ -1967,6 +1968,17 @@
*/ */
/*!
\fn bool BWindow::IsOffscreenWindow() const
\brief Tests if window is used for drawing into a BBitmap.
This is mostly used by the Interface Kit itself.
\return True if the window is used for drawing into a BBitmap.
\since Haiku R1
*/
/*! /*!
\fn void BWindow::Show() \fn void BWindow::Show()
\brief Shows the window on screen, places it frontmost on the screen, adds \brief Shows the window on screen, places it frontmost on the screen, adds
+2 -4
View File
@@ -67,10 +67,8 @@ enum {
B_WORKSPACES_CHANGED = '_WCG', B_WORKSPACES_CHANGED = '_WCG',
B_WORKSPACE_ACTIVATED = '_WAC', B_WORKSPACE_ACTIVATED = '_WAC',
B_ZOOM = '_WZM', B_ZOOM = '_WZM',
_COLORS_UPDATED = '_CLU', B_COLORS_UPDATED = '_CLU',
// Currently internal-use only. Later, public as B_COLORS_UPDATED B_FONTS_UPDATED = '_FNU',
_FONTS_UPDATED = '_FNU',
// Currently internal-use only. Later, public as B_FONTS_UPDATED
_APP_MENU_ = '_AMN', _APP_MENU_ = '_AMN',
_BROWSER_MENUS_ = '_BRM', _BROWSER_MENUS_ = '_BRM',
_MENU_EVENT_ = '_MEV', _MENU_EVENT_ = '_MEV',
+16
View File
@@ -29,6 +29,7 @@ class BHandler;
class BString; class BString;
class BStringList; class BStringList;
struct entry_ref; struct entry_ref;
struct rgb_color;
// Name lengths and Scripting specifiers // Name lengths and Scripting specifiers
@@ -154,6 +155,7 @@ public:
status_t AddBool(const char* name, bool value); status_t AddBool(const char* name, bool value);
status_t AddFloat(const char* name, float value); status_t AddFloat(const char* name, float value);
status_t AddDouble(const char* name, double value); status_t AddDouble(const char* name, double value);
status_t AddColor(const char* name, rgb_color value);
status_t AddPointer(const char* name, status_t AddPointer(const char* name,
const void* pointer); const void* pointer);
status_t AddMessenger(const char* name, status_t AddMessenger(const char* name,
@@ -241,6 +243,10 @@ public:
double* value) const; double* value) const;
status_t FindDouble(const char* name, int32 index, status_t FindDouble(const char* name, int32 index,
double* value) const; 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, status_t FindPointer(const char* name,
void** pointer) const; void** pointer) const;
status_t FindPointer(const char* name, int32 index, 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, double value);
status_t ReplaceDouble(const char* name, int32 index, status_t ReplaceDouble(const char* name, int32 index,
double value); 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, status_t ReplacePointer(const char* name,
const void* pointer); const void* pointer);
status_t ReplacePointer(const char* name, int32 index, status_t ReplacePointer(const char* name, int32 index,
@@ -379,6 +389,7 @@ public:
bool HasBool(const char* name, int32 n = 0) const; bool HasBool(const char* name, int32 n = 0) const;
bool HasFloat(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 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 HasPointer(const char* name, int32 n = 0) const;
bool HasMessenger(const char* name, bool HasMessenger(const char* name,
int32 n = 0) const; int32 n = 0) const;
@@ -446,6 +457,10 @@ public:
double defaultValue) const; double defaultValue) const;
double GetDouble(const char* name, int32 index, double GetDouble(const char* name, int32 index,
double defaultValue) const; 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* GetString(const char* name,
const char* defaultValue = NULL) const; const char* defaultValue = NULL) const;
const char* GetString(const char* name, int32 index, const char* GetString(const char* name, int32 index,
@@ -477,6 +492,7 @@ public:
status_t SetUInt32(const char* name, uint32 value); status_t SetUInt32(const char* name, uint32 value);
status_t SetInt64(const char* name, int64 value); status_t SetInt64(const char* name, int64 value);
status_t SetUInt64(const char* name, uint64 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 SetPointer(const char* name, const void* value);
status_t SetString(const char* name, const char* string); status_t SetString(const char* name, const char* string);
status_t SetString(const char* name, status_t SetString(const char* name,
+2 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2005-2013 Haiku, Inc. All Rights Reserved. * Copyright 2005-2015 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _BOX_H #ifndef _BOX_H
@@ -12,8 +12,7 @@
class BBox : public BView { class BBox : public BView {
public: public:
BBox(BRect frame, const char* name = NULL, BBox(BRect frame, const char* name = NULL,
uint32 resizingMode = B_FOLLOW_LEFT uint32 resizingMode = B_FOLLOW_LEFT_TOP,
| B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
| B_NAVIGABLE_JUMP, | B_NAVIGABLE_JUMP,
border_style border = B_FANCY_BORDER); border_style border = B_FANCY_BORDER);
+2 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2014 Haiku, Inc. All rights reserved. * Copyright 2001-2015 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _BUTTON_H #ifndef _BUTTON_H
@@ -20,8 +20,7 @@ public:
public: public:
BButton(BRect frame, const char* name, BButton(BRect frame, const char* name,
const char* label, BMessage* message, const char* label, BMessage* message,
uint32 resizingMode uint32 resizingMode = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE uint32 flags = B_WILL_DRAW | B_NAVIGABLE
| B_FULL_UPDATE_ON_RESIZE); | B_FULL_UPDATE_ON_RESIZE);
BButton(const char* name, const char* label, BButton(const char* name, const char* label,
+2 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2008-2009, Haiku, Inc. All rights reserved. * Copyright 2008-2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _CHANNEL_CONTROL_H #ifndef _CHANNEL_CONTROL_H
@@ -18,8 +18,7 @@ public:
BChannelControl(BRect frame, const char* name, BChannelControl(BRect frame, const char* name,
const char* label, BMessage* model, const char* label, BMessage* model,
int32 channelCount = 1, int32 channelCount = 1,
uint32 resizingMode uint32 resizingMode = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW); uint32 flags = B_WILL_DRAW);
BChannelControl(const char* name, BChannelControl(const char* name,
const char* label, BMessage* model, const char* label, BMessage* model,
+3 -5
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2009, Haiku, Inc. All rights reserved. * Copyright 2009-2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _CHANNEL_SLIDER_H #ifndef _CHANNEL_SLIDER_H
@@ -14,15 +14,13 @@ public:
BChannelSlider(BRect area, const char* name, BChannelSlider(BRect area, const char* name,
const char* label, BMessage* message, const char* label, BMessage* message,
int32 channels = 1, int32 channels = 1,
uint32 resizeMode uint32 resizeMode = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW); uint32 flags = B_WILL_DRAW);
BChannelSlider(BRect area, const char* name, BChannelSlider(BRect area, const char* name,
const char* label, BMessage* message, const char* label, BMessage* message,
orientation orientation, orientation orientation,
int32 channels = 1, int32 channels = 1,
uint32 resizeMode uint32 resizeMode = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW); uint32 flags = B_WILL_DRAW);
BChannelSlider(const char* name, BChannelSlider(const char* name,
const char* label, BMessage* message, const char* label, BMessage* message,
+2 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2014 Haiku, Inc. All rights reserved. * Copyright 2001-2015 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _CHECK_BOX_H #ifndef _CHECK_BOX_H
@@ -13,8 +13,7 @@ class BCheckBox : public BControl {
public: public:
BCheckBox(BRect frame, const char* name, BCheckBox(BRect frame, const char* name,
const char* label, BMessage* message, const char* label, BMessage* message,
uint32 resizingMode uint32 resizingMode = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE); uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BCheckBox(const char* name, const char* label, BCheckBox(const char* name, const char* label,
BMessage* message, uint32 flags BMessage* message, uint32 flags
+12 -6
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2009-2012, Haiku, Inc. All rights reserved. * Copyright 2009-2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _CONTROL_LOOK_H #ifndef _CONTROL_LOOK_H
@@ -85,6 +85,7 @@ public:
B_PARTIALLY_ACTIVATED = 1 << 7, // like B_ACTIVATED, but for tri-state B_PARTIALLY_ACTIVATED = 1 << 7, // like B_ACTIVATED, but for tri-state
B_FLAT = 1 << 8, // flat look (e.g. button background) B_FLAT = 1 << 8, // flat look (e.g. button background)
B_INVALID = 1 << 9, // invalid value, use B_FAILURE_COLOR B_INVALID = 1 << 9, // invalid value, use B_FAILURE_COLOR
B_IS_CONTROL = 1 << 10, // use control colors
B_BLEND_FRAME = 1 << 16, B_BLEND_FRAME = 1 << 16,
}; };
@@ -328,27 +329,32 @@ public:
/*virtual*/ void DrawLabel(BView* view, const char* label, /*virtual*/ void DrawLabel(BView* view, const char* label,
BRect rect, const BRect& updateRect, BRect rect, const BRect& updateRect,
const rgb_color& base, uint32 flags); const rgb_color& base, uint32 flags,
const rgb_color* textColor = NULL);
virtual void DrawLabel(BView* view, const char* label, virtual void DrawLabel(BView* view, const char* label,
BRect rect, const BRect& updateRect, BRect rect, const BRect& updateRect,
const rgb_color& base, uint32 flags, const rgb_color& base, uint32 flags,
const BAlignment& alignment); const BAlignment& alignment,
const rgb_color* textColor = NULL);
// TODO: Would be nice to have a (non-virtual) version of this method // TODO: Would be nice to have a (non-virtual) version of this method
// which takes an array of labels and locations. That would save some // which takes an array of labels and locations. That would save some
// setup with the view graphics state. // setup with the view graphics state.
/*virtual*/ void DrawLabel(BView* view, const char* label, /*virtual*/ void DrawLabel(BView* view, const char* label,
const rgb_color& base, uint32 flags, const rgb_color& base, uint32 flags,
const BPoint& where); const BPoint& where,
const rgb_color* textColor = NULL);
void DrawLabel(BView* view, const char* label, void DrawLabel(BView* view, const char* label,
const BBitmap* icon, BRect rect, const BBitmap* icon, BRect rect,
const BRect& updateRect, const BRect& updateRect,
const rgb_color& base, uint32 flags); const rgb_color& base, uint32 flags,
const rgb_color* textColor = NULL);
virtual void DrawLabel(BView* view, const char* label, virtual void DrawLabel(BView* view, const char* label,
const BBitmap* icon, BRect rect, const BBitmap* icon, BRect rect,
const BRect& updateRect, const BRect& updateRect,
const rgb_color& base, uint32 flags, const rgb_color& base, uint32 flags,
const BAlignment& alignment); const BAlignment& alignment,
const rgb_color* textColor = NULL);
virtual void GetFrameInsets(frame_type frameType, virtual void GetFrameInsets(frame_type frameType,
uint32 flags, float& _left, float& _top, uint32 flags, float& _left, float& _top,
+8 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2008-2012 Haiku, Inc. All rights reserved. * Copyright 2008-2015 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _GRAPHICS_DEFS_H #ifndef _GRAPHICS_DEFS_H
@@ -57,6 +57,8 @@ typedef struct rgb_color {
return *this; return *this;
} }
int32 Brightness() const;
inline bool inline bool
operator==(const rgb_color& other) const operator==(const rgb_color& other) const
{ {
@@ -88,6 +90,11 @@ make_color(uint8 red, uint8 green, uint8 blue, uint8 alpha = 255)
#endif #endif
rgb_color mix_color(rgb_color color1, rgb_color color2, uint8 amount);
rgb_color blend_color(rgb_color color1, rgb_color color2, uint8 amount);
rgb_color disable_color(rgb_color color, rgb_color background);
extern const rgb_color B_TRANSPARENT_COLOR; extern const rgb_color B_TRANSPARENT_COLOR;
extern const uint8 B_TRANSPARENT_MAGIC_CMAP8; extern const uint8 B_TRANSPARENT_MAGIC_CMAP8;
extern const uint16 B_TRANSPARENT_MAGIC_RGBA15; extern const uint16 B_TRANSPARENT_MAGIC_RGBA15;
+10
View File
@@ -11,6 +11,7 @@
class BBitmap; class BBitmap;
class BMessage;
class BPoint; class BPoint;
class BRect; class BRect;
@@ -296,6 +297,7 @@ enum bitmap_drawing_options {
// Default UI Colors // Default UI Colors
enum color_which { enum color_which {
B_NO_COLOR = 0,
B_PANEL_BACKGROUND_COLOR = 1, B_PANEL_BACKGROUND_COLOR = 1,
B_PANEL_TEXT_COLOR = 10, B_PANEL_TEXT_COLOR = 10,
B_DOCUMENT_BACKGROUND_COLOR = 11, B_DOCUMENT_BACKGROUND_COLOR = 11,
@@ -310,6 +312,11 @@ enum color_which {
B_SHINE_COLOR = 18, B_SHINE_COLOR = 18,
B_SHADOW_COLOR = 19, B_SHADOW_COLOR = 19,
B_LINK_TEXT_COLOR = 33,
B_LINK_HOVER_COLOR = 34,
B_LINK_VISITED_COLOR = 35,
B_LINK_ACTIVE_COLOR = 36,
B_MENU_BACKGROUND_COLOR = 2, B_MENU_BACKGROUND_COLOR = 2,
B_MENU_SELECTED_BACKGROUND_COLOR = 6, B_MENU_SELECTED_BACKGROUND_COLOR = 6,
B_MENU_ITEM_TEXT_COLOR = 7, B_MENU_ITEM_TEXT_COLOR = 7,
@@ -463,7 +470,10 @@ void set_accept_first_click(bool acceptFirstClick);
bool accept_first_click(); bool accept_first_click();
rgb_color ui_color(color_which which); 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_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); rgb_color tint_color(rgb_color color, float tint);
extern "C" status_t _init_interface_kit_(); extern "C" status_t _init_interface_kit_();
+9 -10
View File
@@ -457,9 +457,7 @@ Group<ParentBuilder>::Group(BWindow* window, orientation orientation,
fLayout(new BGroupLayout(orientation, spacing)) fLayout(new BGroupLayout(orientation, spacing))
{ {
window->SetLayout(fLayout); window->SetLayout(fLayout);
fLayout->Owner()->AdoptSystemColors();
fLayout->Owner()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// TODO: we get a white background if we don't do this
} }
@@ -469,9 +467,11 @@ Group<ParentBuilder>::Group(BView* view, orientation orientation,
: :
fLayout(new BGroupLayout(orientation, spacing)) fLayout(new BGroupLayout(orientation, spacing))
{ {
if (view->HasDefaultColors())
view->AdoptSystemColors();
view->SetLayout(fLayout); view->SetLayout(fLayout);
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// TODO: we get a white background if we don't do this
} }
@@ -796,9 +796,7 @@ Grid<ParentBuilder>::Grid(BWindow* window, float horizontalSpacing,
fLayout(new BGridLayout(horizontalSpacing, verticalSpacing)) fLayout(new BGridLayout(horizontalSpacing, verticalSpacing))
{ {
window->SetLayout(fLayout); window->SetLayout(fLayout);
fLayout->Owner()->AdoptSystemColors();
fLayout->Owner()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// TODO: we get a white background if we don't do this
} }
@@ -808,9 +806,10 @@ Grid<ParentBuilder>::Grid(BView* view, float horizontalSpacing,
: :
fLayout(new BGridLayout(horizontalSpacing, verticalSpacing)) fLayout(new BGridLayout(horizontalSpacing, verticalSpacing))
{ {
if (view->HasDefaultColors())
view->AdoptSystemColors();
view->SetLayout(fLayout); view->SetLayout(fLayout);
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// TODO: we get a white background if we don't do this
} }
+2 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 Haiku, Inc. All rights reserved. * Copyright 2002-2015 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _LIST_VIEW_H #ifndef _LIST_VIEW_H
@@ -26,8 +26,7 @@ public:
BListView(BRect frame, const char* name, BListView(BRect frame, const char* name,
list_view_type type list_view_type type
= B_SINGLE_SELECTION_LIST, = B_SINGLE_SELECTION_LIST,
uint32 resizeMask = B_FOLLOW_LEFT uint32 resizeMask = B_FOLLOW_LEFT_TOP,
| B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW uint32 flags = B_WILL_DRAW
| B_FRAME_EVENTS | B_NAVIGABLE); | B_FRAME_EVENTS | B_NAVIGABLE);
BListView(const char* name, BListView(const char* name,
+3 -5
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2013, Haiku, Inc. All rights reserved. * Copyright 2006-2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _MENU_FIELD_H #ifndef _MENU_FIELD_H
@@ -17,14 +17,12 @@ class BMenuField : public BView {
public: public:
BMenuField(BRect frame, const char* name, BMenuField(BRect frame, const char* name,
const char* label, BMenu* menu, const char* label, BMenu* menu,
uint32 resizingMode = B_FOLLOW_LEFT uint32 resizingMode = B_FOLLOW_LEFT_TOP,
| B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE); uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BMenuField(BRect frame, const char* name, BMenuField(BRect frame, const char* name,
const char* label, BMenu* menu, const char* label, BMenu* menu,
bool fixed_size, bool fixed_size,
uint32 resizingMode = B_FOLLOW_LEFT uint32 resizingMode = B_FOLLOW_LEFT_TOP,
| B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE); uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BMenuField(const char* name, BMenuField(const char* name,
const char* label, BMenu* menu, const char* label, BMenu* menu,
+2 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2009, Haiku, Inc. All rights reserved. * Copyright 2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _MULTI_CHANNEL_CONTROL_H #ifndef _MULTI_CHANNEL_CONTROL_H
@@ -14,8 +14,7 @@ public:
BMultiChannelControl(BRect frame, BMultiChannelControl(BRect frame,
const char* name, const char* label, const char* name, const char* label,
BMessage* message, int32 channelCount = 1, BMessage* message, int32 channelCount = 1,
uint32 resize = B_FOLLOW_LEFT uint32 resize = B_FOLLOW_LEFT_TOP,
| B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW); uint32 flags = B_WILL_DRAW);
BMultiChannelControl(BMessage* archive); BMultiChannelControl(BMessage* archive);
virtual ~BMultiChannelControl(); virtual ~BMultiChannelControl();
+2 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2009, Haiku, Inc. All rights reserved. * Copyright 2001-2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _OPTION_CONTROL_H #ifndef _OPTION_CONTROL_H
@@ -18,8 +18,7 @@ class BOptionControl : public BControl {
public: public:
BOptionControl(BRect frame, const char* name, BOptionControl(BRect frame, const char* name,
const char* label, BMessage* message, const char* label, BMessage* message,
uint32 resizeMask = B_FOLLOW_LEFT uint32 resizeMask = B_FOLLOW_LEFT_TOP,
| B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW); uint32 flags = B_WILL_DRAW);
BOptionControl(const char* name, BOptionControl(const char* name,
const char* label, BMessage* message, const char* label, BMessage* message,
+3 -4
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2009, Haiku, Inc. All rights reserved. * Copyright 2001-2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _OPTION_POP_UP_H #ifndef _OPTION_POP_UP_H
@@ -16,13 +16,12 @@ class BOptionPopUp : public BOptionControl {
public: public:
BOptionPopUp(BRect frame, const char* name, BOptionPopUp(BRect frame, const char* name,
const char* label, BMessage* message, const char* label, BMessage* message,
uint32 resizeMask = B_FOLLOW_LEFT uint32 resizeMask = B_FOLLOW_LEFT_TOP,
| B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW); uint32 flags = B_WILL_DRAW);
BOptionPopUp(BRect frame, const char* name, BOptionPopUp(BRect frame, const char* name,
const char* label, BMessage* message, const char* label, BMessage* message,
bool fixed, uint32 resizeMask bool fixed, uint32 resizeMask
= B_FOLLOW_LEFT | B_FOLLOW_TOP, = B_FOLLOW_LEFT_TOP,
uint32 flags = B_WILL_DRAW); uint32 flags = B_WILL_DRAW);
BOptionPopUp(const char* name, BOptionPopUp(const char* name,
const char* label, BMessage* message, const char* label, BMessage* message,
+2 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2013, Haiku, Inc. All rights reserved. * Copyright 2006-2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _OUTLINE_LIST_VIEW_H #ifndef _OUTLINE_LIST_VIEW_H
@@ -14,8 +14,7 @@ public:
BOutlineListView(BRect frame, const char* name, BOutlineListView(BRect frame, const char* name,
list_view_type type list_view_type type
= B_SINGLE_SELECTION_LIST, = B_SINGLE_SELECTION_LIST,
uint32 resizingMode uint32 resizingMode = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW uint32 flags = B_WILL_DRAW
| B_FRAME_EVENTS | B_NAVIGABLE); | B_FRAME_EVENTS | B_NAVIGABLE);
BOutlineListView(const char* name, BOutlineListView(const char* name,
+2 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2008, Haiku, Inc. All rights reserved. * Copyright 2001-2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _PICTURE_BUTTON_H #ifndef _PICTURE_BUTTON_H
@@ -22,8 +22,7 @@ public:
BPicture* off, BPicture* on, BPicture* off, BPicture* on,
BMessage* message, BMessage* message,
uint32 behavior = B_ONE_STATE_BUTTON, uint32 behavior = B_ONE_STATE_BUTTON,
uint32 resizingMode = B_FOLLOW_LEFT uint32 resizingMode = B_FOLLOW_LEFT_TOP,
| B_FOLLOW_TOP,
uint32 flgs = B_WILL_DRAW | B_NAVIGABLE); uint32 flgs = B_WILL_DRAW | B_NAVIGABLE);
BPictureButton(BMessage* archive); BPictureButton(BMessage* archive);
+2 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2008, Haiku, Inc. All rights reserved. * Copyright 2001-2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _RADIO_BUTTON_H #ifndef _RADIO_BUTTON_H
@@ -14,8 +14,7 @@ class BRadioButton : public BControl {
public: public:
BRadioButton(BRect frame, const char* name, BRadioButton(BRect frame, const char* name,
const char* label, BMessage* message, const char* label, BMessage* message,
uint32 resizingMode uint32 resizingMode = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE); uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BRadioButton(const char* name, BRadioButton(const char* name,
const char* label, BMessage* message, const char* label, BMessage* message,
+1 -2
View File
@@ -15,8 +15,7 @@
class BScrollView : public BView { class BScrollView : public BView {
public: public:
BScrollView(const char* name, BView* target, BScrollView(const char* name, BView* target,
uint32 resizingMode uint32 resizingMode = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = 0, bool horizontal = false, uint32 flags = 0, bool horizontal = false,
bool vertical = false, bool vertical = false,
border_style border = B_FANCY_BORDER); border_style border = B_FANCY_BORDER);
+3 -5
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2013, Haiku, Inc. All rights reserved. * Copyright 2001-2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _SLIDER_H #ifndef _SLIDER_H
@@ -30,8 +30,7 @@ public:
const char* label, BMessage* message, const char* label, BMessage* message,
int32 minValue, int32 maxValue, int32 minValue, int32 maxValue,
thumb_style thumbType = B_BLOCK_THUMB, thumb_style thumbType = B_BLOCK_THUMB,
uint32 resizingMode uint32 resizingMode = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_NAVIGABLE | B_WILL_DRAW uint32 flags = B_NAVIGABLE | B_WILL_DRAW
| B_FRAME_EVENTS); | B_FRAME_EVENTS);
@@ -40,8 +39,7 @@ public:
int32 minValue, int32 maxValue, int32 minValue, int32 maxValue,
orientation posture, orientation posture,
thumb_style thumbType = B_BLOCK_THUMB, thumb_style thumbType = B_BLOCK_THUMB,
uint32 resizingMode uint32 resizingMode = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_NAVIGABLE | B_WILL_DRAW uint32 flags = B_NAVIGABLE | B_WILL_DRAW
| B_FRAME_EVENTS); | B_FRAME_EVENTS);
+2 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2010, Haiku, Inc. All rights reserved. * Copyright 2006-2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _SPLIT_VIEW_H #ifndef _SPLIT_VIEW_H
@@ -61,6 +61,7 @@ public:
bool AddChild(int32 index, BLayoutItem* child, bool AddChild(int32 index, BLayoutItem* child,
float weight); float weight);
virtual void AttachedToWindow();
virtual void Draw(BRect updateRect); virtual void Draw(BRect updateRect);
virtual void DrawAfterChildren(BRect updateRect); virtual void DrawAfterChildren(BRect updateRect);
virtual void MouseDown(BPoint where); virtual void MouseDown(BPoint where);
+3 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2009, Haiku, Inc. All rights reserved. * Copyright 2006-2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _STATUS_BAR_H #ifndef _STATUS_BAR_H
@@ -110,8 +110,9 @@ private:
float fTextDivider; float fTextDivider;
rgb_color fBarColor; rgb_color fBarColor;
bool fCustomBarHeight; bool fCustomBarHeight;
uint32 fInternalFlags;
uint32 _reserved[5]; uint32 _reserved[4];
}; };
#endif // _STATUS_BAR_H #endif // _STATUS_BAR_H
+1 -1
View File
@@ -13,7 +13,7 @@ class BStringView : public BView {
public: public:
BStringView(BRect frame, const char* name, BStringView(BRect frame, const char* name,
const char* text, uint32 resizingMode const char* text, uint32 resizingMode
= B_FOLLOW_LEFT | B_FOLLOW_TOP, = B_FOLLOW_LEFT_TOP,
uint32 flags = B_WILL_DRAW); uint32 flags = B_WILL_DRAW);
BStringView(const char* name, const char* text, BStringView(const char* name, const char* text,
uint32 flags = B_WILL_DRAW); uint32 flags = B_WILL_DRAW);
+1 -2
View File
@@ -21,8 +21,7 @@ public:
BTextControl(BRect frame, const char* name, BTextControl(BRect frame, const char* name,
const char* label, const char* initialText, const char* label, const char* initialText,
BMessage* message, BMessage* message,
uint32 resizeMask uint32 resizeMask = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE); uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BTextControl(const char* name, BTextControl(const char* name,
const char* label, const char* initialText, const char* label, const char* initialText,
+28 -8
View File
@@ -107,6 +107,7 @@ inline uint32 _rule_(uint32 r1, uint32 r2, uint32 r3, uint32 r4)
#define B_FOLLOW_TOP_BOTTOM _rule_(_VIEW_TOP_, 0, _VIEW_BOTTOM_, 0) #define B_FOLLOW_TOP_BOTTOM _rule_(_VIEW_TOP_, 0, _VIEW_BOTTOM_, 0)
#define B_FOLLOW_V_CENTER _rule_(_VIEW_CENTER_, 0, _VIEW_CENTER_, 0) #define B_FOLLOW_V_CENTER _rule_(_VIEW_CENTER_, 0, _VIEW_CENTER_, 0)
#define B_FOLLOW_LEFT_TOP B_FOLLOW_TOP | B_FOLLOW_LEFT
class BBitmap; class BBitmap;
class BCursor; class BCursor;
@@ -242,32 +243,38 @@ public:
void SetViewCursor(const BCursor* cursor, void SetViewCursor(const BCursor* cursor,
bool sync = true); bool sync = true);
bool HasDefaultColors() const;
bool HasSystemColors() const;
void AdoptParentColors();
void AdoptSystemColors();
void AdoptViewColors(BView* view);
virtual void SetViewColor(rgb_color color); virtual void SetViewColor(rgb_color color);
void SetViewColor(uchar red, uchar green, uchar blue, void SetViewColor(uchar red, uchar green, uchar blue,
uchar alpha = 255); uchar alpha = 255);
rgb_color ViewColor() const; rgb_color ViewColor() const;
void SetViewUIColor(color_which which,
float tint = B_NO_TINT);
color_which ViewUIColor(float* tint = NULL) const;
void SetViewBitmap(const BBitmap* bitmap, void SetViewBitmap(const BBitmap* bitmap,
BRect srcRect, BRect dstRect, BRect srcRect, BRect dstRect,
uint32 followFlags uint32 followFlags = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_TOP | B_FOLLOW_LEFT,
uint32 options = B_TILE_BITMAP); uint32 options = B_TILE_BITMAP);
void SetViewBitmap(const BBitmap* bitmap, void SetViewBitmap(const BBitmap* bitmap,
uint32 followFlags uint32 followFlags = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_TOP | B_FOLLOW_LEFT,
uint32 options = B_TILE_BITMAP); uint32 options = B_TILE_BITMAP);
void ClearViewBitmap(); void ClearViewBitmap();
status_t SetViewOverlay(const BBitmap* overlay, status_t SetViewOverlay(const BBitmap* overlay,
BRect srcRect, BRect dstRect, BRect srcRect, BRect dstRect,
rgb_color* colorKey, rgb_color* colorKey,
uint32 followFlags uint32 followFlags = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_TOP | B_FOLLOW_LEFT,
uint32 options = 0); uint32 options = 0);
status_t SetViewOverlay(const BBitmap* overlay, status_t SetViewOverlay(const BBitmap* overlay,
rgb_color* colorKey, rgb_color* colorKey,
uint32 followFlags uint32 followFlags = B_FOLLOW_LEFT_TOP,
= B_FOLLOW_TOP | B_FOLLOW_LEFT,
uint32 options = 0); uint32 options = 0);
void ClearViewOverlay(); void ClearViewOverlay();
@@ -276,11 +283,19 @@ public:
uchar alpha = 255); uchar alpha = 255);
rgb_color HighColor() const; rgb_color HighColor() const;
void SetHighUIColor(color_which which,
float tint = B_NO_TINT);
color_which HighUIColor(float* tint = NULL) const;
virtual void SetLowColor(rgb_color color); virtual void SetLowColor(rgb_color color);
void SetLowColor(uchar red, uchar green, uchar blue, void SetLowColor(uchar red, uchar green, uchar blue,
uchar alpha = 255); uchar alpha = 255);
rgb_color LowColor() const; rgb_color LowColor() const;
void SetLowUIColor(color_which which,
float tint = B_NO_TINT);
color_which LowUIColor(float* tint = NULL) const;
void SetLineMode(cap_mode lineCap, void SetLineMode(cap_mode lineCap,
join_mode lineJoin, join_mode lineJoin,
float miterLimit = B_DEFAULT_MITER_LIMIT); float miterLimit = B_DEFAULT_MITER_LIMIT);
@@ -495,6 +510,9 @@ public:
void Invalidate(BRect invalRect); void Invalidate(BRect invalRect);
void Invalidate(const BRegion* invalRegion); void Invalidate(const BRegion* invalRegion);
void Invalidate(); void Invalidate();
void DelayedInvalidate(bigtime_t delay);
void DelayedInvalidate(bigtime_t delay,
BRect invalRect);
void SetDiskMode(char* filename, long offset); void SetDiskMode(char* filename, long offset);
@@ -691,9 +709,11 @@ private:
void _Activate(bool state); void _Activate(bool state);
void _Attach(); void _Attach();
void _ColorsUpdated(BMessage* message);
void _Detach(); void _Detach();
void _Draw(BRect screenUpdateRect); void _Draw(BRect screenUpdateRect);
void _DrawAfterChildren(BRect screenUpdateRect); void _DrawAfterChildren(BRect screenUpdateRect);
void _FontsUpdated(BMessage*);
void _Pulse(); void _Pulse();
void _UpdateStateForRemove(); void _UpdateStateForRemove();
+1 -1
View File
@@ -272,7 +272,7 @@ public:
void InvalidateLayout(bool descendants = false); void InvalidateLayout(bool descendants = false);
void Layout(bool force); void Layout(bool force);
bool IsOffscreenWindow() const;
private: private:
// FBC padding and forbidden methods // FBC padding and forbidden methods
virtual void _ReservedWindow2(); virtual void _ReservedWindow2();
+11
View File
@@ -293,11 +293,18 @@ enum {
AS_VIEW_SET_PEN_SIZE, AS_VIEW_SET_PEN_SIZE,
AS_VIEW_GET_PEN_SIZE, AS_VIEW_GET_PEN_SIZE,
AS_VIEW_SET_HIGH_COLOR, AS_VIEW_SET_HIGH_COLOR,
AS_VIEW_SET_HIGH_UI_COLOR,
AS_VIEW_SET_LOW_COLOR, AS_VIEW_SET_LOW_COLOR,
AS_VIEW_SET_LOW_UI_COLOR,
AS_VIEW_SET_VIEW_COLOR, AS_VIEW_SET_VIEW_COLOR,
AS_VIEW_SET_VIEW_UI_COLOR,
AS_VIEW_GET_HIGH_COLOR, AS_VIEW_GET_HIGH_COLOR,
AS_VIEW_GET_HIGH_UI_COLOR,
AS_VIEW_GET_LOW_COLOR, AS_VIEW_GET_LOW_COLOR,
AS_VIEW_GET_LOW_UI_COLOR,
AS_VIEW_GET_VIEW_COLOR, AS_VIEW_GET_VIEW_COLOR,
AS_VIEW_GET_VIEW_UI_COLOR,
AS_VIEW_PRINT_ALIASING, AS_VIEW_PRINT_ALIASING,
AS_VIEW_CLIP_TO_PICTURE, AS_VIEW_CLIP_TO_PICTURE,
AS_VIEW_GET_CLIP_REGION, AS_VIEW_GET_CLIP_REGION,
@@ -314,6 +321,7 @@ enum {
AS_VIEW_COPY_BITS, AS_VIEW_COPY_BITS,
AS_VIEW_DRAW_PICTURE, AS_VIEW_DRAW_PICTURE,
AS_VIEW_INVALIDATE_RECT, AS_VIEW_INVALIDATE_RECT,
AS_VIEW_DELAYED_INVALIDATE_RECT,
AS_VIEW_INVALIDATE_REGION, AS_VIEW_INVALIDATE_REGION,
AS_VIEW_INVERT_RECT, AS_VIEW_INVERT_RECT,
AS_VIEW_MOVE_TO, AS_VIEW_MOVE_TO,
@@ -355,6 +363,9 @@ enum {
AS_VIEW_CLIP_TO_RECT, AS_VIEW_CLIP_TO_RECT,
AS_VIEW_CLIP_TO_SHAPE, AS_VIEW_CLIP_TO_SHAPE,
// Internal messages
AS_COLOR_MAP_UPDATED,
AS_LAST_CODE AS_LAST_CODE
}; };
@@ -18,6 +18,10 @@ struct ViewSetStateInfo {
float penSize; float penSize;
rgb_color highColor; rgb_color highColor;
rgb_color lowColor; rgb_color lowColor;
color_which whichHighColor;
color_which whichLowColor;
float whichHighColorTint;
float whichLowColorTint;
::pattern pattern; ::pattern pattern;
drawing_mode drawingMode; drawing_mode drawingMode;
BPoint origin; BPoint origin;
+5 -5
View File
@@ -13,11 +13,11 @@
#include <InterfaceDefs.h> #include <InterfaceDefs.h>
// Update this constant with the largest color constant excluding // Update kColorWhichLastContinuous with the largest color constant which
// B_SUCCESS_COLOR and B_FAILURE_COLOR. // leaves no gaps in the color_which integer values.
// If you add a constant with index greater than 100 you'll have to add static const int32 kColorWhichLastContinuous = B_LINK_ACTIVE_COLOR;
// to the second operand. static const int32 kColorWhichCount = kColorWhichLastContinuous + 3;
static const int32 kColorWhichCount = B_SCROLL_BAR_THUMB_COLOR + 3; // + 1 for index-offset, + 2 for B_SUCCESS_COLOR, B_FAILURE_COLOR
struct server_read_only_memory { struct server_read_only_memory {
+1 -1
View File
@@ -39,7 +39,7 @@ class BAbstractSpinner : public BControl {
public: public:
BAbstractSpinner(BRect frame, const char* name, BAbstractSpinner(BRect frame, const char* name,
const char* label, BMessage* message, const char* label, BMessage* message,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 resizingMode = B_FOLLOW_LEFT_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE); uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BAbstractSpinner(const char* name, const char* label, BAbstractSpinner(const char* name, const char* label,
BMessage* message, BMessage* message,
-79
View File
@@ -1,79 +0,0 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
/*******************************************************************************
/
/ File: ColorTools.h
/
/ Description: Additional experimental color manipulation functions.
/
/ Copyright 2000, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#ifndef _COLOR_TOOLS_H
#define _COLOR_TOOLS_H
#include <GraphicsDefs.h>
#if B_BEOS_VERSION <= B_BEOS_VERSION_5
namespace BExperimental {
// Mix two colors together, ignoring their relative alpha channels.
// If amount is 0, the result is color1; if 255, the result is color2;
// if another value, it is somewhere in-between. The resulting alpha
// channel is mixed exactly like the other color channels.
rgb_color mix_color(rgb_color color1, rgb_color color2, uint8 amount);
// Blend two colors together, weighting by their relative alpha channels.
// The resulting color is the same as mix_color(), except that the amount
// used from color1 and color2's color channels is dependent on that color's
// alpha channel. For example, if color1.alpha is 0 and color2.alpha is
// 255, the resulting red, green, and blue values will be the same as those
// in color2, regardless of 'amount'.
rgb_color blend_color(rgb_color color1, rgb_color color2, uint8 amount);
// Return a color that is the disabled representation of 'color' when drawn
// on a solid color 'background'.
rgb_color disable_color(rgb_color color, rgb_color background);
} // namespace BExperimental
using namespace BExperimental;
#endif
#endif
+5 -2
View File
@@ -63,10 +63,10 @@ class RecursiveOutlineIterator;
} // ns BPrivate } // ns BPrivate
class BField;
class BRow;
class BColumn; class BColumn;
class BColumnListView; class BColumnListView;
class BField;
class BRow;
enum LatchType { enum LatchType {
B_NO_LATCH = 0, B_NO_LATCH = 0,
@@ -353,6 +353,7 @@ public:
// Appearance (NEW STYLE) // Appearance (NEW STYLE)
void SetColor(ColumnListViewColor colorIndex, void SetColor(ColumnListViewColor colorIndex,
rgb_color color); rgb_color color);
void ResetColors();
void SetFont(ColumnListViewFont fontIndex, void SetFont(ColumnListViewFont fontIndex,
const BFont* font, const BFont* font,
uint32 mask = B_FONT_ALL); uint32 mask = B_FONT_ALL);
@@ -396,12 +397,14 @@ protected:
private: private:
void _Init(); void _Init();
void _UpdateColors();
void _GetChildViewRects(const BRect& bounds, void _GetChildViewRects(const BRect& bounds,
BRect& titleRect, BRect& outlineRect, BRect& titleRect, BRect& outlineRect,
BRect& vScrollBarRect, BRect& vScrollBarRect,
BRect& hScrollBarRect); BRect& hScrollBarRect);
rgb_color fColorList[B_COLOR_TOTAL]; rgb_color fColorList[B_COLOR_TOTAL];
bool fCustomColors;
BPrivate::TitleView* fTitleView; BPrivate::TitleView* fTitleView;
BPrivate::OutlineView* fOutlineView; BPrivate::OutlineView* fOutlineView;
BList fColumns; BList fColumns;
+1 -1
View File
@@ -16,7 +16,7 @@ class BDecimalSpinner : public BAbstractSpinner {
public: public:
BDecimalSpinner(BRect frame, const char* name, BDecimalSpinner(BRect frame, const char* name,
const char* label, BMessage* message, const char* label, BMessage* message,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 resizingMode = B_FOLLOW_LEFT_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE); uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BDecimalSpinner(const char* name, const char* label, BDecimalSpinner(const char* name, const char* label,
BMessage* message, BMessage* message,
+13 -1
View File
@@ -42,8 +42,11 @@ enum {
B_VIEW_PATTERN_BIT = 0x00020000, B_VIEW_PATTERN_BIT = 0x00020000,
B_VIEW_TRANSFORM_BIT = 0x00040000, B_VIEW_TRANSFORM_BIT = 0x00040000,
B_VIEW_FILL_RULE_BIT = 0x00080000, B_VIEW_FILL_RULE_BIT = 0x00080000,
B_VIEW_WHICH_VIEW_COLOR_BIT = 0x00100000,
B_VIEW_WHICH_LOW_COLOR_BIT = 0x00200000,
B_VIEW_WHICH_HIGH_COLOR_BIT = 0x00400000,
B_VIEW_ALL_BITS = 0x000fffff, B_VIEW_ALL_BITS = 0x00ffffff,
// these used for archiving only // these used for archiving only
B_VIEW_RESIZE_BIT = 0x00001000, B_VIEW_RESIZE_BIT = 0x00001000,
@@ -107,6 +110,15 @@ class ViewState {
// This one is not affected by pop state/push state // This one is not affected by pop state/push state
rgb_color view_color; rgb_color view_color;
color_which which_view_color;
float which_view_color_tint;
// these are cached values
color_which which_low_color;
float which_low_color_tint;
color_which which_high_color;
float which_high_color_tint;
::pattern pattern; ::pattern pattern;
+1 -2
View File
@@ -26,8 +26,7 @@ namespace BPrivate {
class BCalendarView : public BView, public BInvoker { class BCalendarView : public BView, public BInvoker {
public: public:
BCalendarView(BRect frame, const char* name, BCalendarView(BRect frame, const char* name,
uint32 resizeMask = B_FOLLOW_LEFT uint32 resizeMask = B_FOLLOW_LEFT_TOP,
| B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
| B_NAVIGABLE); | B_NAVIGABLE);
+19
View File
@@ -1044,6 +1044,8 @@ BApplication::DispatchMessage(BMessage* message, BHandler* handler)
return; return;
} }
message->PrintToStream();
switch (message->what) { switch (message->what) {
case B_ARGV_RECEIVED: case B_ARGV_RECEIVED:
_ArgvReceived(message); _ArgvReceived(message);
@@ -1102,6 +1104,23 @@ BApplication::DispatchMessage(BMessage* message, BHandler* handler)
break; break;
} }
case B_COLORS_UPDATED:
{
AutoLocker<BLooperList> listLock(gLooperList);
if (!listLock.IsLocked())
break;
BWindow* window = NULL;
uint32 count = gLooperList.CountLoopers();
for (uint32 index = 0; index < count; ++index) {
window = dynamic_cast<BWindow*>(gLooperList.LooperAt(index));
if (window == NULL || (window != NULL && window->fOffscreen))
continue;
window->PostMessage(message);
}
break;
}
case _SHOW_DRAG_HANDLES_: case _SHOW_DRAG_HANDLES_:
{ {
bool show; bool show;
+11
View File
@@ -22,6 +22,7 @@
#include <AppMisc.h> #include <AppMisc.h>
#include <BlockCache.h> #include <BlockCache.h>
#include <Entry.h> #include <Entry.h>
#include <GraphicsDefs.h>
#include <MessageQueue.h> #include <MessageQueue.h>
#include <Messenger.h> #include <Messenger.h>
#include <Path.h> #include <Path.h>
@@ -735,6 +736,14 @@ BMessage::_PrintToStream(const char* indent) const
break; 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: default:
{ {
printf("(type = '%.4s')(size = %ld)\n", (char*)&value, 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(bool, Bool, B_BOOL_TYPE);
DEFINE_FUNCTIONS(float, Float, B_FLOAT_TYPE); DEFINE_FUNCTIONS(float, Float, B_FLOAT_TYPE);
DEFINE_FUNCTIONS(double, Double, B_DOUBLE_TYPE); DEFINE_FUNCTIONS(double, Double, B_DOUBLE_TYPE);
DEFINE_FUNCTIONS(rgb_color, Color, B_RGB_32_BIT_TYPE);
#undef DEFINE_FUNCTIONS #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(bool, Bool, B_BOOL_TYPE);
DEFINE_SET_GET_FUNCTIONS(float, Float, B_FLOAT_TYPE); DEFINE_SET_GET_FUNCTIONS(float, Float, B_FLOAT_TYPE);
DEFINE_SET_GET_FUNCTIONS(double, Double, B_DOUBLE_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 #undef DEFINE_SET_GET_FUNCTION
-110
View File
@@ -1,110 +0,0 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
/*******************************************************************************
/
/ File: ColorTools.cpp
/
/ Description: Additional experimental color manipulation functions.
/
/ Copyright 2000, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#include "ColorTools.h"
#if B_BEOS_VERSION <= B_BEOS_VERSION_MAUI
namespace BExperimental {
#if DEBUG
#define DB_INLINE
#else
#define DB_INLINE inline
#endif
static DB_INLINE void mix_color_func(rgb_color* target, const rgb_color other, uint8 amount)
{
target->red = (uint8)( ((int16(other.red)-int16(target->red))*amount)/255
+ target->red );
target->green = (uint8)( ((int16(other.green)-int16(target->green))*amount)/255
+ target->green );
target->blue = (uint8)( ((int16(other.blue)-int16(target->blue))*amount)/255
+ target->blue );
target->alpha = (uint8)( ((int16(other.alpha)-int16(target->alpha))*amount)/255
+ target->alpha );
}
static DB_INLINE void blend_color_func(rgb_color* target, const rgb_color other, uint8 amount)
{
const uint8 alphaMix = (uint8)( ((int16(other.alpha)-int16(255-target->alpha))*amount)/255
+ (255-target->alpha) );
target->red = (uint8)( ((int16(other.red)-int16(target->red))*alphaMix)/255
+ target->red );
target->green = (uint8)( ((int16(other.green)-int16(target->green))*alphaMix)/255
+ target->green );
target->blue = (uint8)( ((int16(other.blue)-int16(target->blue))*alphaMix)/255
+ target->blue );
target->alpha = (uint8)( ((int16(other.alpha)-int16(target->alpha))*amount)/255
+ target->alpha );
}
static DB_INLINE void disable_color_func(rgb_color* target, const rgb_color background)
{
blend_color_func(target, background, 255-70);
}
// --------------------------------------------------------------------------
rgb_color mix_color(rgb_color color1, rgb_color color2, uint8 amount)
{
mix_color_func(&color1, color2, amount);
return color1;
}
rgb_color blend_color(rgb_color color1, rgb_color color2, uint8 amount)
{
blend_color_func(&color1, color2, amount);
return color1;
}
rgb_color disable_color(rgb_color color, rgb_color background)
{
disable_color_func(&color, background);
return color;
}
}
#endif
+53 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2008, Haiku. * Copyright 2001-2015, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -36,6 +36,58 @@ const uint32 B_TRANSPARENT_MAGIC_RGBA32_BIG = 0x77747700;
const struct screen_id B_MAIN_SCREEN_ID = {0}; const struct screen_id B_MAIN_SCREEN_ID = {0};
// rgb_color
int32
rgb_color::Brightness() const
{
return ((int32)red * 41 + (int32)green * 187 + (int32)blue * 28) >> 8;
}
// Mix two colors without respect for their alpha values
rgb_color
mix_color(rgb_color color1, rgb_color color2, uint8 amount)
{
color1.red = (uint8)(((int16(color2.red) - int16(color1.red)) * amount)
/ 255 + color1.red);
color1.green = (uint8)(((int16(color2.green) - int16(color1.green))
* amount) / 255 + color1.green);
color1.blue = (uint8)(((int16(color2.blue) - int16(color1.blue)) * amount)
/ 255 + color1.blue );
color1.alpha = (uint8)(((int16(color2.alpha) - int16(color1.alpha))
* amount) / 255 + color1.alpha );
return color1;
}
// Mix two colors, respecting their alpha values.
rgb_color
blend_color(rgb_color color1, rgb_color color2, uint8 amount)
{
const uint8 alphaMix = (uint8)(((int16(color2.alpha) - int16(255
- color1.alpha)) * amount) / 255 + (255 - color1.alpha));
color1.red = (uint8)(((int16(color2.red) - int16(color1.red)) * alphaMix)
/ 255 + color1.red );
color1.green = (uint8)(((int16(color2.green) - int16(color1.green))
* alphaMix) / 255 + color1.green);
color1.blue = (uint8)(((int16(color2.blue) - int16(color1.blue))
* alphaMix) / 255 + color1.blue);
color1.alpha = (uint8)(((int16(color2.alpha) - int16(color1.alpha))
* amount) / 255 + color1.alpha);
return color1;
}
rgb_color
disable_color(rgb_color color, rgb_color background)
{
return mix_color(color, background, 185);
}
status_t status_t
get_pixel_size_for(color_space space, size_t *pixelChunk, size_t *rowAlignment, get_pixel_size_for(color_space space, size_t *pixelChunk, size_t *rowAlignment,
size_t *pixelsPerChunk) size_t *pixelsPerChunk)
+134 -2
View File
@@ -8,6 +8,7 @@
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler, axeld@pinc-software.de
* Michael Lotz <mmlr@mlotz.ch> * Michael Lotz <mmlr@mlotz.ch>
* Wim van der Meer <WPJvanderMeer@gmail.com> * Wim van der Meer <WPJvanderMeer@gmail.com>
* Joseph Groover <looncraz@looncraz.net>
*/ */
@@ -39,6 +40,7 @@
#include <ColorConversion.h> #include <ColorConversion.h>
#include <DecorInfo.h> #include <DecorInfo.h>
#include <DefaultColors.h> #include <DefaultColors.h>
#include <DesktopLink.h>
#include <InputServerTypes.h> #include <InputServerTypes.h>
#include <input_globals.h> #include <input_globals.h>
#include <InterfacePrivate.h> #include <InterfacePrivate.h>
@@ -102,6 +104,10 @@ static const rgb_color _kDefaultColors[kColorWhichCount] = {
{0, 0, 0, 255}, // B_LIST_ITEM_TEXT_COLOR {0, 0, 0, 255}, // B_LIST_ITEM_TEXT_COLOR
{0, 0, 0, 255}, // B_LIST_SELECTED_ITEM_TEXT_COLOR {0, 0, 0, 255}, // B_LIST_SELECTED_ITEM_TEXT_COLOR
{216, 216, 216, 255}, // B_SCROLL_BAR_THUMB_COLOR {216, 216, 216, 255}, // B_SCROLL_BAR_THUMB_COLOR
{51, 102, 187, 255}, // B_LINK_TEXT_COLOR
{102, 152, 203, 255}, // B_LINK_HOVER_COLOR
{145, 112, 155, 255}, // B_LINK_VISITED_COLOR
{121, 142, 203, 255}, // B_LINK_ACTIVE_COLOR
// 100... // 100...
{46, 204, 64, 255}, // B_SUCCESS_COLOR {46, 204, 64, 255}, // B_SUCCESS_COLOR
{255, 65, 54, 255}, // B_FAILURE_COLOR {255, 65, 54, 255}, // B_FAILURE_COLOR
@@ -110,6 +116,50 @@ static const rgb_color _kDefaultColors[kColorWhichCount] = {
const rgb_color* BPrivate::kDefaultColors = &_kDefaultColors[0]; 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 { namespace BPrivate {
@@ -1079,14 +1129,51 @@ ui_color(color_which which)
if (be_app != NULL) { if (be_app != NULL) {
server_read_only_memory* shared server_read_only_memory* shared
= BApplication::Private::ServerReadOnlyMemory(); = BApplication::Private::ServerReadOnlyMemory();
if (shared != NULL) if (shared != NULL) {
// check for unset colors
if (shared->colors[index] == B_TRANSPARENT_COLOR)
shared->colors[index] = kDefaultColors[index];
return shared->colors[index]; return shared->colors[index];
}
} }
return kDefaultColors[index]; return kDefaultColors[index];
} }
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 void
set_ui_color(const color_which &which, const rgb_color &color) set_ui_color(const color_which &which, const rgb_color &color)
{ {
@@ -1096,7 +1183,10 @@ set_ui_color(const color_which &which, const rgb_color &color)
return; return;
} }
BPrivate::AppServerLink link; if (ui_color(which) == color)
return;
BPrivate::DesktopLink link;
link.StartMessage(AS_SET_UI_COLOR); link.StartMessage(AS_SET_UI_COLOR);
link.Attach<color_which>(which); link.Attach<color_which>(which);
link.Attach<rgb_color>(color); link.Attach<rgb_color>(color);
@@ -1104,6 +1194,48 @@ set_ui_color(const color_which &which, const rgb_color &color)
} }
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;
desktop.Attach<color_which>(B_NO_COLOR);
desktop.Flush();
}
rgb_color rgb_color
tint_color(rgb_color color, float tint) tint_color(rgb_color color, float tint)
{ {
-1
View File
@@ -57,7 +57,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
CheckBox.cpp CheckBox.cpp
ColorConversion.cpp ColorConversion.cpp
ColorControl.cpp ColorControl.cpp
ColorTools.cpp
Control.cpp Control.cpp
ControlLook.cpp ControlLook.cpp
DecorInfo.cpp DecorInfo.cpp
+438 -5
View File
@@ -8,6 +8,7 @@
* Adrian Oanca, adioanca@cotty.iren.ro * Adrian Oanca, adioanca@cotty.iren.ro
* Ingo Weinhold. ingo_weinhold@gmx.de * Ingo Weinhold. ingo_weinhold@gmx.de
* Julian Harnath, julian.harnath@rwth-aachen.de * Julian Harnath, julian.harnath@rwth-aachen.de
* Joseph Groover, looncraz@looncraz.net
*/ */
@@ -141,6 +142,14 @@ ViewState::ViewState()
high_color = (rgb_color){ 0, 0, 0, 255 }; high_color = (rgb_color){ 0, 0, 0, 255 };
low_color = (rgb_color){ 255, 255, 255, 255 }; low_color = (rgb_color){ 255, 255, 255, 255 };
view_color = low_color; view_color = low_color;
which_view_color = B_NO_COLOR;
which_view_color_tint = B_NO_TINT;
which_high_color = B_NO_COLOR;
which_high_color_tint = B_NO_TINT;
which_low_color = B_NO_COLOR;
which_low_color_tint = B_NO_TINT;
pattern = B_SOLID_HIGH; pattern = B_SOLID_HIGH;
drawing_mode = B_OP_COPY; drawing_mode = B_OP_COPY;
@@ -220,6 +229,10 @@ ViewState::UpdateServerState(BPrivate::PortLink &link)
info.penSize = pen_size; info.penSize = pen_size;
info.highColor = high_color; info.highColor = high_color;
info.lowColor = low_color; info.lowColor = low_color;
info.whichHighColor = which_high_color;
info.whichLowColor = which_low_color;
info.whichHighColorTint = which_high_color_tint;
info.whichLowColorTint = which_low_color_tint;
info.pattern = pattern; info.pattern = pattern;
info.drawingMode = drawing_mode; info.drawingMode = drawing_mode;
info.origin = origin; info.origin = origin;
@@ -456,7 +469,7 @@ BView::BView(BMessage* archive)
| B_FONT_SHEAR | B_FONT_ROTATION); | B_FONT_SHEAR | B_FONT_ROTATION);
} }
int32 color; int32 color = 0;
if (archive->FindInt32("_color", 0, &color) == B_OK) if (archive->FindInt32("_color", 0, &color) == B_OK)
SetHighColor(get_rgb_color(color)); SetHighColor(get_rgb_color(color));
if (archive->FindInt32("_color", 1, &color) == B_OK) if (archive->FindInt32("_color", 1, &color) == B_OK)
@@ -464,6 +477,29 @@ BView::BView(BMessage* archive)
if (archive->FindInt32("_color", 2, &color) == B_OK) if (archive->FindInt32("_color", 2, &color) == B_OK)
SetViewColor(get_rgb_color(color)); SetViewColor(get_rgb_color(color));
float tint = B_NO_TINT;
if (archive->FindInt32("_uicolor", 0, &color) == B_OK
&& color != B_NO_COLOR) {
if (archive->FindFloat("_uitint", 0, &tint) != B_OK)
tint = B_NO_TINT;
SetHighUIColor((color_which)color, tint);
}
if (archive->FindInt32("_uicolor", 1, &color) == B_OK
&& color != B_NO_COLOR) {
if (archive->FindFloat("_uitint", 1, &tint) != B_OK)
tint = B_NO_TINT;
SetLowUIColor((color_which)color, tint);
}
if (archive->FindInt32("_uicolor", 2, &color) == B_OK
&& color != B_NO_COLOR) {
if (archive->FindFloat("_uitint", 2, &tint) != B_OK)
tint = B_NO_TINT;
SetViewUIColor((color_which)color, tint);
}
uint32 evMask; uint32 evMask;
uint32 options; uint32 options;
if (archive->FindInt32("_evmask", 0, (int32*)&evMask) == B_OK if (archive->FindInt32("_evmask", 0, (int32*)&evMask) == B_OK
@@ -595,6 +631,20 @@ BView::Archive(BMessage* data, bool deep) const
if (ret == B_OK) if (ret == B_OK)
ret = data->AddInt32("_color", get_uint32_color(ViewColor())); ret = data->AddInt32("_color", get_uint32_color(ViewColor()));
if (ret == B_OK)
ret = data->AddInt32("_uicolor", (int32)HighUIColor());
if (ret == B_OK)
ret = data->AddInt32("_uicolor", (int32)LowUIColor());
if (ret == B_OK)
ret = data->AddInt32("_uicolor", (int32)ViewUIColor());
if (ret == B_OK)
ret = data->AddFloat("_uitint", fState->which_high_color_tint);
if (ret == B_OK)
ret = data->AddFloat("_uitint", fState->which_low_color_tint);
if (ret == B_OK)
ret = data->AddFloat("_uitint", fState->which_view_color_tint);
// NOTE: we do not use this flag any more // NOTE: we do not use this flag any more
// if ( 1 ){ // if ( 1 ){
// ret = data->AddInt32("_dbuf", 1); // ret = data->AddInt32("_dbuf", 1);
@@ -2304,6 +2354,8 @@ BView::PenSize() const
void void
BView::SetHighColor(rgb_color color) BView::SetHighColor(rgb_color color)
{ {
SetHighUIColor(B_NO_COLOR);
// are we up-to-date already? // are we up-to-date already?
if (fState->IsValid(B_VIEW_HIGH_COLOR_BIT) if (fState->IsValid(B_VIEW_HIGH_COLOR_BIT)
&& fState->high_color == color) && fState->high_color == color)
@@ -2345,9 +2397,73 @@ BView::HighColor() const
} }
void
BView::SetHighUIColor(color_which which, float tint)
{
if (fState->IsValid(B_VIEW_WHICH_HIGH_COLOR_BIT)
&& fState->which_high_color == which
&& fState->which_high_color_tint == tint)
return;
if (fOwner != NULL) {
_CheckLockAndSwitchCurrent();
fOwner->fLink->StartMessage(AS_VIEW_SET_HIGH_UI_COLOR);
fOwner->fLink->Attach<color_which>(which);
fOwner->fLink->Attach<float>(tint);
fState->valid_flags |= B_VIEW_WHICH_HIGH_COLOR_BIT;
}
fState->which_high_color = which;
fState->which_high_color_tint = tint;
if (which != B_NO_COLOR) {
fState->archiving_flags |= B_VIEW_WHICH_HIGH_COLOR_BIT;
fState->archiving_flags &= ~B_VIEW_HIGH_COLOR_BIT;
fState->valid_flags |= B_VIEW_HIGH_COLOR_BIT;
fState->high_color = tint_color(ui_color(which), tint);
} else {
fState->valid_flags &= ~B_VIEW_HIGH_COLOR_BIT;
fState->archiving_flags &= ~B_VIEW_WHICH_HIGH_COLOR_BIT;
}
}
color_which
BView::HighUIColor(float* tint) const
{
if (!fState->IsValid(B_VIEW_WHICH_HIGH_COLOR_BIT)
&& fOwner != NULL) {
_CheckLockAndSwitchCurrent();
fOwner->fLink->StartMessage(AS_VIEW_GET_HIGH_UI_COLOR);
int32 code;
if (fOwner->fLink->FlushWithReply(code) == B_OK
&& code == B_OK) {
fOwner->fLink->Read<color_which>(&fState->which_high_color);
fOwner->fLink->Read<float>(&fState->which_high_color_tint);
fOwner->fLink->Read<rgb_color>(&fState->high_color);
fState->valid_flags |= B_VIEW_WHICH_HIGH_COLOR_BIT;
fState->valid_flags |= B_VIEW_HIGH_COLOR_BIT;
}
}
if (tint != NULL)
*tint = fState->which_high_color_tint;
return fState->which_high_color;
}
void void
BView::SetLowColor(rgb_color color) BView::SetLowColor(rgb_color color)
{ {
SetLowUIColor(B_NO_COLOR);
if (fState->IsValid(B_VIEW_LOW_COLOR_BIT) if (fState->IsValid(B_VIEW_LOW_COLOR_BIT)
&& fState->low_color == color) && fState->low_color == color)
return; return;
@@ -2388,10 +2504,151 @@ BView::LowColor() const
} }
void
BView::SetLowUIColor(color_which which, float tint)
{
if (fState->IsValid(B_VIEW_WHICH_LOW_COLOR_BIT)
&& fState->which_low_color == which
&& fState->which_low_color_tint == tint)
return;
if (fOwner != NULL) {
_CheckLockAndSwitchCurrent();
fOwner->fLink->StartMessage(AS_VIEW_SET_LOW_UI_COLOR);
fOwner->fLink->Attach<color_which>(which);
fOwner->fLink->Attach<float>(tint);
fState->valid_flags |= B_VIEW_WHICH_LOW_COLOR_BIT;
}
fState->which_low_color = which;
fState->which_low_color_tint = tint;
if (which != B_NO_COLOR) {
fState->archiving_flags |= B_VIEW_WHICH_LOW_COLOR_BIT;
fState->archiving_flags &= ~B_VIEW_LOW_COLOR_BIT;
fState->valid_flags |= B_VIEW_LOW_COLOR_BIT;
fState->low_color = tint_color(ui_color(which), tint);
} else {
fState->valid_flags &= ~B_VIEW_LOW_COLOR_BIT;
fState->archiving_flags &= ~B_VIEW_WHICH_LOW_COLOR_BIT;
}
}
color_which
BView::LowUIColor(float* tint) const
{
if (!fState->IsValid(B_VIEW_WHICH_LOW_COLOR_BIT)
&& fOwner != NULL) {
_CheckLockAndSwitchCurrent();
fOwner->fLink->StartMessage(AS_VIEW_GET_LOW_UI_COLOR);
int32 code;
if (fOwner->fLink->FlushWithReply(code) == B_OK
&& code == B_OK) {
fOwner->fLink->Read<color_which>(&fState->which_low_color);
fOwner->fLink->Read<float>(&fState->which_low_color_tint);
fOwner->fLink->Read<rgb_color>(&fState->low_color);
fState->valid_flags |= B_VIEW_WHICH_LOW_COLOR_BIT;
fState->valid_flags |= B_VIEW_LOW_COLOR_BIT;
}
}
if (tint != NULL)
*tint = fState->which_low_color_tint;
return fState->which_low_color;
}
bool
BView::HasDefaultColors() const
{
// If we don't have any of these flags, then we have default colors
uint32 testMask = B_VIEW_VIEW_COLOR_BIT | B_VIEW_HIGH_COLOR_BIT
| B_VIEW_LOW_COLOR_BIT | B_VIEW_WHICH_VIEW_COLOR_BIT
| B_VIEW_WHICH_HIGH_COLOR_BIT | B_VIEW_WHICH_LOW_COLOR_BIT;
return (fState->archiving_flags & testMask) == 0;
}
bool
BView::HasSystemColors() const
{
return fState->which_view_color == B_PANEL_BACKGROUND_COLOR
&& fState->which_high_color == B_PANEL_TEXT_COLOR
&& fState->which_low_color == B_PANEL_BACKGROUND_COLOR
&& fState->which_view_color_tint == B_NO_TINT
&& fState->which_high_color_tint == B_NO_TINT
&& fState->which_low_color_tint == B_NO_TINT;
}
void
BView::AdoptParentColors()
{
AdoptViewColors(Parent());
}
void
BView::AdoptSystemColors()
{
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
SetLowUIColor(B_PANEL_BACKGROUND_COLOR);
SetHighUIColor(B_PANEL_TEXT_COLOR);
}
void
BView::AdoptViewColors(BView* view)
{
if (view == NULL || !view->LockLooper())
return;
float tint = B_NO_TINT;
float viewTint = tint;
color_which viewWhich = view->ViewUIColor(&viewTint);
// View color
if (viewWhich != B_NO_COLOR)
SetViewUIColor(viewWhich, viewTint);
else
SetViewColor(view->ViewColor());
// Low color
color_which which = view->LowUIColor(&tint);
if (which != B_NO_COLOR)
SetLowUIColor(which, tint);
else if (viewWhich != B_NO_COLOR)
SetLowUIColor(viewWhich, viewTint);
else
SetLowColor(view->LowColor());
// High color
which = view->HighUIColor(&tint);
if (which != B_NO_COLOR)
SetHighUIColor(which, tint);
else
SetHighColor(view->HighColor());
view->UnlockLooper();
}
void void
BView::SetViewColor(rgb_color color) BView::SetViewColor(rgb_color color)
{ {
if (fState->IsValid(B_VIEW_VIEW_COLOR_BIT) && fState->view_color == color) SetViewUIColor(B_NO_COLOR);
if (fState->IsValid(B_VIEW_VIEW_COLOR_BIT)
&& fState->view_color == color)
return; return;
if (fOwner) { if (fOwner) {
@@ -2431,6 +2688,71 @@ BView::ViewColor() const
} }
void
BView::SetViewUIColor(color_which which, float tint)
{
if (fState->IsValid(B_VIEW_WHICH_VIEW_COLOR_BIT)
&& fState->which_view_color == which
&& fState->which_view_color_tint == tint)
return;
if (fOwner != NULL) {
_CheckLockAndSwitchCurrent();
fOwner->fLink->StartMessage(AS_VIEW_SET_VIEW_UI_COLOR);
fOwner->fLink->Attach<color_which>(which);
fOwner->fLink->Attach<float>(tint);
fState->valid_flags |= B_VIEW_WHICH_VIEW_COLOR_BIT;
}
fState->which_view_color = which;
fState->which_view_color_tint = tint;
if (which != B_NO_COLOR) {
fState->archiving_flags |= B_VIEW_WHICH_VIEW_COLOR_BIT;
fState->archiving_flags &= ~B_VIEW_VIEW_COLOR_BIT;
fState->valid_flags |= B_VIEW_VIEW_COLOR_BIT;
fState->view_color = tint_color(ui_color(which), tint);
} else {
fState->valid_flags &= ~B_VIEW_VIEW_COLOR_BIT;
fState->archiving_flags &= ~B_VIEW_WHICH_VIEW_COLOR_BIT;
}
if (!fState->IsValid(B_VIEW_WHICH_LOW_COLOR_BIT))
SetLowUIColor(which, tint);
}
color_which
BView::ViewUIColor(float* tint) const
{
if (!fState->IsValid(B_VIEW_WHICH_VIEW_COLOR_BIT)
&& fOwner != NULL) {
_CheckLockAndSwitchCurrent();
fOwner->fLink->StartMessage(AS_VIEW_GET_VIEW_UI_COLOR);
int32 code;
if (fOwner->fLink->FlushWithReply(code) == B_OK
&& code == B_OK) {
fOwner->fLink->Read<color_which>(&fState->which_view_color);
fOwner->fLink->Read<float>(&fState->which_view_color_tint);
fOwner->fLink->Read<rgb_color>(&fState->view_color);
fState->valid_flags |= B_VIEW_WHICH_VIEW_COLOR_BIT;
fState->valid_flags |= B_VIEW_VIEW_COLOR_BIT;
}
}
if (tint != NULL)
*tint = fState->which_view_color_tint;
return fState->which_view_color;
}
void void
BView::ForceFontAliasing(bool enable) BView::ForceFontAliasing(bool enable)
{ {
@@ -4099,6 +4421,35 @@ BView::Invalidate()
} }
void
BView::DelayedInvalidate(bigtime_t delay)
{
DelayedInvalidate(delay, Bounds());
}
void
BView::DelayedInvalidate(bigtime_t delay, BRect invalRect)
{
if (fOwner == NULL)
return;
invalRect.left = (int)invalRect.left;
invalRect.top = (int)invalRect.top;
invalRect.right = (int)invalRect.right;
invalRect.bottom = (int)invalRect.bottom;
if (!invalRect.IsValid())
return;
_CheckLockAndSwitchCurrent();
fOwner->fLink->StartMessage(AS_VIEW_DELAYED_INVALIDATE_RECT);
fOwner->fLink->Attach<bigtime_t>(system_time() + delay);
fOwner->fLink->Attach<BRect>(invalRect);
fOwner->fLink->Flush();
}
void void
BView::InvertRect(BRect rect) BView::InvertRect(BRect rect)
{ {
@@ -4598,6 +4949,11 @@ BView::MessageReceived(BMessage* message)
break; break;
} }
// prevent message repeats
case B_COLORS_UPDATED:
case B_FONTS_UPDATED:
break;
default: default:
BHandler::MessageReceived(message); BHandler::MessageReceived(message);
break; break;
@@ -4940,7 +5296,6 @@ BView::InvalidateLayout(bool descendants)
|| fLayoutData->fLayoutInvalidationDisabled > 0) { || fLayoutData->fLayoutInvalidationDisabled > 0) {
return; return;
} }
fLayoutData->fLayoutValid = false; fLayoutData->fLayoutValid = false;
fLayoutData->fMinMaxValid = false; fLayoutData->fMinMaxValid = false;
LayoutInvalidated(descendants); LayoutInvalidated(descendants);
@@ -4957,7 +5312,8 @@ BView::InvalidateLayout(bool descendants)
else else
_InvalidateParentLayout(); _InvalidateParentLayout();
if (fTopLevelView && fOwner) if (fTopLevelView
&& fOwner != NULL)
fOwner->PostMessage(B_LAYOUT_WINDOW); fOwner->PostMessage(B_LAYOUT_WINDOW);
} }
@@ -5266,6 +5622,12 @@ BView::_InitData(BRect frame, const char* name, uint32 resizingMode,
fLayoutData = new LayoutData; fLayoutData = new LayoutData;
fToolTip = NULL; fToolTip = NULL;
if ((flags & B_SUPPORTS_LAYOUT) != 0) {
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
SetLowUIColor(ViewUIColor());
SetHighUIColor(B_PANEL_TEXT_COLOR);
}
} }
@@ -5545,7 +5907,7 @@ BView::_ResizeBy(int32 deltaWidth, int32 deltaHeight)
} }
// layout the children // layout the children
if (fFlags & B_SUPPORTS_LAYOUT) { if ((fFlags & B_SUPPORTS_LAYOUT) != 0) {
Relayout(); Relayout();
} else { } else {
for (BView* child = fFirstChild; child; child = child->fNextSibling) for (BView* child = fFirstChild; child; child = child->fNextSibling)
@@ -5624,7 +5986,26 @@ BView::_Activate(bool active)
void void
BView::_Attach() BView::_Attach()
{ {
if (fOwner != NULL) {
// unmask state flags to force [re]syncing with the app_server
fState->valid_flags &= ~(B_VIEW_WHICH_VIEW_COLOR_BIT
| B_VIEW_WHICH_LOW_COLOR_BIT | B_VIEW_WHICH_HIGH_COLOR_BIT);
if (fState->which_view_color != B_NO_COLOR)
SetViewUIColor(fState->which_view_color,
fState->which_view_color_tint);
if (fState->which_high_color != B_NO_COLOR)
SetHighUIColor(fState->which_high_color,
fState->which_high_color_tint);
if (fState->which_low_color != B_NO_COLOR)
SetLowUIColor(fState->which_low_color,
fState->which_low_color_tint);
}
AttachedToWindow(); AttachedToWindow();
fAttached = true; fAttached = true;
// after giving the view a chance to do this itself, // after giving the view a chance to do this itself,
@@ -5653,6 +6034,46 @@ BView::_Attach()
} }
void
BView::_ColorsUpdated(BMessage* message)
{
if (fTopLevelView
&& fLayoutData->fLayout != NULL
&& !fState->IsValid(B_VIEW_WHICH_VIEW_COLOR_BIT)) {
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
SetHighUIColor(B_PANEL_TEXT_COLOR);
}
rgb_color color;
const char* colorName = ui_color_name(fState->which_view_color);
if (colorName != NULL && message->FindColor(colorName, &color) == B_OK) {
fState->view_color = tint_color(color, fState->which_view_color_tint);
fState->valid_flags |= B_VIEW_VIEW_COLOR_BIT;
}
colorName = ui_color_name(fState->which_low_color);
if (colorName != NULL && message->FindColor(colorName, &color) == B_OK) {
fState->low_color = tint_color(color, fState->which_low_color_tint);
fState->valid_flags |= B_VIEW_LOW_COLOR_BIT;
}
colorName = ui_color_name(fState->which_high_color);
if (colorName != NULL && message->FindColor(colorName, &color) == B_OK) {
fState->high_color = tint_color(color, fState->which_high_color_tint);
fState->valid_flags |= B_VIEW_HIGH_COLOR_BIT;
}
MessageReceived(message);
for (BView* child = fFirstChild; child != NULL;
child = child->fNextSibling)
child->_ColorsUpdated(message);
Invalidate();
}
void void
BView::_Detach() BView::_Detach()
{ {
@@ -5744,6 +6165,18 @@ BView::_DrawAfterChildren(BRect updateRect)
} }
void
BView::_FontsUpdated(BMessage* message)
{
MessageReceived(message);
for (BView* child = fFirstChild; child != NULL;
child = child->fNextSibling) {
child->_FontsUpdated(message);
}
}
void void
BView::_Pulse() BView::_Pulse()
{ {
+28 -4
View File
@@ -47,6 +47,7 @@
#include <PortLink.h> #include <PortLink.h>
#include <RosterPrivate.h> #include <RosterPrivate.h>
#include <ServerProtocol.h> #include <ServerProtocol.h>
#include <ServerProtocolStructs.h>
#include <TokenSpace.h> #include <TokenSpace.h>
#include <ToolTipManager.h> #include <ToolTipManager.h>
#include <ToolTipWindow.h> #include <ToolTipWindow.h>
@@ -733,7 +734,7 @@ BWindow::MessageReceived(BMessage* message)
// we're talking to the server application using our own // we're talking to the server application using our own
// communication channel (fLink) - we better make sure no one // communication channel (fLink) - we better make sure no one
// interferes by locking that channel (which AppServerLink does // interferes by locking that channel (which AppServerLink does
// implicetly) // implicitly)
fLink->StartMessage(AS_CREATE_WINDOW); fLink->StartMessage(AS_CREATE_WINDOW);
@@ -1439,6 +1440,20 @@ FrameMoved(origin);
break; break;
} }
case B_COLORS_UPDATED:
{
fTopView->_ColorsUpdated(message);
target->MessageReceived(message);
break;
}
case B_FONTS_UPDATED:
{
fTopView->_FontsUpdated(message);
target->MessageReceived(message);
break;
}
default: default:
BLooper::DispatchMessage(message, target); BLooper::DispatchMessage(message, target);
break; break;
@@ -2699,6 +2714,10 @@ BWindow::Run()
void void
BWindow::SetLayout(BLayout* layout) BWindow::SetLayout(BLayout* layout)
{ {
// Adopt layout's colors for fTopView
if (layout != NULL)
fTopView->AdoptViewColors(layout->View());
fTopView->SetLayout(layout); fTopView->SetLayout(layout);
} }
@@ -2727,6 +2746,13 @@ BWindow::Layout(bool force)
} }
bool
BWindow::IsOffscreenWindow() const
{
return fOffscreen;
}
status_t status_t
BWindow::GetSupportedSuites(BMessage* data) BWindow::GetSupportedSuites(BMessage* data)
{ {
@@ -3205,8 +3231,7 @@ BWindow::_CreateTopView()
BRect frame = fFrame.OffsetToCopy(B_ORIGIN); BRect frame = fFrame.OffsetToCopy(B_ORIGIN);
// TODO: what to do here about std::nothrow? // TODO: what to do here about std::nothrow?
fTopView = new BView(frame, "fTopView", fTopView = new BView(frame, "fTopView", B_FOLLOW_ALL, B_WILL_DRAW);
B_FOLLOW_ALL, B_WILL_DRAW);
fTopView->fTopLevelView = true; fTopView->fTopLevelView = true;
//inhibit check_lock() //inhibit check_lock()
@@ -3222,7 +3247,6 @@ BWindow::_CreateTopView()
// we can't use AddChild() because this is the top view // we can't use AddChild() because this is the top view
fTopView->_CreateSelf(); fTopView->_CreateSelf();
STRACE(("BuildTopView ended\n")); STRACE(("BuildTopView ended\n"));
} }
+871
View File
@@ -0,0 +1,871 @@
/*
* Copyright 2015, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Joseph Groover <looncraz@looncraz.net>
*/
#include "DelayedMessage.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <Autolock.h>
#include <String.h>
#include <LinkSender.h>
#include <ServerProtocol.h>
// DelayedMessageSender constants
static const int32 kWakeupMessage = AS_LAST_CODE + 2048;
static const int32 kExitMessage = kWakeupMessage + 1;
static const char* kName = "DMT is here for you, eventually...";
static int32 kPriority = B_URGENT_DISPLAY_PRIORITY;
static int32 kPortCapacity = 10;
//! Data attachment structure.
struct Attachment {
Attachment(const void* data, size_t size);
~Attachment();
const void* constData;
void* data;
size_t size;
};
typedef BObjectList<Attachment> AttachmentList;
/*! \class ScheduledMessage
\brief Responsible for sending of delayed message.
*/
class ScheduledMessage {
public:
ScheduledMessage(DelayedMessage& message);
~ScheduledMessage();
int32 CountTargets() const;
void Finalize();
bigtime_t ScheduledTime() const;
int32 SendMessage();
bool IsValid() const;
bool Merge(DelayedMessage& message);
status_t SendMessageToPort(port_id port);
bool operator<(const ScheduledMessage& other) const;
DelayedMessageData* fData;
};
/*! \class DelayedMessageSender DelayedMessageSender.h
\brief Responsible for scheduling and sending of delayed messages
*/
class DelayedMessageSender {
public:
explicit DelayedMessageSender();
~DelayedMessageSender();
status_t ScheduleMessage (DelayedMessage& message);
int32 CountDelayedMessages() const;
int64 CountSentMessages() const;
private:
void _MessageLoop();
int32 _SendDelayedMessages();
static int32 _thread_func(void* sender);
void _Wakeup(bigtime_t whatTime);
private:
typedef BObjectList<ScheduledMessage> ScheduledList;
mutable BLocker fLock;
ScheduledList fMessages;
bigtime_t fScheduledWakeup;
int32 fWakeupRetry;
thread_id fThread;
port_id fPort;
mutable int64 fSentCount;
};
DelayedMessageSender gDelayedMessageSender;
/*! \class DelayedMessageData DelayedMessageSender.h
\brief Owns DelayedMessage data, allocates memory and copies data only
when needed,
*/
class DelayedMessageData {
typedef BObjectList<port_id> PortList;
typedef void(*FailureCallback)(int32 code, port_id port, void* data);
public:
DelayedMessageData(int32 code, bigtime_t delay,
bool isSpecificTime);
~DelayedMessageData();
bool AddTarget(port_id port);
void RemoveTarget(port_id port);
int32 CountTargets() const;
void MergeTargets(DelayedMessageData* other);
bool CopyData();
bool MergeData(DelayedMessageData* other);
bool IsValid() const;
// Only valid after a successful CopyData().
status_t Attach(const void* data, size_t size);
bool Compare(Attachment* one, Attachment* two,
int32 index);
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;
bigtime_t fScheduledTime;
bool fValid;
AttachmentList fAttachments;
PortList fTargets;
DMMergeMode fMergeMode;
uint32 fMergeMask;
FailureCallback fFailureCallback;
void* fFailureData;
};
// #pragma mark -
DelayedMessage::DelayedMessage(int32 code, bigtime_t delay,
bool isSpecificTime)
:
fData(new(std::nothrow) DelayedMessageData(code, delay < DM_MINIMUM_DELAY
? DM_MINIMUM_DELAY : delay, isSpecificTime)),
fHandedOff(false)
{
}
DelayedMessage::~DelayedMessage()
{
// Message is canceled without a handoff.
if (!fHandedOff)
delete fData;
}
bool
DelayedMessage::AddTarget(port_id port)
{
if (fData == NULL || fHandedOff)
return false;
return fData->AddTarget(port);
}
void
DelayedMessage::SetMerge(DMMergeMode mode, uint32 match)
{
if (fData == NULL || fHandedOff)
return;
fData->SetMerge(mode, match);
}
void
DelayedMessage::SetFailureCallback(void (*callback)(int32, port_id, void*),
void* data)
{
if (fData == NULL || fHandedOff)
return;
fData->SetFailureCallback(callback, data);
}
//! Attach data to message. Memory is not allocated nor copied until handoff.
status_t
DelayedMessage::Attach(const void* data, size_t size)
{
if (fData == NULL)
return B_NO_MEMORY;
if (fHandedOff)
return B_ERROR;
if (data == NULL || size == 0)
return B_BAD_VALUE;
return fData->Attach(data, size);
}
status_t
DelayedMessage::Flush()
{
if (fData == NULL)
return B_NO_MEMORY;
if (fHandedOff)
return B_ERROR;
if (fData->CountTargets() == 0)
return B_BAD_VALUE;
return gDelayedMessageSender.ScheduleMessage(*this);
}
/*! The data handoff occurs upon scheduling and reduces copies to only
when a message is actually scheduled. Canceled messages have low cost.
*/
DelayedMessageData*
DelayedMessage::HandOff()
{
if (fData == NULL || fHandedOff)
return NULL;
if (fData->CopyData()) {
fHandedOff = true;
return fData;
}
return NULL;
}
// #pragma mark -
Attachment::Attachment(const void* _data, size_t _size)
:
constData(_data),
data(NULL),
size(_size)
{
}
Attachment::~Attachment()
{
free(data);
}
// #pragma mark -
DelayedMessageData::DelayedMessageData(int32 code, bigtime_t delay,
bool isSpecificTime)
:
fCode(code),
fScheduledTime(delay + isSpecificTime ? 0 : system_time()),
fValid(false),
fAttachments(3, true),
fTargets(4, true),
fMergeMode(DM_NO_MERGE),
fMergeMask(DM_DATA_DEFAULT),
fFailureCallback(NULL),
fFailureData(NULL)
{
}
DelayedMessageData::~DelayedMessageData()
{
}
bool
DelayedMessageData::AddTarget(port_id port)
{
if (port <= 0)
return false;
// check for duplicates:
for (int32 index = 0; index < fTargets.CountItems(); ++index) {
if (port == *fTargets.ItemAt(index))
return false;
}
return fTargets.AddItem(new(std::nothrow) port_id(port));
}
void
DelayedMessageData::RemoveTarget(port_id port)
{
if (port == B_BAD_PORT_ID)
return;
// Search for a match by value.
for (int32 index = 0; index < fTargets.CountItems(); ++index) {
port_id* target = fTargets.ItemAt(index);
if (port == *target) {
fTargets.RemoveItem(target, true);
return;
}
}
}
int32
DelayedMessageData::CountTargets() const
{
return fTargets.CountItems();
}
void
DelayedMessageData::MergeTargets(DelayedMessageData* other)
{
// Failure to add one target does not abort the loop!
// It could just mean we already have the target.
for (int32 index = 0; index < other->fTargets.CountItems(); ++index)
AddTarget(*(other->fTargets.ItemAt(index)));
}
//! Copy data from original location - merging failed
bool
DelayedMessageData::CopyData()
{
Attachment* attached = NULL;
for (int32 index = 0; index < fAttachments.CountItems(); ++index) {
attached = fAttachments.ItemAt(index);
if (attached == NULL || attached->data != NULL)
return false;
attached->data = malloc(attached->size);
if (attached->data == NULL)
return false;
memcpy(attached->data, attached->constData, attached->size);
}
fValid = true;
return true;
}
bool
DelayedMessageData::MergeData(DelayedMessageData* other)
{
if (!fValid
|| other == NULL
|| other->fCode != fCode
|| fMergeMode == DM_NO_MERGE
|| other->fMergeMode == DM_NO_MERGE
|| other->fMergeMode != fMergeMode
|| other->fAttachments.CountItems() != fAttachments.CountItems())
return false;
if (other->fMergeMode == DM_MERGE_CANCEL) {
MergeTargets(other);
return true;
}
// Compare data
Attachment* attached = NULL;
Attachment* otherAttached = NULL;
for (int32 index = 0; index < fAttachments.CountItems(); ++index) {
attached = fAttachments.ItemAt(index);
otherAttached = other->fAttachments.ItemAt(index);
if (attached == NULL
|| otherAttached == NULL
|| attached->data == NULL
|| otherAttached->constData == NULL
|| attached->size != otherAttached->size)
return false;
// Compares depending upon mode & flags
if (!Compare(attached, otherAttached, index))
return false;
}
// add any targets not included in the existing message!
MergeTargets(other);
// since these are duplicates, we need not copy anything...
if (fMergeMode == DM_MERGE_DUPLICATES)
return true;
// DM_MERGE_REPLACE:
// Import the new data!
for (int32 index = 0; index < fAttachments.CountItems(); ++index) {
attached = fAttachments.ItemAt(index);
otherAttached = other->fAttachments.ItemAt(index);
// We already have allocated our memory, but the other data
// has not. So this reduces memory allocations.
memcpy(attached->data, otherAttached->constData, attached->size);
}
return true;
}
bool
DelayedMessageData::IsValid() const
{
return fValid;
}
status_t
DelayedMessageData::Attach(const void* data, size_t size)
{
// Sanity checking already performed
Attachment* attach = new(std::nothrow) Attachment(data, size);
if (attach == NULL)
return B_NO_MEMORY;
if (fAttachments.AddItem(attach) == false) {
delete attach;
return B_ERROR;
}
return B_OK;
}
bool
DelayedMessageData::Compare(Attachment* one, Attachment* two, int32 index)
{
if (fMergeMode == DM_MERGE_DUPLICATES) {
// Default-policy: all data must match
if (fMergeMask == DM_DATA_DEFAULT || (fMergeMask & 1 << index) != 0)
return memcmp(one->data, two->constData, one->size) == 0;
} else if (fMergeMode == DM_MERGE_REPLACE) {
// Default Policy: no data needs to match
if (fMergeMask != DM_DATA_DEFAULT && (fMergeMask & 1 << index) != 0)
return memcmp(one->data, two->constData, one->size) == 0;
}
return true;
}
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 -
ScheduledMessage::ScheduledMessage(DelayedMessage& message)
:
fData(message.HandOff())
{
}
ScheduledMessage::~ScheduledMessage()
{
delete fData;
}
int32
ScheduledMessage::CountTargets() const
{
if (fData == NULL)
return 0;
return fData->CountTargets();
}
bigtime_t
ScheduledMessage::ScheduledTime() const
{
if (fData == NULL)
return 0;
return fData->ScheduledTime();
}
//! Send our message and data to their intended target(s)
int32
ScheduledMessage::SendMessage()
{
if (fData == NULL || !fData->IsValid())
return 0;
int32 sent = 0;
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) {
++sent;
continue;
}
if (error != B_TIMED_OUT)
fData->SendFailed(port);
}
return sent;
}
status_t
ScheduledMessage::SendMessageToPort(port_id port)
{
if (fData == NULL || !fData->IsValid())
return B_BAD_DATA;
if (port == B_BAD_PORT_ID)
return B_BAD_VALUE;
BPrivate::LinkSender sender(port);
if (sender.StartMessage(fData->Code()) != B_OK)
return B_ERROR;
AttachmentList& list = fData->Attachments();
Attachment* attached = NULL;
status_t error = B_OK;
// The data has been checked already, so we assume it is all good
for (int32 index = 0; index < list.CountItems(); ++index) {
attached = list.ItemAt(index);
error = sender.Attach(attached->data, attached->size);
if (error != B_OK) {
sender.CancelMessage();
return error;
}
}
// We do not want to ever hold up the sender thread for too long, we
// set a 1 second sending delay, which should be more than enough for
// 99.992% of all cases. Approximately.
error = sender.Flush(1000000);
if (error == B_OK || error == B_BAD_PORT_ID)
fData->RemoveTarget(port);
return error;
}
bool
ScheduledMessage::IsValid() const
{
return fData != NULL && fData->IsValid();
}
bool
ScheduledMessage::Merge(DelayedMessage& other)
{
if (!IsValid())
return false;
return fData->MergeData(other.Data());
}
bool
ScheduledMessage::operator<(const ScheduledMessage& other) const
{
if (!IsValid() || !other.IsValid())
return false;
return fData->ScheduledTime() < other.fData->ScheduledTime();
}
int
CompareMessages(const ScheduledMessage* one, const ScheduledMessage* two)
{
return *one < *two;
}
// #pragma mark -
DelayedMessageSender::DelayedMessageSender()
:
fLock("DelayedMessageSender"),
fMessages(20, true),
fScheduledWakeup(B_INFINITE_TIMEOUT),
fWakeupRetry(0),
fThread(spawn_thread(&_thread_func, kName, kPriority, this)),
fPort(create_port(kPortCapacity, "DelayedMessageSender")),
fSentCount(0)
{
resume_thread(fThread);
}
DelayedMessageSender::~DelayedMessageSender()
{
// write the exit message to our port
write_port(fPort, kExitMessage, NULL, 0);
status_t status = B_OK;
while (wait_for_thread(fThread, &status) == B_OK);
// We now know the thread has exited, it is safe to cleanup
delete_port(fPort);
}
status_t
DelayedMessageSender::ScheduleMessage(DelayedMessage& message)
{
BAutolock _(fLock);
// Can we merge with a pending message?
ScheduledMessage* pending = NULL;
for (int32 index = 0; index < fMessages.CountItems(); ++index) {
pending = fMessages.ItemAt(index);
if (pending->Merge(message))
return B_OK;
}
// Guess not, add it to our list!
ScheduledMessage* scheduled = new(std::nothrow) ScheduledMessage(message);
if (scheduled == NULL)
return B_NO_MEMORY;
if (!scheduled->IsValid())
return B_BAD_DATA;
if (fMessages.AddItem(scheduled)) {
fMessages.SortItems(&CompareMessages);
_Wakeup(scheduled->ScheduledTime());
return B_OK;
}
return B_ERROR;
}
int32
DelayedMessageSender::CountDelayedMessages() const
{
BAutolock _(fLock);
return fMessages.CountItems();
}
int64
DelayedMessageSender::CountSentMessages() const
{
return atomic_get64(&fSentCount);
}
void
DelayedMessageSender::_MessageLoop()
{
int32 code = -1;
status_t status = B_TIMED_OUT;
bigtime_t timeout = B_INFINITE_TIMEOUT;
while (true) {
timeout = atomic_get64(&fScheduledWakeup) - (system_time()
+ (DM_MINIMUM_DELAY / 2));
if (timeout > DM_MINIMUM_DELAY / 4) {
status = read_port_etc(fPort, &code, NULL, 0, B_RELATIVE_TIMEOUT,
timeout);
} else
status = B_TIMED_OUT;
if (status == B_INTERRUPTED)
continue;
if (status == B_TIMED_OUT) {
_SendDelayedMessages();
continue;
}
if (status == B_OK) {
switch (code) {
case kWakeupMessage:
continue;
case kExitMessage:
return;
// TODO: trace unhandled messages
default:
continue;
}
}
// port deleted?
if (status < B_OK)
break;
}
}
int32
DelayedMessageSender::_thread_func(void* sender)
{
(static_cast<DelayedMessageSender*>(sender))->_MessageLoop();
return 0;
}
//! Sends pending messages, call ONLY from sender thread!
int32
DelayedMessageSender::_SendDelayedMessages()
{
// avoid sending messages during times of contention
if (fLock.LockWithTimeout(30000) != B_OK) {
atomic_add64(&fScheduledWakeup, DM_MINIMUM_DELAY);
return 0;
}
atomic_set64(&fScheduledWakeup, B_INFINITE_TIMEOUT);
if (fMessages.CountItems() == 0) {
fLock.Unlock();
return 0;
}
int32 sent = 0;
bigtime_t time = system_time() + DM_MINIMUM_DELAY / 2;
// capture any that may be on the verge of being sent.
BObjectList<ScheduledMessage> remove;
ScheduledMessage* message = NULL;
for (int32 index = 0; index < fMessages.CountItems(); ++index) {
message = fMessages.ItemAt(index);
if (message->ScheduledTime() > time) {
atomic_set64(&fScheduledWakeup, message->ScheduledTime());
break;
}
int32 sendCount = message->SendMessage();
if (sendCount > 0)
sent += sendCount;
if (message->CountTargets() == 0)
remove.AddItem(message);
}
// remove serviced messages
for (int32 index = 0; index < remove.CountItems(); ++index)
fMessages.RemoveItem(remove.ItemAt(index));
atomic_add64(&fSentCount, sent);
// catch any partly-failed messages (possibly late):
if (fMessages.CountItems() > 0
&& atomic_get64(&fScheduledWakeup) == B_INFINITE_TIMEOUT) {
fMessages.SortItems(&CompareMessages);
message = fMessages.ItemAt(0);
bigtime_t timeout = message->ScheduledTime() - time;
if (timeout < 0)
timeout = DM_MINIMUM_DELAY;
atomic_set64(&fScheduledWakeup, timeout);
}
fLock.Unlock();
return sent;
}
void
DelayedMessageSender::_Wakeup(bigtime_t when)
{
if (atomic_get64(&fScheduledWakeup) < when
&& atomic_get(&fWakeupRetry) == 0)
return;
atomic_set64(&fScheduledWakeup, when);
BPrivate::LinkSender sender(fPort);
sender.StartMessage(kWakeupMessage);
status_t error = sender.Flush(30000);
atomic_set(&fWakeupRetry, (int32)error == B_TIMED_OUT);
}
+178
View File
@@ -0,0 +1,178 @@
/*
* Copyright 2015, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Joseph Groover <looncraz@looncraz.net>
*/
#ifndef AS_DELAYED_MESSAGE_H
#define AS_DELAYED_MESSAGE_H
#include <ObjectList.h>
#include <OS.h>
//! Method by which to merge DelayedMessages with the same code.
enum DMMergeMode {
DM_NO_MERGE = 0, // Will send this message, and the other(s)
DM_MERGE_REPLACE = 1, // Replace older data with newer data
DM_MERGE_CANCEL = 2, // keeps older data, cancels this message
DM_MERGE_DUPLICATES = 3 // If data is the same, cancel new message
};
//! Merge-mode data-matching, set which data must match to merge messages.
enum {
DM_DATA_DEFAULT = 0, // Match all for DUPLICATES & none for REPLACE modes.
DM_DATA_1 = 1 << 0,
DM_DATA_2 = 1 << 1,
DM_DATA_3 = 1 << 2,
DM_DATA_4 = 1 << 3,
DM_DATA_5 = 1 << 4,
DM_DATA_6 = 1 << 5
};
//! Convenient delay definitions.
enum {
DM_MINIMUM_DELAY = 500ULL,
DM_SHORT_DELAY = 1000ULL,
DM_120HZ_DELAY = 8888ULL,
DM_60HZ_DELAY = 16666ULL,
DM_MEDIUM_DELAY = 15000ULL,
DM_30HZ_DELAY = 33332ULL,
DM_15HZ_DELAY = 66664ULL,
DM_LONG_DELAY = 100000ULL,
DM_QUARTER_SECOND_DELAY = 250000ULL,
DM_HALF_SECOND_DELAY = 500000ULL,
DM_ONE_SECOND_DELAY = 1000000ULL,
DM_ONE_MINUTE_DELAY = DM_ONE_SECOND_DELAY * 60,
DM_ONE_HOUR_DELAY = DM_ONE_MINUTE_DELAY * 60
};
class DelayedMessageData;
/*! \class DelayedMessage
\brief Friendly API for creating messages to be sent at a future time.
Messages can be sent with a relative delay, or at a set time. Messages with
the same code can be merged according to various rules. Each message can
have any number of target recipients.
DelayedMessage is a throw-away object, it is to be created on the stack,
Flush()'d, then left to be destructed when out of scope.
*/
class DelayedMessage {
typedef void(*FailureCallback)(int32 code, port_id port, void* data);
public:
DelayedMessage(int32 code, bigtime_t delay,
bool isSpecificTime = false);
~DelayedMessage();
// At least one target port is required.
bool AddTarget(port_id port);
// Merge messages with the same code according to the following
// rules and data matching mask.
void SetMerge(DMMergeMode mode, uint32 match = 0);
// Called for each port on which the message was failed to be sent.
void SetFailureCallback(FailureCallback callback,
void* data = NULL);
template <class Type>
status_t Attach(const Type& data);
status_t Attach(const void* data, size_t size);
template <class Type>
status_t AttachList(const BObjectList<Type>& list);
template <class Type>
status_t AttachList(const BObjectList<Type>& list,
bool* whichArray);
status_t Flush();
// Private
DelayedMessageData* HandOff();
DelayedMessageData* Data() {return fData;}
private:
// Forbidden methods - these are one time-use objects.
void* operator new(size_t);
void* operator new[](size_t);
DelayedMessageData* fData;
bool fHandedOff;
};
// #pragma mark Implementation
template <class Type>
status_t
DelayedMessage::Attach(const Type& data)
{
return Attach(&data, sizeof(Type));
}
template <class Type>
status_t
DelayedMessage::AttachList(const BObjectList<Type>& list)
{
if (list.CountItems() == 0)
return B_BAD_VALUE;
status_t error = Attach<int32>(list.CountItems());
for (int32 index = 0; index < list.CountItems(); ++index) {
if (error != B_OK)
break;
error = Attach<Type>(*(list.ItemAt(index)));
}
return error;
}
template <class Type>
status_t
DelayedMessage::AttachList(const BObjectList<Type>& list, bool* which)
{
if (list.CountItems() == 0)
return B_BAD_VALUE;
if (which == NULL)
return AttachList(list);
int32 count = 0;
for (int32 index = 0; index < list.CountItems(); ++index) {
if (which[index])
++count;
}
if (count == 0)
return B_BAD_VALUE;
status_t error = Attach<int32>(count);
for (int32 index = 0; index < list.CountItems(); ++index) {
if (error != B_OK)
break;
if (which[index])
error = Attach<Type>(*list.ItemAt(index));
}
return error;
}
#endif // AS_DELAYED_MESSAGE_H
+153 -1
View File
@@ -10,6 +10,7 @@
* Brecht Machiels <brecht@mos6581.org> * Brecht Machiels <brecht@mos6581.org>
* Clemens Zeidler <haiku@clemens-zeidler.de> * Clemens Zeidler <haiku@clemens-zeidler.de>
* Ingo Weinhold <ingo_weinhold@gmx.de> * Ingo Weinhold <ingo_weinhold@gmx.de>
* Joseph Groover <looncraz@looncraz.net>
*/ */
@@ -575,7 +576,7 @@ Desktop::BroadcastToAllApps(int32 code)
void void
Desktop::BroadcastToAllWindows(int32 code) Desktop::BroadcastToAllWindows(int32 code)
{ {
AutoWriteLocker _(fWindowLock); AutoReadLocker _(fWindowLock);
for (Window* window = fAllWindows.FirstWindow(); window != NULL; for (Window* window = fAllWindows.FirstWindow(); window != NULL;
window = window->NextWindow(kAllWindowList)) { window = window->NextWindow(kAllWindowList)) {
@@ -584,6 +585,34 @@ Desktop::BroadcastToAllWindows(int32 code)
} }
int32
Desktop::GetAllWindowTargets(DelayedMessage& message)
{
AutoReadLocker _(fWindowLock);
int32 count = 0;
for (Window* window = fAllWindows.FirstWindow(); window != NULL;
window = window->NextWindow(kAllWindowList)) {
message.AddTarget(window->ServerWindow()->MessagePort());
++count;
}
return count;
}
int32
Desktop::GetAllAppTargets(DelayedMessage& message)
{
BAutolock _(fApplicationsLock);
for (int32 index = 0; index < fApplications.CountItems(); ++index)
message.AddTarget(fApplications.ItemAt(index)->MessagePort());
return fApplications.CountItems();
}
filter_result filter_result
Desktop::KeyEvent(uint32 what, int32 key, int32 modifiers) Desktop::KeyEvent(uint32 what, int32 key, int32 modifiers)
{ {
@@ -1648,6 +1677,31 @@ Desktop::FontsChanged(Window* window)
} }
void
Desktop::ColorUpdated(Window* window, color_which which, rgb_color color)
{
AutoWriteLocker _(fWindowLock);
window->TopView()->ColorUpdated(which, color);
switch (which) {
case B_WINDOW_TAB_COLOR:
case B_WINDOW_TEXT_COLOR:
case B_WINDOW_INACTIVE_TAB_COLOR:
case B_WINDOW_INACTIVE_TEXT_COLOR:
case B_WINDOW_BORDER_COLOR:
case B_WINDOW_INACTIVE_BORDER_COLOR:
break;
default:
return;
}
BRegion dirty;
window->ColorsChanged(&dirty);
RebuildAndRedrawAfterWindowChange(window, dirty);
}
void void
Desktop::SetWindowLook(Window* window, window_look newLook) Desktop::SetWindowLook(Window* window, window_look newLook)
{ {
@@ -2655,6 +2709,56 @@ Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
break; break;
} }
case AS_SET_UI_COLOR:
{
color_which which;
rgb_color color;
if (link.Read<color_which>(&which) == B_OK
&& link.Read<rgb_color>(&color) == B_OK) {
const char* colorName = ui_color_name(which);
fPendingColors.SetColor(colorName, color);
DelayedMessage delayed(AS_SET_UI_COLORS, DM_60HZ_DELAY);
delayed.AddTarget(MessagePort());
delayed.SetMerge(DM_MERGE_CANCEL);
delayed.Attach<bool>(true);
delayed.Flush();
}
break;
}
case AS_SET_UI_COLORS:
{
bool flushPendingOnly = false;
if (link.Read<bool>(&flushPendingOnly) != B_OK
|| (flushPendingOnly &&
fPendingColors.CountNames(B_RGB_32_BIT_TYPE) == 0)) {
break;
}
if (!flushPendingOnly) {
// Client wants to set a color map
color_which which = B_NO_COLOR;
rgb_color color;
do {
if (link.Read<color_which>(&which) != B_OK
|| link.Read<rgb_color>(&color) != B_OK)
break;
fPendingColors.SetColor(ui_color_name(which), color);
} while (which != B_NO_COLOR);
}
_FlushPendingColors();
break;
}
// ToDo: Remove this again. It is a message sent by the // ToDo: Remove this again. It is a message sent by the
// invalidate_on_exit kernel debugger add-on to trigger a redraw // invalidate_on_exit kernel debugger add-on to trigger a redraw
// after exiting a kernel debugger session. // after exiting a kernel debugger session.
@@ -2716,6 +2820,54 @@ Desktop::_Windows(int32 index)
} }
void
Desktop::_FlushPendingColors()
{
// Update all windows while we are holding the write lock.
int32 count = fPendingColors.CountNames(B_RGB_32_BIT_TYPE);
if (count == 0)
return;
bool changed[count];
LockedDesktopSettings settings(this);
settings.SetUIColors(fPendingColors, &changed[0]);
int32 index = 0;
char* name = NULL;
type_code type = B_RGB_32_BIT_TYPE;
rgb_color color;
color_which which = B_NO_COLOR;
BMessage clientMessage(B_COLORS_UPDATED);
while (fPendingColors.GetInfo(type, index, &name, &type) == B_OK) {
which = which_ui_color(name);
if (which == B_NO_COLOR || fPendingColors.FindColor(name,
&color) != B_OK || !changed[index]) {
++index;
continue;
}
for (Window* window = fAllWindows.FirstWindow(); window != NULL;
window = window->NextWindow(kAllWindowList)) {
ColorUpdated(window, which, color);
}
// Ensure client only gets list of changed colors
clientMessage.AddColor(name, color);
++index;
}
// Notify client applications
BAutolock appListLock(fApplicationsLock);
for (int32 index = 0; index < fApplications.CountItems(); ++index) {
fApplications.ItemAt(index)->SendMessageToClient(&clientMessage);
}
fPendingColors.MakeEmpty();
}
void void
Desktop::_UpdateFloating(int32 previousWorkspace, int32 nextWorkspace, Desktop::_UpdateFloating(int32 previousWorkspace, int32 nextWorkspace,
Window* mouseEventWindow) Window* mouseEventWindow)
+16 -1
View File
@@ -9,9 +9,11 @@
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk> * Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
* Brecht Machiels <brecht@mos6581.org> * Brecht Machiels <brecht@mos6581.org>
* Clemens Zeidler <haiku@clemens-zeidler.de> * Clemens Zeidler <haiku@clemens-zeidler.de>
* Joseph Groover <looncraz@looncraz.net>
*/ */
#ifndef DESKTOP_H #ifndef DESKTOP_H
#define DESKTOP_H #define DESKTOP_H
#include "RapidDebug.h"
#include <Autolock.h> #include <Autolock.h>
@@ -22,7 +24,10 @@
#include <Region.h> #include <Region.h>
#include <Window.h> #include <Window.h>
#include <ServerProtocolStructs.h>
#include "CursorManager.h" #include "CursorManager.h"
#include "DelayedMessage.h"
#include "DesktopListener.h" #include "DesktopListener.h"
#include "DesktopSettings.h" #include "DesktopSettings.h"
#include "EventDispatcher.h" #include "EventDispatcher.h"
@@ -56,7 +61,8 @@ namespace BPrivate {
class Desktop : public DesktopObservable, public MessageLooper, class Desktop : public DesktopObservable, public MessageLooper,
public ScreenOwner { public ScreenOwner {
public: public:
Desktop(uid_t userID, const char* targetScreen); Desktop(uid_t userID,
const char* targetScreen);
virtual ~Desktop(); virtual ~Desktop();
void RegisterListener(DesktopListener* listener); void RegisterListener(DesktopListener* listener);
@@ -74,6 +80,9 @@ public:
void BroadcastToAllApps(int32 code); void BroadcastToAllApps(int32 code);
void BroadcastToAllWindows(int32 code); void BroadcastToAllWindows(int32 code);
int32 GetAllWindowTargets(DelayedMessage& message);
int32 GetAllAppTargets(DelayedMessage& message);
filter_result KeyEvent(uint32 what, int32 key, filter_result KeyEvent(uint32 what, int32 key,
int32 modifiers); int32 modifiers);
// Locking // Locking
@@ -191,6 +200,8 @@ public:
Window* window); Window* window);
void FontsChanged(Window* window); void FontsChanged(Window* window);
void ColorUpdated(Window* window, color_which which,
rgb_color color);
void SetWindowLook(Window* window, window_look look); void SetWindowLook(Window* window, window_look look);
void SetWindowFeel(Window* window, window_feel feel); void SetWindowFeel(Window* window, window_feel feel);
@@ -253,6 +264,8 @@ public:
private: private:
WindowList& _Windows(int32 index); WindowList& _Windows(int32 index);
void _FlushPendingColors();
void _LaunchInputServer(); void _LaunchInputServer();
void _GetLooperName(char* name, size_t size); void _GetLooperName(char* name, size_t size);
void _PrepareQuit(); void _PrepareQuit();
@@ -359,6 +372,8 @@ private:
Window* fBack; Window* fBack;
StackAndTile fStackAndTile; StackAndTile fStackAndTile;
BMessage fPendingColors;
}; };
#endif // DESKTOP_H #endif // DESKTOP_H
+54 -5
View File
@@ -1,11 +1,12 @@
/* /*
* Copyright 2005-2013, Haiku. * Copyright 2005-2015, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler, axeld@pinc-software.de
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk> * Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
* Joseph Groover <looncraz@looncraz.net>
*/ */
@@ -297,7 +298,10 @@ DesktopSettingsPrivate::_Load()
snprintf(colorName, sizeof(colorName), "color%" B_PRId32, snprintf(colorName, sizeof(colorName), "color%" B_PRId32,
(int32)index_to_color_which(i)); (int32)index_to_color_which(i));
settings.FindInt32(colorName, (int32*)&fShared.colors[i]); if (settings.FindInt32(colorName, (int32*)&fShared.colors[i]) != B_OK) {
// Set obviously bad value so the Appearance app can detect it
fShared.colors[i] = B_TRANSPARENT_COLOR;
}
} }
} }
} }
@@ -647,12 +651,16 @@ DesktopSettingsPrivate::WorkspacesMessage(int32 index) const
void void
DesktopSettingsPrivate::SetUIColor(color_which which, const rgb_color color) DesktopSettingsPrivate::SetUIColor(color_which which, const rgb_color color,
bool* changed)
{ {
int32 index = color_which_to_index(which); int32 index = color_which_to_index(which);
if (index < 0 || index >= kColorWhichCount) if (index < 0 || index >= kColorWhichCount)
return; return;
if (changed != NULL)
*changed = fShared.colors[index] != color;
fShared.colors[index] = color; fShared.colors[index] = color;
// TODO: deprecate the background_color member of the menu_info struct, // TODO: deprecate the background_color member of the menu_info struct,
// otherwise we have to keep this duplication... // otherwise we have to keep this duplication...
@@ -663,6 +671,47 @@ DesktopSettingsPrivate::SetUIColor(color_which which, const rgb_color color)
} }
void
DesktopSettingsPrivate::SetUIColors(const BMessage& colors, bool* changed)
{
int32 count = colors.CountNames(B_RGB_32_BIT_TYPE);
if (count <= 0)
return;
int32 index = 0;
int32 colorIndex = 0;
char* name = NULL;
type_code type;
rgb_color color;
color_which which = B_NO_COLOR;
while (colors.GetInfo(B_RGB_32_BIT_TYPE, index, &name, &type) == B_OK) {
which = which_ui_color(name);
colorIndex = color_which_to_index(which);
if (colorIndex < 0 || colorIndex >= kColorWhichCount
|| colors.FindColor(name, &color) != B_OK) {
if (changed != NULL)
changed[index] = false;
++index;
continue;
}
if (changed != NULL)
changed[index] = fShared.colors[colorIndex] != color;
fShared.colors[colorIndex] = color;
if (which == (int32)B_MENU_BACKGROUND_COLOR)
fMenuInfo.background_color = color;
++index;
}
Save(kAppearanceSettings);
}
rgb_color rgb_color
DesktopSettingsPrivate::UIColor(color_which which) const DesktopSettingsPrivate::UIColor(color_which which) const
{ {
@@ -977,9 +1026,9 @@ LockedDesktopSettings::SetShowAllDraggers(bool show)
void void
LockedDesktopSettings::SetUIColor(color_which which, const rgb_color color) LockedDesktopSettings::SetUIColors(const BMessage& colors, bool* changed)
{ {
fSettings->SetUIColor(which, color); fSettings->SetUIColors(colors, &changed[0]);
} }
+6 -3
View File
@@ -1,10 +1,11 @@
/* /*
* Copyright 2001-2013, Haiku. * Copyright 2001-2015, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler, axeld@pinc-software.de
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk> * Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
* Joseph Groover <looncraz@looncraz.net>
*/ */
#ifndef DESKTOP_SETTINGS_H #ifndef DESKTOP_SETTINGS_H
#define DESKTOP_SETTINGS_H #define DESKTOP_SETTINGS_H
@@ -14,6 +15,8 @@
#include <Menu.h> #include <Menu.h>
#include <Message.h> #include <Message.h>
#include <ServerProtocolStructs.h>
class Desktop; class Desktop;
class DesktopSettingsPrivate; class DesktopSettingsPrivate;
@@ -97,8 +100,8 @@ public:
void SetShowAllDraggers(bool show); void SetShowAllDraggers(bool show);
void SetUIColor(color_which which, void SetUIColors(const BMessage& colors,
const rgb_color color); bool* changed = NULL);
void SetSubpixelAntialiasing(bool subpix); void SetSubpixelAntialiasing(bool subpix);
void SetHinting(uint8 hinting); void SetHinting(uint8 hinting);
+9 -2
View File
@@ -1,10 +1,11 @@
/* /*
* Copyright 2005-2013, Haiku. * Copyright 2005-2015, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler, axeld@pinc-software.de
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk> * Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
* Joseph Groover <looncraz@looncraz.net>
*/ */
#ifndef DESKTOP_SETTINGS_PRIVATE_H #ifndef DESKTOP_SETTINGS_PRIVATE_H
#define DESKTOP_SETTINGS_PRIVATE_H #define DESKTOP_SETTINGS_PRIVATE_H
@@ -72,7 +73,13 @@ public:
const BMessage* WorkspacesMessage(int32 index) const; const BMessage* WorkspacesMessage(int32 index) const;
void SetUIColor(color_which which, void SetUIColor(color_which which,
const rgb_color color); const rgb_color color,
bool* changed = NULL);
void SetUIColors(const BMessage& colors,
bool* changed = NULL);
// changed must be boolean array equal in
// size to colors' size
rgb_color UIColor(color_which which) const; rgb_color UIColor(color_which which) const;
void SetSubpixelAntialiasing(bool subpix); void SetSubpixelAntialiasing(bool subpix);
+57
View File
@@ -9,6 +9,7 @@
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler, axeld@pinc-software.de
* Michael Pfeiffer <laplace@users.sourceforge.net> * Michael Pfeiffer <laplace@users.sourceforge.net>
* Julian Harnath <julian.harnath@rwth-aachen.de> * Julian Harnath <julian.harnath@rwth-aachen.de>
* Joseph Groover <looncraz@looncraz.net>
*/ */
//! Data classes for working with BView states and draw parameters //! Data classes for working with BView states and draw parameters
@@ -43,6 +44,10 @@ DrawState::DrawState()
fHighColor((rgb_color){ 0, 0, 0, 255 }), fHighColor((rgb_color){ 0, 0, 0, 255 }),
fLowColor((rgb_color){ 255, 255, 255, 255 }), fLowColor((rgb_color){ 255, 255, 255, 255 }),
fWhichHighColor(B_NO_COLOR),
fWhichLowColor(B_NO_COLOR),
fWhichHighColorTint(B_NO_TINT),
fWhichLowColorTint(B_NO_TINT),
fPattern(kSolidHigh), fPattern(kSolidHigh),
fDrawingMode(B_OP_COPY), fDrawingMode(B_OP_COPY),
@@ -78,6 +83,10 @@ DrawState::DrawState(const DrawState& other)
fHighColor(other.fHighColor), fHighColor(other.fHighColor),
fLowColor(other.fLowColor), fLowColor(other.fLowColor),
fWhichHighColor(other.fWhichHighColor),
fWhichLowColor(other.fWhichLowColor),
fWhichHighColorTint(other.fWhichHighColorTint),
fWhichLowColorTint(other.fWhichLowColorTint),
fPattern(other.fPattern), fPattern(other.fPattern),
fDrawingMode(other.fDrawingMode), fDrawingMode(other.fDrawingMode),
@@ -218,6 +227,10 @@ DrawState::ReadFromLink(BPrivate::LinkReceiver& link)
fPenSize = info.penSize; fPenSize = info.penSize;
fHighColor = info.highColor; fHighColor = info.highColor;
fLowColor = info.lowColor; fLowColor = info.lowColor;
fWhichHighColor = info.whichHighColor;
fWhichLowColor = info.whichLowColor;
fWhichHighColorTint = info.whichHighColorTint;
fWhichLowColorTint = info.whichLowColorTint;
fPattern = info.pattern; fPattern = info.pattern;
fDrawingMode = info.drawingMode; fDrawingMode = info.drawingMode;
fOrigin = info.origin; fOrigin = info.origin;
@@ -283,6 +296,10 @@ DrawState::WriteToLink(BPrivate::LinkSender& link) const
info.viewStateInfo.penSize = fPenSize; info.viewStateInfo.penSize = fPenSize;
info.viewStateInfo.highColor = fHighColor; info.viewStateInfo.highColor = fHighColor;
info.viewStateInfo.lowColor = fLowColor; info.viewStateInfo.lowColor = fLowColor;
info.viewStateInfo.whichHighColor = fWhichHighColor;
info.viewStateInfo.whichLowColor = fWhichLowColor;
info.viewStateInfo.whichHighColorTint = fWhichHighColorTint;
info.viewStateInfo.whichLowColorTint = fWhichLowColorTint;
info.viewStateInfo.pattern = (::pattern)fPattern.GetPattern(); info.viewStateInfo.pattern = (::pattern)fPattern.GetPattern();
info.viewStateInfo.drawingMode = fDrawingMode; info.viewStateInfo.drawingMode = fDrawingMode;
info.viewStateInfo.origin = fOrigin; info.viewStateInfo.origin = fOrigin;
@@ -577,6 +594,42 @@ DrawState::SetLowColor(rgb_color color)
} }
void
DrawState::SetHighUIColor(color_which which, float tint)
{
fWhichHighColor = which;
fWhichHighColorTint = tint;
}
color_which
DrawState::HighUIColor(float* tint) const
{
if (tint != NULL)
*tint = fWhichHighColorTint;
return fWhichHighColor;
}
void
DrawState::SetLowUIColor(color_which which, float tint)
{
fWhichLowColor = which;
fWhichLowColorTint = tint;
}
color_which
DrawState::LowUIColor(float* tint) const
{
if (tint != NULL)
*tint = fWhichLowColorTint;
return fWhichLowColor;
}
void void
DrawState::SetPattern(const Pattern& pattern) DrawState::SetPattern(const Pattern& pattern)
{ {
@@ -760,6 +813,10 @@ DrawState::PrintToStream() const
fHighColor.red, fHighColor.green, fHighColor.blue, fHighColor.alpha); fHighColor.red, fHighColor.green, fHighColor.blue, fHighColor.alpha);
printf("\t LowColor: r=%d g=%d b=%d a=%d\n", printf("\t LowColor: r=%d g=%d b=%d a=%d\n",
fLowColor.red, fLowColor.green, fLowColor.blue, fLowColor.alpha); fLowColor.red, fLowColor.green, fLowColor.blue, fLowColor.alpha);
printf("\t WhichHighColor: %i\n", fWhichHighColor);
printf("\t WhichLowColor: %i\n", fWhichLowColor);
printf("\t WhichHighColorTint: %.3f\n", fWhichHighColorTint);
printf("\t WhichLowColorTint: %.3f\n", fWhichLowColorTint);
printf("\t Pattern: %" B_PRIu64 "\n", fPattern.GetInt64()); printf("\t Pattern: %" B_PRIu64 "\n", fPattern.GetInt64());
printf("\t DrawMode: %" B_PRIu32 "\n", (uint32)fDrawingMode); printf("\t DrawMode: %" B_PRIu32 "\n", (uint32)fDrawingMode);
+12
View File
@@ -8,6 +8,7 @@
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler, axeld@pinc-software.de
* Julian Harnath <julian.harnath@rwth-aachen.de> * Julian Harnath <julian.harnath@rwth-aachen.de>
* Joseph Groover <looncraz@looncraz.net>
*/ */
#ifndef _DRAW_STATE_H_ #ifndef _DRAW_STATE_H_
#define _DRAW_STATE_H_ #define _DRAW_STATE_H_
@@ -100,6 +101,12 @@ public:
rgb_color LowColor() const rgb_color LowColor() const
{ return fLowColor; } { return fLowColor; }
void SetHighUIColor(color_which which, float tint);
color_which HighUIColor(float* tint) const;
void SetLowUIColor(color_which which, float tint);
color_which LowUIColor(float* tint) const;
void SetPattern(const Pattern& pattern); void SetPattern(const Pattern& pattern);
const Pattern& GetPattern() const const Pattern& GetPattern() const
{ return fPattern; } { return fPattern; }
@@ -175,6 +182,11 @@ protected:
rgb_color fHighColor; rgb_color fHighColor;
rgb_color fLowColor; rgb_color fLowColor;
color_which fWhichHighColor;
color_which fWhichLowColor;
float fWhichHighColorTint;
float fWhichLowColorTint;
Pattern fPattern; Pattern fPattern;
drawing_mode fDrawingMode; drawing_mode fDrawingMode;
+1
View File
@@ -56,6 +56,7 @@ Server app_server :
CursorData.cpp CursorData.cpp
CursorManager.cpp CursorManager.cpp
CursorSet.cpp CursorSet.cpp
DelayedMessage.cpp
Desktop.cpp Desktop.cpp
DesktopListener.cpp DesktopListener.cpp
DesktopSettings.cpp DesktopSettings.cpp
+3 -1
View File
@@ -22,7 +22,9 @@ class MessageLooper : public BLocker {
virtual bool Run(); virtual bool Run();
virtual void Quit(); virtual void Quit();
status_t PostMessage(int32 code, bigtime_t timeout = B_INFINITE_TIMEOUT); status_t PostMessage(int32 code,
bigtime_t timeout = B_INFINITE_TIMEOUT);
thread_id Thread() const { return fThread; } thread_id Thread() const { return fThread; }
bool IsQuitting() const { return fQuitting; } bool IsQuitting() const { return fQuitting; }
sem_id DeathSemaphore() const { return fDeathSemaphore; } sem_id DeathSemaphore() const { return fDeathSemaphore; }
+10
View File
@@ -271,11 +271,17 @@ string_for_message_code(uint32 code, BString& string)
CODE(AS_VIEW_SET_PEN_SIZE); CODE(AS_VIEW_SET_PEN_SIZE);
CODE(AS_VIEW_GET_PEN_SIZE); CODE(AS_VIEW_GET_PEN_SIZE);
CODE(AS_VIEW_SET_HIGH_COLOR); CODE(AS_VIEW_SET_HIGH_COLOR);
CODE(AS_VIEW_SET_HIGH_UI_COLOR);
CODE(AS_VIEW_SET_LOW_COLOR); CODE(AS_VIEW_SET_LOW_COLOR);
CODE(AS_VIEW_SET_LOW_UI_COLOR);
CODE(AS_VIEW_SET_VIEW_COLOR); CODE(AS_VIEW_SET_VIEW_COLOR);
CODE(AS_VIEW_SET_VIEW_UI_COLOR);
CODE(AS_VIEW_GET_HIGH_COLOR); CODE(AS_VIEW_GET_HIGH_COLOR);
CODE(AS_VIEW_GET_HIGH_UI_COLOR);
CODE(AS_VIEW_GET_LOW_COLOR); CODE(AS_VIEW_GET_LOW_COLOR);
CODE(AS_VIEW_GET_LOW_UI_COLOR);
CODE(AS_VIEW_GET_VIEW_COLOR); CODE(AS_VIEW_GET_VIEW_COLOR);
CODE(AS_VIEW_GET_VIEW_UI_COLOR);
CODE(AS_VIEW_PRINT_ALIASING); CODE(AS_VIEW_PRINT_ALIASING);
CODE(AS_VIEW_CLIP_TO_PICTURE); CODE(AS_VIEW_CLIP_TO_PICTURE);
CODE(AS_VIEW_GET_CLIP_REGION); CODE(AS_VIEW_GET_CLIP_REGION);
@@ -292,6 +298,7 @@ string_for_message_code(uint32 code, BString& string)
CODE(AS_VIEW_COPY_BITS); CODE(AS_VIEW_COPY_BITS);
CODE(AS_VIEW_DRAW_PICTURE); CODE(AS_VIEW_DRAW_PICTURE);
CODE(AS_VIEW_INVALIDATE_RECT); CODE(AS_VIEW_INVALIDATE_RECT);
CODE(AS_VIEW_DELAYED_INVALIDATE_RECT);
CODE(AS_VIEW_INVALIDATE_REGION); CODE(AS_VIEW_INVALIDATE_REGION);
CODE(AS_VIEW_INVERT_RECT); CODE(AS_VIEW_INVERT_RECT);
CODE(AS_VIEW_MOVE_TO); CODE(AS_VIEW_MOVE_TO);
@@ -307,6 +314,9 @@ string_for_message_code(uint32 code, BString& string)
CODE(AS_DIRECT_WINDOW_GET_SYNC_DATA); CODE(AS_DIRECT_WINDOW_GET_SYNC_DATA);
CODE(AS_DIRECT_WINDOW_SET_FULLSCREEN); CODE(AS_DIRECT_WINDOW_SET_FULLSCREEN);
// Internal messages
CODE(AS_COLOR_MAP_UPDATED);
default: default:
string << "unkown code: " << code; string << "unkown code: " << code;
break; break;
+3 -21
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2013, Haiku. * Copyright 2001-2015, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -12,6 +12,7 @@
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk> * Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
* Philippe Saint-Pierre, stpere@gmail.com * Philippe Saint-Pierre, stpere@gmail.com
* Wim van der Meer, <WPJvanderMeer@gmail.com> * Wim van der Meer, <WPJvanderMeer@gmail.com>
* Joseph Groover <looncraz@looncraz.net>
*/ */
@@ -2813,25 +2814,6 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
break; break;
} }
case AS_SET_UI_COLOR:
{
STRACE(("ServerApp %s: Set UI Color\n", Signature()));
// Attached Data:
// 1) color_which which
// 2) rgb_color color
color_which which;
rgb_color color;
link.Read<color_which>(&which);
if (link.Read<rgb_color>(&color) == B_OK) {
LockedDesktopSettings settings(fDesktop);
settings.SetUIColor(which, color);
}
break;
}
case AS_GET_ACCELERANT_INFO: case AS_GET_ACCELERANT_INFO:
{ {
STRACE(("ServerApp %s: get accelerant info\n", Signature())); STRACE(("ServerApp %s: get accelerant info\n", Signature()));
@@ -3204,7 +3186,7 @@ ServerApp::_MessageLooper()
STRACE(("info: ServerApp::_MessageLooper() listening on port %" B_PRId32 STRACE(("info: ServerApp::_MessageLooper() listening on port %" B_PRId32
".\n", fMessagePort)); ".\n", fMessagePort));
err = receiver.GetNextMessage(code, B_INFINITE_TIMEOUT); err = receiver.GetNextMessage(code);
if (err != B_OK || code == B_QUIT_REQUESTED) { if (err != B_OK || code == B_QUIT_REQUESTED) {
STRACE(("ServerApp: application seems to be gone...\n")); STRACE(("ServerApp: application seems to be gone...\n"));
+155 -2
View File
@@ -12,6 +12,7 @@
* Philippe Saint-Pierre <stpere@gmail.com> * Philippe Saint-Pierre <stpere@gmail.com>
* Brecht Machiels <brecht@mos6581.org> * Brecht Machiels <brecht@mos6581.org>
* Julian Harnath <julian.harnath@rwth-aachen.de> * Julian Harnath <julian.harnath@rwth-aachen.de>
* Joseph Groover <looncraz@looncraz.net>
*/ */
@@ -1015,7 +1016,15 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
{ {
// Has the all-window look // Has the all-window look
fDesktop->FontsChanged(fWindow); fDesktop->FontsChanged(fWindow);
// TODO: tell client about this, too, and relayout... break;
}
// Forward to client
case B_FONTS_UPDATED:
{
// TODO: would knowing which font was changed be useful?
BMessage message(code);
SendMessageToClient(&message);
break; break;
} }
@@ -1770,6 +1779,116 @@ fDesktop->LockSingleWindow();
fWindow->GetDrawingEngine()->SetHighColor(color); fWindow->GetDrawingEngine()->SetHighColor(color);
break; break;
} }
case AS_VIEW_SET_HIGH_UI_COLOR:
{
color_which which = B_NO_COLOR;
float tint = B_NO_TINT;
if (link.Read<color_which>(&which) != B_OK
|| link.Read<float>(&tint) != B_OK )
break;
fCurrentView->CurrentState()->SetHighUIColor(which, tint);
// TODO: should we do more color_which validity checking?
if (which != B_NO_COLOR) {
DesktopSettings settings(fDesktop);
rgb_color color = tint_color(settings.UIColor(which), tint);
fCurrentView->CurrentState()->SetHighColor(color);
fWindow->GetDrawingEngine()->SetHighColor(color);
}
break;
}
case AS_VIEW_SET_LOW_UI_COLOR:
{
color_which which = B_NO_COLOR;
float tint = B_NO_TINT;
if (link.Read<color_which>(&which) != B_OK
|| link.Read<float>(&tint) != B_OK )
break;
fCurrentView->CurrentState()->SetLowUIColor(which, tint);
// TODO: should we do more color_which validity checking?
if (which != B_NO_COLOR) {
DesktopSettings settings(fDesktop);
rgb_color color = tint_color(settings.UIColor(which), tint);
fCurrentView->CurrentState()->SetLowColor(color);
fWindow->GetDrawingEngine()->SetLowColor(color);
}
break;
}
case AS_VIEW_SET_VIEW_UI_COLOR:
{
color_which which = B_NO_COLOR;
float tint = B_NO_TINT;
if (link.Read<color_which>(&which) != B_OK
|| link.Read<float>(&tint) != B_OK )
break;
// TODO: should we do more color_which validity checking?
fCurrentView->SetViewUIColor(which, tint);
break;
}
case AS_VIEW_GET_HIGH_UI_COLOR:
{
float tint;
color_which which = fCurrentView->CurrentState()->HighUIColor(&tint);
rgb_color color = fCurrentView->CurrentState()->HighColor();
DTRACE(("ServerWindow %s: Message AS_VIEW_GET_HIGH_UI_COLOR: "
"View: %s -> color_which(%i) tint(%.3f) - rgb_color(%i, %i,"
" %i, %i)\n", Title(), fCurrentView->Name(), which, tint,
color.red, color.green, color.blue, color.alpha));
fLink.StartMessage(B_OK);
fLink.Attach<color_which>(which);
fLink.Attach<float>(tint);
fLink.Attach<rgb_color>(color);
fLink.Flush();
break;
}
case AS_VIEW_GET_LOW_UI_COLOR:
{
float tint;
color_which which = fCurrentView->CurrentState()->LowUIColor(&tint);
rgb_color color = fCurrentView->CurrentState()->LowColor();
DTRACE(("ServerWindow %s: Message AS_VIEW_GET_LOW_UI_COLOR: "
"View: %s -> color_which(%i) tint(%.3f) - rgb_color(%i, %i,"
" %i, %i)\n", Title(), fCurrentView->Name(), which, tint,
color.red, color.green, color.blue, color.alpha));
fLink.StartMessage(B_OK);
fLink.Attach<color_which>(which);
fLink.Attach<float>(tint);
fLink.Attach<rgb_color>(color);
fLink.Flush();
break;
}
case AS_VIEW_GET_VIEW_UI_COLOR:
{
float tint;
color_which which = fCurrentView->ViewUIColor(&tint);
rgb_color color = fCurrentView->ViewColor();
DTRACE(("ServerWindow %s: Message AS_VIEW_GET_VIEW_UI_COLOR: "
"View: %s -> color_which(%i) tint(%.3f) - rgb_color(%i, %i,"
" %i, %i)\n", Title(), fCurrentView->Name(), which, tint,
color.red, color.green, color.blue, color.alpha));
fLink.StartMessage(B_OK);
fLink.Attach<color_which>(which);
fLink.Attach<float>(tint);
fLink.Attach<rgb_color>(color);
fLink.Flush();
break;
}
case AS_VIEW_GET_HIGH_COLOR: case AS_VIEW_GET_HIGH_COLOR:
{ {
rgb_color color = fCurrentView->CurrentState()->HighColor(); rgb_color color = fCurrentView->CurrentState()->HighColor();
@@ -2112,11 +2231,45 @@ fDesktop->LockSingleWindow();
fCurrentView->Name(), invalidRect.left, invalidRect.top, fCurrentView->Name(), invalidRect.left, invalidRect.top,
invalidRect.right, invalidRect.bottom)); invalidRect.right, invalidRect.bottom));
View* view = NULL;
if (link.Read<View*>(&view) != B_OK)
view = fCurrentView;
// make sure the view is still available!
if (view != fCurrentView
&& !fWindow->TopView()->HasView(view))
break;
BRegion dirty(invalidRect); BRegion dirty(invalidRect);
fWindow->InvalidateView(fCurrentView, dirty); fWindow->InvalidateView(view, dirty);
} }
break; break;
} }
case AS_VIEW_DELAYED_INVALIDATE_RECT:
{
bigtime_t time = 0;
BRect invalidRect;
if (link.Read<bigtime_t>(&time) == B_OK
&& link.Read<BRect>(&invalidRect) == B_OK) {
DTRACE(("ServerWindow %s: Message "
"AS_VIEW_DELAYED_INVALIDATE_RECT: "
"View: %s -> BRect(%.1f, %.1f, %.1f, %.1f) at time %llu\n",
Title(), fCurrentView->Name(), invalidRect.left,
invalidRect.top, invalidRect.right, invalidRect.bottom,
time));
DelayedMessage delayed(AS_VIEW_INVALIDATE_RECT, time, true);
delayed.AddTarget(MessagePort());
delayed.SetMerge(DM_MERGE_DUPLICATES);
if (delayed.Attach<BRect>(invalidRect) == B_OK
&& delayed.Attach<View*>(fCurrentView) == B_OK)
delayed.Flush();
}
break;
}
case AS_VIEW_INVALIDATE_REGION: case AS_VIEW_INVALIDATE_REGION:
{ {
// NOTE: looks like this call is NOT affected by origin and scale // NOTE: looks like this call is NOT affected by origin and scale
+66
View File
@@ -10,6 +10,7 @@
* Marcus Overhagen <marcus@overhagen.de> * Marcus Overhagen <marcus@overhagen.de>
* Adrien Destugues <pulkomandy@pulkomandy.tk * Adrien Destugues <pulkomandy@pulkomandy.tk
* Julian Harnath <julian.harnath@rwth-aachen.de> * Julian Harnath <julian.harnath@rwth-aachen.de>
* Joseph Groover <looncraz@looncraz.net>
*/ */
#include "View.h" #include "View.h"
@@ -90,6 +91,8 @@ View::View(IntRect frame, IntPoint scrollingOffset, const char* name,
fScrollingOffset(scrollingOffset), fScrollingOffset(scrollingOffset),
fViewColor((rgb_color){ 255, 255, 255, 255 }), fViewColor((rgb_color){ 255, 255, 255, 255 }),
fWhichViewColor(B_NO_COLOR),
fWhichViewColorTint(B_NO_TINT),
fViewBitmap(NULL), fViewBitmap(NULL),
fBitmapResizingMode(0), fBitmapResizingMode(0),
fBitmapOptions(0), fBitmapOptions(0),
@@ -436,6 +439,21 @@ View::FindViews(uint32 flags, BObjectList<View>& list, int32& left)
} }
bool
View::HasView(View* view)
{
if (view == this)
return true;
for (View* child = FirstChild(); child; child = child->NextSibling()) {
if (child->HasView(view))
return true;
}
return false;
}
View* View*
View::ViewAt(const BPoint& where) View::ViewAt(const BPoint& where)
{ {
@@ -907,6 +925,54 @@ View::CopyBits(IntRect src, IntRect dst, BRegion& windowContentClipping)
// #pragma mark - // #pragma mark -
void
View::ColorUpdated(color_which which, rgb_color color)
{
float tint = B_NO_TINT;
if (fWhichViewColor == which)
SetViewColor(tint_color(color, fWhichViewColorTint));
if (CurrentState()->HighUIColor(&tint) == which)
CurrentState()->SetHighColor(tint_color(color, tint));
if (CurrentState()->LowUIColor(&tint) == which)
CurrentState()->SetLowColor(tint_color(color, tint));
for (View* child = FirstChild(); child != NULL;
child = child->NextSibling()) {
child->ColorUpdated(which, color);
}
}
void
View::SetViewUIColor(color_which which, float tint)
{
if (which != B_NO_COLOR) {
DesktopSettings settings(fWindow->Desktop());
SetViewColor(tint_color(settings.UIColor(which), tint));
}
fWhichViewColor = which;
fWhichViewColorTint = tint;
}
color_which
View::ViewUIColor(float* tint)
{
if (tint != NULL)
*tint = fWhichViewColorTint;
return fWhichViewColor;
}
// #pragma mark -
void void
View::PushState() View::PushState()
{ {
+9
View File
@@ -10,6 +10,7 @@
* Marcus Overhagen <marcus@overhagen.de> * Marcus Overhagen <marcus@overhagen.de>
* Adrien Destugues <pulkomandy@pulkomandy.tk> * Adrien Destugues <pulkomandy@pulkomandy.tk>
* Julian Harnath <julian.harnath@rwth-aachen.de> * Julian Harnath <julian.harnath@rwth-aachen.de>
* Joseph Groover <looncraz@looncraz.net>
*/ */
#ifndef VIEW_H #ifndef VIEW_H
#define VIEW_H #define VIEW_H
@@ -19,6 +20,7 @@
#include "IntRect.h" #include "IntRect.h"
#include <GraphicsDefs.h> #include <GraphicsDefs.h>
#include <InterfaceDefs.h>
#include <ObjectList.h> #include <ObjectList.h>
#include <Region.h> #include <Region.h>
#include <String.h> #include <String.h>
@@ -110,6 +112,7 @@ public:
void FindViews(uint32 flags, BObjectList<View>& list, void FindViews(uint32 flags, BObjectList<View>& list,
int32& left); int32& left);
bool HasView(View* view);
View* ViewAt(const BPoint& where); View* ViewAt(const BPoint& where);
public: public:
@@ -135,6 +138,10 @@ public:
void SetViewColor(const rgb_color& color) void SetViewColor(const rgb_color& color)
{ fViewColor = color; } { fViewColor = color; }
void ColorUpdated(color_which which, rgb_color color);
void SetViewUIColor(color_which which, float tint);
color_which ViewUIColor(float* tint);
ServerBitmap* ViewBitmap() const ServerBitmap* ViewBitmap() const
{ return fViewBitmap; } { return fViewBitmap; }
void SetViewBitmap(ServerBitmap* bitmap, void SetViewBitmap(ServerBitmap* bitmap,
@@ -234,6 +241,8 @@ protected:
IntPoint fScrollingOffset; IntPoint fScrollingOffset;
rgb_color fViewColor; rgb_color fViewColor;
color_which fWhichViewColor;
float fWhichViewColorTint;
ServerBitmap* fViewBitmap; ServerBitmap* fViewBitmap;
IntRect fBitmapSource; IntRect fBitmapSource;
IntRect fBitmapDestination; IntRect fBitmapDestination;
+11
View File
@@ -1242,6 +1242,17 @@ Window::FontsChanged(BRegion* updateRegion)
} }
void
Window::ColorsChanged(BRegion* updateRegion)
{
::Decorator* decorator = Decorator();
if (decorator != NULL) {
DesktopSettings settings(fDesktop);
decorator->ColorsChanged(settings, updateRegion);
}
}
void void
Window::SetLook(window_look look, BRegion* updateRegion) Window::SetLook(window_look look, BRegion* updateRegion)
{ {
+1
View File
@@ -243,6 +243,7 @@ public:
void HighlightDecorator(bool active); void HighlightDecorator(bool active);
void FontsChanged(BRegion* updateRegion); void FontsChanged(BRegion* updateRegion);
void ColorsChanged(BRegion* updateRegion);
void SetLook(window_look look, void SetLook(window_look look,
BRegion* updateRegion); BRegion* updateRegion);
+6 -3
View File
@@ -63,11 +63,13 @@ DecorAddOn::AllocateDecorator(Desktop* desktop, DrawingEngine* engine,
DesktopSettings settings(desktop); DesktopSettings settings(desktop);
Decorator* decorator; Decorator* decorator;
decorator = _AllocateDecorator(settings, rect); decorator = _AllocateDecorator(settings, rect, desktop);
desktop->UnlockSingleWindow(); desktop->UnlockSingleWindow();
if (!decorator) if (!decorator)
return NULL; return NULL;
decorator->UpdateColors(settings);
if (decorator->AddTab(settings, title, look, flags) == false) { if (decorator->AddTab(settings, title, look, flags) == false) {
delete decorator; delete decorator;
return NULL; return NULL;
@@ -94,9 +96,10 @@ DecorAddOn::GetDesktopListeners()
Decorator* Decorator*
DecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect) DecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect,
Desktop* desktop)
{ {
return new (std::nothrow)SATDecorator(settings, rect); return new (std::nothrow)SATDecorator(settings, rect, desktop);
} }
+1 -1
View File
@@ -53,7 +53,7 @@ public:
protected: protected:
virtual Decorator* _AllocateDecorator(DesktopSettings& settings, virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
BRect rect); BRect rect, Desktop* desktop);
DesktopListenerList fDesktopListeners; DesktopListenerList fDesktopListeners;
+34 -5
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2013 Haiku, Inc. * Copyright 2001-2015 Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -8,6 +8,7 @@
* John Scipione, jscipione@gmail.com * John Scipione, jscipione@gmail.com
* Ingo Weinhold, ingo_weinhold@gmx.de * Ingo Weinhold, ingo_weinhold@gmx.de
* Clemens Zeidler, haiku@clemens-zeidler.de * Clemens Zeidler, haiku@clemens-zeidler.de
* Joseph Groover <looncraz@looncraz.net>
*/ */
@@ -20,6 +21,8 @@
#include <Region.h> #include <Region.h>
#include "Desktop.h"
#include "DesktopSettings.h"
#include "DrawingEngine.h" #include "DrawingEngine.h"
@@ -68,7 +71,8 @@ Decorator::Tab::Tab()
\param settings DesktopSettings pointer. \param settings DesktopSettings pointer.
\param frame Decorator frame rectangle \param frame Decorator frame rectangle
*/ */
Decorator::Decorator(DesktopSettings& settings, BRect frame) Decorator::Decorator(DesktopSettings& settings, BRect frame,
Desktop* desktop)
: :
fDrawingEngine(NULL), fDrawingEngine(NULL),
fDrawState(), fDrawState(),
@@ -87,6 +91,7 @@ Decorator::Decorator(DesktopSettings& settings, BRect frame)
fTopTab(NULL), fTopTab(NULL),
fDesktop(desktop),
fFootprintValid(false) fFootprintValid(false)
{ {
memset(&fRegionHighlights, HIGHLIGHT_NONE, sizeof(fRegionHighlights)); memset(&fRegionHighlights, HIGHLIGHT_NONE, sizeof(fRegionHighlights));
@@ -234,11 +239,26 @@ Decorator::SetFlags(int32 tab, uint32 flags, BRegion* updateRegion)
void void
Decorator::FontsChanged(DesktopSettings& settings, BRegion* updateRegion) Decorator::FontsChanged(DesktopSettings& settings, BRegion* updateRegion)
{ {
_FontsChanged(settings, updateRegion); _FontsChanged(settings, updateRegion);
_InvalidateFootprint(); _InvalidateFootprint();
} }
/*! \brief Called when a system colors change.
*/
void
Decorator::ColorsChanged(DesktopSettings& settings, BRegion* updateRegion)
{
UpdateColors(settings);
if (updateRegion != NULL)
updateRegion->Include(&GetFootprint());
_InvalidateBitmaps();
}
/*! \brief Sets the decorator's window look /*! \brief Sets the decorator's window look
\param look New value for the look \param look New value for the look
*/ */
@@ -249,6 +269,7 @@ Decorator::SetLook(int32 tab, DesktopSettings& settings, window_look look,
Decorator::Tab* decoratorTab = fTabList.ItemAt(tab); Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
if (decoratorTab == NULL) if (decoratorTab == NULL)
return; return;
_SetLook(decoratorTab, settings, look, updateRect); _SetLook(decoratorTab, settings, look, updateRect);
_InvalidateFootprint(); _InvalidateFootprint();
// the border very likely changed // the border very likely changed
@@ -496,6 +517,15 @@ Decorator::GetFootprint()
} }
/*! \brief Returns our Desktop object pointer
*/
::Desktop*
Decorator::GetDesktop()
{
return fDesktop;
}
/*! \brief Performs hit-testing for the decorator. /*! \brief Performs hit-testing for the decorator.
The base class provides a basic implementation, recognizing only button and The base class provides a basic implementation, recognizing only button and
@@ -821,9 +851,8 @@ Decorator::DrawZoom(int32 tab)
rgb_color rgb_color
Decorator::UIColor(color_which which) Decorator::UIColor(color_which which)
{ {
// TODO: for now - calling ui_color() from within the app_server DesktopSettings settings(fDesktop);
// will always return the default colors (as there is no be_app) return settings.UIColor(which);
return ui_color(which);
} }
+12 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2013 Haiku, Inc. * Copyright 2001-2015 Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -8,6 +8,7 @@
* John Scipione, jscipione@gmail.com * John Scipione, jscipione@gmail.com
* Ingo Weinhold, ingo_weinhold@gmx.de * Ingo Weinhold, ingo_weinhold@gmx.de
* Clemens Zeidler, haiku@clemens-zeidler.de * Clemens Zeidler, haiku@clemens-zeidler.de
* Joseph Groover <looncraz@looncraz.net>
*/ */
#ifndef DECORATOR_H #ifndef DECORATOR_H
#define DECORATOR_H #define DECORATOR_H
@@ -20,6 +21,7 @@
#include "DrawState.h" #include "DrawState.h"
class Desktop;
class DesktopSettings; class DesktopSettings;
class DrawingEngine; class DrawingEngine;
class ServerBitmap; class ServerBitmap;
@@ -98,7 +100,8 @@ public:
}; };
Decorator(DesktopSettings& settings, Decorator(DesktopSettings& settings,
BRect frame); BRect frame,
Desktop* desktop);
virtual ~Decorator(); virtual ~Decorator();
virtual Decorator::Tab* AddTab(DesktopSettings& settings, virtual Decorator::Tab* AddTab(DesktopSettings& settings,
@@ -123,6 +126,11 @@ public:
void FontsChanged(DesktopSettings& settings, void FontsChanged(DesktopSettings& settings,
BRegion* updateRegion = NULL); BRegion* updateRegion = NULL);
void ColorsChanged(DesktopSettings& settings,
BRegion* updateRegion = NULL);
virtual void UpdateColors(DesktopSettings& settings) = 0;
void SetLook(int32 tab, DesktopSettings& settings, void SetLook(int32 tab, DesktopSettings& settings,
window_look look, window_look look,
BRegion* updateRegion = NULL); BRegion* updateRegion = NULL);
@@ -160,6 +168,7 @@ public:
virtual Region RegionAt(BPoint where, int32& tab) const; virtual Region RegionAt(BPoint where, int32& tab) const;
const BRegion& GetFootprint(); const BRegion& GetFootprint();
::Desktop* GetDesktop();
void MoveBy(float x, float y); void MoveBy(float x, float y);
void MoveBy(BPoint offset); void MoveBy(BPoint offset);
@@ -281,6 +290,7 @@ protected:
BObjectList<Decorator::Tab> fTabList; BObjectList<Decorator::Tab> fTabList;
private: private:
Desktop* fDesktop;
BRegion fFootprint; BRegion fFootprint;
bool fFootprintValid : 1; bool fFootprintValid : 1;
+42 -33
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2013 Haiku, Inc. * Copyright 2001-2015 Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -10,6 +10,7 @@
* John Scipione, jscipione@gmail.com * John Scipione, jscipione@gmail.com
* Ingo Weinhold, ingo_weinhold@gmx.de * Ingo Weinhold, ingo_weinhold@gmx.de
* Clemens Zeidler, haiku@clemens-zeidler.de * Clemens Zeidler, haiku@clemens-zeidler.de
* Joseph Groover <looncraz@looncraz.net>
*/ */
@@ -72,9 +73,10 @@ blend_color_value(uint8 a, uint8 b, float position)
// TODO: get rid of DesktopSettings here, and introduce private accessor // TODO: get rid of DesktopSettings here, and introduce private accessor
// methods to the Decorator base class // methods to the Decorator base class
DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect) DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
Desktop* desktop)
: :
TabDecorator(settings, rect) TabDecorator(settings, rect, desktop)
{ {
// TODO: If the decorator was created with a frame too small, it should // TODO: If the decorator was created with a frame too small, it should
// resize itself! // resize itself!
@@ -112,35 +114,35 @@ DefaultDecorator::GetComponentColors(Component component, uint8 highlight,
case COMPONENT_TAB: case COMPONENT_TAB:
if (tab && tab->buttonFocus) { if (tab && tab->buttonFocus) {
_colors[COLOR_TAB_FRAME_LIGHT] _colors[COLOR_TAB_FRAME_LIGHT]
= tint_color(kFocusFrameColor, B_DARKEN_2_TINT); = tint_color(fFocusFrameColor, B_DARKEN_2_TINT);
_colors[COLOR_TAB_FRAME_DARK] _colors[COLOR_TAB_FRAME_DARK]
= tint_color(kFocusFrameColor, B_DARKEN_3_TINT); = tint_color(fFocusFrameColor, B_DARKEN_3_TINT);
_colors[COLOR_TAB] = kFocusTabColor; _colors[COLOR_TAB] = fFocusTabColor;
_colors[COLOR_TAB_LIGHT] = kFocusTabColorLight; _colors[COLOR_TAB_LIGHT] = fFocusTabColorLight;
_colors[COLOR_TAB_BEVEL] = kFocusTabColorBevel; _colors[COLOR_TAB_BEVEL] = fFocusTabColorBevel;
_colors[COLOR_TAB_SHADOW] = kFocusTabColorShadow; _colors[COLOR_TAB_SHADOW] = fFocusTabColorShadow;
_colors[COLOR_TAB_TEXT] = kFocusTextColor; _colors[COLOR_TAB_TEXT] = fFocusTextColor;
} else { } else {
_colors[COLOR_TAB_FRAME_LIGHT] _colors[COLOR_TAB_FRAME_LIGHT]
= tint_color(kNonFocusFrameColor, B_DARKEN_2_TINT); = tint_color(fNonFocusFrameColor, B_DARKEN_2_TINT);
_colors[COLOR_TAB_FRAME_DARK] _colors[COLOR_TAB_FRAME_DARK]
= tint_color(kNonFocusFrameColor, B_DARKEN_3_TINT); = tint_color(fNonFocusFrameColor, B_DARKEN_3_TINT);
_colors[COLOR_TAB] = kNonFocusTabColor; _colors[COLOR_TAB] = fNonFocusTabColor;
_colors[COLOR_TAB_LIGHT] = kNonFocusTabColorLight; _colors[COLOR_TAB_LIGHT] = fNonFocusTabColorLight;
_colors[COLOR_TAB_BEVEL] = kNonFocusTabColorBevel; _colors[COLOR_TAB_BEVEL] = fNonFocusTabColorBevel;
_colors[COLOR_TAB_SHADOW] = kNonFocusTabColorShadow; _colors[COLOR_TAB_SHADOW] = fNonFocusTabColorShadow;
_colors[COLOR_TAB_TEXT] = kNonFocusTextColor; _colors[COLOR_TAB_TEXT] = fNonFocusTextColor;
} }
break; break;
case COMPONENT_CLOSE_BUTTON: case COMPONENT_CLOSE_BUTTON:
case COMPONENT_ZOOM_BUTTON: case COMPONENT_ZOOM_BUTTON:
if (tab && tab->buttonFocus) { if (tab && tab->buttonFocus) {
_colors[COLOR_BUTTON] = kFocusTabColor; _colors[COLOR_BUTTON] = fFocusTabColor;
_colors[COLOR_BUTTON_LIGHT] = kFocusTabColorLight; _colors[COLOR_BUTTON_LIGHT] = fFocusTabColorLight;
} else { } else {
_colors[COLOR_BUTTON] = kNonFocusTabColor; _colors[COLOR_BUTTON] = fNonFocusTabColor;
_colors[COLOR_BUTTON_LIGHT] = kNonFocusTabColorLight; _colors[COLOR_BUTTON_LIGHT] = fNonFocusTabColorLight;
} }
break; break;
@@ -151,21 +153,21 @@ DefaultDecorator::GetComponentColors(Component component, uint8 highlight,
case COMPONENT_RESIZE_CORNER: case COMPONENT_RESIZE_CORNER:
default: default:
if (tab && tab->buttonFocus) { if (tab && tab->buttonFocus) {
_colors[0] = tint_color(kFocusFrameColor, B_DARKEN_2_TINT); _colors[0] = tint_color(fFocusFrameColor, B_DARKEN_2_TINT);
_colors[1] = tint_color(kFocusFrameColor, B_LIGHTEN_2_TINT); _colors[1] = tint_color(fFocusFrameColor, B_LIGHTEN_2_TINT);
_colors[2] = kFocusFrameColor; _colors[2] = fFocusFrameColor;
_colors[3] = tint_color(kFocusFrameColor, _colors[3] = tint_color(fFocusFrameColor,
(B_DARKEN_1_TINT + B_NO_TINT) / 2); (B_DARKEN_1_TINT + B_NO_TINT) / 2);
_colors[4] = tint_color(kFocusFrameColor, B_DARKEN_2_TINT); _colors[4] = tint_color(fFocusFrameColor, B_DARKEN_2_TINT);
_colors[5] = tint_color(kFocusFrameColor, B_DARKEN_3_TINT); _colors[5] = tint_color(fFocusFrameColor, B_DARKEN_3_TINT);
} else { } else {
_colors[0] = tint_color(kNonFocusFrameColor, B_DARKEN_2_TINT); _colors[0] = tint_color(fNonFocusFrameColor, B_DARKEN_2_TINT);
_colors[1] = tint_color(kNonFocusFrameColor, B_LIGHTEN_2_TINT); _colors[1] = tint_color(fNonFocusFrameColor, B_LIGHTEN_2_TINT);
_colors[2] = kNonFocusFrameColor; _colors[2] = fNonFocusFrameColor;
_colors[3] = tint_color(kNonFocusFrameColor, _colors[3] = tint_color(fNonFocusFrameColor,
(B_DARKEN_1_TINT + B_NO_TINT) / 2); (B_DARKEN_1_TINT + B_NO_TINT) / 2);
_colors[4] = tint_color(kNonFocusFrameColor, B_DARKEN_2_TINT); _colors[4] = tint_color(fNonFocusFrameColor, B_DARKEN_2_TINT);
_colors[5] = tint_color(kNonFocusFrameColor, B_DARKEN_3_TINT); _colors[5] = tint_color(fNonFocusFrameColor, B_DARKEN_3_TINT);
} }
// for the resize-border highlight dye everything bluish. // for the resize-border highlight dye everything bluish.
@@ -181,6 +183,13 @@ DefaultDecorator::GetComponentColors(Component component, uint8 highlight,
} }
void
DefaultDecorator::UpdateColors(DesktopSettings& settings)
{
TabDecorator::UpdateColors(settings);
}
// #pragma mark - Protected methods // #pragma mark - Protected methods
+5 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2013 Haiku, Inc. * Copyright 2001-2015 Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -10,6 +10,7 @@
* John Scipione, jscipione@gmail.com * John Scipione, jscipione@gmail.com
* Ingo Weinhold, ingo_weinhold@gmx.de * Ingo Weinhold, ingo_weinhold@gmx.de
* Clemens Zeidler, haiku@clemens-zeidler.de * Clemens Zeidler, haiku@clemens-zeidler.de
* Joseph Groover <looncraz@looncraz.net>
*/ */
#ifndef DEFAULT_DECORATOR_H #ifndef DEFAULT_DECORATOR_H
#define DEFAULT_DECORATOR_H #define DEFAULT_DECORATOR_H
@@ -25,13 +26,15 @@ class ServerBitmap;
class DefaultDecorator: public TabDecorator { class DefaultDecorator: public TabDecorator {
public: public:
DefaultDecorator(DesktopSettings& settings, DefaultDecorator(DesktopSettings& settings,
BRect frame); BRect frame, Desktop* desktop);
virtual ~DefaultDecorator(); virtual ~DefaultDecorator();
virtual void GetComponentColors(Component component, virtual void GetComponentColors(Component component,
uint8 highlight, ComponentColors _colors, uint8 highlight, ComponentColors _colors,
Decorator::Tab* tab = NULL); Decorator::Tab* tab = NULL);
virtual void UpdateColors(DesktopSettings& settings);
protected: protected:
virtual void _DrawFrame(BRect rect); virtual void _DrawFrame(BRect rect);
+30 -22
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2013 Haiku, Inc. * Copyright 2001-2015 Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -10,6 +10,7 @@
* John Scipione, jscipione@gmail.com * John Scipione, jscipione@gmail.com
* Ingo Weinhold, ingo_weinhold@gmx.de * Ingo Weinhold, ingo_weinhold@gmx.de
* Clemens Zeidler, haiku@clemens-zeidler.de * Clemens Zeidler, haiku@clemens-zeidler.de
* Joseph Groover <looncraz@looncraz.net>
*/ */
@@ -63,28 +64,11 @@ static const float kResizeKnobSize = 18.0;
// TODO: get rid of DesktopSettings here, and introduce private accessor // TODO: get rid of DesktopSettings here, and introduce private accessor
// methods to the Decorator base class // methods to the Decorator base class
TabDecorator::TabDecorator(DesktopSettings& settings, BRect frame) TabDecorator::TabDecorator(DesktopSettings& settings, BRect frame,
Desktop* desktop)
: :
Decorator(settings, frame), Decorator(settings, frame, desktop),
fOldMovingTab(0, 0, -1, -1), fOldMovingTab(0, 0, -1, -1)
// focus color constants
kFocusFrameColor(settings.UIColor(B_WINDOW_BORDER_COLOR)),
kFocusTabColor(settings.UIColor(B_WINDOW_TAB_COLOR)),
kFocusTabColorLight(tint_color(kFocusTabColor,
(B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2)),
kFocusTabColorBevel(tint_color(kFocusTabColor, B_LIGHTEN_2_TINT)),
kFocusTabColorShadow(tint_color(kFocusTabColor,
(B_DARKEN_1_TINT + B_NO_TINT) / 2)),
kFocusTextColor(settings.UIColor(B_WINDOW_TEXT_COLOR)),
// non-focus color constants
kNonFocusFrameColor(settings.UIColor(B_WINDOW_INACTIVE_BORDER_COLOR)),
kNonFocusTabColor(settings.UIColor(B_WINDOW_INACTIVE_TAB_COLOR)),
kNonFocusTabColorLight(tint_color(kNonFocusTabColor,
(B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2)),
kNonFocusTabColorBevel(tint_color(kNonFocusTabColor, B_LIGHTEN_2_TINT)),
kNonFocusTabColorShadow(tint_color(kNonFocusTabColor,
(B_DARKEN_1_TINT + B_NO_TINT) / 2)),
kNonFocusTextColor(settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR))
{ {
STRACE(("TabDecorator:\n")); STRACE(("TabDecorator:\n"));
STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n", STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",
@@ -209,6 +193,30 @@ TabDecorator::SetRegionHighlight(Region region, uint8 highlight,
} }
void
TabDecorator::UpdateColors(DesktopSettings& settings)
{
// Desktop is write locked, so be quick about it.
fFocusFrameColor = settings.UIColor(B_WINDOW_BORDER_COLOR);
fFocusTabColor = settings.UIColor(B_WINDOW_TAB_COLOR);
fFocusTabColorLight = tint_color(fFocusTabColor,
(B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2);
fFocusTabColorBevel = tint_color(fFocusTabColor, B_LIGHTEN_2_TINT);
fFocusTabColorShadow = tint_color(fFocusTabColor,
(B_DARKEN_1_TINT + B_NO_TINT) / 2);
fFocusTextColor = settings.UIColor(B_WINDOW_TEXT_COLOR);
fNonFocusFrameColor = settings.UIColor(B_WINDOW_INACTIVE_BORDER_COLOR);
fNonFocusTabColor = settings.UIColor(B_WINDOW_INACTIVE_TAB_COLOR);
fNonFocusTabColorLight = tint_color(fNonFocusTabColor,
(B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2);
fNonFocusTabColorBevel = tint_color(fNonFocusTabColor, B_LIGHTEN_2_TINT);
fNonFocusTabColorShadow = tint_color(fNonFocusTabColor,
(B_DARKEN_1_TINT + B_NO_TINT) / 2);
fNonFocusTextColor = settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR);
}
void void
TabDecorator::_DoLayout() TabDecorator::_DoLayout()
{ {
+17 -14
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2013 Haiku, Inc. * Copyright 2001-2015 Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -10,6 +10,7 @@
* John Scipione, jscipione@gmail.com * John Scipione, jscipione@gmail.com
* Ingo Weinhold, ingo_weinhold@gmx.de * Ingo Weinhold, ingo_weinhold@gmx.de
* Clemens Zeidler, haiku@clemens-zeidler.de * Clemens Zeidler, haiku@clemens-zeidler.de
* Joseph Groover <looncraz@looncraz.net>
*/ */
#ifndef TAB_DECORATOR_H #ifndef TAB_DECORATOR_H
#define TAB_DECORATOR_H #define TAB_DECORATOR_H
@@ -26,7 +27,7 @@ class Desktop;
class TabDecorator: public Decorator { class TabDecorator: public Decorator {
public: public:
TabDecorator(DesktopSettings& settings, TabDecorator(DesktopSettings& settings,
BRect frame); BRect frame, Desktop* desktop);
virtual ~TabDecorator(); virtual ~TabDecorator();
protected: protected:
@@ -71,6 +72,8 @@ public:
uint8 highlight, BRegion* dirty, uint8 highlight, BRegion* dirty,
int32 tab = -1); int32 tab = -1);
virtual void UpdateColors(DesktopSettings& settings);
protected: protected:
virtual void _DoLayout(); virtual void _DoLayout();
virtual void _DoTabLayout(); virtual void _DoTabLayout();
@@ -132,21 +135,21 @@ protected:
BRegion fTabsRegion; BRegion fTabsRegion;
BRect fOldMovingTab; BRect fOldMovingTab;
const rgb_color kFocusFrameColor; rgb_color fFocusFrameColor;
const rgb_color kFocusTabColor; rgb_color fFocusTabColor;
const rgb_color kFocusTabColorLight; rgb_color fFocusTabColorLight;
const rgb_color kFocusTabColorBevel; rgb_color fFocusTabColorBevel;
const rgb_color kFocusTabColorShadow; rgb_color fFocusTabColorShadow;
const rgb_color kFocusTextColor; rgb_color fFocusTextColor;
const rgb_color kNonFocusFrameColor; rgb_color fNonFocusFrameColor;
const rgb_color kNonFocusTabColor; rgb_color fNonFocusTabColor;
const rgb_color kNonFocusTabColorLight; rgb_color fNonFocusTabColorLight;
const rgb_color kNonFocusTabColorBevel; rgb_color fNonFocusTabColorBevel;
const rgb_color kNonFocusTabColorShadow; rgb_color fNonFocusTabColorShadow;
const rgb_color kNonFocusTextColor; rgb_color fNonFocusTextColor;
}; };
+26 -16
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010, Haiku, Inc. * Copyright 2010-2015, Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -46,19 +46,29 @@ static const rgb_color kHighlightFrameColors[6] = {
{ 8, 8, 8, 255 } { 8, 8, 8, 255 }
}; };
SATDecorator::SATDecorator(DesktopSettings& settings, BRect frame) SATDecorator::SATDecorator(DesktopSettings& settings, BRect frame,
Desktop* desktop)
: :
DefaultDecorator(settings, frame), DefaultDecorator(settings, frame, desktop)
kHighlightTabColor(tint_color(kFocusTabColor, B_DARKEN_2_TINT)),
kHighlightTabColorLight(tint_color(kHighlightTabColor,
(B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2)),
kHighlightTabColorBevel(tint_color(kHighlightTabColor, B_LIGHTEN_2_TINT)),
kHighlightTabColorShadow(tint_color(kHighlightTabColor,
(B_DARKEN_1_TINT + B_NO_TINT) / 2))
{ {
} }
void
SATDecorator::UpdateColors(DesktopSettings& settings)
{
DefaultDecorator::UpdateColors(settings);
// Called during construction, and during any changes
fHighlightTabColor = tint_color(fFocusTabColor, B_DARKEN_2_TINT);
fHighlightTabColorLight = tint_color(fHighlightTabColor,
(B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2);
fHighlightTabColorBevel = tint_color(fHighlightTabColor, B_LIGHTEN_2_TINT);
fHighlightTabColorShadow= tint_color(fHighlightTabColor,
(B_DARKEN_1_TINT + B_NO_TINT) / 2);
}
void void
SATDecorator::GetComponentColors(Component component, uint8 highlight, SATDecorator::GetComponentColors(Component component, uint8 highlight,
ComponentColors _colors, Decorator::Tab* _tab) ComponentColors _colors, Decorator::Tab* _tab)
@@ -82,17 +92,17 @@ SATDecorator::GetComponentColors(Component component, uint8 highlight,
case COMPONENT_TAB: case COMPONENT_TAB:
_colors[COLOR_TAB_FRAME_LIGHT] = kFrameColors[0]; _colors[COLOR_TAB_FRAME_LIGHT] = kFrameColors[0];
_colors[COLOR_TAB_FRAME_DARK] = kFrameColors[3]; _colors[COLOR_TAB_FRAME_DARK] = kFrameColors[3];
_colors[COLOR_TAB] = kHighlightTabColor; _colors[COLOR_TAB] = fHighlightTabColor;
_colors[COLOR_TAB_LIGHT] = kHighlightTabColorLight; _colors[COLOR_TAB_LIGHT] = fHighlightTabColorLight;
_colors[COLOR_TAB_BEVEL] = kHighlightTabColorBevel; _colors[COLOR_TAB_BEVEL] = fHighlightTabColorBevel;
_colors[COLOR_TAB_SHADOW] = kHighlightTabColorShadow; _colors[COLOR_TAB_SHADOW] = fHighlightTabColorShadow;
_colors[COLOR_TAB_TEXT] = kFocusTextColor; _colors[COLOR_TAB_TEXT] = fFocusTextColor;
break; break;
case COMPONENT_CLOSE_BUTTON: case COMPONENT_CLOSE_BUTTON:
case COMPONENT_ZOOM_BUTTON: case COMPONENT_ZOOM_BUTTON:
_colors[COLOR_BUTTON] = kHighlightTabColor; _colors[COLOR_BUTTON] = fHighlightTabColor;
_colors[COLOR_BUTTON_LIGHT] = kHighlightTabColorLight; _colors[COLOR_BUTTON_LIGHT] = fHighlightTabColorLight;
break; break;
case COMPONENT_LEFT_BORDER: case COMPONENT_LEFT_BORDER:
+10 -6
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010, Haiku, Inc. * Copyright 2010-2015, Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -15,6 +15,9 @@
#include "StackAndTile.h" #include "StackAndTile.h"
class Desktop;
class SATDecorator : public DefaultDecorator { class SATDecorator : public DefaultDecorator {
public: public:
enum { enum {
@@ -23,18 +26,19 @@ public:
public: public:
SATDecorator(DesktopSettings& settings, SATDecorator(DesktopSettings& settings,
BRect frame); BRect frame, Desktop* desktop);
protected: protected:
virtual void UpdateColors(DesktopSettings& settings);
virtual void GetComponentColors(Component component, virtual void GetComponentColors(Component component,
uint8 highlight, ComponentColors _colors, uint8 highlight, ComponentColors _colors,
Decorator::Tab* tab = NULL); Decorator::Tab* tab = NULL);
private: private:
const rgb_color kHighlightTabColor; rgb_color fHighlightTabColor;
const rgb_color kHighlightTabColorLight; rgb_color fHighlightTabColorLight;
const rgb_color kHighlightTabColorBevel; rgb_color fHighlightTabColorBevel;
const rgb_color kHighlightTabColorShadow; rgb_color fHighlightTabColorShadow;
}; };