hrev45725 adds 13 changesets to branch 'master' old head: 8835205cf63fe0ee9f833d37ae40af2db9a2220a new head: 14701d3ec941382b6c9543d9d15be7c5aecb1f6e overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=14701d3+%5E8835205 ---------------------------------------------------------------------------- 17aed1b: Use roundf() as suggested by Axel 9af9f51: Don't resize to preferred height if fixed size, BeOS didn't f7c092f: Refactor _BMCMenuBar_::Draw a bit Move the comments around, expand on them and an 80 char fix. 6031e62: Move constants to BMCPrivate.h and refactor We use these constants in both MenuField.cpp and BMCPrivate.cpp Incorporate kMarginWidth into kPopUpIndicatorWidth. A small code simplication in FrameResized() along with replacing bare numbers with magic constants. a1cf3ea: Resize menu field if below minimum width in auto-size mode ... cancelling the normal item truncation behavior. This funcationality comes from BeOS R5, we need to reproduce it for backwards compat. KeymapSwitcher depends on it at least. Minimum width is 20px, was set in last commit, comes from BeOS R5. 6da3c1c: if menu _BMCMenuBar_ subtract the popup indicator width ... when calculating the width of items in _ComputeLayout. This prevents that menu field from growing on selection fixing #9796 and #2413. Also a few style fixes. 92c1250: Move kMinMenuBarWidth to MenuField.cpp d926be8: BMenuItem: Check MaxContentWidth for truncation ca3a1c0: BMenuField: If fixed size always set max content width When you resize, also set max content width. Create a SetMaxContentWidth() method that includes the margins. 0a04b14: Backgrounds: Use layout workspaces menu field f6d98e7: File Panel: make room for icon in directory menu field e9c1c3b: Chart: tweak menu field widths. Don't ResizeToPreferred() 14701d3: Font Demo: Tweak layout of menu fields. Need to add more height to the menu fields because we no longer resize them automatically for fixed size mode (for BeOS compat) and the text was shorter in BeOS. [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 11 files changed, 160 insertions(+), 112 deletions(-) headers/private/interface/BMCPrivate.h | 4 + src/apps/fontdemo/ControlView.cpp | 112 +++++++++++--------- src/apps/fontdemo/ControlView.h | 1 + src/apps/fontdemo/FontDemo.cpp | 2 +- src/kits/interface/BMCPrivate.cpp | 65 +++++++----- src/kits/interface/Menu.cpp | 12 ++- src/kits/interface/MenuField.cpp | 54 ++++++---- src/kits/interface/MenuItem.cpp | 4 +- src/kits/tracker/FilePanelPriv.cpp | 2 + src/preferences/backgrounds/BackgroundsView.cpp | 4 +- src/tests/kits/game/chart/ChartWindow.cpp | 12 +-- ############################################################################ Commit: 17aed1bfc8f4bc1c76f5aa86923f3b0a9c5fbf17 URL: http://cgit.haiku-os.org/haiku/commit/?id=17aed1b Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun May 26 05:43:56 2013 UTC Use roundf() as suggested by Axel ---------------------------------------------------------------------------- diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index cdfe747..3dbd9c4 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -625,10 +625,9 @@ BMenuField::Alignment() const void BMenuField::SetDivider(float position) { - position = floorf(position + 0.5); + position = roundf(position); float delta = fDivider - position; - if (delta == 0.0f) return; ############################################################################ Commit: 9af9f5150d46915ebc10aa8c5f93afcf747c5e71 URL: http://cgit.haiku-os.org/haiku/commit/?id=9af9f51 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun May 26 05:45:00 2013 UTC Don't resize to preferred height if fixed size, BeOS didn't ---------------------------------------------------------------------------- diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index 3dbd9c4..0ff622d 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -963,9 +963,11 @@ BMenuField::InitObject2() { CALLED(); - float height; - fMenuBar->GetPreferredSize(NULL, &height); - fMenuBar->ResizeTo(_MenuBarWidth(), height); + if (!fFixedSizeMB) { + float height; + fMenuBar->GetPreferredSize(NULL, &height); + fMenuBar->ResizeTo(_MenuBarWidth(), height); + } TRACE("frame(%.1f, %.1f, %.1f, %.1f) (%.2f, %.2f)\n", fMenuBar->Frame().left, fMenuBar->Frame().top, ############################################################################ Commit: f7c092f5dbe074036566d6b37da0870e5bbded58 URL: http://cgit.haiku-os.org/haiku/commit/?id=f7c092f Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun May 26 05:48:53 2013 UTC Refactor _BMCMenuBar_::Draw a bit Move the comments around, expand on them and an 80 char fix. ---------------------------------------------------------------------------- diff --git a/src/kits/interface/BMCPrivate.cpp b/src/kits/interface/BMCPrivate.cpp index 491b00d..a494e77 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -139,17 +139,22 @@ _BMCMenuBar_::AttachedToWindow() void _BMCMenuBar_::Draw(BRect updateRect) { - // Set the width of the menu bar because the menu bar bounds may have - // been expanded by the selected menu item. - if (fFixedSize) + if (fFixedSize) { + // Set the width of the menu bar because the menu bar bounds may have + // been expanded by the selected menu item. ResizeTo(fMenuField->_MenuBarWidth(), Bounds().Height()); - else { - // For compatability with BeOS R5 set the height to the preferred height - // in auto-size mode ignoring the height of the menu field. + } else { + // For compatability with BeOS R5: + // - Set to the minimum of the menu bar width set by the menu frame + // and the selected menu item width. + // - Set the height to the preferred height ignoring the height of the + // menu field. float height; BMenuBar::GetPreferredSize(NULL, &height); - ResizeTo(std::min(Bounds().Width(), fMenuField->_MenuBarWidth()), height); + ResizeTo(std::min(Bounds().Width(), fMenuField->_MenuBarWidth()), + height); } + BRect rect(Bounds()); rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR); uint32 flags = 0; ############################################################################ Commit: 6031e62420fec7cc6c360bb210ca860a4a60e0f0 URL: http://cgit.haiku-os.org/haiku/commit/?id=6031e62 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun May 26 05:52:23 2013 UTC Move constants to BMCPrivate.h and refactor We use these constants in both MenuField.cpp and BMCPrivate.cpp Incorporate kMarginWidth into kPopUpIndicatorWidth. A small code simplication in FrameResized() along with replacing bare numbers with magic constants. ---------------------------------------------------------------------------- diff --git a/headers/private/interface/BMCPrivate.h b/headers/private/interface/BMCPrivate.h index 5c9678c..f6c1bc4 100644 --- a/headers/private/interface/BMCPrivate.h +++ b/headers/private/interface/BMCPrivate.h @@ -16,6 +16,12 @@ #include <MessageFilter.h> +static const float kVMargin = 2.0f; +static const float kMinMenuBarWidth = 20.0f; + // found by experimenting on BeOS R5 +static const float kPopUpIndicatorWidth = 13.0f; + + class BMessageRunner; diff --git a/src/kits/interface/BMCPrivate.cpp b/src/kits/interface/BMCPrivate.cpp index a494e77..1d8f60d 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -22,10 +22,6 @@ #include <Window.h> -static const float kPopUpIndicatorWidth = 10.0f; -static const float kMarginWidth = 3.0f; - - _BMCFilter_::_BMCFilter_(BMenuField* menuField, uint32 what) : BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, what), @@ -178,30 +174,29 @@ _BMCMenuBar_::FrameResized(float width, float height) float diff = width - fPreviousWidth; fPreviousWidth = width; - if (Window()) { + if (Window() != NULL && diff != 0) { + BRect dirty(fMenuField->Bounds()); if (diff > 0) { // clean up the dirty right border of // the menu field when enlarging - BRect dirty(fMenuField->Bounds()); - dirty.right = Frame().right + 2; - dirty.left = dirty.left - diff - 4; + dirty.right = Frame().right + kVMargin; + dirty.left = dirty.left - diff - kVMargin * 2; fMenuField->Invalidate(dirty); // clean up the arrow part dirty = Bounds(); - dirty.left = dirty.right - diff - 12; + dirty.left = dirty.right - diff - kPopUpIndicatorWidth; Invalidate(dirty); } else if (diff < 0) { // clean up the dirty right line of // the menu field when shrinking - BRect dirty(fMenuField->Bounds()); - dirty.left = Frame().right - 2; - dirty.right = dirty.left - diff + 4; + dirty.left = Frame().right - kVMargin; + dirty.right = dirty.left - diff + kVMargin * 2; fMenuField->Invalidate(dirty); // clean up the arrow part dirty = Bounds(); - dirty.left = dirty.right - 12; + dirty.left = dirty.right - kPopUpIndicatorWidth; Invalidate(dirty); } } @@ -275,7 +270,7 @@ _BMCMenuBar_::MinSize() if (fShowPopUpMarker) { // account for popup indicator + a few pixels margin - size.width += kPopUpIndicatorWidth + kMarginWidth; + size.width += kPopUpIndicatorWidth; } return BLayoutUtils::ComposeSize(ExplicitMinSize(), size); @@ -322,8 +317,7 @@ _BMCMenuBar_::_Init(bool setMaxContentWidth) left = right = be_control_look->DefaultLabelSpacing(); SetItemMargins(left, top, - right + fShowPopUpMarker ? kPopUpIndicatorWidth + kMarginWidth : 0, - bottom); + right + fShowPopUpMarker ? kPopUpIndicatorWidth : 0, bottom); fPreviousWidth = Bounds().Width(); diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index 0ff622d..1be5d10 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -131,9 +131,6 @@ struct BMenuField::LayoutData { // #pragma mark - -static float kVMargin = 2.0f; - - BMenuField::BMenuField(BRect frame, const char* name, const char* label, BMenu* menu, uint32 resizingMode, uint32 flags) : ############################################################################ Commit: a1cf3ead5f5e9b2857b9622bef5bc1742fd21151 URL: http://cgit.haiku-os.org/haiku/commit/?id=a1cf3ea Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun May 26 05:56:00 2013 UTC Resize menu field if below minimum width in auto-size mode ... cancelling the normal item truncation behavior. This funcationality comes from BeOS R5, we need to reproduce it for backwards compat. KeymapSwitcher depends on it at least. Minimum width is 20px, was set in last commit, comes from BeOS R5. ---------------------------------------------------------------------------- diff --git a/headers/private/interface/BMCPrivate.h b/headers/private/interface/BMCPrivate.h index f6c1bc4..0590fc7 100644 --- a/headers/private/interface/BMCPrivate.h +++ b/headers/private/interface/BMCPrivate.h @@ -19,7 +19,6 @@ static const float kVMargin = 2.0f; static const float kMinMenuBarWidth = 20.0f; // found by experimenting on BeOS R5 -static const float kPopUpIndicatorWidth = 13.0f; class BMessageRunner; diff --git a/src/kits/interface/BMCPrivate.cpp b/src/kits/interface/BMCPrivate.cpp index 1d8f60d..da8719f 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -55,6 +55,9 @@ _BMCFilter_::Filter(BMessage* message, BHandler** handler) // #pragma mark - +static const float kPopUpIndicatorWidth = 13.0f; + + _BMCMenuBar_::_BMCMenuBar_(BRect frame, bool fixedSize, BMenuField* menuField) : BMenuBar(frame, "_mc_mb_", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_ITEMS_IN_ROW, diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index 1be5d10..3c94b44 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -19,6 +19,7 @@ #include <ControlLook.h> #include <LayoutUtils.h> #include <MenuBar.h> +#include <MenuItem.h> #include <Message.h> #include <BMCPrivate.h> #include <Window.h> @@ -397,8 +398,18 @@ BMenuField::AllAttached() TRACE("width: %.2f, height: %.2f\n", Frame().Width(), Frame().Height()); - ResizeTo(Bounds().Width(), - fMenuBar->Bounds().Height() + kVMargin + kVMargin); + float width = Bounds().Width(); + if (!fFixedSizeMB && _MenuBarWidth() < kMinMenuBarWidth) { + // The menu bar is too narrow, resize it to fit the menu items + BMenuItem* item = fMenuBar->ItemAt(0); + if (item != NULL) { + float right; + fMenuBar->GetItemMargins(NULL, NULL, &right, NULL); + width = item->Frame().Width() + kVMargin + _MenuBarOffset() + right; + } + } + + ResizeTo(width, fMenuBar->Bounds().Height() + kVMargin * 2); TRACE("width: %.2f, height: %.2f\n", Frame().Width(), Frame().Height()); } ############################################################################ Commit: 6da3c1c78805a428e567ba00a6effa40df394159 URL: http://cgit.haiku-os.org/haiku/commit/?id=6da3c1c Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed May 29 23:31:42 2013 UTC Ticket: https://dev.haiku-os.org/ticket/2413 Ticket: https://dev.haiku-os.org/ticket/9796 if menu _BMCMenuBar_ subtract the popup indicator width ... when calculating the width of items in _ComputeLayout. This prevents that menu field from growing on selection fixing #9796 and #2413. Also a few style fixes. ---------------------------------------------------------------------------- diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 3b7bb02..7374245 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -2085,7 +2085,8 @@ BMenu::_LayoutItems(int32 index) { _CalcTriggers(); - float width, height; + float width; + float height; _ComputeLayout(index, fResizeToFit, true, &width, &height); if (fResizeToFit) @@ -2128,8 +2129,7 @@ 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: @@ -2147,9 +2147,11 @@ BMenu::_ComputeLayout(int32 index, bool bestFit, bool moveItems, // change width depending on resize mode BSize size; if ((ResizingMode() & B_FOLLOW_LEFT_RIGHT) == B_FOLLOW_LEFT_RIGHT) { - if (Parent()) + if (dynamic_cast<_BMCMenuBar_*>(this) != NULL) + size.width = Bounds().Width() - fPad.right; + else if (Parent() != NULL) size.width = Parent()->Frame().Width() + 1; - else if (Window()) + else if (Window() != NULL) size.width = Window()->Frame().Width() + 1; else size.width = Bounds().Width(); ############################################################################ Commit: 92c12506ac8c145ba7b3588decc3c2b6ea9a009a URL: http://cgit.haiku-os.org/haiku/commit/?id=92c1250 Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu May 30 00:59:38 2013 UTC Move kMinMenuBarWidth to MenuField.cpp ---------------------------------------------------------------------------- diff --git a/headers/private/interface/BMCPrivate.h b/headers/private/interface/BMCPrivate.h index 0590fc7..55fc564 100644 --- a/headers/private/interface/BMCPrivate.h +++ b/headers/private/interface/BMCPrivate.h @@ -17,8 +17,6 @@ static const float kVMargin = 2.0f; -static const float kMinMenuBarWidth = 20.0f; - // found by experimenting on BeOS R5 class BMessageRunner; diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index 3c94b44..9a87784 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -132,6 +132,10 @@ struct BMenuField::LayoutData { // #pragma mark - +static const float kMinMenuBarWidth = 20.0f; + // found by experimenting on BeOS R5 + + BMenuField::BMenuField(BRect frame, const char* name, const char* label, BMenu* menu, uint32 resizingMode, uint32 flags) : ############################################################################ Commit: d926be8ab3ebf6c55999544b4d836e69f1c89203 URL: http://cgit.haiku-os.org/haiku/commit/?id=d926be8 Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu May 30 03:54:32 2013 UTC BMenuItem: Check MaxContentWidth for truncation ---------------------------------------------------------------------------- diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp index 4e5691b..60e9abd 100644 --- a/src/kits/interface/MenuItem.cpp +++ b/src/kits/interface/MenuItem.cpp @@ -406,7 +406,9 @@ BMenuItem::DrawContent() GetContentSize(&labelWidth, &labelHeight); const BRect& padding = menuPrivate.Padding(); - float frameWidth = fSuper->Frame().Width() - padding.left - padding.right; + float maxContentWidth = fSuper->MaxContentWidth(); + float frameWidth = maxContentWidth > 0 ? maxContentWidth + : fSuper->Frame().Width() - padding.left - padding.right; if (roundf(frameWidth) >= roundf(labelWidth)) fSuper->DrawString(fLabel); ############################################################################ Commit: ca3a1c04518ebab574847a83e518c5fa407830a8 URL: http://cgit.haiku-os.org/haiku/commit/?id=ca3a1c0 Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu May 30 03:56:08 2013 UTC BMenuField: If fixed size always set max content width When you resize, also set max content width. Create a SetMaxContentWidth() method that includes the margins. ---------------------------------------------------------------------------- diff --git a/headers/private/interface/BMCPrivate.h b/headers/private/interface/BMCPrivate.h index 55fc564..5581d88 100644 --- a/headers/private/interface/BMCPrivate.h +++ b/headers/private/interface/BMCPrivate.h @@ -51,6 +51,7 @@ public: virtual void FrameResized(float width, float height); virtual void MessageReceived(BMessage* msg); virtual void MakeFocus(bool focused = true); + virtual void SetMaxContentWidth(float width); void TogglePopUpMarker(bool show) { fShowPopUpMarker = show; } diff --git a/src/kits/interface/BMCPrivate.cpp b/src/kits/interface/BMCPrivate.cpp index da8719f..023769a 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -67,7 +67,7 @@ _BMCMenuBar_::_BMCMenuBar_(BRect frame, bool fixedSize, BMenuField* menuField) fRunner(NULL), fShowPopUpMarker(true) { - _Init(true); + _Init(fixedSize); } @@ -79,7 +79,7 @@ _BMCMenuBar_::_BMCMenuBar_(BMenuField* menuField) fRunner(NULL), fShowPopUpMarker(true) { - _Init(false); + _Init(true); } @@ -265,6 +265,17 @@ _BMCMenuBar_::MakeFocus(bool focused) } +void +_BMCMenuBar_::SetMaxContentWidth(float width) +{ + float left; + float right; + GetItemMargins(&left, NULL, &right, NULL); + + BMenuBar::SetMaxContentWidth(width - (left + right)); +} + + BSize _BMCMenuBar_::MinSize() { @@ -325,5 +336,5 @@ _BMCMenuBar_::_Init(bool setMaxContentWidth) fPreviousWidth = Bounds().Width(); if (setMaxContentWidth) - SetMaxContentWidth(fPreviousWidth - (left + right)); + SetMaxContentWidth(fPreviousWidth); } diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index 9a87784..e30fe66 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -539,6 +539,17 @@ BMenuField::FrameResized(float newWidth, float newHeight) { BView::FrameResized(newWidth, newHeight); + if (fFixedSizeMB) { + // we have let the menubar resize itself, but + // in fixed size mode, the menubar is supposed to + // be at the right end of the view always. Since + // the menu bar is in follow left/right mode then, + // resizing ourselfs might have caused the menubar + // to be outside now + fMenuBar->ResizeTo(_MenuBarWidth(), fMenuBar->Frame().Height()); + fMenuBar->SetMaxContentWidth(_MenuBarWidth()); + } + if (newHeight != fLayoutData->previous_height && Label()) { // The height changed, which means the label has to move and we // probably also invalidate a part of the borders around the menu bar. @@ -654,8 +665,10 @@ BMenuField::SetDivider(float position) fMenuBar->MoveTo(_MenuBarOffset(), kVMargin); - if (fFixedSizeMB) + if (fFixedSizeMB) { fMenuBar->ResizeTo(_MenuBarWidth(), dirty.Height()); + fMenuBar->SetMaxContentWidth(_MenuBarWidth()); + } dirty = dirty | fMenuBar->Frame(); dirty.InsetBy(-kVMargin, -kVMargin); @@ -722,15 +735,7 @@ BMenuField::ResizeToPreferred() BView::ResizeToPreferred(); - if (fFixedSizeMB) { - // we have let the menubar resize itself, but - // in fixed size mode, the menubar is supposed to - // be at the right end of the view always. Since - // the menu bar is in follow left/right mode then, - // resizing ourselfs might have caused the menubar - // to be outside now - fMenuBar->ResizeTo(_MenuBarWidth(), fMenuBar->Frame().Height()); - } + Invalidate(); } ############################################################################ Commit: 0a04b14f8c477758ed64bcdf8aa93ccde45851d0 URL: http://cgit.haiku-os.org/haiku/commit/?id=0a04b14 Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu May 30 03:59:04 2013 UTC Backgrounds: Use layout workspaces menu field ---------------------------------------------------------------------------- diff --git a/src/preferences/backgrounds/BackgroundsView.cpp b/src/preferences/backgrounds/BackgroundsView.cpp index bcbe548..728d73e 100644 --- a/src/preferences/backgrounds/BackgroundsView.cpp +++ b/src/preferences/backgrounds/BackgroundsView.cpp @@ -150,8 +150,8 @@ BackgroundsView::BackgroundsView() B_TRANSLATE("Other folder" B_UTF8_ELLIPSIS), new BMessage(kMsgOtherFolder))); - BMenuField* workspaceMenuField = new BMenuField(BRect(0, 0, 130, 18), - "workspaceMenuField", NULL, fWorkspaceMenu, true); + BMenuField* workspaceMenuField = new BMenuField("workspaceMenuField", + NULL, fWorkspaceMenu); workspaceMenuField->ResizeToPreferred(); rightbox->SetLabel(workspaceMenuField); ############################################################################ Commit: f6d98e7b759b2fcb5a48cf5f747c012952c414f3 URL: http://cgit.haiku-os.org/haiku/commit/?id=f6d98e7 Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu May 30 04:00:19 2013 UTC File Panel: make room for icon in directory menu field ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/FilePanelPriv.cpp b/src/kits/tracker/FilePanelPriv.cpp index 70d8cc3..c7994fc 100644 --- a/src/kits/tracker/FilePanelPriv.cpp +++ b/src/kits/tracker/FilePanelPriv.cpp @@ -675,6 +675,8 @@ TFilePanel::Init(const BMessage*) fDirMenuField = new BMenuField(rect, "DirMenuField", "", fDirMenu); fDirMenuField->MenuBar()->SetFont(be_plain_font); fDirMenuField->SetDivider(0); + fDirMenuField->MenuBar()->SetMaxContentWidth(rect.Width() - 26.0f); + // Make room for the icon fDirMenuField->MenuBar()->RemoveItem((int32)0); fDirMenu->SetMenuBar(fDirMenuField->MenuBar()); ############################################################################ Commit: e9c1c3b70bc69d71e894f3ac531781b953d9dd57 URL: http://cgit.haiku-os.org/haiku/commit/?id=e9c1c3b Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu May 30 04:01:33 2013 UTC Chart: tweak menu field widths. Don't ResizeToPreferred() ---------------------------------------------------------------------------- diff --git a/src/tests/kits/game/chart/ChartWindow.cpp b/src/tests/kits/game/chart/ChartWindow.cpp index a319071..c75dc60 100644 --- a/src/tests/kits/game/chart/ChartWindow.cpp +++ b/src/tests/kits/game/chart/ChartWindow.cpp @@ -58,9 +58,9 @@ enum { H_BORDER = 5, V_BORDER = 2, ANIM_LABEL = 52, - ANIM_POPUP = 42, + ANIM_POPUP = 125, DISP_LABEL = 40, - DISP_POPUP = 42, + DISP_POPUP = 122, BUTTON_WIDTH = 50, BUTTON_OFFSET = -100, SPACE_LABEL = 40, @@ -518,12 +518,10 @@ ChartWindow::ChartWindow(BRect frame, const char *name) popup->SetFont(&font); popup->MenuBar()->SetFont(&font); popup->Menu()->SetFont(&font); - popup->ResizeToPreferred(); popup->SetDivider(popup->StringWidth(popup->Label()) + 4.0f); fTopView->AddChild(popup); - h += ANIM_LABEL + ANIM_POPUP + - popup->StringWidth(B_TRANSLATE("Slow rotation")); + h += ANIM_LABEL + ANIM_POPUP + H_BORDER; /* display mode popup */ menu = new BPopUpMenu(B_TRANSLATE("Off")); @@ -551,12 +549,10 @@ ChartWindow::ChartWindow(BRect frame, const char *name) popup->SetFont(&font); popup->MenuBar()->SetFont(&font); popup->Menu()->SetFont(&font); - popup->ResizeToPreferred(); popup->SetDivider(popup->StringWidth(popup->Label()) + 4.0f); fTopView->AddChild(popup); - h += DISP_LABEL + DISP_POPUP + - popup->StringWidth(B_TRANSLATE("DirectWindow")) + H_BORDER; + h += DISP_LABEL + DISP_POPUP + H_BORDER; /* create the offwindow (invisible) button on the left side. this will be used to record the content of the Picture ############################################################################ Revision: hrev45725 Commit: 14701d3ec941382b6c9543d9d15be7c5aecb1f6e URL: http://cgit.haiku-os.org/haiku/commit/?id=14701d3 Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu May 30 04:04:05 2013 UTC Font Demo: Tweak layout of menu fields. Need to add more height to the menu fields because we no longer resize them automatically for fixed size mode (for BeOS compat) and the text was shorter in BeOS. ---------------------------------------------------------------------------- diff --git a/src/apps/fontdemo/ControlView.cpp b/src/apps/fontdemo/ControlView.cpp index 80e069a..66d8c10 100644 --- a/src/apps/fontdemo/ControlView.cpp +++ b/src/apps/fontdemo/ControlView.cpp @@ -71,14 +71,14 @@ ControlView::AttachedToWindow() fTextControl = new BTextControl(rect, "TextInput", B_TRANSLATE("Text:"), B_TRANSLATE("Haiku, Inc."), NULL); - fTextControl->SetDivider(29.0); + fTextControl->SetDivider(36.0); fTextControl->SetModificationMessage(new BMessage(TEXT_CHANGED_MSG)); AddChild(fTextControl); rect.OffsetBy(0.0, 27.0); _AddFontMenu(rect); - rect.OffsetBy(0.0, 29.0); + rect.OffsetBy(0.0, 36.0); fFontsizeSlider = new BSlider(rect, "Fontsize", B_TRANSLATE("Size: 50"), NULL, 4, 360); fFontsizeSlider->SetModificationMessage(new BMessage(FONTSIZE_MSG)); @@ -122,59 +122,15 @@ ControlView::AttachedToWindow() fAliasingCheckBox->SetValue(B_CONTROL_ON); AddChild(fAliasingCheckBox); - rect.OffsetBy(0.0, offsetX); - fDrawingModeMenu = new BMenu("drawingmodemenu"); + rect.OffsetBy(0.0, 30.0f); + _AddDrawingModeMenu(rect); - BMessage* drawingMsg = NULL; - drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); - drawingMsg->AddInt32("_mode", B_OP_COPY); - fDrawingModeMenu->AddItem(new BMenuItem("B_OP_COPY", drawingMsg)); - fDrawingModeMenu->ItemAt(0)->SetMarked(true); - drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); - drawingMsg->AddInt32("_mode", B_OP_OVER); - fDrawingModeMenu->AddItem(new BMenuItem("B_OP_OVER", drawingMsg)); - drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); - drawingMsg->AddInt32("_mode", B_OP_ERASE); - fDrawingModeMenu->AddItem(new BMenuItem("B_OP_ERASE", drawingMsg)); - drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); - drawingMsg->AddInt32("_mode", B_OP_INVERT); - fDrawingModeMenu->AddItem(new BMenuItem("B_OP_INVERT", drawingMsg)); - drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); - drawingMsg->AddInt32("_mode", B_OP_ADD); - fDrawingModeMenu->AddItem(new BMenuItem("B_OP_ADD", drawingMsg)); - drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); - drawingMsg->AddInt32("_mode", B_OP_SUBTRACT); - fDrawingModeMenu->AddItem(new BMenuItem("B_OP_SUBTRACT", drawingMsg)); - drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); - drawingMsg->AddInt32("_mode", B_OP_BLEND); - fDrawingModeMenu->AddItem(new BMenuItem("B_OP_BLEND", drawingMsg)); - drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); - drawingMsg->AddInt32("_mode", B_OP_MIN); - fDrawingModeMenu->AddItem(new BMenuItem("B_OP_MIN", drawingMsg)); - drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); - drawingMsg->AddInt32("_mode", B_OP_MAX); - fDrawingModeMenu->AddItem(new BMenuItem("B_OP_MAX", drawingMsg)); - drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); - drawingMsg->AddInt32("_mode", B_OP_SELECT); - fDrawingModeMenu->AddItem(new BMenuItem("B_OP_SELECT", drawingMsg)); - drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); - drawingMsg->AddInt32("_mode", B_OP_ALPHA); - fDrawingModeMenu->AddItem(new BMenuItem("B_OP_ALPHA", drawingMsg)); - - fDrawingModeMenu->SetLabelFromMarked(true); - - BMenuField *drawingModeMenuField = new BMenuField(rect, "FontMenuField", - B_TRANSLATE("Drawing mode:"), fDrawingModeMenu, true); - drawingModeMenuField->SetDivider(5+StringWidth( - B_TRANSLATE("Drawing mode:"))); - AddChild(drawingModeMenuField); - - rect.OffsetBy(0.0, 22); + rect.OffsetBy(0.0, 30.0f); fBoundingboxesCheckBox = new BCheckBox(rect, "BoundingBoxes", B_TRANSLATE("Bounding boxes"), new BMessage(BOUNDING_BOX_MSG)); AddChild(fBoundingboxesCheckBox); - rect.OffsetBy(0.0, 22.0); + rect.OffsetBy(0.0, 30.0f); fCyclingFontButton = new BButton(rect, "Cyclefonts", B_TRANSLATE("Cycle fonts"), new BMessage(CYCLING_FONTS_MSG)); AddChild(fCyclingFontButton); @@ -472,14 +428,68 @@ ControlView::_AddFontMenu(BRect rect) _UpdateFontmenus(true); + rect.bottom += 4; fFontMenuField = new BMenuField(rect, "FontMenuField", B_TRANSLATE("Font:"), fFontFamilyMenu, true); - fFontMenuField->SetDivider(30.0); + fFontMenuField->SetDivider( + fFontMenuField->StringWidth(B_TRANSLATE("Font:")) + 5); AddChild(fFontMenuField); } void +ControlView::_AddDrawingModeMenu(BRect rect) +{ + fDrawingModeMenu = new BMenu("drawingmodemenu"); + + BMessage* drawingMsg = NULL; + drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); + drawingMsg->AddInt32("_mode", B_OP_COPY); + fDrawingModeMenu->AddItem(new BMenuItem("B_OP_COPY", drawingMsg)); + fDrawingModeMenu->ItemAt(0)->SetMarked(true); + drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); + drawingMsg->AddInt32("_mode", B_OP_OVER); + fDrawingModeMenu->AddItem(new BMenuItem("B_OP_OVER", drawingMsg)); + drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); + drawingMsg->AddInt32("_mode", B_OP_ERASE); + fDrawingModeMenu->AddItem(new BMenuItem("B_OP_ERASE", drawingMsg)); + drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); + drawingMsg->AddInt32("_mode", B_OP_INVERT); + fDrawingModeMenu->AddItem(new BMenuItem("B_OP_INVERT", drawingMsg)); + drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); + drawingMsg->AddInt32("_mode", B_OP_ADD); + fDrawingModeMenu->AddItem(new BMenuItem("B_OP_ADD", drawingMsg)); + drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); + drawingMsg->AddInt32("_mode", B_OP_SUBTRACT); + fDrawingModeMenu->AddItem(new BMenuItem("B_OP_SUBTRACT", drawingMsg)); + drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); + drawingMsg->AddInt32("_mode", B_OP_BLEND); + fDrawingModeMenu->AddItem(new BMenuItem("B_OP_BLEND", drawingMsg)); + drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); + drawingMsg->AddInt32("_mode", B_OP_MIN); + fDrawingModeMenu->AddItem(new BMenuItem("B_OP_MIN", drawingMsg)); + drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); + drawingMsg->AddInt32("_mode", B_OP_MAX); + fDrawingModeMenu->AddItem(new BMenuItem("B_OP_MAX", drawingMsg)); + drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); + drawingMsg->AddInt32("_mode", B_OP_SELECT); + fDrawingModeMenu->AddItem(new BMenuItem("B_OP_SELECT", drawingMsg)); + drawingMsg = new BMessage(DRAWINGMODE_CHANGED_MSG); + drawingMsg->AddInt32("_mode", B_OP_ALPHA); + fDrawingModeMenu->AddItem(new BMenuItem("B_OP_ALPHA", drawingMsg)); + + fDrawingModeMenu->SetLabelFromMarked(true); + + rect.bottom += 4; + BMenuField* drawingModeMenuField = new BMenuField(rect, "FontMenuField", + B_TRANSLATE("Drawing mode:"), fDrawingModeMenu, true); + drawingModeMenuField->SetDivider( + fDrawingModeMenu->StringWidth(B_TRANSLATE("Drawing mode:") + 5)); + AddChild(drawingModeMenuField); +} + + +void ControlView::_UpdateAndSendFamily(const BMessage* message) { _DeselectOldItems(); diff --git a/src/apps/fontdemo/ControlView.h b/src/apps/fontdemo/ControlView.h index ff1c0c9..0e347ed 100644 --- a/src/apps/fontdemo/ControlView.h +++ b/src/apps/fontdemo/ControlView.h @@ -36,6 +36,7 @@ class ControlView : public BView { private: void _AddFontMenu(BRect rect); + void _AddDrawingModeMenu(BRect rect); void _UpdateFontmenus(bool setInitialfont = false); void _DeselectOldItems(); diff --git a/src/apps/fontdemo/FontDemo.cpp b/src/apps/fontdemo/FontDemo.cpp index b809232..94206c4 100644 --- a/src/apps/fontdemo/FontDemo.cpp +++ b/src/apps/fontdemo/FontDemo.cpp @@ -29,7 +29,7 @@ FontDemo::FontDemo() FontDemoView* demoView = new FontDemoView(demoWindow->Bounds()); demoWindow->AddChild(demoView); - BWindow* controlWindow = new BWindow(BRect(500, 30, 700, 402), B_TRANSLATE("Controls"), + BWindow* controlWindow = new BWindow(BRect(500, 30, 700, 420), B_TRANSLATE("Controls"), B_FLOATING_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL, B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS);