diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llnearbychathandler.cpp | 59 | ||||
-rw-r--r-- | indra/newview/lltoast.cpp | 6 | ||||
-rw-r--r-- | indra/newview/lltoast.h | 4 |
3 files changed, 46 insertions, 23 deletions
diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index e199f9f180..9824517ed1 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -56,7 +56,6 @@ LLToastPanelBase* createToastPanel() return item; } - class LLNearbyChatScreenChannel: public LLScreenChannelBase { public: @@ -88,11 +87,7 @@ public: { for(std::vector<LLToast*>::iterator it = m_active_toasts.begin(); it != m_active_toasts.end(); ++it) { - LLToast* toast = (*it); - toast->setVisible(FALSE); - toast->stopTimer(); - m_toast_pool.push_back(toast); - + addToToastPool((*it)); } m_active_toasts.clear(); }; @@ -105,6 +100,14 @@ public: } protected: + void addToToastPool(LLToast* toast) + { + toast->setVisible(FALSE); + toast->stopTimer(); + toast->setIsHidden(true); + m_toast_pool.push_back(toast); + } + void createOverflowToast(S32 bottom, F32 timer); create_toast_panel_callback_t m_create_toast_panel_callback_t; @@ -132,11 +135,12 @@ void LLNearbyChatScreenChannel::onToastFade(LLToast* toast) //fade mean we put toast to toast pool if(!toast) return; - m_toast_pool.push_back(toast); std::vector<LLToast*>::iterator pos = std::find(m_active_toasts.begin(),m_active_toasts.end(),toast); if(pos!=m_active_toasts.end()) m_active_toasts.erase(pos); + + addToToastPool(toast); arrangeToasts(); } @@ -228,7 +232,7 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification) toast->reshapeToPanel(); toast->resetTimer(); - m_active_toasts.insert(m_active_toasts.begin(),toast); + m_active_toasts.push_back(toast); arrangeToasts(); } @@ -240,7 +244,14 @@ void LLNearbyChatScreenChannel::arrangeToasts() hideToastsFromScreen(); - showToastsBottom(); + showToastsBottom(); +} + +int sort_toasts_predicate(LLToast* first,LLToast* second) +{ + F32 v1 = first->getTimer()->getEventTimer().getElapsedTimeF32(); + F32 v2 = second->getTimer()->getEventTimer().getElapsedTimeF32(); + return v1 < v2; } void LLNearbyChatScreenChannel::showToastsBottom() @@ -252,39 +263,41 @@ void LLNearbyChatScreenChannel::showToastsBottom() S32 bottom = getRect().mBottom; S32 margin = gSavedSettings.getS32("ToastGap"); + //sort active toasts + std::sort(m_active_toasts.begin(),m_active_toasts.end(),sort_toasts_predicate); + + //calc max visible item and hide other toasts. + for(std::vector<LLToast*>::iterator it = m_active_toasts.begin(); it != m_active_toasts.end(); ++it) { - LLToast* toast = (*it); - S32 toast_top = bottom + toast->getRect().getHeight() + margin; + S32 toast_top = bottom + (*it)->getRect().getHeight() + margin; if(toast_top > gFloaterView->getRect().getHeight()) { while(it!=m_active_toasts.end()) { - toast->setVisible(FALSE); - toast->stopTimer(); - m_toast_pool.push_back(toast); + addToToastPool((*it)); it=m_active_toasts.erase(it); } break; } - bottom = toast_top - toast->getTopPad(); - } - - // use reverse order to provide correct z-order and avoid toast blinking - for(std::vector<LLToast*>::reverse_iterator it = m_active_toasts.rbegin(); it != m_active_toasts.rend(); ++it) - { LLToast* toast = (*it); - S32 toast_top = bottom + toast->getTopPad(); toast_rect = toast->getRect(); - toast_rect.setLeftTopAndSize(getRect().mLeft , toast_top, toast_rect.getWidth() ,toast_rect.getHeight()); + toast_rect.setLeftTopAndSize(getRect().mLeft , bottom + toast_rect.getHeight(), toast_rect.getWidth() ,toast_rect.getHeight()); toast->setRect(toast_rect); + bottom += toast_rect.getHeight() + margin; + } + + // use reverse order to provide correct z-order and avoid toast blinking + + for(std::vector<LLToast*>::reverse_iterator it = m_active_toasts.rbegin(); it != m_active_toasts.rend(); ++it) + { + LLToast* toast = (*it); toast->setIsHidden(false); toast->setVisible(TRUE); - bottom = toast->getRect().mBottom - margin; } } diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp index 60657d3fa7..911ed6ade7 100644 --- a/indra/newview/lltoast.cpp +++ b/indra/newview/lltoast.cpp @@ -285,6 +285,12 @@ void LLToast::setVisible(BOOL show) } LLModalDialog::setFrontmost(FALSE); } + else + { + //hide "hide" button in case toast was hidden without mouse_leave + if(mHideBtn) + mHideBtn->setVisible(show); + } LLFloater::setVisible(show); if(mPanel) { diff --git a/indra/newview/lltoast.h b/indra/newview/lltoast.h index 20198a9398..bd07ff9fb1 100644 --- a/indra/newview/lltoast.h +++ b/indra/newview/lltoast.h @@ -63,6 +63,8 @@ public: void start() { mEventTimer.start(); } void restart() {mEventTimer.reset(); } BOOL getStarted() { return mEventTimer.getStarted(); } + + LLTimer& getEventTimer() { return mEventTimer;} private : LLToast* mToast; }; @@ -132,6 +134,8 @@ public: // void stopTimer() { mTimer->stop(); } // + LLToastLifeTimer* getTimer() { return mTimer.get();} + // virtual void draw(); // virtual void setVisible(BOOL show); |