Get MacDecorator building again.

Also includes some style fixes and checks on fTopTab which seems to be NULL sometimes.
Does NOT behave well with tabbing yet and still has some drawing bugs.
This commit is contained in:
pulkomandy
2011-11-13 17:43:52 +01:00
parent db686b374c
commit 113bc195de
3 changed files with 195 additions and 105 deletions
@@ -2,8 +2,10 @@ SubDir HAIKU_TOP src add-ons decorators MacDecorator ;
UseFreeTypeHeaders ; UseFreeTypeHeaders ;
UseHeaders [ FDirName $(HAIKU_TOP) src servers app ] ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app ] ;
UseHeaders [ FDirName $(HAIKU_TOP) src servers app decorator ] ;
UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing ] ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing ] ;
UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing Painter ] ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing Painter ] ;
UseHeaders [ FDirName $(HAIKU_TOP) src servers app font ] ;
UsePrivateHeaders app shared interface graphics ; UsePrivateHeaders app shared interface graphics ;
UseLibraryHeaders agg ; UseLibraryHeaders agg ;
@@ -39,17 +39,15 @@ MacDecorAddOn::MacDecorAddOn(image_id id, const char* name)
Decorator* Decorator*
MacDecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect, MacDecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect)
window_look look, uint32 flags)
{ {
return new (std::nothrow)MacDecorator(settings, rect, look, flags); return new (std::nothrow)MacDecorator(settings, rect);
} }
MacDecorator::MacDecorator(DesktopSettings& settings, BRect rect, MacDecorator::MacDecorator(DesktopSettings& settings, BRect rect)
window_look look, uint32 flags)
: :
Decorator(settings, rect, look, flags) Decorator(settings, rect)
{ {
_UpdateFont(settings); _UpdateFont(settings);
@@ -103,7 +101,7 @@ MacDecorator::Draw()
fDrawingEngine->SetDrawState(&fDrawState); fDrawingEngine->SetDrawState(&fDrawState);
_DrawFrame(fBorderRect); _DrawFrame(fBorderRect);
_DrawTab(fTabRect); _DrawTab(fTitleBarRect);
} }
@@ -111,22 +109,22 @@ MacDecorator::Draw()
Decorator::Region Decorator::Region
MacDecorator::RegionAt(BPoint where) const MacDecorator::RegionAt(BPoint where, int32& tab) const
{ {
// Let the base class version identify hits of the buttons and the tab. // Let the base class version identify hits of the buttons and the tab.
Region region = Decorator::RegionAt(where); Region region = Decorator::RegionAt(where, tab);
if (region != REGION_NONE) if (region != REGION_NONE)
return region; return region;
// check the resize corner // check the resize corner
if (fLook == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(where)) if (fTopTab->look == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(where))
return REGION_RIGHT_BOTTOM_CORNER; return REGION_RIGHT_BOTTOM_CORNER;
// hit-test the borders // hit-test the borders
if (!(fFlags & B_NOT_RESIZABLE) if (!(fTopTab->flags & B_NOT_RESIZABLE)
&& (fLook == B_TITLED_WINDOW_LOOK && (fTopTab->look == B_TITLED_WINDOW_LOOK
|| fLook == B_FLOATING_WINDOW_LOOK || fTopTab->look == B_FLOATING_WINDOW_LOOK
|| fLook == B_MODAL_WINDOW_LOOK) || fTopTab->look == B_MODAL_WINDOW_LOOK)
&& fBorderRect.Contains(where) && !fFrame.Contains(where)) { && fBorderRect.Contains(where) && !fFrame.Contains(where)) {
return REGION_BOTTOM_BORDER; return REGION_BOTTOM_BORDER;
// TODO: Determine the actual border! // TODO: Determine the actual border!
@@ -146,28 +144,31 @@ MacDecorator::_DoLayout()
bool hasTab = false; bool hasTab = false;
switch (Look()) { if (fTopTab) {
case B_MODAL_WINDOW_LOOK: switch (fTopTab->look) {
fBorderWidth = kDefaultBorderWidth; case B_MODAL_WINDOW_LOOK:
break; fBorderWidth = kDefaultBorderWidth;
break;
case B_TITLED_WINDOW_LOOK:
case B_DOCUMENT_WINDOW_LOOK: case B_TITLED_WINDOW_LOOK:
hasTab = true; case B_DOCUMENT_WINDOW_LOOK:
fBorderWidth = kDefaultBorderWidth; hasTab = true;
break; fBorderWidth = kDefaultBorderWidth;
case B_FLOATING_WINDOW_LOOK: break;
hasTab = true; case B_FLOATING_WINDOW_LOOK:
fBorderWidth = 3; hasTab = true;
break; fBorderWidth = 3;
break;
case B_BORDERED_WINDOW_LOOK:
fBorderWidth = 1; case B_BORDERED_WINDOW_LOOK:
break; fBorderWidth = 1;
break;
default:
fBorderWidth = 0; default:
} fBorderWidth = 0;
}
} else
fBorderWidth = 0;
fBorderRect=fFrame; fBorderRect=fFrame;
fBorderRect.InsetBy(-fBorderWidth, -fBorderWidth); fBorderRect.InsetBy(-fBorderWidth, -fBorderWidth);
@@ -179,45 +180,54 @@ MacDecorator::_DoLayout()
fDrawState.Font().GetHeight(fontHeight); fDrawState.Font().GetHeight(fontHeight);
// TODO the tab is drawn in a fixed height for now // TODO the tab is drawn in a fixed height for now
fTabRect.Set(fFrame.left - fBorderWidth, fTitleBarRect.Set(fFrame.left - fBorderWidth,
fFrame.top - 23, fFrame.top - 23,
((fFrame.right - fFrame.left) < 32.0 ? ((fFrame.right - fFrame.left) < 32.0 ?
fFrame.left + 32.0 : fFrame.right) + fBorderWidth, fFrame.left + 32.0 : fFrame.right) + fBorderWidth,
fFrame.top - 3); fFrame.top - 3);
fTopTab->tabRect = fTitleBarRect; // TODO actually handle multiple tabs
fZoomRect=fTabRect; fTopTab->zoomRect=fTitleBarRect;
fZoomRect.left=fZoomRect.right-12; fTopTab->zoomRect.left=fTopTab->zoomRect.right - 12;
fZoomRect.bottom=fZoomRect.top+12; fTopTab->zoomRect.bottom=fTopTab->zoomRect.top + 12;
fZoomRect.OffsetBy(-4,4); fTopTab->zoomRect.OffsetBy(-4, 4);
fCloseRect=fZoomRect; fTopTab->closeRect=fTopTab->zoomRect;
fMinimizeRect=fZoomRect; fTopTab->minimizeRect=fTopTab->zoomRect;
fCloseRect.OffsetTo(fTabRect.left+4,fTabRect.top+4); fTopTab->closeRect.OffsetTo(fTitleBarRect.left + 4,
fTitleBarRect.top + 4);
fZoomRect.OffsetBy(0-(fZoomRect.Width()+4),0); fTopTab->zoomRect.OffsetBy(0 - (fTopTab->zoomRect.Width() + 4), 0);
if (Title() && fDrawingEngine) { if (Title(fTopTab) && fDrawingEngine) {
titlepixelwidth=fDrawingEngine->StringWidth(Title(),strlen(Title())); titlepixelwidth=fDrawingEngine->StringWidth(Title(fTopTab),
strlen(Title(fTopTab)));
if (titlepixelwidth<(fZoomRect.left-fCloseRect.right-10)) { if (titlepixelwidth<(fTopTab->zoomRect.left
- fTopTab->closeRect.right-10)) {
// start with offset from closerect.right // start with offset from closerect.right
textoffset=int(((fZoomRect.left-5)-(fCloseRect.right+5))/2); textoffset=int(((fTopTab->zoomRect.left - 5)
textoffset-=int(titlepixelwidth/2); - (fTopTab->closeRect.right + 5)) / 2);
textoffset-=int(titlepixelwidth / 2);
// now make it the offset from fTabRect.left // now make it the offset from fTabRect.left
textoffset+=int(fCloseRect.right+5-fTabRect.left); textoffset+=int(fTopTab->closeRect.right + 5
- fTitleBarRect.left);
} else } else
textoffset=int(fCloseRect.right)+5; textoffset=int(fTopTab->closeRect.right) + 5;
} else { } else {
textoffset=0; textoffset = 0;
titlepixelwidth=0; titlepixelwidth = 0;
} }
} else { } else {
// no tab // no tab
fTabRect.Set(0.0, 0.0, -1.0, -1.0); if (fTopTab) {
fCloseRect.Set(0.0, 0.0, -1.0, -1.0); fTopTab->tabRect.Set(0.0, 0.0, -1.0, -1.0);
fZoomRect.Set(0.0, 0.0, -1.0, -1.0); fTopTab->closeRect.Set(0.0, 0.0, -1.0, -1.0);
fMinimizeRect.Set(0.0, 0.0, -1.0, -1.0); fTopTab->zoomRect.Set(0.0, 0.0, -1.0, -1.0);
fTopTab->minimizeRect.Set(0.0, 0.0, -1.0, -1.0);
}
} }
} }
@@ -225,19 +235,19 @@ MacDecorator::_DoLayout()
void void
MacDecorator::_DrawFrame(BRect invalid) MacDecorator::_DrawFrame(BRect invalid)
{ {
if (fLook == B_NO_BORDER_WINDOW_LOOK) if (fTopTab->look == B_NO_BORDER_WINDOW_LOOK)
return; return;
if (fBorderWidth <= 0) if (fBorderWidth <= 0)
return; return;
BRect r = fBorderRect; BRect r = fBorderRect;
switch (fLook) { switch (fTopTab->look) {
case B_TITLED_WINDOW_LOOK: case B_TITLED_WINDOW_LOOK:
case B_DOCUMENT_WINDOW_LOOK: case B_DOCUMENT_WINDOW_LOOK:
case B_MODAL_WINDOW_LOOK: case B_MODAL_WINDOW_LOOK:
{ {
if (IsFocus()) { if (IsFocus(fTopTab)) {
BPoint offset = r.LeftTop(); BPoint offset = r.LeftTop();
BPoint pt2 = r.LeftBottom(); BPoint pt2 = r.LeftBottom();
@@ -381,14 +391,14 @@ MacDecorator::_DrawTab(BRect invalid)
{ {
// If a window has a tab, this will draw it and any buttons which are // If a window has a tab, this will draw it and any buttons which are
// in it. // in it.
if (!fTabRect.IsValid() || !invalid.Intersects(fTabRect)) if (!fTitleBarRect.IsValid() || !invalid.Intersects(fTitleBarRect))
return; return;
BRect rect(fTabRect); BRect rect(fTitleBarRect);
fDrawingEngine->SetHighColor(RGBColor(frame_midcol)); fDrawingEngine->SetHighColor(RGBColor(frame_midcol));
fDrawingEngine->FillRect(rect,frame_midcol); fDrawingEngine->FillRect(rect,frame_midcol);
if (IsFocus()) { if (IsFocus(fTopTab)) {
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_lowercol); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_lowercol);
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_lowercol); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_lowercol);
fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowercol); fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowercol);
@@ -401,11 +411,11 @@ MacDecorator::_DrawTab(BRect invalid)
fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowcol); fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowcol);
// Draw the neat little lines on either side of the title if there's room // Draw the neat little lines on either side of the title if there's room
if (fTabRect.left + textoffset > fCloseRect.right + 5) { if (fTitleBarRect.left + textoffset > fTopTab->closeRect.right + 5) {
// Left side // Left side
BPoint offset(fCloseRect.right+5,fCloseRect.top), BPoint offset(fTopTab->closeRect.right+5,fTopTab->closeRect.top),
pt2(fTabRect.left+textoffset-5,fCloseRect.top); pt2(fTitleBarRect.left+textoffset-5,fTopTab->closeRect.top);
fDrawState.SetHighColor(RGBColor(frame_highcol)); fDrawState.SetHighColor(RGBColor(frame_highcol));
for (int32 i = 0; i < 6; i++) { for (int32 i = 0; i < 6; i++) {
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor()); fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
@@ -413,8 +423,8 @@ MacDecorator::_DrawTab(BRect invalid)
pt2.y+=2; pt2.y+=2;
} }
offset.Set(fCloseRect.right+6,fCloseRect.top+1), offset.Set(fTopTab->closeRect.right+6,fTopTab->closeRect.top+1),
pt2.Set(fTabRect.left+textoffset-4,fCloseRect.top+1); pt2.Set(fTitleBarRect.left+textoffset-4,fTopTab->closeRect.top+1);
fDrawState.SetHighColor(RGBColor(frame_lowcol)); fDrawState.SetHighColor(RGBColor(frame_lowcol));
for (int32 i = 0; i < 6; i++) { for (int32 i = 0; i < 6; i++) {
fDrawingEngine->StrokeLine(offset, pt2, fDrawState.HighColor()); fDrawingEngine->StrokeLine(offset, pt2, fDrawState.HighColor());
@@ -424,8 +434,9 @@ MacDecorator::_DrawTab(BRect invalid)
// Right side // Right side
offset.Set(fTabRect.left + textoffset + titlepixelwidth + 6, offset.Set(fTitleBarRect.left + textoffset + titlepixelwidth + 6,
fZoomRect.top), pt2.Set(fZoomRect.left - 6, fZoomRect.top); fTopTab->zoomRect.top), pt2.Set(fTopTab->zoomRect.left - 6,
fTopTab->zoomRect.top);
if (offset.x < pt2.x) { if (offset.x < pt2.x) {
fDrawState.SetHighColor(RGBColor(frame_highcol)); fDrawState.SetHighColor(RGBColor(frame_highcol));
for (int32 i = 0; i < 6; i++) { for (int32 i = 0; i < 6; i++) {
@@ -434,9 +445,9 @@ MacDecorator::_DrawTab(BRect invalid)
offset.y += 2; offset.y += 2;
pt2.y += 2; pt2.y += 2;
} }
offset.Set(fTabRect.left+textoffset + titlepixelwidth + 7, offset.Set(fTitleBarRect.left+textoffset + titlepixelwidth + 7,
fZoomRect.top + 1), pt2.Set(fZoomRect.left - 5, fTopTab->zoomRect.top + 1), pt2.Set(fTopTab->zoomRect.left - 5,
fZoomRect.top + 1); fTopTab->zoomRect.top + 1);
fDrawState.SetHighColor(frame_lowcol); fDrawState.SetHighColor(frame_lowcol);
for(int32 i = 0; i < 6; i++) { for(int32 i = 0; i < 6; i++) {
fDrawingEngine->StrokeLine(offset, pt2, fDrawingEngine->StrokeLine(offset, pt2,
@@ -448,10 +459,10 @@ MacDecorator::_DrawTab(BRect invalid)
} }
// Draw the buttons if we're supposed to // Draw the buttons if we're supposed to
if (!(fFlags & B_NOT_CLOSABLE)) if (!(fTopTab->flags & B_NOT_CLOSABLE))
_DrawClose(fCloseRect); _DrawClose(fTopTab->closeRect);
if (!(fFlags & B_NOT_ZOOMABLE)) if (!(fTopTab->flags & B_NOT_ZOOMABLE))
_DrawZoom(fZoomRect); _DrawZoom(fTopTab->zoomRect);
} else { } else {
// Not focused - Just draw a plain light grey area with the title in the middle // Not focused - Just draw a plain light grey area with the title in the middle
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_lowcol); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_lowcol);
@@ -459,14 +470,14 @@ MacDecorator::_DrawTab(BRect invalid)
fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowcol); fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowcol);
} }
_DrawTitle(fTabRect); _DrawTitle(fTitleBarRect);
} }
void void
MacDecorator::_DrawClose(BRect r) MacDecorator::_DrawClose(BRect r)
{ {
bool down = GetClose(); bool down = fTopTab->closePressed;
// Just like DrawZoom, but for a close button // Just like DrawZoom, but for a close button
BRect rect(r); BRect rect(r);
@@ -509,28 +520,28 @@ MacDecorator::_DrawClose(BRect r)
void void
MacDecorator::_DrawTitle(BRect rect) MacDecorator::_DrawTitle(BRect rect)
{ {
if (IsFocus()) if (IsFocus(fTopTab))
fDrawingEngine->SetHighColor(fFocusTextColor); fDrawingEngine->SetHighColor(fFocusTextColor);
else else
fDrawingEngine->SetHighColor(fNonFocusTextColor); fDrawingEngine->SetHighColor(fNonFocusTextColor);
fDrawingEngine->SetLowColor(frame_midcol); fDrawingEngine->SetLowColor(frame_midcol);
fTruncatedTitle = Title(); fTruncatedTitle = Title(fTopTab);
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END,
(fZoomRect.left - 5) - (fCloseRect.right + 5)); (fTopTab->zoomRect.left - 5) - (fTopTab->closeRect.right + 5));
fTruncatedTitleLength = fTruncatedTitle.Length(); fTruncatedTitleLength = fTruncatedTitle.Length();
fDrawingEngine->SetFont(fDrawState.Font()); fDrawingEngine->SetFont(fDrawState.Font());
fDrawingEngine->DrawString(fTruncatedTitle,fTruncatedTitleLength, fDrawingEngine->DrawString(fTruncatedTitle,fTruncatedTitleLength,
BPoint(fTabRect.left+textoffset,fCloseRect.bottom-1)); BPoint(fTitleBarRect.left+textoffset,fTopTab->closeRect.bottom-1));
} }
void void
MacDecorator::_DrawZoom(BRect r) MacDecorator::_DrawZoom(BRect r)
{ {
bool down = GetZoom(); bool down = fTopTab->zoomPressed;
// Just like DrawZoom, but for a close button // Just like DrawZoom, but for a close button
BRect rect(r); BRect rect(r);
@@ -576,7 +587,7 @@ MacDecorator::_DrawZoom(BRect r)
void void
MacDecorator::_DrawMinimize(BRect r) MacDecorator::_DrawMinimize(BRect r)
{ {
bool down = GetMinimize(); bool down = fTopTab->minimizePressed;
// Just like DrawZoom, but for a Minimize button // Just like DrawZoom, but for a Minimize button
BRect rect(r); BRect rect(r);
@@ -619,18 +630,20 @@ MacDecorator::_DrawMinimize(BRect r)
void void
MacDecorator::_SetTitle(const char* string, BRegion* updateRegion) MacDecorator::_SetTitle(Tab* tab, const char* string, BRegion* updateRegion)
{ {
// TODO: we could be much smarter about the update region // TODO: we could be much smarter about the update region
// TODO may this change the other tabs too ? (to make space for a longer
// title ?)
BRect rect = TabRect(); BRect rect = TabRect(fTopTab);
_DoLayout(); _DoLayout();
if (updateRegion == NULL) if (updateRegion == NULL)
return; return;
rect = rect | TabRect(); rect = rect | TabRect(fTopTab);
rect.bottom++; rect.bottom++;
// the border will look differently when the title is adjacent // the border will look differently when the title is adjacent
@@ -666,7 +679,7 @@ MacDecorator::_SetLook(DesktopSettings& settings, window_look look,
if (updateRegion != NULL) if (updateRegion != NULL)
updateRegion->Include(&GetFootprint()); updateRegion->Include(&GetFootprint());
fLook = look; fTopTab->look = look;
_UpdateFont(settings); _UpdateFont(settings);
_DoLayout(); _DoLayout();
@@ -700,11 +713,13 @@ MacDecorator::_SetFlags(uint32 flags, BRegion* updateRegion)
void void
MacDecorator::_MoveBy(BPoint offset) MacDecorator::_MoveBy(BPoint offset)
{ {
// TODO handle all tabs
fFrame.OffsetBy(offset); fFrame.OffsetBy(offset);
fCloseRect.OffsetBy(offset); fTopTab->closeRect.OffsetBy(offset);
fTabRect.OffsetBy(offset); fTitleBarRect.OffsetBy(offset);
fTopTab->tabRect = fTitleBarRect;
fResizeRect.OffsetBy(offset); fResizeRect.OffsetBy(offset);
fZoomRect.OffsetBy(offset); fTopTab->zoomRect.OffsetBy(offset);
fBorderRect.OffsetBy(offset); fBorderRect.OffsetBy(offset);
} }
@@ -716,13 +731,13 @@ MacDecorator::_ResizeBy(BPoint offset, BRegion* dirty)
fFrame.right += offset.x; fFrame.right += offset.x;
fFrame.bottom += offset.y; fFrame.bottom += offset.y;
fTabRect.right += offset.x; fTitleBarRect.right += offset.x;
fBorderRect.right += offset.x; fBorderRect.right += offset.x;
fBorderRect.bottom += offset.y; fBorderRect.bottom += offset.y;
// fZoomRect.OffsetBy(offset.x, 0); // fZoomRect.OffsetBy(offset.x, 0);
// fMinimizeRect.OffsetBy(offset.x, 0); // fMinimizeRect.OffsetBy(offset.x, 0);
if (dirty) { if (dirty) {
dirty->Include(fTabRect); dirty->Include(fTitleBarRect);
dirty->Include(fBorderRect); dirty->Include(fBorderRect);
} }
@@ -746,15 +761,15 @@ MacDecorator::_GetFootprint(BRegion* region)
region->MakeEmpty(); region->MakeEmpty();
if (fLook == B_NO_BORDER_WINDOW_LOOK) if (fTopTab->look == B_NO_BORDER_WINDOW_LOOK)
return; return;
region->Set(fBorderRect); region->Set(fBorderRect);
region->Exclude(fFrame); region->Exclude(fFrame);
if (fLook == B_BORDERED_WINDOW_LOOK) if (fTopTab->look == B_BORDERED_WINDOW_LOOK)
return; return;
region->Include(fTabRect); region->Include(fTitleBarRect);
} }
@@ -762,7 +777,7 @@ void
MacDecorator::_UpdateFont(DesktopSettings& settings) MacDecorator::_UpdateFont(DesktopSettings& settings)
{ {
ServerFont font; ServerFont font;
if (fLook == B_FLOATING_WINDOW_LOOK) if (fTopTab && fTopTab->look == B_FLOATING_WINDOW_LOOK)
settings.GetDefaultPlainFont(font); settings.GetDefaultPlainFont(font);
else else
settings.GetDefaultBoldFont(font); settings.GetDefaultBoldFont(font);
@@ -801,6 +816,75 @@ MacDecorator::_DrawBlendedRect(DrawingEngine* engine, BRect rect,
} }
Decorator::Tab*
MacDecorator::_AllocateNewTab()
{
Decorator::Tab* tab = new(std::nothrow) MacDecorator::Tab;
if (tab == NULL)
return NULL;
// Set appropriate colors based on the current focus value. In this case,
// each decorator defaults to not having the focus.
_SetFocus(tab);
return tab;
}
bool
MacDecorator::_AddTab(DesktopSettings& settings, int32 index,
BRegion* updateRegion)
{
_UpdateFont(settings);
_DoLayout();
if (updateRegion != NULL)
updateRegion->Include(fTitleBarRect);
return true;
}
bool
MacDecorator::_RemoveTab(int32 index, BRegion* updateRegion)
{
BRect oldTitle = fTitleBarRect;
_DoLayout();
if (updateRegion != NULL) {
updateRegion->Include(oldTitle);
updateRegion->Include(fTitleBarRect);
}
return true;
}
bool
MacDecorator::_MoveTab(int32 from, int32 to, bool isMoving,
BRegion* updateRegion)
{
return false; //TODO
#if 0
MacDecorator::Tab* toTab = _TabAt(to);
if (toTab == NULL)
return false;
if (from < to) {
fOldMovingTab.OffsetBy(toTab->tabRect.Width(), 0);
toTab->tabRect.OffsetBy(-fOldMovingTab.Width(), 0);
} else {
fOldMovingTab.OffsetBy(-toTab->tabRect.Width(), 0);
toTab->tabRect.OffsetBy(fOldMovingTab.Width(), 0);
}
toTab->tabOffset = uint32(toTab->tabRect.left - fLeftBorder.left);
_LayoutTabItems(toTab, toTab->tabRect);
_CalculateTabsRegion();
if (updateRegion != NULL)
updateRegion->Include(fTitleBarRect);
return true;
#endif
}
// #pragma mark - // #pragma mark -
@@ -16,21 +16,20 @@ public:
protected: protected:
virtual Decorator* _AllocateDecorator(DesktopSettings& settings, virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
BRect rect, window_look look, uint32 flags); BRect rect);
}; };
class MacDecorator: public Decorator { class MacDecorator: public Decorator {
public: public:
MacDecorator(DesktopSettings& settings, MacDecorator(DesktopSettings& settings,
BRect frame, window_look look, BRect frame);
uint32 flags);
virtual ~MacDecorator(); virtual ~MacDecorator();
void Draw(BRect updateRect); void Draw(BRect updateRect);
void Draw(); void Draw();
virtual Region RegionAt(BPoint where) const; virtual Region RegionAt(BPoint where, int32& tab) const;
protected: protected:
void _DoLayout(); void _DoLayout();
@@ -43,8 +42,8 @@ protected:
void _DrawZoom(BRect r); void _DrawZoom(BRect r);
void _DrawMinimize(BRect r); void _DrawMinimize(BRect r);
void _SetTitle(const char* string, void _SetTitle(Tab* tab, const char* string,
BRegion* updateRegion = NULL); BRegion* updateRegion = NULL);
void _FontsChanged(DesktopSettings& settings, void _FontsChanged(DesktopSettings& settings,
BRegion* updateRegion); BRegion* updateRegion);
@@ -59,6 +58,11 @@ protected:
void _GetFootprint(BRegion *region); void _GetFootprint(BRegion *region);
// TODO
Tab* _AllocateNewTab();
bool _AddTab(DesktopSettings&, long int, BRegion*);
bool _RemoveTab(long int, BRegion*);
bool _MoveTab(long int, long int, bool, BRegion*);
private: private:
void _UpdateFont(DesktopSettings& settings); void _UpdateFont(DesktopSettings& settings);
void _DrawBlendedRect(DrawingEngine* engine, void _DrawBlendedRect(DrawingEngine* engine,