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
meow-7.2.2
Vadim Savchuk 2010-06-11 17:19:40 +03:00
parent 5ec3357a6c
commit eb1929c8f9
2 changed files with 61 additions and 22 deletions

View File

@ -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()

View File

@ -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>