Interface Kit: Adjust max size and default alignment...

...on controls where it makes sense:
- BRadioButton and BCheckBox now return their preferred size as their
maximum.
- BRadioButton, BCheckBox and BTextControl now use left alignment by
default, as this is the most common use case for them.
This commit is contained in:
Rene Gollent
2013-07-01 11:30:49 -04:00
parent 621ae6bd72
commit 46d6e9d9ed
6 changed files with 33 additions and 5 deletions
+3 -2
View File
@@ -17,9 +17,9 @@ public:
uint32 flags = B_WILL_DRAW | B_NAVIGABLE); uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BCheckBox(const char* name, const char* label, BCheckBox(const char* name, const char* label,
BMessage* message, uint32 flags BMessage* message, uint32 flags
= B_WILL_DRAW | B_NAVIGABLE); = B_WILL_DRAW | B_NAVIGABLE);
BCheckBox(const char* label, BCheckBox(const char* label,
BMessage* message = NULL); BMessage* message = NULL);
BCheckBox(BMessage* archive); BCheckBox(BMessage* archive);
virtual ~BCheckBox(); virtual ~BCheckBox();
@@ -55,6 +55,7 @@ public:
virtual BSize MinSize(); virtual BSize MinSize();
virtual BSize MaxSize(); virtual BSize MaxSize();
virtual BSize PreferredSize(); virtual BSize PreferredSize();
virtual BAlignment LayoutAlignment();
virtual void MakeFocus(bool focused = true); virtual void MakeFocus(bool focused = true);
+1 -1
View File
@@ -61,7 +61,7 @@ public:
virtual status_t Perform(perform_code d, void* argument); virtual status_t Perform(perform_code d, void* argument);
virtual BSize MaxSize(); virtual BSize MaxSize();
virtual BAlignment LayoutAlignment();
private: private:
friend status_t _init_interface_kit_(); friend status_t _init_interface_kit_();
+1
View File
@@ -86,6 +86,7 @@ public:
virtual BSize MinSize(); virtual BSize MinSize();
virtual BSize MaxSize(); virtual BSize MaxSize();
virtual BSize PreferredSize(); virtual BSize PreferredSize();
virtual BAlignment LayoutAlignment();
BLayoutItem* CreateLabelLayoutItem(); BLayoutItem* CreateLabelLayoutItem();
BLayoutItem* CreateTextViewLayoutItem(); BLayoutItem* CreateTextViewLayoutItem();
+9 -1
View File
@@ -452,7 +452,7 @@ BSize
BCheckBox::MaxSize() BCheckBox::MaxSize()
{ {
return BLayoutUtils::ComposeSize(ExplicitMaxSize(), return BLayoutUtils::ComposeSize(ExplicitMaxSize(),
BSize(B_SIZE_UNLIMITED, _ValidatePreferredSize().height)); _ValidatePreferredSize());
} }
@@ -464,6 +464,14 @@ BCheckBox::PreferredSize()
} }
BAlignment
BCheckBox::LayoutAlignment()
{
return BLayoutUtils::ComposeAlignment(ExplicitAlignment(),
BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET));
}
// #pragma mark - // #pragma mark -
+8 -1
View File
@@ -566,10 +566,17 @@ BRadioButton::MaxSize()
GetPreferredSize(&width, &height); GetPreferredSize(&width, &height);
return BLayoutUtils::ComposeSize(ExplicitMaxSize(), return BLayoutUtils::ComposeSize(ExplicitMaxSize(),
BSize(B_SIZE_UNLIMITED, height)); BSize(width, height));
} }
BAlignment
BRadioButton::LayoutAlignment()
{
return BLayoutUtils::ComposeAlignment(ExplicitAlignment(),
BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET));
}
void BRadioButton::_ReservedRadioButton1() {} void BRadioButton::_ReservedRadioButton1() {}
+11
View File
@@ -850,6 +850,17 @@ BTextControl::PreferredSize()
} }
BAlignment
BTextControl::LayoutAlignment()
{
CALLED();
_ValidateLayoutData();
return BLayoutUtils::ComposeAlignment(ExplicitAlignment(),
BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET));
}
BLayoutItem* BLayoutItem*
BTextControl::CreateLabelLayoutItem() BTextControl::CreateLabelLayoutItem()
{ {