From 26152d9e07318d90c50694f580f732f65a2af475 Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Tue, 31 Aug 2010 05:36:09 +0000 Subject: [PATCH] - Increase max size for stacked tabs. - Use more title space in stacked tabs. - Fix tab movement in stacked mode. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38475 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../decorators/SATDecorator/SATDecorator.cpp | 66 +++++++++++++++++-- .../decorators/SATDecorator/SATDecorator.h | 2 + .../decorators/SATDecorator/Stacking.cpp | 5 +- 3 files changed, 66 insertions(+), 7 deletions(-) diff --git a/src/add-ons/decorators/SATDecorator/SATDecorator.cpp b/src/add-ons/decorators/SATDecorator/SATDecorator.cpp index 281544dda3..0cd4c58b4a 100644 --- a/src/add-ons/decorators/SATDecorator/SATDecorator.cpp +++ b/src/add-ons/decorators/SATDecorator/SATDecorator.cpp @@ -218,10 +218,7 @@ SATDecorator::_DoLayout() if (hasTab) { // distance from one item of the tab bar to another. // In this case the text and close/zoom rects - if (fStackedMode && false) - fTextOffset = 5; - else - fTextOffset = (fLook == B_FLOATING_WINDOW_LOOK + fTextOffset = (fLook == B_FLOATING_WINDOW_LOOK || fLook == kLeftTitledWindowLook) ? 10 : 18; font_height fontHeight; @@ -396,8 +393,26 @@ SATDecorator::_LayoutTabItems(const BRect& tabRect) fZoomRect.Set(0, 0, 0, 0); size = (fTabRect.right - fCloseRect.right) - fTextOffset * 2 + inset; } + uint8 truncateMode = B_TRUNCATE_MIDDLE; + if (fStackedMode) + truncateMode = B_TRUNCATE_END; + + if (fStackedMode) { + 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, B_TRUNCATE_MIDDLE, size); + fDrawState.Font().TruncateString(&fTruncatedTitle, truncateMode, size); fTruncatedTitleLength = fTruncatedTitle.Length(); } @@ -475,6 +490,47 @@ SATDecorator::_DrawTab(BRect invalid) } +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; +} + + extern "C" DecorAddOn* (instantiate_decor_addon)(image_id id, const char* name) { return new (std::nothrow)SATDecorAddOn(id, name); diff --git a/src/add-ons/decorators/SATDecorator/SATDecorator.h b/src/add-ons/decorators/SATDecorator/SATDecorator.h index 47b749e9a8..511c231e72 100644 --- a/src/add-ons/decorators/SATDecorator/SATDecorator.h +++ b/src/add-ons/decorators/SATDecorator/SATDecorator.h @@ -56,6 +56,8 @@ protected: void _DrawTab(BRect r); void _LayoutTabItems(const BRect& tabRect); + bool _SetTabLocation(float location, + BRegion* updateRegion = NULL); private: bool fTabHighlighted; bool fBordersHighlighted; diff --git a/src/add-ons/decorators/SATDecorator/Stacking.cpp b/src/add-ons/decorators/SATDecorator/Stacking.cpp index 0c95817a43..87e8426de3 100644 --- a/src/add-ons/decorators/SATDecorator/Stacking.cpp +++ b/src/add-ons/decorators/SATDecorator/Stacking.cpp @@ -28,6 +28,9 @@ using namespace BPrivate; +const float kMaxTabWidth = 135.; + + bool StackingEventHandler::HandleMessage(SATWindow* sender, BPrivate::ServerLink& link) @@ -358,8 +361,6 @@ SATStacking::_AdjustWindowTabs() BRect frame = fSATWindow->CompleteWindowFrame(); - const float kMaxTabWidth = 120.; - const SATWindowList& stackedWindows = area->WindowList(); float zoomOffset = decorator->GetZoomOffsetToRight();