diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/app_settings/settings.xml | 11 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 94 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.h | 2 | ||||
-rw-r--r-- | indra/newview/llworldmapview.cpp | 11 |
4 files changed, 82 insertions, 36 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index d328a3856f..bc2466d81b 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -7609,6 +7609,17 @@ <key>Value</key> <real>0.699999988079</real> </map> + <key>ToolTipFadeTime</key> + <map> + <key>Comment</key> + <string>Seconds over which tooltip fades away</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>0.2</real> + </map> <key>ToolboxAutoMove</key> <map> <key>Comment</key> diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index e690ae5f6f..6f094e4b01 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -601,11 +601,11 @@ bool LLViewerWindow::shouldShowToolTipFor(LLMouseHandler *mh) { LLMouseHandler::EShowToolTip showlevel = mh->getShowToolTip(); - return ( - showlevel == LLMouseHandler::SHOW_ALWAYS || - (showlevel == LLMouseHandler::SHOW_IF_NOT_BLOCKED && - !mToolTipBlocked) - ); + bool tool_tip_allowed = (showlevel == LLMouseHandler::SHOW_ALWAYS + || (showlevel == LLMouseHandler::SHOW_IF_NOT_BLOCKED + && !mToolTipBlocked)); + + return tool_tip_allowed; } return false; } @@ -2617,57 +2617,91 @@ void LLViewerWindow::updateUI() // Show a new tool tip (or update one that is alrady shown) BOOL tool_tip_handled = FALSE; std::string tool_tip_msg; - F32 tooltip_delay = gSavedSettings.getF32( "ToolTipDelay" ); - //HACK: hack for tool-based tooltips which need to pop up more quickly - //Also for show xui names as tooltips debug mode - if ((mouse_captor && !mouse_captor->isView()) || LLUI::sShowXUINames) - { - tooltip_delay = gSavedSettings.getF32( "DragAndDropToolTipDelay" ); - } - if( handled && - gMouseIdleTimer.getElapsedTimeF32() > tooltip_delay && - !mWindow->isCursorHidden() ) + if( handled + && !mWindow->isCursorHidden() + && mToolTip) { LLRect screen_sticky_rect; - LLMouseHandler *mh; + LLMouseHandler *tooltip_source = NULL; S32 local_x, local_y; if (mouse_captor) { mouse_captor->screenPointToLocal(x, y, &local_x, &local_y); - mh = mouse_captor; + tooltip_source = mouse_captor; } else if (handled_by_top_ctrl) { top_ctrl->screenPointToLocal(x, y, &local_x, &local_y); - mh = top_ctrl; + tooltip_source = top_ctrl; } else { local_x = x; local_y = y; - mh = mRootView; + tooltip_source = mRootView; } + F32 tooltip_delay = gSavedSettings.getF32( "ToolTipDelay" ); + //HACK: hack for tool-based tooltips which need to pop up more quickly + //Also for show xui names as tooltips debug mode + if ((gFocusMgr.getMouseCapture() + && !gFocusMgr.getMouseCapture()->isView()) + || LLUI::sShowXUINames) + { + tooltip_delay = gSavedSettings.getF32( "DragAndDropToolTipDelay" ); + } + + BOOL tooltip_vis = FALSE; - if (shouldShowToolTipFor(mh)) + if (shouldShowToolTipFor(tooltip_source)) { - tool_tip_handled = mh->handleToolTip(local_x, local_y, tool_tip_msg, &screen_sticky_rect ); + tool_tip_handled = tooltip_source->handleToolTip(local_x, local_y, tool_tip_msg, &screen_sticky_rect ); + // if we actually got a tooltip back... if( tool_tip_handled && !tool_tip_msg.empty() ) { - mToolTipStickyRect = screen_sticky_rect; - mToolTip->setWrappedText( tool_tip_msg, 200 ); - mToolTip->reshapeToFitText(); - mToolTip->setOrigin( x, y ); - LLRect virtual_window_rect(0, getWindowHeight(), getWindowWidth(), 0); - mToolTip->translateIntoRect( virtual_window_rect, FALSE ); - tooltip_vis = TRUE; + if (mToolTip->getVisible() // already showing a tooltip + || gMouseIdleTimer.getElapsedTimeF32() > tooltip_delay) // mouse has been still long enough to show the tooltip + { + // if tooltip has changed or mouse has moved outside of "sticky" rectangle... + if (mLastToolTipMessage != tool_tip_msg + || !mToolTipStickyRect.pointInRect(x, y)) + { + //...update "sticky" rect and tooltip position + mToolTipStickyRect = screen_sticky_rect; + mToolTip->setOrigin( x, y ); + } + + // remember this tooltip so we know when it changes + mLastToolTipMessage = tool_tip_msg; + mToolTip->setWrappedText( tool_tip_msg, 200 ); + mToolTip->reshapeToFitText(); + LLRect virtual_window_rect(0, getWindowHeight(), getWindowWidth(), 0); + mToolTip->translateIntoRect( virtual_window_rect, FALSE ); + tooltip_vis = TRUE; + } } } - if (mToolTip) + // HACK: assuming tooltip background is in ToolTipBGColor, perform fade out + LLColor4 bg_color = LLUIColorTable::instance().getColor( "ToolTipBgColor" ); + if (tooltip_vis) + { + mToolTipFadeTimer.stop(); + mToolTip->setBackgroundColor(bg_color); + } + else { - mToolTip->setVisible( tooltip_vis ); + if (!mToolTipFadeTimer.getStarted()) + { + mToolTipFadeTimer.start(); + } + F32 tool_tip_fade_time = gSavedSettings.getF32("ToolTipFadeTime"); + bg_color.mV[VALPHA] = clamp_rescale(mToolTipFadeTimer.getElapsedTimeF32(), 0.f, tool_tip_fade_time, bg_color.mV[VALPHA], 0.f); + mToolTip->setBackgroundColor(bg_color); } + + // above interpolation of bg_color alpha is guaranteed to reach 0.f exactly + mToolTip->setVisible( bg_color.mV[VALPHA] != 0.f ); } updateLayout(); diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index ef7e30e8b9..a1120b303b 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -414,7 +414,9 @@ protected: LLProgressView *mProgressView; + LLFrameTimer mToolTipFadeTimer; LLTextBox* mToolTip; + std::string mLastToolTipMessage; BOOL mToolTipBlocked; // True after a key press or a mouse button event. False once the mouse moves again. LLRect mToolTipStickyRect; // Once a tool tip is shown, it will stay visible until the mouse leaves this rect. diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index 9e04c14beb..3deddf40ac 100644 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -1228,12 +1228,11 @@ BOOL LLWorldMapView::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* stic msg += region_flags; } - S32 SLOP = 4; - localPointToScreen( - x - SLOP, y - SLOP, - &(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) ); - sticky_rect_screen->mRight = sticky_rect_screen->mLeft + 2 * SLOP; - sticky_rect_screen->mTop = sticky_rect_screen->mBottom + 2 * SLOP; + const S32 SLOP = 9; + S32 screen_x, screen_y; + + localPointToScreen(x, y, &screen_x, &screen_y); + sticky_rect_screen->setCenterAndSize(screen_x, screen_y, SLOP, SLOP); } return TRUE; } |