Reserved space for the close and zoom buttons, even if they were absent.
Hack workaround: enlarged the text width a bit, because the title often appeared truncated for no apparent reason. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13012 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
//
|
//
|
||||||
// File Name: DefaultDecorator.cpp
|
// File Name: DefaultDecorator.cpp
|
||||||
// Author: DarkWyrm <[email protected]>
|
// Author: DarkWyrm <[email protected]>
|
||||||
// Description: Fallback decorator for the app_server
|
// Description: Default and fallback decorator for the app_server
|
||||||
//
|
//
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ DefaultDecorator::GetSizeLimits(float* minWidth, float* minHeight,
|
|||||||
float* maxWidth, float* maxHeight) const
|
float* maxWidth, float* maxHeight) const
|
||||||
{
|
{
|
||||||
if (_tabrect.IsValid())
|
if (_tabrect.IsValid())
|
||||||
*minWidth = max_c(*minWidth, fMinTabWidth - 4.0);
|
*minWidth = max_c(*minWidth, fMinTabWidth);
|
||||||
if (_resizerect.IsValid())
|
if (_resizerect.IsValid())
|
||||||
*minHeight = max_c(*minHeight, _resizerect.Height() - fBorderWidth);
|
*minHeight = max_c(*minHeight, _resizerect.Height() - fBorderWidth);
|
||||||
}
|
}
|
||||||
@@ -298,7 +298,6 @@ DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
|
|||||||
// We got this far, so user is clicking on the border?
|
// We got this far, so user is clicking on the border?
|
||||||
if (fLeftBorder.Contains(pt) || fRightBorder.Contains(pt)
|
if (fLeftBorder.Contains(pt) || fRightBorder.Contains(pt)
|
||||||
|| fTopBorder.Contains(pt) || fBottomBorder.Contains(pt)) {
|
|| fTopBorder.Contains(pt) || fBottomBorder.Contains(pt)) {
|
||||||
|
|
||||||
// check resize area
|
// check resize area
|
||||||
if (!(_flags & B_NOT_RESIZABLE) &&
|
if (!(_flags & B_NOT_RESIZABLE) &&
|
||||||
(_look == B_TITLED_WINDOW_LOOK || _look == B_FLOATING_WINDOW_LOOK)) {
|
(_look == B_TITLED_WINDOW_LOOK || _look == B_FLOATING_WINDOW_LOOK)) {
|
||||||
@@ -385,7 +384,8 @@ DefaultDecorator::_DoLayout()
|
|||||||
fMinTabWidth += offset + size;
|
fMinTabWidth += offset + size;
|
||||||
|
|
||||||
// fMaxTabWidth contains fMinWidth + the width required for the title
|
// fMaxTabWidth contains fMinWidth + the width required for the title
|
||||||
fMaxTabWidth = _driver ? _driver->StringWidth(GetTitle(), strlen(GetTitle()), &_drawdata) : 0.0;
|
fMaxTabWidth = _driver ? _driver->StringWidth(GetTitle(), strlen(GetTitle()),
|
||||||
|
&_drawdata) : 0.0;
|
||||||
if (fMaxTabWidth > 0.0)
|
if (fMaxTabWidth > 0.0)
|
||||||
fMaxTabWidth += fTextOffset;
|
fMaxTabWidth += fTextOffset;
|
||||||
fMaxTabWidth += fMinTabWidth;
|
fMaxTabWidth += fMinTabWidth;
|
||||||
@@ -399,7 +399,6 @@ DefaultDecorator::_DoLayout()
|
|||||||
// layout buttons and truncate text
|
// layout buttons and truncate text
|
||||||
_tabrect.right = _tabrect.left + tabWidth;
|
_tabrect.right = _tabrect.left + tabWidth;
|
||||||
_LayoutTabItems(_tabrect);
|
_LayoutTabItems(_tabrect);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no tab
|
// no tab
|
||||||
fMinTabWidth = 0.0;
|
fMinTabWidth = 0.0;
|
||||||
@@ -660,8 +659,8 @@ DefaultDecorator::_DrawZoom(BRect r)
|
|||||||
STRACE(("_DrawZoom(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
|
STRACE(("_DrawZoom(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
|
||||||
// If this has been implemented, then the decorator has a Zoom button
|
// If this has been implemented, then the decorator has a Zoom button
|
||||||
// which should be drawn based on the state of the member zoomstate
|
// which should be drawn based on the state of the member zoomstate
|
||||||
BRect zr( r );
|
|
||||||
|
|
||||||
|
BRect zr(r);
|
||||||
zr.left += 3.0;
|
zr.left += 3.0;
|
||||||
zr.top += 3.0;
|
zr.top += 3.0;
|
||||||
_DrawBlendedRect(zr, GetZoom());
|
_DrawBlendedRect(zr, GetZoom());
|
||||||
@@ -768,17 +767,29 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect)
|
|||||||
_GetButtonSizeAndOffset(tabRect, &offset, &size);
|
_GetButtonSizeAndOffset(tabRect, &offset, &size);
|
||||||
|
|
||||||
// calulate close rect based on the tab rectangle
|
// calulate close rect based on the tab rectangle
|
||||||
|
if (GetFlags() & B_NOT_CLOSABLE) {
|
||||||
|
_closerect.Set(tabRect.left + offset, tabRect.top + offset,
|
||||||
|
tabRect.left + offset, tabRect.top + offset + size);
|
||||||
|
} else {
|
||||||
_closerect.Set(tabRect.left + offset, tabRect.top + offset,
|
_closerect.Set(tabRect.left + offset, tabRect.top + offset,
|
||||||
tabRect.left + offset + size, tabRect.top + offset + size);
|
tabRect.left + offset + size, tabRect.top + offset + size);
|
||||||
|
}
|
||||||
|
|
||||||
// calulate zoom rect based on the tab rectangle
|
// calulate zoom rect based on the tab rectangle
|
||||||
|
if (GetFlags() & B_NOT_ZOOMABLE) {
|
||||||
|
_zoomrect.Set(tabRect.right, tabRect.top + offset,
|
||||||
|
tabRect.right, tabRect.top + offset + size);
|
||||||
|
} else {
|
||||||
_zoomrect.Set(tabRect.right - offset - size, tabRect.top + offset,
|
_zoomrect.Set(tabRect.right - offset - size, tabRect.top + offset,
|
||||||
tabRect.right - offset, tabRect.top + offset + size);
|
tabRect.right - offset, tabRect.top + offset + size);
|
||||||
|
}
|
||||||
|
|
||||||
// calculate room for title
|
// calculate room for title
|
||||||
float width = (_zoomrect.left - _closerect.right) - fTextOffset * 2.0;
|
// 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
|
||||||
|
float width = (_zoomrect.left - _closerect.right) - fTextOffset * 2 + 2;
|
||||||
fTruncatedTitle = GetTitle();
|
fTruncatedTitle = GetTitle();
|
||||||
_drawdata.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, width);
|
_drawdata.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, width);
|
||||||
// _drawdata.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_BEGINNING, width);
|
fTruncatedTitleLength = fTruncatedTitle.Length();
|
||||||
fTruncatedTitleLength = strlen(fTruncatedTitle.String());
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user