diff options
author | Cosmic Linden <cosmic@lindenlab.com> | 2022-02-25 15:31:49 -0800 |
---|---|---|
committer | Cosmic Linden <cosmic@lindenlab.com> | 2022-03-03 17:12:50 -0800 |
commit | fcbd928679619f2d1cb8550a30234dcdfc50ef81 (patch) | |
tree | 045551d54edefba1dda727e7548223b4ea09d4f8 /indra/newview | |
parent | 0e927e92f33f4a421a3cd56f7b9bc65c19003df2 (diff) |
SL-16918: Minimap navigation improvements: Drag without holding shift, remove auto center, click button to re-center
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/app_settings/settings.xml | 11 | ||||
-rw-r--r-- | indra/newview/llnetmap.cpp | 163 | ||||
-rw-r--r-- | indra/newview/llnetmap.h | 13 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_mini_map.xml | 15 |
4 files changed, 98 insertions, 104 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 3ecfa4ef9a..d6836dd8ba 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -6049,17 +6049,6 @@ <key>Value</key> <integer>1</integer> </map> - <key>MiniMapAutoCenter</key> - <map> - <key>Comment</key> - <string>Center the focal point of the minimap.</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>Boolean</string> - <key>Value</key> - <integer>1</integer> - </map> <key>Marker</key> <map> <key>Comment</key> diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 29623ccd53..f7bcee2bbc 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -87,7 +87,6 @@ LLNetMap::LLNetMap (const Params & p) mPixelsPerMeter( MAP_SCALE_MID / REGION_WIDTH_METERS ), mObjectMapTPM(0.f), mObjectMapPixels(0.f), - mTargetPan(0.f, 0.f), mCurPan(0.f, 0.f), mStartPan(0.f, 0.f), mMouseDown(0, 0), @@ -112,13 +111,17 @@ LLNetMap::~LLNetMap() BOOL LLNetMap::postBuild() { - LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; - - registrar.add("Minimap.Zoom", boost::bind(&LLNetMap::handleZoom, this, _2)); - registrar.add("Minimap.Tracker", boost::bind(&LLNetMap::handleStopTracking, this, _2)); + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar commitRegistrar; - mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_mini_map.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); - return TRUE; + commitRegistrar.add("Minimap.Zoom", boost::bind(&LLNetMap::handleZoom, this, _2)); + commitRegistrar.add("Minimap.Tracker", boost::bind(&LLNetMap::handleStopTracking, this, _2)); + commitRegistrar.add("Minimap.Center.Activate", boost::bind(&LLNetMap::activateCenterMap, this, _2)); + + mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_mini_map.xml", gMenuHolder, + LLViewerMenuHolderGL::child_registry_t::instance()); + mPopupMenu->setItemEnabled("Re-Center Map", false); + + return true; } void LLNetMap::setScale( F32 scale ) @@ -166,10 +169,16 @@ void LLNetMap::draw() createObjectImage(); } - static LLUICachedControl<bool> auto_center("MiniMapAutoCenter", true); - if (auto_center) + mCentering = mCentering && !mPanning; + if (mCentering) { - mCurPan = lerp(mCurPan, mTargetPan, LLSmoothInterpolation::getInterpolant(0.1f)); + mCurPan = lerp(mCurPan, LLVector2(0.0f, 0.0f) , LLSmoothInterpolation::getInterpolant(0.1f)); + if (abs(mCurPan.mV[0]) < 0.5f && abs(mCurPan.mV[1]) < 0.5f){ + mCurPan.mV[0] = 0.0f; + mCurPan.mV[1] = 0.0f; + mCentering = false; + mPopupMenu->setItemEnabled("Re-Center Map", false); + } } // Prepare a scissor region @@ -589,23 +598,25 @@ LLVector3d LLNetMap::viewPosToGlobal( S32 x, S32 y ) BOOL LLNetMap::handleScrollWheel(S32 x, S32 y, S32 clicks) { - // note that clicks are reversed from what you'd think: i.e. > 0 means zoom out, < 0 means zoom in - F32 new_scale = mScale * pow(MAP_SCALE_ZOOM_FACTOR, -clicks); + // note that clicks are reversed from what you'd think: i.e. > 0 means zoom out, < 0 means zoom in + F32 new_scale = mScale * pow(MAP_SCALE_ZOOM_FACTOR, -clicks); + // *TODO: Decide if we want this feature +#if 0 F32 old_scale = mScale; +#endif - setScale(new_scale); + setScale(new_scale); - static LLUICachedControl<bool> auto_center("MiniMapAutoCenter", true); - if (!auto_center) - { - // Adjust pan to center the zoom on the mouse pointer - LLVector2 zoom_offset; - zoom_offset.mV[VX] = x - getRect().getWidth() / 2; - zoom_offset.mV[VY] = y - getRect().getHeight() / 2; - mCurPan -= zoom_offset * mScale / old_scale - zoom_offset; - } + // *TODO: Decide if we want this feature +#if 0 + // Adjust pan to center the zoom on the mouse pointer + LLVector2 zoom_offset; + zoom_offset.mV[VX] = x - getRect().getWidth() / 2; + zoom_offset.mV[VY] = y - getRect().getHeight() / 2; + mCurPan -= zoom_offset * mScale / old_scale - zoom_offset; +#endif - return TRUE; + return true; } BOOL LLNetMap::handleToolTip(S32 x, S32 y, MASK mask) @@ -898,50 +909,48 @@ void LLNetMap::createObjectImage() mUpdateNow = true; } -BOOL LLNetMap::handleMouseDown( S32 x, S32 y, MASK mask ) +BOOL LLNetMap::handleMouseDown(S32 x, S32 y, MASK mask) { - if (!(mask & MASK_SHIFT)) return FALSE; - - // Start panning - gFocusMgr.setMouseCapture(this); + // Start panning + gFocusMgr.setMouseCapture(this); - mStartPan = mCurPan; - mMouseDown.mX = x; - mMouseDown.mY = y; - return TRUE; + mStartPan = mCurPan; + mMouseDown.mX = x; + mMouseDown.mY = y; + return true; } -BOOL LLNetMap::handleMouseUp( S32 x, S32 y, MASK mask ) +BOOL LLNetMap::handleMouseUp(S32 x, S32 y, MASK mask) { - if(abs(mMouseDown.mX-x)<3 && abs(mMouseDown.mY-y)<3) - handleClick(x,y,mask); + if (abs(mMouseDown.mX - x) < 3 && abs(mMouseDown.mY - y) < 3) + { + handleClick(x, y, mask); + } - if (hasMouseCapture()) - { - if (mPanning) - { - // restore mouse cursor - S32 local_x, local_y; - local_x = mMouseDown.mX + llfloor(mCurPan.mV[VX] - mStartPan.mV[VX]); - local_y = mMouseDown.mY + llfloor(mCurPan.mV[VY] - mStartPan.mV[VY]); - LLRect clip_rect = getRect(); - clip_rect.stretch(-8); - clip_rect.clipPointToRect(mMouseDown.mX, mMouseDown.mY, local_x, local_y); - LLUI::getInstance()->setMousePositionLocal(this, local_x, local_y); - - // finish the pan - mPanning = false; - - mMouseDown.set(0, 0); - - // auto centre - mTargetPan.setZero(); - } - gViewerWindow->showCursor(); - gFocusMgr.setMouseCapture(NULL); - return TRUE; - } - return FALSE; + if (hasMouseCapture()) + { + if (mPanning) + { + // restore mouse cursor + S32 local_x, local_y; + local_x = mMouseDown.mX + llfloor(mCurPan.mV[VX] - mStartPan.mV[VX]); + local_y = mMouseDown.mY + llfloor(mCurPan.mV[VY] - mStartPan.mV[VY]); + LLRect clip_rect = getRect(); + clip_rect.stretch(-8); + clip_rect.clipPointToRect(mMouseDown.mX, mMouseDown.mY, local_x, local_y); + LLUI::getInstance()->setMousePositionLocal(this, local_x, local_y); + + // finish the pan + mPanning = false; + + mMouseDown.set(0, 0); + } + gViewerWindow->showCursor(); + gFocusMgr.setMouseCapture(NULL); + return true; + } + + return false; } BOOL LLNetMap::handleRightMouseDown(S32 x, S32 y, MASK mask) @@ -1015,9 +1024,10 @@ BOOL LLNetMap::handleHover( S32 x, S32 y, MASK mask ) { if (!mPanning) { - // just started panning, so hide cursor + // Just started panning. Hide cursor and enable the "Re-Center Map" button. mPanning = true; gViewerWindow->hideCursor(); + mPopupMenu->setItemEnabled("Re-Center Map", true); } LLVector2 delta(static_cast<F32>(gViewerWindow->getCurrentMouseDX()), @@ -1025,27 +1035,22 @@ BOOL LLNetMap::handleHover( S32 x, S32 y, MASK mask ) // Set pan to value at start of drag + offset mCurPan += delta; - mTargetPan = mCurPan; gViewerWindow->moveCursorToCenter(); } - - // Doesn't really matter, cursor should be hidden - gViewerWindow->setCursor( UI_CURSOR_TOOLPAN ); - } - else - { - if (mask & MASK_SHIFT) - { - // If shift is held, change the cursor to hint that the map can be dragged - gViewerWindow->setCursor( UI_CURSOR_TOOLPAN ); - } - else - { - gViewerWindow->setCursor( UI_CURSOR_CROSS ); - } } + if (mask & MASK_SHIFT) + { + // If shift is held, change the cursor to hint that the map can be + // dragged. However, holding shift is not required to drag the map. + gViewerWindow->setCursor( UI_CURSOR_TOOLPAN ); + } + else + { + gViewerWindow->setCursor( UI_CURSOR_CROSS ); + } + return TRUE; } @@ -1083,3 +1088,5 @@ void LLNetMap::handleStopTracking (const LLSD& userdata) LLTracker::stopTracking (LLTracker::isTracking(NULL)); } } + +void LLNetMap::activateCenterMap(const LLSD &userdata) { mCentering = true; } diff --git a/indra/newview/llnetmap.h b/indra/newview/llnetmap.h index b82b3d4105..0f2eee171d 100644 --- a/indra/newview/llnetmap.h +++ b/indra/newview/llnetmap.h @@ -121,11 +121,11 @@ private: F32 mObjectMapPixels; // Width of object map in pixels F32 mDotRadius; // Size of avatar markers - bool mPanning; // map is being dragged - LLVector2 mTargetPan; - LLVector2 mCurPan; - LLVector2 mStartPan; // pan offset at start of drag - LLCoordGL mMouseDown; // pointer position at start of drag + bool mPanning; // map is being dragged + bool mCentering; // map is being re-centered around the agent + LLVector2 mCurPan; + LLVector2 mStartPan; // pan offset at start of drag + LLCoordGL mMouseDown; // pointer position at start of drag LLVector3d mObjectImageCenterGlobal; LLPointer<LLImageRaw> mObjectRawImagep; @@ -148,7 +148,8 @@ public: private: void handleZoom(const LLSD& userdata); - void handleStopTracking (const LLSD& userdata); + void handleStopTracking(const LLSD& userdata); + void activateCenterMap(const LLSD& userdata); LLMenuGL* mPopupMenu; uuid_vec_t gmSelected; diff --git a/indra/newview/skins/default/xui/en/menu_mini_map.xml b/indra/newview/skins/default/xui/en/menu_mini_map.xml index c3899b35cd..ddc952dfe7 100644 --- a/indra/newview/skins/default/xui/en/menu_mini_map.xml +++ b/indra/newview/skins/default/xui/en/menu_mini_map.xml @@ -46,17 +46,14 @@ function="ToggleControl" parameter="MiniMapRotate" /> </menu_item_check> - <menu_item_check - label="Auto Center" - name="Auto Center"> - <menu_item_check.on_check - control="MiniMapAutoCenter" /> - <menu_item_check.on_click - function="ToggleControl" - parameter="MiniMapAutoCenter" /> - </menu_item_check> <menu_item_separator /> <menu_item_call + label="Re-Center Map" + name="Re-Center Map"> + <menu_item_call.on_click + function="Minimap.Center.Activate" /> + </menu_item_call> + <menu_item_call label="Stop Tracking" name="Stop Tracking"> <menu_item_call.on_click |