summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Polunin <apolunin@productengine.com>2010-05-17 16:52:44 +0300
committerAndrew Polunin <apolunin@productengine.com>2010-05-17 16:52:44 +0300
commitbf197d4f410b686a80bd66ab7a3fcc761e8591ca (patch)
tree1be92a87449f68d379b68cd016a9aacc9fa10cbd
parentc94653eec83a49e41a4d92f3e7f1f01810365f06 (diff)
EXT-7199 FIXED (Enable dragging items from inventory view to current outfit in Outfit Editor)
- HandleDragAndDrop() method was overridden in the LLPanelOutfitEdit class to handle drag and drop operations of the Clothing, Body Parts and Attachments. - In panel_outfit_edit.xml parameter allow_multi_select was set to true to allow multiple selections. - Added class LLCOFDragAndDropObserver to implement the drag and drop. - Class LLInventoryMoveFromWorldObserver renamed to LLInventoryAddItemByAssetObserver. Drag and drop reimplemented using functionality of the LLInventoryAddItemByAssetObserver. Reviewed by Neal Orman and Mike Antipov at https://codereview.productengine.com/secondlife/r/373/ --HG-- branch : product-engine
-rw-r--r--indra/newview/llinventoryobserver.cpp6
-rw-r--r--indra/newview/llinventoryobserver.h4
-rw-r--r--indra/newview/llpaneloutfitedit.cpp89
-rw-r--r--indra/newview/llpaneloutfitedit.h9
-rw-r--r--indra/newview/llviewermessage.cpp4
-rw-r--r--indra/newview/skins/default/xui/en/panel_outfit_edit.xml2
6 files changed, 105 insertions, 9 deletions
diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp
index c24d2ee0ea..8557548887 100644
--- a/indra/newview/llinventoryobserver.cpp
+++ b/indra/newview/llinventoryobserver.cpp
@@ -493,7 +493,7 @@ void LLInventoryExistenceObserver::changed(U32 mask)
}
}
-void LLInventoryMoveFromWorldObserver::changed(U32 mask)
+void LLInventoryAddItemByAssetObserver::changed(U32 mask)
{
if(!(mask & LLInventoryObserver::ADD))
{
@@ -535,7 +535,7 @@ void LLInventoryMoveFromWorldObserver::changed(U32 mask)
}
}
-void LLInventoryMoveFromWorldObserver::watchAsset(const LLUUID& asset_id)
+void LLInventoryAddItemByAssetObserver::watchAsset(const LLUUID& asset_id)
{
if(asset_id.notNull())
{
@@ -551,7 +551,7 @@ void LLInventoryMoveFromWorldObserver::watchAsset(const LLUUID& asset_id)
}
}
-bool LLInventoryMoveFromWorldObserver::isAssetWatched( const LLUUID& asset_id )
+bool LLInventoryAddItemByAssetObserver::isAssetWatched( const LLUUID& asset_id )
{
return std::find(mWatchedAssets.begin(), mWatchedAssets.end(), asset_id) != mWatchedAssets.end();
}
diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h
index 036e6ca40d..6d5a86a6fc 100644
--- a/indra/newview/llinventoryobserver.h
+++ b/indra/newview/llinventoryobserver.h
@@ -180,10 +180,10 @@ protected:
// something useful.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class LLInventoryMoveFromWorldObserver : public LLInventoryObserver
+class LLInventoryAddItemByAssetObserver : public LLInventoryObserver
{
public:
- LLInventoryMoveFromWorldObserver() : mIsDirty(false) {}
+ LLInventoryAddItemByAssetObserver() : mIsDirty(false) {}
virtual void changed(U32 mask);
void watchAsset(const LLUUID& asset_id);
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index c04be85174..44832ac496 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -169,14 +169,48 @@ protected:
S32 mBaseOutfitLastVersion;
};
+class LLCOFDragAndDropObserver : public LLInventoryAddItemByAssetObserver
+{
+public:
+ LLCOFDragAndDropObserver(LLInventoryModel* model);
+
+ virtual ~LLCOFDragAndDropObserver();
+
+ virtual void done();
+
+private:
+ LLInventoryModel* mModel;
+};
+
+inline LLCOFDragAndDropObserver::LLCOFDragAndDropObserver(LLInventoryModel* model):
+ mModel(model)
+{
+ if (model != NULL)
+ {
+ model->addObserver(this);
+ }
+}
+
+inline LLCOFDragAndDropObserver::~LLCOFDragAndDropObserver()
+{
+ if (mModel != NULL && mModel->containsObserver(this))
+ {
+ mModel->removeObserver(this);
+ }
+}
+void LLCOFDragAndDropObserver::done()
+{
+ LLAppearanceMgr::instance().updateAppearanceFromCOF();
+}
LLPanelOutfitEdit::LLPanelOutfitEdit()
: LLPanel(),
mSearchFilter(NULL),
mCOFWearables(NULL),
mInventoryItemsPanel(NULL),
- mCOFObserver(NULL)
+ mCOFObserver(NULL),
+ mCOFDragAndDropObserver(NULL)
{
mSavedFolderState = new LLSaveFolderState();
mSavedFolderState->setApply(FALSE);
@@ -197,6 +231,7 @@ LLPanelOutfitEdit::~LLPanelOutfitEdit()
delete mSavedFolderState;
delete mCOFObserver;
+ delete mCOFDragAndDropObserver;
}
BOOL LLPanelOutfitEdit::postBuild()
@@ -234,6 +269,8 @@ BOOL LLPanelOutfitEdit::postBuild()
mInventoryItemsPanel->setSelectCallback(boost::bind(&LLPanelOutfitEdit::onInventorySelectionChange, this, _1, _2));
mInventoryItemsPanel->getRootFolder()->setReshapeCallback(boost::bind(&LLPanelOutfitEdit::onInventorySelectionChange, this, _1, _2));
+ mCOFDragAndDropObserver = new LLCOFDragAndDropObserver(mInventoryItemsPanel->getModel());
+
LLComboBox* type_filter = getChild<LLComboBox>("filter_wearables_combobox");
type_filter->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onTypeFilterChanged, this, _1));
type_filter->removeall();
@@ -522,6 +559,56 @@ void LLPanelOutfitEdit::update()
updateVerbs();
}
+BOOL LLPanelOutfitEdit::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
+ EDragAndDropType cargo_type,
+ void* cargo_data,
+ EAcceptance* accept,
+ std::string& tooltip_msg)
+{
+ if (cargo_data == NULL)
+ {
+ llwarns << "cargo_data is NULL" << llendl;
+ return TRUE;
+ }
+
+ switch (cargo_type)
+ {
+ case DAD_BODYPART:
+ case DAD_CLOTHING:
+ case DAD_OBJECT:
+ case DAD_LINK:
+ *accept = ACCEPT_YES_MULTI;
+ break;
+ default:
+ *accept = ACCEPT_NO;
+ }
+
+ if (drop)
+ {
+ LLInventoryItem* item = static_cast<LLInventoryItem*>(cargo_data);
+
+ if (LLAssetType::lookupIsAssetIDKnowable(item->getType()))
+ {
+ mCOFDragAndDropObserver->watchAsset(item->getAssetUUID());
+
+ /*
+ * Adding request to wear item. If the item is a link, then getLinkedUUID() will
+ * return the ID of the linked item. Otherwise it will return the item's ID. The
+ * second argument is used to delay the appearance update until all dragged items
+ * are added to optimize user experience.
+ */
+ LLAppearanceMgr::instance().addCOFItemLink(item->getLinkedUUID(), false);
+ }
+ else
+ {
+ // if asset id is not available for the item we must wear it immediately (attachments only)
+ LLAppearanceMgr::instance().addCOFItemLink(item->getLinkedUUID(), true);
+ }
+ }
+
+ return TRUE;
+}
+
void LLPanelOutfitEdit::displayCurrentOutfit()
{
if (!getVisible())
diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h
index cb8283fca3..953a70785c 100644
--- a/indra/newview/llpaneloutfitedit.h
+++ b/indra/newview/llpaneloutfitedit.h
@@ -50,6 +50,7 @@ class LLCOFWearables;
class LLTextBox;
class LLInventoryCategory;
class LLCOFObserver;
+class LLCOFDragAndDropObserver;
class LLInventoryPanel;
class LLSaveFolderState;
class LLFolderViewItem;
@@ -114,6 +115,12 @@ public:
*/
bool switchPanels(LLPanel* switch_from_panel, LLPanel* switch_to_panel);
+ virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
+ EDragAndDropType cargo_type,
+ void* cargo_data,
+ EAcceptance* accept,
+ std::string& tooltip_msg);
+
private:
@@ -134,6 +141,8 @@ private:
LLPanel* mWearableItemsPanel;
LLCOFObserver* mCOFObserver;
+ LLCOFDragAndDropObserver* mCOFDragAndDropObserver;
+
std::vector<LLLookItemType> mLookItemTypes;
LLCOFWearables* mCOFWearables;
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 86e040692c..fb87e2d3b9 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -774,11 +774,11 @@ private:
* We can't create it each time items are moved because "drop" event is sent separately for each
* element even while multi-dragging. We have to have the only instance of the observer. See EXT-4347.
*/
-class LLViewerInventoryMoveFromWorldObserver : public LLInventoryMoveFromWorldObserver
+class LLViewerInventoryMoveFromWorldObserver : public LLInventoryAddItemByAssetObserver
{
public:
LLViewerInventoryMoveFromWorldObserver()
- : LLInventoryMoveFromWorldObserver()
+ : LLInventoryAddItemByAssetObserver()
, mActivePanel(NULL)
{
diff --git a/indra/newview/skins/default/xui/en/panel_outfit_edit.xml b/indra/newview/skins/default/xui/en/panel_outfit_edit.xml
index f661d7e237..9072418329 100644
--- a/indra/newview/skins/default/xui/en/panel_outfit_edit.xml
+++ b/indra/newview/skins/default/xui/en/panel_outfit_edit.xml
@@ -292,7 +292,7 @@
width="311"
user_resize="true">
<inventory_panel
- allow_multi_select="false"
+ allow_multi_select="true"
border="false"
follows="left|top|right|bottom"
height="130"