* Make a BStatusBar comfortable to use without any text labels.
* In SetBarHeight(), use InvalidateLayout() when used with layout management. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35418 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -98,6 +98,7 @@ private:
|
|||||||
BRect _BarFrame(const font_height* fontHeight
|
BRect _BarFrame(const font_height* fontHeight
|
||||||
= NULL) const;
|
= NULL) const;
|
||||||
float _BarPosition(const BRect& barFrame) const;
|
float _BarPosition(const BRect& barFrame) const;
|
||||||
|
bool _HasText() const;
|
||||||
|
|
||||||
BString fLabel;
|
BString fLabel;
|
||||||
BString fTrailingLabel;
|
BString fTrailingLabel;
|
||||||
|
|||||||
@@ -207,11 +207,14 @@ BStatusBar::GetPreferredSize(float* _width, float* _height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_height) {
|
if (_height) {
|
||||||
font_height fontHeight;
|
float labelHeight = 0;
|
||||||
GetFontHeight(&fontHeight);
|
if (_HasText()) {
|
||||||
|
font_height fontHeight;
|
||||||
|
GetFontHeight(&fontHeight);
|
||||||
|
labelHeight = ceilf(fontHeight.ascent + fontHeight.descent) + 6;
|
||||||
|
}
|
||||||
|
|
||||||
*_height = ceilf(fontHeight.ascent + fontHeight.descent) + 6
|
*_height = labelHeight + BarHeight();
|
||||||
+ BarHeight();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,9 +478,13 @@ BStatusBar::SetBarHeight(float barHeight)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// resize so that the height fits
|
// resize so that the height fits
|
||||||
float width, height;
|
if ((Flags() & B_SUPPORTS_LAYOUT) != 0) {
|
||||||
GetPreferredSize(&width, &height);
|
InvalidateLayout();
|
||||||
ResizeTo(Bounds().Width(), height);
|
} else {
|
||||||
|
float width, height;
|
||||||
|
GetPreferredSize(&width, &height);
|
||||||
|
ResizeTo(Bounds().Width(), height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -813,13 +820,15 @@ BStatusBar::_SetTextData(BString& text, const char* source,
|
|||||||
BRect
|
BRect
|
||||||
BStatusBar::_BarFrame(const font_height* fontHeight) const
|
BStatusBar::_BarFrame(const font_height* fontHeight) const
|
||||||
{
|
{
|
||||||
float top;
|
float top = 2;
|
||||||
if (fontHeight == NULL) {
|
if (_HasText()) {
|
||||||
font_height height;
|
if (fontHeight == NULL) {
|
||||||
GetFontHeight(&height);
|
font_height height;
|
||||||
top = ceilf(height.ascent + height.descent) + 6;
|
GetFontHeight(&height);
|
||||||
} else
|
top = ceilf(height.ascent + height.descent) + 6;
|
||||||
top = ceilf(fontHeight->ascent + fontHeight->descent) + 6;
|
} else
|
||||||
|
top = ceilf(fontHeight->ascent + fontHeight->descent) + 6;
|
||||||
|
}
|
||||||
|
|
||||||
return BRect(2, top, Bounds().right - 2, top + BarHeight() - 4);
|
return BRect(2, top, Bounds().right - 2, top + BarHeight() - 4);
|
||||||
}
|
}
|
||||||
@@ -835,3 +844,10 @@ BStatusBar::_BarPosition(const BRect& barFrame) const
|
|||||||
+ (fCurrent * (barFrame.Width() + 3) / fMax));
|
+ (fCurrent * (barFrame.Width() + 3) / fMax));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BStatusBar::_HasText() const
|
||||||
|
{
|
||||||
|
return fLabel.Length() > 0 || fTrailingLabel.Length() > 0
|
||||||
|
|| fTrailingText.Length() > 0 || fText.Length() > 0;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user