Fixed the problem that icon buttons are too small when creating new ones.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28667 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2008-11-16 22:14:10 +00:00
parent f1d4302878
commit 34ef8378c5
2 changed files with 42 additions and 0 deletions

View File

@ -239,6 +239,44 @@ LaunchButton::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessa
IconButton::MouseMoved(where, transit, dragMessage);
}
BSize
LaunchButton::MinSize()
{
return PreferredSize();
}
BSize
LaunchButton::PreferredSize()
{
float minWidth = fIconSize;
float minHeight = fIconSize;
float hPadding = max_c(4.0, ceilf(minHeight / 4.0));
float vPadding = max_c(4.0, ceilf(minWidth / 4.0));
if (fLabel.CountChars() > 0) {
font_height fh;
GetFontHeight(&fh);
minHeight += ceilf(fh.ascent + fh.descent) + vPadding;
minWidth += StringWidth(fLabel.String()) + vPadding;
}
return BSize(minWidth + hPadding, minHeight + vPadding);
}
BSize
LaunchButton::MaxSize()
{
return PreferredSize();
}
// #pragma mark -
// SetTo
void
LaunchButton::SetTo(const entry_ref* ref)

View File

@ -40,6 +40,10 @@ class LaunchButton : public IconButton {
virtual void MouseMoved(BPoint where, uint32 transit,
const BMessage* dragMessage);
virtual BSize MinSize();
virtual BSize PreferredSize();
virtual BSize MaxSize();
// LaunchButton
void SetTo(const entry_ref* ref);
entry_ref* Ref() const;