summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Savchuk <vsavchuk@productengine.com>2010-06-11 17:19:40 +0300
committerVadim Savchuk <vsavchuk@productengine.com>2010-06-11 17:19:40 +0300
commiteb1929c8f97f256264cac620871e4b498d985d68 (patch)
treef507a60687520272be439981d43d1a311afa364c
parent5ec3357a6ccf6b6f05d99105db8f510fd395f043 (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
-rw-r--r--indra/newview/llpaneloutfitsinventory.cpp67
-rw-r--r--indra/newview/skins/default/xui/en/menu_outfit_gear.xml16
2 files changed, 61 insertions, 22 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()
diff --git a/indra/newview/skins/default/xui/en/menu_outfit_gear.xml b/indra/newview/skins/default/xui/en/menu_outfit_gear.xml
index c4e31ed180..8e7ef7f0b5 100644
--- a/indra/newview/skins/default/xui/en/menu_outfit_gear.xml
+++ b/indra/newview/skins/default/xui/en/menu_outfit_gear.xml
@@ -11,6 +11,9 @@
<on_enable
function="Gear.OnEnable"
parameter="wear" />
+ <on_visible
+ function="Gear.OnVisible"
+ parameter="wear" />
</menu_item_call>
<menu_item_call
label="Take Off - Remove from Current Outfit"
@@ -21,9 +24,12 @@
<on_enable
function="Gear.OnEnable"
parameter="take_off" />
+ <on_visible
+ function="Gear.OnVisible"
+ parameter="take_off" />
</menu_item_call>
- <menu_item_separator />
+ <menu_item_separator name="sepatator1" />
<!-- copied (with minor modifications) from menu_inventory_add.xml -->
<!-- *TODO: generate dynamically? -->
<menu
@@ -168,7 +174,7 @@
</menu>
<!-- copied from menu_inventory_add.xml -->
- <menu_item_separator />
+ <menu_item_separator name="sepatator2" />
<menu_item_call
label="Rename Outfit"
layout="topleft"
@@ -178,6 +184,9 @@
<on_enable
function="Gear.OnEnable"
parameter="rename" />
+ <on_visible
+ function="Gear.OnVisible"
+ parameter="rename" />
</menu_item_call>
<menu_item_call
label="Delete Outfit"
@@ -188,5 +197,8 @@
<on_enable
function="Gear.OnEnable"
parameter="delete" />
+ <on_visible
+ function="Gear.OnVisible"
+ parameter="delete" />
</menu_item_call>
</menu>