* 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:
+29
-24
@@ -1652,9 +1652,8 @@ BMenu::_ComputeLayout(int32 index, bool bestFit, bool moveItems,
|
|||||||
// Recalculate only the needed items,
|
// Recalculate only the needed items,
|
||||||
// not the whole layout every time
|
// not the whole layout every time
|
||||||
|
|
||||||
BRect frame(0, 0, 0, 0);
|
BRect frame;
|
||||||
if (index > 0)
|
|
||||||
frame = Bounds();
|
|
||||||
switch (fLayout) {
|
switch (fLayout) {
|
||||||
case B_ITEMS_IN_COLUMN:
|
case B_ITEMS_IN_COLUMN:
|
||||||
_ComputeColumnLayout(index, bestFit, moveItems, frame);
|
_ComputeColumnLayout(index, bestFit, moveItems, frame);
|
||||||
@@ -1709,14 +1708,20 @@ BMenu::_ComputeColumnLayout(int32 index, bool bestFit, bool moveItems,
|
|||||||
bool command = false;
|
bool command = false;
|
||||||
bool control = false;
|
bool control = false;
|
||||||
bool shift = false;
|
bool shift = false;
|
||||||
for (int32 i = index; i < fItems.CountItems(); i++) {
|
|
||||||
BMenuItem *item = ItemAt(i);
|
if (index > 0)
|
||||||
if (item != NULL) {
|
frame = ItemAt(index - 1)->Frame();
|
||||||
float iWidth, iHeight;
|
else
|
||||||
item->GetContentSize(&iWidth, &iHeight);
|
frame.Set(0, 0, 0, 0);
|
||||||
|
|
||||||
|
for (; index < fItems.CountItems(); index++) {
|
||||||
|
BMenuItem *item = ItemAt(index);
|
||||||
|
|
||||||
|
float width, height;
|
||||||
|
item->GetContentSize(&width, &height);
|
||||||
|
|
||||||
if (item->fModifiers && item->fShortcutChar) {
|
if (item->fModifiers && item->fShortcutChar) {
|
||||||
iWidth += font.Size();
|
width += font.Size();
|
||||||
if (item->fModifiers & B_COMMAND_KEY)
|
if (item->fModifiers & B_COMMAND_KEY)
|
||||||
command = true;
|
command = true;
|
||||||
if (item->fModifiers & B_CONTROL_KEY)
|
if (item->fModifiers & B_CONTROL_KEY)
|
||||||
@@ -1726,15 +1731,14 @@ BMenu::_ComputeColumnLayout(int32 index, bool bestFit, bool moveItems,
|
|||||||
}
|
}
|
||||||
|
|
||||||
item->fBounds.left = 0.0f;
|
item->fBounds.left = 0.0f;
|
||||||
item->fBounds.top = frame.bottom;
|
item->fBounds.top = frame.bottom + (index > 0 ? 1.0f : 0.0f);
|
||||||
item->fBounds.bottom = item->fBounds.top + iHeight + fPad.top
|
item->fBounds.bottom = item->fBounds.top + height + fPad.top
|
||||||
+ fPad.bottom;
|
+ fPad.bottom;
|
||||||
|
|
||||||
iWidth += item->Frame().Height();
|
width += item->Frame().Height();
|
||||||
|
|
||||||
frame.right = max_c(frame.right, iWidth + fPad.left + fPad.right);
|
frame.right = max_c(frame.right, width + fPad.left + fPad.right);
|
||||||
frame.bottom = item->fBounds.bottom + 1.0f;
|
frame.bottom = item->fBounds.bottom;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command)
|
if (command)
|
||||||
@@ -1751,8 +1755,9 @@ BMenu::_ComputeColumnLayout(int32 index, bool bestFit, bool moveItems,
|
|||||||
for (int32 i = 0; i < fItems.CountItems(); i++)
|
for (int32 i = 0; i < fItems.CountItems(); i++)
|
||||||
ItemAt(i)->fBounds.right = frame.right;
|
ItemAt(i)->fBounds.right = frame.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frame.top = 0;
|
||||||
frame.right = ceilf(frame.right);
|
frame.right = ceilf(frame.right);
|
||||||
frame.bottom--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1762,22 +1767,22 @@ BMenu::_ComputeRowLayout(int32 index, bool bestFit, bool moveItems,
|
|||||||
{
|
{
|
||||||
font_height fh;
|
font_height fh;
|
||||||
GetFontHeight(&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));
|
+ fPad.bottom));
|
||||||
|
|
||||||
for (int32 i = 0; i < fItems.CountItems(); i++) {
|
for (int32 i = 0; i < fItems.CountItems(); i++) {
|
||||||
BMenuItem *item = ItemAt(i);
|
BMenuItem *item = ItemAt(i);
|
||||||
float iWidth, iHeight;
|
float width, height;
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
item->GetContentSize(&iWidth, &iHeight);
|
item->GetContentSize(&width, &height);
|
||||||
|
|
||||||
item->fBounds.left = frame.right;
|
item->fBounds.left = frame.right;
|
||||||
item->fBounds.top = 0.0f;
|
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;
|
+ fPad.right;
|
||||||
|
|
||||||
frame.right = item->Frame().right + 1.0f;
|
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);
|
frame.OffsetBy(0, screenFrame.bottom - frame.bottom);
|
||||||
} else {
|
} else {
|
||||||
if (frame.bottom > screenFrame.bottom) {
|
if (frame.bottom > screenFrame.bottom) {
|
||||||
if (scrollOn != NULL && superMenu != NULL &&
|
if (scrollOn != NULL && superMenu != NULL
|
||||||
dynamic_cast<BMenuBar *>(superMenu) != NULL &&
|
&& dynamic_cast<BMenuBar *>(superMenu) != NULL
|
||||||
frame.top < (screenFrame.bottom - 80)) {
|
&& frame.top < (screenFrame.bottom - 80)) {
|
||||||
*scrollOn = true;
|
*scrollOn = true;
|
||||||
} else {
|
} else {
|
||||||
frame.OffsetBy(0, -superItem->Frame().Height() - frame.Height() - 3);
|
frame.OffsetBy(0, -superItem->Frame().Height() - frame.Height() - 3);
|
||||||
|
|||||||
Reference in New Issue
Block a user