summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatergesture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloatergesture.cpp')
-rw-r--r--indra/newview/llfloatergesture.cpp701
1 files changed, 448 insertions, 253 deletions
diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp
index 6d39d75663..de65c6f876 100644
--- a/indra/newview/llfloatergesture.cpp
+++ b/indra/newview/llfloatergesture.cpp
@@ -34,36 +34,26 @@
#include "llfloatergesture.h"
-#include "lldir.h"
#include "llinventory.h"
-#include "llmultigesture.h"
+#include "llinventorybridge.h"
+#include "llinventorymodel.h"
+#include "llinventoryclipboard.h"
#include "llagent.h"
-#include "llviewerwindow.h"
-#include "llbutton.h"
-#include "llcombobox.h"
+#include "llappearancemgr.h"
+#include "llclipboard.h"
#include "llgesturemgr.h"
-#include "llinventorymodel.h"
-#include "llinventoryview.h"
#include "llkeyboard.h"
-#include "lllineeditor.h"
+#include "llmenugl.h"
+#include "llmultigesture.h"
#include "llpreviewgesture.h"
-#include "llresizehandle.h"
-#include "llscrollbar.h"
-#include "llscrollcontainer.h"
#include "llscrolllistctrl.h"
-#include "lltextbox.h"
-#include "lluictrlfactory.h"
+#include "lltrans.h"
#include "llviewergesture.h"
-#include "llviewerimagelist.h"
+#include "llviewermenu.h"
#include "llviewerinventory.h"
-#include "llvoavatar.h"
#include "llviewercontrol.h"
-// static
-LLFloaterGesture* LLFloaterGesture::sInstance = NULL;
-LLFloaterGestureObserver* LLFloaterGesture::sObserver = NULL;
-
BOOL item_name_precedes( LLInventoryItem* a, LLInventoryItem* b )
{
return LLStringUtil::precedesDict( a->getName(), b->getName() );
@@ -72,35 +62,113 @@ BOOL item_name_precedes( LLInventoryItem* a, LLInventoryItem* b )
class LLFloaterGestureObserver : public LLGestureManagerObserver
{
public:
- LLFloaterGestureObserver() {}
+ LLFloaterGestureObserver(LLFloaterGesture* floater) : mFloater(floater) {}
virtual ~LLFloaterGestureObserver() {}
- virtual void changed() { LLFloaterGesture::refreshAll(); }
+ virtual void changed() { mFloater->refreshAll(); }
+
+private:
+ LLFloaterGesture* mFloater;
+};
+//-----------------------------
+// GestureCallback
+//-----------------------------
+
+class GestureShowCallback : public LLInventoryCallback
+{
+public:
+ void fire(const LLUUID &inv_item)
+ {
+ LLPreviewGesture::show(inv_item, LLUUID::null);
+ }
+};
+
+class GestureCopiedCallback : public LLInventoryCallback
+{
+private:
+ LLFloaterGesture* mFloater;
+
+public:
+ GestureCopiedCallback(LLFloaterGesture* floater): mFloater(floater)
+ {}
+ void fire(const LLUUID &inv_item)
+ {
+ if(mFloater)
+ {
+ mFloater->addGesture(inv_item,NULL,mFloater->getChild<LLScrollListCtrl>("gesture_list"));
+ }
+ }
};
//---------------------------------------------------------------------------
// LLFloaterGesture
//---------------------------------------------------------------------------
-LLFloaterGesture::LLFloaterGesture()
-: LLFloater(std::string("Gesture Floater"))
+LLFloaterGesture::LLFloaterGesture(const LLSD& key)
+ : LLFloater(key)
{
- sInstance = this;
+ mObserver = new LLFloaterGestureObserver(this);
+ LLGestureManager::instance().addObserver(mObserver);
+
+ mCommitCallbackRegistrar.add("Gesture.Action.ToogleActiveState", boost::bind(&LLFloaterGesture::onActivateBtnClick, this));
+ mCommitCallbackRegistrar.add("Gesture.Action.ShowPreview", boost::bind(&LLFloaterGesture::onClickEdit, this));
+ mCommitCallbackRegistrar.add("Gesture.Action.CopyPaste", boost::bind(&LLFloaterGesture::onCopyPasteAction, this, _2));
+ mCommitCallbackRegistrar.add("Gesture.Action.SaveToCOF", boost::bind(&LLFloaterGesture::addToCurrentOutFit, this));
- sObserver = new LLFloaterGestureObserver;
- gGestureManager.addObserver(sObserver);
+ mEnableCallbackRegistrar.add("Gesture.EnableAction", boost::bind(&LLFloaterGesture::isActionEnabled, this, _2));
}
-// virtual
-LLFloaterGesture::~LLFloaterGesture()
+void LLFloaterGesture::done()
{
- gGestureManager.removeObserver(sObserver);
- delete sObserver;
- sObserver = NULL;
+ //this method can be called twice: for GestureFolder and once after loading all sudir of GestureFolder
+ if (gInventory.isCategoryComplete(mGestureFolderID))
+ {
+ LL_DEBUGS("Gesture")<< "mGestureFolderID loaded" << LL_ENDL;
+ // we load only gesture folder without childred.
+ LLInventoryModel::cat_array_t* categories;
+ LLInventoryModel::item_array_t* items;
+ LLInventoryFetchDescendentsObserver::folder_ref_t unloaded_folders;
+ LL_DEBUGS("Gesture")<< "Get subdirs of Gesture Folder...." << LL_ENDL;
+ gInventory.getDirectDescendentsOf(mGestureFolderID, categories, items);
+ if (categories->empty())
+ {
+ gInventory.removeObserver(this);
+ LL_INFOS("Gesture")<< "Gesture dos NOT contains sub-directories."<< LL_ENDL;
+ return;
+ }
+ LL_DEBUGS("Gesture")<< "There are " << categories->size() << " Folders "<< LL_ENDL;
+ for (LLInventoryModel::cat_array_t::iterator it = categories->begin(); it != categories->end(); it++)
+ {
+ if (!gInventory.isCategoryComplete(it->get()->getUUID()))
+ {
+ unloaded_folders.push_back(it->get()->getUUID());
+ LL_DEBUGS("Gesture")<< it->get()->getName()<< " Folder added to fetchlist"<< LL_ENDL;
+ }
- sInstance = NULL;
+ }
+ if (!unloaded_folders.empty())
+ {
+ LL_DEBUGS("Gesture")<< "Fetching subdirectories....." << LL_ENDL;
+ fetchDescendents(unloaded_folders);
+ }
+ else
+ {
+ LL_DEBUGS("Gesture")<< "All Gesture subdirectories have been loaded."<< LL_ENDL;
+ gInventory.removeObserver(this);
+ buildGestureList();
+ }
+ }
+ else
+ {
+ LL_WARNS("Gesture")<< "Gesture list was NOT loaded"<< LL_ENDL;
+ }
+}
- // Custom saving rectangle, since load must be done
- // after postBuild.
- gSavedSettings.setRect("FloaterGestureRect2", getRect());
+// virtual
+LLFloaterGesture::~LLFloaterGesture()
+{
+ LLGestureManager::instance().removeObserver(mObserver);
+ delete mObserver;
+ mObserver = NULL;
+ gInventory.removeObserver(this);
}
// virtual
@@ -108,320 +176,447 @@ BOOL LLFloaterGesture::postBuild()
{
std::string label;
- // Translate title
label = getTitle();
setTitle(label);
+ mGestureList = getChild<LLScrollListCtrl>("gesture_list");
+ mGestureList->setCommitCallback(boost::bind(&LLFloaterGesture::onCommitList, this));
+ mGestureList->setDoubleClickCallback(boost::bind(&LLFloaterGesture::onClickPlay, this));
- childSetCommitCallback("gesture_list", onCommitList, this);
- childSetDoubleClickCallback("gesture_list", onClickPlay);
-
- childSetAction("inventory_btn", onClickInventory, this);
-
- childSetAction("edit_btn", onClickEdit, this);
+ getChild<LLUICtrl>("edit_btn")->setCommitCallback(boost::bind(&LLFloaterGesture::onClickEdit, this));
- childSetAction("play_btn", onClickPlay, this);
- childSetAction("stop_btn", onClickPlay, this);
-
- childSetAction("new_gesture_btn", onClickNew, this);
+ getChild<LLUICtrl>("play_btn")->setCommitCallback(boost::bind(&LLFloaterGesture::onClickPlay, this));
+ getChild<LLUICtrl>("stop_btn")->setCommitCallback(boost::bind(&LLFloaterGesture::onClickPlay, this));
+ getChild<LLButton>("activate_btn")->setClickedCallback(boost::bind(&LLFloaterGesture::onActivateBtnClick, this));
+
+ getChild<LLUICtrl>("new_gesture_btn")->setCommitCallback(boost::bind(&LLFloaterGesture::onClickNew, this));
+ getChild<LLButton>("del_btn")->setClickedCallback(boost::bind(&LLFloaterGesture::onDeleteSelected, this));
childSetVisible("play_btn", true);
childSetVisible("stop_btn", false);
setDefaultBtn("play_btn");
+ mGestureFolderID = gInventory.findCategoryUUIDForType(LLFolderType::FT_GESTURE, false);
- return TRUE;
-}
-
-
-// static
-void LLFloaterGesture::show()
-{
- if (sInstance)
- {
- sInstance->open(); /*Flawfinder: ignore*/
- return;
- }
-
- LLFloaterGesture *self = new LLFloaterGesture();
-
- // Builds and adds to gFloaterView
- LLUICtrlFactory::getInstance()->buildFloater(self, "floater_gesture.xml");
+ folder_ref_t folders;
+ folders.push_back(mGestureFolderID);
+ //perform loading Gesture directory anyway to make sure that all subdirectory are loaded too. See method done() for details.
+ gInventory.addObserver(this);
+ fetchDescendents(folders);
- // Fix up rectangle
- LLRect rect = gSavedSettings.getRect("FloaterGestureRect2");
- self->reshape(rect.getWidth(), rect.getHeight());
- self->setRect(rect);
-
- self->buildGestureList();
-
- self->childSetFocus("gesture_list");
+ buildGestureList();
+
+ mGestureList->setFocus(TRUE);
- LLCtrlListInterface *list = self->childGetListInterface("gesture_list");
- if (list)
+ if (mGestureList)
{
const BOOL ascending = TRUE;
- list->sortByColumn(std::string("name"), ascending);
- list->selectFirstItem();
+ mGestureList->sortByColumn(std::string("name"), ascending);
+ mGestureList->selectFirstItem();
}
- self->mSelectedID = LLUUID::null;
-
// Update button labels
- onCommitList(NULL, self);
- self->open(); /*Flawfinder: ignore*/
+ onCommitList();
+
+ return TRUE;
}
-// static
-void LLFloaterGesture::toggleVisibility()
+
+void LLFloaterGesture::refreshAll()
{
- if(sInstance && sInstance->getVisible())
+ buildGestureList();
+
+ if (!mGestureList) return;
+
+ if (mSelectedID.isNull())
{
- sInstance->close();
+ mGestureList->selectFirstItem();
}
else
{
- show();
+ if (! mGestureList->setCurrentByID(mSelectedID))
+ {
+ mGestureList->selectFirstItem();
+ }
}
+
+ // Update button labels
+ onCommitList();
}
-// static
-void LLFloaterGesture::refreshAll()
+void LLFloaterGesture::buildGestureList()
{
- if (sInstance)
+ S32 scroll_pos = mGestureList->getScrollPos();
+ std::vector<LLUUID> selected_items;
+ getSelectedIds(selected_items);
+ LL_DEBUGS("Gesture")<< "Rebuilding gesture list "<< LL_ENDL;
+ mGestureList->deleteAllItems();
+
+ LLGestureManager::item_map_t::const_iterator it;
+ const LLGestureManager::item_map_t& active_gestures = LLGestureManager::instance().getActiveGestures();
+ for (it = active_gestures.begin(); it != active_gestures.end(); ++it)
{
- sInstance->buildGestureList();
-
- LLCtrlListInterface *list = sInstance->childGetListInterface("gesture_list");
- if (!list) return;
+ addGesture(it->first,it->second, mGestureList);
+ }
+ if (gInventory.isCategoryComplete(mGestureFolderID))
+ {
+ LLIsType is_gesture(LLAssetType::AT_GESTURE);
+ LLInventoryModel::cat_array_t categories;
+ LLInventoryModel::item_array_t items;
+ gInventory.collectDescendentsIf(mGestureFolderID, categories, items,
+ LLInventoryModel::EXCLUDE_TRASH, is_gesture);
- if (sInstance->mSelectedID.isNull())
- {
- list->selectFirstItem();
- }
- else
+ for (LLInventoryModel::item_array_t::iterator it = items.begin(); it!= items.end(); ++it)
{
- if (! list->setCurrentByID(sInstance->mSelectedID))
+ LLInventoryItem* item = it->get();
+ if (active_gestures.find(item->getUUID()) == active_gestures.end())
{
- list->selectFirstItem();
+ // if gesture wasn't loaded yet, we can display only name
+ addGesture(item->getUUID(), NULL, mGestureList);
}
}
+ }
- // Update button labels
- onCommitList(NULL, sInstance);
+ // attempt to preserve scroll position through re-builds
+ // since we do re-build whenever something gets dirty
+ for(std::vector<LLUUID>::iterator it = selected_items.begin(); it != selected_items.end(); it++)
+ {
+ mGestureList->selectByID(*it);
}
+ mGestureList->setScrollPos(scroll_pos);
}
-void LLFloaterGesture::buildGestureList()
+void LLFloaterGesture::addGesture(const LLUUID& item_id , LLMultiGesture* gesture,LLCtrlListInterface * list )
{
- LLCtrlListInterface *list = childGetListInterface("gesture_list");
- LLCtrlScrollInterface *scroll = childGetScrollInterface("gesture_list");
+ // Note: Can have NULL item if inventory hasn't arrived yet.
+ static std::string item_name = getString("loading");
+ LLInventoryItem* item = gInventory.getItem(item_id);
+ if (item)
+ {
+ item_name = item->getName();
+ }
- if (! (list && scroll)) return;
+ static std::string font_style = "NORMAL";
+ // If gesture is playing, bold it
- // attempt to preserve scroll position through re-builds
- // since we do re-build any time anything dirties
- S32 current_scroll_pos = scroll->getScrollPos();
-
- list->operateOnAll(LLCtrlListInterface::OP_DELETE);
+ LLSD element;
+ element["id"] = item_id;
- LLGestureManager::item_map_t::iterator it;
- for (it = gGestureManager.mActive.begin(); it != gGestureManager.mActive.end(); ++it)
+ if (gesture)
{
- const LLUUID& item_id = (*it).first;
- LLMultiGesture* gesture = (*it).second;
-
- // Note: Can have NULL item if inventory hasn't arrived yet.
- std::string item_name = "Loading...";
- LLInventoryItem* item = gInventory.getItem(item_id);
- if (item)
+ if (gesture->mPlaying)
{
- item_name = item->getName();
+ font_style = "BOLD";
}
+ item_name = gesture->mName;
+ element["columns"][0]["column"] = "trigger";
+ element["columns"][0]["value"] = gesture->mTrigger;
+ element["columns"][0]["font"]["name"] = "SANSSERIF";
+ element["columns"][0]["font"]["style"] = font_style;
- std::string font_style = "NORMAL";
- // If gesture is playing, bold it
-
- LLSD element;
- element["id"] = item_id;
+ std::string key_string = LLKeyboard::stringFromKey(gesture->mKey);
+ std::string buffer;
- if (gesture)
+ if (gesture->mKey == KEY_NONE)
{
- if (gesture->mPlaying)
- {
- font_style = "BOLD";
- }
+ buffer = "---";
+ key_string = "~~~"; // alphabetize to end
+ }
+ else
+ {
+ buffer = LLKeyboard::stringFromAccelerator(gesture->mMask,
+ gesture->mKey);
+ }
- element["columns"][0]["column"] = "trigger";
- element["columns"][0]["value"] = gesture->mTrigger;
- element["columns"][0]["font"] = "SANSSERIF";
- element["columns"][0]["font-style"] = font_style;
+ element["columns"][1]["column"] = "shortcut";
+ element["columns"][1]["value"] = buffer;
+ element["columns"][1]["font"]["name"] = "SANSSERIF";
+ element["columns"][1]["font"]["style"] = font_style;
- std::string key_string = LLKeyboard::stringFromKey(gesture->mKey);
- std::string buffer;
+ // hidden column for sorting
+ element["columns"][2]["column"] = "key";
+ element["columns"][2]["value"] = key_string;
+ element["columns"][2]["font"]["name"] = "SANSSERIF";
+ element["columns"][2]["font"]["style"] = font_style;
- {
- if (gesture->mKey == KEY_NONE)
- {
- buffer = "---";
- key_string = "~~~"; // alphabetize to end
- }
- else
- {
- if (gesture->mMask & MASK_CONTROL) buffer.append("Ctrl-");
- if (gesture->mMask & MASK_ALT) buffer.append("Alt-");
- if (gesture->mMask & MASK_SHIFT) buffer.append("Shift-");
- if ((gesture->mMask & (MASK_CONTROL|MASK_ALT|MASK_SHIFT)) &&
- (key_string[0] == '-' || key_string[0] == '='))
- {
- buffer.append(" ");
- }
- buffer.append(key_string);
- }
- }
- element["columns"][1]["column"] = "shortcut";
- element["columns"][1]["value"] = buffer;
- element["columns"][1]["font"] = "SANSSERIF";
- element["columns"][1]["font-style"] = font_style;
-
- // hidden column for sorting
- element["columns"][2]["column"] = "key";
- element["columns"][2]["value"] = key_string;
- element["columns"][2]["font"] = "SANSSERIF";
- element["columns"][2]["font-style"] = font_style;
-
- // Only add "playing" if we've got the name, less confusing. JC
- if (item && gesture->mPlaying)
- {
- item_name += " (Playing)";
- }
- element["columns"][3]["column"] = "name";
- element["columns"][3]["value"] = item_name;
- element["columns"][3]["font"] = "SANSSERIF";
- element["columns"][3]["font-style"] = font_style;
- }
- else
+ // Only add "playing" if we've got the name, less confusing. JC
+ if (item && gesture->mPlaying)
{
- element["columns"][0]["column"] = "trigger";
- element["columns"][0]["value"] = "";
- element["columns"][0]["font"] = "SANSSERIF";
- element["columns"][0]["font-style"] = font_style;
- element["columns"][0]["column"] = "trigger";
- element["columns"][0]["value"] = "---";
- element["columns"][0]["font"] = "SANSSERIF";
- element["columns"][0]["font-style"] = font_style;
- element["columns"][2]["column"] = "key";
- element["columns"][2]["value"] = "~~~";
- element["columns"][2]["font"] = "SANSSERIF";
- element["columns"][2]["font-style"] = font_style;
- element["columns"][3]["column"] = "name";
- element["columns"][3]["value"] = item_name;
- element["columns"][3]["font"] = "SANSSERIF";
- element["columns"][3]["font-style"] = font_style;
+ item_name += " " + getString("playing");
}
- list->addElement(element, ADD_BOTTOM);
+ element["columns"][3]["column"] = "name";
+ element["columns"][3]["value"] = item_name;
+ element["columns"][3]["font"]["name"] = "SANSSERIF";
+ element["columns"][3]["font"]["style"] = font_style;
}
-
- scroll->setScrollPos(current_scroll_pos);
+ else
+ {
+ element["columns"][0]["column"] = "trigger";
+ element["columns"][0]["value"] = "";
+ element["columns"][0]["font"]["name"] = "SANSSERIF";
+ element["columns"][0]["font"]["style"] = font_style;
+ element["columns"][0]["column"] = "trigger";
+ element["columns"][0]["value"] = "---";
+ element["columns"][0]["font"]["name"] = "SANSSERIF";
+ element["columns"][0]["font"]["style"] = font_style;
+ element["columns"][2]["column"] = "key";
+ element["columns"][2]["value"] = "~~~";
+ element["columns"][2]["font"]["name"] = "SANSSERIF";
+ element["columns"][2]["font"]["style"] = font_style;
+ element["columns"][3]["column"] = "name";
+ element["columns"][3]["value"] = item_name;
+ element["columns"][3]["font"]["name"] = "SANSSERIF";
+ element["columns"][3]["font"]["style"] = font_style;
+ }
+ list->addElement(element, ADD_BOTTOM);
}
-// static
-void LLFloaterGesture::onClickInventory(void* data)
+void LLFloaterGesture::getSelectedIds(std::vector<LLUUID>& ids)
{
- LLFloaterGesture* self = (LLFloaterGesture*)data;
-
- LLCtrlListInterface *list = self->childGetListInterface("gesture_list");
- if (!list) return;
- const LLUUID& item_id = list->getCurrentID();
-
- LLInventoryView* inv = LLInventoryView::showAgentInventory();
- if (!inv) return;
- inv->getPanel()->setSelection(item_id, TRUE);
+ std::vector<LLScrollListItem*> items = mGestureList->getAllSelected();
+ for(std::vector<LLScrollListItem*>::const_iterator it = items.begin(); it != items.end(); it++)
+ {
+ ids.push_back((*it)->getUUID());
+ }
}
-// static
-void LLFloaterGesture::onClickPlay(void* data)
+bool LLFloaterGesture::isActionEnabled(const LLSD& command)
{
- LLFloaterGesture* self = (LLFloaterGesture*)data;
-
- LLCtrlListInterface *list = self->childGetListInterface("gesture_list");
- if (!list) return;
- const LLUUID& item_id = list->getCurrentID();
-
- if (gGestureManager.isGesturePlaying(item_id))
+ // paste copy_uuid edit_gesture
+ std::string command_name = command.asString();
+ if("paste" == command_name)
{
- gGestureManager.stopGesture(item_id);
+ if(!LLInventoryClipboard::instance().hasContents())
+ return false;
+
+ LLDynamicArray<LLUUID> ids;
+ LLInventoryClipboard::instance().retrieve(ids);
+ for(LLDynamicArray<LLUUID>::iterator it = ids.begin(); it != ids.end(); it++)
+ {
+ LLInventoryItem* item = gInventory.getItem(*it);
+
+ if(item && item->getInventoryType() == LLInventoryType::IT_GESTURE)
+ {
+ return true;
+ }
+ }
+ return false;
}
- else
+ else if("copy_uuid" == command_name || "edit_gesture" == command_name
+ || "inspect" == command_name)
{
- gGestureManager.playGesture(item_id);
+ return mGestureList->getAllSelected().size() == 1;
}
+ return true;
}
-class GestureShowCallback : public LLInventoryCallback
+void LLFloaterGesture::onClickPlay()
{
-public:
- GestureShowCallback(std::string &title)
+ const LLUUID& item_id = mGestureList->getCurrentID();
+ if(item_id.isNull()) return;
+
+ LL_DEBUGS("Gesture")<<" Trying to play gesture id: "<< item_id <<LL_ENDL;
+ if(!LLGestureManager::instance().isGestureActive(item_id))
{
- mTitle = title;
+ // we need to inform server about gesture activating to be consistent with LLPreviewGesture and LLGestureComboList.
+ BOOL inform_server = TRUE;
+ BOOL deactivate_similar = FALSE;
+ LLGestureManager::instance().setGestureLoadedCallback(item_id, boost::bind(&LLFloaterGesture::playGesture, this, item_id));
+ LLGestureManager::instance().activateGestureWithAsset(item_id, gInventory.getItem(item_id)->getAssetUUID(), inform_server, deactivate_similar);
+ LL_DEBUGS("Gesture")<< "Activating gesture with inventory ID: " << item_id <<LL_ENDL;
}
- void fire(const LLUUID &inv_item)
+ else
{
- LLPreviewGesture::show(mTitle, inv_item, LLUUID::null);
+ playGesture(item_id);
}
-private:
- std::string mTitle;
-};
+}
-// static
-void LLFloaterGesture::onClickNew(void* data)
+void LLFloaterGesture::onClickNew()
{
- std::string title("Gesture: ");
- title.append("New Gesture");
- LLPointer<LLInventoryCallback> cb = new GestureShowCallback(title);
+ LLPointer<LLInventoryCallback> cb = new GestureShowCallback();
create_inventory_item(gAgent.getID(), gAgent.getSessionID(),
LLUUID::null, LLTransactionID::tnull, "New Gesture", "", LLAssetType::AT_GESTURE,
LLInventoryType::IT_GESTURE, NOT_WEARABLE, PERM_MOVE | PERM_TRANSFER, cb);
}
+void LLFloaterGesture::onActivateBtnClick()
+{
+ std::vector<LLUUID> ids;
+ getSelectedIds(ids);
+ if(ids.empty())
+ return;
+
+ LLGestureManager* gm = LLGestureManager::getInstance();
+ std::vector<LLUUID>::const_iterator it = ids.begin();
+ BOOL first_gesture_state = gm->isGestureActive(*it);
+ BOOL is_mixed = FALSE;
+ while( ++it != ids.end() )
+ {
+ if(first_gesture_state != gm->isGestureActive(*it))
+ {
+ is_mixed = TRUE;
+ break;
+ }
+ }
+ for(std::vector<LLUUID>::const_iterator it = ids.begin(); it != ids.end(); it++)
+ {
+ if(is_mixed)
+ {
+ gm->activateGesture(*it);
+ }
+ else
+ {
+ if(first_gesture_state)
+ {
+ gm->deactivateGesture(*it);
+ }
+ else
+ {
+ gm->activateGesture(*it);
+ }
+ }
+ }
+}
-// static
-void LLFloaterGesture::onClickEdit(void* data)
+void LLFloaterGesture::onCopyPasteAction(const LLSD& command)
{
- LLFloaterGesture* self = (LLFloaterGesture*)data;
+ std::string command_name = command.asString();
+ // since we select this comman inventory item had already arrived .
+ if("copy_gesture" == command_name)
+ {
+ std::vector<LLUUID> ids;
+ getSelectedIds(ids);
+ // make sure that clopboard is empty
+ LLInventoryClipboard::instance().reset();
+ for(std::vector<LLUUID>::iterator it = ids.begin(); it != ids.end(); it++)
+ {
+ LLInventoryItem* item = gInventory.getItem(*it);
+ if(item && item->getInventoryType() == LLInventoryType::IT_GESTURE)
+ {
+ LLInventoryClipboard::instance().add(item->getUUID());
+ }
+ }
+ }
+ else if ("paste" == command_name)
+ {
+ LLInventoryClipboard& clipbord = LLInventoryClipboard::instance();
+ LLDynamicArray<LLUUID> ids;
+ clipbord.retrieve(ids);
+ if(ids.empty() || !gInventory.isCategoryComplete(mGestureFolderID))
+ return;
+ LLInventoryCategory* gesture_dir = gInventory.getCategory(mGestureFolderID);
+ LLPointer<GestureCopiedCallback> cb = new GestureCopiedCallback(this);
+
+ for(LLDynamicArray<LLUUID>::iterator it = ids.begin(); it != ids.end(); it++)
+ {
+ LLInventoryItem* item = gInventory.getItem(*it);
+ LLStringUtil::format_map_t string_args;
+ string_args["[COPY_NAME]"] = item->getName();
+ if(item && item->getInventoryType() == LLInventoryType::IT_GESTURE)
+ {
+ LL_DEBUGS("Gesture")<< "Copying gesture " << item->getName() << " "<< item->getUUID() << " into "
+ << gesture_dir->getName() << " "<< gesture_dir->getUUID() << LL_ENDL;
+ copy_inventory_item(gAgent.getID(), item->getPermissions().getOwner(), item->getUUID(),
+ gesture_dir->getUUID(), getString("copy_name", string_args), cb);
+ }
+ }
+ clipbord.reset();
+ }
+ else if ("copy_uuid" == command_name)
+ {
+ gClipboard.copyFromString(utf8str_to_wstring(mGestureList->getCurrentID().asString()), mGestureList->getCurrentID());
+ }
+}
- LLCtrlListInterface *list = self->childGetListInterface("gesture_list");
- if (!list) return;
- const LLUUID& item_id = list->getCurrentID();
+void LLFloaterGesture::onClickEdit()
+{
+ const LLUUID& item_id = mGestureList->getCurrentID();
LLInventoryItem* item = gInventory.getItem(item_id);
if (!item) return;
- std::string title("Gesture: ");
- title.append(item->getName());
-
- LLPreviewGesture* previewp = LLPreviewGesture::show(title, item_id, LLUUID::null);
+ LLPreviewGesture* previewp = LLPreviewGesture::show(item_id, LLUUID::null);
if (!previewp->getHost())
{
- previewp->setRect(gFloaterView->findNeighboringPosition(self, previewp));
+ previewp->setRect(gFloaterView->findNeighboringPosition(this, previewp));
}
}
-// static
-void LLFloaterGesture::onCommitList(LLUICtrl* ctrl, void* data)
+void LLFloaterGesture::onCommitList()
{
- LLFloaterGesture* self = (LLFloaterGesture*)data;
+ const LLUUID& item_id = mGestureList->getCurrentID();
- const LLUUID& item_id = self->childGetValue("gesture_list").asUUID();
+ mSelectedID = item_id;
+ if (LLGestureManager::instance().isGesturePlaying(item_id))
+ {
+ childSetVisible("play_btn", false);
+ childSetVisible("stop_btn", true);
+ }
+ else
+ {
+ childSetVisible("play_btn", true);
+ childSetVisible("stop_btn", false);
+ }
+}
+
+void LLFloaterGesture::onDeleteSelected()
+{
+ std::vector<LLUUID> ids;
+ getSelectedIds(ids);
+ if(ids.empty())
+ return;
+
+ const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
+ LLGestureManager* gm = LLGestureManager::getInstance();
+ for(std::vector<LLUUID>::const_iterator it = ids.begin(); it != ids.end(); it++)
+ {
+ const LLUUID& selected_item = *it;
+ LLInventoryItem* inv_item = gInventory.getItem(selected_item);
+ if (inv_item && inv_item->getInventoryType() == LLInventoryType::IT_GESTURE)
+ {
+ if(gm->isGestureActive(selected_item))
+ {
+ gm->deactivateGesture(selected_item);
+ }
+ LLInventoryModel::update_list_t update;
+ LLInventoryModel::LLCategoryUpdate old_folder(inv_item->getParentUUID(), -1);
+ update.push_back(old_folder);
+ LLInventoryModel::LLCategoryUpdate new_folder(trash_id, 1);
+ update.push_back(new_folder);
+ gInventory.accountForUpdate(update);
+
+ LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(inv_item);
+ new_item->setParent(trash_id);
+ // no need to restamp it though it's a move into trash because
+ // it's a brand new item already.
+ new_item->updateParentOnServer(FALSE);
+ gInventory.updateItem(new_item);
+ }
+ }
+ gInventory.notifyObservers();
+ buildGestureList();
+}
+
+void LLFloaterGesture::addToCurrentOutFit()
+{
+ std::vector<LLUUID> ids;
+ getSelectedIds(ids);
+ LLAppearanceManager* am = LLAppearanceManager::getInstance();
+ for(std::vector<LLUUID>::const_iterator it = ids.begin(); it != ids.end(); it++)
+ {
+ am->addCOFItemLink(*it);
+ }
+}
+
+void LLFloaterGesture::playGesture(LLUUID item_id)
+{
+ LL_DEBUGS("Gesture")<<"Playing gesture "<< item_id<<LL_ENDL;
- self->mSelectedID = item_id;
- if (gGestureManager.isGesturePlaying(item_id))
+ if (LLGestureManager::instance().isGesturePlaying(item_id))
{
- self->childSetVisible("play_btn", false);
- self->childSetVisible("stop_btn", true);
+ LLGestureManager::instance().stopGesture(item_id);
}
else
{
- self->childSetVisible("play_btn", true);
- self->childSetVisible("stop_btn", false);
+ LLGestureManager::instance().playGesture(item_id);
}
}