Only highlight the adjacent borders when tile them.

Simplify Decorator highlighting code. Thanks Ingo for the hard part done in the previous highlight changes!



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39702 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler
2010-12-02 02:33:36 +00:00
parent a54ffcd265
commit ac701f7e7b
6 changed files with 60 additions and 100 deletions
@@ -84,9 +84,6 @@ SATDecorator::SATDecorator(DesktopSettings& settings, BRect frame,
: :
DefaultDecorator(settings, frame, look, flags), DefaultDecorator(settings, frame, look, flags),
fTabHighlighted(false),
fBordersHighlighted(false),
fStackedMode(false), fStackedMode(false),
fStackedTabLength(0) fStackedTabLength(0)
{ {
@@ -94,38 +91,6 @@ SATDecorator::SATDecorator(DesktopSettings& settings, BRect frame,
} }
void
SATDecorator::HighlightTab(bool active, BRegion* dirty)
{
if (active == fTabHighlighted)
return;
uint8 highlight = active ? HIGHLIGHT_STACK_AND_TILE : 0;
SetRegionHighlight(REGION_TAB, highlight, dirty);
SetRegionHighlight(REGION_CLOSE_BUTTON, highlight, dirty);
SetRegionHighlight(REGION_ZOOM_BUTTON, highlight, dirty);
fTabHighlighted = active;
}
void
SATDecorator::HighlightBorders(bool active, BRegion* dirty)
{
if (active == fBordersHighlighted)
return;
uint8 highlight = active ? HIGHLIGHT_STACK_AND_TILE : 0;
SetRegionHighlight(REGION_LEFT_BORDER, highlight, dirty);
SetRegionHighlight(REGION_RIGHT_BORDER, highlight, dirty);
SetRegionHighlight(REGION_TOP_BORDER, highlight, dirty);
SetRegionHighlight(REGION_BOTTOM_BORDER, highlight, dirty);
SetRegionHighlight(REGION_RIGHT_BOTTOM_CORNER, highlight, dirty);
fBordersHighlighted = active;
}
void void
SATDecorator::SetStackedMode(bool stacked, BRegion* dirty) SATDecorator::SetStackedMode(bool stacked, BRegion* dirty)
{ {
@@ -40,13 +40,6 @@ public:
BRect frame, window_look look, BRect frame, window_look look,
uint32 flags); uint32 flags);
void HighlightTab(bool active, BRegion* dirty);
void HighlightBorders(bool active, BRegion* dirty);
bool IsTabHighlighted() const
{ return fTabHighlighted; }
bool IsBordersHighlighted() const
{ return fBordersHighlighted; }
/*! Indicates that window is stacked */ /*! Indicates that window is stacked */
void SetStackedMode(bool stacked, BRegion* dirty); void SetStackedMode(bool stacked, BRegion* dirty);
bool StackedMode() const bool StackedMode() const
@@ -72,9 +65,6 @@ protected:
uint8 highlight, ComponentColors _colors); uint8 highlight, ComponentColors _colors);
private: private:
bool fTabHighlighted;
bool fBordersHighlighted;
bool fStackedMode; bool fStackedMode;
bool fStackedDrawZoom; bool fStackedDrawZoom;
float fStackedTabLength; float fStackedTabLength;
@@ -601,54 +601,35 @@ SATWindow::HighlightTab(bool active)
if (!decorator) if (!decorator)
return false; return false;
if (IsTabHighlighted() == active)
return false;
BRegion dirty; BRegion dirty;
decorator->HighlightTab(active, &dirty); uint8 highlight = active ? SATDecorator::HIGHLIGHT_STACK_AND_TILE : 0;
fWindow->ProcessDirtyRegion(dirty); decorator->SetRegionHighlight(SATDecorator::REGION_TAB, highlight, &dirty);
decorator->SetRegionHighlight(SATDecorator::REGION_CLOSE_BUTTON, highlight,
&dirty);
decorator->SetRegionHighlight(SATDecorator::REGION_ZOOM_BUTTON, highlight,
&dirty);
fWindow->ProcessDirtyRegion(dirty);
return true; return true;
} }
bool bool
SATWindow::HighlightBorders(bool active) SATWindow::HighlightBorders(Decorator::Region region, bool active)
{ {
SATDecorator* decorator = GetDecorator(); SATDecorator* decorator = GetDecorator();
if (!decorator) if (!decorator)
return false; return false;
if (IsBordersHighlighted() == active)
return false;
BRegion dirty; BRegion dirty;
decorator->HighlightBorders(active, &dirty); uint8 highlight = active ? SATDecorator::HIGHLIGHT_STACK_AND_TILE : 0;
decorator->SetRegionHighlight(region, highlight, &dirty);
fWindow->ProcessDirtyRegion(dirty); fWindow->ProcessDirtyRegion(dirty);
return true; return true;
} }
bool
SATWindow::IsTabHighlighted()
{
SATDecorator* decorator = GetDecorator();
if (decorator)
return decorator->IsTabHighlighted();
return false;
}
bool
SATWindow::IsBordersHighlighted()
{
SATDecorator* decorator = GetDecorator();
if (decorator)
return decorator->IsBordersHighlighted();
return false;
}
bool bool
SATWindow::SetStackedMode(bool stacked) SATWindow::SetStackedMode(bool stacked)
{ {
@@ -120,7 +120,8 @@ public:
bool PositionManagedBySAT(); bool PositionManagedBySAT();
bool HighlightTab(bool active); bool HighlightTab(bool active);
bool HighlightBorders(bool active); bool HighlightBorders(Decorator::Region region,
bool active);
bool IsTabHighlighted(); bool IsTabHighlighted();
bool IsBordersHighlighted(); bool IsBordersHighlighted();
+41 -21
View File
@@ -440,28 +440,44 @@ SATTiling::_HighlightWindows(SATGroup* group, bool highlight)
const TabList* hTabs = group->HorizontalTabs(); const TabList* hTabs = group->HorizontalTabs();
const TabList* vTabs = group->VerticalTabs(); const TabList* vTabs = group->VerticalTabs();
// height light windows at all four sites // height light windows at all four sites
_SearchHighlightWindow(fFreeAreaLeft, fFreeAreaTop, fFreeAreaBottom, hTabs, bool leftWindowsFound = _SearchHighlightWindow(fFreeAreaLeft, fFreeAreaTop, fFreeAreaBottom, hTabs,
fFreeAreaTop ? Corner::kLeftBottom : Corner::kLeftTop, highlight); fFreeAreaTop ? Corner::kLeftBottom : Corner::kLeftTop,
Decorator::REGION_RIGHT_BORDER, highlight);
_SearchHighlightWindow(fFreeAreaTop, fFreeAreaLeft, fFreeAreaRight, vTabs, bool topWindowsFound = _SearchHighlightWindow(fFreeAreaTop, fFreeAreaLeft, fFreeAreaRight, vTabs,
fFreeAreaLeft ? Corner::kRightTop : Corner::kLeftTop, highlight); fFreeAreaLeft ? Corner::kRightTop : Corner::kLeftTop,
Decorator::REGION_BOTTOM_BORDER, highlight);
_SearchHighlightWindow(fFreeAreaRight, fFreeAreaTop, fFreeAreaBottom, hTabs, bool rightWindowsFound = _SearchHighlightWindow(fFreeAreaRight, fFreeAreaTop, fFreeAreaBottom, hTabs,
fFreeAreaTop ? Corner::kRightBottom : Corner::kRightTop, highlight); fFreeAreaTop ? Corner::kRightBottom : Corner::kRightTop,
Decorator::REGION_LEFT_BORDER, highlight);
_SearchHighlightWindow(fFreeAreaBottom, fFreeAreaLeft, fFreeAreaRight, bool bottomWindowsFound = _SearchHighlightWindow(fFreeAreaBottom, fFreeAreaLeft, fFreeAreaRight,
vTabs, fFreeAreaLeft ? Corner::kRightBottom : Corner::kLeftBottom, vTabs, fFreeAreaLeft ? Corner::kRightBottom : Corner::kLeftBottom,
highlight); Decorator::REGION_TOP_BORDER, highlight);
if (leftWindowsFound)
fSATWindow->HighlightBorders(Decorator::REGION_LEFT_BORDER, highlight);
if (topWindowsFound)
fSATWindow->HighlightBorders(Decorator::REGION_TOP_BORDER, highlight);
if (rightWindowsFound)
fSATWindow->HighlightBorders(Decorator::REGION_RIGHT_BORDER, highlight);
if (bottomWindowsFound) {
fSATWindow->HighlightBorders(Decorator::REGION_BOTTOM_BORDER,
highlight);
}
} }
void bool
SATTiling::_SearchHighlightWindow(Tab* tab, Tab* firstOrthTab, SATTiling::_SearchHighlightWindow(Tab* tab, Tab* firstOrthTab,
Tab* secondOrthTab, const TabList* orthTabs, Corner::position_t areaCorner, Tab* secondOrthTab, const TabList* orthTabs, Corner::position_t areaCorner,
bool highlight) Decorator::Region region, bool highlight)
{ {
bool windowsFound = false;
if (!tab) if (!tab)
return; return false;
int8 searchDir = 1; int8 searchDir = 1;
Tab* startOrthTab = NULL; Tab* startOrthTab = NULL;
@@ -477,11 +493,11 @@ SATTiling::_SearchHighlightWindow(Tab* tab, Tab* firstOrthTab,
endOrthTab = firstOrthTab; endOrthTab = firstOrthTab;
} }
else else
return; return false;
int32 index = orthTabs->IndexOf(startOrthTab); int32 index = orthTabs->IndexOf(startOrthTab);
if (index < 0) if (index < 0)
return; return false;
for (; index < orthTabs->CountItems() && index >= 0; index += searchDir) { for (; index < orthTabs->CountItems() && index >= 0; index += searchDir) {
Tab* orthTab = orthTabs->ItemAt(index); Tab* orthTab = orthTabs->ItemAt(index);
@@ -491,20 +507,24 @@ SATTiling::_SearchHighlightWindow(Tab* tab, Tab* firstOrthTab,
if (!crossing) if (!crossing)
continue; continue;
Corner* corner = crossing->GetCorner(areaCorner); Corner* corner = crossing->GetCorner(areaCorner);
if (corner->windowArea) if (corner->windowArea) {
_HighlightWindows(corner->windowArea, highlight); _HighlightWindows(corner->windowArea, region, highlight);
windowsFound = true;
}
} }
return windowsFound;
} }
void void
SATTiling::_HighlightWindows(WindowArea* area, bool highlight) SATTiling::_HighlightWindows(WindowArea* area, Decorator::Region region,
bool highlight)
{ {
const SATWindowList& list = area->WindowList(); const SATWindowList& list = area->LayerOrder();
for (int i = 0; i < list.CountItems(); i++) SATWindow* topWindow = list.ItemAt(list.CountItems() - 1);
list.ItemAt(i)->HighlightBorders(highlight); if (topWindow == NULL)
return;
fSATWindow->HighlightBorders(highlight); topWindow->HighlightBorders(region, highlight);
} }
+6 -3
View File
@@ -9,6 +9,8 @@
#define TILING_H #define TILING_H
#include "ObjectList.h" #include "ObjectList.h"
#include "Decorator.h"
#include "StackAndTile.h" #include "StackAndTile.h"
@@ -48,11 +50,12 @@ private:
void _HighlightWindows(SATGroup* group, void _HighlightWindows(SATGroup* group,
bool highlight = true); bool highlight = true);
void _SearchHighlightWindow(Tab* tab, Tab* firstOrthTab, bool _SearchHighlightWindow(Tab* tab, Tab* firstOrthTab,
Tab* secondOrthTab, const TabList* orthTabs, Tab* secondOrthTab, const TabList* orthTabs,
Corner::position_t areaCorner, bool highlight); Corner::position_t areaCorner,
Decorator::Region region, bool highlight);
void _HighlightWindows(WindowArea* area, void _HighlightWindows(WindowArea* area,
bool highlight); Decorator::Region region, bool highlight);
void _ResetSearchResults(); void _ResetSearchResults();