From 35bf78478cdd479d8b87a9cc5afa36de92e0ef7e Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Tue, 11 May 2010 17:43:00 -0400 Subject: EXT-7306 : FIXED : Add shortcut-style icons for inventory links EXT-7312 : FIXED : INFRASTRUCTURE : Cleanup LLPanelObjectInventory Fixed a few minor bugs with LLInventoryIcon being called with incorrect arguments. Big cleanup of LLPanelobjectInventory to make better use of inheritance. Added LLInventoryIcon class and did some major refactoring for how it determines inventory icons from item bridges. --- indra/newview/llfloaterbuy.cpp | 4 +- indra/newview/llfloaterbuycontents.cpp | 1 + indra/newview/llinventoryitemslist.cpp | 2 +- indra/newview/llpanelgroupnotices.cpp | 6 +- indra/newview/llpanelobjectinventory.cpp | 317 +++++++----------------------- indra/newview/lltoastgroupnotifypanel.cpp | 3 +- indra/newview/llwearableitemslist.cpp | 2 +- 7 files changed, 83 insertions(+), 252 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterbuy.cpp b/indra/newview/llfloaterbuy.cpp index 8e7bdba848..46b3695511 100644 --- a/indra/newview/llfloaterbuy.cpp +++ b/indra/newview/llfloaterbuy.cpp @@ -153,8 +153,7 @@ void LLFloaterBuy::show(const LLSaleInfo& sale_info) // Compute icon for this item std::string icon_name = LLInventoryIcon::getIconName(LLAssetType::AT_OBJECT, - LLInventoryType::IT_OBJECT, - 0x0, FALSE); + LLInventoryType::IT_OBJECT); row["columns"][0]["column"] = "icon"; row["columns"][0]["type"] = "icon"; @@ -255,6 +254,7 @@ void LLFloaterBuy::inventoryChanged(LLViewerObject* obj, std::string icon_name = LLInventoryIcon::getIconName(inv_item->getType(), inv_item->getInventoryType(), + inv_item->getIsLinkType(), inv_item->getFlags(), item_is_multi); row["columns"][0]["column"] = "icon"; diff --git a/indra/newview/llfloaterbuycontents.cpp b/indra/newview/llfloaterbuycontents.cpp index 9bde3b1dac..c35653178a 100644 --- a/indra/newview/llfloaterbuycontents.cpp +++ b/indra/newview/llfloaterbuycontents.cpp @@ -223,6 +223,7 @@ void LLFloaterBuyContents::inventoryChanged(LLViewerObject* obj, std::string icon_name = LLInventoryIcon::getIconName(inv_item->getType(), inv_item->getInventoryType(), + inv_item->getIsLinkType(), inv_item->getFlags(), item_is_multi); row["columns"][0]["column"] = "icon"; diff --git a/indra/newview/llinventoryitemslist.cpp b/indra/newview/llinventoryitemslist.cpp index 2be78787fe..f48e7b3966 100644 --- a/indra/newview/llinventoryitemslist.cpp +++ b/indra/newview/llinventoryitemslist.cpp @@ -130,7 +130,7 @@ BOOL LLPanelInventoryListItemBase::postBuild() setIconCtrl(getChild("item_icon")); setTitleCtrl(getChild("item_name")); - mIconImage = LLInventoryIcon::getIcon(mItem->getType(), mItem->getInventoryType(), mItem->getFlags(), FALSE); + mIconImage = LLInventoryIcon::getIcon(mItem->getType(), mItem->getInventoryType(), mItem->getIsLinkType(), mItem->getFlags(), FALSE); setNeedsRefresh(true); diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp index edc29bb6a0..362d8581f3 100644 --- a/indra/newview/llpanelgroupnotices.cpp +++ b/indra/newview/llpanelgroupnotices.cpp @@ -338,6 +338,7 @@ void LLPanelGroupNotices::setItem(LLPointer inv_item) std::string icon_name = LLInventoryIcon::getIconName(inv_item->getType(), inv_item->getInventoryType(), inv_item->getFlags(), + inv_item->getIsLinkType(), item_is_multi ); mCreateInventoryIcon->setValue(icon_name); @@ -554,7 +555,7 @@ void LLPanelGroupNotices::processNotices(LLMessageSystem* msg) { std::string icon_name = LLInventoryIcon::getIconName( (LLAssetType::EType)asset_type, - LLInventoryType::IT_NONE,FALSE, FALSE); + LLInventoryType::IT_NONE); row["columns"][0]["type"] = "icon"; row["columns"][0]["value"] = icon_name; } @@ -621,8 +622,7 @@ void LLPanelGroupNotices::showNotice(const std::string& subject, mInventoryOffer = inventory_offer; std::string icon_name = LLInventoryIcon::getIconName(mInventoryOffer->mType, - LLInventoryType::IT_TEXTURE, - 0, FALSE); + LLInventoryType::IT_TEXTURE); mViewInventoryIcon->setValue(icon_name); mViewInventoryIcon->setVisible(TRUE); diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index 6be37b097e..6a112f35dd 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -83,16 +83,17 @@ protected: mutable std::string mDisplayName; LLPanelObjectInventory* mPanel; U32 mFlags; + LLAssetType::EType mAssetType; + LLInventoryType::EType mInventoryType; LLInventoryItem* findItem() const; public: - LLTaskInvFVBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name, - U32 flags=0); - virtual ~LLTaskInvFVBridge( void ) {} + LLTaskInvFVBridge(LLPanelObjectInventory* panel, + const LLUUID& uuid, + const std::string& name, + U32 flags=0); + virtual ~LLTaskInvFVBridge() {} virtual LLFontGL::StyleFlags getLabelStyle() const { return LLFontGL::NORMAL; } virtual std::string getLabelSuffix() const { return LLStringUtil::null; } @@ -149,9 +150,16 @@ LLTaskInvFVBridge::LLTaskInvFVBridge( mUUID(uuid), mName(name), mPanel(panel), - mFlags(flags) + mFlags(flags), + mAssetType(LLAssetType::AT_NONE), + mInventoryType(LLInventoryType::IT_NONE) { - + const LLInventoryItem *item = findItem(); + if (item) + { + mAssetType = item->getType(); + mInventoryType = item->getInventoryType(); + } } LLInventoryItem* LLTaskInvFVBridge::findItem() const @@ -345,13 +353,9 @@ time_t LLTaskInvFVBridge::getCreationDate() const LLUIImagePtr LLTaskInvFVBridge::getIcon() const { - BOOL item_is_multi = FALSE; - if ( mFlags & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS ) - { - item_is_multi = TRUE; - } + const BOOL item_is_multi = (mFlags & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS); - return LLInventoryIcon::getIcon(LLAssetType::AT_OBJECT, LLInventoryType::IT_OBJECT, 0, item_is_multi ); + return LLInventoryIcon::getIcon(mAssetType, mInventoryType, FALSE, 0, item_is_multi ); } void LLTaskInvFVBridge::openItem() @@ -371,8 +375,7 @@ BOOL LLTaskInvFVBridge::isItemRenameable() const LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); if(object) { - LLInventoryItem* item; - item = (LLInventoryItem*)(object->getInventoryObject(mUUID)); + LLInventoryItem* item = (LLInventoryItem*)(object->getInventoryObject(mUUID)); if(item && gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE, GOD_LIKE)) { @@ -867,33 +870,14 @@ BOOL LLTaskCategoryBridge::dragOrDrop(MASK mask, BOOL drop, class LLTaskTextureBridge : public LLTaskInvFVBridge { public: - LLTaskTextureBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name, - LLInventoryType::EType it); + LLTaskTextureBridge(LLPanelObjectInventory* panel, + const LLUUID& uuid, + const std::string& name) : + LLTaskInvFVBridge(panel, uuid, name) {} - virtual LLUIImagePtr getIcon() const; virtual void openItem(); -protected: - LLInventoryType::EType mInventoryType; }; -LLTaskTextureBridge::LLTaskTextureBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name, - LLInventoryType::EType it) : - LLTaskInvFVBridge(panel, uuid, name), - mInventoryType(it) -{ -} - -LLUIImagePtr LLTaskTextureBridge::getIcon() const -{ - return LLInventoryIcon::getIcon(LLAssetType::AT_TEXTURE, mInventoryType, 0, FALSE); -} - void LLTaskTextureBridge::openItem() { llinfos << "LLTaskTextureBridge::openItem()" << llendl; @@ -912,31 +896,17 @@ void LLTaskTextureBridge::openItem() class LLTaskSoundBridge : public LLTaskInvFVBridge { public: - LLTaskSoundBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name); + LLTaskSoundBridge(LLPanelObjectInventory* panel, + const LLUUID& uuid, + const std::string& name) : + LLTaskInvFVBridge(panel, uuid, name) {} - virtual LLUIImagePtr getIcon() const; virtual void openItem(); virtual void performAction(LLInventoryModel* model, std::string action); virtual void buildContextMenu(LLMenuGL& menu, U32 flags); static void openSoundPreview(void* data); }; -LLTaskSoundBridge::LLTaskSoundBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name) : - LLTaskInvFVBridge(panel, uuid, name) -{ -} - -LLUIImagePtr LLTaskSoundBridge::getIcon() const -{ - return LLInventoryIcon::getIcon(LLAssetType::AT_SOUND, LLInventoryType::IT_SOUND, 0, FALSE); -} - void LLTaskSoundBridge::openItem() { openSoundPreview((void*)this); @@ -1038,28 +1008,12 @@ void LLTaskSoundBridge::buildContextMenu(LLMenuGL& menu, U32 flags) class LLTaskLandmarkBridge : public LLTaskInvFVBridge { public: - LLTaskLandmarkBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name); - - virtual LLUIImagePtr getIcon() const; + LLTaskLandmarkBridge(LLPanelObjectInventory* panel, + const LLUUID& uuid, + const std::string& name) : + LLTaskInvFVBridge(panel, uuid, name) {} }; -LLTaskLandmarkBridge::LLTaskLandmarkBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name) : - LLTaskInvFVBridge(panel, uuid, name) -{ -} - -LLUIImagePtr LLTaskLandmarkBridge::getIcon() const -{ - return LLInventoryIcon::getIcon(LLAssetType::AT_LANDMARK, LLInventoryType::IT_LANDMARK, 0, FALSE); -} - - ///---------------------------------------------------------------------------- /// Class LLTaskCallingCardBridge ///---------------------------------------------------------------------------- @@ -1067,29 +1021,15 @@ LLUIImagePtr LLTaskLandmarkBridge::getIcon() const class LLTaskCallingCardBridge : public LLTaskInvFVBridge { public: - LLTaskCallingCardBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name); + LLTaskCallingCardBridge(LLPanelObjectInventory* panel, + const LLUUID& uuid, + const std::string& name) : + LLTaskInvFVBridge(panel, uuid, name) {} - virtual LLUIImagePtr getIcon() const; virtual BOOL isItemRenameable() const; virtual BOOL renameItem(const std::string& new_name); }; -LLTaskCallingCardBridge::LLTaskCallingCardBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name) : - LLTaskInvFVBridge(panel, uuid, name) -{ -} - -LLUIImagePtr LLTaskCallingCardBridge::getIcon() const -{ - return LLInventoryIcon::getIcon(LLAssetType::AT_CALLINGCARD, LLInventoryType::IT_CALLINGCARD, 0, FALSE); -} - BOOL LLTaskCallingCardBridge::isItemRenameable() const { return FALSE; @@ -1108,36 +1048,21 @@ BOOL LLTaskCallingCardBridge::renameItem(const std::string& new_name) class LLTaskScriptBridge : public LLTaskInvFVBridge { public: - LLTaskScriptBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name); + LLTaskScriptBridge(LLPanelObjectInventory* panel, + const LLUUID& uuid, + const std::string& name) : + LLTaskInvFVBridge(panel, uuid, name) {} - virtual LLUIImagePtr getIcon() const; //static BOOL enableIfCopyable( void* userdata ); }; -LLTaskScriptBridge::LLTaskScriptBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name) : - LLTaskInvFVBridge(panel, uuid, name) -{ -} - -LLUIImagePtr LLTaskScriptBridge::getIcon() const -{ - return LLInventoryIcon::getIcon(LLAssetType::AT_SCRIPT, LLInventoryType::IT_LSL, 0, FALSE); -} - - class LLTaskLSLBridge : public LLTaskScriptBridge { public: - LLTaskLSLBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name); + LLTaskLSLBridge(LLPanelObjectInventory* panel, + const LLUUID& uuid, + const std::string& name) : + LLTaskScriptBridge(panel, uuid, name) {} virtual void openItem(); virtual BOOL removeItem(); @@ -1146,14 +1071,6 @@ public: //static void copyToInventory(void* userdata); }; -LLTaskLSLBridge::LLTaskLSLBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name) : - LLTaskScriptBridge(panel, uuid, name) -{ -} - void LLTaskLSLBridge::openItem() { llinfos << "LLTaskLSLBridge::openItem() " << mUUID << llendl; @@ -1189,35 +1106,13 @@ BOOL LLTaskLSLBridge::removeItem() class LLTaskObjectBridge : public LLTaskInvFVBridge { public: - LLTaskObjectBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name, - U32 flags = 0); - - virtual LLUIImagePtr getIcon() const; + LLTaskObjectBridge(LLPanelObjectInventory* panel, + const LLUUID& uuid, + const std::string& name, + U32 flags = 0) : + LLTaskInvFVBridge(panel, uuid, name, flags) {} }; -LLTaskObjectBridge::LLTaskObjectBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name, - U32 flags) : - LLTaskInvFVBridge(panel, uuid, name, flags) -{ -} - -LLUIImagePtr LLTaskObjectBridge::getIcon() const -{ - BOOL item_is_multi = FALSE; - if ( mFlags & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS ) - { - item_is_multi = TRUE; - } - - return LLInventoryIcon::getIcon(LLAssetType::AT_OBJECT, LLInventoryType::IT_OBJECT, 0, item_is_multi); -} - ///---------------------------------------------------------------------------- /// Class LLTaskNotecardBridge ///---------------------------------------------------------------------------- @@ -1225,29 +1120,15 @@ LLUIImagePtr LLTaskObjectBridge::getIcon() const class LLTaskNotecardBridge : public LLTaskInvFVBridge { public: - LLTaskNotecardBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name); + LLTaskNotecardBridge(LLPanelObjectInventory* panel, + const LLUUID& uuid, + const std::string& name) : + LLTaskInvFVBridge(panel, uuid, name) {} - virtual LLUIImagePtr getIcon() const; virtual void openItem(); virtual BOOL removeItem(); }; -LLTaskNotecardBridge::LLTaskNotecardBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name) : - LLTaskInvFVBridge(panel, uuid, name) -{ -} - -LLUIImagePtr LLTaskNotecardBridge::getIcon() const -{ - return LLInventoryIcon::getIcon(LLAssetType::AT_NOTECARD, LLInventoryType::IT_NOTECARD, 0, FALSE); -} - void LLTaskNotecardBridge::openItem() { LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); @@ -1278,29 +1159,15 @@ BOOL LLTaskNotecardBridge::removeItem() class LLTaskGestureBridge : public LLTaskInvFVBridge { public: - LLTaskGestureBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name); + LLTaskGestureBridge(LLPanelObjectInventory* panel, + const LLUUID& uuid, + const std::string& name) : + LLTaskInvFVBridge(panel, uuid, name) {} - virtual LLUIImagePtr getIcon() const; virtual void openItem(); virtual BOOL removeItem(); }; -LLTaskGestureBridge::LLTaskGestureBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name) : - LLTaskInvFVBridge(panel, uuid, name) -{ -} - -LLUIImagePtr LLTaskGestureBridge::getIcon() const -{ - return LLInventoryIcon::getIcon(LLAssetType::AT_GESTURE, LLInventoryType::IT_GESTURE, 0, FALSE); -} - void LLTaskGestureBridge::openItem() { LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); @@ -1325,29 +1192,15 @@ BOOL LLTaskGestureBridge::removeItem() class LLTaskAnimationBridge : public LLTaskInvFVBridge { public: - LLTaskAnimationBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name); + LLTaskAnimationBridge(LLPanelObjectInventory* panel, + const LLUUID& uuid, + const std::string& name) : + LLTaskInvFVBridge(panel, uuid, name) {} - virtual LLUIImagePtr getIcon() const; virtual void openItem(); virtual BOOL removeItem(); }; -LLTaskAnimationBridge::LLTaskAnimationBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name) : - LLTaskInvFVBridge(panel, uuid, name) -{ -} - -LLUIImagePtr LLTaskAnimationBridge::getIcon() const -{ - return LLInventoryIcon::getIcon(LLAssetType::AT_ANIMATION, LLInventoryType::IT_ANIMATION, 0, FALSE); -} - void LLTaskAnimationBridge::openItem() { LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); @@ -1376,33 +1229,18 @@ BOOL LLTaskAnimationBridge::removeItem() class LLTaskWearableBridge : public LLTaskInvFVBridge { public: - LLTaskWearableBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name, - LLAssetType::EType asset_type, - U32 flags); + LLTaskWearableBridge(LLPanelObjectInventory* panel, + const LLUUID& uuid, + const std::string& name, + U32 flags) : + LLTaskInvFVBridge(panel, uuid, name, flags) {} virtual LLUIImagePtr getIcon() const; - -protected: - LLAssetType::EType mAssetType; }; -LLTaskWearableBridge::LLTaskWearableBridge( - LLPanelObjectInventory* panel, - const LLUUID& uuid, - const std::string& name, - LLAssetType::EType asset_type, - U32 flags) : - LLTaskInvFVBridge(panel, uuid, name, flags), - mAssetType( asset_type ) -{ -} - LLUIImagePtr LLTaskWearableBridge::getIcon() const { - return LLInventoryIcon::getIcon(mAssetType, LLInventoryType::IT_WEARABLE, mFlags, FALSE ); + return LLInventoryIcon::getIcon(mAssetType, mInventoryType, FALSE, mFlags, FALSE ); } @@ -1414,16 +1252,15 @@ LLTaskInvFVBridge* LLTaskInvFVBridge::createObjectBridge(LLPanelObjectInventory* LLInventoryObject* object) { LLTaskInvFVBridge* new_bridge = NULL; + const LLInventoryItem* item = dynamic_cast(object); LLAssetType::EType type = object->getType(); - LLInventoryItem* item = NULL; + switch(type) { case LLAssetType::AT_TEXTURE: - item = (LLInventoryItem*)object; new_bridge = new LLTaskTextureBridge(panel, object->getUUID(), - object->getName(), - item->getInventoryType()); + object->getName()); break; case LLAssetType::AT_SOUND: new_bridge = new LLTaskSoundBridge(panel, @@ -1449,13 +1286,11 @@ LLTaskInvFVBridge* LLTaskInvFVBridge::createObjectBridge(LLPanelObjectInventory* break; case LLAssetType::AT_OBJECT: { - item = dynamic_cast(object); - U32 flags = ( NULL == item ? 0 : item->getFlags() ); - - new_bridge = new LLTaskObjectBridge(panel, - object->getUUID(), - object->getName(), - flags); + U32 flags = ( NULL == item ? 0 : item->getFlags() ); + new_bridge = new LLTaskObjectBridge(panel, + object->getUUID(), + object->getName(), + flags); } break; case LLAssetType::AT_NOTECARD: @@ -1475,11 +1310,9 @@ LLTaskInvFVBridge* LLTaskInvFVBridge::createObjectBridge(LLPanelObjectInventory* break; case LLAssetType::AT_CLOTHING: case LLAssetType::AT_BODYPART: - item = (LLInventoryItem*)object; new_bridge = new LLTaskWearableBridge(panel, object->getUUID(), object->getName(), - type, item->getFlags()); break; case LLAssetType::AT_CATEGORY: @@ -1492,8 +1325,6 @@ LLTaskInvFVBridge* LLTaskInvFVBridge::createObjectBridge(LLPanelObjectInventory* object->getUUID(), object->getName()); break; - - break; default: llinfos << "Unhandled inventory type (llassetstorage.h): " << (S32)type << llendl; diff --git a/indra/newview/lltoastgroupnotifypanel.cpp b/indra/newview/lltoastgroupnotifypanel.cpp index 0c0ee1cc41..7eac3867d5 100644 --- a/indra/newview/lltoastgroupnotifypanel.cpp +++ b/indra/newview/lltoastgroupnotifypanel.cpp @@ -134,8 +134,7 @@ LLToastGroupNotifyPanel::LLToastGroupNotifyPanel(LLNotificationPtr& notification &LLToastGroupNotifyPanel::onClickAttachment, this)); LLUIImagePtr attachIconImg = LLInventoryIcon::getIcon(mInventoryOffer->mType, - LLInventoryType::IT_TEXTURE, - 0, FALSE); + LLInventoryType::IT_TEXTURE); pAttachIcon->setValue(attachIconImg->getName()); } diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp index d29d38018b..26f6bc47cd 100644 --- a/indra/newview/llwearableitemslist.cpp +++ b/indra/newview/llwearableitemslist.cpp @@ -201,7 +201,7 @@ BOOL LLPanelDummyClothingListItem::postBuild() addWidgetToRightSide("btn_add"); - setIconImage(LLInventoryIcon::getIcon(LLAssetType::AT_CLOTHING, LLInventoryType::IT_NONE, mWearableType, FALSE)); + setIconImage(LLInventoryIcon::getIcon(LLAssetType::AT_CLOTHING, LLInventoryType::IT_NONE, FALSE, mWearableType, FALSE)); updateItem(); // Make it look loke clothing item - reserve space for 'delete' button -- cgit v1.2.3