MAINT-4437 FIXED Spillover Branch shows when it should not

meow-7.2.2
andreykproductengine 2014-09-15 20:29:36 +03:00
parent d61a8e34a3
commit eebb94159e
1 changed files with 37 additions and 36 deletions

View File

@ -60,6 +60,7 @@
#include "v2math.h"
#include <set>
#include <boost/tokenizer.hpp>
#include <boost/foreach.hpp>
// static
LLMenuHolderGL *LLMenuGL::sMenuContainer = NULL;
@ -2038,15 +2039,7 @@ void LLMenuGL::arrange( void )
// torn off menus are not constrained to the size of the screen
U32 max_width = getTornOff() ? U32_MAX : menu_region_rect.getWidth();
U32 max_height = U32_MAX;
if (!getTornOff())
{
max_height = getRect().mTop - menu_region_rect.mBottom;
if (menu_region_rect.mTop - getRect().mTop > (S32)max_height)
{
max_height = menu_region_rect.mTop - getRect().mTop;
}
}
U32 max_height = getTornOff() ? U32_MAX: menu_region_rect.getHeight();
// *FIX: create the item first and then ask for its dimensions?
S32 spillover_item_width = PLAIN_PAD_PIXELS + LLFontGL::getFontSansSerif()->getWidth( std::string("More") ); // *TODO: Translate
@ -2104,13 +2097,15 @@ void LLMenuGL::arrange( void )
}
else
{
BOOST_FOREACH(LLMenuItemGL* itemp, mItems)
{
// do first so LLMenuGLItemCall can call on_visible to determine if visible
itemp->buildDrawLabel();
}
item_list_t::iterator item_iter;
for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter)
{
// do first so LLMenuGLItemCall can call on_visible to determine if visible
(*item_iter)->buildDrawLabel();
if ((*item_iter)->getVisible())
{
if (!getTornOff()
@ -2118,34 +2113,40 @@ void LLMenuGL::arrange( void )
&& *item_iter != mSpilloverBranch
&& height + (*item_iter)->getNominalHeight() > max_height - spillover_item_height)
{
// no room for any more items
createSpilloverBranch();
std::vector<LLMenuItemGL*> items_to_remove;
std::copy(item_iter, mItems.end(), std::back_inserter(items_to_remove));
std::vector<LLMenuItemGL*>::iterator spillover_iter;
for (spillover_iter= items_to_remove.begin(); spillover_iter != items_to_remove.end(); ++spillover_iter)
// don't show only one item
int visible_items = std::count_if(item_iter, mItems.end(), [](LLMenuItemGL* itemp)
{
LLMenuItemGL* itemp = (*spillover_iter);
removeChild(itemp);
mSpilloverMenu->addChild(itemp);
return itemp->getVisible();
});
if (visible_items>1)
{
// no room for any more items
createSpilloverBranch();
std::vector<LLMenuItemGL*> items_to_remove;
std::copy(item_iter, mItems.end(), std::back_inserter(items_to_remove));
std::vector<LLMenuItemGL*>::iterator spillover_iter;
for (spillover_iter= items_to_remove.begin(); spillover_iter != items_to_remove.end(); ++spillover_iter)
{
LLMenuItemGL* itemp = (*spillover_iter);
removeChild(itemp);
mSpilloverMenu->addChild(itemp);
}
addChild(mSpilloverBranch);
height += mSpilloverBranch->getNominalHeight();
width = llmax( width, mSpilloverBranch->getNominalWidth() );
break;
}
addChild(mSpilloverBranch);
height += mSpilloverBranch->getNominalHeight();
width = llmax( width, mSpilloverBranch->getNominalWidth() );
break;
}
else
{
// track our rect
height += (*item_iter)->getNominalHeight();
width = llmax( width, (*item_iter)->getNominalWidth() );
}
// track our rect
height += (*item_iter)->getNominalHeight();
width = llmax( width, (*item_iter)->getNominalWidth() );
if (mScrollable)
{
// Determining visible items boundaries