summaryrefslogtreecommitdiff
path: root/indra/newview/lllocationinputctrl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lllocationinputctrl.cpp')
-rw-r--r--indra/newview/lllocationinputctrl.cpp80
1 files changed, 45 insertions, 35 deletions
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp
index 2e1f01eca1..b6e793522a 100644
--- a/indra/newview/lllocationinputctrl.cpp
+++ b/indra/newview/lllocationinputctrl.cpp
@@ -52,7 +52,6 @@
#include "llinventoryobserver.h"
#include "lllandmarkactions.h"
#include "lllandmarklist.h"
-#include "lllocationhistory.h"
#include "llteleporthistory.h"
#include "llsidetray.h"
#include "llslurl.h"
@@ -377,9 +376,10 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p)
// - Update the location string on parcel change.
mParcelMgrConnection = LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(
boost::bind(&LLLocationInputCtrl::onAgentParcelChange, this));
-
- mLocationHistoryConnection = LLLocationHistory::getInstance()->setLoadedCallback(
- boost::bind(&LLLocationInputCtrl::onLocationHistoryLoaded, this));
+ // LLLocationHistory instance is being created before the location input control, so we have to update initial state of button manually.
+ mButton->setEnabled(LLLocationHistory::instance().getItemCount() > 0);
+ mLocationHistoryConnection = LLLocationHistory::getInstance()->setChangedCallback(
+ boost::bind(&LLLocationInputCtrl::onLocationHistoryChanged, this,_1));
mRemoveLandmarkObserver = new LLRemoveLandmarkObserver(this);
mAddLandmarkObserver = new LLAddLandmarkObserver(this);
@@ -473,6 +473,7 @@ BOOL LLLocationInputCtrl::handleKeyHere(KEY key, MASK mask)
void LLLocationInputCtrl::onTextEntry(LLLineEditor* line_editor)
{
KEY key = gKeyboard->currentKey();
+ MASK mask = gKeyboard->currentMask(TRUE);
if (line_editor->getText().empty())
{
@@ -480,7 +481,7 @@ void LLLocationInputCtrl::onTextEntry(LLLineEditor* line_editor)
hideList();
}
// Typing? (moving cursor should not affect showing the list)
- else if (key != KEY_LEFT && key != KEY_RIGHT && key != KEY_HOME && key != KEY_END)
+ else if (mask != MASK_CONTROL && key != KEY_LEFT && key != KEY_RIGHT && key != KEY_HOME && key != KEY_END)
{
prearrangeList(line_editor->getText());
if (mList->getItemCount() != 0)
@@ -576,7 +577,7 @@ void LLLocationInputCtrl::reshape(S32 width, S32 height, BOOL called_from_parent
if (isHumanReadableLocationVisible)
{
- positionMaturityIcon();
+ refreshMaturityIcon();
}
}
@@ -619,9 +620,13 @@ void LLLocationInputCtrl::onLandmarkLoaded(LLLandmark* lm)
updateAddLandmarkButton();
}
-void LLLocationInputCtrl::onLocationHistoryLoaded()
+void LLLocationInputCtrl::onLocationHistoryChanged(LLLocationHistory::EChangeType event)
{
- rebuildLocationHistory();
+ if(event == LLLocationHistory::LOAD)
+ {
+ rebuildLocationHistory();
+ }
+ mButton->setEnabled(LLLocationHistory::instance().getItemCount() > 0);
}
void LLLocationInputCtrl::onLocationPrearrange(const LLSD& data)
@@ -731,32 +736,7 @@ void LLLocationInputCtrl::refreshLocation()
setText(location_name);
isHumanReadableLocationVisible = true;
- // Updating maturity rating icon.
- LLViewerRegion* region = gAgent.getRegion();
- if (!region)
- return;
-
- U8 sim_access = region->getSimAccess();
- switch(sim_access)
- {
- case SIM_ACCESS_PG:
- mMaturityIcon->setValue(mIconMaturityGeneral->getName());
- mMaturityIcon->setVisible(TRUE);
- break;
-
- case SIM_ACCESS_ADULT:
- mMaturityIcon->setValue(mIconMaturityAdult->getName());
- mMaturityIcon->setVisible(TRUE);
- break;
-
- default:
- mMaturityIcon->setVisible(FALSE);
- }
-
- if (mMaturityIcon->getVisible())
- {
- positionMaturityIcon();
- }
+ refreshMaturityIcon();
}
// returns new right edge
@@ -872,6 +852,36 @@ void LLLocationInputCtrl::refreshHealth()
}
}
+void LLLocationInputCtrl::refreshMaturityIcon()
+{
+ // Updating maturity rating icon.
+ LLViewerRegion* region = gAgent.getRegion();
+ if (!region)
+ return;
+
+ U8 sim_access = region->getSimAccess();
+ switch(sim_access)
+ {
+ case SIM_ACCESS_PG:
+ mMaturityIcon->setValue(mIconMaturityGeneral->getName());
+ mMaturityIcon->setVisible(TRUE);
+ break;
+
+ case SIM_ACCESS_ADULT:
+ mMaturityIcon->setValue(mIconMaturityAdult->getName());
+ mMaturityIcon->setVisible(TRUE);
+ break;
+
+ default:
+ mMaturityIcon->setVisible(FALSE);
+ }
+
+ if (mMaturityIcon->getVisible())
+ {
+ positionMaturityIcon();
+ }
+}
+
void LLLocationInputCtrl::positionMaturityIcon()
{
const LLFontGL* font = mTextEntry->getFont();
@@ -891,7 +901,7 @@ void LLLocationInputCtrl::positionMaturityIcon()
mMaturityIcon->setVisible(rect.mRight < mTextEntry->getRect().getWidth() - right_pad);
}
-void LLLocationInputCtrl::rebuildLocationHistory(std::string filter)
+void LLLocationInputCtrl::rebuildLocationHistory(const std::string& filter)
{
LLLocationHistory::location_list_t filtered_items;
const LLLocationHistory::location_list_t* itemsp = NULL;