summaryrefslogtreecommitdiff
path: root/indra/newview/lltoast.cpp
diff options
context:
space:
mode:
authorDebi King (Dessie) <dessie@lindenlab.com>2012-01-05 14:37:06 -0500
committerDebi King (Dessie) <dessie@lindenlab.com>2012-01-05 14:37:06 -0500
commitbf8e1137012c1e26d570545db1feda77c60aa6ba (patch)
treef2a0da29601da94b496c545436c1ef310bc4bed5 /indra/newview/lltoast.cpp
parentd8aa31d10a89aa826cc549594c083a054a2ad967 (diff)
parent7026c80d51128854458f585e50b3b9e3ecab555a (diff)
merge
Diffstat (limited to 'indra/newview/lltoast.cpp')
-rw-r--r--indra/newview/lltoast.cpp137
1 files changed, 86 insertions, 51 deletions
diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp
index e0b07ed408..da691a2d0c 100644
--- a/indra/newview/lltoast.cpp
+++ b/indra/newview/lltoast.cpp
@@ -113,7 +113,8 @@ LLToast::LLToast(const LLToast::Params& p)
mHideBtnPressed(false),
mIsTip(p.is_tip),
mWrapperPanel(NULL),
- mIsFading(false)
+ mIsFading(false),
+ mIsHovered(false)
{
mTimer.reset(new LLToastLifeTimer(this, p.lifetime_secs));
@@ -122,8 +123,6 @@ LLToast::LLToast(const LLToast::Params& p)
setCanDrag(FALSE);
mWrapperPanel = getChild<LLPanel>("wrapper_panel");
- mWrapperPanel->setMouseEnterCallback(boost::bind(&LLToast::onToastMouseEnter, this));
- mWrapperPanel->setMouseLeaveCallback(boost::bind(&LLToast::onToastMouseLeave, this));
setBackgroundOpaque(TRUE); // *TODO: obsolete
updateTransparency();
@@ -137,13 +136,13 @@ 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
if(!p.on_delete_toast().empty())
+ {
mOnDeleteToastSignal.connect(p.on_delete_toast());
+ }
}
void LLToast::reshape(S32 width, S32 height, BOOL called_from_parent)
@@ -239,7 +238,9 @@ void LLToast::setCanFade(bool can_fade)
{
mCanFade = can_fade;
if(!mCanFade)
+ {
mTimer->stop();
+ }
}
//--------------------------------------------------------------------------
@@ -378,8 +379,11 @@ void LLToast::setVisible(BOOL show)
}
}
-void LLToast::onToastMouseEnter()
+void LLToast::updateHoveredState()
{
+ S32 x, y;
+ LLUI::getMousePositionScreen(&x, &y);
+
LLRect panel_rc = mWrapperPanel->calcScreenRect();
LLRect button_rc;
if(mHideBtn)
@@ -387,56 +391,83 @@ void LLToast::onToastMouseEnter()
button_rc = mHideBtn->calcScreenRect();
}
- S32 x, y;
- LLUI::getMousePositionScreen(&x, &y);
-
- if(panel_rc.pointInRect(x, y) || button_rc.pointInRect(x, y))
+ if (!panel_rc.pointInRect(x, y) && !button_rc.pointInRect(x, y))
{
- mOnToastHoverSignal(this, MOUSE_ENTER);
-
- updateTransparency();
+ // mouse is not over this toast
+ mIsHovered = false;
+ }
+ else
+ {
+ bool is_overlapped_by_other_floater = false;
- //toasts fading is management by Screen Channel
+ const child_list_t* child_list = gFloaterView->getChildList();
- sendChildToFront(mHideBtn);
- if(mHideBtn && mHideBtn->getEnabled())
+ // find this toast in gFloaterView child list to check whether any floater
+ // with higher Z-order is visible under the mouse pointer overlapping this toast
+ child_list_const_reverse_iter_t r_iter = std::find(child_list->rbegin(), child_list->rend(), this);
+ if (r_iter != child_list->rend())
{
- mHideBtn->setVisible(TRUE);
+ // skip this toast and proceed to views above in Z-order
+ for (++r_iter; r_iter != child_list->rend(); ++r_iter)
+ {
+ LLView* view = *r_iter;
+ is_overlapped_by_other_floater = view->isInVisibleChain() && view->calcScreenRect().pointInRect(x, y);
+ if (is_overlapped_by_other_floater)
+ {
+ break;
+ }
+ }
}
- mToastMouseEnterSignal(this, getValue());
- }
-}
-void LLToast::onToastMouseLeave()
-{
- LLRect panel_rc = mWrapperPanel->calcScreenRect();
- LLRect button_rc;
- if(mHideBtn)
- {
- button_rc = mHideBtn->calcScreenRect();
+ mIsHovered = !is_overlapped_by_other_floater;
}
- S32 x, y;
- LLUI::getMousePositionScreen(&x, &y);
-
- if( !panel_rc.pointInRect(x, y) && !button_rc.pointInRect(x, y))
- {
- mOnToastHoverSignal(this, MOUSE_LEAVE);
-
- updateTransparency();
-
- //toasts fading is management by Screen Channel
-
- if(mHideBtn && mHideBtn->getEnabled())
+ LLToastLifeTimer* timer = getTimer();
+
+ if (timer)
+ {
+ // Started timer means the mouse had left the toast previously.
+ // If toast is hovered in the current frame we should handle
+ // a mouse enter event.
+ if(timer->getStarted() && mIsHovered)
+ {
+ mOnToastHoverSignal(this, MOUSE_ENTER);
+
+ updateTransparency();
+
+ //toasts fading is management by Screen Channel
+
+ sendChildToFront(mHideBtn);
+ if(mHideBtn && mHideBtn->getEnabled())
+ {
+ mHideBtn->setVisible(TRUE);
+ }
+
+ mToastMouseEnterSignal(this, getValue());
+ }
+ // Stopped timer means the mouse had entered the toast previously.
+ // If the toast is not hovered in the current frame we should handle
+ // a mouse leave event.
+ else if(!timer->getStarted() && !mIsHovered)
{
- if( mHideBtnPressed )
+ mOnToastHoverSignal(this, MOUSE_LEAVE);
+
+ updateTransparency();
+
+ //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());
}
- mToastMouseLeaveSignal(this, getValue());
}
}
@@ -495,13 +526,6 @@ void LLNotificationsUI::LLToast::startTimer()
}
}
-bool LLToast::isHovered()
-{
- S32 x, y;
- LLUI::getMousePositionScreen(&x, &y);
- return mWrapperPanel->calcScreenRect().pointInRect(x, y);
-}
-
//--------------------------------------------------------------------------
BOOL LLToast::handleMouseDown(S32 x, S32 y, MASK mask)
@@ -536,3 +560,14 @@ S32 LLToast::notifyParent(const LLSD& info)
return LLModalDialog::notifyParent(info);
}
+
+//static
+void LLToast::updateClass()
+{
+ for (LLInstanceTracker<LLToast>::instance_iter iter = LLInstanceTracker<LLToast>::beginInstances(); iter != LLInstanceTracker<LLToast>::endInstances(); )
+ {
+ LLToast& toast = *iter++;
+
+ toast.updateHoveredState();
+ }
+}