diff options
author | Vadim Savchuk <vsavchuk@productengine.com> | 2010-06-11 17:19:40 +0300 |
---|---|---|
committer | Vadim Savchuk <vsavchuk@productengine.com> | 2010-06-11 17:19:40 +0300 |
commit | eb1929c8f97f256264cac620871e4b498d985d68 (patch) | |
tree | f507a60687520272be439981d43d1a311afa364c /indra/newview/llpaneloutfitsinventory.cpp | |
parent | 5ec3357a6ccf6b6f05d99105db8f510fd395f043 (diff) |
EXT-6726 WIP Improved the way we disable irrelevant items of the My Outfits gear menu.
* Made the "Wear" and "Take Off" items mutually exclusive (i.e. only one of them is now shown).
* Hide all context-dependant items ("Wear", "Take off", "Rename", "Delete") when no outfit selected.
Reviewed by Mike Antipov at https://codereview.productengine.com/secondlife/r/566/
--HG--
branch : product-engine
Diffstat (limited to 'indra/newview/llpaneloutfitsinventory.cpp')
-rw-r--r-- | indra/newview/llpaneloutfitsinventory.cpp | 67 |
1 files changed, 47 insertions, 20 deletions
diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp index 1286642897..b5cffd84b3 100644 --- a/indra/newview/llpaneloutfitsinventory.cpp +++ b/indra/newview/llpaneloutfitsinventory.cpp @@ -91,6 +91,7 @@ public: registrar.add("Gear.Create", boost::bind(&LLOutfitListGearMenu::onCreate, this, _2)); enable_registrar.add("Gear.OnEnable", boost::bind(&LLOutfitListGearMenu::onEnable, this, _2)); + enable_registrar.add("Gear.OnVisible", boost::bind(&LLOutfitListGearMenu::onVisible, this, _2)); mMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>( "menu_outfit_gear.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); @@ -99,6 +100,28 @@ public: LLMenuGL* getMenu() { return mMenu; } + void show(LLView* spawning_view) + { + if (!mMenu) return; + + updateItemsVisibility(); + mMenu->buildDrawLabels(); + mMenu->updateParent(LLMenuGL::sMenuContainer); + S32 menu_x = 0; + S32 menu_y = spawning_view->getRect().getHeight() + mMenu->getRect().getHeight(); + LLMenuGL::showPopup(spawning_view, mMenu, menu_x, menu_y); + } + + void updateItemsVisibility() + { + if (!mMenu) return; + + bool have_selection = getSelectedOutfitID().notNull(); + mMenu->setItemVisible("sepatator1", have_selection); + mMenu->setItemVisible("sepatator2", have_selection); + mMenu->arrangeAndClear(); // update menu height + } + private: const LLUUID& getSelectedOutfitID() { @@ -174,6 +197,26 @@ private: return false; } + if ("rename" == param) + { + return get_is_category_renameable(&gInventory, selected_outfit_id); + } + else if ("delete" == param) + { + return LLAppearanceMgr::instance().getCanRemoveOutfit(selected_outfit_id); + } + + return true; + } + + bool onVisible(LLSD::String param) + { + const LLUUID& selected_outfit_id = getSelectedOutfitID(); + if (selected_outfit_id.isNull()) // no selection or invalid outfit selected + { + return false; + } + bool is_worn = LLAppearanceMgr::instance().getBaseOutfitUUID() == selected_outfit_id; if ("wear" == param) @@ -184,14 +227,6 @@ private: { return is_worn; } - else if ("rename" == param) - { - return get_is_category_renameable(&gInventory, selected_outfit_id); - } - else if ("delete" == param) - { - return LLAppearanceMgr::instance().getCanRemoveOutfit(selected_outfit_id); - } return true; } @@ -538,18 +573,10 @@ void LLPanelOutfitsInventory::updateListCommands() void LLPanelOutfitsInventory::showGearMenu() { - LLMenuGL* menu = mGearMenu ? mGearMenu->getMenu() : NULL; - if (menu) - { - menu->buildDrawLabels(); - menu->updateParent(LLMenuGL::sMenuContainer); - LLView* spawning_view = getChild<LLView>("options_gear_btn"); - S32 menu_x, menu_y; - //show menu in co-ordinates of panel - spawning_view->localPointToOtherView(0, spawning_view->getRect().getHeight(), &menu_x, &menu_y, this); - menu_y += menu->getRect().getHeight(); - LLMenuGL::showPopup(this, menu, menu_x, menu_y); - } + if (!mGearMenu) return; + + LLView* spawning_view = getChild<LLView>("options_gear_btn"); + mGearMenu->show(spawning_view); } void LLPanelOutfitsInventory::onTrashButtonClick() |