diff options
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/newview/llnearbychathandler.cpp | 58 | ||||
| -rw-r--r-- | indra/newview/llscreenchannel.cpp | 8 | ||||
| -rw-r--r-- | indra/newview/lltoast.cpp | 110 | ||||
| -rw-r--r-- | indra/newview/lltoast.h | 35 | ||||
| -rw-r--r-- | indra/newview/skins/default/xui/en/panel_preferences_chat.xml | 34 | 
5 files changed, 210 insertions, 35 deletions
| 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<LLToast> first, LLHandle<LLToast> 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() diff --git a/indra/newview/llscreenchannel.cpp b/indra/newview/llscreenchannel.cpp index 18c9ac28c1..61f4897ed0 100644 --- a/indra/newview/llscreenchannel.cpp +++ b/indra/newview/llscreenchannel.cpp @@ -369,7 +369,7 @@ void LLScreenChannel::loadStoredToastsToChannel()  	for(it = mStoredToastList.begin(); it != mStoredToastList.end(); ++it)  	{  		(*it).toast->setIsHidden(false); -		(*it).toast->resetTimer(); +		(*it).toast->startFading();  		mToastList.push_back((*it));  	} @@ -394,7 +394,7 @@ void LLScreenChannel::loadStoredToastByNotificationIDToChannel(LLUUID id)  	}  	toast->setIsHidden(false); -	toast->resetTimer(); +	toast->startFading();  	mToastList.push_back((*it));  	redrawToasts(); @@ -477,7 +477,7 @@ void LLScreenChannel::modifyToastByNotificationID(LLUUID id, LLPanel* panel)  		toast->removeChild(old_panel);  		delete old_panel;  		toast->insertPanel(panel); -		toast->resetTimer(); +		toast->startFading();  		redrawToasts();  	}  } @@ -588,7 +588,7 @@ void LLScreenChannel::showToastsBottom()  		mHiddenToastsNum = 0;  		for(; it != mToastList.rend(); it++)  		{ -			(*it).toast->stopTimer(); +			(*it).toast->stopFading();  			(*it).toast->setVisible(FALSE);  			mHiddenToastsNum++;  		} diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp index c3090cb1fc..8176b8c1f9 100644 --- a/indra/newview/lltoast.cpp +++ b/indra/newview/lltoast.cpp @@ -35,6 +35,13 @@  using namespace LLNotificationsUI; +//-------------------------------------------------------------------------- +LLToastLifeTimer::LLToastLifeTimer(LLToast* toast, F32 period) +	: mToast(toast), +	  LLEventTimer(period) +{ +} +  /*virtual*/  BOOL LLToastLifeTimer::tick()  { @@ -45,6 +52,38 @@ BOOL LLToastLifeTimer::tick()  	return FALSE;  } +void LLToastLifeTimer::stop() +{ +	mEventTimer.stop(); +} + +void LLToastLifeTimer::start() +{ +	mEventTimer.start(); +} + +void LLToastLifeTimer::restart() +{ +	mEventTimer.reset(); +} + +BOOL LLToastLifeTimer::getStarted() +{ +	return mEventTimer.getStarted(); +} + +void LLToastLifeTimer::setPeriod(F32 period) +{ +	mPeriod = period; +} + +F32 LLToastLifeTimer::getRemainingTimeF32() +{ +	F32 et = mEventTimer.getElapsedTimeF32(); +	if (!getStarted() || et > mPeriod) return 0.0f; +	return mPeriod - et; +} +  //--------------------------------------------------------------------------  LLToast::Params::Params()   :	can_fade("can_fade", true), @@ -73,7 +112,8 @@ LLToast::LLToast(const LLToast::Params& p)  	mIsHidden(false),  	mHideBtnPressed(false),  	mIsTip(p.is_tip), -	mWrapperPanel(NULL) +	mWrapperPanel(NULL), +	mIsTransparent(false)  {  	mTimer.reset(new LLToastLifeTimer(this, p.lifetime_secs)); @@ -143,6 +183,7 @@ LLToast::~LLToast()  void LLToast::hide()  {  	setVisible(FALSE); +	setTransparentState(false);  	mTimer->stop();  	mIsHidden = true;  	mOnFadeSignal(this);  @@ -166,6 +207,16 @@ void LLToast::onFocusReceived()  	}  } +void LLToast::setLifetime(S32 seconds) +{ +	mToastLifetime = seconds; +} + +void LLToast::setFadingTime(S32 seconds) +{ +	mToastFadingTime = seconds; +} +  S32 LLToast::getTopPad()  {  	if(mWrapperPanel) @@ -195,13 +246,46 @@ void LLToast::setCanFade(bool can_fade)  //--------------------------------------------------------------------------  void LLToast::expire()  { -	// if toast has fade property - hide it -	if(mCanFade) +	if (mCanFade)  	{ -		hide(); +		if (mIsTransparent) +		{ +			hide(); +		} +		else +		{ +			setTransparentState(true); +			mTimer->restart(); +		}  	}  } +void LLToast::setTransparentState(bool transparent) +{ +	setBackgroundOpaque(!transparent); +	mIsTransparent = transparent; + +	if (transparent) +	{ +		mTimer->setPeriod(mToastFadingTime); +	} +	else +	{ +		mTimer->setPeriod(mToastLifetime); +	} +} + +F32 LLToast::getTimeLeftToLive() +{ +	F32 time_to_live = mTimer->getRemainingTimeF32(); + +	if (!mIsTransparent) +	{ +		time_to_live += mToastFadingTime; +	} + +	return time_to_live; +}  //--------------------------------------------------------------------------  void LLToast::reshapeToPanel() @@ -245,13 +329,6 @@ void LLToast::draw()  			drawChild(mHideBtn);  		}  	} - -	// if timer started and remaining time <= fading time -	if (mTimer->getStarted() && (mToastLifetime -			- mTimer->getEventTimer().getElapsedTimeF32()) <= mToastFadingTime) -	{ -		setBackgroundOpaque(FALSE); -	}  }  //-------------------------------------------------------------------------- @@ -267,6 +344,11 @@ void LLToast::setVisible(BOOL show)  		return;  	} +	if (show && getVisible()) +	{ +		return; +	} +  	if(show)  	{  		setBackgroundOpaque(TRUE); @@ -372,7 +454,8 @@ void LLNotificationsUI::LLToast::stopFading()  {  	if(mCanFade)  	{ -		stopTimer(); +		setTransparentState(false); +		mTimer->stop();  	}  } @@ -380,7 +463,8 @@ void LLNotificationsUI::LLToast::startFading()  {  	if(mCanFade)  	{ -		resetTimer(); +		setTransparentState(false); +		mTimer->start();  	}  } diff --git a/indra/newview/lltoast.h b/indra/newview/lltoast.h index 0a96c092a0..fb534561c9 100644 --- a/indra/newview/lltoast.h +++ b/indra/newview/lltoast.h @@ -49,14 +49,16 @@ class LLToast;  class LLToastLifeTimer: public LLEventTimer  {  public: -	LLToastLifeTimer(LLToast* toast, F32 period) : mToast(toast), LLEventTimer(period){} +	LLToastLifeTimer(LLToast* toast, F32 period);  	/*virtual*/  	BOOL tick(); -	void stop() { mEventTimer.stop(); } -	void start() { mEventTimer.start(); } -	void restart() {mEventTimer.reset(); } -	BOOL getStarted() { return mEventTimer.getStarted(); } +	void stop(); +	void start(); +	void restart(); +	BOOL getStarted(); +	void setPeriod(F32 period); +	F32 getRemainingTimeF32();  	LLTimer&  getEventTimer() { return mEventTimer;}  private : @@ -80,8 +82,14 @@ public:  		Optional<LLUUID>				notif_id,	 //notification ID  										session_id;	 //im session ID  		Optional<LLNotificationPtr>		notification; -		Optional<F32>					lifetime_secs, -										fading_time_secs; // Number of seconds while a toast is fading + +		//NOTE: Life time of a toast (i.e. period of time from the moment toast was shown +		//till the moment when toast was hidden) is the sum of lifetime_secs and fading_time_secs. + +		Optional<F32>					lifetime_secs, // Number of seconds while a toast is non-transparent +										fading_time_secs; // Number of seconds while a toast is transparent + +  		Optional<toast_callback_t>		on_delete_toast,  										on_mouse_enter;  		Optional<bool>					can_fade, @@ -125,10 +133,8 @@ public:  	LLPanel* getPanel() { return mPanel; }  	// enable/disable Toast's Hide button  	void setHideButtonEnabled(bool enabled); -	//  -	void resetTimer() { mTimer->start(); }  	// -	void stopTimer() { mTimer->stop(); } +	F32 getTimeLeftToLive();  	//  	LLToastLifeTimer* getTimer() { return mTimer.get();}  	// @@ -144,6 +150,10 @@ public:  	/*virtual*/ void onFocusReceived(); +	void setLifetime(S32 seconds); + +	void setFadingTime(S32 seconds); +  	/**  	 * Returns padding between floater top and wrapper_panel top.  	 * This padding should be taken into account when positioning or reshaping toasts @@ -196,7 +206,9 @@ private:  	void onToastMouseLeave(); -	void	expire(); +	void expire(); + +	void setTransparentState(bool transparent);  	LLUUID				mNotificationID;  	LLUUID				mSessionID; @@ -222,6 +234,7 @@ private:  	bool		mHideBtnPressed;  	bool		mIsHidden;  // this flag is TRUE when a toast has faded or was hidden with (x) button (EXT-1849)  	bool		mIsTip; +	bool		mIsTransparent;  	commit_signal_t mToastMouseEnterSignal;  	commit_signal_t mToastMouseLeaveSignal; diff --git a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml index 31e160ec33..c009fd2931 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml @@ -308,6 +308,38 @@       width="95">          URLs      </text> +    <spinner +     control_name="NearbyToastLifeTime" +     decimal_digits="0" +     follows="left|top" +     height="23" +     increment="1" +     initial_value="23" +     label="Nearby chat toasts life time:" +     label_width="190" +     layout="topleft" +     left="290" +     max_val="60" +     min_val="1" +     name="nearby_toasts_lifetime" +     top_pad="33" +     width="210" /> +    <spinner +     control_name="NearbyToastFadingTime" +     decimal_digits="0" +     follows="left|top" +     height="23" +     increment="1" +     initial_value="3" +     label="Nearby chat toasts fading time:" +     label_width="190" +     layout="topleft" +     left_delta="00" +     max_val="60" +     min_val="0" +     name="nearby_toasts_fadingtime" +     top_pad="15" +     width="210" />      <check_box       control_name="PlayTypingAnim"       height="16" @@ -316,7 +348,7 @@       layout="topleft"       left="30"       name="play_typing_animation" -     top_pad="32" +     top="205"       width="400" />      <check_box       enabled="false" | 
