From 84b7e122328acc208f32698d1f29ed0737e6d4df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 16 Apr 2009 09:38:03 +0000 Subject: [PATCH] Both BTextControl and BMenuField layout the inner control at divider + frame width. BTextControl was even calculating it like this everywhere, but then layouted like BMenuField. Now it's consistent and much easier to align other controls with the text view or menu bar layout item. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30190 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/MenuField.cpp | 15 ++++----------- src/kits/interface/TextControl.cpp | 6 +++--- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index 4bf8b24735..3801b7446b 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -833,7 +833,7 @@ BMenuField::DoLayout() // menu bar BRect dirty(fMenuBar->Frame()); - BRect menuBarFrame(divider + 1, kVMargin, size.width - 2, + BRect menuBarFrame(divider + kVMargin, kVMargin, size.width - kVMargin, size.height - kVMargin); // place the menu bar and set the divider @@ -1104,14 +1104,8 @@ BMenuField::_ValidateLayoutData() TRACE("menu bar min width: %.2f\n", fLayoutData->menu_bar_min.width); // compute our minimal (== preferred) size - // TODO: The layout is a bit broken. A one pixel wide border is drawn - // around the menu bar to give it it's look. When the view has the focus, - // additionally a one pixel wide blue frame is drawn around it. In order - // to be able to easily visually align the menu bar with the text view of - // a text control, the divider must ignore the focus frame, though. Hence - // we add one less pixel to our width. BSize min(fLayoutData->menu_bar_min); - min.width += 2 * kVMargin - 1; + min.width += 2 * kVMargin; min.height += 2 * kVMargin; if (divider > 0) @@ -1131,7 +1125,7 @@ BMenuField::_ValidateLayoutData() float BMenuField::_MenuBarOffset() const { - return max_c(kVMargin, fDivider + 1); + return max_c(kVMargin, fDivider + kVMargin); } @@ -1276,9 +1270,8 @@ BMenuField::MenuBarLayoutItem::BaseMinSize() { fParent->_ValidateLayoutData(); - // TODO: Cf. the TODO in _ValidateLayoutData(). BSize size = fParent->fLayoutData->menu_bar_min; - size.width += 2 * kVMargin - 1; + size.width += 2 * kVMargin; size.height += 2 * kVMargin; return size; diff --git a/src/kits/interface/TextControl.cpp b/src/kits/interface/TextControl.cpp index 7a8e2b57cf..2eb28498ce 100644 --- a/src/kits/interface/TextControl.cpp +++ b/src/kits/interface/TextControl.cpp @@ -831,8 +831,8 @@ BTextControl::DoLayout() // text view BRect dirty(fText->Frame()); - BRect textFrame(divider + 1, kFrameMargin, size.width - 2, - size.height - kFrameMargin); + BRect textFrame(divider + kFrameMargin, kFrameMargin, + size.width - kFrameMargin, size.height - kFrameMargin); // place the text view and set the divider BLayoutUtils::AlignInFrame(fText, textFrame); @@ -1030,7 +1030,7 @@ BTextControl::_LayoutTextView() frame.left = fDivider; // we are stroking the frame around the text view, which // is 2 pixels wide - frame.InsetBy(2.0, 2.0); + frame.InsetBy(kFrameMargin, kFrameMargin); fText->MoveTo(frame.left, frame.top); fText->ResizeTo(frame.Width(), frame.Height()); fText->AlignTextRect();