From a4137d72ebc9f49dfd8bd124b255da0dfbc4ba92 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 3 Jul 2018 14:18:24 -0700 Subject: MAINT-8821: New "My Environments" floater. First pass. --- indra/newview/llfloatermyenvironment.cpp | 769 +++++++++++++++++++++++++++++++ 1 file changed, 769 insertions(+) create mode 100644 indra/newview/llfloatermyenvironment.cpp (limited to 'indra/newview/llfloatermyenvironment.cpp') diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp new file mode 100644 index 0000000000..83cd726eb8 --- /dev/null +++ b/indra/newview/llfloatermyenvironment.cpp @@ -0,0 +1,769 @@ +/** + * @file llfloatergesture.cpp + * @brief Read-only list of gestures from your inventory. + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloatermyenvironment.h" + +#include "llinventory.h" +#include "llinventorybridge.h" +#include "llinventoryfunctions.h" +#include "llinventorymodel.h" +#include "llclipboard.h" + +#include "llagent.h" +#include "llclipboard.h" +#include "llkeyboard.h" +#include "llmenugl.h" +#include "llmultigesture.h" +#include "llscrolllistctrl.h" +#include "llcheckboxctrl.h" +#include "lltrans.h" +#include "llviewergesture.h" +#include "llviewermenu.h" +#include "llviewerinventory.h" +#include "llviewercontrol.h" +#include "llfloaterperms.h" + +//========================================================================= +namespace +{ + const std::string CHECK_DAYS("chk_days"); + const std::string CHECK_SKIES("chk_skies"); + const std::string CHECK_WATER("chk_water"); + const std::string PANEL_SETTINGS("pnl_settings"); + const std::string CHECK_SHOWFOLDERS("chk_showfolders"); + const std::string BUTTON_NEWSETTINGS("btn_gear"); + const std::string BUTTON_GEAR("btn_newsettings"); + const std::string BUTTON_DELETE("btn_del"); + const std::string BUTTON_EDIT("btn_edit"); + +} + +//========================================================================= +#if 0 +BOOL item_name_precedes( LLInventoryItem* a, LLInventoryItem* b ) +{ + return LLStringUtil::precedesDict( a->getName(), b->getName() ); +} + +class LLFloaterGestureObserver : public LLGestureManagerObserver +{ +public: + LLFloaterGestureObserver(LLFloaterGesture* floater) : mFloater(floater) {} + virtual ~LLFloaterGestureObserver() {} + 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); + + LLInventoryItem* item = gInventory.getItem(inv_item); + if (item) + { + LLPermissions perm = item->getPermissions(); + perm.setMaskNext(LLFloaterPerms::getNextOwnerPerms("Gestures")); + perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Gestures")); + perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Gestures")); + item->setPermissions(perm); + item->updateServer(FALSE); + } + } +}; + +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("gesture_list")); + + // EXP-1909 (Pasted gesture displayed twice) + // The problem is that addGesture is called here for the second time for the same item (which is copied) + // First time addGesture is called from LLFloaterGestureObserver::changed(), which is a callback for inventory + // change. So we need to refresh the gesture list to avoid duplicates. + mFloater->refreshAll(); + } + } +}; + +#endif + +//========================================================================= +LLFloaterMyEnvironment::LLFloaterMyEnvironment(const LLSD& key) : + LLFloater(key), + mInventoryList(nullptr), + mShowFolders(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS), + mTypeFilter((0x01 << static_cast(LLSettingsType::ST_DAYCYCLE)) | (0x01 << static_cast(LLSettingsType::ST_SKY)) | (0x01 << static_cast(LLSettingsType::ST_WATER))), + mSelectedAsset() +{ + +#if 0 + mObserver = new LLFloaterGestureObserver(this); + LLGestureMgr::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)); + + mEnableCallbackRegistrar.add("Gesture.EnableAction", boost::bind(&LLFloaterGesture::isActionEnabled, this, _2)); +#endif +} + +LLFloaterMyEnvironment::~LLFloaterMyEnvironment() +{ + // LLGestureMgr::instance().removeObserver(mObserver); + // delete mObserver; + // mObserver = NULL; + // gInventory.removeObserver(this); +} + + +BOOL LLFloaterMyEnvironment::postBuild() +{ + mInventoryList = getChild(PANEL_SETTINGS); + + if (mInventoryList) + { + U32 filter_types = 0x0; + filter_types |= 0x1 << LLInventoryType::IT_SETTINGS; + + mInventoryList->setFilterTypes(filter_types); + +// mInventoryList->setSelectCallback(boost::bind(&LLFloaterTexturePicker::onSelectionChange, this, _1, _2)); + mInventoryList->setShowFolderState(mShowFolders); + mInventoryList->setFilterSettingsTypes(mTypeFilter); + } + + childSetCommitCallback(CHECK_DAYS, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); + childSetCommitCallback(CHECK_SKIES, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); + childSetCommitCallback(CHECK_WATER, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); + childSetCommitCallback(CHECK_SHOWFOLDERS, [this](LLUICtrl*, void*) { onShowFoldersChange(); }, nullptr); + + /*TODO: Enable these*/ + getChild(BUTTON_NEWSETTINGS)->setEnabled(false); + getChild(BUTTON_GEAR)->setEnabled(false); + getChild(BUTTON_DELETE)->setEnabled(false); + getChild(BUTTON_EDIT)->setEnabled(false); + + return TRUE; +} + +void LLFloaterMyEnvironment::refresh() +{ + getChild(CHECK_SHOWFOLDERS)->setValue(LLSD::Boolean(mShowFolders == LLInventoryFilter::SHOW_ALL_FOLDERS)); + + getChild(CHECK_DAYS)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast(LLSettingsType::ST_DAYCYCLE)))); + getChild(CHECK_SKIES)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast(LLSettingsType::ST_SKY)))); + getChild(CHECK_WATER)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast(LLSettingsType::ST_WATER)))); + +// if (mInventoryList) +// { +// LLUUID obj_id = findItemByAssetId(mSelectedAsset, false, false); +// mInventoryList->setSelection(obj_id, false); +// } +} + +void LLFloaterMyEnvironment::onOpen(const LLSD& key) +{ + LLFloater::onOpen(key); + + if (key.has("asset_id") && mInventoryList) + { + mSelectedAsset = key["asset_id"].asUUID(); + } + else + { + mSelectedAsset.setNull(); + } + + refresh(); +} + +//------------------------------------------------------------------------- +void LLFloaterMyEnvironment::onShowFoldersChange() +{ + bool show_check (getChild(CHECK_SHOWFOLDERS)->getValue().asBoolean()); + + mShowFolders = (show_check) ? LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS; + + if (mInventoryList) + mInventoryList->setShowFolderState(mShowFolders); +} + +void LLFloaterMyEnvironment::onFilterCheckChange() +{ + mTypeFilter = 0x0; + + if (getChild(CHECK_DAYS)->getValue().asBoolean()) + mTypeFilter |= 0x01 << static_cast(LLSettingsType::ST_DAYCYCLE); + if (getChild(CHECK_SKIES)->getValue().asBoolean()) + mTypeFilter |= 0x01 << static_cast(LLSettingsType::ST_SKY); + if (getChild(CHECK_WATER)->getValue().asBoolean()) + mTypeFilter |= 0x01 << static_cast(LLSettingsType::ST_WATER); + + if (mInventoryList) + mInventoryList->setFilterSettingsTypes(mTypeFilter); +} + +//------------------------------------------------------------------------- +LLUUID LLFloaterMyEnvironment::findItemByAssetId(LLUUID asset_id, bool copyable_only, bool ignore_library) +{ + /*TODO: Rider: Move this to gInventory? */ + + LLViewerInventoryCategory::cat_array_t cats; + LLViewerInventoryItem::item_array_t items; + LLAssetIDMatches asset_id_matches(asset_id); + + gInventory.collectDescendentsIf(LLUUID::null, + cats, + items, + LLInventoryModel::INCLUDE_TRASH, + asset_id_matches); + + if (!items.empty()) + { + // search for copyable version first + for (auto & item : items) + { + const LLPermissions& item_permissions = item->getPermissions(); + if (item_permissions.allowCopyBy(gAgent.getID(), gAgent.getGroupID())) + { + if(!ignore_library || !gInventory.isObjectDescendentOf(item->getUUID(),gInventory.getLibraryRootFolderID())) + { + return item->getUUID(); + } + } + } + // otherwise just return first instance, unless copyable requested + if (copyable_only) + { + return LLUUID::null; + } + else + { + if(!ignore_library || !gInventory.isObjectDescendentOf(items[0]->getUUID(),gInventory.getLibraryRootFolderID())) + { + return items[0]->getUUID(); + } + } + } + + return LLUUID::null; +} + +#if 0 +void LLFloaterGesture::done() +{ + //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; + uuid_vec_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; + } + + } + if (!unloaded_folders.empty()) + { + LL_DEBUGS("Gesture")<< "Fetching subdirectories....." << LL_ENDL; + setFetchIDs(unloaded_folders); + startFetch(); + } + 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; + } +} + +// virtual + +void LLFloaterGesture::refreshAll() +{ + if (!mGestureList) return; + + buildGestureList(); + + if (mSelectedID.isNull()) + { + mGestureList->selectFirstItem(); + } + else + { + if (! mGestureList->setCurrentByID(mSelectedID)) + { + mGestureList->selectFirstItem(); + } + } + + // Update button labels + onCommitList(); +} + +void LLFloaterGesture::buildGestureList() +{ + S32 scroll_pos = mGestureList->getScrollPos(); + uuid_vec_t selected_items; + getSelectedIds(selected_items); + LL_DEBUGS("Gesture")<< "Rebuilding gesture list "<< LL_ENDL; + mGestureList->deleteAllItems(); + + LLGestureMgr::item_map_t::const_iterator it; + const LLGestureMgr::item_map_t& active_gestures = LLGestureMgr::instance().getActiveGestures(); + for (it = active_gestures.begin(); it != active_gestures.end(); ++it) + { + 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); + + for (LLInventoryModel::item_array_t::iterator it = items.begin(); it!= items.end(); ++it) + { + LLInventoryItem* item = it->get(); + if (active_gestures.find(item->getUUID()) == active_gestures.end()) + { + // if gesture wasn't loaded yet, we can display only name + addGesture(item->getUUID(), NULL, mGestureList); + } + } + } + + // attempt to preserve scroll position through re-builds + // since we do re-build whenever something gets dirty + for(uuid_vec_t::iterator it = selected_items.begin(); it != selected_items.end(); it++) + { + mGestureList->selectByID(*it); + } + mGestureList->setScrollPos(scroll_pos); +} + +void LLFloaterGesture::addGesture(const LLUUID& item_id , LLMultiGesture* gesture,LLCtrlListInterface * 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(); + } + + static std::string font_style = "NORMAL"; + // If gesture is playing, bold it + + LLSD element; + element["id"] = item_id; + + if (gesture) + { + if (gesture->mPlaying) + { + 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 key_string; + std::string buffer; + + if (gesture->mKey == KEY_NONE) + { + buffer = "---"; + key_string = "~~~"; // alphabetize to end + } + else + { + key_string = LLKeyboard::stringFromKey(gesture->mKey); + buffer = LLKeyboard::stringFromAccelerator(gesture->mMask, + gesture->mKey); + } + + element["columns"][1]["column"] = "shortcut"; + element["columns"][1]["value"] = buffer; + element["columns"][1]["font"]["name"] = "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"]["name"] = "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 += " " + getString("playing"); + } + element["columns"][3]["column"] = "name"; + element["columns"][3]["value"] = item_name; + element["columns"][3]["font"]["name"] = "SANSSERIF"; + element["columns"][3]["font"]["style"] = font_style; + } + 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"][1]["column"] = "shortcut"; + element["columns"][1]["value"] = "---"; + element["columns"][1]["font"]["name"] = "SANSSERIF"; + element["columns"][1]["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; + } + + LL_DEBUGS("Gesture") << "Added gesture [" << item_name << "]" << LL_ENDL; + + LLScrollListItem* sl_item = list->addElement(element, ADD_BOTTOM); + if(sl_item) + { + LLFontGL::StyleFlags style = LLGestureMgr::getInstance()->isGestureActive(item_id) ? LLFontGL::BOLD : LLFontGL::NORMAL; + // *TODO find out why ["font"]["style"] does not affect font style + ((LLScrollListText*)sl_item->getColumn(0))->setFontStyle(style); + } +} + +void LLFloaterGesture::getSelectedIds(uuid_vec_t& ids) +{ + std::vector items = mGestureList->getAllSelected(); + for(std::vector::const_iterator it = items.begin(); it != items.end(); it++) + { + ids.push_back((*it)->getUUID()); + } +} + +bool LLFloaterGesture::isActionEnabled(const LLSD& command) +{ + // paste copy_uuid edit_gesture + std::string command_name = command.asString(); + if("paste" == command_name) + { + if(!LLClipboard::instance().hasContents()) + return false; + + std::vector ids; + LLClipboard::instance().pasteFromClipboard(ids); + for(std::vector::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 if("copy_uuid" == command_name || "edit_gesture" == command_name) + { + return mGestureList->getAllSelected().size() == 1; + } + return true; +} + +void LLFloaterGesture::onClickPlay() +{ + const LLUUID& item_id = mGestureList->getCurrentID(); + if(item_id.isNull()) return; + + LL_DEBUGS("Gesture")<<" Trying to play gesture id: "<< item_id <getAssetUUID(), inform_server, deactivate_similar); + LL_DEBUGS("Gesture")<< "Activating gesture with inventory ID: " << item_id < cb = new GestureShowCallback(); + create_inventory_item(gAgent.getID(), + gAgent.getSessionID(), + LLUUID::null, + LLTransactionID::tnull, + "New Gesture", + "", + LLAssetType::AT_GESTURE, + LLInventoryType::IT_GESTURE, + NO_INV_SUBTYPE, + PERM_MOVE | LLFloaterPerms::getNextOwnerPerms("Gestures"), + cb); +} + +void LLFloaterGesture::onActivateBtnClick() +{ + uuid_vec_t ids; + getSelectedIds(ids); + if(ids.empty()) + return; + + LLGestureMgr* gm = LLGestureMgr::getInstance(); + uuid_vec_t::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(uuid_vec_t::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); + } + } + } +} + +void LLFloaterGesture::onCopyPasteAction(const LLSD& command) +{ + std::string command_name = command.asString(); + // Since we select this command, the inventory items must have already arrived + if("copy_gesture" == command_name) + { + uuid_vec_t ids; + getSelectedIds(ids); + // Make sure the clipboard is empty + LLClipboard::instance().reset(); + for(uuid_vec_t::iterator it = ids.begin(); it != ids.end(); it++) + { + LLInventoryItem* item = gInventory.getItem(*it); + if(item && item->getInventoryType() == LLInventoryType::IT_GESTURE) + { + LLWString item_name = utf8str_to_wstring(item->getName()); + LLClipboard::instance().addToClipboard(item_name, 0, item_name.size()); + } + } + } + else if ("paste" == command_name) + { + std::vector ids; + LLClipboard::instance().pasteFromClipboard(ids); + if(ids.empty() || !gInventory.isCategoryComplete(mGestureFolderID)) + return; + LLInventoryCategory* gesture_dir = gInventory.getCategory(mGestureFolderID); + llassert(gesture_dir); + LLPointer cb = new GestureCopiedCallback(this); + + for(std::vector::iterator it = ids.begin(); it != ids.end(); it++) + { + LLInventoryItem* item = gInventory.getItem(*it); + if(gesture_dir && item && item->getInventoryType() == LLInventoryType::IT_GESTURE) + { + LLStringUtil::format_map_t string_args; + string_args["[COPY_NAME]"] = item->getName(); + 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); + } + } + LLClipboard::instance().reset(); + } + else if ("copy_uuid" == command_name) + { + LLClipboard::instance().copyToClipboard(mGestureList->getCurrentID(),LLAssetType::AT_GESTURE); + } +} + +void LLFloaterGesture::onClickEdit() +{ + const LLUUID& item_id = mGestureList->getCurrentID(); + + LLInventoryItem* item = gInventory.getItem(item_id); + if (!item) return; + + LLPreviewGesture* previewp = LLPreviewGesture::show(item_id, LLUUID::null); + if (!previewp->getHost()) + { + previewp->setRect(gFloaterView->findNeighboringPosition(this, previewp)); + } +} + +void LLFloaterGesture::onCommitList() +{ + const LLUUID& item_id = mGestureList->getCurrentID(); + + mSelectedID = item_id; + if (LLGestureMgr::instance().isGesturePlaying(item_id)) + { + getChildView("play_btn")->setVisible( false); + getChildView("stop_btn")->setVisible( true); + } + else + { + getChildView("play_btn")->setVisible( true); + getChildView("stop_btn")->setVisible( false); + } +} + +void LLFloaterGesture::onDeleteSelected() +{ + uuid_vec_t ids; + getSelectedIds(ids); + if(ids.empty()) + return; + + const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH); + LLGestureMgr* gm = LLGestureMgr::getInstance(); + for(uuid_vec_t::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 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() +{ + uuid_vec_t ids; + getSelectedIds(ids); + LLAppearanceMgr* am = LLAppearanceMgr::getInstance(); + LLPointer cb = new LLUpdateAppearanceOnDestroy; + for(uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); it++) + { + am->addCOFItemLink(*it, cb); + } +} + +void LLFloaterGesture::playGesture(LLUUID item_id) +{ + LL_DEBUGS("Gesture")<<"Playing gesture "<< item_id< Date: Mon, 9 Jul 2018 17:06:24 -0700 Subject: MAINT-8821: Clean up some of the selection and enable/disable code, Add menu for adding settings. --- indra/newview/llfloatermyenvironment.cpp | 564 +++++-------------------------- 1 file changed, 80 insertions(+), 484 deletions(-) (limited to 'indra/newview/llfloatermyenvironment.cpp') diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index 83cd726eb8..4863e4c471 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -47,6 +47,7 @@ #include "llviewerinventory.h" #include "llviewercontrol.h" #include "llfloaterperms.h" +#include "llenvironment.h" //========================================================================= namespace @@ -59,7 +60,6 @@ namespace const std::string BUTTON_NEWSETTINGS("btn_gear"); const std::string BUTTON_GEAR("btn_newsettings"); const std::string BUTTON_DELETE("btn_del"); - const std::string BUTTON_EDIT("btn_edit"); } @@ -137,7 +137,10 @@ LLFloaterMyEnvironment::LLFloaterMyEnvironment(const LLSD& key) : mTypeFilter((0x01 << static_cast(LLSettingsType::ST_DAYCYCLE)) | (0x01 << static_cast(LLSettingsType::ST_SKY)) | (0x01 << static_cast(LLSettingsType::ST_WATER))), mSelectedAsset() { - + mCommitCallbackRegistrar.add("MyEnvironments.DoCreate", [this](LLUICtrl *, const LLSD &userdata) { onDoCreate(userdata); }); + + mEnableCallbackRegistrar.add("MyEnvironments.EnvironmentEnabled", [](LLUICtrl *, const LLSD &) { return LLEnvironment::instance().isInventoryEnabled(); }); + #if 0 mObserver = new LLFloaterGestureObserver(this); LLGestureMgr::instance().addObserver(mObserver); @@ -171,7 +174,7 @@ BOOL LLFloaterMyEnvironment::postBuild() mInventoryList->setFilterTypes(filter_types); -// mInventoryList->setSelectCallback(boost::bind(&LLFloaterTexturePicker::onSelectionChange, this, _1, _2)); + mInventoryList->setSelectCallback([this](const std::deque&, BOOL) { onSelectionChange(); }); mInventoryList->setShowFolderState(mShowFolders); mInventoryList->setFilterSettingsTypes(mTypeFilter); } @@ -181,11 +184,7 @@ BOOL LLFloaterMyEnvironment::postBuild() childSetCommitCallback(CHECK_WATER, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); childSetCommitCallback(CHECK_SHOWFOLDERS, [this](LLUICtrl*, void*) { onShowFoldersChange(); }, nullptr); - /*TODO: Enable these*/ - getChild(BUTTON_NEWSETTINGS)->setEnabled(false); - getChild(BUTTON_GEAR)->setEnabled(false); - getChild(BUTTON_DELETE)->setEnabled(false); - getChild(BUTTON_EDIT)->setEnabled(false); + childSetCommitCallback(BUTTON_DELETE, [this](LLUICtrl *, void*) { onDeleteSelected(); }, nullptr); return TRUE; } @@ -198,11 +197,8 @@ void LLFloaterMyEnvironment::refresh() getChild(CHECK_SKIES)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast(LLSettingsType::ST_SKY)))); getChild(CHECK_WATER)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast(LLSettingsType::ST_WATER)))); -// if (mInventoryList) -// { -// LLUUID obj_id = findItemByAssetId(mSelectedAsset, false, false); -// mInventoryList->setSelection(obj_id, false); -// } + refreshButtonStates(); + } void LLFloaterMyEnvironment::onOpen(const LLSD& key) @@ -212,6 +208,13 @@ void LLFloaterMyEnvironment::onOpen(const LLSD& key) if (key.has("asset_id") && mInventoryList) { mSelectedAsset = key["asset_id"].asUUID(); + + if (!mSelectedAsset.isNull()) + { + LLUUID obj_id = findItemByAssetId(mSelectedAsset, false, false); + if (!obj_id.isNull()) + mInventoryList->setSelection(obj_id, false); + } } else { @@ -247,6 +250,63 @@ void LLFloaterMyEnvironment::onFilterCheckChange() mInventoryList->setFilterSettingsTypes(mTypeFilter); } +void LLFloaterMyEnvironment::onSelectionChange() +{ + refreshButtonStates(); +} + +void LLFloaterMyEnvironment::onDeleteSelected() +{ + uuid_vec_t selected; + + getSelectedIds(selected); + if (selected.empty()) + return; + + const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH); + for (const LLUUID& itemid: selected) + { + LLInventoryItem* inv_item = gInventory.getItem(itemid); + + if (inv_item && inv_item->getInventoryType() == LLInventoryType::IT_SETTINGS) + { + 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 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(); +} + + +void LLFloaterMyEnvironment::onDoCreate(const LLSD &data) +{ + menu_create_inventory_item(mInventoryList, NULL, data); +} + +//------------------------------------------------------------------------- +void LLFloaterMyEnvironment::refreshButtonStates() +{ + bool settings_ok = LLEnvironment::instance().isInventoryEnabled(); + + uuid_vec_t selected; + getSelectedIds(selected); + + getChild(BUTTON_GEAR)->setEnabled(settings_ok); + getChild(BUTTON_NEWSETTINGS)->setEnabled(true); + getChild(BUTTON_DELETE)->setEnabled(settings_ok && !selected.empty()); +} + //------------------------------------------------------------------------- LLUUID LLFloaterMyEnvironment::findItemByAssetId(LLUUID asset_id, bool copyable_only, bool ignore_library) { @@ -293,477 +353,13 @@ LLUUID LLFloaterMyEnvironment::findItemByAssetId(LLUUID asset_id, bool copyable_ return LLUUID::null; } -#if 0 -void LLFloaterGesture::done() -{ - //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; - uuid_vec_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; - } - - } - if (!unloaded_folders.empty()) - { - LL_DEBUGS("Gesture")<< "Fetching subdirectories....." << LL_ENDL; - setFetchIDs(unloaded_folders); - startFetch(); - } - 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; - } -} - -// virtual - -void LLFloaterGesture::refreshAll() -{ - if (!mGestureList) return; - - buildGestureList(); - - if (mSelectedID.isNull()) - { - mGestureList->selectFirstItem(); - } - else - { - if (! mGestureList->setCurrentByID(mSelectedID)) - { - mGestureList->selectFirstItem(); - } - } - - // Update button labels - onCommitList(); -} - -void LLFloaterGesture::buildGestureList() -{ - S32 scroll_pos = mGestureList->getScrollPos(); - uuid_vec_t selected_items; - getSelectedIds(selected_items); - LL_DEBUGS("Gesture")<< "Rebuilding gesture list "<< LL_ENDL; - mGestureList->deleteAllItems(); - - LLGestureMgr::item_map_t::const_iterator it; - const LLGestureMgr::item_map_t& active_gestures = LLGestureMgr::instance().getActiveGestures(); - for (it = active_gestures.begin(); it != active_gestures.end(); ++it) - { - 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); - - for (LLInventoryModel::item_array_t::iterator it = items.begin(); it!= items.end(); ++it) - { - LLInventoryItem* item = it->get(); - if (active_gestures.find(item->getUUID()) == active_gestures.end()) - { - // if gesture wasn't loaded yet, we can display only name - addGesture(item->getUUID(), NULL, mGestureList); - } - } - } - - // attempt to preserve scroll position through re-builds - // since we do re-build whenever something gets dirty - for(uuid_vec_t::iterator it = selected_items.begin(); it != selected_items.end(); it++) - { - mGestureList->selectByID(*it); - } - mGestureList->setScrollPos(scroll_pos); -} - -void LLFloaterGesture::addGesture(const LLUUID& item_id , LLMultiGesture* gesture,LLCtrlListInterface * 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(); - } - - static std::string font_style = "NORMAL"; - // If gesture is playing, bold it - - LLSD element; - element["id"] = item_id; - - if (gesture) - { - if (gesture->mPlaying) - { - 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 key_string; - std::string buffer; - - if (gesture->mKey == KEY_NONE) - { - buffer = "---"; - key_string = "~~~"; // alphabetize to end - } - else - { - key_string = LLKeyboard::stringFromKey(gesture->mKey); - buffer = LLKeyboard::stringFromAccelerator(gesture->mMask, - gesture->mKey); - } - - element["columns"][1]["column"] = "shortcut"; - element["columns"][1]["value"] = buffer; - element["columns"][1]["font"]["name"] = "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"]["name"] = "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 += " " + getString("playing"); - } - element["columns"][3]["column"] = "name"; - element["columns"][3]["value"] = item_name; - element["columns"][3]["font"]["name"] = "SANSSERIF"; - element["columns"][3]["font"]["style"] = font_style; - } - 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"][1]["column"] = "shortcut"; - element["columns"][1]["value"] = "---"; - element["columns"][1]["font"]["name"] = "SANSSERIF"; - element["columns"][1]["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; - } - - LL_DEBUGS("Gesture") << "Added gesture [" << item_name << "]" << LL_ENDL; - - LLScrollListItem* sl_item = list->addElement(element, ADD_BOTTOM); - if(sl_item) - { - LLFontGL::StyleFlags style = LLGestureMgr::getInstance()->isGestureActive(item_id) ? LLFontGL::BOLD : LLFontGL::NORMAL; - // *TODO find out why ["font"]["style"] does not affect font style - ((LLScrollListText*)sl_item->getColumn(0))->setFontStyle(style); - } -} - -void LLFloaterGesture::getSelectedIds(uuid_vec_t& ids) -{ - std::vector items = mGestureList->getAllSelected(); - for(std::vector::const_iterator it = items.begin(); it != items.end(); it++) - { - ids.push_back((*it)->getUUID()); - } -} - -bool LLFloaterGesture::isActionEnabled(const LLSD& command) -{ - // paste copy_uuid edit_gesture - std::string command_name = command.asString(); - if("paste" == command_name) - { - if(!LLClipboard::instance().hasContents()) - return false; - - std::vector ids; - LLClipboard::instance().pasteFromClipboard(ids); - for(std::vector::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 if("copy_uuid" == command_name || "edit_gesture" == command_name) - { - return mGestureList->getAllSelected().size() == 1; - } - return true; -} - -void LLFloaterGesture::onClickPlay() -{ - const LLUUID& item_id = mGestureList->getCurrentID(); - if(item_id.isNull()) return; - - LL_DEBUGS("Gesture")<<" Trying to play gesture id: "<< item_id <getAssetUUID(), inform_server, deactivate_similar); - LL_DEBUGS("Gesture")<< "Activating gesture with inventory ID: " << item_id < cb = new GestureShowCallback(); - create_inventory_item(gAgent.getID(), - gAgent.getSessionID(), - LLUUID::null, - LLTransactionID::tnull, - "New Gesture", - "", - LLAssetType::AT_GESTURE, - LLInventoryType::IT_GESTURE, - NO_INV_SUBTYPE, - PERM_MOVE | LLFloaterPerms::getNextOwnerPerms("Gestures"), - cb); -} - -void LLFloaterGesture::onActivateBtnClick() +void LLFloaterMyEnvironment::getSelectedIds(uuid_vec_t& ids) const { - uuid_vec_t ids; - getSelectedIds(ids); - if(ids.empty()) - return; - - LLGestureMgr* gm = LLGestureMgr::getInstance(); - uuid_vec_t::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(uuid_vec_t::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); - } - } - } -} + LLInventoryPanel::selected_items_t items = mInventoryList->getSelectedItems(); -void LLFloaterGesture::onCopyPasteAction(const LLSD& command) -{ - std::string command_name = command.asString(); - // Since we select this command, the inventory items must have already arrived - if("copy_gesture" == command_name) - { - uuid_vec_t ids; - getSelectedIds(ids); - // Make sure the clipboard is empty - LLClipboard::instance().reset(); - for(uuid_vec_t::iterator it = ids.begin(); it != ids.end(); it++) - { - LLInventoryItem* item = gInventory.getItem(*it); - if(item && item->getInventoryType() == LLInventoryType::IT_GESTURE) - { - LLWString item_name = utf8str_to_wstring(item->getName()); - LLClipboard::instance().addToClipboard(item_name, 0, item_name.size()); - } - } - } - else if ("paste" == command_name) - { - std::vector ids; - LLClipboard::instance().pasteFromClipboard(ids); - if(ids.empty() || !gInventory.isCategoryComplete(mGestureFolderID)) - return; - LLInventoryCategory* gesture_dir = gInventory.getCategory(mGestureFolderID); - llassert(gesture_dir); - LLPointer cb = new GestureCopiedCallback(this); - - for(std::vector::iterator it = ids.begin(); it != ids.end(); it++) - { - LLInventoryItem* item = gInventory.getItem(*it); - if(gesture_dir && item && item->getInventoryType() == LLInventoryType::IT_GESTURE) - { - LLStringUtil::format_map_t string_args; - string_args["[COPY_NAME]"] = item->getName(); - 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); - } - } - LLClipboard::instance().reset(); - } - else if ("copy_uuid" == command_name) - { - LLClipboard::instance().copyToClipboard(mGestureList->getCurrentID(),LLAssetType::AT_GESTURE); - } -} - -void LLFloaterGesture::onClickEdit() -{ - const LLUUID& item_id = mGestureList->getCurrentID(); - - LLInventoryItem* item = gInventory.getItem(item_id); - if (!item) return; - - LLPreviewGesture* previewp = LLPreviewGesture::show(item_id, LLUUID::null); - if (!previewp->getHost()) - { - previewp->setRect(gFloaterView->findNeighboringPosition(this, previewp)); - } -} - -void LLFloaterGesture::onCommitList() -{ - const LLUUID& item_id = mGestureList->getCurrentID(); - - mSelectedID = item_id; - if (LLGestureMgr::instance().isGesturePlaying(item_id)) - { - getChildView("play_btn")->setVisible( false); - getChildView("stop_btn")->setVisible( true); - } - else - { - getChildView("play_btn")->setVisible( true); - getChildView("stop_btn")->setVisible( false); - } -} - -void LLFloaterGesture::onDeleteSelected() -{ - uuid_vec_t ids; - getSelectedIds(ids); - if(ids.empty()) - return; - - const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH); - LLGestureMgr* gm = LLGestureMgr::getInstance(); - for(uuid_vec_t::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 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() -{ - uuid_vec_t ids; - getSelectedIds(ids); - LLAppearanceMgr* am = LLAppearanceMgr::getInstance(); - LLPointer cb = new LLUpdateAppearanceOnDestroy; - for(uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); it++) - { - am->addCOFItemLink(*it, cb); - } -} - -void LLFloaterGesture::playGesture(LLUUID item_id) -{ - LL_DEBUGS("Gesture")<<"Playing gesture "<< item_id<(itemview->getViewModelItem()); + ids.push_back(itemp->getUUID()); + } } -#endif -- cgit v1.2.3 From 294793b9a983a0c26c0e82bd432d4cc311ecb1ba Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 10 Jul 2018 15:15:47 -0700 Subject: MAINT-8821: Tighten up floater. Allow apply from gear menu. --- indra/newview/llfloatermyenvironment.cpp | 126 +++++++++++++++++++++++++++---- 1 file changed, 111 insertions(+), 15 deletions(-) (limited to 'indra/newview/llfloatermyenvironment.cpp') diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index 4863e4c471..a42a356c49 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -48,6 +48,8 @@ #include "llviewercontrol.h" #include "llfloaterperms.h" #include "llenvironment.h" +#include "llparcel.h" +#include "llviewerparcelmgr.h" //========================================================================= namespace @@ -61,6 +63,23 @@ namespace const std::string BUTTON_GEAR("btn_newsettings"); const std::string BUTTON_DELETE("btn_del"); + + const std::string ACTION_DOCREATE("MyEnvironments.DoCreate"); + const std::string ACTION_DOEDIT("MyEnvironments.DoEdit"); + const std::string ACTION_DOAPPLY("MyEnvironments.DoApply"); + const std::string ACTION_COPYPASTE("MyEnvironments.CopyPaste"); + const std::string ENABLE_ACTION("MyEnvironments.EnableAction"); + const std::string ENABLE_CANAPPLY("MyEnvironments.CanApply"); + const std::string ENABLE_ENVIRONMENT("MyEnvironments.EnvironmentEnabled"); + + const std::string PARAMETER_REGION("region"); + const std::string PARAMETER_PARCEL("parcel"); + const std::string PARAMETER_LOCAL("local"); + + const std::string PARAMETER_EDIT("edit"); + const std::string PARAMETER_COPY("copy"); + const std::string PARAMETER_PASTE("paste"); + const std::string PARAMETER_COPYUUID("copy_uuid"); } //========================================================================= @@ -137,21 +156,15 @@ LLFloaterMyEnvironment::LLFloaterMyEnvironment(const LLSD& key) : mTypeFilter((0x01 << static_cast(LLSettingsType::ST_DAYCYCLE)) | (0x01 << static_cast(LLSettingsType::ST_SKY)) | (0x01 << static_cast(LLSettingsType::ST_WATER))), mSelectedAsset() { - mCommitCallbackRegistrar.add("MyEnvironments.DoCreate", [this](LLUICtrl *, const LLSD &userdata) { onDoCreate(userdata); }); - - mEnableCallbackRegistrar.add("MyEnvironments.EnvironmentEnabled", [](LLUICtrl *, const LLSD &) { return LLEnvironment::instance().isInventoryEnabled(); }); - -#if 0 - mObserver = new LLFloaterGestureObserver(this); - LLGestureMgr::instance().addObserver(mObserver); + mCommitCallbackRegistrar.add(ACTION_DOCREATE, [this](LLUICtrl *, const LLSD &userdata) { onDoCreate(userdata); }); + mCommitCallbackRegistrar.add(ACTION_DOEDIT, [this](LLUICtrl *, const LLSD &userdata) {}); + mCommitCallbackRegistrar.add(ACTION_DOAPPLY, [this](LLUICtrl *, const LLSD &userdata) { onDoApply(userdata.asString()); }); + mCommitCallbackRegistrar.add(ACTION_COPYPASTE, [this](LLUICtrl *, const LLSD &userdata) {}); - 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)); + mEnableCallbackRegistrar.add(ENABLE_ACTION, [this](LLUICtrl *, const LLSD &userdata) { return canAction(userdata.asString()); }); + mEnableCallbackRegistrar.add(ENABLE_CANAPPLY, [this](LLUICtrl *, const LLSD &userdata) { return canApply(userdata.asString()); }); + mEnableCallbackRegistrar.add(ENABLE_ENVIRONMENT, [](LLUICtrl *, const LLSD &) { return LLEnvironment::instance().isInventoryEnabled(); }); - mEnableCallbackRegistrar.add("Gesture.EnableAction", boost::bind(&LLFloaterGesture::isActionEnabled, this, _2)); -#endif } LLFloaterMyEnvironment::~LLFloaterMyEnvironment() @@ -279,8 +292,6 @@ void LLFloaterMyEnvironment::onDeleteSelected() LLPointer 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); } @@ -294,6 +305,91 @@ void LLFloaterMyEnvironment::onDoCreate(const LLSD &data) menu_create_inventory_item(mInventoryList, NULL, data); } +void LLFloaterMyEnvironment::onDoApply(const std::string &context) +{ + uuid_vec_t selected; + getSelectedIds(selected); + + if (selected.size() != 1) // Exactly one item selected. + return; + + LLUUID item_id(selected.front()); + + LLInventoryItem* itemp = gInventory.getItem(item_id); + + if (itemp && itemp->getInventoryType() == LLInventoryType::IT_SETTINGS) + { + LLUUID asset_id = itemp->getAssetUUID(); + + if (context == PARAMETER_REGION) + { + LLEnvironment::instance().updateRegion(asset_id, -1, -1); + } + else if (context == PARAMETER_PARCEL) + { + LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel()); + if (!parcel) + { + LL_WARNS("ENVIRONMENT") << "Unable to determine parcel." << LL_ENDL; + return; + } + LLEnvironment::instance().updateParcel(parcel->getLocalID(), asset_id, -1, -1); + } + else if (context == PARAMETER_LOCAL) + { + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, asset_id); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + } + } +} + + +bool LLFloaterMyEnvironment::canAction(const std::string &context) +{ +// uuid_vec_t selected; +// getSelectedIds(selected); +// +// if (selected.empty()) +// return false; +// +// if (context == PARAMETER_EDIT) +// { +// } +// else if (context == PARAMETER_COPY) +// { +// } +// else if (context == PARAMETER_PASTE) +// { +// } +// else if (context == PARAMETER_COPYUUID) +// { +// } + + return false; +} + +bool LLFloaterMyEnvironment::canApply(const std::string &context) +{ + uuid_vec_t selected; + getSelectedIds(selected); + + if (selected.size() != 1) // Exactly one item selected. + return false; + + if (context == PARAMETER_REGION) + { + return LLEnvironment::instance().canAgentUpdateRegionEnvironment(); + } + else if (context == PARAMETER_PARCEL) + { + return LLEnvironment::instance().canAgentUpdateParcelEnvironment(); + } + else + { + return (context == PARAMETER_LOCAL); + } +} + //------------------------------------------------------------------------- void LLFloaterMyEnvironment::refreshButtonStates() { -- cgit v1.2.3 From 31aa86b7039b025b23b5b02455e65be103e2ea0b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 19 Jul 2018 21:11:23 +0100 Subject: Compile fixes for latest Xcode on OSX. --- indra/newview/llfloatermyenvironment.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloatermyenvironment.cpp') diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index a42a356c49..62c9997ebf 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -157,9 +157,9 @@ LLFloaterMyEnvironment::LLFloaterMyEnvironment(const LLSD& key) : mSelectedAsset() { mCommitCallbackRegistrar.add(ACTION_DOCREATE, [this](LLUICtrl *, const LLSD &userdata) { onDoCreate(userdata); }); - mCommitCallbackRegistrar.add(ACTION_DOEDIT, [this](LLUICtrl *, const LLSD &userdata) {}); + mCommitCallbackRegistrar.add(ACTION_DOEDIT, [this](LLUICtrl *, const LLSD &userdata) {(void)this;}); mCommitCallbackRegistrar.add(ACTION_DOAPPLY, [this](LLUICtrl *, const LLSD &userdata) { onDoApply(userdata.asString()); }); - mCommitCallbackRegistrar.add(ACTION_COPYPASTE, [this](LLUICtrl *, const LLSD &userdata) {}); + mCommitCallbackRegistrar.add(ACTION_COPYPASTE, [this](LLUICtrl *, const LLSD &userdata) {(void)this;}); mEnableCallbackRegistrar.add(ENABLE_ACTION, [this](LLUICtrl *, const LLSD &userdata) { return canAction(userdata.asString()); }); mEnableCallbackRegistrar.add(ENABLE_CANAPPLY, [this](LLUICtrl *, const LLSD &userdata) { return canApply(userdata.asString()); }); -- cgit v1.2.3 From bb836fcdec22c4dbdc40f768be491e0d5d897089 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 19 Jul 2018 13:40:47 -0700 Subject: Should have been an empty capture for noop lambdas. --- indra/newview/llfloatermyenvironment.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloatermyenvironment.cpp') diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index 62c9997ebf..35f43d57e2 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -157,9 +157,9 @@ LLFloaterMyEnvironment::LLFloaterMyEnvironment(const LLSD& key) : mSelectedAsset() { mCommitCallbackRegistrar.add(ACTION_DOCREATE, [this](LLUICtrl *, const LLSD &userdata) { onDoCreate(userdata); }); - mCommitCallbackRegistrar.add(ACTION_DOEDIT, [this](LLUICtrl *, const LLSD &userdata) {(void)this;}); + mCommitCallbackRegistrar.add(ACTION_DOEDIT, [](LLUICtrl *, const LLSD &userdata) { }); mCommitCallbackRegistrar.add(ACTION_DOAPPLY, [this](LLUICtrl *, const LLSD &userdata) { onDoApply(userdata.asString()); }); - mCommitCallbackRegistrar.add(ACTION_COPYPASTE, [this](LLUICtrl *, const LLSD &userdata) {(void)this;}); + mCommitCallbackRegistrar.add(ACTION_COPYPASTE, [](LLUICtrl *, const LLSD &userdata) { }); mEnableCallbackRegistrar.add(ENABLE_ACTION, [this](LLUICtrl *, const LLSD &userdata) { return canAction(userdata.asString()); }); mEnableCallbackRegistrar.add(ENABLE_CANAPPLY, [this](LLUICtrl *, const LLSD &userdata) { return canApply(userdata.asString()); }); -- cgit v1.2.3 From e010203d769c907d3b5570c3062ca2fd38046bd2 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Wed, 5 Sep 2018 16:41:23 +0300 Subject: MAINT-9080 Edit, Copy, Copy UUID options greyed out in My Environments floater --- indra/newview/llfloatermyenvironment.cpp | 75 +++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 21 deletions(-) (limited to 'indra/newview/llfloatermyenvironment.cpp') diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index 35f43d57e2..6dcff7c264 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -157,9 +157,9 @@ LLFloaterMyEnvironment::LLFloaterMyEnvironment(const LLSD& key) : mSelectedAsset() { mCommitCallbackRegistrar.add(ACTION_DOCREATE, [this](LLUICtrl *, const LLSD &userdata) { onDoCreate(userdata); }); - mCommitCallbackRegistrar.add(ACTION_DOEDIT, [](LLUICtrl *, const LLSD &userdata) { }); + mCommitCallbackRegistrar.add(ACTION_DOEDIT, [this](LLUICtrl *, const LLSD &userdata) { mInventoryList->openSelected(); }); mCommitCallbackRegistrar.add(ACTION_DOAPPLY, [this](LLUICtrl *, const LLSD &userdata) { onDoApply(userdata.asString()); }); - mCommitCallbackRegistrar.add(ACTION_COPYPASTE, [](LLUICtrl *, const LLSD &userdata) { }); + mCommitCallbackRegistrar.add(ACTION_COPYPASTE, [this](LLUICtrl *, const LLSD &userdata) { mInventoryList->doToSelected(userdata.asString()); }); mEnableCallbackRegistrar.add(ENABLE_ACTION, [this](LLUICtrl *, const LLSD &userdata) { return canAction(userdata.asString()); }); mEnableCallbackRegistrar.add(ENABLE_CANAPPLY, [this](LLUICtrl *, const LLSD &userdata) { return canApply(userdata.asString()); }); @@ -343,27 +343,49 @@ void LLFloaterMyEnvironment::onDoApply(const std::string &context) } } - bool LLFloaterMyEnvironment::canAction(const std::string &context) { -// uuid_vec_t selected; -// getSelectedIds(selected); -// -// if (selected.empty()) -// return false; -// -// if (context == PARAMETER_EDIT) -// { -// } -// else if (context == PARAMETER_COPY) -// { -// } -// else if (context == PARAMETER_PASTE) -// { -// } -// else if (context == PARAMETER_COPYUUID) -// { -// } + uuid_vec_t selected; + getSelectedIds(selected); + + if (selected.empty()) + return false; + + if (context == PARAMETER_EDIT) + { + return (selected.size() == 1) && isSettingSelected(selected.front()); + } + else if (context == PARAMETER_COPY) + { + for (std::vector::iterator it = selected.begin(); it != selected.end(); it++) + { + if(!isSettingSelected(*it)) + { + return false; + } + } + return true; + } + else if (context == PARAMETER_PASTE) + { + if (!LLClipboard::instance().hasContents()) + return false; + + std::vector ids; + LLClipboard::instance().pasteFromClipboard(ids); + for (std::vector::iterator it = ids.begin(); it != ids.end(); it++) + { + if (!isSettingSelected(*it)) + { + return false; + } + } + return (selected.size() == 1); + } + else if (context == PARAMETER_COPYUUID) + { + return (selected.size() == 1) && isSettingSelected(selected.front()); + } return false; } @@ -449,6 +471,17 @@ LLUUID LLFloaterMyEnvironment::findItemByAssetId(LLUUID asset_id, bool copyable_ return LLUUID::null; } +bool LLFloaterMyEnvironment::isSettingSelected(LLUUID item_id) +{ + LLInventoryItem* itemp = gInventory.getItem(item_id); + + if (itemp && itemp->getInventoryType() == LLInventoryType::IT_SETTINGS) + { + return true; + } + return false; +} + void LLFloaterMyEnvironment::getSelectedIds(uuid_vec_t& ids) const { LLInventoryPanel::selected_items_t items = mInventoryList->getSelectedItems(); -- cgit v1.2.3 From 51772e6083d8af786704cee18f5eb3c9b3dfefda Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 2 Nov 2018 09:17:19 -0700 Subject: SL-9886: Viewer send and receive new day_name(s) information in the environment protocol for viewer specified names on individual tracks. --- indra/newview/llfloatermyenvironment.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloatermyenvironment.cpp') diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index 6dcff7c264..c34ca9e458 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -320,10 +320,11 @@ void LLFloaterMyEnvironment::onDoApply(const std::string &context) if (itemp && itemp->getInventoryType() == LLInventoryType::IT_SETTINGS) { LLUUID asset_id = itemp->getAssetUUID(); + std::string name = itemp->getName(); if (context == PARAMETER_REGION) { - LLEnvironment::instance().updateRegion(asset_id, -1, -1); + LLEnvironment::instance().updateRegion(asset_id, name, -1, -1); } else if (context == PARAMETER_PARCEL) { @@ -333,7 +334,7 @@ void LLFloaterMyEnvironment::onDoApply(const std::string &context) LL_WARNS("ENVIRONMENT") << "Unable to determine parcel." << LL_ENDL; return; } - LLEnvironment::instance().updateParcel(parcel->getLocalID(), asset_id, -1, -1); + LLEnvironment::instance().updateParcel(parcel->getLocalID(), asset_id, name, -1, -1); } else if (context == PARAMETER_LOCAL) { -- cgit v1.2.3 From d66012f85e885679738cf8c488fd8ff460319c85 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Fri, 30 Nov 2018 17:48:08 +0200 Subject: SL-9716 [EEP] "Use Shared Environment" does not enable when applying an environment to a parcel or region --- indra/newview/llfloatermyenvironment.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llfloatermyenvironment.cpp') diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index c34ca9e458..f93d7ce8ed 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -325,6 +325,7 @@ void LLFloaterMyEnvironment::onDoApply(const std::string &context) if (context == PARAMETER_REGION) { LLEnvironment::instance().updateRegion(asset_id, name, -1, -1); + LLEnvironment::instance().setSharedEnvironment(); } else if (context == PARAMETER_PARCEL) { @@ -335,6 +336,7 @@ void LLFloaterMyEnvironment::onDoApply(const std::string &context) return; } LLEnvironment::instance().updateParcel(parcel->getLocalID(), asset_id, name, -1, -1); + LLEnvironment::instance().setSharedEnvironment(); } else if (context == PARAMETER_LOCAL) { -- cgit v1.2.3 From 00d8caa359a216620db46d49696bc79a95fe8dc2 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 10 Jan 2019 22:11:11 +0200 Subject: SL-10279 Finalize drag and drop support --- indra/newview/llfloatermyenvironment.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloatermyenvironment.cpp') diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index f93d7ce8ed..1edec248d9 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -324,7 +324,7 @@ void LLFloaterMyEnvironment::onDoApply(const std::string &context) if (context == PARAMETER_REGION) { - LLEnvironment::instance().updateRegion(asset_id, name, -1, -1); + LLEnvironment::instance().updateRegion(asset_id, name, LLEnvironment::NO_TRACK, -1, -1); LLEnvironment::instance().setSharedEnvironment(); } else if (context == PARAMETER_PARCEL) @@ -335,7 +335,7 @@ void LLFloaterMyEnvironment::onDoApply(const std::string &context) LL_WARNS("ENVIRONMENT") << "Unable to determine parcel." << LL_ENDL; return; } - LLEnvironment::instance().updateParcel(parcel->getLocalID(), asset_id, name, -1, -1); + LLEnvironment::instance().updateParcel(parcel->getLocalID(), asset_id, name, LLEnvironment::NO_TRACK, -1, -1); LLEnvironment::instance().setSharedEnvironment(); } else if (context == PARAMETER_LOCAL) -- cgit v1.2.3 From 66aa3d390d78eab482ce51bc916789a35b6dd50f Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Mon, 8 Apr 2019 15:26:59 +0300 Subject: SL-10893 Remove "Show Empty Folders" option --- indra/newview/llfloatermyenvironment.cpp | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'indra/newview/llfloatermyenvironment.cpp') diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index 1edec248d9..3a83042d4f 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -58,7 +58,6 @@ namespace const std::string CHECK_SKIES("chk_skies"); const std::string CHECK_WATER("chk_water"); const std::string PANEL_SETTINGS("pnl_settings"); - const std::string CHECK_SHOWFOLDERS("chk_showfolders"); const std::string BUTTON_NEWSETTINGS("btn_gear"); const std::string BUTTON_GEAR("btn_newsettings"); const std::string BUTTON_DELETE("btn_del"); @@ -152,7 +151,6 @@ public: LLFloaterMyEnvironment::LLFloaterMyEnvironment(const LLSD& key) : LLFloater(key), mInventoryList(nullptr), - mShowFolders(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS), mTypeFilter((0x01 << static_cast(LLSettingsType::ST_DAYCYCLE)) | (0x01 << static_cast(LLSettingsType::ST_SKY)) | (0x01 << static_cast(LLSettingsType::ST_WATER))), mSelectedAsset() { @@ -188,14 +186,12 @@ BOOL LLFloaterMyEnvironment::postBuild() mInventoryList->setFilterTypes(filter_types); mInventoryList->setSelectCallback([this](const std::deque&, BOOL) { onSelectionChange(); }); - mInventoryList->setShowFolderState(mShowFolders); mInventoryList->setFilterSettingsTypes(mTypeFilter); } childSetCommitCallback(CHECK_DAYS, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); childSetCommitCallback(CHECK_SKIES, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); childSetCommitCallback(CHECK_WATER, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); - childSetCommitCallback(CHECK_SHOWFOLDERS, [this](LLUICtrl*, void*) { onShowFoldersChange(); }, nullptr); childSetCommitCallback(BUTTON_DELETE, [this](LLUICtrl *, void*) { onDeleteSelected(); }, nullptr); @@ -204,8 +200,6 @@ BOOL LLFloaterMyEnvironment::postBuild() void LLFloaterMyEnvironment::refresh() { - getChild(CHECK_SHOWFOLDERS)->setValue(LLSD::Boolean(mShowFolders == LLInventoryFilter::SHOW_ALL_FOLDERS)); - getChild(CHECK_DAYS)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast(LLSettingsType::ST_DAYCYCLE)))); getChild(CHECK_SKIES)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast(LLSettingsType::ST_SKY)))); getChild(CHECK_WATER)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast(LLSettingsType::ST_WATER)))); @@ -238,16 +232,6 @@ void LLFloaterMyEnvironment::onOpen(const LLSD& key) } //------------------------------------------------------------------------- -void LLFloaterMyEnvironment::onShowFoldersChange() -{ - bool show_check (getChild(CHECK_SHOWFOLDERS)->getValue().asBoolean()); - - mShowFolders = (show_check) ? LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS; - - if (mInventoryList) - mInventoryList->setShowFolderState(mShowFolders); -} - void LLFloaterMyEnvironment::onFilterCheckChange() { mTypeFilter = 0x0; -- cgit v1.2.3 From 32598518816be6c312acc9b027d3a28ed807429a Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Thu, 18 Apr 2019 17:35:28 +0300 Subject: SL-10983 [EEP] Add a search box to the "My Environments" floater --- indra/newview/llfloatermyenvironment.cpp | 121 ++++++++++--------------------- 1 file changed, 38 insertions(+), 83 deletions(-) (limited to 'indra/newview/llfloatermyenvironment.cpp') diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index 3a83042d4f..8c2772a87d 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -1,10 +1,10 @@ /** * @file llfloatergesture.cpp - * @brief Read-only list of gestures from your inventory. + * @brief LLFloaterMyEnvironment class implementation * * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2019, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -32,21 +32,11 @@ #include "llinventorybridge.h" #include "llinventoryfunctions.h" #include "llinventorymodel.h" -#include "llclipboard.h" #include "llagent.h" #include "llclipboard.h" -#include "llkeyboard.h" -#include "llmenugl.h" -#include "llmultigesture.h" -#include "llscrolllistctrl.h" #include "llcheckboxctrl.h" -#include "lltrans.h" -#include "llviewergesture.h" -#include "llviewermenu.h" #include "llviewerinventory.h" -#include "llviewercontrol.h" -#include "llfloaterperms.h" #include "llenvironment.h" #include "llparcel.h" #include "llviewerparcelmgr.h" @@ -57,6 +47,7 @@ namespace const std::string CHECK_DAYS("chk_days"); const std::string CHECK_SKIES("chk_skies"); const std::string CHECK_WATER("chk_water"); + const std::string FLT_SEARCH("flt_search"); const std::string PANEL_SETTINGS("pnl_settings"); const std::string BUTTON_NEWSETTINGS("btn_gear"); const std::string BUTTON_GEAR("btn_newsettings"); @@ -81,72 +72,6 @@ namespace const std::string PARAMETER_COPYUUID("copy_uuid"); } -//========================================================================= -#if 0 -BOOL item_name_precedes( LLInventoryItem* a, LLInventoryItem* b ) -{ - return LLStringUtil::precedesDict( a->getName(), b->getName() ); -} - -class LLFloaterGestureObserver : public LLGestureManagerObserver -{ -public: - LLFloaterGestureObserver(LLFloaterGesture* floater) : mFloater(floater) {} - virtual ~LLFloaterGestureObserver() {} - 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); - - LLInventoryItem* item = gInventory.getItem(inv_item); - if (item) - { - LLPermissions perm = item->getPermissions(); - perm.setMaskNext(LLFloaterPerms::getNextOwnerPerms("Gestures")); - perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Gestures")); - perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Gestures")); - item->setPermissions(perm); - item->updateServer(FALSE); - } - } -}; - -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("gesture_list")); - - // EXP-1909 (Pasted gesture displayed twice) - // The problem is that addGesture is called here for the second time for the same item (which is copied) - // First time addGesture is called from LLFloaterGestureObserver::changed(), which is a callback for inventory - // change. So we need to refresh the gesture list to avoid duplicates. - mFloater->refreshAll(); - } - } -}; - -#endif - //========================================================================= LLFloaterMyEnvironment::LLFloaterMyEnvironment(const LLSD& key) : LLFloater(key), @@ -167,10 +92,6 @@ LLFloaterMyEnvironment::LLFloaterMyEnvironment(const LLSD& key) : LLFloaterMyEnvironment::~LLFloaterMyEnvironment() { - // LLGestureMgr::instance().removeObserver(mObserver); - // delete mObserver; - // mObserver = NULL; - // gInventory.removeObserver(this); } @@ -193,8 +114,11 @@ BOOL LLFloaterMyEnvironment::postBuild() childSetCommitCallback(CHECK_SKIES, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); childSetCommitCallback(CHECK_WATER, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); - childSetCommitCallback(BUTTON_DELETE, [this](LLUICtrl *, void*) { onDeleteSelected(); }, nullptr); + mFilterEdit = getChild(FLT_SEARCH); + mFilterEdit->setCommitCallback([this](LLUICtrl*, const LLSD& param){ onFilterEdit(param.asString()); }); + childSetCommitCallback(BUTTON_DELETE, [this](LLUICtrl *, void*) { onDeleteSelected(); }, nullptr); + mSavedFolderState.setApply(FALSE); return TRUE; } @@ -252,6 +176,37 @@ void LLFloaterMyEnvironment::onSelectionChange() refreshButtonStates(); } +void LLFloaterMyEnvironment::onFilterEdit(const std::string& search_string) +{ + std::string upper_case_search_string = search_string; + LLStringUtil::toUpper(upper_case_search_string); + + if (upper_case_search_string.empty()) + { + if (mInventoryList->getFilterSubString().empty()) + { + // current filter and new filter empty, do nothing + return; + } + + mSavedFolderState.setApply(TRUE); + mInventoryList->getRootFolder()->applyFunctorRecursively(mSavedFolderState); + // add folder with current item to list of previously opened folders + LLOpenFoldersWithSelection opener; + mInventoryList->getRootFolder()->applyFunctorRecursively(opener); + mInventoryList->getRootFolder()->scrollToShowSelection(); + + } + else if (mInventoryList->getFilterSubString().empty()) + { + // first letter in search term, save existing folder open state + mSavedFolderState.setApply(FALSE); + mInventoryList->getRootFolder()->applyFunctorRecursively(mSavedFolderState); + } + + mInventoryList->setFilterSubString(search_string); +} + void LLFloaterMyEnvironment::onDeleteSelected() { uuid_vec_t selected; -- cgit v1.2.3 From 89884ed1465ed4baf811e05172dd13f9af97bcbb Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Thu, 2 May 2019 12:58:48 +0300 Subject: SL-11057 Revert SL-10893 change to restore "Show All Folders" --- indra/newview/llfloatermyenvironment.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'indra/newview/llfloatermyenvironment.cpp') diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index 8c2772a87d..af71329607 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -49,6 +49,7 @@ namespace const std::string CHECK_WATER("chk_water"); const std::string FLT_SEARCH("flt_search"); const std::string PANEL_SETTINGS("pnl_settings"); + const std::string CHECK_SHOWFOLDERS("chk_showfolders"); const std::string BUTTON_NEWSETTINGS("btn_gear"); const std::string BUTTON_GEAR("btn_newsettings"); const std::string BUTTON_DELETE("btn_del"); @@ -76,6 +77,7 @@ namespace LLFloaterMyEnvironment::LLFloaterMyEnvironment(const LLSD& key) : LLFloater(key), mInventoryList(nullptr), + mShowFolders(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS), mTypeFilter((0x01 << static_cast(LLSettingsType::ST_DAYCYCLE)) | (0x01 << static_cast(LLSettingsType::ST_SKY)) | (0x01 << static_cast(LLSettingsType::ST_WATER))), mSelectedAsset() { @@ -107,12 +109,14 @@ BOOL LLFloaterMyEnvironment::postBuild() mInventoryList->setFilterTypes(filter_types); mInventoryList->setSelectCallback([this](const std::deque&, BOOL) { onSelectionChange(); }); + mInventoryList->setShowFolderState(mShowFolders); mInventoryList->setFilterSettingsTypes(mTypeFilter); } childSetCommitCallback(CHECK_DAYS, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); childSetCommitCallback(CHECK_SKIES, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); childSetCommitCallback(CHECK_WATER, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); + childSetCommitCallback(CHECK_SHOWFOLDERS, [this](LLUICtrl*, void*) { onShowFoldersChange(); }, nullptr); mFilterEdit = getChild(FLT_SEARCH); mFilterEdit->setCommitCallback([this](LLUICtrl*, const LLSD& param){ onFilterEdit(param.asString()); }); @@ -124,6 +128,8 @@ BOOL LLFloaterMyEnvironment::postBuild() void LLFloaterMyEnvironment::refresh() { + getChild(CHECK_SHOWFOLDERS)->setValue(LLSD::Boolean(mShowFolders == LLInventoryFilter::SHOW_ALL_FOLDERS)); + getChild(CHECK_DAYS)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast(LLSettingsType::ST_DAYCYCLE)))); getChild(CHECK_SKIES)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast(LLSettingsType::ST_SKY)))); getChild(CHECK_WATER)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast(LLSettingsType::ST_WATER)))); @@ -156,6 +162,16 @@ void LLFloaterMyEnvironment::onOpen(const LLSD& key) } //------------------------------------------------------------------------- +void LLFloaterMyEnvironment::onShowFoldersChange() +{ + bool show_check(getChild(CHECK_SHOWFOLDERS)->getValue().asBoolean()); + + mShowFolders = (show_check) ? LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS; + + if (mInventoryList) + mInventoryList->setShowFolderState(mShowFolders); +} + void LLFloaterMyEnvironment::onFilterCheckChange() { mTypeFilter = 0x0; -- cgit v1.2.3 From 24acb7d5c3b6c3af4d7d814b8ccb0b9652eb38d3 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 3 May 2019 14:58:51 -0700 Subject: Fix some line-endings to be newline only. --- indra/newview/llfloatermyenvironment.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/newview/llfloatermyenvironment.cpp') diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index af71329607..1d2f14532d 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -162,14 +162,14 @@ void LLFloaterMyEnvironment::onOpen(const LLSD& key) } //------------------------------------------------------------------------- -void LLFloaterMyEnvironment::onShowFoldersChange() -{ - bool show_check(getChild(CHECK_SHOWFOLDERS)->getValue().asBoolean()); - - mShowFolders = (show_check) ? LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS; - - if (mInventoryList) - mInventoryList->setShowFolderState(mShowFolders); +void LLFloaterMyEnvironment::onShowFoldersChange() +{ + bool show_check(getChild(CHECK_SHOWFOLDERS)->getValue().asBoolean()); + + mShowFolders = (show_check) ? LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS; + + if (mInventoryList) + mInventoryList->setShowFolderState(mShowFolders); } void LLFloaterMyEnvironment::onFilterCheckChange() -- cgit v1.2.3 From 1f656735d339fc4d83da86efbb400af1361c27db Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 26 Aug 2019 11:43:45 -0700 Subject: SL-11705, SL-11706: New flags in llsettings base for tracking by simulator. --- indra/newview/llfloatermyenvironment.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloatermyenvironment.cpp') diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index 1d2f14532d..21d106c8b1 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -277,9 +277,16 @@ void LLFloaterMyEnvironment::onDoApply(const std::string &context) LLUUID asset_id = itemp->getAssetUUID(); std::string name = itemp->getName(); + U32 flags(0); + + if (!itemp->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID())) + flags |= LLSettingsBase::FLAG_NOMOD; + if (!itemp->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID())) + flags |= LLSettingsBase::FLAG_NOTRANS; + if (context == PARAMETER_REGION) { - LLEnvironment::instance().updateRegion(asset_id, name, LLEnvironment::NO_TRACK, -1, -1); + LLEnvironment::instance().updateRegion(asset_id, name, LLEnvironment::NO_TRACK, -1, -1, flags); LLEnvironment::instance().setSharedEnvironment(); } else if (context == PARAMETER_PARCEL) @@ -290,7 +297,7 @@ void LLFloaterMyEnvironment::onDoApply(const std::string &context) LL_WARNS("ENVIRONMENT") << "Unable to determine parcel." << LL_ENDL; return; } - LLEnvironment::instance().updateParcel(parcel->getLocalID(), asset_id, name, LLEnvironment::NO_TRACK, -1, -1); + LLEnvironment::instance().updateParcel(parcel->getLocalID(), asset_id, name, LLEnvironment::NO_TRACK, -1, -1, flags); LLEnvironment::instance().setSharedEnvironment(); } else if (context == PARAMETER_LOCAL) -- cgit v1.2.3