From d541d99fce104d28eac378947261297461603462 Mon Sep 17 00:00:00 2001
From: AlexanderP ProductEngine <apaschenko@productengine.com>
Date: Wed, 14 Nov 2012 21:44:58 +0200
Subject: CHUI-487, CHUI-488 W.I.P. #1 (Enable flashing FUI button behavior and
 Implement Flashing Conversations panel line item behavior): build new class
 LLFlashTimer based on LLSysWellChiclet::FlashToLitTimer; prepared it for
 general purpose; replaced LLSysWellChiclet::FlashToLitTimer to LLFlashTimer

---
 indra/newview/CMakeLists.txt            |  2 +
 indra/newview/app_settings/settings.xml |  4 +-
 indra/newview/llchiclet.cpp             | 65 ++-------------------------------
 indra/newview/llchiclet.h               |  5 ++-
 4 files changed, 10 insertions(+), 66 deletions(-)

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index f652c9e50c..574fdc495a 100755
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -178,6 +178,7 @@ set(viewer_SOURCE_FILES
     llfilepicker.cpp
     llfilteredwearablelist.cpp
     llfirstuse.cpp
+    llflashtimer.cpp
     llflexibleobject.cpp
     llfloaterabout.cpp
     llfloaterbvhpreview.cpp
@@ -762,6 +763,7 @@ set(viewer_HEADER_FILES
     llfilepicker.h
     llfilteredwearablelist.h
     llfirstuse.h
+    llflashtimer.h
     llflexibleobject.h
     llfloaterabout.h
     llfloaterbvhpreview.h
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index b703b9cc8e..14117ee47b 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -13142,7 +13142,7 @@
       <key>Value</key>
       <real>50.0</real>
     </map>
-    <key>WellIconFlashCount</key>
+    <key>FlashCount</key>
     <map>
       <key>Comment</key>
       <string>Number of flashes of IM Well and Notification Well icons after which flashing buttons stay lit up. Requires restart.</string>
@@ -13153,7 +13153,7 @@
       <key>Value</key>
       <integer>3</integer>
     </map>
-    <key>WellIconFlashPeriod</key>
+    <key>FlashPeriod</key>
     <map>
       <key>Comment</key>
       <string>Period at which IM Well and Notification Well icons flash (seconds). Requires restart.</string>
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp
index 64d8a68a99..d6860640b7 100644
--- a/indra/newview/llchiclet.cpp
+++ b/indra/newview/llchiclet.cpp
@@ -67,60 +67,6 @@ boost::signals2::signal<LLChiclet* (const LLUUID&),
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 
-/**
- * Updates the Well's 'Lit' state to flash it when "new messages" are come.
- *
- * It gets callback which will be called 2*N times with passed period. See EXT-3147
- */
-class LLSysWellChiclet::FlashToLitTimer : public LLEventTimer
-{
-public:
-	typedef boost::function<void()> callback_t;
-
-	/**
-	 * Constructor.
-	 *
-	 * @param count - how many times callback should be called (twice to not change original state)
-	 * @param period - how frequently callback should be called
-	 * @param cb - callback to be called each tick
-	 */
-	FlashToLitTimer(S32 count, F32 period, callback_t cb)
-		: LLEventTimer(period)
-		, mCallback(cb)
-		, mFlashCount(2 * count)
-		, mCurrentFlashCount(0)
-	{
-		mEventTimer.stop();
-	}
-
-	BOOL tick()
-	{
-		mCallback();
-
-		if (++mCurrentFlashCount == mFlashCount) mEventTimer.stop();
-		return FALSE;
-	}
-
-	void flash()
-	{
-		mCurrentFlashCount = 0;
-		mEventTimer.start();
-	}
-
-	void stopFlashing()
-	{
-		mEventTimer.stop();
-	}
-
-private:
-	callback_t		mCallback;
-
-	/**
-	 * How many times Well will blink.
-	 */
-	S32 mFlashCount;
-	S32 mCurrentFlashCount;
-};
 
 LLSysWellChiclet::Params::Params()
 : button("button")
@@ -145,13 +91,8 @@ LLSysWellChiclet::LLSysWellChiclet(const Params& p)
 	mButton = LLUICtrlFactory::create<LLButton>(button_params);
 	addChild(mButton);
 
-	// use settings from settings.xml to be able change them via Debug settings. See EXT-5973.
-	// Due to Timer is implemented as derived class from EventTimer it is impossible to change period
-	// in runtime. So, both settings are made as required restart.
-	static S32 flash_to_lit_count = gSavedSettings.getS32("WellIconFlashCount");
-	static F32 flash_period = gSavedSettings.getF32("WellIconFlashPeriod");
 
-	mFlashToLitTimer = new FlashToLitTimer(flash_to_lit_count, flash_period, boost::bind(&LLSysWellChiclet::changeLitState, this));
+	mFlashToLitTimer = new LLFlashTimer(boost::bind(&LLSysWellChiclet::changeLitState, this, _1));
 }
 
 LLSysWellChiclet::~LLSysWellChiclet()
@@ -191,7 +132,7 @@ void LLSysWellChiclet::setToggleState(BOOL toggled) {
 	mButton->setToggleState(toggled);
 }
 
-void LLSysWellChiclet::changeLitState()
+void LLSysWellChiclet::changeLitState(bool blink)
 {
 	setNewMessagesState(!mIsNewMessagesState);
 }
@@ -320,7 +261,7 @@ void LLIMWellChiclet::messageCountChanged(const LLSD& session_data)
 	// we have to flash to 'Lit' state each time new unread message is coming.
 	if (counter > mCounter && im_not_visible)
 	{
-		mFlashToLitTimer->flash();
+		mFlashToLitTimer->startFlashing();
 	}
 	else if (counter == 0)
 	{
diff --git a/indra/newview/llchiclet.h b/indra/newview/llchiclet.h
index d6be2df103..79ffad92ef 100644
--- a/indra/newview/llchiclet.h
+++ b/indra/newview/llchiclet.h
@@ -29,6 +29,7 @@
 
 #include "llavatariconctrl.h"
 #include "llbutton.h"
+#include "llflashtimer.h"
 #include "llpanel.h"
 #include "lltextbox.h"
 #include "lloutputmonitorctrl.h"
@@ -844,7 +845,7 @@ protected:
 	 * There is an assumption that it will be called 2*N times to do not change its start state.
 	 * @see FlashToLitTimer
 	 */
-	void changeLitState();
+	void changeLitState(bool blink);
 
 	/**
 	 * Displays menu.
@@ -860,7 +861,7 @@ protected:
 	S32 mMaxDisplayedCount;
 	bool mIsNewMessagesState;
 
-	FlashToLitTimer* mFlashToLitTimer;
+	LLFlashTimer* mFlashToLitTimer;
 	LLContextMenu* mContextMenu;
 };
 
-- 
cgit v1.2.3