diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2023-02-04 19:23:45 +0200 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2023-02-04 19:54:23 +0200 |
commit | 13a65319e0648cf228a82950e96a84d3a69bf6e3 (patch) | |
tree | b98260153c28fce5dc3693ae4f28a483daa84d0a /indra | |
parent | 25b42dd1902e1ba855856878aec7b2f7c41e2624 (diff) |
SL-19109 Turn LLSidepanelItemInfo into a normal panel
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llfloatermarketplacelistings.cpp | 10 | ||||
-rw-r--r-- | indra/newview/llsidepaneliteminfo.cpp | 155 | ||||
-rw-r--r-- | indra/newview/llsidepaneliteminfo.h | 22 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/sidepanel_item_info.xml | 32 |
4 files changed, 82 insertions, 137 deletions
diff --git a/indra/newview/llfloatermarketplacelistings.cpp b/indra/newview/llfloatermarketplacelistings.cpp index 478b6a9a50..4c8e365dd0 100644 --- a/indra/newview/llfloatermarketplacelistings.cpp +++ b/indra/newview/llfloatermarketplacelistings.cpp @@ -955,20 +955,13 @@ LLFloaterItemProperties::~LLFloaterItemProperties() BOOL LLFloaterItemProperties::postBuild() { - // On the standalone properties floater, we have no need for a back button... - LLSidepanelInventorySubpanel* panel = findChild<LLSidepanelInventorySubpanel>("sidepanel"); - if (panel) - { - LLButton* back_btn = panel->getChild<LLButton>("back_btn"); - back_btn->setVisible(FALSE); - } return LLFloater::postBuild(); } void LLFloaterItemProperties::onOpen(const LLSD& key) { // Tell the panel which item it needs to visualize - LLSidepanelInventorySubpanel* panel = findChild<LLSidepanelInventorySubpanel>("sidepanel"); + LLPanel* panel = findChild<LLPanel>("sidepanel"); LLSidepanelItemInfo* item_panel = dynamic_cast<LLSidepanelItemInfo*>(panel); if (item_panel) @@ -978,6 +971,7 @@ void LLFloaterItemProperties::onOpen(const LLSD& key) { item_panel->setObjectID(key["object"].asUUID()); } + item_panel->setParentFloater(this); } LLSidepanelTaskInfo* task_panel = dynamic_cast<LLSidepanelTaskInfo*>(panel); diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp index b23e24a222..e5e6afac19 100644 --- a/indra/newview/llsidepaneliteminfo.cpp +++ b/indra/newview/llsidepaneliteminfo.cpp @@ -32,8 +32,9 @@ #include "llagent.h" #include "llavataractions.h" #include "llbutton.h" +#include "llcallbacklist.h" #include "llcombobox.h" -#include "llfloaterreg.h" +#include "llfloater.h" #include "llgroupactions.h" #include "llinventorydefines.h" #include "llinventorymodel.h" @@ -73,49 +74,6 @@ private: }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Class LLItemPropertiesObserver -// -// Helper class to watch for changes to the item. -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLItemPropertiesObserver : public LLInventoryObserver -{ -public: - LLItemPropertiesObserver(LLSidepanelItemInfo* floater) - : mFloater(floater) - { - gInventory.addObserver(this); - } - virtual ~LLItemPropertiesObserver() - { - gInventory.removeObserver(this); - } - virtual void changed(U32 mask); -private: - LLSidepanelItemInfo* mFloater; // Not a handle because LLSidepanelItemInfo is managing LLItemPropertiesObserver -}; - -void LLItemPropertiesObserver::changed(U32 mask) -{ - const std::set<LLUUID>& mChangedItemIDs = gInventory.getChangedIDs(); - std::set<LLUUID>::const_iterator it; - - const LLUUID& item_id = mFloater->getItemID(); - - for (it = mChangedItemIDs.begin(); it != mChangedItemIDs.end(); it++) - { - // set dirty for 'item profile panel' only if changed item is the item for which 'item profile panel' is shown (STORM-288) - if (*it == item_id) - { - // if there's a change we're interested in. - if((mask & (LLInventoryObserver::LABEL | LLInventoryObserver::INTERNAL | LLInventoryObserver::REMOVE)) != 0) - { - mFloater->dirty(); - } - } - } -} - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLObjectInventoryObserver // // Helper class to watch for changes in an object inventory. @@ -158,19 +116,22 @@ static LLPanelInjector<LLSidepanelItemInfo> t_item_info("sidepanel_item_info"); // Default constructor LLSidepanelItemInfo::LLSidepanelItemInfo(const LLPanel::Params& p) - : LLSidepanelInventorySubpanel(p) + : LLPanel(p) , mItemID(LLUUID::null) , mObjectInventoryObserver(NULL) , mUpdatePendingId(-1) + , mIsDirty(false) /*Not ready*/ + , mParentFloater(NULL) { - mPropertiesObserver = new LLItemPropertiesObserver(this); + gInventory.addObserver(this); + gIdleCallbacks.addFunction(&LLSidepanelItemInfo::onIdle, (void*)this); } // Destroys the object LLSidepanelItemInfo::~LLSidepanelItemInfo() { - delete mPropertiesObserver; - mPropertiesObserver = NULL; + gInventory.removeObserver(this); + gIdleCallbacks.deleteFunction(&LLSidepanelItemInfo::onIdle, (void*)this); stopObjectInventoryObserver(); } @@ -178,8 +139,6 @@ LLSidepanelItemInfo::~LLSidepanelItemInfo() // virtual BOOL LLSidepanelItemInfo::postBuild() { - LLSidepanelInventorySubpanel::postBuild(); - getChild<LLLineEditor>("LabelItemName")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe); getChild<LLUICtrl>("LabelItemName")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitName,this)); getChild<LLLineEditor>("LabelItemDesc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe); @@ -226,6 +185,12 @@ void LLSidepanelItemInfo::setItemID(const LLUUID& item_id) mItemID = item_id; mUpdatePendingId = -1; } + dirty(); +} + +void LLSidepanelItemInfo::setParentFloater(LLFloater* parent) +{ + mParentFloater = parent; } const LLUUID& LLSidepanelItemInfo::getObjectID() const @@ -249,12 +214,11 @@ void LLSidepanelItemInfo::onUpdateCallback(const LLUUID& item_id, S32 received_u void LLSidepanelItemInfo::reset() { - LLSidepanelInventorySubpanel::reset(); - mObjectID = LLUUID::null; mItemID = LLUUID::null; stopObjectInventoryObserver(); + dirty(); } void LLSidepanelItemInfo::refresh() @@ -263,45 +227,8 @@ void LLSidepanelItemInfo::refresh() if(item) { refreshFromItem(item); - updateVerbs(); return; } - else - { - if (getIsEditing()) - { - setIsEditing(FALSE); - } - } - - if (!getIsEditing()) - { - const std::string no_item_names[]={ - "LabelItemName", - "LabelItemDesc", - "LabelCreatorName", - "LabelOwnerName" - }; - - for(size_t t=0; t<LL_ARRAY_SIZE(no_item_names); ++t) - { - getChildView(no_item_names[t])->setEnabled(false); - } - - setPropertiesFieldsEnabled(false); - - const std::string hide_names[]={ - "BaseMaskDebug", - "OwnerMaskDebug", - "GroupMaskDebug", - "EveryoneMaskDebug", - "NextMaskDebug" - }; - for(size_t t=0; t<LL_ARRAY_SIZE(hide_names); ++t) - { - getChildView(hide_names[t])->setVisible(false); - } - } if (!item) { @@ -314,8 +241,12 @@ void LLSidepanelItemInfo::refresh() getChildView(no_edit_mode_names[t])->setEnabled(false); } } - - updateVerbs(); + + if (mParentFloater) + { + // if we failed to get item, it likely no longer exists + mParentFloater->closeFloater(); + } } void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item) @@ -731,6 +662,48 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item) } } +void LLSidepanelItemInfo::changed(U32 mask) +{ + const LLUUID& item_id = getItemID(); + if (getObjectID().notNull() || item_id.isNull()) + { + // Tasl inventory or not set up yet + return; + } + + const std::set<LLUUID>& mChangedItemIDs = gInventory.getChangedIDs(); + std::set<LLUUID>::const_iterator it; + + for (it = mChangedItemIDs.begin(); it != mChangedItemIDs.end(); it++) + { + // set dirty for 'item profile panel' only if changed item is the item for which 'item profile panel' is shown (STORM-288) + if (*it == item_id) + { + // if there's a change we're interested in. + if((mask & (LLInventoryObserver::LABEL | LLInventoryObserver::INTERNAL | LLInventoryObserver::REMOVE)) != 0) + { + dirty(); + } + } + } +} + +void LLSidepanelItemInfo::dirty() +{ + mIsDirty = true; +} + +// static +void LLSidepanelItemInfo::onIdle( void* user_data ) +{ + LLSidepanelItemInfo* self = reinterpret_cast<LLSidepanelItemInfo*>(user_data); + + if( self->mIsDirty ) + { + self->refresh(); + self->mIsDirty = false; + } +} void LLSidepanelItemInfo::setAssociatedExperience( LLHandle<LLSidepanelItemInfo> hInfo, const LLSD& experience ) { diff --git a/indra/newview/llsidepaneliteminfo.h b/indra/newview/llsidepaneliteminfo.h index 5f29254182..67f8683802 100644 --- a/indra/newview/llsidepaneliteminfo.h +++ b/indra/newview/llsidepaneliteminfo.h @@ -27,7 +27,8 @@ #ifndef LL_LLSIDEPANELITEMINFO_H #define LL_LLSIDEPANELITEMINFO_H -#include "llsidepanelinventorysubpanel.h" +#include "llinventoryobserver.h" +#include "llpanel.h" //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLSidepanelItemInfo @@ -35,34 +36,40 @@ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class LLButton; +class LLFloater; class LLViewerInventoryItem; class LLItemPropertiesObserver; class LLObjectInventoryObserver; class LLViewerObject; class LLPermissions; -class LLSidepanelItemInfo : public LLSidepanelInventorySubpanel +class LLSidepanelItemInfo : public LLPanel, public LLInventoryObserver { public: LLSidepanelItemInfo(const LLPanel::Params& p = getDefaultParams()); virtual ~LLSidepanelItemInfo(); - /*virtual*/ BOOL postBuild(); + /*virtual*/ BOOL postBuild() override; /*virtual*/ void reset(); void setObjectID(const LLUUID& object_id); void setItemID(const LLUUID& item_id); - void setEditMode(BOOL edit); + void setParentFloater(LLFloater* parent); // For simplicity const LLUUID& getObjectID() const; const LLUUID& getItemID() const; // if received update and item id (from callback) matches internal ones, update UI void onUpdateCallback(const LLUUID& item_id, S32 received_update_id); + + void changed(U32 mask) override; + void dirty(); + + static void onIdle( void* user_data ); protected: - /*virtual*/ void refresh(); - /*virtual*/ void save(); + void refresh() override; + void save(); LLViewerInventoryItem* findItem() const; LLViewerObject* findObject() const; @@ -78,11 +85,12 @@ private: LLUUID mItemID; // inventory UUID for the inventory item. LLUUID mObjectID; // in-world task UUID, or null if in agent inventory. - LLItemPropertiesObserver* mPropertiesObserver; // for syncing changes to item LLObjectInventoryObserver* mObjectInventoryObserver; // for syncing changes to items inside an object // We can send multiple properties updates simultaneously, make sure only last response counts and there won't be a race condition. S32 mUpdatePendingId; + bool mIsDirty; // item properties need to be updated + LLFloater* mParentFloater; // // UI Elements diff --git a/indra/newview/skins/default/xui/en/sidepanel_item_info.xml b/indra/newview/skins/default/xui/en/sidepanel_item_info.xml index ff7ea08251..813294cf83 100644 --- a/indra/newview/skins/default/xui/en/sidepanel_item_info.xml +++ b/indra/newview/skins/default/xui/en/sidepanel_item_info.xml @@ -53,25 +53,12 @@ name="IconLocked" top="8" width="18" /> - <button - follows="top|left" - height="24" - image_hover_unselected="BackButton_Over" - image_pressed="BackButton_Press" - image_unselected="BackButton_Off" - layout="topleft" - left="12" - name="back_btn" - tab_stop="false" - top="2" - width="30" - use_draw_context_alpha="false" /> <text follows="top|left|right" font="SansSerifHugeBold" height="26" layout="topleft" - left_pad="3" + left="45" name="title" text_color="LtGray" top="2" @@ -528,21 +515,4 @@ </text> </panel> </scroll_container> - <panel - height="30" - layout="topleft" - name="button_panel" - left="5" - top_pad="0" - width="313" - follows="top|right|left"> - <button - follows="top|right" - height="23" - label="Cancel" - layout="topleft" - name="cancel_btn" - right="-1" - width="100" /> - </panel> </panel> |