Fix the SATDecorator. Much of the stacking part is handled by the DefaultDecorator now.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42479 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -85,359 +85,29 @@ SATDecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect,
|
|||||||
SATDecorator::SATDecorator(DesktopSettings& settings, BRect frame,
|
SATDecorator::SATDecorator(DesktopSettings& settings, BRect frame,
|
||||||
window_look look, uint32 flags)
|
window_look look, uint32 flags)
|
||||||
:
|
:
|
||||||
DefaultDecorator(settings, frame, look, flags),
|
DefaultDecorator(settings, frame, look, flags)
|
||||||
|
|
||||||
fStackedMode(false),
|
|
||||||
fStackedTabLength(0)
|
|
||||||
{
|
{
|
||||||
fStackedDrawZoom = IsFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SATDecorator::SetStackedMode(bool stacked, BRegion* dirty)
|
|
||||||
{
|
|
||||||
fStackedMode = stacked;
|
|
||||||
|
|
||||||
dirty->Include(fTabRect);
|
|
||||||
_DoLayout();
|
|
||||||
_InvalidateFootprint();
|
|
||||||
dirty->Include(fTabRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SATDecorator::SetStackedTabLength(float length, BRegion* dirty)
|
|
||||||
{
|
|
||||||
fStackedTabLength = length;
|
|
||||||
|
|
||||||
dirty->Include(fTabRect);
|
|
||||||
_DoLayout();
|
|
||||||
_InvalidateFootprint();
|
|
||||||
dirty->Include(fTabRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SATDecorator::_DoLayout()
|
|
||||||
{
|
|
||||||
STRACE(("DefaultDecorator: Do Layout\n"));
|
|
||||||
// Here we determine the size of every rectangle that we use
|
|
||||||
// internally when we are given the size of the client rectangle.
|
|
||||||
|
|
||||||
bool hasTab = false;
|
|
||||||
|
|
||||||
switch ((int)Look()) {
|
|
||||||
case B_MODAL_WINDOW_LOOK:
|
|
||||||
fBorderWidth = 5;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_TITLED_WINDOW_LOOK:
|
|
||||||
case B_DOCUMENT_WINDOW_LOOK:
|
|
||||||
hasTab = true;
|
|
||||||
fBorderWidth = 5;
|
|
||||||
break;
|
|
||||||
case B_FLOATING_WINDOW_LOOK:
|
|
||||||
case kLeftTitledWindowLook:
|
|
||||||
hasTab = true;
|
|
||||||
fBorderWidth = 3;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_BORDERED_WINDOW_LOOK:
|
|
||||||
fBorderWidth = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
fBorderWidth = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate our tab rect
|
|
||||||
if (hasTab) {
|
|
||||||
// distance from one item of the tab bar to another.
|
|
||||||
// In this case the text and close/zoom rects
|
|
||||||
fTextOffset = (fLook == B_FLOATING_WINDOW_LOOK
|
|
||||||
|| fLook == kLeftTitledWindowLook) ? 10 : 18;
|
|
||||||
|
|
||||||
font_height fontHeight;
|
|
||||||
fDrawState.Font().GetHeight(fontHeight);
|
|
||||||
|
|
||||||
if (fLook != kLeftTitledWindowLook) {
|
|
||||||
fTabRect.Set(fFrame.left - fBorderWidth,
|
|
||||||
fFrame.top - fBorderWidth
|
|
||||||
- ceilf(fontHeight.ascent + fontHeight.descent + 7.0),
|
|
||||||
((fFrame.right - fFrame.left) < 35.0 ?
|
|
||||||
fFrame.left + 35.0 : fFrame.right) + fBorderWidth,
|
|
||||||
fFrame.top - fBorderWidth);
|
|
||||||
} else {
|
|
||||||
fTabRect.Set(fFrame.left - fBorderWidth
|
|
||||||
- ceilf(fontHeight.ascent + fontHeight.descent + 5.0),
|
|
||||||
fFrame.top - fBorderWidth, fFrame.left - fBorderWidth,
|
|
||||||
fFrame.bottom + fBorderWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
// format tab rect for a floating window - make the rect smaller
|
|
||||||
if (fLook == B_FLOATING_WINDOW_LOOK) {
|
|
||||||
fTabRect.InsetBy(0, 2);
|
|
||||||
fTabRect.OffsetBy(0, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fStackedMode)
|
|
||||||
fTabRect.right = fTabRect.left + fStackedTabLength;
|
|
||||||
|
|
||||||
float offset;
|
|
||||||
float size;
|
|
||||||
float inset;
|
|
||||||
_GetButtonSizeAndOffset(fTabRect, &offset, &size, &inset);
|
|
||||||
|
|
||||||
// fMinTabSize contains just the room for the buttons
|
|
||||||
fMinTabSize = inset * 2 + fTextOffset;
|
|
||||||
if ((fFlags & B_NOT_CLOSABLE) == 0)
|
|
||||||
fMinTabSize += offset + size;
|
|
||||||
if ((fFlags & B_NOT_ZOOMABLE) == 0)
|
|
||||||
fMinTabSize += offset + size;
|
|
||||||
|
|
||||||
// fMaxTabSize contains fMinWidth + the width required for the title
|
|
||||||
fMaxTabSize = fDrawingEngine
|
|
||||||
? ceilf(fDrawingEngine->StringWidth(Title(), strlen(Title()),
|
|
||||||
fDrawState.Font())) : 0.0;
|
|
||||||
if (fMaxTabSize > 0.0)
|
|
||||||
fMaxTabSize += fTextOffset;
|
|
||||||
fMaxTabSize += fMinTabSize;
|
|
||||||
|
|
||||||
float tabSize = (fLook != kLeftTitledWindowLook
|
|
||||||
? fFrame.Width() : fFrame.Height()) + fBorderWidth * 2;
|
|
||||||
|
|
||||||
if (fStackedMode) {
|
|
||||||
tabSize = fStackedTabLength;
|
|
||||||
fMaxTabSize = tabSize;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (tabSize < fMinTabSize)
|
|
||||||
tabSize = fMinTabSize;
|
|
||||||
if (tabSize > fMaxTabSize)
|
|
||||||
tabSize = fMaxTabSize;
|
|
||||||
}
|
|
||||||
// layout buttons and truncate text
|
|
||||||
if (fLook != kLeftTitledWindowLook)
|
|
||||||
fTabRect.right = fTabRect.left + tabSize;
|
|
||||||
else
|
|
||||||
fTabRect.bottom = fTabRect.top + tabSize;
|
|
||||||
} else {
|
|
||||||
// no tab
|
|
||||||
fMinTabSize = 0.0;
|
|
||||||
fMaxTabSize = 0.0;
|
|
||||||
fTabRect.Set(0.0, 0.0, -1.0, -1.0);
|
|
||||||
fCloseRect.Set(0.0, 0.0, -1.0, -1.0);
|
|
||||||
fZoomRect.Set(0.0, 0.0, -1.0, -1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate left/top/right/bottom borders
|
|
||||||
if (fBorderWidth > 0) {
|
|
||||||
// NOTE: no overlapping, the left and right border rects
|
|
||||||
// don't include the corners!
|
|
||||||
fLeftBorder.Set(fFrame.left - fBorderWidth, fFrame.top,
|
|
||||||
fFrame.left - 1, fFrame.bottom);
|
|
||||||
|
|
||||||
fRightBorder.Set(fFrame.right + 1, fFrame.top ,
|
|
||||||
fFrame.right + fBorderWidth, fFrame.bottom);
|
|
||||||
|
|
||||||
fTopBorder.Set(fFrame.left - fBorderWidth, fFrame.top - fBorderWidth,
|
|
||||||
fFrame.right + fBorderWidth, fFrame.top - 1);
|
|
||||||
|
|
||||||
fBottomBorder.Set(fFrame.left - fBorderWidth, fFrame.bottom + 1,
|
|
||||||
fFrame.right + fBorderWidth, fFrame.bottom + fBorderWidth);
|
|
||||||
} else {
|
|
||||||
// no border
|
|
||||||
fLeftBorder.Set(0.0, 0.0, -1.0, -1.0);
|
|
||||||
fRightBorder.Set(0.0, 0.0, -1.0, -1.0);
|
|
||||||
fTopBorder.Set(0.0, 0.0, -1.0, -1.0);
|
|
||||||
fBottomBorder.Set(0.0, 0.0, -1.0, -1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate resize rect
|
|
||||||
if (fBorderWidth > 1) {
|
|
||||||
fResizeRect.Set(fBottomBorder.right - kResizeKnobSize,
|
|
||||||
fBottomBorder.bottom - kResizeKnobSize, fBottomBorder.right,
|
|
||||||
fBottomBorder.bottom);
|
|
||||||
} else {
|
|
||||||
// no border or one pixel border (menus and such)
|
|
||||||
fResizeRect.Set(0, 0, -1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasTab) {
|
|
||||||
// make sure fTabOffset is within limits and apply it to
|
|
||||||
// the fTabRect
|
|
||||||
if (fTabOffset < 0)
|
|
||||||
fTabOffset = 0;
|
|
||||||
if (fTabLocation != 0.0
|
|
||||||
&& fTabOffset > (fRightBorder.right - fLeftBorder.left
|
|
||||||
- fTabRect.Width()))
|
|
||||||
fTabOffset = uint32(fRightBorder.right - fLeftBorder.left
|
|
||||||
- fTabRect.Width());
|
|
||||||
fTabRect.OffsetBy(fTabOffset, 0);
|
|
||||||
|
|
||||||
// finally, layout the buttons and text within the tab rect
|
|
||||||
_LayoutTabItems(fTabRect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SATDecorator::_LayoutTabItems(const BRect& tabRect)
|
|
||||||
{
|
|
||||||
float offset;
|
|
||||||
float size;
|
|
||||||
float inset;
|
|
||||||
_GetButtonSizeAndOffset(tabRect, &offset, &size, &inset);
|
|
||||||
|
|
||||||
// calulate close rect based on the tab rectangle
|
|
||||||
if (fLook != kLeftTitledWindowLook) {
|
|
||||||
fCloseRect.Set(tabRect.left + offset, tabRect.top + offset,
|
|
||||||
tabRect.left + offset + size, tabRect.top + offset + size);
|
|
||||||
|
|
||||||
fZoomRect.Set(tabRect.right - offset - size, tabRect.top + offset,
|
|
||||||
tabRect.right - offset, tabRect.top + offset + size);
|
|
||||||
|
|
||||||
// hidden buttons have no width
|
|
||||||
if ((Flags() & B_NOT_CLOSABLE) != 0)
|
|
||||||
fCloseRect.right = fCloseRect.left - offset;
|
|
||||||
if ((Flags() & B_NOT_ZOOMABLE) != 0)
|
|
||||||
fZoomRect.left = fZoomRect.right + offset;
|
|
||||||
} else {
|
|
||||||
fCloseRect.Set(tabRect.left + offset, tabRect.top + offset,
|
|
||||||
tabRect.left + offset + size, tabRect.top + offset + size);
|
|
||||||
|
|
||||||
fZoomRect.Set(tabRect.left + offset, tabRect.bottom - offset - size,
|
|
||||||
tabRect.left + size + offset, tabRect.bottom - offset);
|
|
||||||
|
|
||||||
// hidden buttons have no height
|
|
||||||
if ((Flags() & B_NOT_CLOSABLE) != 0)
|
|
||||||
fCloseRect.bottom = fCloseRect.top - offset;
|
|
||||||
if ((Flags() & B_NOT_ZOOMABLE) != 0)
|
|
||||||
fZoomRect.top = fZoomRect.bottom + offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate room for title
|
|
||||||
// TODO: the +2 is there because the title often appeared
|
|
||||||
// truncated for no apparent reason - OTOH the title does
|
|
||||||
// also not appear perfectly in the middle
|
|
||||||
if (fLook != kLeftTitledWindowLook)
|
|
||||||
size = (fZoomRect.left - fCloseRect.right) - fTextOffset * 2 + inset;
|
|
||||||
else
|
|
||||||
size = (fZoomRect.top - fCloseRect.bottom) - fTextOffset * 2 + inset;
|
|
||||||
|
|
||||||
if (fStackedMode && !fStackedDrawZoom) {
|
|
||||||
fZoomRect.Set(0, 0, 0, 0);
|
|
||||||
size = (fTabRect.right - fCloseRect.right) - fTextOffset * 2 + inset;
|
|
||||||
}
|
|
||||||
uint8 truncateMode = B_TRUNCATE_MIDDLE;
|
|
||||||
|
|
||||||
if (fStackedMode) {
|
|
||||||
if (fStackedTabLength < 100)
|
|
||||||
truncateMode = B_TRUNCATE_END;
|
|
||||||
float titleWidth = fDrawState.Font().StringWidth(Title(),
|
|
||||||
BString(Title()).Length());
|
|
||||||
if (size < titleWidth) {
|
|
||||||
float oldTextOffset = fTextOffset;
|
|
||||||
fTextOffset -= (titleWidth - size) / 2;
|
|
||||||
const float kMinTextOffset = 5.;
|
|
||||||
if (fTextOffset < kMinTextOffset)
|
|
||||||
fTextOffset = kMinTextOffset;
|
|
||||||
size += oldTextOffset * 2;
|
|
||||||
size -= fTextOffset * 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fTruncatedTitle = Title();
|
|
||||||
fDrawState.Font().TruncateString(&fTruncatedTitle, truncateMode, size);
|
|
||||||
fTruncatedTitleLength = fTruncatedTitle.Length();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
SATDecorator::_SetTabLocation(float location, BRegion* updateRegion)
|
|
||||||
{
|
|
||||||
STRACE(("DefaultDecorator: Set Tab Location(%.1f)\n", location));
|
|
||||||
if (!fTabRect.IsValid())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (location < 0)
|
|
||||||
location = 0;
|
|
||||||
|
|
||||||
float maxLocation = 0.;
|
|
||||||
if (fStackedMode)
|
|
||||||
maxLocation = fRightBorder.right - fLeftBorder.left - fStackedTabLength;
|
|
||||||
else
|
|
||||||
maxLocation = fRightBorder.right - fLeftBorder.left - fTabRect.Width();
|
|
||||||
if (location > maxLocation)
|
|
||||||
location = maxLocation;
|
|
||||||
|
|
||||||
float delta = location - fTabOffset;
|
|
||||||
if (delta == 0.0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// redraw old rect (1 pix on the border also must be updated)
|
|
||||||
BRect trect(fTabRect);
|
|
||||||
trect.bottom++;
|
|
||||||
updateRegion->Include(trect);
|
|
||||||
|
|
||||||
fTabRect.OffsetBy(delta, 0);
|
|
||||||
fTabOffset = (int32)location;
|
|
||||||
_LayoutTabItems(fTabRect);
|
|
||||||
|
|
||||||
fTabLocation = maxLocation > 0.0 ? fTabOffset / maxLocation : 0.0;
|
|
||||||
|
|
||||||
// redraw new rect as well
|
|
||||||
trect = fTabRect;
|
|
||||||
trect.bottom++;
|
|
||||||
updateRegion->Include(trect);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SATDecorator::_SetFocus()
|
|
||||||
{
|
|
||||||
DefaultDecorator::_SetFocus();
|
|
||||||
|
|
||||||
if (!fStackedMode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (IsFocus())
|
|
||||||
fStackedDrawZoom = true;
|
|
||||||
else
|
|
||||||
fStackedDrawZoom = false;
|
|
||||||
|
|
||||||
_DoLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SATDecorator::GetComponentColors(Component component, uint8 highlight,
|
SATDecorator::GetComponentColors(Component component, uint8 highlight,
|
||||||
ComponentColors _colors)
|
ComponentColors _colors, Decorator::Tab* _tab)
|
||||||
{
|
{
|
||||||
|
DefaultDecorator::Tab* tab = static_cast<DefaultDecorator::Tab*>(_tab);
|
||||||
// we handle only our own highlights
|
// we handle only our own highlights
|
||||||
if (highlight != HIGHLIGHT_STACK_AND_TILE) {
|
if (highlight != HIGHLIGHT_STACK_AND_TILE) {
|
||||||
DefaultDecorator::GetComponentColors(component, highlight, _colors);
|
DefaultDecorator::GetComponentColors(component, highlight,
|
||||||
|
_colors, tab);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tab && tab->isHighlighted == false
|
||||||
|
&& (component == COMPONENT_TAB || component == COMPONENT_CLOSE_BUTTON
|
||||||
|
|| component == COMPONENT_ZOOM_BUTTON)) {
|
||||||
|
DefaultDecorator::GetComponentColors(component, highlight,
|
||||||
|
_colors, tab);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,35 +42,10 @@ public:
|
|||||||
BRect frame, window_look look,
|
BRect frame, window_look look,
|
||||||
uint32 flags);
|
uint32 flags);
|
||||||
|
|
||||||
/*! Indicates that window is stacked */
|
|
||||||
void SetStackedMode(bool stacked, BRegion* dirty);
|
|
||||||
bool StackedMode() const
|
|
||||||
{ return fStackedMode; }
|
|
||||||
|
|
||||||
/*! Set the tab length if the decorator is in stacked mode and if
|
|
||||||
the tab is the last one in the tab bar. */
|
|
||||||
void SetStackedTabLength(float length,
|
|
||||||
BRegion* dirty);
|
|
||||||
float StackedTabLength() const
|
|
||||||
{ return fStackedTabLength; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _DoLayout();
|
|
||||||
void _LayoutTabItems(const BRect& tabRect);
|
|
||||||
|
|
||||||
bool _SetTabLocation(float location,
|
|
||||||
BRegion* updateRegion = NULL);
|
|
||||||
void _SetFocus();
|
|
||||||
|
|
||||||
virtual void DrawButtons(const BRect& invalid);
|
|
||||||
virtual void GetComponentColors(Component component,
|
virtual void GetComponentColors(Component component,
|
||||||
uint8 highlight, ComponentColors _colors);
|
uint8 highlight, ComponentColors _colors,
|
||||||
|
Decorator::Tab* tab = NULL);
|
||||||
private:
|
|
||||||
bool fStackedMode;
|
|
||||||
bool fStackedDrawZoom;
|
|
||||||
float fStackedTabLength;
|
|
||||||
bool fStackedTabShifting;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -403,15 +403,17 @@ SATWindow::StackWindow(SATWindow* child)
|
|||||||
if (!group || !area)
|
if (!group || !area)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool status = group->AddWindow(child, area, this);
|
if (group->AddWindow(child, area, this) == false)
|
||||||
|
return false;
|
||||||
if (status) {
|
|
||||||
area->WindowList().ItemAt(0)->SetStackedMode(true);
|
|
||||||
// for the case we are the first added window
|
|
||||||
child->SetStackedMode(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
DoGroupLayout();
|
DoGroupLayout();
|
||||||
|
|
||||||
|
if (fWindow->AddWindowToStack(child->GetWindow()) == false) {
|
||||||
|
group->RemoveWindow(child);
|
||||||
|
DoGroupLayout();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,6 +421,7 @@ SATWindow::StackWindow(SATWindow* child)
|
|||||||
void
|
void
|
||||||
SATWindow::RemovedFromArea(WindowArea* area)
|
SATWindow::RemovedFromArea(WindowArea* area)
|
||||||
{
|
{
|
||||||
|
fWindow->DetachFromWindowStack(true);
|
||||||
for (int i = 0; i < fSATSnappingBehaviourList.CountItems(); i++)
|
for (int i = 0; i < fSATSnappingBehaviourList.CountItems(); i++)
|
||||||
fSATSnappingBehaviourList.ItemAt(i)->RemovedFromArea(area);
|
fSATSnappingBehaviourList.ItemAt(i)->RemovedFromArea(area);
|
||||||
}
|
}
|
||||||
@@ -461,14 +464,6 @@ SATWindow::JoinCandidates()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SATWindow::DoWindowLayout()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < fSATSnappingBehaviourList.CountItems(); i++)
|
|
||||||
fSATSnappingBehaviourList.ItemAt(i)->DoWindowLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SATWindow::DoGroupLayout()
|
SATWindow::DoGroupLayout()
|
||||||
{
|
{
|
||||||
@@ -476,8 +471,6 @@ SATWindow::DoGroupLayout()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
fGroupCookie->DoGroupLayout();
|
fGroupCookie->DoGroupLayout();
|
||||||
|
|
||||||
DoWindowLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -659,15 +652,17 @@ SATWindow::HighlightTab(bool active)
|
|||||||
if (!decorator)
|
if (!decorator)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
int32 tabIndex = fWindow->PositionInStack();
|
||||||
BRegion dirty;
|
BRegion dirty;
|
||||||
uint8 highlight = active ? SATDecorator::HIGHLIGHT_STACK_AND_TILE : 0;
|
uint8 highlight = active ? SATDecorator::HIGHLIGHT_STACK_AND_TILE : 0;
|
||||||
decorator->SetRegionHighlight(SATDecorator::REGION_TAB, highlight, &dirty);
|
decorator->SetRegionHighlight(Decorator::REGION_TAB, highlight, &dirty,
|
||||||
decorator->SetRegionHighlight(SATDecorator::REGION_CLOSE_BUTTON, highlight,
|
tabIndex);
|
||||||
&dirty);
|
decorator->SetRegionHighlight(Decorator::REGION_CLOSE_BUTTON, highlight,
|
||||||
decorator->SetRegionHighlight(SATDecorator::REGION_ZOOM_BUTTON, highlight,
|
&dirty, tabIndex);
|
||||||
&dirty);
|
decorator->SetRegionHighlight(Decorator::REGION_ZOOM_BUTTON, highlight,
|
||||||
|
&dirty, tabIndex);
|
||||||
|
|
||||||
fWindow->ProcessDirtyRegion(dirty);
|
fWindow->TopLayerStackWindow()->ProcessDirtyRegion(dirty);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -688,55 +683,6 @@ SATWindow::HighlightBorders(Decorator::Region region, bool active)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
SATWindow::SetStackedMode(bool stacked)
|
|
||||||
{
|
|
||||||
SATDecorator* decorator = GetDecorator();
|
|
||||||
if (!decorator)
|
|
||||||
return false;
|
|
||||||
BRegion dirty;
|
|
||||||
decorator->SetStackedMode(stacked, &dirty);
|
|
||||||
fDesktop->RebuildAndRedrawAfterWindowChange(fWindow, dirty);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
SATWindow::SetStackedTabLength(float length)
|
|
||||||
{
|
|
||||||
SATDecorator* decorator = GetDecorator();
|
|
||||||
if (!decorator)
|
|
||||||
return false;
|
|
||||||
BRegion dirty;
|
|
||||||
decorator->SetStackedTabLength(length, &dirty);
|
|
||||||
fDesktop->RebuildAndRedrawAfterWindowChange(fWindow, dirty);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
SATWindow::SetStackedTabMoving(bool moving)
|
|
||||||
{
|
|
||||||
SATDecorator* decorator = GetDecorator();
|
|
||||||
if (!decorator)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!moving)
|
|
||||||
DoGroupLayout();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SATWindow::TabLocationMoved(float location, bool shifting)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < fSATSnappingBehaviourList.CountItems(); i++)
|
|
||||||
fSATSnappingBehaviourList.ItemAt(i)->TabLocationMoved(location,
|
|
||||||
shifting);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint64
|
uint64
|
||||||
SATWindow::Id()
|
SATWindow::Id()
|
||||||
{
|
{
|
||||||
@@ -814,7 +760,7 @@ SATWindow::_RestoreOriginalSize(bool stayBelowMouse)
|
|||||||
SATDecorator* decorator = GetDecorator();
|
SATDecorator* decorator = GetDecorator();
|
||||||
if (decorator == NULL)
|
if (decorator == NULL)
|
||||||
return;
|
return;
|
||||||
BRect tabRect = decorator->TabRect();
|
BRect tabRect = decorator->TitleBarRect();
|
||||||
if (mousePosition.y < tabRect.bottom && mousePosition.y > tabRect.top
|
if (mousePosition.y < tabRect.bottom && mousePosition.y > tabRect.top
|
||||||
&& mousePosition.x <= frame.right + decorator->BorderWidth() +1
|
&& mousePosition.x <= frame.right + decorator->BorderWidth() +1
|
||||||
&& mousePosition.x >= frame.left + decorator->BorderWidth()) {
|
&& mousePosition.x >= frame.left + decorator->BorderWidth()) {
|
||||||
|
|||||||
@@ -104,7 +104,6 @@ public:
|
|||||||
|
|
||||||
void FindSnappingCandidates();
|
void FindSnappingCandidates();
|
||||||
bool JoinCandidates();
|
bool JoinCandidates();
|
||||||
void DoWindowLayout();
|
|
||||||
void DoGroupLayout();
|
void DoGroupLayout();
|
||||||
|
|
||||||
void AdjustSizeLimits(BRect targetFrame);
|
void AdjustSizeLimits(BRect targetFrame);
|
||||||
@@ -134,11 +133,6 @@ public:
|
|||||||
bool IsTabHighlighted();
|
bool IsTabHighlighted();
|
||||||
bool IsBordersHighlighted();
|
bool IsBordersHighlighted();
|
||||||
|
|
||||||
bool SetStackedMode(bool stacked = true);
|
|
||||||
bool SetStackedTabLength(float length);
|
|
||||||
bool SetStackedTabMoving(bool moving = true);
|
|
||||||
void TabLocationMoved(float location, bool shifting);
|
|
||||||
|
|
||||||
uint64 Id();
|
uint64 Id();
|
||||||
|
|
||||||
bool SetSettings(const BMessage& message);
|
bool SetSettings(const BMessage& message);
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ StackAndTile::StackAndTile()
|
|||||||
:
|
:
|
||||||
fDesktop(NULL),
|
fDesktop(NULL),
|
||||||
fSATKeyPressed(false),
|
fSATKeyPressed(false),
|
||||||
fCurrentSATWindow(NULL),
|
fCurrentSATWindow(NULL)
|
||||||
fTabIsShifting(false)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -218,7 +217,8 @@ StackAndTile::MouseDown(Window* window, BMessage* message, const BPoint& where)
|
|||||||
if (message->FindInt32("clicks") == 2)
|
if (message->FindInt32("clicks") == 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (satWindow->GetDecorator()->RegionAt(where)) {
|
int32 tab;
|
||||||
|
switch (satWindow->GetDecorator()->RegionAt(where, tab)) {
|
||||||
case Decorator::REGION_TAB:
|
case Decorator::REGION_TAB:
|
||||||
case Decorator::REGION_LEFT_BORDER:
|
case Decorator::REGION_LEFT_BORDER:
|
||||||
case Decorator::REGION_RIGHT_BORDER:
|
case Decorator::REGION_RIGHT_BORDER:
|
||||||
@@ -247,15 +247,6 @@ StackAndTile::MouseDown(Window* window, BMessage* message, const BPoint& where)
|
|||||||
void
|
void
|
||||||
StackAndTile::MouseUp(Window* window, BMessage* message, const BPoint& where)
|
StackAndTile::MouseUp(Window* window, BMessage* message, const BPoint& where)
|
||||||
{
|
{
|
||||||
if (fTabIsShifting) {
|
|
||||||
SATWindow* satWindow = GetSATWindow(window);
|
|
||||||
if (satWindow) {
|
|
||||||
fTabIsShifting = false;
|
|
||||||
satWindow->TabLocationMoved(satWindow->GetWindow()->TabLocation(),
|
|
||||||
fTabIsShifting);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fSATKeyPressed)
|
if (fSATKeyPressed)
|
||||||
_StopSAT();
|
_StopSAT();
|
||||||
|
|
||||||
@@ -287,20 +278,8 @@ StackAndTile::WindowResized(Window* window)
|
|||||||
|
|
||||||
if (SATKeyPressed() && fCurrentSATWindow)
|
if (SATKeyPressed() && fCurrentSATWindow)
|
||||||
satWindow->FindSnappingCandidates();
|
satWindow->FindSnappingCandidates();
|
||||||
else {
|
else
|
||||||
satWindow->DoGroupLayout();
|
satWindow->DoGroupLayout();
|
||||||
|
|
||||||
// Do a window layout for all windows. TODO: maybe do it a bit more
|
|
||||||
// efficient
|
|
||||||
SATGroup* group = satWindow->GetGroup();
|
|
||||||
if (!group)
|
|
||||||
return;
|
|
||||||
for (int i = 0; i < group->CountItems(); i++) {
|
|
||||||
SATWindow* listWindow = group->WindowAt(i);
|
|
||||||
if (listWindow != satWindow)
|
|
||||||
listWindow->DoWindowLayout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -379,14 +358,10 @@ StackAndTile::WindowMinimized(Window* window, bool minimize)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
StackAndTile::WindowTabLocationChanged(Window* window, float location)
|
StackAndTile::WindowTabLocationChanged(Window* window, float location,
|
||||||
|
bool isShifting)
|
||||||
{
|
{
|
||||||
SATWindow* satWindow = GetSATWindow(window);
|
|
||||||
if (!satWindow)
|
|
||||||
return;
|
|
||||||
|
|
||||||
fTabIsShifting = true;
|
|
||||||
satWindow->TabLocationMoved(location, fTabIsShifting);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public:
|
|||||||
virtual void WindowMinimized(Window* window, bool minimize);
|
virtual void WindowMinimized(Window* window, bool minimize);
|
||||||
|
|
||||||
virtual void WindowTabLocationChanged(Window* window,
|
virtual void WindowTabLocationChanged(Window* window,
|
||||||
float location);
|
float location, bool isShifting);
|
||||||
virtual void SizeLimitsChanged(Window* window,
|
virtual void SizeLimitsChanged(Window* window,
|
||||||
int32 minWidth, int32 maxWidth,
|
int32 minWidth, int32 maxWidth,
|
||||||
int32 minHeight, int32 maxHeight);
|
int32 minHeight, int32 maxHeight);
|
||||||
@@ -107,8 +107,6 @@ private:
|
|||||||
SATWindowList fGrouplessWindows;
|
SATWindowList fGrouplessWindows;
|
||||||
|
|
||||||
SATWindow* fCurrentSATWindow;
|
SATWindow* fCurrentSATWindow;
|
||||||
|
|
||||||
bool fTabIsShifting;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -167,7 +165,6 @@ public:
|
|||||||
virtual bool JoinCandidates() = 0;
|
virtual bool JoinCandidates() = 0;
|
||||||
/*! Update the window tab values, solve the layout and move all windows in
|
/*! Update the window tab values, solve the layout and move all windows in
|
||||||
the group accordantly. */
|
the group accordantly. */
|
||||||
virtual void DoWindowLayout() = 0;
|
|
||||||
virtual void RemovedFromArea(WindowArea* area) {}
|
virtual void RemovedFromArea(WindowArea* area) {}
|
||||||
virtual void TabLocationMoved(float location, bool shifting)
|
virtual void TabLocationMoved(float location, bool shifting)
|
||||||
{}
|
{}
|
||||||
|
|||||||
@@ -227,11 +227,11 @@ SATStacking::FindSnappingCandidates(SATGroup* group)
|
|||||||
BPoint mousePosition;
|
BPoint mousePosition;
|
||||||
int32 buttons;
|
int32 buttons;
|
||||||
fSATWindow->GetDesktop()->GetLastMouseState(&mousePosition, &buttons);
|
fSATWindow->GetDesktop()->GetLastMouseState(&mousePosition, &buttons);
|
||||||
if (!window->Decorator()->TabRect().Contains(mousePosition))
|
if (!window->Decorator()->TitleBarRect().Contains(mousePosition))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// use the upper edge of the candidate window to find the parent window
|
// use the upper edge of the candidate window to find the parent window
|
||||||
mousePosition.y = window->Decorator()->TabRect().top;
|
mousePosition.y = window->Decorator()->TitleBarRect().top;
|
||||||
|
|
||||||
for (int i = 0; i < group->CountItems(); i++) {
|
for (int i = 0; i < group->CountItems(); i++) {
|
||||||
SATWindow* satWindow = group->WindowAt(i);
|
SATWindow* satWindow = group->WindowAt(i);
|
||||||
@@ -239,7 +239,10 @@ SATStacking::FindSnappingCandidates(SATGroup* group)
|
|||||||
Window* win = satWindow->GetWindow();
|
Window* win = satWindow->GetWindow();
|
||||||
if (win == window || !win->Decorator())
|
if (win == window || !win->Decorator())
|
||||||
continue;
|
continue;
|
||||||
if (win->Decorator()->TabRect().Contains(mousePosition)) {
|
Decorator::Tab* tab = win->Decorator()->TabAt(win->PositionInStack());
|
||||||
|
if (tab == NULL)
|
||||||
|
continue;
|
||||||
|
if (tab->tabRect.Contains(mousePosition)) {
|
||||||
// remember window as the parent for stacking
|
// remember window as the parent for stacking
|
||||||
fStackingParent = satWindow;
|
fStackingParent = satWindow;
|
||||||
_HighlightWindows(true);
|
_HighlightWindows(true);
|
||||||
@@ -264,64 +267,12 @@ SATStacking::JoinCandidates()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SATStacking::DoWindowLayout()
|
|
||||||
{
|
|
||||||
_AdjustWindowTabs();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SATStacking::RemovedFromArea(WindowArea* area)
|
SATStacking::RemovedFromArea(WindowArea* area)
|
||||||
{
|
{
|
||||||
const SATWindowList& list = area->WindowList();
|
const SATWindowList& list = area->WindowList();
|
||||||
if (list.CountItems() == 1)
|
if (list.CountItems() > 0)
|
||||||
list.ItemAt(0)->SetStackedMode(false);
|
|
||||||
else if (list.CountItems() > 0)
|
|
||||||
list.ItemAt(0)->DoGroupLayout();
|
list.ItemAt(0)->DoGroupLayout();
|
||||||
|
|
||||||
fSATWindow->SetStackedMode(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SATStacking::TabLocationMoved(float location, bool shifting)
|
|
||||||
{
|
|
||||||
if (!shifting) {
|
|
||||||
_AdjustWindowTabs();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SATDecorator* decorator = fSATWindow->GetDecorator();
|
|
||||||
Desktop* desktop = fSATWindow->GetWindow()->Desktop();
|
|
||||||
WindowArea* area = fSATWindow->GetWindowArea();
|
|
||||||
if (!desktop || !area || ! decorator)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const SATWindowList& stackedWindows = area->WindowList();
|
|
||||||
ASSERT(stackedWindows.CountItems() > 0);
|
|
||||||
int32 windowIndex = stackedWindows.IndexOf(fSATWindow);
|
|
||||||
ASSERT(windowIndex >= 0);
|
|
||||||
float tabLength = stackedWindows.ItemAt(0)->GetDecorator()
|
|
||||||
->StackedTabLength();
|
|
||||||
|
|
||||||
float oldTabPosition = windowIndex * (tabLength + 1);
|
|
||||||
if (fabs(oldTabPosition - location) < tabLength / 2)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int32 neighbourIndex = windowIndex;
|
|
||||||
if (oldTabPosition > location)
|
|
||||||
neighbourIndex--;
|
|
||||||
else
|
|
||||||
neighbourIndex++;
|
|
||||||
|
|
||||||
SATWindow* neighbour = stackedWindows.ItemAt(neighbourIndex);
|
|
||||||
if (!neighbour)
|
|
||||||
return;
|
|
||||||
|
|
||||||
float newNeighbourPosition = windowIndex * (tabLength + 1);
|
|
||||||
area->MoveWindowToPosition(fSATWindow, neighbourIndex);
|
|
||||||
desktop->SetWindowTabLocation(neighbour->GetWindow(), newNeighbourPosition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -345,46 +296,3 @@ SATStacking::_HighlightWindows(bool highlight)
|
|||||||
fStackingParent->HighlightTab(highlight);
|
fStackingParent->HighlightTab(highlight);
|
||||||
fSATWindow->HighlightTab(highlight);
|
fSATWindow->HighlightTab(highlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
SATStacking::_AdjustWindowTabs()
|
|
||||||
{
|
|
||||||
SATDecorator* decorator = fSATWindow->GetDecorator();
|
|
||||||
Desktop* desktop = fSATWindow->GetWindow()->Desktop();
|
|
||||||
WindowArea* area = fSATWindow->GetWindowArea();
|
|
||||||
if (!desktop || !area || ! decorator)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!decorator->StackedMode())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
BRect frame = fSATWindow->CompleteWindowFrame();
|
|
||||||
|
|
||||||
const SATWindowList& stackedWindows = area->WindowList();
|
|
||||||
|
|
||||||
int stackCount = stackedWindows.CountItems();
|
|
||||||
float titleBarLength = frame.Width();
|
|
||||||
ASSERT(titleBarLength > 0);
|
|
||||||
// floor to avoid drawing issues
|
|
||||||
float tabLength = floorf(titleBarLength / stackCount);
|
|
||||||
// the part that we lost due to the floor
|
|
||||||
float roundingError = 0;
|
|
||||||
if (tabLength > kMaxTabWidth)
|
|
||||||
tabLength = kMaxTabWidth;
|
|
||||||
else
|
|
||||||
roundingError = titleBarLength - stackCount * tabLength;
|
|
||||||
|
|
||||||
float location = 0;
|
|
||||||
for (int i = 0; i < stackCount; i++) {
|
|
||||||
SATWindow* window = stackedWindows.ItemAt(i);
|
|
||||||
if (i == stackCount - 1)
|
|
||||||
window->SetStackedTabLength(tabLength - 1 + roundingError);
|
|
||||||
else
|
|
||||||
window->SetStackedTabLength(tabLength - 1);
|
|
||||||
|
|
||||||
desktop->SetWindowTabLocation(window->GetWindow(), location);
|
|
||||||
location += tabLength;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -34,12 +34,10 @@ public:
|
|||||||
void DoWindowLayout();
|
void DoWindowLayout();
|
||||||
|
|
||||||
void RemovedFromArea(WindowArea* area);
|
void RemovedFromArea(WindowArea* area);
|
||||||
void TabLocationMoved(float location, bool shifting);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _ClearSearchResult();
|
void _ClearSearchResult();
|
||||||
void _HighlightWindows(bool highlight = true);
|
void _HighlightWindows(bool highlight = true);
|
||||||
bool _AdjustWindowTabs();
|
|
||||||
|
|
||||||
SATWindow* fSATWindow;
|
SATWindow* fSATWindow;
|
||||||
|
|
||||||
|
|||||||
@@ -78,13 +78,6 @@ SATTiling::JoinCandidates()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SATTiling::DoWindowLayout()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SATTiling::_FindFreeAreaInGroup(SATGroup* group)
|
SATTiling::_FindFreeAreaInGroup(SATGroup* group)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ public:
|
|||||||
|
|
||||||
bool FindSnappingCandidates(SATGroup* group);
|
bool FindSnappingCandidates(SATGroup* group);
|
||||||
bool JoinCandidates();
|
bool JoinCandidates();
|
||||||
void DoWindowLayout();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _FindFreeAreaInGroup(SATGroup* group);
|
bool _FindFreeAreaInGroup(SATGroup* group);
|
||||||
|
|||||||
Reference in New Issue
Block a user