diff options
Diffstat (limited to 'indra/newview/llpanelpeople.cpp')
-rw-r--r-- | indra/newview/llpanelpeople.cpp | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index 58765d0ad8..6dd800c0c6 100644 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -272,7 +272,6 @@ public: friend class LLInventoryFriendCardObserver; LLFriendListUpdater(callback_t cb) : LLAvatarListUpdater(cb, FRIEND_LIST_UPDATE_TIMEOUT) - , mIsActive(false) { LLAvatarTracker::instance().addObserver(this); @@ -291,12 +290,9 @@ public: /*virtual*/ void changed(U32 mask) { - if (mIsActive) - { - // events can arrive quickly in bulk - we need not process EVERY one of them - - // so we wait a short while to let others pile-in, and process them in aggregate. - mEventTimer.start(); - } + // events can arrive quickly in bulk - we need not process EVERY one of them - + // so we wait a short while to let others pile-in, and process them in aggregate. + mEventTimer.start(); // save-up all the mask-bits which have come-in mMask |= mask; @@ -305,12 +301,8 @@ public: /*virtual*/ BOOL tick() { - if (!mIsActive) return FALSE; - if (mMask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE)) - { updateList(); - } // Stop updates. mEventTimer.stop(); @@ -319,20 +311,9 @@ public: return FALSE; } - // virtual - void setActive(bool active) - { - mIsActive = active; - if (active) - { - tick(); - } - } - private: U32 mMask; LLInventoryFriendCardObserver* mInvObserver; - bool mIsActive; /** * This class is intended for updating Friend List when Inventory Friend Card is added/removed. @@ -515,25 +496,22 @@ void LLPanelPeople::onFriendsAccordionExpandedCollapsed(LLUICtrl* ctrl, const LL BOOL LLPanelPeople::postBuild() { + setVisibleCallback(boost::bind(&LLPanelPeople::onVisibilityChange, this, _2)); + mFilterEditor = getChild<LLFilterEditor>("filter_input"); mFilterEditor->setCommitCallback(boost::bind(&LLPanelPeople::onFilterEdit, this, _2)); mTabContainer = getChild<LLTabContainer>("tabs"); mTabContainer->setCommitCallback(boost::bind(&LLPanelPeople::onTabSelected, this, _2)); - LLPanel* friends_tab = getChild<LLPanel>(FRIENDS_TAB_NAME); - // updater is active only if panel is visible to user. - friends_tab->setVisibleCallback(boost::bind(&Updater::setActive, mFriendListUpdater, _2)); - mOnlineFriendList = friends_tab->getChild<LLAvatarList>("avatars_online"); - mAllFriendList = friends_tab->getChild<LLAvatarList>("avatars_all"); + mOnlineFriendList = getChild<LLPanel>(FRIENDS_TAB_NAME)->getChild<LLAvatarList>("avatars_online"); + mAllFriendList = getChild<LLPanel>(FRIENDS_TAB_NAME)->getChild<LLAvatarList>("avatars_all"); mOnlineFriendList->setNoItemsCommentText(getString("no_friends_online")); mOnlineFriendList->setShowIcons("FriendsListShowIcons"); mAllFriendList->setNoItemsCommentText(getString("no_friends")); mAllFriendList->setShowIcons("FriendsListShowIcons"); - LLPanel* nearby_tab = getChild<LLPanel>(NEARBY_TAB_NAME); - nearby_tab->setVisibleCallback(boost::bind(&Updater::setActive, mNearbyListUpdater, _2)); - mNearbyList = nearby_tab->getChild<LLAvatarList>("avatar_list"); + mNearbyList = getChild<LLPanel>(NEARBY_TAB_NAME)->getChild<LLAvatarList>("avatar_list"); mNearbyList->setNoItemsCommentText(getString("no_one_near")); mNearbyList->setNoItemsMsg(getString("no_one_near")); mNearbyList->setNoFilteredItemsMsg(getString("no_one_filtered_near")); @@ -822,8 +800,8 @@ void LLPanelPeople::updateButtons() } LLPanel* groups_panel = mTabContainer->getCurrentPanel(); - groups_panel->getChildView("activate_btn")->setEnabled(item_selected && !cur_group_active); // "none" or a non-active group selected - groups_panel->getChildView("minus_btn")->setEnabled(item_selected && selected_id.notNull()); + groups_panel->childSetEnabled("activate_btn", item_selected && !cur_group_active); // "none" or a non-active group selected + groups_panel->childSetEnabled("minus_btn", item_selected && selected_id.notNull()); } else { @@ -839,10 +817,10 @@ void LLPanelPeople::updateButtons() LLPanel* cur_panel = mTabContainer->getCurrentPanel(); if (cur_panel) { - cur_panel->getChildView("add_friend_btn")->setEnabled(!is_friend); + cur_panel->childSetEnabled("add_friend_btn", !is_friend); if (friends_tab_active) { - cur_panel->getChildView("del_btn")->setEnabled(multiple_selected); + cur_panel->childSetEnabled("del_btn", multiple_selected); } } } @@ -977,6 +955,28 @@ void LLPanelPeople::setSortOrder(LLAvatarList* list, ESortOrder order, bool save } } +void LLPanelPeople::onVisibilityChange(const LLSD& new_visibility) +{ + if (new_visibility.asBoolean() == FALSE) + { + // Don't update anything while we're invisible. + mNearbyListUpdater->setActive(FALSE); + } + else + { + reSelectedCurrentTab(); + } +} + +// Make the tab-container re-select current tab +// for onTabSelected() callback to get called. +// (currently this is needed to reactivate nearby list updates +// when we get visible) +void LLPanelPeople::reSelectedCurrentTab() +{ + mTabContainer->selectTab(mTabContainer->getCurrentPanelIndex()); +} + bool LLPanelPeople::isRealGroup() { return getCurrentItemID() != LLUUID::null; @@ -1024,6 +1024,7 @@ void LLPanelPeople::onFilterEdit(const std::string& search_string) void LLPanelPeople::onTabSelected(const LLSD& param) { std::string tab_name = getChild<LLPanel>(param.asString())->getName(); + mNearbyListUpdater->setActive(tab_name == NEARBY_TAB_NAME); updateButtons(); showFriendsAccordionsIfNeeded(); @@ -1387,6 +1388,8 @@ void LLPanelPeople::onOpen(const LLSD& key) if (!tab_name.empty()) mTabContainer->selectTabByName(tab_name); + else + reSelectedCurrentTab(); } bool LLPanelPeople::notifyChildren(const LLSD& info) |