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.cpp229
1 files changed, 190 insertions, 39 deletions
diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp
index eba43d76a6..60a89c02e4 100644
--- a/indra/newview/lltoast.cpp
+++ b/indra/newview/lltoast.cpp
@@ -36,6 +36,7 @@
#include "llbutton.h"
#include "llfocusmgr.h"
+#include "llnotifications.h"
#include "llviewercontrol.h"
using namespace LLNotificationsUI;
@@ -49,13 +50,15 @@ LLToast::Params::Params()
enable_hide_btn("enable_hide_btn", true),
force_show("force_show", false),
force_store("force_store", false),
+ fading_time_secs("fading_time_secs", gSavedSettings.getS32("ToastFadingTime")),
lifetime_secs("lifetime_secs", gSavedSettings.getS32("NotificationToastLifeTime"))
{};
LLToast::LLToast(const LLToast::Params& p)
: LLModalDialog(LLSD(), p.is_modal),
mPanel(p.panel),
- mToastLifetime(p.lifetime_secs),
+ mToastLifetime(p.lifetime_secs),
+ mToastFadingTime(p.fading_time_secs),
mNotificationID(p.notif_id),
mSessionID(p.session_id),
mCanFade(p.can_fade),
@@ -63,10 +66,19 @@ LLToast::LLToast(const LLToast::Params& p)
mHideBtnEnabled(p.enable_hide_btn),
mHideBtn(NULL),
mNotification(p.notification),
- mHideBtnPressed(false)
+ mIsHidden(false),
+ mHideBtnPressed(false),
+ mIsTip(p.is_tip),
+ mWrapperPanel(NULL)
{
LLUICtrlFactory::getInstance()->buildFloater(this, "panel_toast.xml", NULL);
+ setCanDrag(FALSE);
+
+ mWrapperPanel = getChild<LLPanel>("wrapper_panel");
+ mWrapperPanel->setMouseEnterCallback(boost::bind(&LLToast::onToastMouseEnter, this));
+ mWrapperPanel->setMouseLeaveCallback(boost::bind(&LLToast::onToastMouseLeave, this));
+
if(mPanel)
{
insertPanel(mPanel);
@@ -76,6 +88,8 @@ LLToast::LLToast(const LLToast::Params& p)
{
mHideBtn = getChild<LLButton>("hide_btn");
mHideBtn->setClickedCallback(boost::bind(&LLToast::hide,this));
+ mHideBtn->setMouseEnterCallback(boost::bind(&LLToast::onToastMouseEnter, this));
+ mHideBtn->setMouseLeaveCallback(boost::bind(&LLToast::onToastMouseLeave, this));
}
// init callbacks if present
@@ -94,10 +108,30 @@ BOOL LLToast::postBuild()
mTimer.stop();
}
+ if (mIsTip)
+ {
+ mTextEditor = mPanel->getChild<LLTextEditor>("text_editor_box");
+
+ if (mTextEditor)
+ {
+ mTextEditor->setMouseUpCallback(boost::bind(&LLToast::hide,this));
+ mPanel->setMouseUpCallback(boost::bind(&LLToast::handleTipToastClick, this, _2, _3, _4));
+ }
+ }
+
return TRUE;
}
//--------------------------------------------------------------------------
+void LLToast::handleTipToastClick(S32 x, S32 y, MASK mask)
+{
+ if (!mTextEditor->getRect().pointInRect(x, y))
+ {
+ hide();
+ }
+}
+
+//--------------------------------------------------------------------------
void LLToast::setHideButtonEnabled(bool enabled)
{
if(mHideBtn)
@@ -126,7 +160,7 @@ bool LLToast::lifetimeHasExpired()
if (mTimer.getStarted())
{
F32 elapsed_time = mTimer.getElapsedTimeF32();
- if ((mToastLifetime - elapsed_time) <= gSavedSettings.getS32("ToastOpaqueTime"))
+ if ((mToastLifetime - elapsed_time) <= mToastFadingTime)
{
setBackgroundOpaque(FALSE);
}
@@ -143,7 +177,44 @@ void LLToast::hide()
{
setVisible(FALSE);
mTimer.stop();
- mOnFadeSignal(this);
+ mIsHidden = true;
+ mOnFadeSignal(this);
+}
+
+void LLToast::onFocusLost()
+{
+ if(mWrapperPanel && !isBackgroundVisible())
+ {
+ // Lets make wrapper panel behave like a floater
+ setBackgroundOpaque(FALSE);
+ }
+}
+
+void LLToast::onFocusReceived()
+{
+ if(mWrapperPanel && !isBackgroundVisible())
+ {
+ // Lets make wrapper panel behave like a floater
+ setBackgroundOpaque(TRUE);
+ }
+}
+
+S32 LLToast::getTopPad()
+{
+ if(mWrapperPanel)
+ {
+ return getRect().getHeight() - mWrapperPanel->getRect().getHeight();
+ }
+ return 0;
+}
+
+S32 LLToast::getRightPad()
+{
+ if(mWrapperPanel)
+ {
+ return getRect().getWidth() - mWrapperPanel->getRect().getWidth();
+ }
+ return 0;
}
//--------------------------------------------------------------------------
@@ -159,9 +230,7 @@ void LLToast::tick()
{
if(mCanFade)
{
- setVisible(FALSE);
- mTimer.stop();
- mOnFadeSignal(this);
+ hide();
}
}
@@ -173,22 +242,21 @@ void LLToast::reshapeToPanel()
if(!panel)
return;
- LLRect panel_rect;
+ LLRect panel_rect = panel->getRect();
- panel_rect = panel->getRect();
- reshape(panel_rect.getWidth(), panel_rect.getHeight());
panel_rect.setLeftTopAndSize(0, panel_rect.getHeight(), panel_rect.getWidth(), panel_rect.getHeight());
- panel->setRect(panel_rect);
+ panel->setShape(panel_rect);
LLRect toast_rect = getRect();
- toast_rect.setLeftTopAndSize(toast_rect.mLeft,toast_rect.mTop,panel_rect.getWidth(), panel_rect.getHeight());
- setRect(toast_rect);
+ toast_rect.setLeftTopAndSize(toast_rect.mLeft, toast_rect.mTop,
+ panel_rect.getWidth() + getRightPad(), panel_rect.getHeight() + getTopPad());
+ setShape(toast_rect);
}
void LLToast::insertPanel(LLPanel* panel)
{
- addChild(panel);
+ mWrapperPanel->addChild(panel);
reshapeToPanel();
}
@@ -201,20 +269,44 @@ void LLToast::draw()
}
LLFloater::draw();
+
+ if(!isBackgroundVisible())
+ {
+ // Floater background is invisible, lets make wrapper panel look like a
+ // floater - draw shadow.
+ drawShadow(mWrapperPanel);
+
+ // Shadow will probably overlap close button, lets redraw the button
+ if(mHideBtn)
+ {
+ drawChild(mHideBtn);
+ }
+ }
}
//--------------------------------------------------------------------------
void LLToast::setVisible(BOOL show)
{
+ if(mIsHidden)
+ {
+ // this toast is invisible after fade until its ScreenChannel will allow it
+ //
+ // (EXT-1849) according to this bug a toast can be resurrected from
+ // invisible state if it faded during a teleportation
+ // then it fades a second time and causes a crash
+ return;
+ }
+
if(show)
{
setBackgroundOpaque(TRUE);
- if(!mTimer.getStarted())
+ if(!mTimer.getStarted() && mCanFade)
{
mTimer.start();
}
+ LLModalDialog::setFrontmost(FALSE);
}
- LLPanel::setVisible(show);
+ LLFloater::setVisible(show);
if(mPanel)
{
if(!mPanel->isDead())
@@ -224,41 +316,100 @@ void LLToast::setVisible(BOOL show)
}
}
-//--------------------------------------------------------------------------
-void LLToast::onMouseEnter(S32 x, S32 y, MASK mask)
+void LLToast::onToastMouseEnter()
{
- mOnToastHoverSignal(this, MOUSE_ENTER);
+ LLRect panel_rc = mWrapperPanel->calcScreenRect();
+ LLRect button_rc;
+ if(mHideBtn)
+ {
+ button_rc = mHideBtn->calcScreenRect();
+ }
- setBackgroundOpaque(TRUE);
- if(mCanFade)
+ S32 x, y;
+ LLUI::getMousePositionScreen(&x, &y);
+
+ if(panel_rc.pointInRect(x, y) || button_rc.pointInRect(x, y))
{
- mTimer.stop();
+ mOnToastHoverSignal(this, MOUSE_ENTER);
+
+ setBackgroundOpaque(TRUE);
+
+ //toasts fading is management by Screen Channel
+
+ sendChildToFront(mHideBtn);
+ if(mHideBtn && mHideBtn->getEnabled())
+ {
+ mHideBtn->setVisible(TRUE);
+ }
+ mOnMouseEnterSignal(this);
+ mToastMouseEnterSignal(this, getValue());
}
-
- sendChildToFront(mHideBtn);
- if(mHideBtn && mHideBtn->getEnabled())
- mHideBtn->setVisible(TRUE);
- mOnMouseEnterSignal(this);
}
-//--------------------------------------------------------------------------
-void LLToast::onMouseLeave(S32 x, S32 y, MASK mask)
-{
- mOnToastHoverSignal(this, MOUSE_LEAVE);
-
- if(mCanFade)
+void LLToast::onToastMouseLeave()
+{
+ LLRect panel_rc = mWrapperPanel->calcScreenRect();
+ LLRect button_rc;
+ if(mHideBtn)
{
- mTimer.start();
+ button_rc = mHideBtn->calcScreenRect();
}
- if(mHideBtn && mHideBtn->getEnabled())
+
+ S32 x, y;
+ LLUI::getMousePositionScreen(&x, &y);
+
+ if( !panel_rc.pointInRect(x, y) && !button_rc.pointInRect(x, y))
{
- if( mHideBtnPressed )
+ mOnToastHoverSignal(this, MOUSE_LEAVE);
+
+ //toasts fading is management by Screen Channel
+
+ if(mHideBtn && mHideBtn->getEnabled())
{
- mHideBtnPressed = false;
- return;
+ if( mHideBtnPressed )
+ {
+ mHideBtnPressed = false;
+ return;
+ }
+ mHideBtn->setVisible(FALSE);
}
- mHideBtn->setVisible(FALSE);
+ mToastMouseLeaveSignal(this, getValue());
+ }
+}
+
+void LLToast::setBackgroundOpaque(BOOL b)
+{
+ if(mWrapperPanel && !isBackgroundVisible())
+ {
+ mWrapperPanel->setBackgroundOpaque(b);
}
+ else
+ {
+ LLModalDialog::setBackgroundOpaque(b);
+ }
+}
+
+void LLNotificationsUI::LLToast::stopFading()
+{
+ if(mCanFade)
+ {
+ stopTimer();
+ }
+}
+
+void LLNotificationsUI::LLToast::startFading()
+{
+ if(mCanFade)
+ {
+ resetTimer();
+ }
+}
+
+bool LLToast::isHovered()
+{
+ S32 x, y;
+ LLUI::getMousePositionScreen(&x, &y);
+ return mWrapperPanel->calcScreenRect().pointInRect(x, y);
}
//--------------------------------------------------------------------------