From 14fd78a5afab1317342ab831b6636f8b2e6061f6 Mon Sep 17 00:00:00 2001 From: Lirusaito Date: Sun, 15 Jul 2018 09:01:26 -0400 Subject: [PATCH] Do the scroll list menu thing more cleanly. --- indra/llui/llscrolllistctrl.cpp | 4 ++-- indra/llui/llscrolllistctrl.h | 4 ++++ indra/newview/llviewermenu.cpp | 5 ++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 15d1345ef..4e1531831 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -57,7 +57,7 @@ static LLRegisterWidget r("scroll_list"); -LLMenuGL* sScrollListMenus[1] = {}; // List menus that recur, such as general avatars or groups menus +std::vector LLScrollListCtrl::sMenus = {}; // List menus that recur, such as general avatars or groups menus // local structures & classes. struct SortScrollListItem @@ -2576,7 +2576,7 @@ void LLScrollListCtrl::setScrollListParameters(LLXMLNodePtr node) // 0 is menu_avs_list.xml, 1 will be for groups, 2 could be for lists of objects S32 menu_num; node->getAttributeS32("menu_num", menu_num); - mPopupMenu = sScrollListMenus[menu_num]; + setContextMenu(menu_num); } else if (node->hasAttribute("menu_file")) { diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h index b4dca4fc0..5c914ee17 100644 --- a/indra/llui/llscrolllistctrl.h +++ b/indra/llui/llscrolllistctrl.h @@ -250,6 +250,8 @@ public: // support right-click context menus for avatar/group lists void setContextMenu(LLMenuGL* menu) { mPopupMenu = menu; } + void setContextMenu(S32 index) { mPopupMenu = sMenus[index]; } + static void addCommonMenu(LLMenuGL* menu) { sMenus.push_back(menu); } // Overridden from LLView /*virtual*/ void draw(); @@ -456,6 +458,8 @@ private: S32 mHighlightedItem; class LLViewBorder* mBorder; LLMenuGL *mPopupMenu; + + static std::vector sMenus; // List menus that recur, such as general avatars or groups menus LLView *mCommentTextView; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 81f58aeed..742d5f7d6 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -192,7 +192,6 @@ extern BOOL gDebugTextEditorTips; extern BOOL gShowOverlayTitle; extern BOOL gOcclusionCull; extern AIHTTPView* gHttpView; -extern LLMenuGL* sScrollListMenus[1]; // // Globals // @@ -730,8 +729,8 @@ void init_menus() gMenuHolder->addChild(gLoginMenuBarView); // Singu Note: Initialize common ScrollListMenus here - sScrollListMenus[0] = LLUICtrlFactory::getInstance()->buildMenu("menu_avs_list.xml", gMenuHolder); - //sScrollListMenus[1] = LLUICtrlFactory::getInstance()->buildMenu("menu_groups_list.xml"); // Singu TODO + LLScrollListCtrl::addCommonMenu(LLUICtrlFactory::getInstance()->buildMenu("menu_avs_list.xml", gMenuHolder)); // 0 + //LLScrollListCtrl::addCommonMenu(LLUICtrlFactory::getInstance()->buildMenu("menu_groups_list.xml")); // 1 // Singu TODO LLView* ins = gMenuBarView->getChildView("insert_world", true, false); ins->setVisible(false);