diff options
author | andreykproductengine <akleshchev@productengine.com> | 2014-09-15 20:29:36 +0300 |
---|---|---|
committer | andreykproductengine <akleshchev@productengine.com> | 2014-09-15 20:29:36 +0300 |
commit | eebb94159e061ec90e8dc1387a0de8f7a0733217 (patch) | |
tree | 950916410722f5c949039ef6936fae907cf93024 /indra | |
parent | d61a8e34a3d81e5de02bf997ba6df055217af937 (diff) |
MAINT-4437 FIXED Spillover Branch shows when it should not
Diffstat (limited to 'indra')
-rwxr-xr-x | indra/llui/llmenugl.cpp | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 3e6002e546..cb0b75ea48 100755 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -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() ); + addChild(mSpilloverBranch); - break; - } - else - { - // track our rect - height += (*item_iter)->getNominalHeight(); - width = llmax( width, (*item_iter)->getNominalWidth() ); + height += mSpilloverBranch->getNominalHeight(); + width = llmax( width, mSpilloverBranch->getNominalWidth() ); + + break; + } } + // track our rect + height += (*item_iter)->getNominalHeight(); + width = llmax( width, (*item_iter)->getNominalWidth() ); + if (mScrollable) { // Determining visible items boundaries |