diff options
author | Richard Linden <none@none> | 2011-07-07 13:34:13 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2011-07-07 13:34:13 -0700 |
commit | 88a90aabcb5bdede24bb451d443239e1e116c4ea (patch) | |
tree | 9399a4aefc1a9017986e1c29f9c9077d6e3c74c7 /indra/newview/llviewermessage.cpp | |
parent | 66dcc72870b19c6ada65a643ca33c779c9c9989b (diff) | |
parent | 8f7579e4e46bb8da9fece3125ae31c3bb885be96 (diff) |
Automated merge with http://hg.secondlife.com/viewer-development
Diffstat (limited to 'indra/newview/llviewermessage.cpp')
-rw-r--r-- | indra/newview/llviewermessage.cpp | 117 |
1 files changed, 99 insertions, 18 deletions
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 9f7559ad15..44b3a85f25 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -37,6 +37,7 @@ #include "lleconomy.h" #include "lleventtimer.h" #include "llfloaterreg.h" +#include "llfolderview.h" #include "llfollowcamparams.h" #include "llinventorydefines.h" #include "lllslconstants.h" @@ -87,6 +88,7 @@ #include "lluri.h" #include "llviewergenericmessage.h" #include "llviewermenu.h" +#include "llviewerinventory.h" #include "llviewerjoystick.h" #include "llviewerobjectlist.h" #include "llviewerparcelmgr.h" @@ -694,7 +696,7 @@ bool join_group_response(const LLSD& notification, const LLSD& response) return false; } -static void highlight_inventory_items_in_panel(const std::vector<LLUUID>& items, LLInventoryPanel *inventory_panel) +static void highlight_inventory_objects_in_panel(const std::vector<LLUUID>& items, LLInventoryPanel *inventory_panel) { if (NULL == inventory_panel) return; @@ -708,7 +710,7 @@ static void highlight_inventory_items_in_panel(const std::vector<LLUUID>& items, continue; } - LLInventoryItem* item = gInventory.getItem(item_id); + LLInventoryObject* item = gInventory.getObject(item_id); llassert(item); if (!item) { continue; @@ -787,7 +789,6 @@ class LLViewerInventoryMoveFromWorldObserver : public LLInventoryAddItemByAssetO public: LLViewerInventoryMoveFromWorldObserver() : LLInventoryAddItemByAssetObserver() - , mActivePanel(NULL) { } @@ -798,13 +799,16 @@ private: /*virtual */void onAssetAdded(const LLUUID& asset_id) { // Store active Inventory panel. - mActivePanel = LLInventoryPanel::getActiveInventoryPanel(); + if (LLInventoryPanel::getActiveInventoryPanel()) + { + mActivePanel = LLInventoryPanel::getActiveInventoryPanel()->getHandle(); + } // Store selected items (without destination folder) mSelectedItems.clear(); - if (mActivePanel) + if (LLInventoryPanel::getActiveInventoryPanel()) { - mSelectedItems = mActivePanel->getRootFolder()->getSelectionList(); + mSelectedItems = LLInventoryPanel::getActiveInventoryPanel()->getRootFolder()->getSelectionList(); } mSelectedItems.erase(mMoveIntoFolderID); } @@ -815,12 +819,14 @@ private: */ void done() { + LLInventoryPanel* active_panel = dynamic_cast<LLInventoryPanel*>(mActivePanel.get()); + // if selection is not changed since watch started lets hightlight new items. - if (mActivePanel && !isSelectionChanged()) + if (active_panel && !isSelectionChanged()) { LL_DEBUGS("Inventory_Move") << "Selecting new items..." << LL_ENDL; - mActivePanel->clearSelection(); - highlight_inventory_items_in_panel(mAddedItems, mActivePanel); + active_panel->clearSelection(); + highlight_inventory_objects_in_panel(mAddedItems, active_panel); } } @@ -828,16 +834,16 @@ private: * Returns true if selected inventory items were changed since moved inventory items were started to watch. */ bool isSelectionChanged() - { - const LLInventoryPanel * const current_active_panel = LLInventoryPanel::getActiveInventoryPanel(); + { + LLInventoryPanel* active_panel = dynamic_cast<LLInventoryPanel*>(mActivePanel.get()); - if (NULL == mActivePanel || current_active_panel != mActivePanel) + if (NULL == active_panel) { return true; } // get selected items (without destination folder) - selected_items_t selected_items = mActivePanel->getRootFolder()->getSelectionList(); + selected_items_t selected_items = active_panel->getRootFolder()->getSelectionList(); selected_items.erase(mMoveIntoFolderID); // compare stored & current sets of selected items @@ -851,7 +857,7 @@ private: return different_items.size() > 0; } - LLInventoryPanel *mActivePanel; + LLHandle<LLPanel> mActivePanel; typedef std::set<LLUUID> selected_items_t; selected_items_t mSelectedItems; @@ -880,6 +886,75 @@ void set_dad_inventory_item(LLInventoryItem* inv_item, const LLUUID& into_folder gInventoryMoveObserver->watchAsset(inv_item->getAssetUUID()); } + +/** + * Class to observe moving of items and to select them in inventory. + * + * Used currently for dragging from inbox to regular inventory folders + */ + +class LLViewerInventoryMoveObserver : public LLInventoryObserver +{ +public: + + LLViewerInventoryMoveObserver(const LLUUID& object_id) + : LLInventoryObserver() + , mObjectID(object_id) + { + if (LLInventoryPanel::getActiveInventoryPanel()) + { + mActivePanel = LLInventoryPanel::getActiveInventoryPanel()->getHandle(); + } + } + + virtual ~LLViewerInventoryMoveObserver() {} + virtual void changed(U32 mask); + +private: + LLUUID mObjectID; + LLHandle<LLPanel> mActivePanel; + +}; + +void LLViewerInventoryMoveObserver::changed(U32 mask) +{ + LLInventoryPanel* active_panel = dynamic_cast<LLInventoryPanel*>(mActivePanel.get()); + + if (NULL == active_panel) + { + gInventory.removeObserver(this); + return; + } + + if((mask & (LLInventoryObserver::STRUCTURE)) != 0) + { + const std::set<LLUUID>& changed_items = gInventory.getChangedIDs(); + + std::set<LLUUID>::const_iterator id_it = changed_items.begin(); + std::set<LLUUID>::const_iterator id_end = changed_items.end(); + for (;id_it != id_end; ++id_it) + { + if ((*id_it) == mObjectID) + { + active_panel->clearSelection(); + std::vector<LLUUID> items; + items.push_back(mObjectID); + highlight_inventory_objects_in_panel(items, active_panel); + active_panel->getRootFolder()->scrollToShowSelection(); + + gInventory.removeObserver(this); + break; + } + } + } +} + +void set_dad_inbox_object(const LLUUID& object_id) +{ + LLViewerInventoryMoveObserver* move_observer = new LLViewerInventoryMoveObserver(object_id); + gInventory.addObserver(move_observer); +} + //unlike the FetchObserver for AgentOffer, we only make one //instance of the AddedObserver for TaskOffers //and it never dies. We do this because we don't know the UUID of @@ -936,7 +1011,6 @@ protected: //one global instance to bind them LLOpenTaskOffer* gNewInventoryObserver=NULL; - class LLNewInventoryHintObserver : public LLInventoryAddedObserver { protected: @@ -946,6 +1020,8 @@ protected: } }; +LLNewInventoryHintObserver* gNewInventoryHintObserver=NULL; + void start_new_inventory_observer() { if (!gNewInventoryObserver) //task offer observer @@ -962,7 +1038,12 @@ void start_new_inventory_observer() gInventory.addObserver(gInventoryMoveObserver); } - gInventory.addObserver(new LLNewInventoryHintObserver()); + if (!gNewInventoryHintObserver) + { + // Observer is deleted by gInventory + gNewInventoryHintObserver = new LLNewInventoryHintObserver(); + gInventory.addObserver(gNewInventoryHintObserver); + } } class LLDiscardAgentOffer : public LLInventoryFetchItemsObserver @@ -4324,7 +4405,7 @@ void process_sound_trigger(LLMessageSystem *msg, void **) { return; } - + // Don't play sounds from gestures if they are not enabled. if (object_id == owner_id && !gSavedSettings.getBOOL("EnableGestureSounds")) { @@ -6499,7 +6580,7 @@ void process_script_dialog(LLMessageSystem* msg, void**) LLUUID owner_id; if (gMessageSystem->getNumberOfBlocks("OwnerData") > 0) { - msg->getUUID("OwnerData", "OwnerID", owner_id); + msg->getUUID("OwnerData", "OwnerID", owner_id); } if (LLMuteList::getInstance()->isMuted(object_id) || LLMuteList::getInstance()->isMuted(owner_id)) |