summaryrefslogtreecommitdiff
path: root/indra/newview/llnetmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llnetmap.cpp')
-rw-r--r--indra/newview/llnetmap.cpp450
1 files changed, 320 insertions, 130 deletions
diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp
index b40af37f7e..6db8001d57 100644
--- a/indra/newview/llnetmap.cpp
+++ b/indra/newview/llnetmap.cpp
@@ -3,31 +3,25 @@
* @author James Cook
* @brief Display of surrounding regions, objects, and agents.
*
- * $LicenseInfo:firstyear=2001&license=viewergpl$
- *
- * Copyright (c) 2001-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -35,44 +29,70 @@
#include "llnetmap.h"
+// Library includes (should move below)
#include "indra_constants.h"
#include "llmath.h"
#include "llfloaterreg.h"
#include "llfocusmgr.h"
+#include "lllocalcliprect.h"
#include "llrender.h"
#include "llui.h"
+#include "lltooltip.h"
#include "llglheaders.h"
+// Viewer includes
#include "llagent.h"
+#include "llagentcamera.h"
#include "llappviewer.h" // for gDisconnected
#include "llcallingcard.h" // LLAvatarTracker
#include "lltracker.h"
#include "llsurface.h"
#include "llviewercamera.h"
#include "llviewercontrol.h"
+#include "llviewertexture.h"
+#include "llviewertexturelist.h"
+#include "llviewermenu.h"
#include "llviewerobjectlist.h"
#include "llviewerregion.h"
+#include "llviewerwindow.h"
#include "llworld.h"
#include "llworldmapview.h" // shared draw code
-static LLDefaultWidgetRegistry::Register<LLNetMap> r1("net_map");
+static LLDefaultChildRegistry::Register<LLNetMap> r1("net_map");
-const F32 MAP_SCALE_MIN = 64;
-const F32 MAP_SCALE_MID = 172;
-const F32 MAP_SCALE_MAX = 512;
-const F32 MAP_SCALE_INCREMENT = 16;
-const F32 MAP_MIN_PICK_DIST = 4;
-const F32 MAX_PRIM_RADIUS = 256.0f; // Don't try to draw giant mega-prims on the mini map
+const F32 LLNetMap::MAP_SCALE_MIN = 32;
+const F32 LLNetMap::MAP_SCALE_MID = 1024;
+const F32 LLNetMap::MAP_SCALE_MAX = 4096;
-LLNetMap::LLNetMap (const Params & p) :
- LLUICtrl (p),
- mScale(128.0f),
+const F32 MAP_SCALE_INCREMENT = 16;
+const F32 MAP_SCALE_ZOOM_FACTOR = 1.04f; // Zoom in factor per click of scroll wheel (4%)
+const F32 MIN_DOT_RADIUS = 3.5f;
+const F32 DOT_SCALE = 0.75f;
+const F32 MIN_PICK_SCALE = 2.f;
+const S32 MOUSE_DRAG_SLOP = 2; // How far the mouse needs to move before we think it's a drag
+
+LLNetMap::LLNetMap (const Params & p)
+: LLUICtrl (p),
mBackgroundColor (p.bg_color()),
- mRotateMap(FALSE)
+ mScale( MAP_SCALE_MID ),
+ 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),
+ mPanning(false),
+ mUpdateNow(false),
+ mObjectImageCenterGlobal( gAgentCamera.getCameraPositionGlobal() ),
+ mObjectRawImagep(),
+ mObjectImagep(),
+ mClosestAgentToCursor(),
+ mClosestAgentAtLastRightClick(),
+ mToolTipMsg()
{
- mObjectImageCenterGlobal = gAgent.getCameraPositionGlobal();
- mPixelsPerMeter = mScale / REGION_WIDTH_METERS;
+ mDotRadius = llmax(DOT_SCALE * mPixelsPerMeter, MIN_DOT_RADIUS);
}
LLNetMap::~LLNetMap()
@@ -81,29 +101,26 @@ LLNetMap::~LLNetMap()
void LLNetMap::setScale( F32 scale )
{
- mScale = llclamp(scale, 0.1f, 16.f*1024.f); // [reasonably small , unreasonably large]
+ scale = llclamp(scale, MAP_SCALE_MIN, MAP_SCALE_MAX);
+ mCurPan *= scale / mScale;
+ mScale = scale;
if (mObjectImagep.notNull())
{
- F32 half_width = (F32)(getRect().getWidth() / 2);
- F32 half_height = (F32)(getRect().getHeight() / 2);
- F32 radius = sqrt( half_width * half_width + half_height * half_height );
- F32 region_widths = (2.f*radius)/mScale;
+ F32 width = (F32)(getRect().getWidth());
+ F32 height = (F32)(getRect().getHeight());
+ F32 diameter = sqrt(width * width + height * height);
+ F32 region_widths = diameter / mScale;
F32 meters = region_widths * LLWorld::getInstance()->getRegionWidthInMeters();
F32 num_pixels = (F32)mObjectImagep->getWidth();
- mObjectMapTPM = num_pixels/meters;
- mObjectMapPixels = 2.f*radius;
+ mObjectMapTPM = num_pixels / meters;
+ mObjectMapPixels = diameter;
}
mPixelsPerMeter = mScale / REGION_WIDTH_METERS;
+ mDotRadius = llmax(DOT_SCALE * mPixelsPerMeter, MIN_DOT_RADIUS);
- mUpdateNow = TRUE;
-}
-
-void LLNetMap::translatePan( F32 delta_x, F32 delta_y )
-{
- mTargetPanX += delta_x;
- mTargetPanY += delta_y;
+ mUpdateNow = true;
}
@@ -112,30 +129,43 @@ void LLNetMap::translatePan( F32 delta_x, F32 delta_y )
void LLNetMap::draw()
{
static LLFrameTimer map_timer;
- static LLCachedControl<LLColor4> map_avatar_color(gSavedSkinSettings, "MapAvatarColor", LLColor4::white);
- static LLCachedControl<LLColor4> map_avatar_friend_color(gSavedSkinSettings, "MapAvatarFriendColor", LLColor4::white);
- static LLCachedControl<LLColor4> map_track_color(gSavedSkinSettings, "MapTrackColor", LLColor4::white);
- static LLCachedControl<LLColor4> map_track_disabled_color(gSavedSkinSettings, "MapTrackDisabledColor", LLColor4::white);
- static LLCachedControl<LLColor4> map_frustum_color(gSavedSkinSettings, "MapFrustumColor", LLColor4::white);
- static LLCachedControl<LLColor4> map_frustum_rotating_color(gSavedSkinSettings, "MapFrustumRotatingColor", LLColor4::white);
+ static LLUIColor map_avatar_color = LLUIColorTable::instance().getColor("MapAvatarColor", LLColor4::white);
+ static LLUIColor map_avatar_friend_color = LLUIColorTable::instance().getColor("MapAvatarFriendColor", LLColor4::white);
+ static LLUIColor map_track_color = LLUIColorTable::instance().getColor("MapTrackColor", LLColor4::white);
+ static LLUIColor map_track_disabled_color = LLUIColorTable::instance().getColor("MapTrackDisabledColor", LLColor4::white);
+ static LLUIColor map_frustum_color = LLUIColorTable::instance().getColor("MapFrustumColor", LLColor4::white);
+ static LLUIColor map_frustum_rotating_color = LLUIColorTable::instance().getColor("MapFrustumRotatingColor", LLColor4::white);
if (mObjectImagep.isNull())
{
createObjectImage();
}
-
- mCurPanX = lerp(mCurPanX, mTargetPanX, LLCriticalDamp::getInterpolant(0.1f));
- mCurPanY = lerp(mCurPanY, mTargetPanY, LLCriticalDamp::getInterpolant(0.1f));
+
+ static LLUICachedControl<bool> auto_center("MiniMapAutoCenter", true);
+ if (auto_center)
+ {
+ mCurPan = lerp(mCurPan, mTargetPan, LLCriticalDamp::getInterpolant(0.1f));
+ }
// Prepare a scissor region
F32 rotation = 0;
+ gGL.pushMatrix();
+ gGL.pushUIMatrix();
+
+ LLVector3 offset = gGL.getUITranslation();
+ LLVector3 scale = gGL.getUIScale();
+
+ glLoadIdentity();
+ gGL.loadUIIdentity();
+
+ glScalef(scale.mV[0], scale.mV[1], scale.mV[2]);
+ gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]);
+
{
- LLGLEnable scissor(GL_SCISSOR_TEST);
-
+ LLLocalClipRect clip(getLocalRect());
{
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- LLLocalClipRect clip(getLocalRect());
glMatrixMode(GL_MODELVIEW);
@@ -146,14 +176,15 @@ void LLNetMap::draw()
}
// region 0,0 is in the middle
- S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPanX);
- S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPanY);
+ S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPan.mV[VX]);
+ S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPan.mV[VY]);
gGL.pushMatrix();
gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f);
- if( mRotateMap )
+ static LLUICachedControl<bool> rotate_map("MiniMapRotate", true);
+ if( rotate_map )
{
// rotate subsequent draws to agent rotation
rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] );
@@ -169,7 +200,7 @@ void LLNetMap::draw()
LLViewerRegion* regionp = *iter;
// Find x and y position relative to camera's center.
LLVector3 origin_agent = regionp->getOriginAgent();
- LLVector3 rel_region_pos = origin_agent - gAgent.getCameraPositionAgent();
+ LLVector3 rel_region_pos = origin_agent - gAgentCamera.getCameraPositionAgent();
F32 relative_x = (rel_region_pos.mV[0] / region_width) * mScale;
F32 relative_y = (rel_region_pos.mV[1] / region_width) * mScale;
@@ -227,26 +258,24 @@ void LLNetMap::draw()
}
gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
}
-
-
- LLVector3d old_center = mObjectImageCenterGlobal;
- LLVector3d new_center = gAgent.getCameraPositionGlobal();
-
- new_center.mdV[0] = (5.f/mObjectMapTPM)*floor(0.2f*mObjectMapTPM*new_center.mdV[0]);
- new_center.mdV[1] = (5.f/mObjectMapTPM)*floor(0.2f*mObjectMapTPM*new_center.mdV[1]);
- new_center.mdV[2] = 0.f;
+ // Redraw object layer periodically
if (mUpdateNow || (map_timer.getElapsedTimeF32() > 0.5f))
{
- mUpdateNow = FALSE;
- mObjectImageCenterGlobal = new_center;
+ mUpdateNow = false;
+
+ // Locate the centre of the object layer, accounting for panning
+ LLVector3 new_center = globalPosToView(gAgentCamera.getCameraPositionGlobal());
+ new_center.mV[VX] -= mCurPan.mV[VX];
+ new_center.mV[VY] -= mCurPan.mV[VY];
+ new_center.mV[VZ] = 0.f;
+ mObjectImageCenterGlobal = viewPosToGlobal(llfloor(new_center.mV[VX]), llfloor(new_center.mV[VY]));
- // Center moved enough.
// Create the base texture.
U8 *default_texture = mObjectRawImagep->getData();
memset( default_texture, 0, mObjectImagep->getWidth() * mObjectImagep->getHeight() * mObjectImagep->getComponents() );
- // Draw buildings
+ // Draw objects
gObjectList.renderObjectsForMap(*this);
mObjectImagep->setSubImage(mObjectRawImagep, 0, 0, mObjectImagep->getWidth(), mObjectImagep->getHeight());
@@ -255,7 +284,7 @@ void LLNetMap::draw()
}
LLVector3 map_center_agent = gAgent.getPosAgentFromGlobal(mObjectImageCenterGlobal);
- map_center_agent -= gAgent.getCameraPositionAgent();
+ map_center_agent -= gAgentCamera.getCameraPositionAgent();
map_center_agent.mV[VX] *= mScale/region_width;
map_center_agent.mV[VY] *= mScale/region_width;
@@ -283,9 +312,10 @@ void LLNetMap::draw()
S32 local_mouse_x;
S32 local_mouse_y;
//localMouse(&local_mouse_x, &local_mouse_y);
- LLUI::getCursorPositionLocal(this, &local_mouse_x, &local_mouse_y);
+ LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y);
mClosestAgentToCursor.setNull();
F32 closest_dist = F32_MAX;
+ F32 min_pick_dist = mDotRadius * MIN_PICK_SCALE;
// Draw avatars
for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin();
@@ -329,10 +359,11 @@ void LLNetMap::draw()
LLWorldMapView::drawAvatar(
pos_map.mV[VX], pos_map.mV[VY],
show_as_friend ? map_avatar_friend_color : map_avatar_color,
- pos_map.mV[VZ]);
+ pos_map.mV[VZ], mDotRadius);
- F32 dist_to_cursor = dist_vec(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), LLVector2(local_mouse_x,local_mouse_y));
- if(dist_to_cursor < MAP_MIN_PICK_DIST && dist_to_cursor < closest_dist)
+ F32 dist_to_cursor = dist_vec(LLVector2(pos_map.mV[VX], pos_map.mV[VY]),
+ LLVector2(local_mouse_x,local_mouse_y));
+ if(dist_to_cursor < min_pick_dist && dist_to_cursor < closest_dist)
{
closest_dist = dist_to_cursor;
mClosestAgentToCursor = regionp->mMapAvatarIDs.get(i);
@@ -362,10 +393,22 @@ void LLNetMap::draw()
// Draw dot for self avatar position
pos_global = gAgent.getPositionGlobal();
pos_map = globalPosToView(pos_global);
- LLUIImagePtr you = LLWorldMapView::sAvatarYouSmallImage;
- you->draw(
- llround(pos_map.mV[VX]) - you->getWidth()/2,
- llround(pos_map.mV[VY]) - you->getHeight()/2);
+ S32 dot_width = llround(mDotRadius * 2.f);
+ LLUIImagePtr you = LLWorldMapView::sAvatarYouLargeImage;
+ if (you)
+ {
+ you->draw(llround(pos_map.mV[VX] - mDotRadius),
+ llround(pos_map.mV[VY] - mDotRadius),
+ dot_width,
+ dot_width);
+
+ F32 dist_to_cursor = dist_vec(LLVector2(pos_map.mV[VX], pos_map.mV[VY]),
+ LLVector2(local_mouse_x,local_mouse_y));
+ if(dist_to_cursor < min_pick_dist && dist_to_cursor < closest_dist)
+ {
+ mClosestAgentToCursor = gAgent.getID();
+ }
+ }
// Draw frustum
F32 meters_to_pixels = mScale/ LLWorld::getInstance()->getRegionWidthInMeters();
@@ -383,7 +426,7 @@ void LLNetMap::draw()
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- if( mRotateMap )
+ if( rotate_map )
{
gGL.color4fv((map_frustum_color()).mV);
@@ -410,12 +453,21 @@ void LLNetMap::draw()
}
}
+ gGL.popMatrix();
+ gGL.popUIMatrix();
+
LLUICtrl::draw();
}
+void LLNetMap::reshape(S32 width, S32 height, BOOL called_from_parent)
+{
+ LLUICtrl::reshape(width, height, called_from_parent);
+ createObjectImage();
+}
+
LLVector3 LLNetMap::globalPosToView( const LLVector3d& global_pos )
{
- LLVector3d relative_pos_global = global_pos - gAgent.getCameraPositionGlobal();
+ LLVector3d relative_pos_global = global_pos - gAgentCamera.getCameraPositionGlobal();
LLVector3 pos_local;
pos_local.setVec(relative_pos_global); // convert to floats from doubles
@@ -423,15 +475,16 @@ LLVector3 LLNetMap::globalPosToView( const LLVector3d& global_pos )
pos_local.mV[VY] *= mPixelsPerMeter;
// leave Z component in meters
- if( mRotateMap )
+ static LLUICachedControl<bool> rotate_map("MiniMapRotate", true);
+ if( rotate_map )
{
F32 radians = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] );
LLQuaternion rot(radians, LLVector3(0.f, 0.f, 1.f));
pos_local.rotVec( rot );
}
- pos_local.mV[VX] += getRect().getWidth() / 2 + mCurPanX;
- pos_local.mV[VY] += getRect().getHeight() / 2 + mCurPanY;
+ pos_local.mV[VX] += getRect().getWidth() / 2 + mCurPan.mV[VX];
+ pos_local.mV[VY] += getRect().getHeight() / 2 + mCurPan.mV[VY];
return pos_local;
}
@@ -464,14 +517,15 @@ void LLNetMap::drawTracking(const LLVector3d& pos_global, const LLColor4& color,
LLVector3d LLNetMap::viewPosToGlobal( S32 x, S32 y )
{
- x -= llround(getRect().getWidth() / 2 + mCurPanX);
- y -= llround(getRect().getHeight() / 2 + mCurPanY);
+ x -= llround(getRect().getWidth() / 2 + mCurPan.mV[VX]);
+ y -= llround(getRect().getHeight() / 2 + mCurPan.mV[VY]);
LLVector3 pos_local( (F32)x, (F32)y, 0 );
F32 radians = - atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] );
- if( mRotateMap )
+ static LLUICachedControl<bool> rotate_map("MiniMapRotate", true);
+ if( rotate_map )
{
LLQuaternion rot(radians, LLVector3(0.f, 0.f, 1.f));
pos_local.rotVec( rot );
@@ -481,39 +535,64 @@ LLVector3d LLNetMap::viewPosToGlobal( S32 x, S32 y )
LLVector3d pos_global;
pos_global.setVec( pos_local );
- pos_global += gAgent.getCameraPositionGlobal();
+ pos_global += gAgentCamera.getCameraPositionGlobal();
return pos_global;
}
BOOL LLNetMap::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
- // note that clicks are reversed from what you'd think
- setScale(llclamp(mScale - clicks*MAP_SCALE_INCREMENT, MAP_SCALE_MIN, MAP_SCALE_MAX));
+ // 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);
+ F32 old_scale = mScale;
+
+ 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;
+ }
+
return TRUE;
}
-BOOL LLNetMap::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen )
+BOOL LLNetMap::handleToolTip( S32 x, S32 y, MASK mask )
{
- BOOL handled = FALSE;
if (gDisconnected)
{
return FALSE;
}
-
- // mToolTipMsg = "[AGENT][REGION](Double-click to open Map)"
-
- LLStringUtil::format_map_t args;
- std::string fullname;
- if(mClosestAgentToCursor.notNull() && gCacheName->getFullName(mClosestAgentToCursor, fullname))
- {
- args["[AGENT]"] = fullname + "\n";
- }
- else
+
+ std::string avatar_name;
+ if(mClosestAgentToCursor.notNull() && gCacheName->getFullName(mClosestAgentToCursor, avatar_name))
{
- args["[AGENT]"] = "";
+ // only show tooltip if same inspector not already open
+ LLFloater* existing_inspector = LLFloaterReg::findInstance("inspect_avatar");
+ if (!existing_inspector
+ || !existing_inspector->getVisible()
+ || existing_inspector->getKey()["avatar_id"].asUUID() != mClosestAgentToCursor)
+ {
+ LLInspector::Params p;
+ p.fillFrom(LLUICtrlFactory::instance().getDefaultParams<LLInspector>());
+ p.message(avatar_name);
+ p.image.name("Inspector_I");
+ p.click_callback(boost::bind(showAvatarInspector, mClosestAgentToCursor));
+ p.visible_time_near(6.f);
+ p.visible_time_far(3.f);
+ p.delay_time(0.35f);
+ p.wrap(false);
+
+ LLToolTipMgr::instance().show(p);
+ }
+ return TRUE;
}
-
+
+ LLStringUtil::format_map_t args;
LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal( viewPosToGlobal( x, y ) );
if( region )
{
@@ -523,34 +602,51 @@ BOOL LLNetMap::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rec
{
args["[REGION]"] = "";
}
-
- msg = mToolTipMsg;
+
+ std::string msg = mToolTipMsg;
LLStringUtil::format(msg, args);
-
+
+ LLRect sticky_rect;
// set sticky_rect
if (region)
{
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;
+ &(sticky_rect.mLeft), &(sticky_rect.mBottom) );
+ sticky_rect.mRight = sticky_rect.mLeft + 2 * SLOP;
+ sticky_rect.mTop = sticky_rect.mBottom + 2 * SLOP;
}
-
- handled = TRUE;
- return handled;
+
+ LLToolTipMgr::instance().show(LLToolTip::Params()
+ .message(msg)
+ .sticky_rect(sticky_rect));
+
+ return TRUE;
}
+// static
+void LLNetMap::showAvatarInspector(const LLUUID& avatar_id)
+{
+ LLSD params;
+ params["avatar_id"] = avatar_id;
+
+ if (LLToolTipMgr::instance().toolTipVisible())
+ {
+ LLRect rect = LLToolTipMgr::instance().getToolTipRect();
+ params["pos"]["x"] = rect.mLeft;
+ params["pos"]["y"] = rect.mTop;
+ }
+
+ LLFloaterReg::showInstance("inspect_avatar", params);
+}
void LLNetMap::renderScaledPointGlobal( const LLVector3d& pos, const LLColor4U &color, F32 radius_meters )
{
LLVector3 local_pos;
local_pos.setVec( pos - mObjectImageCenterGlobal );
- F32 radius_clamped = llmin(radius_meters, MAX_PRIM_RADIUS);
-
- S32 diameter_pixels = llround(2 * radius_clamped * mObjectMapTPM);
+ S32 diameter_pixels = llround(2 * radius_meters * mObjectMapTPM);
renderPoint( local_pos, color, diameter_pixels );
}
@@ -643,13 +739,13 @@ void LLNetMap::renderPoint(const LLVector3 &pos_local, const LLColor4U &color,
void LLNetMap::createObjectImage()
{
// Find the size of the side of a square that surrounds the circle that surrounds getRect().
- F32 half_width = (F32)(getRect().getWidth() / 2);
- F32 half_height = (F32)(getRect().getHeight() / 2);
- F32 radius = sqrt( half_width * half_width + half_height * half_height );
- S32 square_size = S32( 2 * radius );
+ // ... which is, the diagonal of the rect.
+ F32 width = (F32)getRect().getWidth();
+ F32 height = (F32)getRect().getHeight();
+ S32 square_size = llround( sqrt(width*width + height*height) );
// Find the least power of two >= the minimum size.
- const S32 MIN_SIZE = 32;
+ const S32 MIN_SIZE = 64;
const S32 MAX_SIZE = 256;
S32 img_size = MIN_SIZE;
while( (img_size*2 < square_size ) && (img_size < MAX_SIZE) )
@@ -664,8 +760,102 @@ void LLNetMap::createObjectImage()
mObjectRawImagep = new LLImageRaw(img_size, img_size, 4);
U8* data = mObjectRawImagep->getData();
memset( data, 0, img_size * img_size * 4 );
- mObjectImagep = new LLImageGL( mObjectRawImagep, FALSE);
- setScale(mScale);
+ mObjectImagep = LLViewerTextureManager::getLocalTexture( mObjectRawImagep.get(), FALSE);
+ }
+ setScale(mScale);
+ mUpdateNow = true;
+}
+
+BOOL LLNetMap::handleMouseDown( S32 x, S32 y, MASK mask )
+{
+ if (!(mask & MASK_SHIFT)) return FALSE;
+
+ // Start panning
+ gFocusMgr.setMouseCapture(this);
+
+ mStartPan = mCurPan;
+ mMouseDown.mX = x;
+ mMouseDown.mY = y;
+ return TRUE;
+}
+
+BOOL LLNetMap::handleMouseUp( S32 x, S32 y, MASK 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::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;
}
- mUpdateNow = TRUE;
+ return FALSE;
+}
+
+// static
+bool LLNetMap::outsideSlop( S32 x, S32 y, S32 start_x, S32 start_y, S32 slop )
+{
+ S32 dx = x - start_x;
+ S32 dy = y - start_y;
+
+ return (dx <= -slop || slop <= dx || dy <= -slop || slop <= dy);
+}
+
+BOOL LLNetMap::handleHover( S32 x, S32 y, MASK mask )
+{
+ if (hasMouseCapture())
+ {
+ if (mPanning || outsideSlop(x, y, mMouseDown.mX, mMouseDown.mY, MOUSE_DRAG_SLOP))
+ {
+ if (!mPanning)
+ {
+ // just started panning, so hide cursor
+ mPanning = true;
+ gViewerWindow->hideCursor();
+ }
+
+ LLVector2 delta(static_cast<F32>(gViewerWindow->getCurrentMouseDX()),
+ static_cast<F32>(gViewerWindow->getCurrentMouseDY()));
+
+ // 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 );
+ }
+ }
+
+ return TRUE;
}