All controls/views now accept NULL arguments for "width" and "height" in GetPreferredSize().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15091 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+19
-11
@@ -328,24 +328,27 @@ BBox::ResizeToPreferred()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BBox::GetPreferredSize(float *width, float *height)
|
BBox::GetPreferredSize(float *_width, float *_height)
|
||||||
{
|
{
|
||||||
|
float width, height;
|
||||||
bool label = true;
|
bool label = true;
|
||||||
|
|
||||||
// acount for label
|
// acount for label
|
||||||
if (fLabelView) {
|
if (fLabelView) {
|
||||||
fLabelView->GetPreferredSize(width, height);
|
fLabelView->GetPreferredSize(&width, &height);
|
||||||
*width += 10.0;
|
width += 10.0;
|
||||||
// the label view is placed 10 pixels from the left
|
// the label view is placed 10 pixels from the left
|
||||||
} else if (fLabel) {
|
} else if (fLabel) {
|
||||||
font_height fh;
|
font_height fh;
|
||||||
GetFontHeight(&fh);
|
GetFontHeight(&fh);
|
||||||
*width += ceilf(StringWidth(fLabel));
|
width += ceilf(StringWidth(fLabel));
|
||||||
*height += ceilf(fh.ascent + fh.descent);
|
height += ceilf(fh.ascent + fh.descent);
|
||||||
} else {
|
} else {
|
||||||
label = false;
|
label = false;
|
||||||
*width = 0;
|
width = 0;
|
||||||
*height = 0;
|
height = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// acount for border
|
// acount for border
|
||||||
switch (fStyle) {
|
switch (fStyle) {
|
||||||
case B_NO_BORDER:
|
case B_NO_BORDER:
|
||||||
@@ -353,23 +356,28 @@ BBox::GetPreferredSize(float *width, float *height)
|
|||||||
case B_PLAIN_BORDER:
|
case B_PLAIN_BORDER:
|
||||||
// label: (1 pixel for border + 1 pixel for padding) * 2
|
// label: (1 pixel for border + 1 pixel for padding) * 2
|
||||||
// no label: (1 pixel for border) * 2 + 1 pixel for padding
|
// no label: (1 pixel for border) * 2 + 1 pixel for padding
|
||||||
*width += label ? 4 : 3;
|
width += label ? 4 : 3;
|
||||||
// label: 1 pixel for bottom border + 1 pixel for padding
|
// label: 1 pixel for bottom border + 1 pixel for padding
|
||||||
// no label: (1 pixel for border) * 2 + 1 pixel for padding
|
// no label: (1 pixel for border) * 2 + 1 pixel for padding
|
||||||
*height += label ? 2 : 3;
|
height += label ? 2 : 3;
|
||||||
break;
|
break;
|
||||||
case B_FANCY_BORDER:
|
case B_FANCY_BORDER:
|
||||||
// label: (2 pixel for border + 1 pixel for padding) * 2
|
// label: (2 pixel for border + 1 pixel for padding) * 2
|
||||||
// no label: (2 pixel for border) * 2 + 1 pixel for padding
|
// no label: (2 pixel for border) * 2 + 1 pixel for padding
|
||||||
*width += label ? 6 : 5;
|
width += label ? 6 : 5;
|
||||||
// label: 2 pixel for bottom border + 1 pixel for padding
|
// label: 2 pixel for bottom border + 1 pixel for padding
|
||||||
// no label: (2 pixel for border) * 2 + 1 pixel for padding
|
// no label: (2 pixel for border) * 2 + 1 pixel for padding
|
||||||
*height += label ? 3 : 5;
|
height += label ? 3 : 5;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// NOTE: children are ignored, you can use BBox::GetPreferredSize()
|
// NOTE: children are ignored, you can use BBox::GetPreferredSize()
|
||||||
// to get the minimum size of this object, then add the size
|
// to get the minimum size of this object, then add the size
|
||||||
// of your child(ren) plus inner padding for the final size
|
// of your child(ren) plus inner padding for the final size
|
||||||
|
|
||||||
|
if (_width)
|
||||||
|
*_width = width;
|
||||||
|
if (_height)
|
||||||
|
*_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -357,18 +357,22 @@ BCheckBox::SetValue(int32 value)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BCheckBox::GetPreferredSize(float *width, float *height)
|
BCheckBox::GetPreferredSize(float* _width, float* _height)
|
||||||
{
|
{
|
||||||
font_height fh;
|
font_height fontHeight;
|
||||||
GetFontHeight(&fh);
|
GetFontHeight(&fontHeight);
|
||||||
|
|
||||||
*height = (float)ceil(6.0f + fh.ascent + fh.descent);
|
if (_width) {
|
||||||
*width = 12.0f + fh.ascent;
|
float width = 12.0f + fontHeight.ascent;
|
||||||
|
|
||||||
if (Label())
|
|
||||||
*width += StringWidth(Label());
|
|
||||||
|
|
||||||
*width = (float)ceil(*width);
|
if (Label())
|
||||||
|
width += StringWidth(Label());
|
||||||
|
|
||||||
|
*_width = (float)ceil(width);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_height)
|
||||||
|
*_height = (float)ceil(6.0f + fontHeight.ascent + fontHeight.descent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+15
-11
@@ -1333,18 +1333,22 @@ BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is for BMenuBar.
|
// This is for BMenuBar
|
||||||
if ((ResizingMode() & B_FOLLOW_LEFT_RIGHT) == B_FOLLOW_LEFT_RIGHT) {
|
|
||||||
if (Parent())
|
|
||||||
*_width = Parent()->Frame().Width() + 1;
|
|
||||||
else if (Window())
|
|
||||||
*_width = Window()->Frame().Width() + 1;
|
|
||||||
else
|
|
||||||
*_width = Bounds().Width();
|
|
||||||
} else
|
|
||||||
*_width = frame.Width();
|
|
||||||
|
|
||||||
*_height = frame.Height();
|
if (_width) {
|
||||||
|
if ((ResizingMode() & B_FOLLOW_LEFT_RIGHT) == B_FOLLOW_LEFT_RIGHT) {
|
||||||
|
if (Parent())
|
||||||
|
*_width = Parent()->Frame().Width() + 1;
|
||||||
|
else if (Window())
|
||||||
|
*_width = Window()->Frame().Width() + 1;
|
||||||
|
else
|
||||||
|
*_width = Bounds().Width();
|
||||||
|
} else
|
||||||
|
*_width = frame.Width();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_height)
|
||||||
|
*_height = frame.Height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ BMenuField::GetPreferredSize(float *_width, float *_height)
|
|||||||
{
|
{
|
||||||
BView::GetPreferredSize(_width, _height);
|
BView::GetPreferredSize(_width, _height);
|
||||||
|
|
||||||
if (!fFixedSizeMB) {
|
if (!fFixedSizeMB && _width != NULL) {
|
||||||
BMenu* menu = Menu();
|
BMenu* menu = Menu();
|
||||||
float width = 0;
|
float width = 0;
|
||||||
|
|
||||||
@@ -507,13 +507,15 @@ BMenuField::GetPreferredSize(float *_width, float *_height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: fix these values (they should match the visual appearance)
|
// TODO: fix these values (they should match the visual appearance)
|
||||||
*_width = width + 45 + fDivider;
|
width += 45 + fDivider;
|
||||||
|
|
||||||
if (Label())
|
if (Label())
|
||||||
*_width += StringWidth(Label()) + 5;
|
width += StringWidth(Label()) + 5;
|
||||||
|
|
||||||
|
*_width = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
*_height = fMenuBar->Bounds().Height();
|
if (_height)
|
||||||
|
*_height = fMenuBar->Bounds().Height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,19 @@
|
|||||||
//-----------------------------------------------------------------------------
|
/*
|
||||||
// Copyright (c) 2003-2004 Haiku
|
* Copyright 2003-2005, Haiku, Inc.
|
||||||
//
|
* Distributed under the terms of the MIT license.
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
*
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
* Authors:
|
||||||
// to deal in the Software without restriction, including without limitation
|
* Stefano Ceccherini (burton666@libero.it)
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
*/
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// File Name: OptionPopUp.cpp
|
|
||||||
// Author: Stefano Ceccherini ([email protected])
|
|
||||||
// Description: An option like control.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <OptionPopUp.h>
|
#include <OptionPopUp.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
|
|
||||||
#include <cstdio>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
// If enabled, behaves like in BeOS R5, in that when you call
|
// If enabled, behaves like in BeOS R5, in that when you call
|
||||||
// SelectOptionFor() or SetValue(), the selected item isn't marked, and
|
// SelectOptionFor() or SetValue(), the selected item isn't marked, and
|
||||||
@@ -49,9 +34,8 @@ const float kHeightModifier = 10.0;
|
|||||||
\param flags View flags. They will be passed to the base class.
|
\param flags View flags. They will be passed to the base class.
|
||||||
*/
|
*/
|
||||||
BOptionPopUp::BOptionPopUp(BRect frame, const char *name, const char *label,
|
BOptionPopUp::BOptionPopUp(BRect frame, const char *name, const char *label,
|
||||||
BMessage *message, uint32 resize, uint32 flags)
|
BMessage *message, uint32 resize, uint32 flags)
|
||||||
:
|
: BOptionControl(frame, name, label, message, resize, flags)
|
||||||
BOptionControl(frame, name, label, message, resize, flags)
|
|
||||||
{
|
{
|
||||||
BPopUpMenu *popUp = new BPopUpMenu(label, true, true);
|
BPopUpMenu *popUp = new BPopUpMenu(label, true, true);
|
||||||
_mField = new BMenuField(Bounds(), "_menu", label, popUp);
|
_mField = new BMenuField(Bounds(), "_menu", label, popUp);
|
||||||
@@ -70,9 +54,8 @@ BOptionPopUp::BOptionPopUp(BRect frame, const char *name, const char *label,
|
|||||||
\param flags View flags. They will be passed to the base class.
|
\param flags View flags. They will be passed to the base class.
|
||||||
*/
|
*/
|
||||||
BOptionPopUp::BOptionPopUp(BRect frame, const char *name, const char *label,
|
BOptionPopUp::BOptionPopUp(BRect frame, const char *name, const char *label,
|
||||||
BMessage *message, bool fixed, uint32 resize, uint32 flags)
|
BMessage *message, bool fixed, uint32 resize, uint32 flags)
|
||||||
:
|
: BOptionControl(frame, name, label, message, resize, flags)
|
||||||
BOptionControl(frame, name, label, message, resize, flags)
|
|
||||||
{
|
{
|
||||||
BPopUpMenu *popUp = new BPopUpMenu(label, true, true);
|
BPopUpMenu *popUp = new BPopUpMenu(label, true, true);
|
||||||
_mField = new BMenuField(Bounds(), "_menu", label, popUp, fixed);
|
_mField = new BMenuField(Bounds(), "_menu", label, popUp, fixed);
|
||||||
@@ -80,9 +63,6 @@ BOptionPopUp::BOptionPopUp(BRect frame, const char *name, const char *label,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Frees the allocated resources.
|
|
||||||
It does nothing.
|
|
||||||
*/
|
|
||||||
BOptionPopUp::~BOptionPopUp()
|
BOptionPopUp::~BOptionPopUp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -112,7 +92,7 @@ BOptionPopUp::GetOptionAt(int32 index, const char **outName, int32 *outValue)
|
|||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
BMenu *menu = _mField->Menu();
|
BMenu *menu = _mField->Menu();
|
||||||
|
|
||||||
if (menu != NULL) {
|
if (menu != NULL) {
|
||||||
BMenuItem *item = menu->ItemAt(index);
|
BMenuItem *item = menu->ItemAt(index);
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
@@ -124,7 +104,7 @@ BOptionPopUp::GetOptionAt(int32 index, const char **outName, int32 *outValue)
|
|||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,36 +260,38 @@ BOptionPopUp::SetEnabled(bool state)
|
|||||||
preferred height.
|
preferred height.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
BOptionPopUp::GetPreferredSize(float *width, float *height)
|
BOptionPopUp::GetPreferredSize(float* _width, float* _height)
|
||||||
{
|
{
|
||||||
// Calculate control's height, looking at the BMenuField font's height
|
// Calculate control's height, looking at the BMenuField font's height
|
||||||
font_height fontHeight;
|
if (_height != NULL) {
|
||||||
_mField->GetFontHeight(&fontHeight);
|
font_height fontHeight;
|
||||||
|
_mField->GetFontHeight(&fontHeight);
|
||||||
if (height != NULL)
|
|
||||||
*height = fontHeight.ascent + fontHeight.descent +
|
*_height = fontHeight.ascent + fontHeight.descent
|
||||||
fontHeight.leading + kHeightModifier;
|
+ fontHeight.leading + kHeightModifier;
|
||||||
|
}
|
||||||
float maxWidth = 0;
|
|
||||||
BMenu *menu = _mField->Menu();
|
if (_width != NULL) {
|
||||||
if (menu == NULL)
|
float maxWidth = 0;
|
||||||
return;
|
BMenu *menu = _mField->Menu();
|
||||||
|
if (menu == NULL)
|
||||||
// Iterate over all the entries in the control,
|
return;
|
||||||
// and take the maximum width.
|
|
||||||
// TODO: Should we call BMenuField::GetPreferredSize() instead ?
|
// Iterate over all the entries in the control,
|
||||||
int32 numItems = menu->CountItems();
|
// and take the maximum width.
|
||||||
for (int32 i = 0; i < numItems; i++) {
|
// TODO: Should we call BMenuField::GetPreferredSize() instead ?
|
||||||
BMenuItem *item = menu->ItemAt(i);
|
int32 numItems = menu->CountItems();
|
||||||
if (item != NULL) {
|
for (int32 i = 0; i < numItems; i++) {
|
||||||
float stringWidth = menu->StringWidth(item->Label());
|
BMenuItem *item = menu->ItemAt(i);
|
||||||
maxWidth = max_c(maxWidth, stringWidth);
|
if (item != NULL) {
|
||||||
}
|
float stringWidth = menu->StringWidth(item->Label());
|
||||||
|
maxWidth = max_c(maxWidth, stringWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
maxWidth += _mField->StringWidth(BControl::Label()) + kLabelSpace + kWidthModifier;
|
||||||
|
*_width = maxWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
maxWidth += _mField->StringWidth(BControl::Label()) + kLabelSpace + kWidthModifier;
|
|
||||||
if (width != NULL)
|
|
||||||
*width = maxWidth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
* Authors:
|
* Authors:
|
||||||
* Marc Flerackers (mflerackers@androme.be)
|
* Marc Flerackers (mflerackers@androme.be)
|
||||||
* Stephan Aßmus <superstippi@gmx.de>
|
* Stephan Aßmus <superstippi@gmx.de>
|
||||||
*
|
*/
|
||||||
* Description:
|
|
||||||
* BRadioButton represents a single on/off button.
|
/** BRadioButton represents a single on/off button.
|
||||||
* All sibling BRadioButton objects comprise a single
|
* All sibling BRadioButton objects comprise a single
|
||||||
* "multiple choice" control.
|
* "multiple choice" control.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
@@ -318,18 +318,23 @@ BRadioButton::SetValue(int32 value)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BRadioButton::GetPreferredSize(float *width, float *height)
|
BRadioButton::GetPreferredSize(float* _width, float* _height)
|
||||||
{
|
{
|
||||||
font_height fh;
|
if (_width) {
|
||||||
GetFontHeight(&fh);
|
float width = 22.0f; // TODO: check if ascent is included
|
||||||
|
|
||||||
*height = (float)ceil(fh.ascent + fh.descent) + 6.0f;
|
if (Label())
|
||||||
*width = 22.0f; // TODO: check if ascent is included
|
width += StringWidth(Label());
|
||||||
|
|
||||||
if (Label())
|
*_width = (float)ceil(width);
|
||||||
*width += StringWidth(Label());
|
}
|
||||||
|
|
||||||
*width = (float)ceil(*width);
|
if (_height) {
|
||||||
|
font_height fontHeight;
|
||||||
|
GetFontHeight(&fontHeight);
|
||||||
|
|
||||||
|
*_height = (float)ceil(fontHeight.ascent + fontHeight.descent) + 6.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -896,14 +896,18 @@ BScrollBar::ResizeToPreferred()
|
|||||||
|
|
||||||
// GetPreferredSize
|
// GetPreferredSize
|
||||||
void
|
void
|
||||||
BScrollBar::GetPreferredSize(float *width, float *height)
|
BScrollBar::GetPreferredSize(float* _width, float* _height)
|
||||||
{
|
{
|
||||||
if (fOrientation == B_VERTICAL) {
|
if (fOrientation == B_VERTICAL) {
|
||||||
*width = B_V_SCROLL_BAR_WIDTH;
|
if (_width)
|
||||||
*height = Bounds().Height();
|
*_width = B_V_SCROLL_BAR_WIDTH;
|
||||||
|
if (_height)
|
||||||
|
*_height = Bounds().Height();
|
||||||
} else if (fOrientation == B_HORIZONTAL) {
|
} else if (fOrientation == B_HORIZONTAL) {
|
||||||
*width = Bounds().Width();
|
if (_width)
|
||||||
*height = B_H_SCROLL_BAR_HEIGHT;
|
*_width = Bounds().Width();
|
||||||
|
if (_height)
|
||||||
|
*_height = B_H_SCROLL_BAR_HEIGHT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1152,11 +1152,12 @@ BSlider::GetPreferredSize(float* _width, float* _height)
|
|||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
GetFontHeight(&fontHeight);
|
GetFontHeight(&fontHeight);
|
||||||
|
|
||||||
|
float width, height;
|
||||||
int32 rows = 0;
|
int32 rows = 0;
|
||||||
|
|
||||||
if (Orientation() == B_HORIZONTAL) {
|
if (Orientation() == B_HORIZONTAL) {
|
||||||
*_width = Frame().Width();
|
width = Frame().Width();
|
||||||
*_height = 12.0f + fBarThickness;
|
height = 12.0f + fBarThickness;
|
||||||
|
|
||||||
float labelWidth = 0;
|
float labelWidth = 0;
|
||||||
if (Label()) {
|
if (Label()) {
|
||||||
@@ -1175,21 +1176,21 @@ BSlider::GetPreferredSize(float* _width, float* _height)
|
|||||||
minWidth += StringWidth(MaxLimitLabel());
|
minWidth += StringWidth(MaxLimitLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minWidth > *_width)
|
if (minWidth > width)
|
||||||
*_width = minWidth;
|
width = minWidth;
|
||||||
if (labelWidth > *_width)
|
if (labelWidth > width)
|
||||||
*_width = labelWidth;
|
width = labelWidth;
|
||||||
if (*_width < 32.0f)
|
if (width < 32.0f)
|
||||||
*_width = 32.0f;
|
width = 32.0f;
|
||||||
|
|
||||||
if (MinLimitLabel() || MaxLimitLabel())
|
if (MinLimitLabel() || MaxLimitLabel())
|
||||||
rows++;
|
rows++;
|
||||||
|
|
||||||
*_height += rows * ((float)ceil(fontHeight.ascent + fontHeight.descent) + 4.0f);
|
height += rows * ((float)ceil(fontHeight.ascent + fontHeight.descent) + 4.0f);
|
||||||
} else {
|
} else {
|
||||||
// B_VERTICAL
|
// B_VERTICAL
|
||||||
*_width = 12.0f + fBarThickness;
|
width = 12.0f + fBarThickness;
|
||||||
*_height = Frame().Height();
|
height = Frame().Height();
|
||||||
|
|
||||||
// find largest label
|
// find largest label
|
||||||
|
|
||||||
@@ -1211,8 +1212,8 @@ BSlider::GetPreferredSize(float* _width, float* _height)
|
|||||||
rows++;
|
rows++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minWidth > *_width)
|
if (minWidth > width)
|
||||||
*_width = minWidth;
|
width = minWidth;
|
||||||
|
|
||||||
float minHeight = 32.0f + rows
|
float minHeight = 32.0f + rows
|
||||||
* ((float)ceil(fontHeight.ascent + fontHeight.descent) + 4.0f);
|
* ((float)ceil(fontHeight.ascent + fontHeight.descent) + 4.0f);
|
||||||
@@ -1220,9 +1221,14 @@ BSlider::GetPreferredSize(float* _width, float* _height)
|
|||||||
if (Label() && MaxLimitLabel())
|
if (Label() && MaxLimitLabel())
|
||||||
minHeight -= 4.0f;
|
minHeight -= 4.0f;
|
||||||
|
|
||||||
if (minHeight > *_height)
|
if (minHeight > height)
|
||||||
*_height = minHeight;
|
height = minHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_width)
|
||||||
|
*_width = width;
|
||||||
|
if (_height)
|
||||||
|
*_height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -533,15 +533,20 @@ BStatusBar::ResizeToPreferred()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BStatusBar::GetPreferredSize(float *width, float *height)
|
BStatusBar::GetPreferredSize(float* _width, float* _height)
|
||||||
{
|
{
|
||||||
font_height fh;
|
if (_width) {
|
||||||
GetFontHeight(&fh);
|
*_width = (fLabel ? (float)ceil(StringWidth(fLabel)) : 0.0f)
|
||||||
|
+ (fTrailingLabel ? (float)ceil(StringWidth(fTrailingLabel)) : 0.0f)
|
||||||
*width = (fLabel ? (float)ceil(StringWidth(fLabel)) : 0.0f) +
|
+ 7.0f;
|
||||||
(fTrailingLabel ? (float)ceil(StringWidth(fTrailingLabel)) : 0.0f) +
|
}
|
||||||
7.0f;
|
|
||||||
*height = fh.ascent + fh.descent + 5.0f + BarHeight();
|
if (_height) {
|
||||||
|
font_height fontHeight;
|
||||||
|
GetFontHeight(&fontHeight);
|
||||||
|
|
||||||
|
*_height = ceil(fontHeight.ascent + fontHeight.descent) + 5.0f + BarHeight();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user