Create a TabDecorator class
Which contains methods common to Default Decorator and BeDecorator, aka "tabbed" decorators. Derive DefaultDecorator from a new TabDecorator base class.
This commit is contained in:
@@ -17,6 +17,7 @@ local decorator_src =
|
||||
DefaultDecorator.cpp
|
||||
DefaultWindowBehaviour.cpp
|
||||
MagneticBorder.cpp
|
||||
TabDecorator.cpp
|
||||
WindowBehaviour.cpp
|
||||
;
|
||||
|
||||
|
||||
@@ -47,10 +47,8 @@ Decorator::Tab::Tab()
|
||||
Does general initialization of internal data members and creates a colorset
|
||||
object.
|
||||
|
||||
\param rect Size of client area
|
||||
\param wlook style of window look. See Window.h
|
||||
\param wfeel style of window feel. See Window.h
|
||||
\param wflags various window flags. See Window.h
|
||||
\param settings DesktopSettings pointer.
|
||||
\param rect Size of client area.
|
||||
*/
|
||||
Decorator::Decorator(DesktopSettings& settings, BRect rect)
|
||||
:
|
||||
@@ -70,8 +68,7 @@ Decorator::Decorator(DesktopSettings& settings, BRect rect)
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Destructor
|
||||
/*! \brief Destructor
|
||||
|
||||
Frees the color set and the title string
|
||||
*/
|
||||
@@ -677,6 +674,7 @@ Decorator::DrawClose(int32 tab)
|
||||
Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
|
||||
if (decoratorTab == NULL)
|
||||
return;
|
||||
|
||||
_DrawClose(decoratorTab, true, decoratorTab->closeRect);
|
||||
}
|
||||
|
||||
@@ -688,6 +686,7 @@ Decorator::DrawMinimize(int32 tab)
|
||||
Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
|
||||
if (decoratorTab == NULL)
|
||||
return;
|
||||
|
||||
_DrawTab(decoratorTab, decoratorTab->minimizeRect);
|
||||
}
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ protected:
|
||||
virtual bool _SetSettings(const BMessage& settings,
|
||||
BRegion* updateRegion = NULL);
|
||||
|
||||
virtual bool _AddTab(DesktopSettings& settings,
|
||||
virtual bool _AddTab(DesktopSettings& settings,
|
||||
int32 index = -1,
|
||||
BRegion* updateRegion = NULL) = 0;
|
||||
virtual bool _RemoveTab(int32 index,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,163 +17,52 @@
|
||||
|
||||
#include <Region.h>
|
||||
|
||||
#include "Decorator.h"
|
||||
#include "TabDecorator.h"
|
||||
|
||||
|
||||
class Desktop;
|
||||
class ServerBitmap;
|
||||
|
||||
class DefaultDecorator: public Decorator {
|
||||
class DefaultDecorator: public TabDecorator {
|
||||
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;
|
||||
};
|
||||
|
||||
DefaultDecorator(DesktopSettings& settings,
|
||||
BRect frame);
|
||||
virtual ~DefaultDecorator();
|
||||
|
||||
virtual float TabLocation(int32 tab) const;
|
||||
|
||||
virtual bool GetSettings(BMessage* settings) const;
|
||||
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void Draw();
|
||||
|
||||
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:
|
||||
enum Component {
|
||||
COMPONENT_TAB,
|
||||
virtual void _DrawFrame(BRect r);
|
||||
virtual void _DrawTab(Decorator::Tab* tab, BRect r);
|
||||
|
||||
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();
|
||||
DefaultDecorator::Tab* _TabAt(int32 index) const;
|
||||
|
||||
virtual void _DrawFrame(BRect r);
|
||||
virtual void _DrawTab(Decorator::Tab* tab, BRect r);
|
||||
|
||||
virtual void _DrawClose(Decorator::Tab* tab, bool direct,
|
||||
virtual void _DrawClose(Decorator::Tab* tab, bool direct,
|
||||
BRect r);
|
||||
virtual void _DrawTitle(Decorator::Tab* tab, BRect r);
|
||||
virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
|
||||
virtual void _DrawTitle(Decorator::Tab* tab, BRect r);
|
||||
virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
|
||||
BRect r);
|
||||
|
||||
virtual void _SetTitle(Decorator::Tab* tab,
|
||||
const char* string,
|
||||
BRegion* updateRegion = NULL);
|
||||
virtual void _SetFocus(Decorator::Tab* tab);
|
||||
virtual void _SetFocus(Decorator::Tab* tab);
|
||||
|
||||
virtual void _FontsChanged(DesktopSettings& settings,
|
||||
virtual void _FontsChanged(DesktopSettings& settings,
|
||||
BRegion* updateRegion);
|
||||
virtual void _SetLook(Decorator::Tab* tab,
|
||||
|
||||
virtual void _SetLook(Decorator::Tab* tab,
|
||||
DesktopSettings& settings, window_look look,
|
||||
BRegion* updateRegion = NULL);
|
||||
virtual void _SetFlags(Decorator::Tab* tab, uint32 flags,
|
||||
virtual void _SetFlags(Decorator::Tab* tab, uint32 flags,
|
||||
BRegion* updateRegion = NULL);
|
||||
|
||||
virtual void _MoveBy(BPoint offset);
|
||||
virtual void _ResizeBy(BPoint offset, BRegion* dirty);
|
||||
|
||||
virtual bool _SetTabLocation(Decorator::Tab* tab,
|
||||
float location, bool isShifting,
|
||||
BRegion* updateRegion = NULL);
|
||||
|
||||
virtual bool _SetSettings(const BMessage& settings,
|
||||
BRegion* updateRegion = NULL);
|
||||
|
||||
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 void _GetFootprint(BRegion *region);
|
||||
|
||||
void _GetButtonSizeAndOffset(const BRect& tabRect,
|
||||
virtual void _GetButtonSizeAndOffset(const BRect& tabRect,
|
||||
float* offset, float* size,
|
||||
float* inset) const;
|
||||
|
||||
// DefaultDecorator customization points
|
||||
virtual void DrawButtons(Decorator::Tab* tab,
|
||||
const BRect& invalid);
|
||||
virtual void GetComponentColors(Component component,
|
||||
uint8 highlight, ComponentColors _colors,
|
||||
Decorator::Tab* tab = NULL);
|
||||
|
||||
private:
|
||||
void _UpdateFont(DesktopSettings& settings);
|
||||
void _DrawButtonBitmap(ServerBitmap* bitmap,
|
||||
bool direct, BRect rect);
|
||||
void _DrawBlendedRect(DrawingEngine *engine,
|
||||
BRect rect, bool down,
|
||||
const ComponentColors& colors);
|
||||
void _LayoutTabItems(Decorator::Tab* tab,
|
||||
const BRect& tabRect);
|
||||
void _InvalidateBitmaps();
|
||||
ServerBitmap* _GetBitmapForButton(Decorator::Tab* tab,
|
||||
Component item, bool down, int32 width,
|
||||
@@ -187,36 +76,6 @@ private:
|
||||
inline float _SingleTabOffsetAndSize(float& tabSize);
|
||||
|
||||
void _CalculateTabsRegion();
|
||||
protected:
|
||||
static const rgb_color kFrameColors[4];
|
||||
|
||||
const rgb_color kFocusFrameColor;
|
||||
|
||||
const rgb_color kFocusTabColor;
|
||||
const rgb_color kFocusTabColorLight;
|
||||
const rgb_color kFocusTabColorBevel;
|
||||
const rgb_color kFocusTabColorShadow;
|
||||
const rgb_color kFocusTextColor;
|
||||
|
||||
const rgb_color kNonFocusFrameColor;
|
||||
|
||||
const rgb_color kNonFocusTabColor;
|
||||
const rgb_color kNonFocusTabColorLight;
|
||||
const rgb_color kNonFocusTabColorBevel;
|
||||
const rgb_color kNonFocusTabColorShadow;
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* Copyright 2001-2013 Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus, [email protected]
|
||||
* DarkWyrm, [email protected]
|
||||
* Ryan Leavengood, [email protected]
|
||||
* Philippe Saint-Pierre, [email protected]
|
||||
* John Scipione, [email protected]
|
||||
* Ingo Weinhold, [email protected]
|
||||
* Clemens Zeidler, [email protected]
|
||||
*/
|
||||
#ifndef TAB_DECORATOR_H
|
||||
#define TAB_DECORATOR_H
|
||||
|
||||
|
||||
#include <Region.h>
|
||||
|
||||
#include "Decorator.h"
|
||||
|
||||
|
||||
class Desktop;
|
||||
class ServerBitmap;
|
||||
|
||||
|
||||
class TabDecorator: public Decorator {
|
||||
public:
|
||||
class Tab : public TabDecorator::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;
|
||||
};
|
||||
|
||||
TabDecorator(DesktopSettings& settings,
|
||||
BRect frame);
|
||||
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:
|
||||
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
|
||||
};
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
typedef rgb_color ComponentColors[7];
|
||||
|
||||
protected:
|
||||
virtual void _DoLayout();
|
||||
virtual void _DoTabLayout();
|
||||
void _DistributeTabSize(float delta);
|
||||
|
||||
virtual Decorator::Tab* _AllocateNewTab();
|
||||
TabDecorator::Tab* _TabAt(int32 index) const;
|
||||
|
||||
virtual void _DrawFrame(BRect r) = 0;
|
||||
virtual void _DrawTab(Decorator::Tab* tab, BRect r) = 0;
|
||||
|
||||
virtual void _DrawClose(Decorator::Tab* tab, bool direct,
|
||||
BRect r) = 0;
|
||||
virtual void _DrawTitle(Decorator::Tab* tab, BRect r) = 0;
|
||||
virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
|
||||
BRect r) = 0;
|
||||
|
||||
virtual void _SetTitle(Decorator::Tab* tab,
|
||||
const char* string,
|
||||
BRegion* updateRegion = NULL);
|
||||
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 _MoveBy(BPoint offset);
|
||||
virtual void _ResizeBy(BPoint offset, BRegion* dirty);
|
||||
|
||||
virtual bool _SetTabLocation(Decorator::Tab* tab,
|
||||
float location, bool isShifting,
|
||||
BRegion* updateRegion = NULL);
|
||||
|
||||
virtual bool _SetSettings(const BMessage& settings,
|
||||
BRegion* updateRegion = NULL);
|
||||
|
||||
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 void _GetFootprint(BRegion *region);
|
||||
|
||||
virtual void _GetButtonSizeAndOffset(const BRect& tabRect,
|
||||
float* offset, float* size,
|
||||
float* inset) const;
|
||||
|
||||
// TabDecorator customization points
|
||||
virtual void DrawButtons(Decorator::Tab* tab,
|
||||
const BRect& invalid);
|
||||
virtual void GetComponentColors(Component component,
|
||||
uint8 highlight, ComponentColors _colors,
|
||||
Decorator::Tab* tab = NULL);
|
||||
|
||||
virtual void _UpdateFont(DesktopSettings& settings);
|
||||
|
||||
private:
|
||||
void _LayoutTabItems(Decorator::Tab* tab,
|
||||
const BRect& tabRect);
|
||||
|
||||
inline float _DefaultTextOffset() const;
|
||||
inline float _SingleTabOffsetAndSize(float& tabSize);
|
||||
|
||||
void _CalculateTabsRegion();
|
||||
protected:
|
||||
const rgb_color kFocusFrameColor;
|
||||
|
||||
const rgb_color kFocusTabColor;
|
||||
const rgb_color kFocusTabColorLight;
|
||||
const rgb_color kFocusTabColorBevel;
|
||||
const rgb_color kFocusTabColorShadow;
|
||||
const rgb_color kFocusTextColor;
|
||||
|
||||
const rgb_color kNonFocusFrameColor;
|
||||
|
||||
const rgb_color kNonFocusTabColor;
|
||||
const rgb_color kNonFocusTabColorLight;
|
||||
const rgb_color kNonFocusTabColorBevel;
|
||||
const rgb_color kNonFocusTabColorShadow;
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
#endif // TAB_DECORATOR_H
|
||||
@@ -29,6 +29,14 @@
|
||||
|
||||
static const float kResizeKnobSize = 18.0;
|
||||
|
||||
|
||||
static const rgb_color kFrameColors[4] = {
|
||||
{ 152, 152, 152, 255 },
|
||||
{ 240, 240, 240, 255 },
|
||||
{ 152, 152, 152, 255 },
|
||||
{ 108, 108, 108, 255 }
|
||||
};
|
||||
|
||||
static const rgb_color kHighlightFrameColors[6] = {
|
||||
{ 52, 52, 52, 255 },
|
||||
{ 140, 140, 140, 255 },
|
||||
|
||||
Reference in New Issue
Block a user