BeDecorator: make it compile, use tabs.

Crashes spectacularly like WinDecorator.
This commit is contained in:
John Scipione
2014-02-20 19:31:17 -05:00
parent a19e96e3ad
commit db9c24a651
2 changed files with 823 additions and 405 deletions
File diff suppressed because it is too large Load Diff
+101 -22
View File
@@ -18,7 +18,7 @@
class Desktop;
class ServerBitmap;
class BeDecorAddOn : public DecorAddOn {
public:
@@ -26,19 +26,36 @@ public:
protected:
virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
BRect rect, window_look look, uint32 flags);
BRect rect);
};
class BeDecorator: public Decorator {
public:
BeDecorator(DesktopSettings& settings,
BRect frame, window_look look,
uint32 flags);
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);
virtual ~BeDecorator();
virtual float TabLocation() const
{ return (float)fTabOffset; }
virtual float TabLocation(int32 tab) const;
virtual bool GetSettings(BMessage* settings) const;
@@ -48,48 +65,107 @@ public:
virtual void GetSizeLimits(int32* minWidth, int32* minHeight,
int32* maxWidth, int32* maxHeight) const;
virtual Region RegionAt(BPoint where) const;
virtual Region RegionAt(BPoint where, int32& tab) const;
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 void _DrawFrame(BRect r);
virtual void _DrawTab(BRect r);
virtual Decorator::Tab* _AllocateNewTab();
BeDecorator::Tab* _TabAt(int32 index) const;
virtual void _DrawClose(BRect r);
virtual void _DrawTitle(BRect r);
virtual void _DrawZoom(BRect r);
virtual void _DrawFrame(BRect rect);
virtual void _DrawTab(Decorator::Tab* tab, BRect rect);
virtual void _DrawTitle(Decorator::Tab* tab, BRect rect);
virtual void _SetTitle(const char* string,
virtual void _DrawClose(Decorator::Tab* tab, bool direct,
BRect rect);
virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
BRect rect);
virtual void _SetTitle(Decorator::Tab* tab, const char* string,
BRegion* updateRegion = NULL);
virtual void _FontsChanged(DesktopSettings& settings,
BRegion* updateRegion);
virtual void _SetLook(DesktopSettings& settings,
virtual void _SetLook(Decorator::Tab* tab,
DesktopSettings& settings,
window_look look,
BRegion* updateRegion = NULL);
virtual void _SetFlags(uint32 flags,
virtual void _SetFlags(Decorator::Tab* tab, uint32 flags,
BRegion* updateRegion = NULL);
virtual void _SetFocus();
virtual void _SetFocus(Decorator::Tab* tab);
virtual void _MoveBy(BPoint offset);
virtual void _ResizeBy(BPoint offset, BRegion* dirty);
virtual bool _SetTabLocation(float location,
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:
void _UpdateFont(DesktopSettings& settings);
void _DrawBlendedRect(BRect r, bool down);
void _GetButtonSizeAndOffset(const BRect& tabRect,
float* offset, float*size) const;
void _LayoutTabItems(const BRect& tabRect);
void _LayoutTabItems(Decorator::Tab* _tab, const BRect& tabRect);
void _InvalidateBitmaps();
inline float _DefaultTextOffset() const;
inline float _SingleTabOffsetAndSize(float& tabSize);
void _CalculateTabsRegion();
private:
RGBColor fButtonHighColor;
@@ -108,6 +184,9 @@ private:
int32 fBorderWidth;
BRegion fTabsRegion;
BRect fOldMovingTab;
uint32 fTabOffset;
float fTabLocation;
float fTextOffset;