From c9482ecac5af109e0421dad2285dc834c615df22 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Sat, 24 Aug 2013 21:52:53 -0400 Subject: [PATCH] Feature request: Add an option to open inventory folders in a new separate window --- indra/newview/CMakeLists.txt | 2 + indra/newview/app_settings/settings.xml | 16 ++++ indra/newview/lffloaterinvpanel.cpp | 81 +++++++++++++++++++ indra/newview/lffloaterinvpanel.h | 44 ++++++++++ indra/newview/llinventorybridge.cpp | 11 +++ indra/newview/llinventorypanel.cpp | 1 + indra/newview/llinventorypanel.h | 1 + indra/newview/rlvui.cpp | 2 + .../default/xui/en-us/floater_inv_panel.xml | 7 ++ .../default/xui/en-us/menu_inventory.xml | 3 + 10 files changed, 168 insertions(+) create mode 100644 indra/newview/lffloaterinvpanel.cpp create mode 100644 indra/newview/lffloaterinvpanel.h create mode 100644 indra/newview/skins/default/xui/en-us/floater_inv_panel.xml diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index fee36a2be..74cbf25a0 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -101,6 +101,7 @@ set(viewer_SOURCE_FILES hippopanelgrids.cpp importtracker.cpp jcfloaterareasearch.cpp + lffloaterinvpanel.cpp lfsimfeaturehandler.cpp lggdicdownload.cpp lgghunspell_wrapper.cpp @@ -615,6 +616,7 @@ set(viewer_HEADER_FILES hippopanelgrids.h importtracker.h jcfloaterareasearch.h + lffloaterinvpanel.h lfsimfeaturehandler.h lggdicdownload.h lgghunspell_wrapper.h diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 8e1cda872..b2f233f70 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -6828,6 +6828,22 @@ This should be as low as possible, but too low may break functionality 0 + FloaterInvPanelRect + + Comment + Rectangle for new inventory windows a folder is opened in + Persist + 1 + Type + Rect + Value + + 0 + 400 + 300 + 0 + + FloaterJoystickRect Comment diff --git a/indra/newview/lffloaterinvpanel.cpp b/indra/newview/lffloaterinvpanel.cpp new file mode 100644 index 000000000..0132579d2 --- /dev/null +++ b/indra/newview/lffloaterinvpanel.cpp @@ -0,0 +1,81 @@ +/* @file lffloaterinvpanel.cpp + * @brief Simple floater displaying an inventory panel with any category as its root + * + * Copyright (C) 2013 Liru Færs + * + * 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; either + * version 2.1 of the License, or (at your option) any later version. + * + * 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 */ + +#include "llviewerprecompiledheaders.h" + +#include "lffloaterinvpanel.h" + +#include "llinventorypanel.h" +#include "lluictrlfactory.h" + + +LFFloaterInvPanel::LFFloaterInvPanel(const LLUUID& cat_id, LLInventoryModel* model, const std::string& name) +: LLInstanceTracker(cat_id) +{ + mCommitCallbackRegistrar.add("InvPanel.Search", boost::bind(&LFFloaterInvPanel::onSearch, this, _2)); + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_inv_panel.xml"); + LLPanel* panel = getChild("placeholder_panel"); + mPanel = new LLInventoryPanel("inv_panel", LLInventoryPanel::DEFAULT_SORT_ORDER, cat_id.asString(), panel->getRect(), model, true); + mPanel->postBuild(); + mPanel->setFollows(FOLLOWS_ALL); + mPanel->setEnabled(true); + addChild(mPanel); + removeChild(panel); + setTitle(name); +} + +LFFloaterInvPanel::~LFFloaterInvPanel() +{ + delete mPanel; +} + +// static +void LFFloaterInvPanel::show(const LLUUID& cat_id, LLInventoryModel* model, const std::string& name) +{ + LFFloaterInvPanel* floater = LFFloaterInvPanel::getInstance(cat_id); + if (!floater) floater = new LFFloaterInvPanel(cat_id, model, name); + floater->open(); +} + +// static +void LFFloaterInvPanel::closeAll() +{ + for (instance_iter i = endInstances(); i >= beginInstances(); --i) + i->close(); +} + +// virtual +BOOL LFFloaterInvPanel::handleKeyHere(KEY key, MASK mask) +{ + if (!mPanel->hasFocus() && mask == MASK_NONE && (key == KEY_RETURN || key == KEY_DOWN)) + { + mPanel->setFocus(true); + if (LLFolderView* root = mPanel->getRootFolder()) + root->scrollToShowSelection(); + return true; + } + + return LLFloater::handleKeyHere(key, mask); +} + +void LFFloaterInvPanel::onSearch(const LLSD& val) +{ + mPanel->setFilterSubString(val.asString()); +} diff --git a/indra/newview/lffloaterinvpanel.h b/indra/newview/lffloaterinvpanel.h new file mode 100644 index 000000000..24ae089fd --- /dev/null +++ b/indra/newview/lffloaterinvpanel.h @@ -0,0 +1,44 @@ +/* @file lffloaterinvpanel.h + * @brief Simple floater displaying an inventory panel with any category as its root + * + * Copyright (C) 2013 Liru Færs + * + * 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; either + * version 2.1 of the License, or (at your option) any later version. + * + * 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 */ + +#ifndef LFFLOATERINVPANEL_H +#define LFFLOATERINVPANEL_H + +#include "llfloater.h" +#include "llinstancetracker.h" + + +class LFFloaterInvPanel : public LLFloater, public LLInstanceTracker +{ + LFFloaterInvPanel(const LLUUID& cat_id, class LLInventoryModel* model, const std::string& name); + ~LFFloaterInvPanel(); + +public: + static void show(const LLUUID& cat_id, LLInventoryModel* model, const std::string& name); // Show the floater for cat_id (create with other params if necessary) + static void closeAll(); // Called when not allowed to have inventory open + + /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); + void onSearch(const LLSD& val); + +private: + class LLInventoryPanel* mPanel; +}; + +#endif //LFFLOATERINVPANEL_H diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 1014f41db..212f953fb 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -34,6 +34,7 @@ #include "lluictrlfactory.h" +#include "lffloaterinvpanel.h" #include "llagent.h" #include "llagentcamera.h" #include "llagentwearables.h" @@ -2771,6 +2772,14 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) return; } + else if ("open_in_new_window" == action) + { + LLInventoryModel* model = getInventoryModel(); + LLViewerInventoryCategory* cat = getCategory(); + if (!model || !cat) return; + LFFloaterInvPanel::show(mUUID, model, cat->getName()); + return; + } else if ("paste" == action) { pasteFromClipboard(); @@ -3371,6 +3380,8 @@ void LLFolderBridge::buildContextMenuFolderOptions(U32 flags) if (!isAgentInventory()) return; if (isOutboxFolder()) return; + mItems.push_back(std::string("Open Folder In New Window")); + LLFolderType::EType type = category->getPreferredType(); const bool is_system_folder = LLFolderType::lookupIsProtectedType(type); // calling card related functionality for folders. diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 3de4fc349..6d8793a4d 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -174,6 +174,7 @@ void LLInventoryPanel::buildFolderView() { root_id = (preferred_type != LLFolderType::FT_NONE) ? gInventory.findCategoryUUIDForType(preferred_type, false, false) + : gInventory.getCategory(static_cast(mStartFolder)) ? static_cast(mStartFolder) // Singu Note: if start folder is an id of a folder, use it : LLUUID::null; } diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index e3d3c54f9..5a858143a 100644 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -66,6 +66,7 @@ class LLInvPanelComplObserver; class LLInventoryPanel : public LLPanel { protected: + friend class LFFloaterInvPanel; LLInventoryPanel(const std::string& name, const std::string& sort_order_setting, const std::string& start_folder, diff --git a/indra/newview/rlvui.cpp b/indra/newview/rlvui.cpp index aadfc20ed..a434ad026 100644 --- a/indra/newview/rlvui.cpp +++ b/indra/newview/rlvui.cpp @@ -29,6 +29,7 @@ #include "llvoavatar.h" #include "roles_constants.h" // Group "powers" +#include "lffloaterinvpanel.h" #include "llfloaterbeacons.h" #include "llfloatertools.h" #include "llfloaterenvsettings.h" @@ -208,6 +209,7 @@ void RlvUIEnabler::onToggleShowInv(bool fQuitting) if (!fEnable) { LLInventoryView::closeAll(); + LFFloaterInvPanel::closeAll(); } } diff --git a/indra/newview/skins/default/xui/en-us/floater_inv_panel.xml b/indra/newview/skins/default/xui/en-us/floater_inv_panel.xml new file mode 100644 index 000000000..00a7ccb44 --- /dev/null +++ b/indra/newview/skins/default/xui/en-us/floater_inv_panel.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/indra/newview/skins/default/xui/en-us/menu_inventory.xml b/indra/newview/skins/default/xui/en-us/menu_inventory.xml index 26b40db6f..de5537571 100644 --- a/indra/newview/skins/default/xui/en-us/menu_inventory.xml +++ b/indra/newview/skins/default/xui/en-us/menu_inventory.xml @@ -39,6 +39,9 @@ mouse_opaque="true" name="Empty Lost And Found" width="128"> + + +