* Decorator:

- Added ExtendDirtyRegion(), given a decorator region it extends the given
    dirty region. Implemented only in DefaultDecorator yet.
  - Added [Set]RegionHighlight() which allows to set/get a highlight for a
    decorator region. The visual representation of the set highlight value
    is up to the derived classes. The only globally defined value is
    HIGHLIGHT_RESIZE_BORDER, though it's not implemented anywhere yet.
* DefaultDecorator: Added the highlight for the component as a parameter to
  GetComponentColors(). Added a wrapper _GetComponentColors() with the old
  interface, fetching the highlight from the base class.
* SATDecorator: Defines and interprets its own highlight value
  HIGHLIGHT_STACK_AND_TILE.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39640 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2010-11-26 01:03:27 +00:00
parent d66b59cdfc
commit 2b602c7364
6 changed files with 207 additions and 40 deletions
@@ -97,7 +97,14 @@ SATDecorator::SATDecorator(DesktopSettings& settings, BRect frame,
void
SATDecorator::HighlightTab(bool active, BRegion* dirty)
{
dirty->Include(fTabRect);
if (active == fTabHighlighted)
return;
uint8 highlight = active ? HIGHLIGHT_STACK_AND_TILE : 0;
SetRegionHighlight(REGION_TAB, highlight, dirty);
SetRegionHighlight(REGION_CLOSE_BUTTON, highlight, dirty);
SetRegionHighlight(REGION_ZOOM_BUTTON, highlight, dirty);
fTabHighlighted = active;
}
@@ -105,11 +112,16 @@ SATDecorator::HighlightTab(bool active, BRegion* dirty)
void
SATDecorator::HighlightBorders(bool active, BRegion* dirty)
{
dirty->Include(fLeftBorder);
dirty->Include(fRightBorder);
dirty->Include(fTopBorder);
dirty->Include(fBottomBorder);
dirty->Include(fResizeRect);
if (active == fBordersHighlighted)
return;
uint8 highlight = active ? HIGHLIGHT_STACK_AND_TILE : 0;
SetRegionHighlight(REGION_LEFT_BORDER, highlight, dirty);
SetRegionHighlight(REGION_RIGHT_BORDER, highlight, dirty);
SetRegionHighlight(REGION_TOP_BORDER, highlight, dirty);
SetRegionHighlight(REGION_BOTTOM_BORDER, highlight, dirty);
SetRegionHighlight(REGION_RIGHT_BOTTOM_CORNER, highlight, dirty);
fBordersHighlighted = active;
}
@@ -452,15 +464,17 @@ SATDecorator::DrawButtons(const BRect& invalid)
void
SATDecorator::GetComponentColors(Component component, ComponentColors _colors)
SATDecorator::GetComponentColors(Component component, uint8 highlight,
ComponentColors _colors)
{
// we handle only our own highlights
if (highlight != HIGHLIGHT_STACK_AND_TILE) {
DefaultDecorator::GetComponentColors(component, highlight, _colors);
return;
}
switch (component) {
case COMPONENT_TAB:
if (!fTabHighlighted) {
DefaultDecorator::GetComponentColors(component, _colors);
return;
}
_colors[COLOR_TAB_FRAME_LIGHT] = kFrameColors[0];
_colors[COLOR_TAB_FRAME_DARK] = kFrameColors[3];
_colors[COLOR_TAB] = kHighlightTabColor;
@@ -472,11 +486,6 @@ SATDecorator::GetComponentColors(Component component, ComponentColors _colors)
case COMPONENT_CLOSE_BUTTON:
case COMPONENT_ZOOM_BUTTON:
if (!fTabHighlighted) {
DefaultDecorator::GetComponentColors(component, _colors);
return;
}
_colors[COLOR_BUTTON] = kHighlightTabColor;
_colors[COLOR_BUTTON_LIGHT] = kHighlightTabColorLight;
break;
@@ -487,11 +496,6 @@ SATDecorator::GetComponentColors(Component component, ComponentColors _colors)
case COMPONENT_BOTTOM_BORDER:
case COMPONENT_RESIZE_CORNER:
default:
if (!fBordersHighlighted) {
DefaultDecorator::GetComponentColors(component, _colors);
return;
}
_colors[0] = kHighlightFrameColors[0];
_colors[1] = kHighlightFrameColors[1];
_colors[2] = kHighlightFrameColors[2];
@@ -30,6 +30,11 @@ protected:
class SATDecorator : public DefaultDecorator {
public:
enum {
HIGHLIGHT_STACK_AND_TILE = HIGHLIGHT_USER_DEFINED
};
public:
SATDecorator(DesktopSettings& settings,
BRect frame, window_look look,
@@ -64,7 +69,7 @@ protected:
virtual void DrawButtons(const BRect& invalid);
virtual void GetComponentColors(Component component,
ComponentColors _colors);
uint8 highlight, ComponentColors _colors);
private:
bool fTabHighlighted;
+41
View File
@@ -57,6 +57,7 @@ Decorator::Decorator(DesktopSettings& settings, BRect rect, window_look look,
fFootprintValid(false)
{
memset(&fRegionHighlights, HIGHLIGHT_NONE, sizeof(fRegionHighlights));
}
@@ -421,6 +422,33 @@ Decorator::SetTabLocation(float location, BRegion* updateRegion)
}
/*! \brief Sets a specific highlight for a decorator region.
Can be overridden by derived classes, but the base class version must be
called, if the highlight shall be applied.
\param region The decorator region.
\param highlight The value identifying the kind of highlight.
\param dirty The dirty region to be extended, if the highlight changes. Can
be \c NULL.
\return \c true, if the highlight could be applied.
*/
bool
Decorator::SetRegionHighlight(Region region, uint8 highlight, BRegion* dirty)
{
int32 index = (int32)region - 1;
if (index < 0 || index >= REGION_COUNT - 1)
return false;
fRegionHighlights[index] = highlight;
if (dirty != NULL)
ExtendDirtyRegion(region, *dirty);
return true;
}
bool
Decorator::SetSettings(const BMessage& settings, BRegion* updateRegion)
{
@@ -523,6 +551,19 @@ Decorator::UIColor(color_which which)
}
/*! \brief Extends a dirty region by a decorator region.
Must be implemented by derived classes.
\param region The decorator region.
\param dirty The dirty region to be extended.
*/
void
Decorator::ExtendDirtyRegion(Region region, BRegion& dirty)
{
}
//! Function for calculating layout for the decorator
void
Decorator::_DoLayout()
+28 -1
View File
@@ -44,7 +44,16 @@ public:
REGION_LEFT_TOP_CORNER,
REGION_LEFT_BOTTOM_CORNER,
REGION_RIGHT_TOP_CORNER,
REGION_RIGHT_BOTTOM_CORNER
REGION_RIGHT_BOTTOM_CORNER,
REGION_COUNT
};
enum {
HIGHLIGHT_NONE,
HIGHLIGHT_RESIZE_BORDER,
HIGHLIGHT_USER_DEFINED
};
public:
@@ -106,6 +115,10 @@ public:
virtual float TabLocation() const
{ return 0.0; }
virtual bool SetRegionHighlight(Region region, uint8 highlight,
BRegion* dirty);
inline uint8 RegionHighlight(Region region) const;
bool SetSettings(const BMessage& settings,
BRegion* updateRegion = NULL);
virtual bool GetSettings(BMessage* settings) const;
@@ -121,6 +134,8 @@ public:
rgb_color UIColor(color_which which);
virtual void ExtendDirtyRegion(Region region, BRegion& dirty);
protected:
int32 _TitleWidth() const
{ return fTitle.CountChars(); }
@@ -184,6 +199,18 @@ private:
BRegion fFootprint;
bool fFootprintValid : 1;
uint8 fRegionHighlights[REGION_COUNT - 1];
};
uint8
Decorator::RegionHighlight(Region region) const
{
int32 index = (int32)region - 1;
return index >= 0 && index < REGION_COUNT - 1
? fRegionHighlights[index] : 0;
}
#endif // DECORATOR_H
+99 -15
View File
@@ -242,6 +242,51 @@ DefaultDecorator::RegionAt(BPoint where) const
}
void
DefaultDecorator::ExtendDirtyRegion(Region region, BRegion& dirty)
{
switch (region) {
case REGION_TAB:
dirty.Include(fTabRect);
break;
case REGION_CLOSE_BUTTON:
if ((fFlags & B_NOT_CLOSABLE) == 0)
dirty.Include(fCloseRect);
break;
case REGION_ZOOM_BUTTON:
if ((fFlags & B_NOT_ZOOMABLE) == 0)
dirty.Include(fZoomRect);
break;
case REGION_LEFT_BORDER:
dirty.Include(fLeftBorder);
break;
case REGION_RIGHT_BORDER:
dirty.Include(fRightBorder);
break;
case REGION_TOP_BORDER:
dirty.Include(fTopBorder);
break;
case REGION_BOTTOM_BORDER:
dirty.Include(fBottomBorder);
break;
case REGION_RIGHT_BOTTOM_CORNER:
if ((fFlags & B_NOT_RESIZABLE) == 0)
dirty.Include(fResizeRect);
break;
default:
break;
}
}
float
DefaultDecorator::BorderWidth()
{
@@ -438,7 +483,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// top
if (invalid.Intersects(fTopBorder)) {
ComponentColors colors;
GetComponentColors(COMPONENT_TOP_BORDER, colors);
_GetComponentColors(COMPONENT_TOP_BORDER, colors);
for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
@@ -456,7 +501,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// left
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
ComponentColors colors;
GetComponentColors(COMPONENT_LEFT_BORDER, colors);
_GetComponentColors(COMPONENT_LEFT_BORDER, colors);
for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
@@ -466,7 +511,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// bottom
if (invalid.Intersects(fBottomBorder)) {
ComponentColors colors;
GetComponentColors(COMPONENT_BOTTOM_BORDER, colors);
_GetComponentColors(COMPONENT_BOTTOM_BORDER, colors);
for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
@@ -477,7 +522,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// right
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
ComponentColors colors;
GetComponentColors(COMPONENT_RIGHT_BORDER, colors);
_GetComponentColors(COMPONENT_RIGHT_BORDER, colors);
for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
@@ -494,7 +539,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// top
if (invalid.Intersects(fTopBorder)) {
ComponentColors colors;
GetComponentColors(COMPONENT_TOP_BORDER, colors);
_GetComponentColors(COMPONENT_TOP_BORDER, colors);
for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
@@ -512,7 +557,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// left
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
ComponentColors colors;
GetComponentColors(COMPONENT_LEFT_BORDER, colors);
_GetComponentColors(COMPONENT_LEFT_BORDER, colors);
for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
@@ -530,7 +575,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// bottom
if (invalid.Intersects(fBottomBorder)) {
ComponentColors colors;
GetComponentColors(COMPONENT_BOTTOM_BORDER, colors);
_GetComponentColors(COMPONENT_BOTTOM_BORDER, colors);
for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
@@ -541,7 +586,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// right
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
ComponentColors colors;
GetComponentColors(COMPONENT_RIGHT_BORDER, colors);
_GetComponentColors(COMPONENT_RIGHT_BORDER, colors);
for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
@@ -556,7 +601,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
{
// TODO: Draw the borders individually!
ComponentColors colors;
GetComponentColors(COMPONENT_LEFT_BORDER, colors);
_GetComponentColors(COMPONENT_LEFT_BORDER, colors);
fDrawingEngine->StrokeRect(r, colors[5]);
break;
@@ -572,7 +617,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
r = fResizeRect;
ComponentColors colors;
GetComponentColors(COMPONENT_RESIZE_CORNER, colors);
_GetComponentColors(COMPONENT_RESIZE_CORNER, colors);
switch (fLook) {
case B_DOCUMENT_WINDOW_LOOK:
@@ -658,7 +703,7 @@ DefaultDecorator::_DrawTab(BRect invalid)
return;
ComponentColors colors;
GetComponentColors(COMPONENT_TAB, colors);
_GetComponentColors(COMPONENT_TAB, colors);
// outer frame
fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.LeftBottom(),
@@ -740,7 +785,7 @@ DefaultDecorator::_DrawTitle(BRect r)
STRACE(("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
ComponentColors colors;
GetComponentColors(COMPONENT_TAB, colors);
_GetComponentColors(COMPONENT_TAB, colors);
fDrawingEngine->SetDrawingMode(B_OP_OVER);
fDrawingEngine->SetHighColor(colors[COLOR_TAB_TEXT]);
@@ -1141,11 +1186,12 @@ DefaultDecorator::DrawButtons(const BRect& invalid)
The meaning of the color array elements depends on the specified component.
For some components some array elements are unused.
\param region The region for which to return the frame colors.
\param component The component for which to return the frame colors.
\param highlight The highlight set for the component.
\param colors An array of colors to be initialized by the function.
*/
void
DefaultDecorator::GetComponentColors(Component component,
DefaultDecorator::GetComponentColors(Component component, uint8 highlight,
ComponentColors _colors)
{
switch (component) {
@@ -1369,7 +1415,7 @@ DefaultDecorator::_GetBitmapForButton(Component item, bool down, int32 width,
static decorator_bitmap* sBitmapList = NULL;
ComponentColors colors;
GetComponentColors(item, colors);
_GetComponentColors(item, colors);
BAutolock locker(sBitmapListLock);
@@ -1452,3 +1498,41 @@ DefaultDecorator::_GetBitmapForButton(Component item, bool down, int32 width,
sBitmapList = entry;
return bitmap;
}
void
DefaultDecorator::_GetComponentColors(Component component,
ComponentColors _colors)
{
// get the highlight for our component
Region region;
switch (component) {
case COMPONENT_TAB:
region = REGION_TAB;
break;
case COMPONENT_CLOSE_BUTTON:
region = REGION_CLOSE_BUTTON;
break;
case COMPONENT_ZOOM_BUTTON:
region = REGION_ZOOM_BUTTON;
break;
case COMPONENT_LEFT_BORDER:
region = REGION_LEFT_BORDER;
break;
case COMPONENT_RIGHT_BORDER:
region = REGION_RIGHT_BORDER;
break;
case COMPONENT_TOP_BORDER:
region = REGION_TOP_BORDER;
break;
case COMPONENT_BOTTOM_BORDER:
region = REGION_BOTTOM_BORDER;
break;
case COMPONENT_RESIZE_CORNER:
region = REGION_RIGHT_BOTTOM_CORNER;
break;
}
return GetComponentColors(component, RegionHighlight(region), _colors);
}
+7 -1
View File
@@ -40,6 +40,9 @@ public:
virtual Region RegionAt(BPoint where) const;
virtual void ExtendDirtyRegion(Region region,
BRegion& dirty);
float BorderWidth();
float TabHeight();
@@ -116,7 +119,7 @@ protected:
// DefaultDecorator customization points
virtual void DrawButtons(const BRect& invalid);
virtual void GetComponentColors(Component component,
ComponentColors _colors);
uint8 highlight, ComponentColors _colors);
private:
void _UpdateFont(DesktopSettings& settings);
@@ -130,6 +133,9 @@ private:
ServerBitmap* _GetBitmapForButton(Component item, bool down,
int32 width, int32 height);
void _GetComponentColors(Component component,
ComponentColors _colors);
protected:
static const rgb_color kFrameColors[4];
static const rgb_color kFocusFrameColors[2];