Author: bonefish Date: 2010-11-25 16:01:30 +0100 (Thu, 25 Nov 2010) New Revision: 39627 Changeset: http://dev.haiku-os.org/changeset/39627 Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.cpp haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.h haiku/trunk/src/servers/app/DefaultDecorator.cpp haiku/trunk/src/servers/app/DefaultDecorator.h Log: * DefaultDecorator: Moved the button drawing from _DrawTab() to the new virtual DrawButtons(). * SATDecorator: Override DrawButtons() instead of _DrawTab(), thus saving a good deal of code duplication. Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.cpp =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.cpp 2010-11-25 14:42:28 UTC (rev 39626) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.cpp 2010-11-25 15:01:30 UTC (rev 39627) @@ -406,79 +406,6 @@ } -void -SATDecorator::_DrawTab(BRect invalid) -{ - STRACE(("_DrawTab(%.1f,%.1f,%.1f,%.1f)\n", - invalid.left, invalid.top, invalid.right, invalid.bottom)); - // If a window has a tab, this will draw it and any buttons which are - // in it. - if (!fTabRect.IsValid() || !invalid.Intersects(fTabRect)) - return; - - // outer frame - fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.LeftBottom(), - fFrameColors[0]); - fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.RightTop(), - fFrameColors[0]); - if (fLook != kLeftTitledWindowLook) { - fDrawingEngine->StrokeLine(fTabRect.RightTop(), fTabRect.RightBottom(), - fFrameColors[5]); - } else { - fDrawingEngine->StrokeLine(fTabRect.LeftBottom(), - fTabRect.RightBottom(), fFrameColors[5]); - } - - // bevel - fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 1, fTabRect.top + 1), - BPoint(fTabRect.left + 1, - fTabRect.bottom - (fLook == kLeftTitledWindowLook ? 1 : 0)), - fTabColorBevel); - fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 1, fTabRect.top + 1), - BPoint(fTabRect.right - (fLook == kLeftTitledWindowLook ? 0 : 1), - fTabRect.top + 1), - fTabColorBevel); - - if (fLook != kLeftTitledWindowLook) { - fDrawingEngine->StrokeLine(BPoint(fTabRect.right - 1, fTabRect.top + 2), - BPoint(fTabRect.right - 1, fTabRect.bottom), fTabColorShadow); - } else { - fDrawingEngine->StrokeLine( - BPoint(fTabRect.left + 2, fTabRect.bottom - 1), - BPoint(fTabRect.right, fTabRect.bottom - 1), fTabColorShadow); - } - - // fill - BGradientLinear gradient; - gradient.SetStart(fTabRect.LeftTop()); - gradient.AddColor(fTabColorLight, 0); - gradient.AddColor(fTabColor, 255); - - if (fLook != kLeftTitledWindowLook) { - gradient.SetEnd(fTabRect.LeftBottom()); - fDrawingEngine->FillRect(BRect(fTabRect.left + 2, fTabRect.top + 2, - fTabRect.right - 2, fTabRect.bottom), gradient); - } else { - gradient.SetEnd(fTabRect.RightTop()); - fDrawingEngine->FillRect(BRect(fTabRect.left + 2, fTabRect.top + 2, - fTabRect.right, fTabRect.bottom - 2), gradient); - } - - _DrawTitle(fTabRect); - - // Draw the buttons if we're supposed to - if (!(fFlags & B_NOT_CLOSABLE) && invalid.Intersects(fCloseRect)) - _DrawClose(fCloseRect); - - if (fStackedMode) { - if (fStackedDrawZoom && invalid.Intersects(fZoomRect)) - _DrawZoom(fZoomRect); - } - else if (!(fFlags & B_NOT_ZOOMABLE) && invalid.Intersects(fZoomRect)) - _DrawZoom(fZoomRect); -} - - bool SATDecorator::_SetTabLocation(float location, BRegion* updateRegion) { @@ -538,6 +465,24 @@ } +void +SATDecorator::DrawButtons(const BRect& invalid) +{ + // Draw the buttons if we're supposed to + if (!(fFlags & B_NOT_CLOSABLE) && invalid.Intersects(fCloseRect)) + _DrawClose(fCloseRect); + + if (fStackedMode) { + // TODO: This should be solved differently. We don't just want to not + // draw the button, we actually want it removed. So rather add extra + // flags to remove the individual buttons to DefaultDecorator. + if (fStackedDrawZoom && invalid.Intersects(fZoomRect)) + _DrawZoom(fZoomRect); + } else if (!(fFlags & B_NOT_ZOOMABLE) && invalid.Intersects(fZoomRect)) + _DrawZoom(fZoomRect); +} + + extern "C" DecorAddOn* (instantiate_decor_addon)(image_id id, const char* name) { return new (std::nothrow)SATDecorAddOn(id, name); Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.h =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.h 2010-11-25 14:42:28 UTC (rev 39626) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.h 2010-11-25 15:01:30 UTC (rev 39627) @@ -56,13 +56,14 @@ protected: void _DoLayout(); - void _DrawTab(BRect r); void _LayoutTabItems(const BRect& tabRect); bool _SetTabLocation(float location, BRegion* updateRegion = NULL); void _SetFocus(); + virtual void DrawButtons(const BRect& invalid); + private: bool fTabHighlighted; bool fBordersHighlighted; Modified: haiku/trunk/src/servers/app/DefaultDecorator.cpp =================================================================== --- haiku/trunk/src/servers/app/DefaultDecorator.cpp 2010-11-25 14:42:28 UTC (rev 39626) +++ haiku/trunk/src/servers/app/DefaultDecorator.cpp 2010-11-25 15:01:30 UTC (rev 39627) @@ -655,11 +655,7 @@ _DrawTitle(fTabRect); - // Draw the buttons if we're supposed to - if (!(fFlags & B_NOT_CLOSABLE) && invalid.Intersects(fCloseRect)) - _DrawClose(fCloseRect); - if (!(fFlags & B_NOT_ZOOMABLE) && invalid.Intersects(fZoomRect)) - _DrawZoom(fZoomRect); + DrawButtons(invalid); } @@ -1091,6 +1087,17 @@ void +DefaultDecorator::DrawButtons(const BRect& invalid) +{ + // Draw the buttons if we're supposed to + if (!(fFlags & B_NOT_CLOSABLE) && invalid.Intersects(fCloseRect)) + _DrawClose(fCloseRect); + if (!(fFlags & B_NOT_ZOOMABLE) && invalid.Intersects(fZoomRect)) + _DrawZoom(fZoomRect); +} + + +void DefaultDecorator::_UpdateFont(DesktopSettings& settings) { ServerFont font; Modified: haiku/trunk/src/servers/app/DefaultDecorator.h =================================================================== --- haiku/trunk/src/servers/app/DefaultDecorator.h 2010-11-25 14:42:28 UTC (rev 39626) +++ haiku/trunk/src/servers/app/DefaultDecorator.h 2010-11-25 15:01:30 UTC (rev 39627) @@ -80,6 +80,9 @@ float* offset, float* size, float* inset) const; + // DefaultDecorator customization points + virtual void DrawButtons(const BRect& invalid); + private: void _UpdateFont(DesktopSettings& settings); void _DrawButtonBitmap(ServerBitmap* bitmap,