summaryrefslogtreecommitdiff
path: root/indra/newview/lltoast.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lltoast.h')
-rw-r--r--indra/newview/lltoast.h69
1 files changed, 55 insertions, 14 deletions
diff --git a/indra/newview/lltoast.h b/indra/newview/lltoast.h
index 3d25fd4f02..4211f21ef1 100644
--- a/indra/newview/lltoast.h
+++ b/indra/newview/lltoast.h
@@ -36,7 +36,7 @@
#include "llpanel.h"
#include "llmodaldialog.h"
-#include "lltimer.h"
+#include "lleventtimer.h"
#include "llnotificationptr.h"
#include "llviewercontrol.h"
@@ -48,12 +48,34 @@
namespace LLNotificationsUI
{
+class LLToast;
+/**
+ * Timer for toasts.
+ */
+class LLToastLifeTimer: public LLEventTimer
+{
+public:
+ LLToastLifeTimer(LLToast* toast, F32 period) : mToast(toast), LLEventTimer(period){}
+
+ /*virtual*/
+ BOOL tick();
+ void stop() { mEventTimer.stop(); }
+ void start() { mEventTimer.start(); }
+ void restart() {mEventTimer.reset(); }
+ BOOL getStarted() { return mEventTimer.getStarted(); }
+
+ LLTimer& getEventTimer() { return mEventTimer;}
+private :
+ LLToast* mToast;
+};
+
/**
* Represents toast pop-up.
* This is a parent view for all toast panels.
*/
class LLToast : public LLModalDialog
{
+ friend class LLToastLifeTimer;
public:
typedef boost::function<void (LLToast* toast)> toast_callback_t;
typedef boost::signals2::signal<void (LLToast* toast)> toast_signal_t;
@@ -86,8 +108,6 @@ public:
// Toast handlers
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
- virtual void onMouseEnter(S32 x, S32 y, MASK mask);
- virtual void onMouseLeave(S32 x, S32 y, MASK mask);
//Fading
@@ -97,6 +117,7 @@ public:
/** Start fading timer */
virtual void startFading();
+ bool isHovered();
// Operating with toasts
// insert a panel to a toast
@@ -108,20 +129,32 @@ public:
LLPanel* getPanel() { return mPanel; }
// enable/disable Toast's Hide button
void setHideButtonEnabled(bool enabled);
- // initialize and start Toast's timer
- void setAndStartTimer(F32 period);
//
- void resetTimer() { mTimer.start(); }
+ void resetTimer() { mTimer->start(); }
//
- void stopTimer() { mTimer.stop(); }
+ void stopTimer() { mTimer->stop(); }
+ //
+ LLToastLifeTimer* getTimer() { return mTimer.get();}
//
virtual void draw();
//
virtual void setVisible(BOOL show);
+
+ /*virtual*/ void setBackgroundOpaque(BOOL b);
//
virtual void hide();
+ /*virtual*/ void onFocusLost();
+ /*virtual*/ void onFocusReceived();
+
+ /**
+ * Returns padding between floater top and wrapper_panel top.
+ * This padding should be taken into account when positioning or reshaping toasts
+ */
+ S32 getTopPad();
+
+ S32 getRightPad();
// get/set Toast's flags or states
// get information whether the notification corresponding to the toast is valid or not
@@ -154,28 +187,33 @@ public:
toast_hover_check_signal_t mOnToastHoverSignal;
boost::signals2::connection setOnToastHoverCallback(toast_hover_check_callback_t cb) { return mOnToastHoverSignal.connect(cb); }
+ boost::signals2::connection setMouseEnterCallback( const commit_signal_t::slot_type& cb ) { return mToastMouseEnterSignal.connect(cb); };
+ boost::signals2::connection setMouseLeaveCallback( const commit_signal_t::slot_type& cb ) { return mToastMouseLeaveSignal.connect(cb); };
+
+ virtual S32 notifyParent(const LLSD& info);
private:
- void handleTipToastClick(S32 x, S32 y, MASK mask);
+ void onToastMouseEnter();
+
+ void onToastMouseLeave();
- // check timer
- bool lifetimeHasExpired();
- // on timer finished function
- void tick();
+ void expire();
LLUUID mNotificationID;
LLUUID mSessionID;
LLNotificationPtr mNotification;
+ LLPanel* mWrapperPanel;
+
// timer counts a lifetime of a toast
- LLTimer mTimer;
+ std::auto_ptr<LLToastLifeTimer> mTimer;
+
F32 mToastLifetime; // in seconds
F32 mToastFadingTime; // in seconds
LLPanel* mPanel;
LLButton* mHideBtn;
- LLTextEditor* mTextEditor;
LLColor4 mBgColor;
bool mCanFade;
@@ -184,6 +222,9 @@ private:
bool mHideBtnPressed;
bool mIsHidden; // this flag is TRUE when a toast has faded or was hidden with (x) button (EXT-1849)
bool mIsTip;
+
+ commit_signal_t mToastMouseEnterSignal;
+ commit_signal_t mToastMouseLeaveSignal;
};
}