diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2010-02-17 18:18:19 -0500 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2010-02-17 18:18:19 -0500 |
commit | 000106dd3faaae47af0e0b2d74145a260d540fa8 (patch) | |
tree | 164bc73bb01048e580ca1154c137abb1811cfdff /indra/newview/lltoast.cpp | |
parent | 2aacee62ad2c001b8c860f8bedc84e2b7f634fef (diff) | |
parent | 50e696872ecebd37e8a43df3031e4cdaf26147a9 (diff) |
merge
Diffstat (limited to 'indra/newview/lltoast.cpp')
-rw-r--r-- | indra/newview/lltoast.cpp | 159 |
1 files changed, 128 insertions, 31 deletions
diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp index 110d158e2d..60a89c02e4 100644 --- a/indra/newview/lltoast.cpp +++ b/indra/newview/lltoast.cpp @@ -68,12 +68,17 @@ LLToast::LLToast(const LLToast::Params& p) mNotification(p.notification), mIsHidden(false), mHideBtnPressed(false), - mIsTip(p.is_tip) + 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); @@ -83,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 @@ -174,6 +181,42 @@ void LLToast::hide() 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; +} + //-------------------------------------------------------------------------- void LLToast::setCanFade(bool can_fade) { @@ -199,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(); } @@ -227,6 +269,19 @@ 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); + } + } } //-------------------------------------------------------------------------- @@ -261,43 +316,78 @@ 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); + S32 x, y; + LLUI::getMousePositionScreen(&x, &y); - //toasts fading is management by Screen Channel - - sendChildToFront(mHideBtn); - if(mHideBtn && mHideBtn->getEnabled()) - mHideBtn->setVisible(TRUE); - mOnMouseEnterSignal(this); + if(panel_rc.pointInRect(x, y) || button_rc.pointInRect(x, y)) + { + mOnToastHoverSignal(this, MOUSE_ENTER); + + setBackgroundOpaque(TRUE); + + //toasts fading is management by Screen Channel - LLModalDialog::onMouseEnter(x, y, mask); + sendChildToFront(mHideBtn); + if(mHideBtn && mHideBtn->getEnabled()) + { + mHideBtn->setVisible(TRUE); + } + mOnMouseEnterSignal(this); + mToastMouseEnterSignal(this, getValue()); + } } -//-------------------------------------------------------------------------- -void LLToast::onMouseLeave(S32 x, S32 y, MASK mask) -{ - mOnToastHoverSignal(this, MOUSE_LEAVE); +void LLToast::onToastMouseLeave() +{ + LLRect panel_rc = mWrapperPanel->calcScreenRect(); + LLRect button_rc; + if(mHideBtn) + { + button_rc = mHideBtn->calcScreenRect(); + } - //toasts fading is management by Screen Channel + S32 x, y; + LLUI::getMousePositionScreen(&x, &y); - if(mHideBtn && mHideBtn->getEnabled()) + 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()); } - - LLModalDialog::onMouseLeave(x, y, mask); } +void LLToast::setBackgroundOpaque(BOOL b) +{ + if(mWrapperPanel && !isBackgroundVisible()) + { + mWrapperPanel->setBackgroundOpaque(b); + } + else + { + LLModalDialog::setBackgroundOpaque(b); + } +} void LLNotificationsUI::LLToast::stopFading() { @@ -315,6 +405,13 @@ void LLNotificationsUI::LLToast::startFading() } } +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) |