summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorAlexanderP ProductEngine <apaschenko@productengine.com>2012-11-16 22:36:12 +0200
committerAlexanderP ProductEngine <apaschenko@productengine.com>2012-11-16 22:36:12 +0200
commite298c2ded8e25a28127c668cf30a74a25c139041 (patch)
tree0517349a365864905a68ba6bf9f66ee05ddc41f4 /indra/llui
parent50b69c3f97c0b58791f7dd67f8b2fbdc9e8ef503 (diff)
CHUI-487, CHUI-488 FIXED (Enable flashing FUI button behavior and Implement Flashing Conversations panel line item behavior): implemented FUI button flashing; clean up code
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/CMakeLists.txt2
-rw-r--r--indra/llui/llbutton.cpp46
-rw-r--r--indra/llui/llbutton.h6
-rw-r--r--indra/llui/llflashtimer.cpp80
-rw-r--r--indra/llui/llflashtimer.h67
-rwxr-xr-xindra/llui/llfolderviewitem.cpp15
-rwxr-xr-xindra/llui/llfolderviewitem.h3
-rw-r--r--indra/llui/lltabcontainer.cpp4
8 files changed, 185 insertions, 38 deletions
diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt
index 80cec6c9f3..ccc7aa8cec 100644
--- a/indra/llui/CMakeLists.txt
+++ b/indra/llui/CMakeLists.txt
@@ -47,6 +47,7 @@ set(llui_SOURCE_FILES
lleditmenuhandler.cpp
llf32uictrl.cpp
llfiltereditor.cpp
+ llflashtimer.cpp
llflatlistview.cpp
llfloater.cpp
llfloaterreg.cpp
@@ -153,6 +154,7 @@ set(llui_HEADER_FILES
lleditmenuhandler.h
llf32uictrl.h
llfiltereditor.h
+ llflashtimer.h
llflatlistview.h
llfloater.h
llfloaterreg.h
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index 3b9076ee54..8a34e221b1 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -170,17 +170,18 @@ LLButton::LLButton(const LLButton::Params& p)
mMouseUpSignal(NULL),
mHeldDownSignal(NULL),
mUseDrawContextAlpha(p.use_draw_context_alpha),
- mHandleRightMouse(p.handle_right_mouse),
- mButtonFlashCount(p.button_flash_count),
- mButtonFlashRate(p.button_flash_rate)
+ mHandleRightMouse(p.handle_right_mouse)
{
+ // If optional parameter "p.button_flash_count" is not provided, LLFlashTimer will be
+ // used instead it a "default" value from gSavedSettings.getS32("FlashCount")).
+ // Likewise, missing "p.button_flash_rate" is replaced by gSavedSettings.getF32("FlashPeriod");
+ S32 flash_count = p.button_flash_count || 0;
+ F32 flash_rate = p.button_flash_rate || 0.0; //
+ mFlashingTimer = new LLFlashTimer ((LLFlashTimer::callback_t)NULL, flash_count, flash_rate);
+
static LLUICachedControl<S32> llbutton_orig_h_pad ("UIButtonOrigHPad", 0);
static Params default_params(LLUICtrlFactory::getDefaultParams<LLButton>());
-if (this->getName() == "chat")
-{
-bool q = false;
-q = !q;
-}
+
if (!p.label_selected.isProvided())
{
mSelectedLabel = mUnselectedLabel;
@@ -271,6 +272,7 @@ LLButton::~LLButton()
delete mMouseDownSignal;
delete mMouseUpSignal;
delete mHeldDownSignal;
+ delete mFlashingTimer;
}
// HACK: Committing a button is the same as instantly clicking it.
@@ -595,22 +597,11 @@ void LLButton::draw()
{
static LLCachedControl<bool> sEnableButtonFlashing(*LLUI::sSettingGroups["config"], "EnableButtonFlashing", true);
F32 alpha = mUseDrawContextAlpha ? getDrawContext().mAlpha : getCurrentTransparency();
- bool flash = FALSE;
- if( mFlashing)
- {
- if ( sEnableButtonFlashing)
- {
- F32 elapsed = mFlashingTimer.getElapsedTimeF32();
- S32 flash_count = S32(elapsed * mButtonFlashRate * 2.f);
- // flash on or off?
- flash = (flash_count % 2 == 0) || flash_count > S32((F32)mButtonFlashCount * 2.f);
- }
- else
- { // otherwise just highlight button in flash color
- flash = true;
- }
- }
+ mFlashing = mFlashingTimer->isFlashing();
+
+ bool flash = mFlashing &&
+ (!sEnableButtonFlashing || mFlashingTimer->isHighlight());
bool pressed_by_keyboard = FALSE;
if (hasFocus())
@@ -955,10 +946,13 @@ void LLButton::setToggleState(BOOL b)
void LLButton::setFlashing( BOOL b )
{
- if ((bool)b != mFlashing)
+ if (b)
+ {
+ mFlashingTimer->startFlashing();
+ }
+ else
{
- mFlashing = b;
- mFlashingTimer.reset();
+ mFlashingTimer->stopFlashing();
}
}
diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h
index deaa0823c6..92548298f5 100644
--- a/indra/llui/llbutton.h
+++ b/indra/llui/llbutton.h
@@ -30,6 +30,7 @@
#include "lluuid.h"
#include "llbadgeowner.h"
#include "llcontrol.h"
+#include "llflashtimer.h"
#include "lluictrl.h"
#include "v4color.h"
#include "llframetimer.h"
@@ -201,6 +202,7 @@ public:
void setHighlight(bool b);
void setFlashing( BOOL b );
BOOL getFlashing() const { return mFlashing; }
+ LLFlashTimer* getFlashTimer() {return mFlashingTimer;}
void setHAlign( LLFontGL::HAlign align ) { mHAlign = align; }
LLFontGL::HAlign getHAlign() const { return mHAlign; }
@@ -285,8 +287,6 @@ protected:
LLFrameTimer mMouseDownTimer;
bool mNeedsHighlight;
- S32 mButtonFlashCount;
- F32 mButtonFlashRate;
void drawBorder(LLUIImage* imagep, const LLColor4& color, S32 size);
void resetMouseDownTimer();
@@ -373,7 +373,7 @@ protected:
bool mForcePressedState;
bool mDisplayPressedState;
- LLFrameTimer mFlashingTimer;
+ LLFlashTimer* mFlashingTimer;
bool mHandleRightMouse;
};
diff --git a/indra/llui/llflashtimer.cpp b/indra/llui/llflashtimer.cpp
new file mode 100644
index 0000000000..c572a83ff5
--- /dev/null
+++ b/indra/llui/llflashtimer.cpp
@@ -0,0 +1,80 @@
+/**
+ * @file llflashtimer.cpp
+ * @brief LLFlashTimer class implementation
+ *
+ * $LicenseInfo:firstyear=2002&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2012, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+#include "../newview/llviewerprecompiledheaders.h"
+
+#include "llflashtimer.h"
+#include "../newview/llviewercontrol.h"
+#include "lleventtimer.h"
+
+LLFlashTimer::LLFlashTimer(callback_t cb, S32 count, F32 period)
+ : LLEventTimer(period)
+ , mCallback(cb)
+ , mCurrentTickCount(0)
+ , mIsFlashing(false)
+{
+ mEventTimer.stop();
+
+ // By default 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.
+ mFlashCount = 2 * ((count>0)? count : gSavedSettings.getS32("FlashCount"));
+ if (mPeriod<=0)
+ {
+ mPeriod = gSavedSettings.getF32("FlashPeriod");
+ }
+}
+
+BOOL LLFlashTimer::tick()
+{
+ mIsHighlight = !(mCurrentTickCount % 2);
+ if (mCallback)
+ {
+ mCallback(mIsHighlight);
+ }
+
+ if (++mCurrentTickCount >= mFlashCount)
+ {
+ mEventTimer.stop();
+ }
+
+ return FALSE;
+}
+
+void LLFlashTimer::startFlashing()
+{
+ mCurrentTickCount = 0;
+ mIsFlashing = true;
+ mEventTimer.start();
+}
+
+void LLFlashTimer::stopFlashing()
+{
+ mIsFlashing = false;
+ mIsHighlight = false;
+ mEventTimer.stop();
+}
+
+
diff --git a/indra/llui/llflashtimer.h b/indra/llui/llflashtimer.h
new file mode 100644
index 0000000000..2ef6ebcc8a
--- /dev/null
+++ b/indra/llui/llflashtimer.h
@@ -0,0 +1,67 @@
+/**
+ * @file llflashtimer.h
+ * @brief LLFlashTimer class implementation
+ *
+ * $LicenseInfo:firstyear=2002&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2012, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_FLASHTIMER_H
+#define LL_FLASHTIMER_H
+
+#include "lleventtimer.h"
+
+class LLFlashTimer : public LLEventTimer
+{
+public:
+
+ typedef boost::function<void (bool)> 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
+ */
+ LLFlashTimer(callback_t cb = NULL, S32 count = 0, F32 period = 0.0);
+ ~LLFlashTimer() {};
+
+ /*virtual*/ BOOL tick();
+
+ void startFlashing();
+ void stopFlashing();
+
+ bool isFlashing() {return mIsFlashing;}
+ bool isHighlight() {return mIsHighlight;}
+
+private:
+ callback_t mCallback;
+ /**
+ * How many times parent will blink.
+ */
+ S32 mFlashCount;
+ S32 mCurrentTickCount;
+ bool mIsHighlight;
+ bool mIsFlashing;
+};
+
+#endif /* LL_FLASHTIMER_H */
diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp
index 90568f344a..d65f53cd4d 100755
--- a/indra/llui/llfolderviewitem.cpp
+++ b/indra/llui/llfolderviewitem.cpp
@@ -23,8 +23,9 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
+#include "../newview/llviewerprecompiledheaders.h"
-#include "../newview/llflashtimer.h"
+#include "llflashtimer.h"
#include "linden_common.h"
#include "llfolderviewitem.h"
@@ -164,17 +165,19 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p)
}
}
+// Destroys the object
+LLFolderViewItem::~LLFolderViewItem()
+{
+ delete mFlashTimer;
+ mViewModelItem = NULL;
+}
+
BOOL LLFolderViewItem::postBuild()
{
refresh();
return TRUE;
}
-// Destroys the object
-LLFolderViewItem::~LLFolderViewItem( void )
-{
- mViewModelItem = NULL;
-}
LLFolderView* LLFolderViewItem::getRoot()
{
diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h
index c16d65206f..c8d6c37b04 100755
--- a/indra/llui/llfolderviewitem.h
+++ b/indra/llui/llfolderviewitem.h
@@ -26,10 +26,10 @@
#ifndef LLFOLDERVIEWITEM_H
#define LLFOLDERVIEWITEM_H
+#include "llflashtimer.h"
#include "llview.h"
#include "lluiimage.h"
-class LLFlashTimer;
class LLFolderView;
class LLFolderViewModelItem;
class LLFolderViewFolder;
@@ -163,6 +163,7 @@ public:
S32 getIconPad();
S32 getTextPad();
+ LLFlashTimer* getFlashTimer() {return mFlashTimer;}
// If 'selection' is 'this' then note that otherwise ignore.
// Returns TRUE if this item ends up being selected.
virtual BOOL setSelection(LLFolderViewItem* selection, BOOL openitem, BOOL take_keyboard_focus);
diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp
index c24eb2ee90..d1f77830a6 100644
--- a/indra/llui/lltabcontainer.cpp
+++ b/indra/llui/lltabcontainer.cpp
@@ -506,8 +506,8 @@ void LLTabContainer::draw()
}
}
- mPrevArrowBtn->setFlashing(FALSE);
- mNextArrowBtn->setFlashing(FALSE);
+ mPrevArrowBtn->getFlashTimer()->stopFlashing();
+ mNextArrowBtn->getFlashTimer()->stopFlashing();
}