diff options
Diffstat (limited to 'indra/newview/llpanelpeople.cpp')
-rw-r--r-- | indra/newview/llpanelpeople.cpp | 111 |
1 files changed, 60 insertions, 51 deletions
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index 040b5319b9..54198d6aa4 100644 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -29,11 +29,13 @@ // libs #include "llavatarname.h" #include "llfloaterreg.h" +#include "llmenubutton.h" #include "llmenugl.h" #include "llnotificationsutil.h" #include "lleventtimer.h" #include "llfiltereditor.h" #include "lltabcontainer.h" +#include "lltoggleablemenu.h" #include "lluictrlfactory.h" #include "llpanelpeople.h" @@ -229,7 +231,7 @@ public: virtual void setActive(bool) {} protected: - void updateList() + void update() { mCallback(); } @@ -237,6 +239,30 @@ protected: callback_t mCallback; }; +/** + * Update buttons on changes in our friend relations (STORM-557). + */ +class LLButtonsUpdater : public LLPanelPeople::Updater, public LLFriendObserver +{ +public: + LLButtonsUpdater(callback_t cb) + : LLPanelPeople::Updater(cb) + { + LLAvatarTracker::instance().addObserver(this); + } + + ~LLButtonsUpdater() + { + LLAvatarTracker::instance().removeObserver(this); + } + + /*virtual*/ void changed(U32 mask) + { + (void) mask; + update(); + } +}; + class LLAvatarListUpdater : public LLPanelPeople::Updater, public LLEventTimer { public: @@ -304,7 +330,7 @@ public: if (mMask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE)) { - updateList(); + update(); } // Stop updates. @@ -419,7 +445,7 @@ public: if (val) { // update immediately and start regular updates - updateList(); + update(); mEventTimer.start(); } else @@ -431,7 +457,7 @@ public: /*virtual*/ BOOL tick() { - updateList(); + update(); return FALSE; } private: @@ -448,7 +474,7 @@ public: LLRecentListUpdater(callback_t cb) : LLAvatarListUpdater(cb, 0) { - LLRecentPeople::instance().setChangedCallback(boost::bind(&LLRecentListUpdater::updateList, this)); + LLRecentPeople::instance().setChangedCallback(boost::bind(&LLRecentListUpdater::update, this)); } }; @@ -464,16 +490,22 @@ LLPanelPeople::LLPanelPeople() mAllFriendList(NULL), mNearbyList(NULL), mRecentList(NULL), - mGroupList(NULL) + mGroupList(NULL), + mNearbyGearButton(NULL), + mFriendsGearButton(NULL), + mGroupsGearButton(NULL), + mRecentGearButton(NULL) { mFriendListUpdater = new LLFriendListUpdater(boost::bind(&LLPanelPeople::updateFriendList, this)); mNearbyListUpdater = new LLNearbyListUpdater(boost::bind(&LLPanelPeople::updateNearbyList, this)); mRecentListUpdater = new LLRecentListUpdater(boost::bind(&LLPanelPeople::updateRecentList, this)); + mButtonsUpdater = new LLButtonsUpdater(boost::bind(&LLPanelPeople::updateButtons, this)); mCommitCallbackRegistrar.add("People.addFriend", boost::bind(&LLPanelPeople::onAddFriendButtonClicked, this)); } LLPanelPeople::~LLPanelPeople() { + delete mButtonsUpdater; delete mNearbyListUpdater; delete mFriendListUpdater; delete mRecentListUpdater; @@ -600,11 +632,6 @@ BOOL LLPanelPeople::postBuild() buttonSetAction("teleport_btn", boost::bind(&LLPanelPeople::onTeleportButtonClicked, this)); buttonSetAction("share_btn", boost::bind(&LLPanelPeople::onShareButtonClicked, this)); - getChild<LLPanel>(NEARBY_TAB_NAME)->childSetAction("nearby_view_sort_btn",boost::bind(&LLPanelPeople::onNearbyViewSortButtonClicked, this)); - getChild<LLPanel>(RECENT_TAB_NAME)->childSetAction("recent_viewsort_btn",boost::bind(&LLPanelPeople::onRecentViewSortButtonClicked, this)); - getChild<LLPanel>(FRIENDS_TAB_NAME)->childSetAction("friends_viewsort_btn",boost::bind(&LLPanelPeople::onFriendsViewSortButtonClicked, this)); - getChild<LLPanel>(GROUP_TAB_NAME)->childSetAction("groups_viewsort_btn",boost::bind(&LLPanelPeople::onGroupsViewSortButtonClicked, this)); - // Must go after setting commit callback and initializing all pointers to children. mTabContainer->selectTabByName(NEARBY_TAB_NAME); @@ -624,24 +651,41 @@ BOOL LLPanelPeople::postBuild() enable_registrar.add("People.Recent.ViewSort.CheckItem", boost::bind(&LLPanelPeople::onRecentViewSortMenuItemCheck, this, _2)); enable_registrar.add("People.Nearby.ViewSort.CheckItem", boost::bind(&LLPanelPeople::onNearbyViewSortMenuItemCheck, this, _2)); + mNearbyGearButton = getChild<LLMenuButton>("nearby_view_sort_btn"); + mFriendsGearButton = getChild<LLMenuButton>("friends_viewsort_btn"); + mGroupsGearButton = getChild<LLMenuButton>("groups_viewsort_btn"); + mRecentGearButton = getChild<LLMenuButton>("recent_viewsort_btn"); + LLMenuGL* plus_menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_group_plus.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); mGroupPlusMenuHandle = plus_menu->getHandle(); - LLMenuGL* nearby_view_sort = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_people_nearby_view_sort.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + LLToggleableMenu* nearby_view_sort = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_people_nearby_view_sort.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); if(nearby_view_sort) + { mNearbyViewSortMenuHandle = nearby_view_sort->getHandle(); + mNearbyGearButton->setMenu(nearby_view_sort); + } - LLMenuGL* friend_view_sort = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_people_friends_view_sort.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + LLToggleableMenu* friend_view_sort = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_people_friends_view_sort.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); if(friend_view_sort) + { mFriendsViewSortMenuHandle = friend_view_sort->getHandle(); + mFriendsGearButton->setMenu(friend_view_sort); + } - LLMenuGL* group_view_sort = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_people_groups_view_sort.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + LLToggleableMenu* group_view_sort = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_people_groups_view_sort.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); if(group_view_sort) + { mGroupsViewSortMenuHandle = group_view_sort->getHandle(); + mGroupsGearButton->setMenu(group_view_sort); + } - LLMenuGL* recent_view_sort = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_people_recent_view_sort.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + LLToggleableMenu* recent_view_sort = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_people_recent_view_sort.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); if(recent_view_sort) + { mRecentViewSortMenuHandle = recent_view_sort->getHandle(); + mRecentGearButton->setMenu(recent_view_sort); + } LLVoiceClient::getInstance()->addObserver(this); @@ -911,7 +955,7 @@ void LLPanelPeople::showGroupMenu(LLMenuGL* menu) // Calculate its coordinates. // (assumes that groups panel is the current tab) - LLPanel* bottom_panel = mTabContainer->getCurrentPanel()->getChild<LLPanel>("bottom_panel"); + LLPanel* bottom_panel = mTabContainer->getCurrentPanel()->getChild<LLPanel>("bottom_panel"); LLPanel* parent_panel = mTabContainer->getCurrentPanel(); menu->arrangeAndClear(); S32 menu_height = menu->getRect().getHeight(); @@ -1346,44 +1390,9 @@ void LLPanelPeople::onMoreButtonClicked() // *TODO: not implemented yet } -void LLPanelPeople::onFriendsViewSortButtonClicked() -{ - LLMenuGL* menu = (LLMenuGL*)mFriendsViewSortMenuHandle.get(); - if (!menu) - return; - showGroupMenu(menu); -} - -void LLPanelPeople::onGroupsViewSortButtonClicked() -{ - LLMenuGL* menu = (LLMenuGL*)mGroupsViewSortMenuHandle.get(); - if (!menu) - return; - showGroupMenu(menu); -} - -void LLPanelPeople::onRecentViewSortButtonClicked() -{ - LLMenuGL* menu = (LLMenuGL*)mRecentViewSortMenuHandle.get(); - if (!menu) - return; - showGroupMenu(menu); -} - -void LLPanelPeople::onNearbyViewSortButtonClicked() -{ - LLMenuGL* menu = (LLMenuGL*)mNearbyViewSortMenuHandle.get(); - if (!menu) - return; - showGroupMenu(menu); -} - void LLPanelPeople::onOpen(const LLSD& key) { std::string tab_name = key["people_panel_tab_name"]; - mFilterEditor -> clear(); - onFilterEdit(""); - if (!tab_name.empty()) mTabContainer->selectTabByName(tab_name); } |