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
master
Andrew Polunin 2010-05-17 16:52:44 +03:00
parent c94653eec8
commit bf197d4f41
6 changed files with 105 additions and 9 deletions

View File

@ -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();
}

View File

@ -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);

View File

@ -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())

View File

@ -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;

View File

@ -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)
{

View File

@ -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"