diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 0513a888e5..9ed2f542f7 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -135,6 +135,8 @@ set(viewer_SOURCE_FILES fsareasearch.cpp fsareasearchlistctrl.cpp fsareasearchmenu.cpp + fsavatarsearchlistctrl.cpp + fsavatarsearchmenu.cpp fsblocklistctrl.cpp fsblocklistmenu.cpp fschathistory.cpp @@ -844,6 +846,8 @@ set(viewer_HEADER_FILES fsareasearch.h fsareasearchlistctrl.h fsareasearchmenu.h + fsavatarsearchlistctrl.h + fsavatarsearchmenu.h fsblocklistctrl.h fsblocklistmenu.h fschathistory.h diff --git a/indra/newview/fsavatarsearchlistctrl.cpp b/indra/newview/fsavatarsearchlistctrl.cpp new file mode 100644 index 0000000000..23de2ebefe --- /dev/null +++ b/indra/newview/fsavatarsearchlistctrl.cpp @@ -0,0 +1,69 @@ +/** + * @file fsavatarsearchlistctrl.cpp + * @brief A avatar search-specific implementation of scrolllist + * + * $LicenseInfo:firstyear=2014&license=viewerlgpl$ + * Phoenix Firestorm Viewer Source Code + * Copyright (c) 2014 Ansariel Hiller + * + * 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 + * + * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA + * http://www.firestormviewer.org + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "fsavatarsearchlistctrl.h" +#include "llscrolllistitem.h" + +static LLDefaultChildRegistry::Register r("fs_avatar_search_list"); + +FSAvatarSearchListCtrl::FSAvatarSearchListCtrl(const Params& p) +: FSScrollListCtrl(p) +{ +} + +BOOL FSAvatarSearchListCtrl::handleRightMouseDown(S32 x, S32 y, MASK mask) +{ + BOOL handled = LLUICtrl::handleRightMouseDown(x, y, mask); + if (mContextMenu) + { + std::vector selected_items = getAllSelected(); + if (selected_items.size() > 1) + { + uuid_vec_t selected_uuids; + for (std::vector::iterator it = selected_items.begin(); it != selected_items.end(); ++it) + { + selected_uuids.push_back((*it)->getUUID()); + } + mContextMenu->show(this, selected_uuids, x, y); + } + else + { + LLScrollListItem* hit_item = hitItem(x, y); + if (hit_item) + { + LLUUID val = hit_item->getValue(); + selectByID(val); + uuid_vec_t selected_uuids; + selected_uuids.push_back(val); + mContextMenu->show(this, selected_uuids, x, y); + } + } + } + return handled; +} diff --git a/indra/newview/fsavatarsearchlistctrl.h b/indra/newview/fsavatarsearchlistctrl.h new file mode 100644 index 0000000000..41778ce8b4 --- /dev/null +++ b/indra/newview/fsavatarsearchlistctrl.h @@ -0,0 +1,52 @@ +/** + * @file fsavatarsearchlistctrl.h + * @brief A avatar search-specific implementation of scrolllist + * + * $LicenseInfo:firstyear=2014&license=viewerlgpl$ + * Phoenix Firestorm Viewer Source Code + * Copyright (c) 2014 Ansariel Hiller + * + * 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 + * + * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA + * http://www.firestormviewer.org + * $/LicenseInfo$ + */ + +#ifndef FS_AVATARSEARCHLISTCTRL_H +#define FS_AVATARSEARCHLISTCTRL_H + +#include "fsscrolllistctrl.h" + +class FSAvatarSearchListCtrl + : public FSScrollListCtrl, public LLInstanceTracker +{ +public: + + struct Params : public LLInitParam::Block + { + Params() + {} + }; + + BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); + +protected: + FSAvatarSearchListCtrl(const Params&); + virtual ~FSAvatarSearchListCtrl() {} + friend class LLUICtrlFactory; +}; + +#endif // FS_AVATARSEARCHLISTCTRL_H diff --git a/indra/newview/fsavatarsearchmenu.cpp b/indra/newview/fsavatarsearchmenu.cpp new file mode 100644 index 0000000000..c14770caf2 --- /dev/null +++ b/indra/newview/fsavatarsearchmenu.cpp @@ -0,0 +1,201 @@ +/** + * @file fsavatarsearchmenu.cpp + * @brief Menu used by the avatar picker + * + * $LicenseInfo:firstyear=2014&license=viewerlgpl$ + * Phoenix Firestorm Viewer Source Code + * Copyright (c) 2014 Ansariel Hiller + * + * 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 + * + * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA + * http://www.firestormviewer.org + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "fsavatarsearchmenu.h" + +#include "fsradar.h" +#include "llagent.h" +#include "llavataractions.h" +#include "llcallingcard.h" +#include "llfloaterreg.h" +#include "lluictrl.h" +#include "llviewermenu.h" +#include "rlvhandler.h" + +FSAvatarSearchMenu gFSAvatarSearchMenu; + +LLContextMenu* FSAvatarSearchMenu::createMenu() +{ + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + + if (mUUIDs.size() == 1) + { + // Set up for one person selected menu + + const LLUUID& id = mUUIDs.front(); + registrar.add("Avatar.Profile", boost::bind(&LLAvatarActions::showProfile, id)); + registrar.add("Avatar.AddFriend", boost::bind(&LLAvatarActions::requestFriendshipDialog, id)); + registrar.add("Avatar.RemoveFriend", boost::bind(&LLAvatarActions::removeFriendDialog, id)); + registrar.add("Avatar.IM", boost::bind(&LLAvatarActions::startIM, id)); + registrar.add("Avatar.Call", boost::bind(&LLAvatarActions::startCall, id)); + registrar.add("Avatar.OfferTeleport", boost::bind(&FSAvatarSearchMenu::offerTeleport, this)); + registrar.add("Avatar.TeleportRequest", boost::bind(&LLAvatarActions::teleportRequest, id)); + registrar.add("Avatar.GroupInvite", boost::bind(&LLAvatarActions::inviteToGroup, id)); + registrar.add("Avatar.Share", boost::bind(&LLAvatarActions::share, id)); + registrar.add("Avatar.Pay", boost::bind(&LLAvatarActions::pay, id)); + registrar.add("Avatar.BlockUnblock", boost::bind(&LLAvatarActions::toggleBlock, id)); + + enable_registrar.add("Avatar.EnableItem", boost::bind(&FSAvatarSearchMenu::onContextMenuItemEnable, this, _2)); + enable_registrar.add("Avatar.CheckItem", boost::bind(&FSAvatarSearchMenu::onContextMenuItemCheck, this, _2)); + + // create the context menu from the XUI + return createFromFile("menu_fs_avatar_search.xml"); + } + else + { + // Set up for multi-selected People + registrar.add("Avatar.IM", boost::bind(&LLAvatarActions::startConference, mUUIDs, LLUUID::null)); + registrar.add("Avatar.Call", boost::bind(&LLAvatarActions::startAdhocCall, mUUIDs, LLUUID::null)); + registrar.add("Avatar.OfferTeleport", boost::bind(&FSAvatarSearchMenu::offerTeleport, this)); + registrar.add("Avatar.RemoveFriend", boost::bind(&LLAvatarActions::removeFriendsDialog, mUUIDs)); + registrar.add("Avatar.AddToContactSet", boost::bind(&FSAvatarSearchMenu::addToContactSet, this)); + + enable_registrar.add("Avatar.EnableItem", boost::bind(&FSAvatarSearchMenu::onContextMenuItemEnable, this, _2)); + + // create the context menu from the XUI + return createFromFile("menu_fs_avatar_search_multiselect.xml"); + } +} + +bool FSAvatarSearchMenu::onContextMenuItemEnable(const LLSD& userdata) +{ + std::string item = userdata.asString(); + + if (item == std::string("can_block")) + { + const LLUUID& id = mUUIDs.front(); + return LLAvatarActions::canBlock(id); + } + else if (item == std::string("can_add")) + { + // We can add friends if: + // - there are selected people + // - and there are no friends among selection yet. + + //EXT-7389 - disable for more than 1 + if(mUUIDs.size() > 1) + { + return false; + } + + bool result = (mUUIDs.size() > 0); + + uuid_vec_t::const_iterator + id = mUUIDs.begin(), + uuids_end = mUUIDs.end(); + + for (;id != uuids_end; ++id) + { + if ( LLAvatarActions::isFriend(*id) ) + { + result = false; + break; + } + } + + return result; + } + else if (item == std::string("can_delete")) + { + // We can remove friends if: + // - there are selected people + // - and there are only friends among selection. + + bool result = (mUUIDs.size() > 0); + + uuid_vec_t::const_iterator + id = mUUIDs.begin(), + uuids_end = mUUIDs.end(); + + for (;id != uuids_end; ++id) + { + if ( !LLAvatarActions::isFriend(*id) ) + { + result = false; + break; + } + } + + return result; + } + else if (item == std::string("can_call")) + { + return LLAvatarActions::canCall(); + } + else if (item == std::string("can_show_on_map")) + { + const LLUUID& id = mUUIDs.front(); + + return (LLAvatarTracker::instance().isBuddyOnline(id) && is_agent_mappable(id)) + || gAgent.isGodlike(); + } + else if(item == std::string("can_offer_teleport")) + { + return LLAvatarActions::canOfferTeleport(mUUIDs); + } + else if(item == std::string("can_request_teleport")) + { + if (mUUIDs.size() == 1) + { + return LLAvatarActions::canRequestTeleport(mUUIDs.front()); + } + return false; + } + else if (item == std::string("can_open_inventory")) + { + return (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWINV)); + } + + return false; +} + +bool FSAvatarSearchMenu::onContextMenuItemCheck(const LLSD& userdata) +{ + std::string item = userdata.asString(); + const LLUUID& id = mUUIDs.front(); + + if (item == std::string("is_blocked")) + { + return LLAvatarActions::isBlocked(id); + } + + return false; +} + +void FSAvatarSearchMenu::offerTeleport() +{ + LLAvatarActions::offerTeleport(mUUIDs); +} + +void FSAvatarSearchMenu::addToContactSet() +{ + LLAvatarActions::addToContactSet(mUUIDs); +} + diff --git a/indra/newview/fsavatarsearchmenu.h b/indra/newview/fsavatarsearchmenu.h new file mode 100644 index 0000000000..0c4bcea2a5 --- /dev/null +++ b/indra/newview/fsavatarsearchmenu.h @@ -0,0 +1,47 @@ +/** + * @file fsavatarsearchmenu.h + * @brief Menu used by the avatar picker + * + * $LicenseInfo:firstyear=2014&license=viewerlgpl$ + * Phoenix Firestorm Viewer Source Code + * Copyright (c) 2014 Ansariel Hiller + * + * 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 + * + * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA + * http://www.firestormviewer.org + * $/LicenseInfo$ + */ + +#ifndef FS_AVATARSEARCHMENU_H +#define FS_AVATARSEARCHMENU_H + +#include "lllistcontextmenu.h" + +class FSAvatarSearchMenu : public LLListContextMenu +{ +public: + /*virtual*/ LLContextMenu* createMenu(); +private: + bool onContextMenuItemEnable(const LLSD& userdata); + bool onContextMenuItemCheck(const LLSD& userdata); + + void offerTeleport(); + void addToContactSet(); +}; + +extern FSAvatarSearchMenu gFSAvatarSearchMenu; + +#endif // FS_AVATARSEARCHMENU_H diff --git a/indra/newview/fsfloatersearch.cpp b/indra/newview/fsfloatersearch.cpp index 77f95a704f..374a2b3640 100644 --- a/indra/newview/fsfloatersearch.cpp +++ b/indra/newview/fsfloatersearch.cpp @@ -28,6 +28,8 @@ #include "llviewerprecompiledheaders.h" #include "fsfloatersearch.h" +#include "fsavatarsearchlistctrl.h" +#include "fsavatarsearchmenu.h" #include "lfsimfeaturehandler.h" #include "llagent.h" #include "llavatarname.h" @@ -734,7 +736,7 @@ FSPanelSearchPeople::~FSPanelSearchPeople() BOOL FSPanelSearchPeople::postBuild() { mSearchComboBox = findChild("people_edit"); - mSearchResults = findChild("search_results_people"); + mSearchResults = findChild("search_results_people"); if (mSearchComboBox) { mSearchComboBox->setCommitCallback(boost::bind(&FSPanelSearchPeople::onBtnFind, this)); @@ -745,6 +747,7 @@ BOOL FSPanelSearchPeople::postBuild() mSearchResults->setCommitCallback(boost::bind(&FSPanelSearchPeople::onSelectItem, this)); mSearchResults->setEnabled(FALSE); mSearchResults->setCommentText(LLTrans::getString("no_results")); + mSearchResults->setContextMenu(&gFSAvatarSearchMenu); } childSetAction("people_next", boost::bind(&FSPanelSearchPeople::onBtnNext, this)); diff --git a/indra/newview/fsfloatersearch.h b/indra/newview/fsfloatersearch.h index 04b4b475f1..e0563e8e0e 100644 --- a/indra/newview/fsfloatersearch.h +++ b/indra/newview/fsfloatersearch.h @@ -48,7 +48,7 @@ class LLGroupMgrObserver; class LLSearchEditor; class LLSearchComboBox; class FSFloaterSearch; - +class FSAvatarSearchListCtrl; class FSPanelProfile; struct SearchQuery : public LLInitParam::Block @@ -106,9 +106,9 @@ private: LLSD mResultsContent; LLUUID mQueryID; - FSFloaterSearch* mParent; - LLSearchComboBox* mSearchComboBox; - LLScrollListCtrl* mSearchResults; + FSFloaterSearch* mParent; + LLSearchComboBox* mSearchComboBox; + FSAvatarSearchListCtrl* mSearchResults; }; class FSPanelSearchGroups : public FSSearchPanelBase diff --git a/indra/newview/fsscrolllistctrl.h b/indra/newview/fsscrolllistctrl.h index 9603db4bc9..87ae33db6c 100644 --- a/indra/newview/fsscrolllistctrl.h +++ b/indra/newview/fsscrolllistctrl.h @@ -54,6 +54,7 @@ public: protected: FSScrollListCtrl(const Params&); + virtual ~FSScrollListCtrl() {}; friend class LLUICtrlFactory; LLListContextMenu* mContextMenu; diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index a396703441..2e226a377a 100755 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -59,6 +59,9 @@ //#include "llsdserialize.h" +#include "fsavatarsearchlistctrl.h" +#include "fsavatarsearchmenu.h" + //put it back as a member once the legacy path is out? static std::map sAvatarNameMap; @@ -129,16 +132,28 @@ BOOL LLFloaterAvatarPicker::postBuild() childSetAction("Refresh", boost::bind(&LLFloaterAvatarPicker::onBtnRefresh, this)); getChild("near_me_range")->setCommitCallback(boost::bind(&LLFloaterAvatarPicker::onRangeAdjust, this)); - LLScrollListCtrl* searchresults = getChild("SearchResults"); + // FIRE-5096: Add context menu for result lists + //LLScrollListCtrl* searchresults = getChild("SearchResults"); + FSAvatarSearchListCtrl* searchresults = getChild("SearchResults"); + searchresults->setContextMenu(&gFSAvatarSearchMenu); + // searchresults->setDoubleClickCallback( boost::bind(&LLFloaterAvatarPicker::onBtnSelect, this)); searchresults->setCommitCallback(boost::bind(&LLFloaterAvatarPicker::onList, this)); getChildView("SearchResults")->setEnabled(FALSE); - LLScrollListCtrl* nearme = getChild("NearMe"); + // FIRE-5096: Add context menu for result lists + //LLScrollListCtrl* nearme = getChild("NearMe"); + FSAvatarSearchListCtrl* nearme = getChild("NearMe"); + nearme->setContextMenu(&gFSAvatarSearchMenu); + // nearme->setDoubleClickCallback(boost::bind(&LLFloaterAvatarPicker::onBtnSelect, this)); nearme->setCommitCallback(boost::bind(&LLFloaterAvatarPicker::onList, this)); - LLScrollListCtrl* friends = getChild("Friends"); + // FIRE-5096: Add context menu for result lists + //LLScrollListCtrl* friends = getChild("Friends"); + FSAvatarSearchListCtrl* friends = getChild("Friends"); + friends->setContextMenu(&gFSAvatarSearchMenu); + // friends->setDoubleClickCallback(boost::bind(&LLFloaterAvatarPicker::onBtnSelect, this)); getChild("Friends")->setCommitCallback(boost::bind(&LLFloaterAvatarPicker::onList, this)); @@ -165,7 +180,8 @@ BOOL LLFloaterAvatarPicker::postBuild() childSetAction("FindUUID", boost::bind(&LLFloaterAvatarPicker::onBtnFindUUID, this)); getChildView("FindUUID")->setEnabled(FALSE); - LLScrollListCtrl* searchresultsuuid = getChild("SearchResultsUUID"); + FSAvatarSearchListCtrl* searchresultsuuid = getChild("SearchResultsUUID"); + searchresultsuuid->setContextMenu(&gFSAvatarSearchMenu); searchresultsuuid->setDoubleClickCallback( boost::bind(&LLFloaterAvatarPicker::onBtnSelect, this)); searchresultsuuid->setCommitCallback(boost::bind(&LLFloaterAvatarPicker::onList, this)); searchresultsuuid->setEnabled(FALSE); diff --git a/indra/newview/skins/default/xui/da/floater_avatar_picker.xml b/indra/newview/skins/default/xui/da/floater_avatar_picker.xml index e97089f61e..9efff25a6f 100755 --- a/indra/newview/skins/default/xui/da/floater_avatar_picker.xml +++ b/indra/newview/skins/default/xui/da/floater_avatar_picker.xml @@ -24,10 +24,10 @@ Indtast en del af beboerens navn: - - - + - - +