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
This commit is contained in:
Stephan Aßmus
2009-04-16 09:38:03 +00:00
parent 699451e6f9
commit 84b7e12232
2 changed files with 7 additions and 14 deletions
+4 -11
View File
@@ -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;
+3 -3
View File
@@ -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();