summaryrefslogtreecommitdiff
path: root/indra/newview/llwearableitemslist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llwearableitemslist.cpp')
-rw-r--r--indra/newview/llwearableitemslist.cpp198
1 files changed, 148 insertions, 50 deletions
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index 9f9a9bef35..35abbc0c4d 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -85,8 +85,8 @@ void LLPanelWearableListItem::onMouseLeave(S32 x, S32 y, MASK mask)
reshapeWidgets();
}
-LLPanelWearableListItem::LLPanelWearableListItem(LLViewerInventoryItem* item)
-: LLPanelInventoryListItemBase(item)
+LLPanelWearableListItem::LLPanelWearableListItem(LLViewerInventoryItem* item, const LLPanelWearableListItem::Params& params)
+: LLPanelInventoryListItemBase(item, params)
{
}
@@ -101,15 +101,19 @@ LLPanelWearableOutfitItem* LLPanelWearableOutfitItem::create(LLViewerInventoryIt
LLPanelWearableOutfitItem* list_item = NULL;
if (item)
{
- list_item = new LLPanelWearableOutfitItem(item, worn_indication_enabled);
- list_item->init();
+ const LLPanelInventoryListItemBase::Params& params = LLUICtrlFactory::getDefaultParams<LLPanelInventoryListItemBase>();
+
+ list_item = new LLPanelWearableOutfitItem(item, worn_indication_enabled, params);
+ list_item->initFromParams(params);
+ list_item->postBuild();
}
return list_item;
}
LLPanelWearableOutfitItem::LLPanelWearableOutfitItem(LLViewerInventoryItem* item,
- bool worn_indication_enabled)
-: LLPanelInventoryListItemBase(item)
+ bool worn_indication_enabled,
+ const LLPanelWearableOutfitItem::Params& params)
+: LLPanelInventoryListItemBase(item, params)
, mWornIndicationEnabled(worn_indication_enabled)
{
}
@@ -132,6 +136,17 @@ void LLPanelWearableOutfitItem::updateItem(const std::string& name,
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
+static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelClothingListItem(&typeid(LLPanelClothingListItem::Params), "clothing_list_item");
+
+
+LLPanelClothingListItem::Params::Params()
+: up_btn("up_btn"),
+ down_btn("down_btn"),
+ edit_btn("edit_btn"),
+ lock_panel("lock_panel"),
+ edit_panel("edit_panel"),
+ lock_icon("lock_icon")
+{}
// static
LLPanelClothingListItem* LLPanelClothingListItem::create(LLViewerInventoryItem* item)
@@ -139,24 +154,54 @@ LLPanelClothingListItem* LLPanelClothingListItem::create(LLViewerInventoryItem*
LLPanelClothingListItem* list_item = NULL;
if(item)
{
- list_item = new LLPanelClothingListItem(item);
- list_item->init();
+ const LLPanelClothingListItem::Params& params = LLUICtrlFactory::getDefaultParams<LLPanelClothingListItem>();
+ list_item = new LLPanelClothingListItem(item, params);
+ list_item->initFromParams(params);
+ list_item->postBuild();
}
return list_item;
}
-LLPanelClothingListItem::LLPanelClothingListItem(LLViewerInventoryItem* item)
- : LLPanelDeletableWearableListItem(item)
+LLPanelClothingListItem::LLPanelClothingListItem(LLViewerInventoryItem* item, const LLPanelClothingListItem::Params& params)
+ : LLPanelDeletableWearableListItem(item, params)
+{
+ LLButton::Params button_params = params.up_btn;
+ applyXUILayout(button_params, this);
+ addChild(LLUICtrlFactory::create<LLButton>(button_params));
+
+ button_params = params.down_btn;
+ applyXUILayout(button_params, this);
+ addChild(LLUICtrlFactory::create<LLButton>(button_params));
+
+ LLPanel::Params panel_params = params.lock_panel;
+ applyXUILayout(panel_params, this);
+ LLPanel* lock_panelp = LLUICtrlFactory::create<LLPanel>(panel_params);
+ addChild(lock_panelp);
+
+ panel_params = params.edit_panel;
+ applyXUILayout(panel_params, this);
+ LLPanel* edit_panelp = LLUICtrlFactory::create<LLPanel>(panel_params);
+ addChild(edit_panelp);
+
+ if (lock_panelp)
{
+ LLIconCtrl::Params icon_params = params.lock_icon;
+ applyXUILayout(icon_params, this);
+ lock_panelp->addChild(LLUICtrlFactory::create<LLIconCtrl>(icon_params));
}
-LLPanelClothingListItem::~LLPanelClothingListItem()
+ if (edit_panelp)
{
+ button_params = params.edit_btn;
+ applyXUILayout(button_params, this);
+ edit_panelp->addChild(LLUICtrlFactory::create<LLButton>(button_params));
+ }
+
+ setSeparatorVisible(false);
}
-void LLPanelClothingListItem::init()
+LLPanelClothingListItem::~LLPanelClothingListItem()
{
- LLUICtrlFactory::getInstance()->buildPanel(this, "panel_clothing_list_item.xml");
}
BOOL LLPanelClothingListItem::postBuild()
@@ -178,30 +223,62 @@ BOOL LLPanelClothingListItem::postBuild()
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
+static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelBodyPartsListItem(&typeid(LLPanelBodyPartsListItem::Params), "bodyparts_list_item");
+
+
+LLPanelBodyPartsListItem::Params::Params()
+: edit_btn("edit_btn"),
+ edit_panel("edit_panel"),
+ lock_panel("lock_panel"),
+ lock_icon("lock_icon")
+{}
+
// static
LLPanelBodyPartsListItem* LLPanelBodyPartsListItem::create(LLViewerInventoryItem* item)
{
LLPanelBodyPartsListItem* list_item = NULL;
if(item)
{
- list_item = new LLPanelBodyPartsListItem(item);
- list_item->init();
+ const Params& params = LLUICtrlFactory::getDefaultParams<LLPanelBodyPartsListItem>();
+ list_item = new LLPanelBodyPartsListItem(item, params);
+ list_item->initFromParams(params);
+ list_item->postBuild();
}
return list_item;
}
-LLPanelBodyPartsListItem::LLPanelBodyPartsListItem(LLViewerInventoryItem* item)
-: LLPanelWearableListItem(item)
+LLPanelBodyPartsListItem::LLPanelBodyPartsListItem(LLViewerInventoryItem* item, const LLPanelBodyPartsListItem::Params& params)
+: LLPanelWearableListItem(item, params)
{
+ LLPanel::Params panel_params = params.edit_panel;
+ applyXUILayout(panel_params, this);
+ LLPanel* edit_panelp = LLUICtrlFactory::create<LLPanel>(panel_params);
+ addChild(edit_panelp);
+
+ panel_params = params.lock_panel;
+ applyXUILayout(panel_params, this);
+ LLPanel* lock_panelp = LLUICtrlFactory::create<LLPanel>(panel_params);
+ addChild(lock_panelp);
+
+ if (edit_panelp)
+ {
+ LLButton::Params btn_params = params.edit_btn;
+ applyXUILayout(btn_params, this);
+ edit_panelp->addChild(LLUICtrlFactory::create<LLButton>(btn_params));
}
-LLPanelBodyPartsListItem::~LLPanelBodyPartsListItem()
+ if (lock_panelp)
{
+ LLIconCtrl::Params icon_params = params.lock_icon;
+ applyXUILayout(icon_params, this);
+ lock_panelp->addChild(LLUICtrlFactory::create<LLIconCtrl>(icon_params));
+ }
+
+ setSeparatorVisible(true);
}
-void LLPanelBodyPartsListItem::init()
+LLPanelBodyPartsListItem::~LLPanelBodyPartsListItem()
{
- LLUICtrlFactory::getInstance()->buildPanel(this, "panel_body_parts_list_item.xml");
}
BOOL LLPanelBodyPartsListItem::postBuild()
@@ -214,6 +291,11 @@ BOOL LLPanelBodyPartsListItem::postBuild()
return TRUE;
}
+static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelDeletableWearableListItem(&typeid(LLPanelDeletableWearableListItem::Params), "deletable_wearable_list_item");
+
+LLPanelDeletableWearableListItem::Params::Params()
+: delete_btn("delete_btn")
+{}
// static
LLPanelDeletableWearableListItem* LLPanelDeletableWearableListItem::create(LLViewerInventoryItem* item)
@@ -221,20 +303,22 @@ LLPanelDeletableWearableListItem* LLPanelDeletableWearableListItem::create(LLVie
LLPanelDeletableWearableListItem* list_item = NULL;
if(item)
{
- list_item = new LLPanelDeletableWearableListItem(item);
- list_item->init();
+ const Params& params = LLUICtrlFactory::getDefaultParams<LLPanelDeletableWearableListItem>();
+ list_item = new LLPanelDeletableWearableListItem(item, params);
+ list_item->initFromParams(params);
+ list_item->postBuild();
}
return list_item;
}
-LLPanelDeletableWearableListItem::LLPanelDeletableWearableListItem(LLViewerInventoryItem* item)
-: LLPanelWearableListItem(item)
+LLPanelDeletableWearableListItem::LLPanelDeletableWearableListItem(LLViewerInventoryItem* item, const LLPanelDeletableWearableListItem::Params& params)
+: LLPanelWearableListItem(item, params)
{
-}
+ LLButton::Params button_params = params.delete_btn;
+ applyXUILayout(button_params, this);
+ addChild(LLUICtrlFactory::create<LLButton>(button_params));
-void LLPanelDeletableWearableListItem::init()
-{
- LLUICtrlFactory::getInstance()->buildPanel(this, "panel_deletable_wearable_list_item.xml");
+ setSeparatorVisible(true);
}
BOOL LLPanelDeletableWearableListItem::postBuild()
@@ -260,8 +344,11 @@ LLPanelAttachmentListItem* LLPanelAttachmentListItem::create(LLViewerInventoryIt
LLPanelAttachmentListItem* list_item = NULL;
if(item)
{
- list_item = new LLPanelAttachmentListItem(item);
- list_item->init();
+ const Params& params = LLUICtrlFactory::getDefaultParams<LLPanelDeletableWearableListItem>();
+
+ list_item = new LLPanelAttachmentListItem(item, params);
+ list_item->initFromParams(params);
+ list_item->postBuild();
}
return list_item;
}
@@ -284,27 +371,32 @@ void LLPanelAttachmentListItem::updateItem(const std::string& name,
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
+static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelDummyClothingListItem(&typeid(LLPanelDummyClothingListItem::Params), "dummy_clothing_list_item");
+
+LLPanelDummyClothingListItem::Params::Params()
+: add_panel("add_panel"),
+ add_btn("add_btn")
+{}
LLPanelDummyClothingListItem* LLPanelDummyClothingListItem::create(LLWearableType::EType w_type)
{
- LLPanelDummyClothingListItem* list_item = new LLPanelDummyClothingListItem(w_type);
- list_item->init();
+ const Params& params = LLUICtrlFactory::getDefaultParams<LLPanelDummyClothingListItem>();
+
+ LLPanelDummyClothingListItem* list_item = new LLPanelDummyClothingListItem(w_type, params);
+ list_item->initFromParams(params);
+ list_item->postBuild();
return list_item;
}
BOOL LLPanelDummyClothingListItem::postBuild()
{
- LLIconCtrl* icon = getChild<LLIconCtrl>("item_icon");
- setIconCtrl(icon);
- setTitleCtrl(getChild<LLTextBox>("item_name"));
-
addWidgetToRightSide("btn_add_panel");
setIconImage(LLInventoryIcon::getIcon(LLAssetType::AT_CLOTHING, LLInventoryType::IT_NONE, mWearableType, FALSE));
updateItem(wearableTypeToString(mWearableType));
// Make it look loke clothing item - reserve space for 'delete' button
- setLeftWidgetsWidth(icon->getRect().mLeft);
+ setLeftWidgetsWidth(getChildView("item_icon")->getRect().mLeft);
setWidgetsVisible(false);
reshapeWidgets();
@@ -317,15 +409,23 @@ LLWearableType::EType LLPanelDummyClothingListItem::getWearableType() const
return mWearableType;
}
-LLPanelDummyClothingListItem::LLPanelDummyClothingListItem(LLWearableType::EType w_type)
- : LLPanelWearableListItem(NULL)
- , mWearableType(w_type)
+LLPanelDummyClothingListItem::LLPanelDummyClothingListItem(LLWearableType::EType w_type, const LLPanelDummyClothingListItem::Params& params)
+: LLPanelWearableListItem(NULL, params),
+ mWearableType(w_type)
{
-}
+ LLPanel::Params panel_params(params.add_panel);
+ applyXUILayout(panel_params, this);
+ LLPanel* add_panelp = LLUICtrlFactory::create<LLPanel>(panel_params);
+ addChild(add_panelp);
-void LLPanelDummyClothingListItem::init()
+ if (add_panelp)
{
- LLUICtrlFactory::getInstance()->buildPanel(this, "panel_dummy_clothing_list_item.xml");
+ LLButton::Params button_params(params.add_btn);
+ applyXUILayout(button_params, this);
+ add_panelp->addChild(LLUICtrlFactory::create<LLButton>(button_params));
+}
+
+ setSeparatorVisible(true);
}
typedef std::map<LLWearableType::EType, std::string> clothing_to_string_map_t;
@@ -576,8 +676,8 @@ LLContextMenu* LLWearableItemsList::ContextMenu::createMenu()
const uuid_vec_t& ids = mUUIDs; // selected items IDs
LLUUID selected_id = ids.front(); // ID of the first selected item
- functor_t wear = boost::bind(&LLAppearanceMgr::wearItemOnAvatar, LLAppearanceMgr::getInstance(), _1, true, true);
- functor_t add = boost::bind(&LLAppearanceMgr::wearItemOnAvatar, LLAppearanceMgr::getInstance(), _1, true, false);
+ functor_t wear = boost::bind(&LLAppearanceMgr::wearItemOnAvatar, LLAppearanceMgr::getInstance(), _1, true, true, LLPointer<LLInventoryCallback>(NULL));
+ functor_t add = boost::bind(&LLAppearanceMgr::wearItemOnAvatar, LLAppearanceMgr::getInstance(), _1, true, false, LLPointer<LLInventoryCallback>(NULL));
functor_t take_off = boost::bind(&LLAppearanceMgr::removeItemFromAvatar, LLAppearanceMgr::getInstance(), _1);
// Register handlers common for all wearable types.
@@ -665,8 +765,8 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
bool standalone = mParent ? mParent->isStandalone() : false;
// *TODO: eliminate multiple traversals over the menu items
- setMenuItemVisible(menu, "wear_wear", n_already_worn == 0);
- setMenuItemEnabled(menu, "wear_wear", n_already_worn == 0);
+ setMenuItemVisible(menu, "wear_wear", n_already_worn == 0 && n_worn == 0);
+ setMenuItemEnabled(menu, "wear_wear", n_already_worn == 0 && n_worn == 0);
setMenuItemVisible(menu, "wear_add", mask == MASK_CLOTHING && n_worn == 0 && n_already_worn != 0);
setMenuItemEnabled(menu, "wear_add", n_items == 1 && canAddWearable(ids.front()) && n_already_worn != 0);
setMenuItemVisible(menu, "wear_replace", n_worn == 0 && n_already_worn != 0);
@@ -725,10 +825,8 @@ void LLWearableItemsList::ContextMenu::updateItemsLabels(LLContextMenu* menu)
LLViewerInventoryItem* item = gInventory.getLinkedItem(mUUIDs.back());
if (!item || !item->isWearableType()) return;
- LLStringUtil::format_map_t args;
LLWearableType::EType w_type = item->getWearableType();
- args["[WEARABLE_TYPE]"] = LLWearableType::getTypeDefaultNewName(w_type);
- std::string new_label = LLTrans::getString("CreateNewWearable", args);
+ std::string new_label = LLTrans::getString("create_new_" + LLWearableType::getTypeName(w_type));
LLMenuItemGL* menu_item = menu->getChild<LLMenuItemGL>("create_new");
menu_item->setLabel(new_label);