summaryrefslogtreecommitdiff
path: root/indra/newview/lltoast.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lltoast.cpp')
-rw-r--r--indra/newview/lltoast.cpp110
1 files changed, 97 insertions, 13 deletions
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();
}
}