From be50a053ed4ae7d0b15fc20f1c6ca0973c56ffd9 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Thu, 12 Aug 2010 09:46:45 -0700 Subject: first pass at hints --- indra/newview/llnearbychathandler.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/newview/llnearbychathandler.cpp') diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index 1fadb126e4..31a59146d6 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -37,6 +37,7 @@ #include "llbottomtray.h" #include "llchatitemscontainerctrl.h" +#include "llfirstuse.h" #include "llfloaterscriptdebug.h" #include "llnearbychat.h" #include "llrecentpeople.h" @@ -347,7 +348,10 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, const LLSD &args) if(chat_msg.mMuted == TRUE) return; if(chat_msg.mSourceType == CHAT_SOURCE_AGENT && chat_msg.mFromID.notNull()) - LLRecentPeople::instance().add(chat_msg.mFromID); + { + LLRecentPeople::instance().add(chat_msg.mFromID); + LLFirstUse::otherAvatarChat(); + } if(chat_msg.mText.empty()) return;//don't process empty messages -- cgit v1.2.3 From 2c999688c4c792630865bd97c2b45ff886d9a26c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 12 Aug 2010 15:18:25 -0700 Subject: added remaining hints and fade in/fade out behavior --- indra/newview/llnearbychathandler.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/newview/llnearbychathandler.cpp') diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index 31a59146d6..4011552112 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -350,7 +350,10 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, const LLSD &args) if(chat_msg.mSourceType == CHAT_SOURCE_AGENT && chat_msg.mFromID.notNull()) { LLRecentPeople::instance().add(chat_msg.mFromID); - LLFirstUse::otherAvatarChat(); + if (chat_msg.mFromID != gAgentID) + { + LLFirstUse::otherAvatarChatFirst(); + } } if(chat_msg.mText.empty()) -- cgit v1.2.3 From c20bd2dfee1068d5a23eef9a10d21c2035c0b324 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 16 Aug 2010 15:00:51 -0700 Subject: cleaned up LLUICtrlFactory... removed redundant functionality moved buildPanel to LLPanel --- indra/newview/llnearbychathandler.cpp | 120 ++++++++++++++++++++-------------- 1 file changed, 71 insertions(+), 49 deletions(-) (limited to 'indra/newview/llnearbychathandler.cpp') diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index 4011552112..024929430c 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -39,6 +39,7 @@ #include "llchatitemscontainerctrl.h" #include "llfirstuse.h" #include "llfloaterscriptdebug.h" +#include "llhints.h" #include "llnearbychat.h" #include "llrecentpeople.h" @@ -62,7 +63,13 @@ LLToastPanelBase* createToastPanel() class LLNearbyChatScreenChannel: public LLScreenChannelBase { public: - LLNearbyChatScreenChannel(const LLUUID& id):LLScreenChannelBase(id) { mStopProcessing = false;}; + typedef std::vector > toast_vec_t; + typedef std::list > toast_list_t; + + LLNearbyChatScreenChannel(const LLUUID& id):LLScreenChannelBase(id) + { + mStopProcessing = false; + } void addNotification (LLSD& notification); void arrangeToasts (); @@ -82,15 +89,12 @@ public: } // hide all toasts from screen, but not remove them from a channel - virtual void hideToastsFromScreen() - { - }; // removes all toasts from a channel virtual void removeToastsFromChannel() { - for(std::vector::iterator it = m_active_toasts.begin(); it != m_active_toasts.end(); ++it) + for(toast_vec_t::iterator it = m_active_toasts.begin(); it != m_active_toasts.end(); ++it) { - addToToastPool((*it)); + addToToastPool(it->get()); } m_active_toasts.clear(); }; @@ -105,10 +109,11 @@ public: protected: void addToToastPool(LLToast* toast) { + if (!toast) return; toast->setVisible(FALSE); toast->stopTimer(); toast->setIsHidden(true); - m_toast_pool.push_back(toast); + m_toast_pool.push_back(toast->getHandle()); } void createOverflowToast(S32 bottom, F32 timer); @@ -117,8 +122,8 @@ protected: bool createPoolToast(); - std::vector m_active_toasts; - std::list m_toast_pool; + toast_vec_t m_active_toasts; + toast_list_t m_toast_pool; bool mStopProcessing; }; @@ -139,7 +144,7 @@ void LLNearbyChatScreenChannel::onToastFade(LLToast* toast) if(!toast) return; - std::vector::iterator pos = std::find(m_active_toasts.begin(),m_active_toasts.end(),toast); + toast_vec_t::iterator pos = std::find(m_active_toasts.begin(),m_active_toasts.end(),toast->getHandle()); if(pos!=m_active_toasts.end()) m_active_toasts.erase(pos); @@ -166,7 +171,7 @@ bool LLNearbyChatScreenChannel::createPoolToast() toast->setOnFadeCallback(boost::bind(&LLNearbyChatScreenChannel::onToastFade, this, _1)); toast->setOnToastDestroyedCallback(boost::bind(&LLNearbyChatScreenChannel::onToastDestroyed, this, _1)); - m_toast_pool.push_back(toast); + m_toast_pool.push_back(toast->getHandle()); return true; } @@ -184,17 +189,20 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification) { LLUUID fromID = notification["from_id"].asUUID(); // agent id or object id std::string from = notification["from"].asString(); - LLToast* toast = m_active_toasts[0]; - LLNearbyChatToastPanel* panel = dynamic_cast(toast->getPanel()); - - if(panel && panel->messageID() == fromID && panel->getFromName() == from && panel->canAddText()) + LLToast* toast = m_active_toasts[0].get(); + if (toast) { - panel->addMessage(notification); - toast->reshapeToPanel(); - toast->resetTimer(); - - arrangeToasts(); - return; + LLNearbyChatToastPanel* panel = dynamic_cast(toast->getPanel()); + + if(panel && panel->messageID() == fromID && panel->getFromName() == from && panel->canAddText()) + { + panel->addMessage(notification); + toast->reshapeToPanel(); + toast->resetTimer(); + + arrangeToasts(); + return; + } } } @@ -222,7 +230,7 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification) //take 1st element from pool, (re)initialize it, put it in active toasts - LLToast* toast = m_toast_pool.back(); + LLToast* toast = m_toast_pool.back().get(); m_toast_pool.pop_back(); @@ -235,25 +243,36 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification) toast->reshapeToPanel(); toast->resetTimer(); - m_active_toasts.push_back(toast); + m_active_toasts.push_back(toast->getHandle()); arrangeToasts(); } void LLNearbyChatScreenChannel::arrangeToasts() { - if(m_active_toasts.size() == 0 || isHovering()) - return; - - hideToastsFromScreen(); + if(!isHovering()) + { + showToastsBottom(); + } - showToastsBottom(); + if (m_active_toasts.empty()) + { + LLHints::registerHintTarget("incoming_chat", LLHandle()); + } + else + { + LLToast* toast = m_active_toasts.front().get(); + if (toast) + { + LLHints::registerHintTarget("incoming_chat", m_active_toasts.front().get()->LLView::getHandle()); + } + } } -int sort_toasts_predicate(LLToast* first,LLToast* second) +int sort_toasts_predicate(LLHandle first, LLHandle second) { - F32 v1 = first->getTimer()->getEventTimer().getElapsedTimeF32(); - F32 v2 = second->getTimer()->getEventTimer().getElapsedTimeF32(); + F32 v1 = first.get()->getTimer()->getEventTimer().getElapsedTimeF32(); + F32 v2 = second.get()->getTimer()->getEventTimer().getElapsedTimeF32(); return v1 < v2; } @@ -271,20 +290,22 @@ void LLNearbyChatScreenChannel::showToastsBottom() //calc max visible item and hide other toasts. - for(std::vector::iterator it = m_active_toasts.begin(); it != m_active_toasts.end(); ++it) + for(toast_vec_t::iterator it = m_active_toasts.begin(); it != m_active_toasts.end(); ++it) { - S32 toast_top = bottom + (*it)->getRect().getHeight() + margin; + LLToast* toast = it->get(); + if (!toast) continue; + + S32 toast_top = bottom + toast->getRect().getHeight() + margin; if(toast_top > gFloaterView->getRect().getHeight()) { while(it!=m_active_toasts.end()) { - addToToastPool((*it)); + addToToastPool(it->get()); it=m_active_toasts.erase(it); } break; } - LLToast* toast = (*it); toast_rect = toast->getRect(); toast_rect.setLeftTopAndSize(getRect().mLeft , bottom + toast_rect.getHeight(), toast_rect.getWidth() ,toast_rect.getHeight()); @@ -295,13 +316,16 @@ void LLNearbyChatScreenChannel::showToastsBottom() // use reverse order to provide correct z-order and avoid toast blinking - for(std::vector::reverse_iterator it = m_active_toasts.rbegin(); it != m_active_toasts.rend(); ++it) + for(toast_vec_t::reverse_iterator it = m_active_toasts.rbegin(); it != m_active_toasts.rend(); ++it) { - LLToast* toast = (*it); - toast->setIsHidden(false); - toast->setVisible(TRUE); - + LLToast* toast = it->get(); + if (toast) + { + toast->setIsHidden(false); + toast->setVisible(TRUE); + } } + } void LLNearbyChatScreenChannel::reshape (S32 width, S32 height, BOOL called_from_parent) @@ -347,14 +371,6 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, const LLSD &args) { if(chat_msg.mMuted == TRUE) return; - if(chat_msg.mSourceType == CHAT_SOURCE_AGENT && chat_msg.mFromID.notNull()) - { - LLRecentPeople::instance().add(chat_msg.mFromID); - if (chat_msg.mFromID != gAgentID) - { - LLFirstUse::otherAvatarChatFirst(); - } - } if(chat_msg.mText.empty()) return;//don't process empty messages @@ -457,7 +473,13 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, const LLSD &args) notification["font_size"] = (S32)LLViewerChat::getChatFontSize() ; channel->addNotification(notification); } - + + if(chat_msg.mSourceType == CHAT_SOURCE_AGENT + && chat_msg.mFromID.notNull() + && chat_msg.mFromID != gAgentID) + { + LLFirstUse::otherAvatarChatFirst(); + } } void LLNearbyChatHandler::onDeleteToast(LLToast* toast) -- cgit v1.2.3 From 83bb4b9518da813a42e49366cea15e5ae9dc7507 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 16 Sep 2010 22:10:30 -0700 Subject: fixed merge --- indra/newview/llnearbychathandler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llnearbychathandler.cpp') diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index 303f2abcce..83777af31a 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -28,7 +28,7 @@ #include "llagentdata.h" // for gAgentID #include "llnearbychathandler.h" - +#include "llchannelmanager.h" #include "llbottomtray.h" #include "llchatitemscontainerctrl.h" #include "llfirstuse.h" @@ -36,6 +36,7 @@ #include "llhints.h" #include "llnearbychat.h" #include "llrecentpeople.h" +#include "llscreenchannel.h" #include "llviewercontrol.h" -- cgit v1.2.3 From 5fac8e4fd0fdb6ee136bbafa8263d234766da7e2 Mon Sep 17 00:00:00 2001 From: Vadim Savchuk Date: Fri, 17 Sep 2010 22:21:00 +0300 Subject: STORM-192 FIXED Ctrl-Shift-W not to disable nearby chat toasts. Bug reason: The fix of EXT-1419 disables showing nearby chat showing toasts at all whenever you close one. That was done to prevent a crash when viewer is exiting, but closing a toast manually should be handled differently. Fix: If a toast is being closed (destroyed) manually, just remove it from the toast pool (to prevent further references to the invalid pointer), but keep on showing new toasts. I've overriden LLFloater::onClose() to differentiate the two cases. --- indra/newview/llnearbychathandler.cpp | 75 +++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 8 deletions(-) (limited to 'indra/newview/llnearbychathandler.cpp') diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index a747c228a6..b6d2e02eef 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -64,7 +64,7 @@ public: typedef boost::function create_toast_panel_callback_t; void setCreatePanelCallback(create_toast_panel_callback_t value) { m_create_toast_panel_callback_t = value;} - void onToastDestroyed (LLToast* toast); + void onToastDestroyed (LLToast* toast, bool app_quitting); void onToastFade (LLToast* toast); void reshape (S32 width, S32 height, BOOL called_from_parent); @@ -96,6 +96,7 @@ public: } protected: + void deactivateToast(LLToast* toast); void addToToastPool(LLToast* toast) { toast->setVisible(FALSE); @@ -116,14 +117,65 @@ protected: bool mStopProcessing; }; +//----------------------------------------------------------------------------------------------- +// LLNearbyChatToast +//----------------------------------------------------------------------------------------------- + +// We're deriving from LLToast to be able to override onClose() +// in order to handle closing nearby chat toasts properly. +class LLNearbyChatToast : public LLToast +{ + LOG_CLASS(LLNearbyChatToast); +public: + LLNearbyChatToast(const LLToast::Params& p, LLNearbyChatScreenChannel* nc_channelp) + : LLToast(p), + mNearbyChatScreenChannelp(nc_channelp) + { + } + + /*virtual*/ void onClose(bool app_quitting); + +private: + LLNearbyChatScreenChannel* mNearbyChatScreenChannelp; +}; + +//----------------------------------------------------------------------------------------------- +// LLNearbyChatScreenChannel +//----------------------------------------------------------------------------------------------- + +void LLNearbyChatScreenChannel::deactivateToast(LLToast* toast) +{ + std::vector::iterator pos = std::find(m_active_toasts.begin(), m_active_toasts.end(), toast); + + if (pos == m_active_toasts.end()) + { + llassert(pos == m_active_toasts.end()); + return; + } + + m_active_toasts.erase(pos); +} + void LLNearbyChatScreenChannel::createOverflowToast(S32 bottom, F32 timer) { //we don't need overflow toast in nearby chat } -void LLNearbyChatScreenChannel::onToastDestroyed(LLToast* toast) +void LLNearbyChatScreenChannel::onToastDestroyed(LLToast* toast, bool app_quitting) { - mStopProcessing = true; + if (app_quitting) + { + // Viewer is quitting. + // Immediately stop processing chat messages (EXT-1419). + mStopProcessing = true; + } + else + { + // The toast is being closed by user (STORM-192). + // Remove it from the list of active toasts to prevent + // further references to the invalid pointer. + deactivateToast(toast); + } } void LLNearbyChatScreenChannel::onToastFade(LLToast* toast) @@ -132,9 +184,7 @@ void LLNearbyChatScreenChannel::onToastFade(LLToast* toast) if(!toast) return; - std::vector::iterator pos = std::find(m_active_toasts.begin(),m_active_toasts.end(),toast); - if(pos!=m_active_toasts.end()) - m_active_toasts.erase(pos); + deactivateToast(toast); addToToastPool(toast); @@ -153,11 +203,10 @@ bool LLNearbyChatScreenChannel::createPoolToast() p.lifetime_secs = gSavedSettings.getS32("NearbyToastLifeTime"); p.fading_time_secs = gSavedSettings.getS32("NearbyToastFadingTime"); - LLToast* toast = new LLToast(p); + LLToast* toast = new LLNearbyChatToast(p, this); toast->setOnFadeCallback(boost::bind(&LLNearbyChatScreenChannel::onToastFade, this, _1)); - toast->setOnToastDestroyedCallback(boost::bind(&LLNearbyChatScreenChannel::onToastDestroyed, this, _1)); m_toast_pool.push_back(toast); return true; @@ -452,4 +501,14 @@ void LLNearbyChatHandler::onDeleteToast(LLToast* toast) } +//----------------------------------------------------------------------------------------------- +// LLNearbyChatToast +//----------------------------------------------------------------------------------------------- + +// virtual +void LLNearbyChatToast::onClose(bool app_quitting) +{ + mNearbyChatScreenChannelp->onToastDestroyed(this, app_quitting); +} +// EOF -- cgit v1.2.3 From 949b60465593764118c03d0f4e112f69c41bab31 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 17 Sep 2010 15:01:44 -0700 Subject: Backed out changeset: d71309f8bd0e --- indra/newview/llnearbychathandler.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/llnearbychathandler.cpp') diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index 83777af31a..303f2abcce 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -28,7 +28,7 @@ #include "llagentdata.h" // for gAgentID #include "llnearbychathandler.h" -#include "llchannelmanager.h" + #include "llbottomtray.h" #include "llchatitemscontainerctrl.h" #include "llfirstuse.h" @@ -36,7 +36,6 @@ #include "llhints.h" #include "llnearbychat.h" #include "llrecentpeople.h" -#include "llscreenchannel.h" #include "llviewercontrol.h" -- cgit v1.2.3 From 022f9bd9a8b80481bb5ecfd651457fe6df3bae30 Mon Sep 17 00:00:00 2001 From: Vadim Savchuk Date: Mon, 20 Sep 2010 19:08:45 +0300 Subject: STORM-192 ADDITIONAL FIX Fixed crash on pressing Ctrl+Shift+W (which closes all floaters). The crash was introduced by my previous fix of this ticket in changeset 8ceebd3612f0. The problem was that, suprisingly, even invisible (faded) toasts were destroyed when you hit Ctrl_Shift+W, however they were still referenced by the toast pool, so the references were invalidated. The easiest fix would be to remove all references to the toast being destroyed, no matter is it visible or not. However, then we'd have to search for each destroyed toast in the pool, which is slow. Besides, removing toasts from the pool compromises the whole idea of pooling (which was introduced to speed up creation of new toasts). Another possible fix is not to destroy any nearby chat toasts when user hits Ctrl+Shift+W. That would save us from any crashes at a price of changing existing behaviour (the toasts will remain visible). So I went for a third option: when closing all floaters, skip invisible ones. Then there won't be attempts to destroy invisible (pooled) toasts, so the crash won't happen, and we don't seem to change any existing behavior. However I'm not 100% sure of the latter statement, so the fix requires extensive testing. --- indra/newview/llnearbychathandler.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'indra/newview/llnearbychathandler.cpp') diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index b6d2e02eef..c80583cd0e 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -54,6 +54,7 @@ LLToastPanelBase* createToastPanel() class LLNearbyChatScreenChannel: public LLScreenChannelBase { + LOG_CLASS(LLNearbyChatScreenChannel); public: LLNearbyChatScreenChannel(const LLUUID& id):LLScreenChannelBase(id) { mStopProcessing = false;}; @@ -90,6 +91,7 @@ public: virtual void deleteAllChildren() { + LL_DEBUGS("NearbyChat") << "Clearing toast pool" << llendl; m_toast_pool.clear(); m_active_toasts.clear(); LLScreenChannelBase::deleteAllChildren(); @@ -99,6 +101,7 @@ protected: void deactivateToast(LLToast* toast); void addToToastPool(LLToast* toast) { + LL_DEBUGS("NearbyChat") << "Pooling toast" << llendl; toast->setVisible(FALSE); toast->stopTimer(); toast->setIsHidden(true); @@ -153,6 +156,7 @@ void LLNearbyChatScreenChannel::deactivateToast(LLToast* toast) return; } + LL_DEBUGS("NearbyChat") << "Deactivating toast" << llendl; m_active_toasts.erase(pos); } @@ -163,6 +167,8 @@ void LLNearbyChatScreenChannel::createOverflowToast(S32 bottom, F32 timer) void LLNearbyChatScreenChannel::onToastDestroyed(LLToast* toast, bool app_quitting) { + LL_DEBUGS("NearbyChat") << "Toast destroyed (app_quitting=" << app_quitting << ")" << llendl; + if (app_quitting) { // Viewer is quitting. @@ -179,7 +185,9 @@ void LLNearbyChatScreenChannel::onToastDestroyed(LLToast* toast, bool app_quitti } void LLNearbyChatScreenChannel::onToastFade(LLToast* toast) -{ +{ + LL_DEBUGS("NearbyChat") << "Toast fading" << llendl; + //fade mean we put toast to toast pool if(!toast) return; @@ -208,6 +216,7 @@ bool LLNearbyChatScreenChannel::createPoolToast() toast->setOnFadeCallback(boost::bind(&LLNearbyChatScreenChannel::onToastFade, this, _1)); + LL_DEBUGS("NearbyChat") << "Creating and pooling toast" << llendl; m_toast_pool.push_back(toast); return true; } @@ -245,6 +254,7 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification) if(m_toast_pool.empty()) { //"pool" is empty - create one more panel + LL_DEBUGS("NearbyChat") << "Empty pool" << llendl; if(!createPoolToast())//created toast will go to pool. so next call will find it return; addNotification(notification); @@ -264,6 +274,7 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification) //take 1st element from pool, (re)initialize it, put it in active toasts + LL_DEBUGS("NearbyChat") << "Getting toast from pool" << llendl; LLToast* toast = m_toast_pool.back(); m_toast_pool.pop_back(); -- cgit v1.2.3 From 0034bdc38bb9f757edbfe2600ee19b3731a5c68b Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 22 Sep 2010 20:12:06 -0700 Subject: fixed build --- indra/newview/llnearbychathandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llnearbychathandler.cpp') diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index f141817b3f..47d32e57fb 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -154,7 +154,7 @@ private: void LLNearbyChatScreenChannel::deactivateToast(LLToast* toast) { - std::vector::iterator pos = std::find(m_active_toasts.begin(), m_active_toasts.end(), toast); + toast_vec_t::iterator pos = std::find(m_active_toasts.begin(), m_active_toasts.end(), toast->getHandle()); if (pos == m_active_toasts.end()) { -- cgit v1.2.3 From b2a6f4853b550af68a6f4487db00663639e20b38 Mon Sep 17 00:00:00 2001 From: Paul Guslisty Date: Tue, 26 Oct 2010 18:15:30 +0300 Subject: STORM-36 FIXED As a User, I want to control how long a chat toast appears before it fades. Please add fade time back to Chat preferences. - Added two spinners to the Chat preferences tab that control NearbyToastLifeTime and NearbyToastFadingTime - Added callbacks to the LLNearbyChatScreenChannel that update these properties if they were changed Refactoring of LLToast: - Removed code that was making toast transparent from LLToast::draw() - Modified LLToast interface that relates to showing and hiding toast, so that all screen channels can use LLToast universally. - Replaced in LLScreenChannel calling methods of old interface to new ones. --- indra/newview/llnearbychathandler.cpp | 58 +++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 6 deletions(-) (limited to 'indra/newview/llnearbychathandler.cpp') diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index 47d32e57fb..d2ad78f140 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -64,6 +64,18 @@ public: LLNearbyChatScreenChannel(const LLUUID& id):LLScreenChannelBase(id) { mStopProcessing = false; + + LLControlVariable* ctrl = gSavedSettings.getControl("NearbyToastLifeTime").get(); + if (ctrl) + { + ctrl->getSignal()->connect(boost::bind(&LLNearbyChatScreenChannel::updateToastsLifetime, this)); + } + + ctrl = gSavedSettings.getControl("NearbyToastFadingTime").get(); + if (ctrl) + { + ctrl->getSignal()->connect(boost::bind(&LLNearbyChatScreenChannel::updateToastFadingTime, this)); + } } void addNotification (LLSD& notification); @@ -109,13 +121,26 @@ protected: if (!toast) return; LL_DEBUGS("NearbyChat") << "Pooling toast" << llendl; toast->setVisible(FALSE); - toast->stopTimer(); + toast->stopFading(); toast->setIsHidden(true); + + // Nearby chat toasts that are hidden, not destroyed. They are collected to the toast pool, so that + // they can be used next time, this is done for performance. But if the toast lifetime was changed + // (from preferences floater (STORY-36)) while it was shown (at this moment toast isn't in the pool yet) + // changes don't take affect. + // So toast's lifetime should be updated each time it's added to the pool. Otherwise viewer would have + // to be restarted so that changes take effect. + toast->setLifetime(gSavedSettings.getS32("NearbyToastLifeTime")); + toast->setFadingTime(gSavedSettings.getS32("NearbyToastFadingTime")); m_toast_pool.push_back(toast->getHandle()); } void createOverflowToast(S32 bottom, F32 timer); + void updateToastsLifetime(); + + void updateToastFadingTime(); + create_toast_panel_callback_t m_create_toast_panel_callback_t; bool createPoolToast(); @@ -205,6 +230,27 @@ void LLNearbyChatScreenChannel::onToastFade(LLToast* toast) arrangeToasts(); } +void LLNearbyChatScreenChannel::updateToastsLifetime() +{ + S32 seconds = gSavedSettings.getS32("NearbyToastLifeTime"); + toast_list_t::iterator it; + + for(it = m_toast_pool.begin(); it != m_toast_pool.end(); ++it) + { + (*it).get()->setLifetime(seconds); + } +} + +void LLNearbyChatScreenChannel::updateToastFadingTime() +{ + S32 seconds = gSavedSettings.getS32("NearbyToastFadingTime"); + toast_list_t::iterator it; + + for(it = m_toast_pool.begin(); it != m_toast_pool.end(); ++it) + { + (*it).get()->setFadingTime(seconds); + } +} bool LLNearbyChatScreenChannel::createPoolToast() { @@ -250,7 +296,7 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification) { panel->addMessage(notification); toast->reshapeToPanel(); - toast->resetTimer(); + toast->startFading(); arrangeToasts(); return; @@ -295,7 +341,7 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification) panel->init(notification); toast->reshapeToPanel(); - toast->resetTimer(); + toast->startFading(); m_active_toasts.push_back(toast->getHandle()); @@ -325,9 +371,9 @@ void LLNearbyChatScreenChannel::arrangeToasts() int sort_toasts_predicate(LLHandle first, LLHandle second) { - F32 v1 = first.get()->getTimer()->getEventTimer().getElapsedTimeF32(); - F32 v2 = second.get()->getTimer()->getEventTimer().getElapsedTimeF32(); - return v1 < v2; + F32 v1 = first.get()->getTimeLeftToLive(); + F32 v2 = second.get()->getTimeLeftToLive(); + return v1 > v2; } void LLNearbyChatScreenChannel::showToastsBottom() -- cgit v1.2.3