summaryrefslogtreecommitdiff
path: root/indra/newview/llpaneloutfitedit.cpp
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 /indra/newview/llpaneloutfitedit.cpp
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
Diffstat (limited to 'indra/newview/llpaneloutfitedit.cpp')
-rw-r--r--indra/newview/llpaneloutfitedit.cpp89
1 files changed, 88 insertions, 1 deletions
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())