summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatermap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloatermap.cpp')
-rw-r--r--indra/newview/llfloatermap.cpp157
1 files changed, 118 insertions, 39 deletions
diff --git a/indra/newview/llfloatermap.cpp b/indra/newview/llfloatermap.cpp
index 6660650c56..a1d291fea6 100644
--- a/indra/newview/llfloatermap.cpp
+++ b/indra/newview/llfloatermap.cpp
@@ -2,35 +2,28 @@
* @file llfloatermap.cpp
* @brief The "mini-map" or radar in the upper right part of the screen.
*
- * $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.
+ *
+ * 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.
*
- * 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 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.
*
- * 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.
+ * 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
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-#include <string>
#include "llviewerprecompiledheaders.h"
// self include
@@ -42,7 +35,7 @@
#include "llglheaders.h"
// Viewer includes
-#include "llagent.h"
+#include "llagentcamera.h"
#include "llviewercontrol.h"
#include "llnetmap.h"
#include "lltracker.h"
@@ -54,18 +47,31 @@
//
// Constants
//
-const F32 MAP_SCALE_MIN = 64;
-const F32 MAP_SCALE_MID = 172;
-const F32 MAP_SCALE_MAX = 512;
+// The minor cardinal direction labels are hidden if their height is more
+// than this proportion of the map.
+const F32 MAP_MINOR_DIR_THRESHOLD = 0.07f;
+const S32 MAP_PADDING_LEFT = 0;
+const S32 MAP_PADDING_TOP = 2;
+const S32 MAP_PADDING_RIGHT = 2;
+const S32 MAP_PADDING_BOTTOM = 0;
//
// Member functions
//
LLFloaterMap::LLFloaterMap(const LLSD& key)
- : LLFloater(key)
+ : LLFloater(key),
+ mPopupMenu(NULL),
+ mTextBoxEast(NULL),
+ mTextBoxNorth(NULL),
+ mTextBoxWest(NULL),
+ mTextBoxSouth(NULL),
+ mTextBoxSouthEast(NULL),
+ mTextBoxNorthEast(NULL),
+ mTextBoxNorthWest(NULL),
+ mTextBoxSouthWest(NULL),
+ mMap(NULL)
{
- //Called from floater reg: LLUICtrlFactory::getInstance()->buildFloater(this, "floater_map.xml", FALSE);
}
LLFloaterMap::~LLFloaterMap()
@@ -76,7 +82,6 @@ BOOL LLFloaterMap::postBuild()
{
mMap = getChild<LLNetMap>("Net Map");
mMap->setScale(gSavedSettings.getF32("MiniMapScale"));
- mMap->setRotateMap(gSavedSettings.getBOOL( "MiniMapRotate" ));
mMap->setToolTipMsg(getString("ToolTipMsg"));
sendChildToBack(mMap);
@@ -94,16 +99,22 @@ BOOL LLFloaterMap::postBuild()
registrar.add("Minimap.Zoom", boost::bind(&LLFloaterMap::handleZoom, this, _2));
registrar.add("Minimap.Tracker", boost::bind(&LLFloaterMap::handleStopTracking, this, _2));
- mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_minimap.xml", gMenuHolder);
+ mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_mini_map.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
if (mPopupMenu && !LLTracker::isTracking(0))
{
mPopupMenu->setItemEnabled ("Stop Tracking", false);
}
+ stretchMiniMap(getRect().getWidth() - MAP_PADDING_LEFT - MAP_PADDING_RIGHT
+ ,getRect().getHeight() - MAP_PADDING_TOP - MAP_PADDING_BOTTOM);
+
+ updateMinorDirections();
+
// Get the drag handle all the way in back
sendChildToBack(getDragHandle());
setIsChrome(TRUE);
+ getDragHandle()->setTitleVisible(TRUE);
// keep onscreen
gFloaterView->adjustToFitScreen(this, FALSE);
@@ -113,7 +124,9 @@ BOOL LLFloaterMap::postBuild()
BOOL LLFloaterMap::handleDoubleClick( S32 x, S32 y, MASK mask )
{
- LLFloaterReg::showInstance("world_map");
+ // If floater is minimized, minimap should be shown on doubleclick (STORM-299)
+ std::string floater_to_show = this->isMinimized() ? "mini_map" : "world_map";
+ LLFloaterReg::showInstance(floater_to_show);
return TRUE;
}
@@ -133,8 +146,8 @@ void LLFloaterMap::setDirectionPos( LLTextBox* text_box, F32 rotation )
// Rotation is in radians.
// Rotation of 0 means x = 1, y = 0 on the unit circle.
- F32 map_half_height = (F32)(getRect().getHeight() / 2);
- F32 map_half_width = (F32)(getRect().getWidth() / 2);
+ F32 map_half_height = (F32)(getRect().getHeight() / 2) - getHeaderHeight()/2;
+ F32 map_half_width = (F32)(getRect().getWidth() / 2) ;
F32 text_half_height = (F32)(text_box->getRect().getHeight() / 2);
F32 text_half_width = (F32)(text_box->getRect().getWidth() / 2);
F32 radius = llmin( map_half_height - text_half_height, map_half_width - text_half_width );
@@ -147,12 +160,30 @@ void LLFloaterMap::setDirectionPos( LLTextBox* text_box, F32 rotation )
llround(map_half_height - text_half_height + radius * sin( rotation )) );
}
+void LLFloaterMap::updateMinorDirections()
+{
+ if (mTextBoxNorthEast == NULL)
+ {
+ return;
+ }
+
+ // Hide minor directions if they cover too much of the map
+ bool show_minors = mTextBoxNorthEast->getRect().getHeight() < MAP_MINOR_DIR_THRESHOLD *
+ llmin(getRect().getWidth(), getRect().getHeight());
+
+ mTextBoxNorthEast->setVisible(show_minors);
+ mTextBoxNorthWest->setVisible(show_minors);
+ mTextBoxSouthWest->setVisible(show_minors);
+ mTextBoxSouthEast->setVisible(show_minors);
+}
+
// virtual
void LLFloaterMap::draw()
{
F32 rotation = 0;
- if( mMap->getRotateMap() )
+ 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 LLFloaterMap::draw()
setDirectionPos( mTextBoxSouthEast, rotation + F_PI + F_PI_BY_TWO + F_PI_BY_TWO / 2);
// Note: we can't just gAgent.check cameraMouselook() because the transition states are wrong.
- if( gAgent.cameraMouselook())
+ if(gAgentCamera.cameraMouselook())
{
setMouseOpaque(FALSE);
getDragHandle()->setMouseOpaque(FALSE);
@@ -188,17 +219,54 @@ void LLFloaterMap::draw()
LLFloater::draw();
}
+// virtual
+void LLFloaterMap::onFocusReceived()
+{
+ setBackgroundOpaque(true);
+ LLPanel::onFocusReceived();
+}
+
+// virtual
+void LLFloaterMap::onFocusLost()
+{
+ setBackgroundOpaque(false);
+ LLPanel::onFocusLost();
+}
+
+void LLFloaterMap::stretchMiniMap(S32 width,S32 height)
+{
+ //fix for ext-7112
+ //by default ctrl can't overlap caption area
+ if(mMap)
+ {
+ LLRect map_rect;
+ map_rect.setLeftTopAndSize( MAP_PADDING_LEFT, getRect().getHeight() - MAP_PADDING_TOP, width, height);
+ mMap->reshape( width, height, 1);
+ mMap->setRect(map_rect);
+ }
+}
+
+void LLFloaterMap::reshape(S32 width, S32 height, BOOL called_from_parent)
+{
+ LLFloater::reshape(width, height, called_from_parent);
+
+ stretchMiniMap(width - MAP_PADDING_LEFT - MAP_PADDING_RIGHT
+ ,height - MAP_PADDING_TOP - MAP_PADDING_BOTTOM);
+
+ updateMinorDirections();
+}
+
void LLFloaterMap::handleZoom(const LLSD& userdata)
{
std::string level = userdata.asString();
F32 scale = 0.0f;
if (level == std::string("close"))
- scale = MAP_SCALE_MAX;
+ scale = LLNetMap::MAP_SCALE_MAX;
else if (level == std::string("medium"))
- scale = MAP_SCALE_MID;
+ scale = LLNetMap::MAP_SCALE_MID;
else if (level == std::string("far"))
- scale = MAP_SCALE_MIN;
+ scale = LLNetMap::MAP_SCALE_MIN;
if (scale != 0.0f)
{
gSavedSettings.setF32("MiniMapScale", scale );
@@ -214,4 +282,15 @@ void LLFloaterMap::handleStopTracking (const LLSD& userdata)
LLTracker::stopTracking ((void*)LLTracker::isTracking(NULL));
}
}
-
+void LLFloaterMap::setMinimized(BOOL b)
+{
+ LLFloater::setMinimized(b);
+ if(b)
+ {
+ setTitle(getString("mini_map_caption"));
+ }
+ else
+ {
+ setTitle("");
+ }
+}