diff options
Diffstat (limited to 'indra/newview/lltoast.h')
-rw-r--r-- | indra/newview/lltoast.h | 101 |
1 files changed, 80 insertions, 21 deletions
diff --git a/indra/newview/lltoast.h b/indra/newview/lltoast.h index f998754585..a4dee1e386 100644 --- a/indra/newview/lltoast.h +++ b/indra/newview/lltoast.h @@ -37,7 +37,9 @@ #include "llpanel.h" #include "llfloater.h" #include "lltimer.h" -#include "lldate.h" +#include "llnotifications.h" + +#include "llviewercontrol.h" #define MOUSE_LEAVE false #define MOUSE_ENTER true @@ -52,53 +54,108 @@ namespace LLNotificationsUI class LLToast : public LLFloater { public: - LLToast(LLPanel* panel); + typedef boost::function<void (LLToast* toast)> toast_callback_t; + typedef boost::signals2::signal<void (LLToast* toast)> toast_signal_t; + + struct Params : public LLInitParam::Block<Params, LLFloater::Params> + { + LLPanel* panel; + LLUUID id; //notification or message ID + LLNotificationPtr notification; + F32 timer_period; + toast_callback_t on_toast_destroy; + toast_callback_t on_mouse_enter; + bool can_fade; + bool can_be_stored; + bool enable_hide_btn; + bool is_modal; + bool is_tip; + + Params() : can_fade(true), + can_be_stored(true), + is_modal(false), + is_tip(false), + enable_hide_btn(true), + panel(NULL), + timer_period(gSavedSettings.getS32("NotificationToastTime")) + + {}; + }; + + LLToast(LLToast::Params p); virtual ~LLToast(); + BOOL postBuild(); + // Toast handlers virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); - // - bool isViewed() { return mIsViewed; } - - void setCanFade(bool can_fade); + virtual void onMouseEnter(S32 x, S32 y, MASK mask); + virtual void onMouseLeave(S32 x, S32 y, MASK mask); + // Operating with toasts + // insert a panel to a toast + void insertPanel(LLPanel* panel); + // get toast's panel + LLPanel* getPanel() { return mPanel; } + // discard notification + void discardNotification(); + // enable/disable Toast's Hide button void setHideButtonEnabled(bool enabled); - - void setCanBeStored(bool can_be_stored) { mCanBeStored = can_be_stored; } - bool getCanBeStored() { return mCanBeStored; } - // + // initialize and start Toast's timer void setAndStartTimer(F32 period); - // + // void resetTimer() { mTimer.start(); } + // void stopTimer() { mTimer.stop(); } + // void close() { die(); } + // virtual void draw(); + // virtual void setVisible(BOOL show); - virtual void onMouseEnter(S32 x, S32 y, MASK mask); - virtual void onMouseLeave(S32 x, S32 y, MASK mask); + // virtual void hide(); - LLPanel* getPanel() { return mPanel; } - void arrange(LLPanel* panel); + + + + // get/set Toast's flags or states + // get information whether the notification corresponding to the toast is responded or not + bool getIsNotificationUnResponded(); + // + bool isViewed() { return mIsViewed; } + // + void setCanFade(bool can_fade); + // + void setCanBeStored(bool can_be_stored) { mCanBeStored = can_be_stored; } + // + bool getCanBeStored() { return mCanBeStored; } + // void setModal(bool modal); // Registers callbacks for events - boost::signals2::connection setOnFadeCallback(commit_callback_t cb) { return mOnFade.connect(cb); } - boost::signals2::connection setOnMouseEnterCallback(commit_callback_t cb) { return mOnMousEnter.connect(cb); } - boost::signals2::connection setOnToastDestroyCallback(commit_callback_t cb) { return mOnToastDestroy.connect(cb); } + toast_signal_t mOnFade; + toast_signal_t mOnMousEnter; + toast_signal_t mOnToastDestroy; + boost::signals2::connection setOnFadeCallback(toast_callback_t cb) { return mOnFade.connect(cb); } + boost::signals2::connection setOnMouseEnterCallback(toast_callback_t cb) { return mOnMousEnter.connect(cb); } + boost::signals2::connection setOnToastDestroyCallback(toast_callback_t cb) { return mOnToastDestroy.connect(cb); } + typedef boost::function<void (LLToast* toast, bool mouse_enter)> toast_hover_check_callback_t; typedef boost::signals2::signal<void (LLToast* toast, bool mouse_enter)> toast_hover_check_signal_t; toast_hover_check_signal_t mOnToastHover; boost::signals2::connection setOnToastHoverCallback(toast_hover_check_callback_t cb) { return mOnToastHover.connect(cb); } - commit_signal_t mOnFade; - commit_signal_t mOnMousEnter; - commit_signal_t mOnToastDestroy; private: + // check timer bool timerHasExpired(); + // on timer finished function void tick(); + LLUUID mID; + LLNotificationPtr mNotification; + LLTimer mTimer; F32 mTimerValue; @@ -107,9 +164,11 @@ private: LLColor4 mBgColor; bool mIsViewed; + bool mIsTipNotification; bool mCanFade; bool mIsModal; bool mCanBeStored; + bool mHideBtnEnabled; bool mHideBtnPressed; }; |