* Fixed _ComputeColumnLayout() optimization introduced in r22658: it actually

never worked correctly for any case which was very visible in Tracker (and
  especially so if you had "sorting apps" turned on).
* Removed superfluous white space at the end of lines.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22850 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-11-07 14:24:09 +00:00
parent afd60167e3
commit 82a54995b5
+38 -33
View File
@@ -1652,9 +1652,8 @@ BMenu::_ComputeLayout(int32 index, bool bestFit, bool moveItems,
// Recalculate only the needed items,
// not the whole layout every time
BRect frame(0, 0, 0, 0);
if (index > 0)
frame = Bounds();
BRect frame;
switch (fLayout) {
case B_ITEMS_IN_COLUMN:
_ComputeColumnLayout(index, bestFit, moveItems, frame);
@@ -1709,32 +1708,37 @@ BMenu::_ComputeColumnLayout(int32 index, bool bestFit, bool moveItems,
bool command = false;
bool control = false;
bool shift = false;
for (int32 i = index; i < fItems.CountItems(); i++) {
BMenuItem *item = ItemAt(i);
if (item != NULL) {
float iWidth, iHeight;
item->GetContentSize(&iWidth, &iHeight);
if (item->fModifiers && item->fShortcutChar) {
iWidth += font.Size();
if (item->fModifiers & B_COMMAND_KEY)
command = true;
if (item->fModifiers & B_CONTROL_KEY)
control = true;
if (item->fModifiers & B_SHIFT_KEY)
shift = true;
}
if (index > 0)
frame = ItemAt(index - 1)->Frame();
else
frame.Set(0, 0, 0, 0);
item->fBounds.left = 0.0f;
item->fBounds.top = frame.bottom;
item->fBounds.bottom = item->fBounds.top + iHeight + fPad.top
+ fPad.bottom;
for (; index < fItems.CountItems(); index++) {
BMenuItem *item = ItemAt(index);
iWidth += item->Frame().Height();
float width, height;
item->GetContentSize(&width, &height);
frame.right = max_c(frame.right, iWidth + fPad.left + fPad.right);
frame.bottom = item->fBounds.bottom + 1.0f;
if (item->fModifiers && item->fShortcutChar) {
width += font.Size();
if (item->fModifiers & B_COMMAND_KEY)
command = true;
if (item->fModifiers & B_CONTROL_KEY)
control = true;
if (item->fModifiers & B_SHIFT_KEY)
shift = true;
}
item->fBounds.left = 0.0f;
item->fBounds.top = frame.bottom + (index > 0 ? 1.0f : 0.0f);
item->fBounds.bottom = item->fBounds.top + height + fPad.top
+ fPad.bottom;
width += item->Frame().Height();
frame.right = max_c(frame.right, width + fPad.left + fPad.right);
frame.bottom = item->fBounds.bottom;
}
if (command)
@@ -1751,8 +1755,9 @@ BMenu::_ComputeColumnLayout(int32 index, bool bestFit, bool moveItems,
for (int32 i = 0; i < fItems.CountItems(); i++)
ItemAt(i)->fBounds.right = frame.right;
}
frame.top = 0;
frame.right = ceilf(frame.right);
frame.bottom--;
}
@@ -1762,22 +1767,22 @@ BMenu::_ComputeRowLayout(int32 index, bool bestFit, bool moveItems,
{
font_height fh;
GetFontHeight(&fh);
frame = BRect(0.0f, 0.0f, 0.0f, ceilf(fh.ascent + fh.descent + fPad.top
frame.Set(0.0f, 0.0f, 0.0f, ceilf(fh.ascent + fh.descent + fPad.top
+ fPad.bottom));
for (int32 i = 0; i < fItems.CountItems(); i++) {
BMenuItem *item = ItemAt(i);
float iWidth, iHeight;
float width, height;
if (item != NULL) {
item->GetContentSize(&iWidth, &iHeight);
item->GetContentSize(&width, &height);
item->fBounds.left = frame.right;
item->fBounds.top = 0.0f;
item->fBounds.right = item->fBounds.left + iWidth + fPad.left
item->fBounds.right = item->fBounds.left + width + fPad.left
+ fPad.right;
frame.right = item->Frame().right + 1.0f;
frame.bottom = max_c(frame.bottom, iHeight + fPad.top + fPad.bottom);
frame.bottom = max_c(frame.bottom, height + fPad.top + fPad.bottom);
}
}
@@ -1883,9 +1888,9 @@ BMenu::_CalcFrame(BPoint where, bool *scrollOn)
frame.OffsetBy(0, screenFrame.bottom - frame.bottom);
} else {
if (frame.bottom > screenFrame.bottom) {
if (scrollOn != NULL && superMenu != NULL &&
dynamic_cast<BMenuBar *>(superMenu) != NULL &&
frame.top < (screenFrame.bottom - 80)) {
if (scrollOn != NULL && superMenu != NULL
&& dynamic_cast<BMenuBar *>(superMenu) != NULL
&& frame.top < (screenFrame.bottom - 80)) {
*scrollOn = true;
} else {
frame.OffsetBy(0, -superItem->Frame().Height() - frame.Height() - 3);