* 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.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39627 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-11-25 15:01:30 +00:00
parent 638d9c8039
commit 7ca71ab6a2
4 changed files with 35 additions and 79 deletions

View File

@ -406,79 +406,6 @@ SATDecorator::_LayoutTabItems(const BRect& tabRect)
}
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 @@ SATDecorator::_SetFocus()
}
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);

View File

@ -56,13 +56,14 @@ public:
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;

View File

@ -655,11 +655,7 @@ DefaultDecorator::_DrawTab(BRect invalid)
_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);
}
@ -1090,6 +1086,17 @@ DefaultDecorator::_GetFootprint(BRegion *region)
}
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)
{

View File

@ -80,6 +80,9 @@ protected:
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,