Convert BeDecorator to derive from TabDecorator
Also, make the close and zoom buttons update when clicked.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -16,10 +16,11 @@
|
|||||||
|
|
||||||
#include "DecorManager.h"
|
#include "DecorManager.h"
|
||||||
#include "RGBColor.h"
|
#include "RGBColor.h"
|
||||||
|
#include "TabDecorator.h"
|
||||||
|
|
||||||
|
|
||||||
class Desktop;
|
class Desktop;
|
||||||
class ServerBitmap;
|
|
||||||
|
|
||||||
class BeDecorAddOn : public DecorAddOn {
|
class BeDecorAddOn : public DecorAddOn {
|
||||||
public:
|
public:
|
||||||
@@ -30,171 +31,37 @@ protected:
|
|||||||
BRect rect);
|
BRect rect);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BeDecorator: public Decorator {
|
|
||||||
|
class BeDecorator: public TabDecorator {
|
||||||
public:
|
public:
|
||||||
class Tab : public Decorator::Tab {
|
|
||||||
public:
|
|
||||||
Tab();
|
|
||||||
|
|
||||||
uint32 tabOffset;
|
|
||||||
float tabLocation;
|
|
||||||
float textOffset;
|
|
||||||
|
|
||||||
BString truncatedTitle;
|
|
||||||
int32 truncatedTitleLength;
|
|
||||||
|
|
||||||
bool buttonFocus : 1;
|
|
||||||
|
|
||||||
bool isHighlighted : 1;
|
|
||||||
ServerBitmap* closeBitmaps[4];
|
|
||||||
ServerBitmap* zoomBitmaps[4];
|
|
||||||
|
|
||||||
float minTabSize;
|
|
||||||
float maxTabSize;
|
|
||||||
};
|
|
||||||
|
|
||||||
BeDecorator(DesktopSettings& settings, BRect frame);
|
BeDecorator(DesktopSettings& settings, BRect frame);
|
||||||
virtual ~BeDecorator();
|
virtual ~BeDecorator();
|
||||||
|
|
||||||
virtual float TabLocation(int32 tab) const;
|
|
||||||
|
|
||||||
virtual bool GetSettings(BMessage* settings) const;
|
|
||||||
|
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual void Draw();
|
virtual void Draw();
|
||||||
|
|
||||||
virtual void GetSizeLimits(int32* minWidth, int32* minHeight,
|
|
||||||
int32* maxWidth, int32* maxHeight) const;
|
|
||||||
|
|
||||||
virtual Region RegionAt(BPoint where, int32& tab) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum Component {
|
|
||||||
COMPONENT_TAB,
|
|
||||||
|
|
||||||
COMPONENT_CLOSE_BUTTON,
|
|
||||||
COMPONENT_ZOOM_BUTTON,
|
|
||||||
|
|
||||||
COMPONENT_LEFT_BORDER,
|
|
||||||
COMPONENT_RIGHT_BORDER,
|
|
||||||
COMPONENT_TOP_BORDER,
|
|
||||||
COMPONENT_BOTTOM_BORDER,
|
|
||||||
|
|
||||||
COMPONENT_RESIZE_CORNER
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
COLOR_TAB_FRAME_LIGHT = 0,
|
|
||||||
COLOR_TAB_FRAME_DARK = 1,
|
|
||||||
COLOR_TAB = 2,
|
|
||||||
COLOR_TAB_LIGHT = 3,
|
|
||||||
COLOR_TAB_BEVEL = 4,
|
|
||||||
COLOR_TAB_SHADOW = 5,
|
|
||||||
COLOR_TAB_TEXT = 6
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
COLOR_BUTTON = 0,
|
|
||||||
COLOR_BUTTON_LIGHT = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef rgb_color ComponentColors[7];
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void _DoLayout();
|
|
||||||
virtual void _DoTabLayout();
|
|
||||||
void _DistributeTabSize(float delta);
|
|
||||||
|
|
||||||
virtual Decorator::Tab* _AllocateNewTab();
|
|
||||||
BeDecorator::Tab* _TabAt(int32 index) const;
|
|
||||||
|
|
||||||
virtual void _DrawFrame(BRect rect);
|
virtual void _DrawFrame(BRect rect);
|
||||||
virtual void _DrawTab(Decorator::Tab* tab, BRect rect);
|
virtual void _DrawTab(Decorator::Tab* tab, BRect rect);
|
||||||
virtual void _DrawTitle(Decorator::Tab* tab, BRect rect);
|
|
||||||
|
|
||||||
virtual void _DrawClose(Decorator::Tab* tab, bool direct,
|
virtual void _DrawClose(Decorator::Tab* tab, bool direct,
|
||||||
BRect rect);
|
BRect rect);
|
||||||
|
virtual void _DrawTitle(Decorator::Tab* tab, BRect rect);
|
||||||
virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
|
virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
|
||||||
BRect rect);
|
BRect rect);
|
||||||
|
|
||||||
virtual void _SetTitle(Decorator::Tab* tab, const char* string,
|
|
||||||
BRegion* updateRegion = NULL);
|
|
||||||
|
|
||||||
virtual void _FontsChanged(DesktopSettings& settings,
|
|
||||||
BRegion* updateRegion);
|
|
||||||
virtual void _SetLook(Decorator::Tab* tab,
|
|
||||||
DesktopSettings& settings,
|
|
||||||
window_look look,
|
|
||||||
BRegion* updateRegion = NULL);
|
|
||||||
virtual void _SetFlags(Decorator::Tab* tab, uint32 flags,
|
|
||||||
BRegion* updateRegion = NULL);
|
|
||||||
|
|
||||||
virtual void _SetFocus(Decorator::Tab* tab);
|
|
||||||
|
|
||||||
virtual void _MoveBy(BPoint offset);
|
|
||||||
virtual void _ResizeBy(BPoint offset, BRegion* dirty);
|
|
||||||
|
|
||||||
virtual bool _AddTab(DesktopSettings& settings,
|
|
||||||
int32 index = -1,
|
|
||||||
BRegion* updateRegion = NULL);
|
|
||||||
virtual bool _RemoveTab(int32 index,
|
|
||||||
BRegion* updateRegion = NULL);
|
|
||||||
virtual bool _MoveTab(int32 from, int32 to, bool isMoving,
|
|
||||||
BRegion* updateRegion = NULL);
|
|
||||||
|
|
||||||
virtual bool _SetTabLocation(Decorator::Tab* tab, float location,
|
|
||||||
bool isShifting, BRegion* updateRegion = NULL);
|
|
||||||
|
|
||||||
virtual bool _SetSettings(const BMessage& settings,
|
|
||||||
BRegion* updateRegion = NULL);
|
|
||||||
|
|
||||||
virtual void _GetFootprint(BRegion* region);
|
|
||||||
|
|
||||||
void _GetButtonSizeAndOffset(const BRect& tabRect,
|
|
||||||
float* offset, float* size,
|
|
||||||
float* inset) const;
|
|
||||||
|
|
||||||
virtual void DrawButtons(Decorator::Tab* tab,
|
|
||||||
const BRect& invalid);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _UpdateFont(DesktopSettings& settings);
|
void _DrawBlendedRect(Decorator::Tab* tab,
|
||||||
void _DrawBlendedRect(BRect r, bool down);
|
BRect rect, bool down);
|
||||||
void _LayoutTabItems(Decorator::Tab* _tab, const BRect& tabRect);
|
|
||||||
void _InvalidateBitmaps();
|
void _GetComponentColors(Component component,
|
||||||
|
ComponentColors _colors,
|
||||||
|
Decorator::Tab* tab = NULL);
|
||||||
|
|
||||||
inline float _DefaultTextOffset() const;
|
inline float _DefaultTextOffset() const;
|
||||||
inline float _SingleTabOffsetAndSize(float& tabSize);
|
inline float _SingleTabOffsetAndSize(float& tabSize);
|
||||||
|
|
||||||
void _CalculateTabsRegion();
|
void _CalculateTabsRegion();
|
||||||
|
|
||||||
private:
|
|
||||||
RGBColor fButtonHighColor;
|
|
||||||
RGBColor fButtonLowColor;
|
|
||||||
RGBColor fTextColor;
|
|
||||||
RGBColor fTabColor;
|
|
||||||
|
|
||||||
RGBColor* fFrameColors;
|
|
||||||
|
|
||||||
// Individual rects for handling window frame
|
|
||||||
// rendering the proper way
|
|
||||||
BRect fRightBorder;
|
|
||||||
BRect fLeftBorder;
|
|
||||||
BRect fTopBorder;
|
|
||||||
BRect fBottomBorder;
|
|
||||||
|
|
||||||
int32 fBorderWidth;
|
|
||||||
|
|
||||||
BRegion fTabsRegion;
|
|
||||||
BRect fOldMovingTab;
|
|
||||||
|
|
||||||
uint32 fTabOffset;
|
|
||||||
float fTabLocation;
|
|
||||||
|
|
||||||
float fMinTabSize;
|
|
||||||
float fMaxTabSize;
|
|
||||||
|
|
||||||
bool fWasDoubleClick;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -525,39 +525,6 @@ DefaultDecorator::_DrawZoom(Decorator::Tab* _tab, bool direct, BRect rect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DefaultDecorator::_FontsChanged(DesktopSettings& settings,
|
|
||||||
BRegion* updateRegion)
|
|
||||||
{
|
|
||||||
TabDecorator::_FontsChanged(settings, updateRegion);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DefaultDecorator::_SetLook(Decorator::Tab* tab, DesktopSettings& settings,
|
|
||||||
window_look look, BRegion* updateRegion)
|
|
||||||
{
|
|
||||||
_InvalidateBitmaps();
|
|
||||||
|
|
||||||
TabDecorator::_SetLook(tab, settings, look, updateRegion);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DefaultDecorator::_SetFlags(Decorator::Tab* tab, uint32 flags,
|
|
||||||
BRegion* updateRegion)
|
|
||||||
{
|
|
||||||
TabDecorator::_SetFlags(tab, flags, updateRegion);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DefaultDecorator::_SetFocus(Decorator::Tab* tab)
|
|
||||||
{
|
|
||||||
TabDecorator::_SetFocus(tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - Private methods
|
// #pragma mark - Private methods
|
||||||
|
|
||||||
|
|
||||||
@@ -612,14 +579,6 @@ DefaultDecorator::_DrawBlendedRect(DrawingEngine* engine, BRect rect,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DefaultDecorator::_GetButtonSizeAndOffset(const BRect& tabRect, float* _offset,
|
|
||||||
float* _size, float* _inset) const
|
|
||||||
{
|
|
||||||
TabDecorator::_GetButtonSizeAndOffset(tabRect, _offset, _size, _inset);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DefaultDecorator::_InvalidateBitmaps()
|
DefaultDecorator::_InvalidateBitmaps()
|
||||||
{
|
{
|
||||||
@@ -773,38 +732,3 @@ DefaultDecorator::_GetComponentColors(Component component,
|
|||||||
|
|
||||||
return GetComponentColors(component, RegionHighlight(region), _colors, tab);
|
return GetComponentColors(component, RegionHighlight(region), _colors, tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float
|
|
||||||
DefaultDecorator::_DefaultTextOffset() const
|
|
||||||
{
|
|
||||||
return (fTopTab->look == B_FLOATING_WINDOW_LOOK
|
|
||||||
|| fTopTab->look == kLeftTitledWindowLook) ? 10 : 18;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
float
|
|
||||||
DefaultDecorator::_SingleTabOffsetAndSize(float& tabSize)
|
|
||||||
{
|
|
||||||
float maxLocation;
|
|
||||||
if (fTopTab->look != kLeftTitledWindowLook) {
|
|
||||||
tabSize = fRightBorder.right - fLeftBorder.left;
|
|
||||||
} else {
|
|
||||||
tabSize = fBottomBorder.bottom - fTopBorder.top;
|
|
||||||
}
|
|
||||||
TabDecorator::Tab* tab = static_cast<TabDecorator::Tab*>(_TabAt(0));
|
|
||||||
maxLocation = tabSize - tab->maxTabSize;
|
|
||||||
if (maxLocation < 0)
|
|
||||||
maxLocation = 0;
|
|
||||||
|
|
||||||
return floorf(tab->tabLocation * maxLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DefaultDecorator::_CalculateTabsRegion()
|
|
||||||
{
|
|
||||||
fTabsRegion.MakeEmpty();
|
|
||||||
for (int32 i = 0; i < fTabList.CountItems(); i++)
|
|
||||||
fTabsRegion.Include(fTabList.ItemAt(i)->tabRect);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
|
|
||||||
class Desktop;
|
class Desktop;
|
||||||
class ServerBitmap;
|
|
||||||
|
|
||||||
class DefaultDecorator: public TabDecorator {
|
class DefaultDecorator: public TabDecorator {
|
||||||
public:
|
public:
|
||||||
@@ -42,21 +42,6 @@ protected:
|
|||||||
virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
|
virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
|
||||||
BRect r);
|
BRect r);
|
||||||
|
|
||||||
virtual void _SetFocus(Decorator::Tab* tab);
|
|
||||||
|
|
||||||
virtual void _FontsChanged(DesktopSettings& settings,
|
|
||||||
BRegion* updateRegion);
|
|
||||||
|
|
||||||
virtual void _SetLook(Decorator::Tab* tab,
|
|
||||||
DesktopSettings& settings, window_look look,
|
|
||||||
BRegion* updateRegion = NULL);
|
|
||||||
virtual void _SetFlags(Decorator::Tab* tab, uint32 flags,
|
|
||||||
BRegion* updateRegion = NULL);
|
|
||||||
|
|
||||||
virtual void _GetButtonSizeAndOffset(const BRect& tabRect,
|
|
||||||
float* offset, float* size,
|
|
||||||
float* inset) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _DrawButtonBitmap(ServerBitmap* bitmap,
|
void _DrawButtonBitmap(ServerBitmap* bitmap,
|
||||||
bool direct, BRect rect);
|
bool direct, BRect rect);
|
||||||
@@ -71,11 +56,6 @@ private:
|
|||||||
void _GetComponentColors(Component component,
|
void _GetComponentColors(Component component,
|
||||||
ComponentColors _colors,
|
ComponentColors _colors,
|
||||||
Decorator::Tab* tab = NULL);
|
Decorator::Tab* tab = NULL);
|
||||||
|
|
||||||
inline float _DefaultTextOffset() const;
|
|
||||||
inline float _SingleTabOffsetAndSize(float& tabSize);
|
|
||||||
|
|
||||||
void _CalculateTabsRegion();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
#include "DrawState.h"
|
#include "DrawState.h"
|
||||||
#include "FontManager.h"
|
#include "FontManager.h"
|
||||||
#include "PatternHandler.h"
|
#include "PatternHandler.h"
|
||||||
#include "ServerBitmap.h"
|
|
||||||
|
|
||||||
|
|
||||||
//#define DEBUG_DECORATOR
|
//#define DEBUG_DECORATOR
|
||||||
@@ -58,8 +57,14 @@ int_equal(float x, float y)
|
|||||||
TabDecorator::Tab::Tab()
|
TabDecorator::Tab::Tab()
|
||||||
:
|
:
|
||||||
tabOffset(0),
|
tabOffset(0),
|
||||||
tabLocation(0.0),
|
tabLocation(0.0f),
|
||||||
isHighlighted(false)
|
textOffset(10.0f),
|
||||||
|
truncatedTitle(""),
|
||||||
|
truncatedTitleLength(0),
|
||||||
|
buttonFocus(false),
|
||||||
|
isHighlighted(false),
|
||||||
|
minTabSize(0.0f),
|
||||||
|
maxTabSize(0.0f)
|
||||||
{
|
{
|
||||||
closeBitmaps[0] = closeBitmaps[1] = closeBitmaps[2] = closeBitmaps[3]
|
closeBitmaps[0] = closeBitmaps[1] = closeBitmaps[2] = closeBitmaps[3]
|
||||||
= zoomBitmaps[0] = zoomBitmaps[1] = zoomBitmaps[2] = zoomBitmaps[3]
|
= zoomBitmaps[0] = zoomBitmaps[1] = zoomBitmaps[2] = zoomBitmaps[3]
|
||||||
@@ -79,6 +84,7 @@ static const float kResizeKnobSize = 18.0;
|
|||||||
TabDecorator::TabDecorator(DesktopSettings& settings, BRect rect)
|
TabDecorator::TabDecorator(DesktopSettings& settings, BRect rect)
|
||||||
:
|
:
|
||||||
Decorator(settings, rect),
|
Decorator(settings, rect),
|
||||||
|
fOldMovingTab(0, 0, -1, -1),
|
||||||
// focus color constants
|
// focus color constants
|
||||||
kFocusFrameColor(settings.UIColor(B_WINDOW_BORDER_COLOR)),
|
kFocusFrameColor(settings.UIColor(B_WINDOW_BORDER_COLOR)),
|
||||||
kFocusTabColor(settings.UIColor(B_WINDOW_TAB_COLOR)),
|
kFocusTabColor(settings.UIColor(B_WINDOW_TAB_COLOR)),
|
||||||
@@ -96,9 +102,7 @@ TabDecorator::TabDecorator(DesktopSettings& settings, BRect rect)
|
|||||||
kNonFocusTabColorBevel(tint_color(kNonFocusTabColor, B_LIGHTEN_2_TINT)),
|
kNonFocusTabColorBevel(tint_color(kNonFocusTabColor, B_LIGHTEN_2_TINT)),
|
||||||
kNonFocusTabColorShadow(tint_color(kNonFocusTabColor,
|
kNonFocusTabColorShadow(tint_color(kNonFocusTabColor,
|
||||||
(B_DARKEN_1_TINT + B_NO_TINT) / 2)),
|
(B_DARKEN_1_TINT + B_NO_TINT) / 2)),
|
||||||
kNonFocusTextColor(settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR)),
|
kNonFocusTextColor(settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR))
|
||||||
|
|
||||||
fOldMovingTab(0, 0, -1, -1)
|
|
||||||
{
|
{
|
||||||
// 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!
|
||||||
@@ -216,33 +220,6 @@ TabDecorator::RegionAt(BPoint where, int32& tab) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
TabDecorator::SetRegionHighlight(Region region, uint8 highlight,
|
|
||||||
BRegion* dirty, int32 tabIndex)
|
|
||||||
{
|
|
||||||
TabDecorator::Tab* tab = _TabAt(tabIndex);
|
|
||||||
if (tab != NULL) {
|
|
||||||
tab->isHighlighted = highlight != 0;
|
|
||||||
// Invalidate the bitmap caches for the close/zoom button, when the
|
|
||||||
// highlight changes.
|
|
||||||
switch (region) {
|
|
||||||
case REGION_CLOSE_BUTTON:
|
|
||||||
if (highlight != RegionHighlight(region))
|
|
||||||
memset(&tab->closeBitmaps, 0, sizeof(tab->closeBitmaps));
|
|
||||||
break;
|
|
||||||
case REGION_ZOOM_BUTTON:
|
|
||||||
if (highlight != RegionHighlight(region))
|
|
||||||
memset(&tab->zoomBitmaps, 0, sizeof(tab->zoomBitmaps));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Decorator::SetRegionHighlight(region, highlight, dirty, tabIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TabDecorator::ExtendDirtyRegion(Region region, BRegion& dirty)
|
TabDecorator::ExtendDirtyRegion(Region region, BRegion& dirty)
|
||||||
{
|
{
|
||||||
@@ -304,6 +281,121 @@ TabDecorator::ExtendDirtyRegion(Region region, BRegion& dirty)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! Returns the frame colors for the specified decorator component.
|
||||||
|
|
||||||
|
The meaning of the color array elements depends on the specified component.
|
||||||
|
For some components some array elements are unused.
|
||||||
|
|
||||||
|
\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
|
||||||
|
TabDecorator::GetComponentColors(Component component, uint8 highlight,
|
||||||
|
ComponentColors _colors, Decorator::Tab* _tab)
|
||||||
|
{
|
||||||
|
TabDecorator::Tab* tab = static_cast<TabDecorator::Tab*>(_tab);
|
||||||
|
switch (component) {
|
||||||
|
case COMPONENT_TAB:
|
||||||
|
if (tab && tab->buttonFocus) {
|
||||||
|
_colors[COLOR_TAB_FRAME_LIGHT]
|
||||||
|
= tint_color(kFocusFrameColor, B_DARKEN_2_TINT);
|
||||||
|
_colors[COLOR_TAB_FRAME_DARK]
|
||||||
|
= tint_color(kFocusFrameColor, B_DARKEN_3_TINT);
|
||||||
|
_colors[COLOR_TAB] = kFocusTabColor;
|
||||||
|
_colors[COLOR_TAB_LIGHT] = kFocusTabColorLight;
|
||||||
|
_colors[COLOR_TAB_BEVEL] = kFocusTabColorBevel;
|
||||||
|
_colors[COLOR_TAB_SHADOW] = kFocusTabColorShadow;
|
||||||
|
_colors[COLOR_TAB_TEXT] = kFocusTextColor;
|
||||||
|
} else {
|
||||||
|
_colors[COLOR_TAB_FRAME_LIGHT]
|
||||||
|
= tint_color(kNonFocusFrameColor, B_DARKEN_2_TINT);
|
||||||
|
_colors[COLOR_TAB_FRAME_DARK]
|
||||||
|
= tint_color(kNonFocusFrameColor, B_DARKEN_3_TINT);
|
||||||
|
_colors[COLOR_TAB] = kNonFocusTabColor;
|
||||||
|
_colors[COLOR_TAB_LIGHT] = kNonFocusTabColorLight;
|
||||||
|
_colors[COLOR_TAB_BEVEL] = kNonFocusTabColorBevel;
|
||||||
|
_colors[COLOR_TAB_SHADOW] = kNonFocusTabColorShadow;
|
||||||
|
_colors[COLOR_TAB_TEXT] = kNonFocusTextColor;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COMPONENT_CLOSE_BUTTON:
|
||||||
|
case COMPONENT_ZOOM_BUTTON:
|
||||||
|
if (tab && tab->buttonFocus) {
|
||||||
|
_colors[COLOR_BUTTON] = kFocusTabColor;
|
||||||
|
_colors[COLOR_BUTTON_LIGHT] = kFocusTabColorLight;
|
||||||
|
} else {
|
||||||
|
_colors[COLOR_BUTTON] = kNonFocusTabColor;
|
||||||
|
_colors[COLOR_BUTTON_LIGHT] = kNonFocusTabColorLight;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COMPONENT_LEFT_BORDER:
|
||||||
|
case COMPONENT_RIGHT_BORDER:
|
||||||
|
case COMPONENT_TOP_BORDER:
|
||||||
|
case COMPONENT_BOTTOM_BORDER:
|
||||||
|
case COMPONENT_RESIZE_CORNER:
|
||||||
|
default:
|
||||||
|
if (tab && tab->buttonFocus) {
|
||||||
|
_colors[0] = tint_color(kFocusFrameColor, B_DARKEN_2_TINT);
|
||||||
|
_colors[1] = tint_color(kFocusFrameColor, B_LIGHTEN_2_TINT);
|
||||||
|
_colors[2] = kFocusFrameColor;
|
||||||
|
_colors[3] = tint_color(kFocusFrameColor,
|
||||||
|
(B_DARKEN_1_TINT + B_NO_TINT) / 2);
|
||||||
|
_colors[4] = tint_color(kFocusFrameColor, B_DARKEN_2_TINT);
|
||||||
|
_colors[5] = tint_color(kFocusFrameColor, B_DARKEN_3_TINT);
|
||||||
|
} else {
|
||||||
|
_colors[0] = tint_color(kNonFocusFrameColor, B_DARKEN_2_TINT);
|
||||||
|
_colors[1] = tint_color(kNonFocusFrameColor, B_LIGHTEN_2_TINT);
|
||||||
|
_colors[2] = kNonFocusFrameColor;
|
||||||
|
_colors[3] = tint_color(kNonFocusFrameColor,
|
||||||
|
(B_DARKEN_1_TINT + B_NO_TINT) / 2);
|
||||||
|
_colors[4] = tint_color(kNonFocusFrameColor, B_DARKEN_2_TINT);
|
||||||
|
_colors[5] = tint_color(kNonFocusFrameColor, B_DARKEN_3_TINT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// for the resize-border highlight dye everything bluish.
|
||||||
|
if (highlight == HIGHLIGHT_RESIZE_BORDER) {
|
||||||
|
for (int32 i = 0; i < 6; i++) {
|
||||||
|
_colors[i].red = std::max((int)_colors[i].red - 80, 0);
|
||||||
|
_colors[i].green = std::max((int)_colors[i].green - 80, 0);
|
||||||
|
_colors[i].blue = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
TabDecorator::SetRegionHighlight(Region region, uint8 highlight,
|
||||||
|
BRegion* dirty, int32 tabIndex)
|
||||||
|
{
|
||||||
|
TabDecorator::Tab* tab
|
||||||
|
= static_cast<TabDecorator::Tab*>(_TabAt(tabIndex));
|
||||||
|
if (tab != NULL) {
|
||||||
|
tab->isHighlighted = highlight != 0;
|
||||||
|
// Invalidate the bitmap caches for the close/zoom button, when the
|
||||||
|
// highlight changes.
|
||||||
|
switch (region) {
|
||||||
|
case REGION_CLOSE_BUTTON:
|
||||||
|
if (highlight != RegionHighlight(region))
|
||||||
|
memset(&tab->closeBitmaps, 0, sizeof(tab->closeBitmaps));
|
||||||
|
break;
|
||||||
|
case REGION_ZOOM_BUTTON:
|
||||||
|
if (highlight != RegionHighlight(region))
|
||||||
|
memset(&tab->zoomBitmaps, 0, sizeof(tab->zoomBitmaps));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Decorator::SetRegionHighlight(region, highlight, dirty, tabIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
TabDecorator::BorderWidth()
|
TabDecorator::BorderWidth()
|
||||||
{
|
{
|
||||||
@@ -1044,93 +1136,6 @@ TabDecorator::DrawButtons(Decorator::Tab* tab, const BRect& invalid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! Returns the frame colors for the specified decorator component.
|
|
||||||
|
|
||||||
The meaning of the color array elements depends on the specified component.
|
|
||||||
For some components some array elements are unused.
|
|
||||||
|
|
||||||
\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
|
|
||||||
TabDecorator::GetComponentColors(Component component, uint8 highlight,
|
|
||||||
ComponentColors _colors, Decorator::Tab* _tab)
|
|
||||||
{
|
|
||||||
TabDecorator::Tab* tab = static_cast<TabDecorator::Tab*>(_tab);
|
|
||||||
switch (component) {
|
|
||||||
case COMPONENT_TAB:
|
|
||||||
if (tab && tab->buttonFocus) {
|
|
||||||
_colors[COLOR_TAB_FRAME_LIGHT]
|
|
||||||
= tint_color(kFocusFrameColor, B_DARKEN_2_TINT);
|
|
||||||
_colors[COLOR_TAB_FRAME_DARK]
|
|
||||||
= tint_color(kFocusFrameColor, B_DARKEN_3_TINT);
|
|
||||||
_colors[COLOR_TAB] = kFocusTabColor;
|
|
||||||
_colors[COLOR_TAB_LIGHT] = kFocusTabColorLight;
|
|
||||||
_colors[COLOR_TAB_BEVEL] = kFocusTabColorBevel;
|
|
||||||
_colors[COLOR_TAB_SHADOW] = kFocusTabColorShadow;
|
|
||||||
_colors[COLOR_TAB_TEXT] = kFocusTextColor;
|
|
||||||
} else {
|
|
||||||
_colors[COLOR_TAB_FRAME_LIGHT]
|
|
||||||
= tint_color(kNonFocusFrameColor, B_DARKEN_2_TINT);
|
|
||||||
_colors[COLOR_TAB_FRAME_DARK]
|
|
||||||
= tint_color(kNonFocusFrameColor, B_DARKEN_3_TINT);
|
|
||||||
_colors[COLOR_TAB] = kNonFocusTabColor;
|
|
||||||
_colors[COLOR_TAB_LIGHT] = kNonFocusTabColorLight;
|
|
||||||
_colors[COLOR_TAB_BEVEL] = kNonFocusTabColorBevel;
|
|
||||||
_colors[COLOR_TAB_SHADOW] = kNonFocusTabColorShadow;
|
|
||||||
_colors[COLOR_TAB_TEXT] = kNonFocusTextColor;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case COMPONENT_CLOSE_BUTTON:
|
|
||||||
case COMPONENT_ZOOM_BUTTON:
|
|
||||||
if (tab && tab->buttonFocus) {
|
|
||||||
_colors[COLOR_BUTTON] = kFocusTabColor;
|
|
||||||
_colors[COLOR_BUTTON_LIGHT] = kFocusTabColorLight;
|
|
||||||
} else {
|
|
||||||
_colors[COLOR_BUTTON] = kNonFocusTabColor;
|
|
||||||
_colors[COLOR_BUTTON_LIGHT] = kNonFocusTabColorLight;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case COMPONENT_LEFT_BORDER:
|
|
||||||
case COMPONENT_RIGHT_BORDER:
|
|
||||||
case COMPONENT_TOP_BORDER:
|
|
||||||
case COMPONENT_BOTTOM_BORDER:
|
|
||||||
case COMPONENT_RESIZE_CORNER:
|
|
||||||
default:
|
|
||||||
if (tab && tab->buttonFocus) {
|
|
||||||
_colors[0] = tint_color(kFocusFrameColor, B_DARKEN_2_TINT);
|
|
||||||
_colors[1] = tint_color(kFocusFrameColor, B_LIGHTEN_2_TINT);
|
|
||||||
_colors[2] = kFocusFrameColor;
|
|
||||||
_colors[3] = tint_color(kFocusFrameColor,
|
|
||||||
(B_DARKEN_1_TINT + B_NO_TINT) / 2);
|
|
||||||
_colors[4] = tint_color(kFocusFrameColor, B_DARKEN_2_TINT);
|
|
||||||
_colors[5] = tint_color(kFocusFrameColor, B_DARKEN_3_TINT);
|
|
||||||
} else {
|
|
||||||
_colors[0] = tint_color(kNonFocusFrameColor, B_DARKEN_2_TINT);
|
|
||||||
_colors[1] = tint_color(kNonFocusFrameColor, B_LIGHTEN_2_TINT);
|
|
||||||
_colors[2] = kNonFocusFrameColor;
|
|
||||||
_colors[3] = tint_color(kNonFocusFrameColor,
|
|
||||||
(B_DARKEN_1_TINT + B_NO_TINT) / 2);
|
|
||||||
_colors[4] = tint_color(kNonFocusFrameColor, B_DARKEN_2_TINT);
|
|
||||||
_colors[5] = tint_color(kNonFocusFrameColor, B_DARKEN_3_TINT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// for the resize-border highlight dye everything bluish.
|
|
||||||
if (highlight == HIGHLIGHT_RESIZE_BORDER) {
|
|
||||||
for (int32 i = 0; i < 6; i++) {
|
|
||||||
_colors[i].red = std::max((int)_colors[i].red - 80, 0);
|
|
||||||
_colors[i].green = std::max((int)_colors[i].green - 80, 0);
|
|
||||||
_colors[i].blue = 255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TabDecorator::_UpdateFont(DesktopSettings& settings)
|
TabDecorator::_UpdateFont(DesktopSettings& settings)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,39 +40,18 @@ public:
|
|||||||
bool buttonFocus : 1;
|
bool buttonFocus : 1;
|
||||||
|
|
||||||
bool isHighlighted : 1;
|
bool isHighlighted : 1;
|
||||||
ServerBitmap* closeBitmaps[4];
|
|
||||||
ServerBitmap* zoomBitmaps[4];
|
|
||||||
|
|
||||||
float minTabSize;
|
float minTabSize;
|
||||||
float maxTabSize;
|
float maxTabSize;
|
||||||
|
|
||||||
|
ServerBitmap* closeBitmaps[4];
|
||||||
|
ServerBitmap* zoomBitmaps[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
TabDecorator(DesktopSettings& settings,
|
TabDecorator(DesktopSettings& settings,
|
||||||
BRect frame);
|
BRect frame);
|
||||||
virtual ~TabDecorator();
|
virtual ~TabDecorator();
|
||||||
|
|
||||||
virtual float TabLocation(int32 tab) const;
|
|
||||||
|
|
||||||
virtual bool GetSettings(BMessage* settings) const;
|
|
||||||
|
|
||||||
virtual void Draw(BRect updateRect) = 0;
|
|
||||||
virtual void Draw() = 0;
|
|
||||||
|
|
||||||
virtual void GetSizeLimits(int32* minWidth, int32* minHeight,
|
|
||||||
int32* maxWidth, int32* maxHeight) const;
|
|
||||||
|
|
||||||
virtual Region RegionAt(BPoint where, int32& tab) const;
|
|
||||||
|
|
||||||
virtual bool SetRegionHighlight(Region region,
|
|
||||||
uint8 highlight, BRegion* dirty,
|
|
||||||
int32 tab = -1);
|
|
||||||
|
|
||||||
virtual void ExtendDirtyRegion(Region region,
|
|
||||||
BRegion& dirty);
|
|
||||||
|
|
||||||
float BorderWidth();
|
|
||||||
float TabHeight();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum {
|
enum {
|
||||||
COLOR_TAB_FRAME_LIGHT = 0,
|
COLOR_TAB_FRAME_LIGHT = 0,
|
||||||
@@ -105,6 +84,33 @@ protected:
|
|||||||
|
|
||||||
typedef rgb_color ComponentColors[7];
|
typedef rgb_color ComponentColors[7];
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual float TabLocation(int32 tab) const;
|
||||||
|
|
||||||
|
virtual bool GetSettings(BMessage* settings) const;
|
||||||
|
|
||||||
|
virtual void Draw(BRect updateRect) = 0;
|
||||||
|
virtual void Draw() = 0;
|
||||||
|
|
||||||
|
virtual void GetSizeLimits(int32* minWidth, int32* minHeight,
|
||||||
|
int32* maxWidth, int32* maxHeight) const;
|
||||||
|
|
||||||
|
virtual Region RegionAt(BPoint where, int32& tab) const;
|
||||||
|
|
||||||
|
virtual void ExtendDirtyRegion(Region region,
|
||||||
|
BRegion& dirty);
|
||||||
|
|
||||||
|
virtual void GetComponentColors(Component component,
|
||||||
|
uint8 highlight, ComponentColors _colors,
|
||||||
|
Decorator::Tab* tab = NULL);
|
||||||
|
|
||||||
|
virtual bool SetRegionHighlight(Region region,
|
||||||
|
uint8 highlight, BRegion* dirty,
|
||||||
|
int32 tab = -1);
|
||||||
|
|
||||||
|
float BorderWidth();
|
||||||
|
float TabHeight();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void _DoLayout();
|
virtual void _DoLayout();
|
||||||
virtual void _DoTabLayout();
|
virtual void _DoTabLayout();
|
||||||
@@ -162,9 +168,6 @@ protected:
|
|||||||
// TabDecorator customization points
|
// TabDecorator customization points
|
||||||
virtual void DrawButtons(Decorator::Tab* tab,
|
virtual void DrawButtons(Decorator::Tab* tab,
|
||||||
const BRect& invalid);
|
const BRect& invalid);
|
||||||
virtual void GetComponentColors(Component component,
|
|
||||||
uint8 highlight, ComponentColors _colors,
|
|
||||||
Decorator::Tab* tab = NULL);
|
|
||||||
|
|
||||||
virtual void _UpdateFont(DesktopSettings& settings);
|
virtual void _UpdateFont(DesktopSettings& settings);
|
||||||
|
|
||||||
@@ -172,11 +175,25 @@ private:
|
|||||||
void _LayoutTabItems(Decorator::Tab* tab,
|
void _LayoutTabItems(Decorator::Tab* tab,
|
||||||
const BRect& tabRect);
|
const BRect& tabRect);
|
||||||
|
|
||||||
|
protected:
|
||||||
inline float _DefaultTextOffset() const;
|
inline float _DefaultTextOffset() const;
|
||||||
inline float _SingleTabOffsetAndSize(float& tabSize);
|
inline float _SingleTabOffsetAndSize(float& tabSize);
|
||||||
|
|
||||||
void _CalculateTabsRegion();
|
void _CalculateTabsRegion();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// Individual rects for handling window frame
|
||||||
|
// rendering the proper way
|
||||||
|
BRect fRightBorder;
|
||||||
|
BRect fLeftBorder;
|
||||||
|
BRect fTopBorder;
|
||||||
|
BRect fBottomBorder;
|
||||||
|
|
||||||
|
int32 fBorderWidth;
|
||||||
|
|
||||||
|
BRegion fTabsRegion;
|
||||||
|
BRect fOldMovingTab;
|
||||||
|
|
||||||
const rgb_color kFocusFrameColor;
|
const rgb_color kFocusFrameColor;
|
||||||
|
|
||||||
const rgb_color kFocusTabColor;
|
const rgb_color kFocusTabColor;
|
||||||
@@ -192,18 +209,6 @@ protected:
|
|||||||
const rgb_color kNonFocusTabColorBevel;
|
const rgb_color kNonFocusTabColorBevel;
|
||||||
const rgb_color kNonFocusTabColorShadow;
|
const rgb_color kNonFocusTabColorShadow;
|
||||||
const rgb_color kNonFocusTextColor;
|
const rgb_color kNonFocusTextColor;
|
||||||
|
|
||||||
// Individual rects for handling window frame
|
|
||||||
// rendering the proper way
|
|
||||||
BRect fRightBorder;
|
|
||||||
BRect fLeftBorder;
|
|
||||||
BRect fTopBorder;
|
|
||||||
BRect fBottomBorder;
|
|
||||||
|
|
||||||
int32 fBorderWidth;
|
|
||||||
|
|
||||||
BRegion fTabsRegion;
|
|
||||||
BRect fOldMovingTab;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user