From 0bbcb0d22d2a215e0d8bf824b44a18a8bd948f20 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 3 Mar 2010 20:23:26 -0800 Subject: resizing and nesting of popups now work --- indra/newview/llpopupview.cpp | 64 +++++++++++++++++++++++++------------------ indra/newview/llpopupview.h | 2 +- indra/newview/llstatusbar.cpp | 10 +++---- 3 files changed, 43 insertions(+), 33 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpopupview.cpp b/indra/newview/llpopupview.cpp index eb750a87e2..3494522969 100644 --- a/indra/newview/llpopupview.cpp +++ b/indra/newview/llpopupview.cpp @@ -54,17 +54,25 @@ void LLPopupView::draw() { S32 screen_x, screen_y; + // remove dead popups for (popup_list_t::iterator popup_it = mPopups.begin(); popup_it != mPopups.end();) { - LLView* popup = popup_it->get(); - if (!popup) + if (!popup_it->get()) { - popup_list_t::iterator cur_popup_it = popup_it; - ++popup_it; - mPopups.erase(cur_popup_it); - continue; + mPopups.erase(popup_it++); + } + else + { + popup_it++; } + } + + // draw in reverse order (most recent is on top) + for (popup_list_t::reverse_iterator popup_it = mPopups.rbegin(); + popup_it != mPopups.rend();) + { + LLView* popup = popup_it->get(); if (popup->getVisible()) { @@ -85,16 +93,17 @@ void LLPopupView::draw() BOOL LLPopupView::handleMouseEvent(boost::function func, boost::function predicate, - S32 x, S32 y) + S32 x, S32 y, + bool close_popups) { - for (popup_list_t::reverse_iterator popup_it = mPopups.rbegin(); - popup_it != mPopups.rend(); - ++popup_it) + for (popup_list_t::iterator popup_it = mPopups.begin(); + popup_it != mPopups.end();) { LLView* popup = popup_it->get(); if (!popup || !predicate(popup)) { + ++popup_it; continue; } @@ -107,6 +116,9 @@ BOOL LLPopupView::handleMouseEvent(boost::function func return TRUE; } } + + popup->onTopLost(); + mPopups.erase(popup_it++); } return FALSE; @@ -115,9 +127,8 @@ BOOL LLPopupView::handleMouseEvent(boost::function func BOOL LLPopupView::handleMouseDown(S32 x, S32 y, MASK mask) { - if (!handleMouseEvent(boost::bind(&LLMouseHandler::handleMouseDown, _1, _2, _3, mask), view_visible_and_enabled, x, y)) + if (!handleMouseEvent(boost::bind(&LLMouseHandler::handleMouseDown, _1, _2, _3, mask), view_visible_and_enabled, x, y, true)) { - clearPopups(); return FALSE; } return TRUE; @@ -125,14 +136,13 @@ BOOL LLPopupView::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLPopupView::handleMouseUp(S32 x, S32 y, MASK mask) { - return handleMouseEvent(boost::bind(&LLMouseHandler::handleMouseUp, _1, _2, _3, mask), view_visible_and_enabled, x, y); + return handleMouseEvent(boost::bind(&LLMouseHandler::handleMouseUp, _1, _2, _3, mask), view_visible_and_enabled, x, y, false); } BOOL LLPopupView::handleMiddleMouseDown(S32 x, S32 y, MASK mask) { - if (!handleMouseEvent(boost::bind(&LLMouseHandler::handleMiddleMouseDown, _1, _2, _3, mask), view_visible_and_enabled, x, y)) + if (!handleMouseEvent(boost::bind(&LLMouseHandler::handleMiddleMouseDown, _1, _2, _3, mask), view_visible_and_enabled, x, y, true)) { - clearPopups(); return FALSE; } return TRUE; @@ -140,14 +150,13 @@ BOOL LLPopupView::handleMiddleMouseDown(S32 x, S32 y, MASK mask) BOOL LLPopupView::handleMiddleMouseUp(S32 x, S32 y, MASK mask) { - return handleMouseEvent(boost::bind(&LLMouseHandler::handleMiddleMouseUp, _1, _2, _3, mask), view_visible_and_enabled, x, y); + return handleMouseEvent(boost::bind(&LLMouseHandler::handleMiddleMouseUp, _1, _2, _3, mask), view_visible_and_enabled, x, y, false); } BOOL LLPopupView::handleRightMouseDown(S32 x, S32 y, MASK mask) { - if (!handleMouseEvent(boost::bind(&LLMouseHandler::handleRightMouseDown, _1, _2, _3, mask), view_visible_and_enabled, x, y)) + if (!handleMouseEvent(boost::bind(&LLMouseHandler::handleRightMouseDown, _1, _2, _3, mask), view_visible_and_enabled, x, y, true)) { - clearPopups(); return FALSE; } return TRUE; @@ -155,27 +164,27 @@ BOOL LLPopupView::handleRightMouseDown(S32 x, S32 y, MASK mask) BOOL LLPopupView::handleRightMouseUp(S32 x, S32 y, MASK mask) { - return handleMouseEvent(boost::bind(&LLMouseHandler::handleRightMouseUp, _1, _2, _3, mask), view_visible_and_enabled, x, y); + return handleMouseEvent(boost::bind(&LLMouseHandler::handleRightMouseUp, _1, _2, _3, mask), view_visible_and_enabled, x, y, false); } BOOL LLPopupView::handleDoubleClick(S32 x, S32 y, MASK mask) { - return handleMouseEvent(boost::bind(&LLMouseHandler::handleDoubleClick, _1, _2, _3, mask), view_visible_and_enabled, x, y); + return handleMouseEvent(boost::bind(&LLMouseHandler::handleDoubleClick, _1, _2, _3, mask), view_visible_and_enabled, x, y, false); } BOOL LLPopupView::handleHover(S32 x, S32 y, MASK mask) { - return handleMouseEvent(boost::bind(&LLMouseHandler::handleHover, _1, _2, _3, mask), view_visible_and_enabled, x, y); + return handleMouseEvent(boost::bind(&LLMouseHandler::handleHover, _1, _2, _3, mask), view_visible_and_enabled, x, y, false); } BOOL LLPopupView::handleScrollWheel(S32 x, S32 y, S32 clicks) { - return handleMouseEvent(boost::bind(&LLMouseHandler::handleScrollWheel, _1, _2, _3, clicks), view_visible_and_enabled, x, y); + return handleMouseEvent(boost::bind(&LLMouseHandler::handleScrollWheel, _1, _2, _3, clicks), view_visible_and_enabled, x, y, false); } BOOL LLPopupView::handleToolTip(S32 x, S32 y, MASK mask) { - return handleMouseEvent(boost::bind(&LLMouseHandler::handleToolTip, _1, _2, _3, mask), view_visible, x, y); + return handleMouseEvent(boost::bind(&LLMouseHandler::handleToolTip, _1, _2, _3, mask), view_visible, x, y, false); } void LLPopupView::addPopup(LLView* popup) @@ -183,7 +192,7 @@ void LLPopupView::addPopup(LLView* popup) if (popup) { mPopups.erase(std::find(mPopups.begin(), mPopups.end(), popup->getHandle())); - mPopups.push_back(popup->getHandle()); + mPopups.push_front(popup->getHandle()); } } @@ -206,11 +215,12 @@ void LLPopupView::clearPopups() popup_it != mPopups.end();) { LLView* popup = popup_it->get(); + + popup_list_t::iterator cur_popup_it = popup_it; ++popup_it; - if (popup) popup->onTopLost(); + mPopups.erase(cur_popup_it); + popup->onTopLost(); } - - mPopups.clear(); } diff --git a/indra/newview/llpopupview.h b/indra/newview/llpopupview.h index c5dbb94c4c..6248e9a553 100644 --- a/indra/newview/llpopupview.h +++ b/indra/newview/llpopupview.h @@ -60,7 +60,7 @@ public: popup_list_t getCurrentPopups() { return mPopups; } private: - BOOL handleMouseEvent(boost::function, boost::function, S32 x, S32 y); + BOOL handleMouseEvent(boost::function, boost::function, S32 x, S32 y, bool close_popups); popup_list_t mPopups; }; #endif //LL_LLROOTVIEW_H diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index 2ed0718e41..0a30ed0ecf 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -522,11 +522,11 @@ static void onClickScriptDebug(void*) void LLStatusBar::onMouseEnterVolume() { LLButton* volbtn = getChild( "volume_btn" ); - LLRect vol_btn_screen_rect = volbtn->calcScreenRect(); + LLRect vol_btn_rect = volbtn->getRect(); LLRect volume_pulldown_rect = mPanelVolumePulldown->getRect(); - volume_pulldown_rect.setLeftTopAndSize(vol_btn_screen_rect.mLeft - - (volume_pulldown_rect.getWidth() - vol_btn_screen_rect.getWidth())/2, - vol_btn_screen_rect.mBottom, + volume_pulldown_rect.setLeftTopAndSize(vol_btn_rect.mLeft - + (volume_pulldown_rect.getWidth() - vol_btn_rect.getWidth())/2, + vol_btn_rect.mBottom, volume_pulldown_rect.getWidth(), volume_pulldown_rect.getHeight()); @@ -545,7 +545,7 @@ void LLStatusBar::onMouseEnterNearbyMedia() LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder"); LLRect nearby_media_rect = mPanelNearByMedia->getRect(); LLButton* nearby_media_btn = getChild( "media_toggle_btn" ); - LLRect nearby_media_btn_rect = nearby_media_btn->calcScreenRect(); + LLRect nearby_media_btn_rect = nearby_media_btn->getRect(); nearby_media_rect.setLeftTopAndSize(nearby_media_btn_rect.mLeft - (nearby_media_rect.getWidth() - nearby_media_btn_rect.getWidth())/2, nearby_media_btn_rect.mBottom, -- cgit v1.2.3