From 46d6e9d9ed21f6752b4f256ed193faa5bc586501 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 29 Jun 2013 20:33:42 -0400 Subject: [PATCH] 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. --- headers/os/interface/CheckBox.h | 5 +++-- headers/os/interface/RadioButton.h | 2 +- headers/os/interface/TextControl.h | 1 + src/kits/interface/CheckBox.cpp | 10 +++++++++- src/kits/interface/RadioButton.cpp | 9 ++++++++- src/kits/interface/TextControl.cpp | 11 +++++++++++ 6 files changed, 33 insertions(+), 5 deletions(-) diff --git a/headers/os/interface/CheckBox.h b/headers/os/interface/CheckBox.h index b8d2c58ecc..7e7de4241f 100644 --- a/headers/os/interface/CheckBox.h +++ b/headers/os/interface/CheckBox.h @@ -17,9 +17,9 @@ public: uint32 flags = B_WILL_DRAW | B_NAVIGABLE); BCheckBox(const char* name, const char* label, BMessage* message, uint32 flags - = B_WILL_DRAW | B_NAVIGABLE); + = B_WILL_DRAW | B_NAVIGABLE); BCheckBox(const char* label, - BMessage* message = NULL); + BMessage* message = NULL); BCheckBox(BMessage* archive); virtual ~BCheckBox(); @@ -55,6 +55,7 @@ public: virtual BSize MinSize(); virtual BSize MaxSize(); virtual BSize PreferredSize(); + virtual BAlignment LayoutAlignment(); virtual void MakeFocus(bool focused = true); diff --git a/headers/os/interface/RadioButton.h b/headers/os/interface/RadioButton.h index 5586a51e97..48da0183bc 100644 --- a/headers/os/interface/RadioButton.h +++ b/headers/os/interface/RadioButton.h @@ -61,7 +61,7 @@ public: virtual status_t Perform(perform_code d, void* argument); virtual BSize MaxSize(); - + virtual BAlignment LayoutAlignment(); private: friend status_t _init_interface_kit_(); diff --git a/headers/os/interface/TextControl.h b/headers/os/interface/TextControl.h index aca56a18f9..77d36d9928 100644 --- a/headers/os/interface/TextControl.h +++ b/headers/os/interface/TextControl.h @@ -86,6 +86,7 @@ public: virtual BSize MinSize(); virtual BSize MaxSize(); virtual BSize PreferredSize(); + virtual BAlignment LayoutAlignment(); BLayoutItem* CreateLabelLayoutItem(); BLayoutItem* CreateTextViewLayoutItem(); diff --git a/src/kits/interface/CheckBox.cpp b/src/kits/interface/CheckBox.cpp index 031fb11c58..ffe9ee3ef3 100644 --- a/src/kits/interface/CheckBox.cpp +++ b/src/kits/interface/CheckBox.cpp @@ -452,7 +452,7 @@ BSize BCheckBox::MaxSize() { 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 - diff --git a/src/kits/interface/RadioButton.cpp b/src/kits/interface/RadioButton.cpp index e3b3cfbee4..3e7659d0eb 100644 --- a/src/kits/interface/RadioButton.cpp +++ b/src/kits/interface/RadioButton.cpp @@ -566,10 +566,17 @@ BRadioButton::MaxSize() GetPreferredSize(&width, &height); 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() {} diff --git a/src/kits/interface/TextControl.cpp b/src/kits/interface/TextControl.cpp index 90ee19dd13..05ba91b6ba 100644 --- a/src/kits/interface/TextControl.cpp +++ b/src/kits/interface/TextControl.cpp @@ -850,6 +850,17 @@ BTextControl::PreferredSize() } +BAlignment +BTextControl::LayoutAlignment() +{ + CALLED(); + + _ValidateLayoutData(); + return BLayoutUtils::ComposeAlignment(ExplicitAlignment(), + BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); +} + + BLayoutItem* BTextControl::CreateLabelLayoutItem() {