* Draw the complete decorator off screen and copy it to the front when finished. Stippi please take a look. This fixes some flickering when drawing shifted tabs in stack mode. In stack mode the different tabs sometime repaint each other, thus the decorator has to been drawn double buffered to avoid artefacts.

* Add an option to draw the button directly, i.e. when they are clicked.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42493 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler 2011-07-26 05:53:35 +00:00
parent 7c5525e834
commit 86b010824c
5 changed files with 34 additions and 25 deletions

View File

@ -1761,11 +1761,12 @@ Window::_DrawBorder()
if (dirtyBorderRegion->CountRects() > 0 && engine->LockParallelAccess()) {
engine->ConstrainClippingRegion(dirtyBorderRegion);
bool copyToFrontEnabled = engine->CopyToFrontEnabled();
engine->SetCopyToFrontEnabled(true);
engine->SetCopyToFrontEnabled(false);
decorator->Draw(dirtyBorderRegion->Frame());
engine->SetCopyToFrontEnabled(copyToFrontEnabled);
engine->CopyToFront(*dirtyBorderRegion);
// TODO: remove this once the DrawState stuff is handled
// more cleanly. The reason why this is needed is that

View File

@ -651,10 +651,10 @@ Decorator::DrawTab(int32 tabIndex)
return;
_DrawTab(tab, tab->tabRect);
_DrawZoom(tab, tab->zoomRect);
_DrawMinimize(tab, tab->minimizeRect);
_DrawZoom(tab, false, tab->zoomRect);
_DrawMinimize(tab, false, tab->minimizeRect);
_DrawTitle(tab, tab->tabRect);
_DrawClose(tab, tab->closeRect);
_DrawClose(tab, false, tab->closeRect);
}
@ -665,7 +665,7 @@ Decorator::DrawClose(int32 tab)
Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
if (decoratorTab == NULL)
return;
_DrawClose(decoratorTab, decoratorTab->closeRect);
_DrawClose(decoratorTab, true, decoratorTab->closeRect);
}
@ -698,7 +698,7 @@ Decorator::DrawZoom(int32 tab)
Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
if (decoratorTab == NULL)
return;
_DrawZoom(decoratorTab, decoratorTab->zoomRect);
_DrawZoom(decoratorTab, true, decoratorTab->zoomRect);
}
@ -779,7 +779,7 @@ Decorator::_DrawTab(Decorator::Tab* tab, BRect rect)
\param rect Area of the button to update
*/
void
Decorator::_DrawClose(Decorator::Tab* tab, BRect rect)
Decorator::_DrawClose(Decorator::Tab* tab, bool direct, BRect rect)
{
}
@ -807,7 +807,7 @@ Decorator::_DrawTitle(Decorator::Tab* tab, BRect rect)
\param rect Area of the button to update
*/
void
Decorator::_DrawZoom(Decorator::Tab* tab, BRect rect)
Decorator::_DrawZoom(Decorator::Tab* tab, bool direct, BRect rect)
{
}
@ -820,7 +820,7 @@ Decorator::_DrawZoom(Decorator::Tab* tab, BRect rect)
\param rect Area of the button to update
*/
void
Decorator::_DrawMinimize(Decorator::Tab* tab, BRect rect)
Decorator::_DrawMinimize(Decorator::Tab* tab, bool direct, BRect rect)
{
}

View File

@ -173,10 +173,14 @@ protected:
virtual void _DrawTabs(BRect rect);
virtual void _DrawTab(Decorator::Tab* tab, BRect rect);
virtual void _DrawClose(Decorator::Tab* tab, BRect rect);
virtual void _DrawTitle(Decorator::Tab* tab, BRect rect);
virtual void _DrawZoom(Decorator::Tab* tab, BRect rect);
virtual void _DrawMinimize(Decorator::Tab* tab, BRect rect);
//! direct means drawing without double buffering
virtual void _DrawClose(Decorator::Tab* tab, bool direct,
BRect rect);
virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
BRect rect);
virtual void _DrawMinimize(Decorator::Tab* tab, bool direct,
BRect rect);
virtual Decorator::Tab* _AllocateNewTab() = 0;

View File

@ -952,7 +952,7 @@ DefaultDecorator::_DrawTab(Decorator::Tab* tab, BRect invalid)
void
DefaultDecorator::_DrawClose(Decorator::Tab* _tab, BRect rect)
DefaultDecorator::_DrawClose(Decorator::Tab* _tab, bool direct, BRect rect)
{
STRACE(("_DrawClose(%f,%f,%f,%f)\n", rect.left, rect.top, rect.right,
rect.bottom));
@ -967,7 +967,7 @@ DefaultDecorator::_DrawClose(Decorator::Tab* _tab, BRect rect)
tab->closeBitmaps[index] = bitmap;
}
_DrawButtonBitmap(bitmap, rect);
_DrawButtonBitmap(bitmap, direct, rect);
}
@ -1016,7 +1016,7 @@ DefaultDecorator::_DrawTitle(Decorator::Tab* _tab, BRect r)
void
DefaultDecorator::_DrawZoom(Decorator::Tab* _tab, BRect rect)
DefaultDecorator::_DrawZoom(Decorator::Tab* _tab, bool direct, BRect rect)
{
STRACE(("_DrawZoom(%f,%f,%f,%f)\n", rect.left, rect.top, rect.right,
rect.bottom));
@ -1032,7 +1032,7 @@ DefaultDecorator::_DrawZoom(Decorator::Tab* _tab, BRect rect)
tab->zoomBitmaps[index] = bitmap;
}
_DrawButtonBitmap(bitmap, rect);
_DrawButtonBitmap(bitmap, direct, rect);
}
@ -1397,7 +1397,7 @@ DefaultDecorator::_AddTab(int32 index, BRegion* updateRegion)
bool
DefaultDecorator::_RemoveTab(int32 index, BRegion* updateRegion )
DefaultDecorator::_RemoveTab(int32 index, BRegion* updateRegion)
{
BRect oldTitle = fTitleBarRect;
_DoLayout();
@ -1475,9 +1475,9 @@ DefaultDecorator::DrawButtons(Decorator::Tab* tab, const BRect& invalid)
{
// Draw the buttons if we're supposed to
if (!(fFlags & B_NOT_CLOSABLE) && invalid.Intersects(tab->closeRect))
_DrawClose(tab, tab->closeRect);
_DrawClose(tab, false, tab->closeRect);
if (!(fFlags & B_NOT_ZOOMABLE) && invalid.Intersects(tab->zoomRect))
_DrawZoom(tab, tab->zoomRect);
_DrawZoom(tab, false, tab->zoomRect);
}
@ -1574,13 +1574,14 @@ DefaultDecorator::_UpdateFont(DesktopSettings& settings)
void
DefaultDecorator::_DrawButtonBitmap(ServerBitmap* bitmap, BRect rect)
DefaultDecorator::_DrawButtonBitmap(ServerBitmap* bitmap, bool direct,
BRect rect)
{
if (bitmap == NULL)
return;
bool copyToFrontEnabled = fDrawingEngine->CopyToFrontEnabled();
fDrawingEngine->SetCopyToFrontEnabled(true);
fDrawingEngine->SetCopyToFrontEnabled(direct);
drawing_mode oldMode;
fDrawingEngine->SetDrawingMode(B_OP_OVER, oldMode);
fDrawingEngine->DrawBitmap(bitmap, rect.OffsetToCopy(0, 0), rect);

View File

@ -113,11 +113,14 @@ protected:
virtual void _DrawFrame(BRect r);
virtual void _DrawTab(Decorator::Tab* tab, BRect r);
virtual void _DrawClose(Decorator::Tab* tab, BRect r);
virtual void _DrawClose(Decorator::Tab* tab, bool direct,
BRect r);
virtual void _DrawTitle(Decorator::Tab* tab, BRect r);
virtual void _DrawZoom(Decorator::Tab* tab, BRect r);
virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
BRect r);
virtual void _SetTitle(Decorator::Tab* tab, const char* string,
virtual void _SetTitle(Decorator::Tab* tab,
const char* string,
BRegion* updateRegion = NULL);
virtual void _SetFocus(Decorator::Tab* tab);
@ -162,7 +165,7 @@ protected:
private:
void _UpdateFont(DesktopSettings& settings);
void _DrawButtonBitmap(ServerBitmap* bitmap,
BRect rect);
bool direct, BRect rect);
void _DrawBlendedRect(DrawingEngine *engine,
BRect rect, bool down,
const ComponentColors& colors);