- 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
This commit is contained in:
Clemens Zeidler 2010-08-31 05:36:09 +00:00
parent fef53dfffd
commit 26152d9e07
3 changed files with 66 additions and 7 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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();