summaryrefslogtreecommitdiff
path: root/indra/newview/llcofwearables.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llcofwearables.cpp')
-rw-r--r--indra/newview/llcofwearables.cpp130
1 files changed, 69 insertions, 61 deletions
diff --git a/indra/newview/llcofwearables.cpp b/indra/newview/llcofwearables.cpp
index e21644e119..36a8031cce 100644
--- a/indra/newview/llcofwearables.cpp
+++ b/indra/newview/llcofwearables.cpp
@@ -34,10 +34,13 @@
#include "llcofwearables.h"
+#include "llagentdata.h"
#include "llappearancemgr.h"
#include "llinventory.h"
-#include "llinventoryitemslist.h"
#include "llinventoryfunctions.h"
+#include "llwearableitemslist.h"
+
+static LLRegisterPanelClassWrapper<LLCOFAccordionListAdaptor> t_cof_accodion_list_adaptor("accordion_list_adaptor");
static LLRegisterPanelClassWrapper<LLCOFWearables> t_cof_wearables("cof_wearables");
@@ -117,18 +120,18 @@ void LLCOFWearables::populateAttachmentsAndBodypartsLists(const LLInventoryModel
const LLAssetType::EType item_type = item->getType();
if (item_type == LLAssetType::AT_CLOTHING) continue;
-
- LLPanelInventoryListItem* item_panel = LLPanelInventoryListItem::createItemPanel(item);
- if (!item_panel) continue;
-
+ LLPanelInventoryListItemBase* item_panel = NULL;
if (item_type == LLAssetType::AT_OBJECT)
{
+ item_panel = LLPanelInventoryListItemBase::create(item);
mAttachments->addItem(item_panel, item->getUUID(), ADD_BOTTOM, false);
}
else if (item_type == LLAssetType::AT_BODYPART)
{
+ item_panel = buildBodypartListItem(item);
+ if (!item_panel) continue;
+
mBodyParts->addItem(item_panel, item->getUUID(), ADD_BOTTOM, false);
- addWearableTypeSeparator(mBodyParts);
}
}
@@ -143,17 +146,69 @@ void LLCOFWearables::populateAttachmentsAndBodypartsLists(const LLInventoryModel
mBodyParts->sort(); //*TODO by name
}
- addListButtonBar(mBodyParts, "panel_bodyparts_list_button_bar.xml");
mBodyParts->notify(REARRANGE);
}
+//create a clothing list item, update verbs and show/hide line separator
+LLPanelClothingListItem* LLCOFWearables::buildClothingListItem(LLViewerInventoryItem* item, bool first, bool last)
+{
+ llassert(item);
+
+ LLPanelClothingListItem* item_panel = LLPanelClothingListItem::create(item);
+ if (!item_panel) return NULL;
+
+ //updating verbs
+ //we don't need to use permissions of a link but of an actual/linked item
+ if (item->getLinkedItem()) item = item->getLinkedItem();
+
+ bool allow_modify = item->getPermissions().allowModifyBy(gAgentID);
+
+ item_panel->setShowLockButton(!allow_modify);
+ item_panel->setShowEditButton(allow_modify);
+
+ item_panel->setShowMoveUpButton(!first);
+ item_panel->setShowMoveDownButton(!last);
+
+ //setting callbacks
+ //*TODO move that item panel's inner structure disclosing stuff into the panels
+ item_panel->childSetAction("btn_delete", mCOFCallbacks.mDeleteWearable);
+ item_panel->childSetAction("btn_move_up", mCOFCallbacks.mMoveWearableCloser);
+ item_panel->childSetAction("btn_move_down", mCOFCallbacks.mMoveWearableFurther);
+ item_panel->childSetAction("btn_edit", mCOFCallbacks.mEditWearable);
+
+ //turning on gray separator line for the last item in the items group of the same wearable type
+ item_panel->childSetVisible("wearable_type_separator_panel", last);
+
+ return item_panel;
+}
+
+LLPanelBodyPartsListItem* LLCOFWearables::buildBodypartListItem(LLViewerInventoryItem* item)
+{
+ llassert(item);
+
+ LLPanelBodyPartsListItem* item_panel = LLPanelBodyPartsListItem::create(item);
+ if (!item_panel) return NULL;
+
+ //updating verbs
+ //we don't need to use permissions of a link but of an actual/linked item
+ if (item->getLinkedItem()) item = item->getLinkedItem();
+
+ bool allow_modify = item->getPermissions().allowModifyBy(gAgentID);
+ item_panel->setShowLockButton(!allow_modify);
+ item_panel->setShowEditButton(allow_modify);
+
+ //setting callbacks
+ //*TODO move that item panel's inner structure disclosing stuff into the panels
+ item_panel->childSetAction("btn_delete", mCOFCallbacks.mDeleteWearable);
+ item_panel->childSetAction("btn_edit", mCOFCallbacks.mEditWearable);
+
+ return item_panel;
+}
void LLCOFWearables::populateClothingList(LLAppearanceMgr::wearables_by_type_t& clothing_by_type)
{
llassert(clothing_by_type.size() == WT_COUNT);
- addListButtonBar(mClothing, "panel_clothing_list_button_bar.xml");
-
for (U32 type = WT_SHIRT; type < WT_COUNT; ++type)
{
U32 size = clothing_by_type[type].size();
@@ -165,13 +220,11 @@ void LLCOFWearables::populateClothingList(LLAppearanceMgr::wearables_by_type_t&
{
LLViewerInventoryItem* item = clothing_by_type[type][i];
- LLPanelInventoryListItem* item_panel = LLPanelInventoryListItem::createItemPanel(item);
+ LLPanelClothingListItem* item_panel = buildClothingListItem(item, i == 0, i == size - 1);
if (!item_panel) continue;
mClothing->addItem(item_panel, item->getUUID(), ADD_BOTTOM, false);
}
-
- addWearableTypeSeparator(mClothing);
}
addClothingTypesDummies(clothing_by_type);
@@ -179,21 +232,6 @@ void LLCOFWearables::populateClothingList(LLAppearanceMgr::wearables_by_type_t&
mClothing->notify(REARRANGE);
}
-void LLCOFWearables::addListButtonBar(LLFlatListView* list, std::string xml_filename)
-{
- llassert(list);
- llassert(xml_filename.length());
-
- LLPanel::Params params;
- LLPanel* button_bar = LLUICtrlFactory::create<LLPanel>(params);
- LLUICtrlFactory::instance().buildPanel(button_bar, xml_filename);
-
- LLRect rc = button_bar->getRect();
- button_bar->reshape(list->getItemsRect().getWidth(), rc.getHeight());
-
- list->addItem(button_bar, LLUUID::null, ADD_TOP, false);
-}
-
//adding dummy items for missing wearable types
void LLCOFWearables::addClothingTypesDummies(const LLAppearanceMgr::wearables_by_type_t& clothing_by_type)
{
@@ -204,30 +242,13 @@ void LLCOFWearables::addClothingTypesDummies(const LLAppearanceMgr::wearables_by
U32 size = clothing_by_type[type].size();
if (size) continue;
- //*TODO create dummy item panel
-
- //*TODO add dummy item panel -> mClothing->addItem(dummy_item_panel, item->getUUID(), ADD_BOTTOM, false);
-
- addWearableTypeSeparator(mClothing);
+ EWearableType w_type = static_cast<EWearableType>(type);
+ LLPanelInventoryListItemBase* item_panel = LLPanelDummyClothingListItem::create(w_type);
+ if(!item_panel) continue;
+ mClothing->addItem(item_panel, LLUUID::null, ADD_BOTTOM, false);
}
}
-void LLCOFWearables::addWearableTypeSeparator(LLFlatListView* list)
-{
- llassert(list);
-
- static LLXMLNodePtr separator_xml_node = getXMLNode("panel_wearable_type_separator.xml");
- if (separator_xml_node->isNull()) return;
-
- LLPanel* separator = LLUICtrlFactory::defaultBuilder<LLPanel>(separator_xml_node, NULL, NULL);
-
- LLRect rc = separator->getRect();
- rc.setOriginAndSize(0, 0, list->getItemsRect().getWidth(), rc.getHeight());
- separator->setRect(rc);
-
- list->addItem(separator, LLUUID::null, ADD_BOTTOM, false);
-}
-
LLUUID LLCOFWearables::getSelectedUUID()
{
if (!mLastSelectedList) return LLUUID::null;
@@ -242,17 +263,4 @@ void LLCOFWearables::clear()
mBodyParts->clear();
}
-LLXMLNodePtr LLCOFWearables::getXMLNode(std::string xml_filename)
-{
- LLXMLNodePtr xmlNode = NULL;
- bool success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, xmlNode);
- if (!success)
- {
- llwarning("Failed to read xml", 0);
- return NULL;
- }
-
- return xmlNode;
-}
-
//EOF