diff options
Diffstat (limited to 'indra/llui/llmenugl.cpp')
-rw-r--r-- | indra/llui/llmenugl.cpp | 101 |
1 files changed, 86 insertions, 15 deletions
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index cd6cc6a75e..b7148bb91b 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -1751,35 +1751,50 @@ void LLMenuGL::setCanTearOff(BOOL tear_off) bool LLMenuGL::addChild(LLView* view, S32 tab_group) { - if (LLMenuGL* menup = dynamic_cast<LLMenuGL*>(view)) + LLMenuGL* menup = dynamic_cast<LLMenuGL*>(view); + if (menup) { - appendMenu(menup); - return true; + return appendMenu(menup); } - else if (LLMenuItemGL* itemp = dynamic_cast<LLMenuItemGL*>(view)) + + LLMenuItemGL* itemp = dynamic_cast<LLMenuItemGL*>(view); + if (itemp) { - append(itemp); - return true; + return append(itemp); } + return false; } // Used in LLContextMenu and in LLTogleableMenu -// to add an item of context menu branch + +// Add an item to the context menu branch bool LLMenuGL::addContextChild(LLView* view, S32 tab_group) { LLContextMenu* context = dynamic_cast<LLContextMenu*>(view); if (context) + { return appendContextSubMenu(context); + } LLMenuItemSeparatorGL* separator = dynamic_cast<LLMenuItemSeparatorGL*>(view); if (separator) + { return append(separator); + } LLMenuItemGL* item = dynamic_cast<LLMenuItemGL*>(view); if (item) + { return append(item); - + } + + LLMenuGL* menup = dynamic_cast<LLMenuGL*>(view); + if (menup) + { + return appendMenu(menup); + } + return false; } @@ -2446,6 +2461,56 @@ void LLMenuGL::empty( void ) deleteAllChildren(); } +// erase group of items from menu +void LLMenuGL::erase( S32 begin, S32 end, bool arrange/* = true*/) +{ + S32 items = mItems.size(); + + if ( items == 0 || begin >= end || begin < 0 || end > items ) + { + return; + } + + item_list_t::iterator start_position = mItems.begin(); + std::advance(start_position, begin); + + item_list_t::iterator end_position = mItems.begin(); + std::advance(end_position, end); + + for (item_list_t::iterator position_iter = start_position; position_iter != end_position; position_iter++) + { + LLUICtrl::removeChild(*position_iter); + } + + mItems.erase(start_position, end_position); + + if (arrange) + { + needsArrange(); + } +} + +// add new item at position +void LLMenuGL::insert( S32 position, LLView * ctrl, bool arrange /*= true*/ ) +{ + LLMenuItemGL * item = dynamic_cast<LLMenuItemGL *>(ctrl); + + if (NULL == item || position < 0 || position >= mItems.size()) + { + return; + } + + item_list_t::iterator position_iter = mItems.begin(); + std::advance(position_iter, position); + mItems.insert(position_iter, item); + LLUICtrl::addChild(item); + + if (arrange) + { + needsArrange(); + } +} + // Adjust rectangle of the menu void LLMenuGL::setLeftAndBottom(S32 left, S32 bottom) { @@ -2487,7 +2552,8 @@ BOOL LLMenuGL::append( LLMenuItemGL* item ) // add a separator to this menu BOOL LLMenuGL::addSeparator() { - LLMenuItemGL* separator = new LLMenuItemSeparatorGL(); + LLMenuItemSeparatorGL::Params p; + LLMenuItemGL* separator = LLUICtrlFactory::create<LLMenuItemSeparatorGL>(p); return addChild(separator); } @@ -3080,7 +3146,17 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y) const S32 CURSOR_HEIGHT = 22; // Approximate "normal" cursor size const S32 CURSOR_WIDTH = 12; - if(menu->getChildList()->empty()) + //Do not show menu if all menu items are disabled + BOOL item_enabled = false; + for (LLView::child_list_t::const_iterator itor = menu->getChildList()->begin(); + itor != menu->getChildList()->end(); + ++itor) + { + LLView *menu_item = (*itor); + item_enabled = item_enabled || menu_item->getEnabled(); + } + + if(menu->getChildList()->empty() || !item_enabled) { return; } @@ -4039,11 +4115,6 @@ BOOL LLContextMenu::handleRightMouseUp( S32 x, S32 y, MASK mask ) return result; } -void LLContextMenu::draw() -{ - LLMenuGL::draw(); -} - bool LLContextMenu::addChild(LLView* view, S32 tab_group) { return addContextChild(view, tab_group); |