hrev47164 adds 10 changesets to branch 'master' old head: c161ea9ac29499057df524e0a438ea92426ff76f new head: 60370b9a6c8456c5970455f6bf170a383e56c621 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=60370b9+%5Ec161ea9 ---------------------------------------------------------------------------- a631719: BButton style fixes cb30cf1: BMenu: style fixes b7096fd: BMenu: remove useless default case ca6cc0a: BMenu: Replace min_c and max_c ... with std:min and std:max c884d01: BMenuBar style fixes 58a3b20: BMenuField: style fixes d055b93: BMenuField: Replace 5 with DefaultLabelSpacing() c79f260: BMenuField: Check if menuBar is NULL explicitly b11edca: BTextControl: style fixes 60370b9: BMenuField/BTextControl: Store and reuse Label() [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 6 files changed, 201 insertions(+), 124 deletions(-) src/kits/interface/BMCPrivate.cpp | 2 +- src/kits/interface/Button.cpp | 60 +++++++++------ src/kits/interface/Menu.cpp | 136 +++++++++++++++++++-------------- src/kits/interface/MenuBar.cpp | 8 ++ src/kits/interface/MenuField.cpp | 43 ++++++++--- src/kits/interface/TextControl.cpp | 76 +++++++++++------- ############################################################################ Commit: a631719fb4dfdc322d52e128fa96c488dfd6c689 URL: http://cgit.haiku-os.org/haiku/commit/?id=a631719 Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu Apr 24 19:06:49 2014 UTC BButton style fixes ---------------------------------------------------------------------------- diff --git a/src/kits/interface/Button.cpp b/src/kits/interface/Button.cpp index 0ec9453..8dd31fa 100644 --- a/src/kits/interface/Button.cpp +++ b/src/kits/interface/Button.cpp @@ -39,9 +39,10 @@ static const float kLabelMargin = 3; BButton::BButton(BRect frame, const char* name, const char* label, - BMessage* message, uint32 resizingMode, uint32 flags) - : BControl(frame, name, label, message, resizingMode, - flags | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE), + BMessage* message, uint32 resizingMode, uint32 flags) + : + BControl(frame, name, label, message, resizingMode, + flags | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE), fPreferredSize(-1, -1), fFlags(0), fBehavior(B_BUTTON_BEHAVIOR), @@ -57,9 +58,10 @@ BButton::BButton(BRect frame, const char* name, const char* label, BButton::BButton(const char* name, const char* label, BMessage* message, - uint32 flags) - : BControl(name, label, message, - flags | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE), + uint32 flags) + : + BControl(name, label, message, + flags | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE), fPreferredSize(-1, -1), fFlags(0), fBehavior(B_BUTTON_BEHAVIOR), @@ -69,8 +71,9 @@ BButton::BButton(const char* name, const char* label, BMessage* message, BButton::BButton(const char* label, BMessage* message) - : BControl(NULL, label, message, - B_WILL_DRAW | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE), + : + BControl(NULL, label, message, + B_WILL_DRAW | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE), fPreferredSize(-1, -1), fFlags(0), fBehavior(B_BUTTON_BEHAVIOR), @@ -86,7 +89,8 @@ BButton::~BButton() BButton::BButton(BMessage* archive) - : BControl(archive), + : + BControl(archive), fPreferredSize(-1, -1), fFlags(0), fBehavior(B_BUTTON_BEHAVIOR), @@ -235,7 +239,7 @@ BButton::AttachedToWindow() void -BButton::KeyDown(const char *bytes, int32 numBytes) +BButton::KeyDown(const char* bytes, int32 numBytes) { if (*bytes == B_ENTER || *bytes == B_SPACE) { if (!IsEnabled()) @@ -257,8 +261,8 @@ BButton::KeyDown(const char *bytes, int32 numBytes) void BButton::MakeDefault(bool flag) { - BButton *oldDefault = NULL; - BWindow *window = Window(); + BButton* oldDefault = NULL; + BWindow* window = Window(); if (window) oldDefault = window->DefaultButton(); @@ -296,7 +300,7 @@ BButton::MakeDefault(bool flag) void -BButton::SetLabel(const char *string) +BButton::SetLabel(const char* string) { BControl::SetLabel(string); } @@ -358,7 +362,7 @@ BButton::SetPopUpMessage(BMessage* message) void -BButton::MessageReceived(BMessage *message) +BButton::MessageReceived(BMessage* message) { BControl::MessageReceived(message); } @@ -372,7 +376,7 @@ BButton::WindowActivated(bool active) void -BButton::MouseMoved(BPoint point, uint32 transit, const BMessage *message) +BButton::MouseMoved(BPoint point, uint32 transit, const BMessage* message) { bool inside = Bounds().Contains(point); if (_SetFlag(FLAG_INSIDE, inside)) @@ -425,7 +429,7 @@ BButton::SetValue(int32 value) void -BButton::GetPreferredSize(float *_width, float *_height) +BButton::GetPreferredSize(float* _width, float* _height) { _ValidatePreferredSize(); @@ -445,7 +449,7 @@ BButton::ResizeToPreferred() status_t -BButton::Invoke(BMessage *message) +BButton::Invoke(BMessage* message) { Sync(); snooze(50000); @@ -494,17 +498,17 @@ BButton::AllDetached() } -BHandler * -BButton::ResolveSpecifier(BMessage *message, int32 index, - BMessage *specifier, int32 what, - const char *property) +BHandler* +BButton::ResolveSpecifier(BMessage* message, int32 index, + BMessage* specifier, int32 what, const char* property) { - return BControl::ResolveSpecifier(message, index, specifier, what, property); + return BControl::ResolveSpecifier(message, index, specifier, what, + property); } status_t -BButton::GetSupportedSuites(BMessage *message) +BButton::GetSupportedSuites(BMessage* message) { return BControl::GetSupportedSuites(message); } @@ -518,22 +522,27 @@ BButton::Perform(perform_code code, void* _data) ((perform_data_min_size*)_data)->return_value = BButton::MinSize(); return B_OK; + case PERFORM_CODE_MAX_SIZE: ((perform_data_max_size*)_data)->return_value = BButton::MaxSize(); return B_OK; + case PERFORM_CODE_PREFERRED_SIZE: ((perform_data_preferred_size*)_data)->return_value = BButton::PreferredSize(); return B_OK; + case PERFORM_CODE_LAYOUT_ALIGNMENT: ((perform_data_layout_alignment*)_data)->return_value = BButton::LayoutAlignment(); return B_OK; + case PERFORM_CODE_HAS_HEIGHT_FOR_WIDTH: ((perform_data_has_height_for_width*)_data)->return_value = BButton::HasHeightForWidth(); return B_OK; + case PERFORM_CODE_GET_HEIGHT_FOR_WIDTH: { perform_data_get_height_for_width* data @@ -542,12 +551,14 @@ BButton::Perform(perform_code code, void* _data) &data->preferred); return B_OK; } + case PERFORM_CODE_SET_LAYOUT: { perform_data_set_layout* data = (perform_data_set_layout*)_data; BButton::SetLayout(data->layout); return B_OK; } + case PERFORM_CODE_LAYOUT_INVALIDATED: { perform_data_layout_invalidated* data @@ -555,11 +566,13 @@ BButton::Perform(perform_code code, void* _data) BButton::LayoutInvalidated(data->descendants); return B_OK; } + case PERFORM_CODE_DO_LAYOUT: { BButton::DoLayout(); return B_OK; } + case PERFORM_CODE_SET_ICON: { perform_data_set_icon* data = (perform_data_set_icon*)_data; @@ -733,4 +746,3 @@ B_IF_GCC_2(InvalidateLayout__7BButtonb, _ZN7BButton16InvalidateLayoutEb)( view->Perform(PERFORM_CODE_LAYOUT_INVALIDATED, &data); } - ############################################################################ Commit: cb30cf1423cec942ca12e67cb67f62a1aaeeb3c5 URL: http://cgit.haiku-os.org/haiku/commit/?id=cb30cf1 Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Apr 22 23:35:18 2014 UTC BMenu: style fixes ---------------------------------------------------------------------------- diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index f3a6c5c..307b6da 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -207,7 +207,7 @@ struct BMenu::LayoutData { }; -// #pragma mark - +// #pragma mark - BMenu BMenu::BMenu(const char* name, menu_layout layout) @@ -326,9 +326,6 @@ BMenu::~BMenu() } -// #pragma mark - - - BArchivable* BMenu::Instantiate(BMessage* archive) { @@ -377,9 +374,6 @@ BMenu::Archive(BMessage* data, bool deep) const } -// #pragma mark - - - void BMenu::AttachedToWindow() { @@ -422,9 +416,6 @@ BMenu::AllDetached() } -// #pragma mark - - - void BMenu::Draw(BRect updateRect) { @@ -593,16 +584,14 @@ BMenu::KeyDown(const char* bytes, int32 numBytes) } -// #pragma mark - - - BSize BMenu::MinSize() { _ValidatePreferredSize(); - BSize size = (GetLayout() ? GetLayout()->MinSize() + BSize size = (GetLayout() != NULL ? GetLayout()->MinSize() : fLayoutData->preferred); + return BLayoutUtils::ComposeSize(ExplicitMinSize(), size); } @@ -612,8 +601,9 @@ BMenu::MaxSize() { _ValidatePreferredSize(); - BSize size = (GetLayout() ? GetLayout()->MaxSize() + BSize size = (GetLayout() != NULL ? GetLayout()->MaxSize() : fLayoutData->preferred); + return BLayoutUtils::ComposeSize(ExplicitMaxSize(), size); } @@ -623,8 +613,9 @@ BMenu::PreferredSize() { _ValidatePreferredSize(); - BSize size = (GetLayout() ? GetLayout()->PreferredSize() + BSize size = (GetLayout() != NULL ? GetLayout()->PreferredSize() : fLayoutData->preferred); + return BLayoutUtils::ComposeSize(ExplicitPreferredSize(), size); } @@ -636,6 +627,7 @@ BMenu::GetPreferredSize(float* _width, float* _height) if (_width) *_width = fLayoutData->preferred.width; + if (_height) *_height = fLayoutData->preferred.height; } @@ -653,7 +645,7 @@ BMenu::DoLayout() { // If the user set a layout, we let the base class version call its // hook. - if (GetLayout()) { + if (GetLayout() != NULL) { BView::DoLayout(); return; } @@ -688,9 +680,6 @@ BMenu::InvalidateLayout() } -// #pragma mark - - - void BMenu::MakeFocus(bool focused) { @@ -725,6 +714,7 @@ BMenu::AddItem(BMenuItem* item, int32 index) } UnlockLooper(); } + return true; } @@ -1151,9 +1141,6 @@ BMenu::Superitem() const } -// #pragma mark - - - BHandler* BMenu::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier, int32 form, const char* property) @@ -1228,22 +1215,27 @@ BMenu::Perform(perform_code code, void* _data) ((perform_data_min_size*)_data)->return_value = BMenu::MinSize(); return B_OK; + case PERFORM_CODE_MAX_SIZE: ((perform_data_max_size*)_data)->return_value = BMenu::MaxSize(); return B_OK; + case PERFORM_CODE_PREFERRED_SIZE: ((perform_data_preferred_size*)_data)->return_value = BMenu::PreferredSize(); return B_OK; + case PERFORM_CODE_LAYOUT_ALIGNMENT: ((perform_data_layout_alignment*)_data)->return_value = BMenu::LayoutAlignment(); return B_OK; + case PERFORM_CODE_HAS_HEIGHT_FOR_WIDTH: ((perform_data_has_height_for_width*)_data)->return_value = BMenu::HasHeightForWidth(); return B_OK; + case PERFORM_CODE_GET_HEIGHT_FOR_WIDTH: { perform_data_get_height_for_width* data @@ -1252,12 +1244,14 @@ BMenu::Perform(perform_code code, void* _data) &data->preferred); return B_OK; } + case PERFORM_CODE_SET_LAYOUT: { perform_data_set_layout* data = (perform_data_set_layout*)_data; BMenu::SetLayout(data->layout); return B_OK; } + case PERFORM_CODE_LAYOUT_INVALIDATED: { perform_data_layout_invalidated* data @@ -1265,6 +1259,7 @@ BMenu::Perform(perform_code code, void* _data) BMenu::LayoutInvalidated(data->descendants); return B_OK; } + case PERFORM_CODE_DO_LAYOUT: { BMenu::DoLayout(); @@ -1276,8 +1271,11 @@ BMenu::Perform(perform_code code, void* _data) } +// #pragma mark - BMenu protected methods + + BMenu::BMenu(BRect frame, const char* name, uint32 resizingMode, uint32 flags, - menu_layout layout, bool resizeToFit) + menu_layout layout, bool resizeToFit) : BView(frame, name, resizingMode, flags), fChosenItem(NULL), @@ -1324,10 +1322,13 @@ BMenu::GetItemMargins(float* _left, float* _top, float* _right, { if (_left != NULL) *_left = fPad.left; + if (_top != NULL) *_top = fPad.top; + if (_right != NULL) *_right = fPad.right; + if (_bottom != NULL) *_bottom = fPad.bottom; } @@ -1389,6 +1390,9 @@ BMenu::Track(bool sticky, BRect* clickToOpenRect) } +// #pragma mark - BMenu private methods + + bool BMenu::AddDynamicItem(add_state state) { @@ -1405,14 +1409,17 @@ BMenu::DrawBackground(BRect updateRect) uint32 flags = 0; if (!IsEnabled()) flags |= BControlLook::B_DISABLED; + if (IsFocus()) flags |= BControlLook::B_FOCUSED; + BRect rect = Bounds(); uint32 borders = BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER; if (Window() != NULL && Parent() != NULL) { if (Parent()->Frame().top == Window()->Bounds().top) borders |= BControlLook::B_TOP_BORDER; + if (Parent()->Frame().bottom == Window()->Bounds().bottom) borders |= BControlLook::B_BOTTOM_BORDER; } else { @@ -1980,9 +1987,6 @@ BMenu::_UpdateStateClose(BMenuItem* item, const BPoint& where, } -// #pragma mark - - - bool BMenu::_AddItem(BMenuItem* item, int32 index) { @@ -2128,7 +2132,6 @@ BMenu::_ComputeLayout(int32 index, bool bestFit, bool moveItems, fLayoutData->lastResizingMode = ResizingMode(); BRect frame; - switch (fLayout) { case B_ITEMS_IN_COLUMN: { @@ -2139,9 +2142,11 @@ BMenu::_ComputeLayout(int32 index, bool bestFit, bool moveItems, overrideFrame = &parentFrame; } - _ComputeColumnLayout(index, bestFit, moveItems, overrideFrame, frame); + _ComputeColumnLayout(index, bestFit, moveItems, overrideFrame, + frame); break; } + case B_ITEMS_IN_ROW: _ComputeRowLayout(index, bestFit, moveItems, frame); break; @@ -2188,34 +2193,40 @@ void BMenu::_ComputeColumnLayout(int32 index, bool bestFit, bool moveItems, BRect* overrideFrame, BRect& frame) { - BFont font; - GetFont(&font); bool command = false; bool control = false; bool shift = false; bool option = false; + if (index > 0) frame = ItemAt(index - 1)->Frame(); - else if (overrideFrame != NULL) { + else if (overrideFrame != NULL) frame.Set(0, 0, overrideFrame->right, -1); - } else + else frame.Set(0, 0, 0, -1); + BFont font; + GetFont(&font); + for (; index < fItems.CountItems(); index++) { BMenuItem* item = ItemAt(index); - float width, height; + float width; + float height; item->GetContentSize(&width, &height); if (item->fModifiers && item->fShortcutChar) { width += font.Size(); - if (item->fModifiers & B_COMMAND_KEY) + if ((item->fModifiers & B_COMMAND_KEY) != 0) command = true; - if (item->fModifiers & B_CONTROL_KEY) + + if ((item->fModifiers & B_CONTROL_KEY) != 0) control = true; - if (item->fModifiers & B_SHIFT_KEY) + + if ((item->fModifiers & B_SHIFT_KEY) != 0) shift = true; - if (item->fModifiers & B_OPTION_KEY) + + if ((item->fModifiers & B_OPTION_KEY) != 0) option = true; } @@ -2231,14 +2242,22 @@ BMenu::_ComputeColumnLayout(int32 index, bool bestFit, bool moveItems, frame.bottom = item->fBounds.bottom; } - if (command) - frame.right += BPrivate::MenuPrivate::MenuItemCommand()->Bounds().Width() + 1; - if (control) - frame.right += BPrivate::MenuPrivate::MenuItemControl()->Bounds().Width() + 1; - if (option) - frame.right += BPrivate::MenuPrivate::MenuItemOption()->Bounds().Width() + 1; - if (shift) - frame.right += BPrivate::MenuPrivate::MenuItemShift()->Bounds().Width() + 1; + if (command) { + frame.right + += BPrivate::MenuPrivate::MenuItemCommand()->Bounds().Width() + 1; + } + if (control) { + frame.right + += BPrivate::MenuPrivate::MenuItemControl()->Bounds().Width() + 1; + } + if (option) { + frame.right + += BPrivate::MenuPrivate::MenuItemOption()->Bounds().Width() + 1; + } + if (shift) { + frame.right + += BPrivate::MenuPrivate::MenuItemShift()->Bounds().Width() + 1; + } if (fMaxContentWidth > 0) frame.right = min_c(frame.right, fMaxContentWidth); @@ -3005,7 +3024,7 @@ BMenu::_QuitTracking(bool onlyThis) } -// #pragma mark - +// #pragma mark - menu_info functions // TODO: Maybe the following two methods would fit better into ############################################################################ Commit: b7096fd76be21a95d778c65948fef2634108dbd6 URL: http://cgit.haiku-os.org/haiku/commit/?id=b7096fd Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Apr 23 19:29:43 2014 UTC BMenu: remove useless default case ---------------------------------------------------------------------------- diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 307b6da..6d72a40 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -2154,9 +2154,6 @@ BMenu::_ComputeLayout(int32 index, bool bestFit, bool moveItems, case B_ITEMS_IN_MATRIX: _ComputeMatrixLayout(frame); break; - - default: - break; } // change width depending on resize mode ############################################################################ Commit: ca6cc0aa5033795c5acea1d73a3f72e2f36df3ce URL: http://cgit.haiku-os.org/haiku/commit/?id=ca6cc0a Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu Apr 24 18:54:48 2014 UTC BMenu: Replace min_c and max_c ... with std:min and std:max ---------------------------------------------------------------------------- diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 6d72a40..2288cef 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -13,7 +13,9 @@ #include <Menu.h> +#include <algorithm> #include <new> + #include <ctype.h> #include <string.h> @@ -2039,11 +2041,11 @@ BMenu::_RemoveItems(int32 index, int32 count, BMenuItem* item, } } else { // We iterate backwards because it's simpler - int32 i = min_c(index + count - 1, fItems.CountItems() - 1); + int32 i = std::min(index + count - 1, fItems.CountItems() - 1); // NOTE: the range check for "index" is done after // calculating the last index to be removed, so // that the range is not "shifted" unintentionally - index = max_c(0, index); + index = std::max((int32)0, index); for (; i >= index; i--) { item = static_cast<BMenuItem*>(fItems.ItemAt(i)); if (item != NULL) { @@ -2235,7 +2237,7 @@ BMenu::_ComputeColumnLayout(int32 index, bool bestFit, bool moveItems, if (item->fSubmenu != NULL) width += item->Frame().Height(); - frame.right = max_c(frame.right, width + fPad.left + fPad.right); + frame.right = std::max(frame.right, width + fPad.left + fPad.right); frame.bottom = item->fBounds.bottom; } @@ -2257,7 +2259,7 @@ BMenu::_ComputeColumnLayout(int32 index, bool bestFit, bool moveItems, } if (fMaxContentWidth > 0) - frame.right = min_c(frame.right, fMaxContentWidth); + frame.right = std::min(frame.right, fMaxContentWidth); if (moveItems) { for (int32 i = 0; i < fItems.CountItems(); i++) @@ -2290,7 +2292,7 @@ BMenu::_ComputeRowLayout(int32 index, bool bestFit, bool moveItems, + fPad.right; frame.right = item->Frame().right + 1.0f; - frame.bottom = max_c(frame.bottom, height + fPad.top + fPad.bottom); + frame.bottom = std::max(frame.bottom, height + fPad.top + fPad.bottom); } if (moveItems) { @@ -2312,10 +2314,10 @@ BMenu::_ComputeMatrixLayout(BRect &frame) for (int32 i = 0; i < CountItems(); i++) { BMenuItem* item = ItemAt(i); if (item != NULL) { - frame.left = min_c(frame.left, item->Frame().left); - frame.right = max_c(frame.right, item->Frame().right); - frame.top = min_c(frame.top, item->Frame().top); - frame.bottom = max_c(frame.bottom, item->Frame().bottom); + frame.left = std::min(frame.left, item->Frame().left); + frame.right = std::max(frame.right, item->Frame().right); + frame.top = std::min(frame.top, item->Frame().top); + frame.bottom = std::max(frame.bottom, item->Frame().bottom); } } } ############################################################################ Commit: c884d017ed8e70e7a8a4f883aab64a3955af5ea5 URL: http://cgit.haiku-os.org/haiku/commit/?id=c884d01 Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu Apr 24 18:58:29 2014 UTC BMenuBar style fixes ---------------------------------------------------------------------------- diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index 36840a0..194cfcf 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -380,22 +380,27 @@ BMenuBar::Perform(perform_code code, void* _data) ((perform_data_min_size*)_data)->return_value = BMenuBar::MinSize(); return B_OK; + case PERFORM_CODE_MAX_SIZE: ((perform_data_max_size*)_data)->return_value = BMenuBar::MaxSize(); return B_OK; + case PERFORM_CODE_PREFERRED_SIZE: ((perform_data_preferred_size*)_data)->return_value = BMenuBar::PreferredSize(); return B_OK; + case PERFORM_CODE_LAYOUT_ALIGNMENT: ((perform_data_layout_alignment*)_data)->return_value = BMenuBar::LayoutAlignment(); return B_OK; + case PERFORM_CODE_HAS_HEIGHT_FOR_WIDTH: ((perform_data_has_height_for_width*)_data)->return_value = BMenuBar::HasHeightForWidth(); return B_OK; + case PERFORM_CODE_GET_HEIGHT_FOR_WIDTH: { perform_data_get_height_for_width* data @@ -404,12 +409,14 @@ BMenuBar::Perform(perform_code code, void* _data) &data->preferred); return B_OK; } + case PERFORM_CODE_SET_LAYOUT: { perform_data_set_layout* data = (perform_data_set_layout*)_data; BMenuBar::SetLayout(data->layout); return B_OK; } + case PERFORM_CODE_LAYOUT_INVALIDATED: { perform_data_layout_invalidated* data @@ -417,6 +424,7 @@ BMenuBar::Perform(perform_code code, void* _data) BMenuBar::LayoutInvalidated(data->descendants); return B_OK; } + case PERFORM_CODE_DO_LAYOUT: { BMenuBar::DoLayout(); ############################################################################ Commit: 58a3b20760f388db630dbda0986c67e9e87ca38c URL: http://cgit.haiku-os.org/haiku/commit/?id=58a3b20 Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Apr 22 23:37:32 2014 UTC BMenuField: style fixes ---------------------------------------------------------------------------- diff --git a/src/kits/interface/BMCPrivate.cpp b/src/kits/interface/BMCPrivate.cpp index 632ac74..4e27aa5 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -262,7 +262,6 @@ _BMCMenuBar_::MinSize() { BSize size; BMenuBar::GetPreferredSize(&size.width, &size.height); - if (fShowPopUpMarker) { // account for popup indicator + a few pixels margin size.width += kPopUpIndicatorWidth; @@ -279,6 +278,7 @@ _BMCMenuBar_::MaxSize() // limited. BSize size; BMenuBar::GetPreferredSize(&size.width, &size.height); + return BLayoutUtils::ComposeSize(ExplicitMaxSize(), size); } diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index 7b41472..0a5fb8d 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -845,6 +845,7 @@ BMenuField::CreateMenuBarLayoutItem() B_ALIGN_VERTICAL_UNSET)); fLayoutData->menu_bar_layout_item = new MenuBarLayoutItem(this); } + return fLayoutData->menu_bar_layout_item; } @@ -857,22 +858,27 @@ BMenuField::Perform(perform_code code, void* _data) ((perform_data_min_size*)_data)->return_value = BMenuField::MinSize(); return B_OK; + case PERFORM_CODE_MAX_SIZE: ((perform_data_max_size*)_data)->return_value = BMenuField::MaxSize(); return B_OK; + case PERFORM_CODE_PREFERRED_SIZE: ((perform_data_preferred_size*)_data)->return_value = BMenuField::PreferredSize(); return B_OK; + case PERFORM_CODE_LAYOUT_ALIGNMENT: ((perform_data_layout_alignment*)_data)->return_value = BMenuField::LayoutAlignment(); return B_OK; + case PERFORM_CODE_HAS_HEIGHT_FOR_WIDTH: ((perform_data_has_height_for_width*)_data)->return_value = BMenuField::HasHeightForWidth(); return B_OK; + case PERFORM_CODE_GET_HEIGHT_FOR_WIDTH: { perform_data_get_height_for_width* data @@ -881,12 +887,14 @@ BMenuField::Perform(perform_code code, void* _data) &data->preferred); return B_OK; } + case PERFORM_CODE_SET_LAYOUT: { perform_data_set_layout* data = (perform_data_set_layout*)_data; BMenuField::SetLayout(data->layout); return B_OK; } + case PERFORM_CODE_LAYOUT_INVALIDATED: { perform_data_layout_invalidated* data @@ -894,24 +902,25 @@ BMenuField::Perform(perform_code code, void* _data) BMenuField::LayoutInvalidated(data->descendants); return B_OK; } + case PERFORM_CODE_DO_LAYOUT: { BMenuField::DoLayout(); return B_OK; } + case PERFORM_CODE_ALL_UNARCHIVED: { perform_data_all_unarchived* data = (perform_data_all_unarchived*)_data; - data->return_value = BMenuField::AllUnarchived(data->archive); return B_OK; } + case PERFORM_CODE_ALL_ARCHIVED: { perform_data_all_archived* data = (perform_data_all_archived*)_data; - data->return_value = BMenuField::AllArchived(data->archive); return B_OK; } @@ -952,6 +961,7 @@ BMenuField::DoLayout() BSize size(Bounds().Size()); if (size.width < fLayoutData->min.width) size.width = fLayoutData->min.width; + if (size.height < fLayoutData->min.height) size.height = fLayoutData->min.height; @@ -1104,6 +1114,7 @@ BMenuField::_DrawMenuBar(BRect updateRect) uint32 flags = 0; if (!IsEnabled()) flags |= BControlLook::B_DISABLED; + if (IsFocus() && Window()->IsActive()) flags |= BControlLook::B_FOCUSED; @@ -1307,6 +1318,7 @@ BMenuField::_ValidateLayoutData() if (divider > 0) min.width += divider; + if (fLayoutData->label_height > min.height) min.height = fLayoutData->label_height; @@ -1415,7 +1427,7 @@ BMenuField::LabelLayoutItem::BaseMinSize() { fParent->_ValidateLayoutData(); - if (!fParent->Label()) + if (fParent->Label() == NULL) return BSize(-1, -1); return BSize(fParent->fLayoutData->label_width + 5, @@ -1462,6 +1474,7 @@ BMenuField::LabelLayoutItem::Instantiate(BMessage* from) { if (validate_instantiation(from, "BMenuField::LabelLayoutItem")) return new LabelLayoutItem(from); + return NULL; } @@ -1551,6 +1564,7 @@ BMenuField::MenuBarLayoutItem::BaseMaxSize() { BSize size(BaseMinSize()); size.width = B_SIZE_UNLIMITED; + return size; } ############################################################################ Commit: d055b93b25ba69743749309ac615cef8cc443e02 URL: http://cgit.haiku-os.org/haiku/commit/?id=d055b93 Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Apr 22 23:38:43 2014 UTC BMenuField: Replace 5 with DefaultLabelSpacing() ---------------------------------------------------------------------------- diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index 0a5fb8d..eb53930 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -974,8 +974,10 @@ BMenuField::DoLayout() // We have valid layout items, they define the divider location. divider = fLayoutData->menu_bar_layout_item->Frame().left - fLayoutData->label_layout_item->Frame().left; - } else if (fLayoutData->label_width > 0) - divider = fLayoutData->label_width + 5; + } else if (fLayoutData->label_width > 0) { + divider = fLayoutData->label_width + + be_control_look->DefaultLabelSpacing(); + } // menu bar BRect dirty(fMenuBar->Frame()); @@ -1295,8 +1297,10 @@ BMenuField::_ValidateLayoutData() // compute the minimal divider float divider = 0; - if (fLayoutData->label_width > 0) - divider = fLayoutData->label_width + 5; + if (fLayoutData->label_width > 0) { + divider = fLayoutData->label_width + + be_control_look->DefaultLabelSpacing(); + } // If we shan't do real layout, we let the current divider take influence. if ((Flags() & B_SUPPORTS_LAYOUT) == 0) @@ -1430,7 +1434,8 @@ BMenuField::LabelLayoutItem::BaseMinSize() if (fParent->Label() == NULL) return BSize(-1, -1); - return BSize(fParent->fLayoutData->label_width + 5, + return BSize(fParent->fLayoutData->label_width + + be_control_look->DefaultLabelSpacing(), fParent->fLayoutData->label_height); } ############################################################################ Commit: c79f2602761f226941852caa2305d5f2dcf8036b URL: http://cgit.haiku-os.org/haiku/commit/?id=c79f260 Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Apr 22 23:39:45 2014 UTC BMenuField: Check if menuBar is NULL explicitly ---------------------------------------------------------------------------- diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index eb53930..14a69ad 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -1270,7 +1270,8 @@ BMenuField::_InitMenuBar(const BMessage* archive) bool dmark = false; archive->FindBool("be:dmark", &dmark); - if (_BMCMenuBar_* menuBar = dynamic_cast<_BMCMenuBar_*>(fMenuBar)) + _BMCMenuBar_* menuBar = dynamic_cast<_BMCMenuBar_*>(fMenuBar); + if (menuBar != NULL) menuBar->TogglePopUpMarker(dmark); } ############################################################################ Commit: b11edca47d067a1afd3cdb8368d0e1e5ca98b2bb URL: http://cgit.haiku-os.org/haiku/commit/?id=b11edca Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Apr 22 23:43:08 2014 UTC BTextControl: style fixes ---------------------------------------------------------------------------- diff --git a/src/kits/interface/TextControl.cpp b/src/kits/interface/TextControl.cpp index 9863ecd..566721f 100644 --- a/src/kits/interface/TextControl.cpp +++ b/src/kits/interface/TextControl.cpp @@ -148,13 +148,13 @@ struct BTextControl::LayoutData { }; -// #pragma mark - - - static const int32 kFrameMargin = 2; static const int32 kLabelInputSpacing = 3; +// #pragma mark - BTextControl + + BTextControl::BTextControl(BRect frame, const char* name, const char* label, const char* text, BMessage* message, uint32 mask, uint32 flags) : @@ -347,7 +347,7 @@ BTextControl::Invoke(BMessage *message) } -BTextView * +BTextView* BTextControl::TextView() const { return fText; @@ -385,9 +385,10 @@ BTextControl::SetAlignment(alignment labelAlignment, alignment textAlignment) void BTextControl::GetAlignment(alignment* _label, alignment* _text) const { - if (_label) + if (_label != NULL) *_label = fLabelAlign; - if (_text) + + if (_text != NULL) *_text = fText->Alignment(); } @@ -659,7 +660,7 @@ BTextControl::MessageReceived(BMessage *message) reply.AddString("result", fText->Text()); handled = true; } else { - const char *value = NULL; + const char* value = NULL; // B_SET_PROPERTY if (message->FindString("data", &value) == B_OK) { fText->SetText(value); @@ -680,10 +681,9 @@ BTextControl::MessageReceived(BMessage *message) } -BHandler * -BTextControl::ResolveSpecifier(BMessage *message, int32 index, - BMessage *specifier, int32 what, - const char *property) +BHandler* +BTextControl::ResolveSpecifier(BMessage* message, int32 index, + BMessage* specifier, int32 what, const char* property) { BPropertyInfo propInfo(sPropertyList); @@ -696,23 +696,24 @@ BTextControl::ResolveSpecifier(BMessage *message, int32 index, status_t -BTextControl::GetSupportedSuites(BMessage *data) +BTextControl::GetSupportedSuites(BMessage* data) { return BControl::GetSupportedSuites(data); } void -BTextControl::MouseUp(BPoint pt) +BTextControl::MouseUp(BPoint point) { - BControl::MouseUp(pt); + BControl::MouseUp(point); } void -BTextControl::MouseMoved(BPoint pt, uint32 code, const BMessage *msg) +BTextControl::MouseMoved(BPoint point, uint32 transit, + const BMessage* dragMessage) { - BControl::MouseMoved(pt, code, msg); + BControl::MouseMoved(point, transit, dragMessage); } @@ -866,6 +867,7 @@ BTextControl::CreateLabelLayoutItem() { if (!fLayoutData->label_layout_item) fLayoutData->label_layout_item = new LabelLayoutItem(this); + return fLayoutData->label_layout_item; } @@ -875,6 +877,7 @@ BTextControl::CreateTextViewLayoutItem() { if (!fLayoutData->text_view_layout_item) fLayoutData->text_view_layout_item = new TextViewLayoutItem(this); + return fLayoutData->text_view_layout_item; } @@ -910,6 +913,7 @@ BTextControl::DoLayout() BSize size(Bounds().Size()); if (size.width < fLayoutData->min.width) size.width = fLayoutData->min.width; + if (size.height < fLayoutData->min.height) size.height = fLayoutData->min.height; @@ -954,7 +958,7 @@ BTextControl::SetIcon(const BBitmap* icon, uint32 flags) } -// #pragma mark - +// #pragma mark - BTextControl private methods status_t @@ -965,22 +969,27 @@ BTextControl::Perform(perform_code code, void* _data) ((perform_data_min_size*)_data)->return_value = BTextControl::MinSize(); return B_OK; + case PERFORM_CODE_MAX_SIZE: ((perform_data_max_size*)_data)->return_value = BTextControl::MaxSize(); return B_OK; + case PERFORM_CODE_PREFERRED_SIZE: ((perform_data_preferred_size*)_data)->return_value = BTextControl::PreferredSize(); return B_OK; + case PERFORM_CODE_LAYOUT_ALIGNMENT: ((perform_data_layout_alignment*)_data)->return_value = BTextControl::LayoutAlignment(); return B_OK; + case PERFORM_CODE_HAS_HEIGHT_FOR_WIDTH: ((perform_data_has_height_for_width*)_data)->return_value = BTextControl::HasHeightForWidth(); return B_OK; + case PERFORM_CODE_GET_HEIGHT_FOR_WIDTH: { perform_data_get_height_for_width* data @@ -989,12 +998,14 @@ BTextControl::Perform(perform_code code, void* _data) &data->preferred); return B_OK; } + case PERFORM_CODE_SET_LAYOUT: { perform_data_set_layout* data = (perform_data_set_layout*)_data; BTextControl::SetLayout(data->layout); return B_OK; } + case PERFORM_CODE_LAYOUT_INVALIDATED: { perform_data_layout_invalidated* data @@ -1002,29 +1013,31 @@ BTextControl::Perform(perform_code code, void* _data) BTextControl::LayoutInvalidated(data->descendants); return B_OK; } + case PERFORM_CODE_DO_LAYOUT: { BTextControl::DoLayout(); return B_OK; } + case PERFORM_CODE_SET_ICON: { perform_data_set_icon* data = (perform_data_set_icon*)_data; return BTextControl::SetIcon(data->icon, data->flags); } + case PERFORM_CODE_ALL_UNARCHIVED: { perform_data_all_unarchived* data = (perform_data_all_unarchived*)_data; - data->return_value = BTextControl::AllUnarchived(data->archive); return B_OK; } + case PERFORM_CODE_ALL_ARCHIVED: { perform_data_all_archived* data = (perform_data_all_archived*)_data; - data->return_value = BTextControl::AllArchived(data->archive); return B_OK; } @@ -1040,7 +1053,7 @@ void BTextControl::_ReservedTextControl3() {} void BTextControl::_ReservedTextControl4() {} -BTextControl & +BTextControl& BTextControl::operator=(const BTextControl&) { return *this; @@ -1065,9 +1078,9 @@ BTextControl::_UpdateTextViewColors(bool enabled) fText->SetFontAndColor(&font, B_FONT_ALL, &textColor); - if (enabled) { + if (enabled) color = ui_color(B_DOCUMENT_BACKGROUND_COLOR); - } else { + else { color = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_2_TINT); } @@ -1220,10 +1233,11 @@ BTextControl::_UpdateFrame() fDivider = 0; } + // update our frame MoveTo(frame.left, frame.top); - BSize oldSize = Bounds().Size(); + BSize oldSize(Bounds().Size()); ResizeTo(frame.Width(), frame.Height()); - BSize newSize = Bounds().Size(); + BSize newSize(Bounds().Size()); // If the size changes, ResizeTo() will trigger a relayout, otherwise // we need to do that explicitly. @@ -1276,6 +1290,7 @@ BTextControl::_ValidateLayoutData() if (divider > 0) min.width += divider; + if (fLayoutData->label_height > min.height) min.height = fLayoutData->label_height; @@ -1288,7 +1303,7 @@ BTextControl::_ValidateLayoutData() } -// #pragma mark - +// #pragma mark - BTextControl::LabelLayoutItem BTextControl::LabelLayoutItem::LabelLayoutItem(BTextControl* parent) @@ -1415,7 +1430,7 @@ BTextControl::LabelLayoutItem::Instantiate(BMessage* from) } -// #pragma mark - +// #pragma mark - BTextControl::TextViewLayoutItem BTextControl::TextViewLayoutItem::TextViewLayoutItem(BTextControl* parent) @@ -1500,6 +1515,7 @@ BTextControl::TextViewLayoutItem::BaseMaxSize() { BSize size(BaseMinSize()); size.width = B_SIZE_UNLIMITED; + return size; } @@ -1510,6 +1526,7 @@ BTextControl::TextViewLayoutItem::BasePreferredSize() BSize size(BaseMinSize()); // puh, no idea... size.width = 100; + return size; } @@ -1545,6 +1562,7 @@ BTextControl::TextViewLayoutItem::Instantiate(BMessage* from) { if (validate_instantiation(from, "BTextControl::TextViewLayoutItem")) return new TextViewLayoutItem(from); + return NULL; } @@ -1558,4 +1576,3 @@ B_IF_GCC_2(InvalidateLayout__12BTextControlb, view->Perform(PERFORM_CODE_LAYOUT_INVALIDATED, &data); } - ############################################################################ Revision: hrev47164 Commit: 60370b9a6c8456c5970455f6bf170a383e56c621 URL: http://cgit.haiku-os.org/haiku/commit/?id=60370b9 Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Apr 22 23:43:46 2014 UTC BMenuField/BTextControl: Store and reuse Label() ---------------------------------------------------------------------------- diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index 14a69ad..476fadc 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -1288,8 +1288,9 @@ BMenuField::_ValidateLayoutData() font_height& fh = fLayoutData->font_info; GetFontHeight(&fh); - if (Label() != NULL) { - fLayoutData->label_width = ceilf(StringWidth(Label())); + const char* label = Label(); + if (label != NULL) { + fLayoutData->label_width = ceilf(StringWidth(label)); fLayoutData->label_height = ceilf(fh.ascent) + ceilf(fh.descent); } else { fLayoutData->label_width = 0; diff --git a/src/kits/interface/TextControl.cpp b/src/kits/interface/TextControl.cpp index 566721f..f4828d6 100644 --- a/src/kits/interface/TextControl.cpp +++ b/src/kits/interface/TextControl.cpp @@ -1259,8 +1259,9 @@ BTextControl::_ValidateLayoutData() font_height& fh = fLayoutData->font_info; GetFontHeight(&fh); - if (Label() != NULL) { - fLayoutData->label_width = ceilf(StringWidth(Label())); + const char* label = Label(); + if (label != NULL) { + fLayoutData->label_width = ceilf(StringWidth(label)); fLayoutData->label_height = ceilf(fh.ascent) + ceilf(fh.descent); } else { fLayoutData->label_width = 0;