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),
fTabHighlighted(false),
fBordersHighlighted(false),
fStackedMode(false),
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
SATDecorator::SetStackedMode(bool stacked, BRegion* dirty)
{
@@ -40,13 +40,6 @@ public:
BRect frame, window_look look,
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 */
void SetStackedMode(bool stacked, BRegion* dirty);
bool StackedMode() const
@@ -72,9 +65,6 @@ protected:
uint8 highlight, ComponentColors _colors);
private:
bool fTabHighlighted;
bool fBordersHighlighted;
bool fStackedMode;
bool fStackedDrawZoom;
float fStackedTabLength;
@@ -601,54 +601,35 @@ SATWindow::HighlightTab(bool active)
if (!decorator)
return false;
if (IsTabHighlighted() == active)
return false;
BRegion dirty;
decorator->HighlightTab(active, &dirty);
fWindow->ProcessDirtyRegion(dirty);
uint8 highlight = active ? SATDecorator::HIGHLIGHT_STACK_AND_TILE : 0;
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;
}
bool
SATWindow::HighlightBorders(bool active)
SATWindow::HighlightBorders(Decorator::Region region, bool active)
{
SATDecorator* decorator = GetDecorator();
if (!decorator)
return false;
if (IsBordersHighlighted() == active)
return false;
BRegion dirty;
decorator->HighlightBorders(active, &dirty);
uint8 highlight = active ? SATDecorator::HIGHLIGHT_STACK_AND_TILE : 0;
decorator->SetRegionHighlight(region, highlight, &dirty);
fWindow->ProcessDirtyRegion(dirty);
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
SATWindow::SetStackedMode(bool stacked)
{
@@ -120,7 +120,8 @@ public:
bool PositionManagedBySAT();
bool HighlightTab(bool active);
bool HighlightBorders(bool active);
bool HighlightBorders(Decorator::Region region,
bool active);
bool IsTabHighlighted();
bool IsBordersHighlighted();
+41 -21
View File
@@ -440,28 +440,44 @@ SATTiling::_HighlightWindows(SATGroup* group, bool highlight)
const TabList* hTabs = group->HorizontalTabs();
const TabList* vTabs = group->VerticalTabs();
// height light windows at all four sites
_SearchHighlightWindow(fFreeAreaLeft, fFreeAreaTop, fFreeAreaBottom, hTabs,
fFreeAreaTop ? Corner::kLeftBottom : Corner::kLeftTop, highlight);
bool leftWindowsFound = _SearchHighlightWindow(fFreeAreaLeft, fFreeAreaTop, fFreeAreaBottom, hTabs,
fFreeAreaTop ? Corner::kLeftBottom : Corner::kLeftTop,
Decorator::REGION_RIGHT_BORDER, highlight);
_SearchHighlightWindow(fFreeAreaTop, fFreeAreaLeft, fFreeAreaRight, vTabs,
fFreeAreaLeft ? Corner::kRightTop : Corner::kLeftTop, highlight);
bool topWindowsFound = _SearchHighlightWindow(fFreeAreaTop, fFreeAreaLeft, fFreeAreaRight, vTabs,
fFreeAreaLeft ? Corner::kRightTop : Corner::kLeftTop,
Decorator::REGION_BOTTOM_BORDER, highlight);
_SearchHighlightWindow(fFreeAreaRight, fFreeAreaTop, fFreeAreaBottom, hTabs,
fFreeAreaTop ? Corner::kRightBottom : Corner::kRightTop, highlight);
bool rightWindowsFound = _SearchHighlightWindow(fFreeAreaRight, fFreeAreaTop, fFreeAreaBottom, hTabs,
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,
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,
Tab* secondOrthTab, const TabList* orthTabs, Corner::position_t areaCorner,
bool highlight)
Decorator::Region region, bool highlight)
{
bool windowsFound = false;
if (!tab)
return;
return false;
int8 searchDir = 1;
Tab* startOrthTab = NULL;
@@ -477,11 +493,11 @@ SATTiling::_SearchHighlightWindow(Tab* tab, Tab* firstOrthTab,
endOrthTab = firstOrthTab;
}
else
return;
return false;
int32 index = orthTabs->IndexOf(startOrthTab);
if (index < 0)
return;
return false;
for (; index < orthTabs->CountItems() && index >= 0; index += searchDir) {
Tab* orthTab = orthTabs->ItemAt(index);
@@ -491,20 +507,24 @@ SATTiling::_SearchHighlightWindow(Tab* tab, Tab* firstOrthTab,
if (!crossing)
continue;
Corner* corner = crossing->GetCorner(areaCorner);
if (corner->windowArea)
_HighlightWindows(corner->windowArea, highlight);
if (corner->windowArea) {
_HighlightWindows(corner->windowArea, region, highlight);
windowsFound = true;
}
}
return windowsFound;
}
void
SATTiling::_HighlightWindows(WindowArea* area, bool highlight)
SATTiling::_HighlightWindows(WindowArea* area, Decorator::Region region,
bool highlight)
{
const SATWindowList& list = area->WindowList();
for (int i = 0; i < list.CountItems(); i++)
list.ItemAt(i)->HighlightBorders(highlight);
fSATWindow->HighlightBorders(highlight);
const SATWindowList& list = area->LayerOrder();
SATWindow* topWindow = list.ItemAt(list.CountItems() - 1);
if (topWindow == NULL)
return;
topWindow->HighlightBorders(region, highlight);
}
+6 -3
View File
@@ -9,6 +9,8 @@
#define TILING_H
#include "ObjectList.h"
#include "Decorator.h"
#include "StackAndTile.h"
@@ -48,11 +50,12 @@ private:
void _HighlightWindows(SATGroup* group,
bool highlight = true);
void _SearchHighlightWindow(Tab* tab, Tab* firstOrthTab,
bool _SearchHighlightWindow(Tab* tab, Tab* firstOrthTab,
Tab* secondOrthTab, const TabList* orthTabs,
Corner::position_t areaCorner, bool highlight);
Corner::position_t areaCorner,
Decorator::Region region, bool highlight);
void _HighlightWindows(WindowArea* area,
bool highlight);
Decorator::Region region, bool highlight);
void _ResetSearchResults();