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.cpp109
1 files changed, 100 insertions, 9 deletions
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp
index 1b7ad6ab7e..ff713d74ad 100644
--- a/indra/newview/lllocationinputctrl.cpp
+++ b/indra/newview/lllocationinputctrl.cpp
@@ -176,7 +176,9 @@ private:
static LLDefaultChildRegistry::Register<LLLocationInputCtrl> r("location_input");
LLLocationInputCtrl::Params::Params()
-: add_landmark_image_enabled("add_landmark_image_enabled"),
+: icon_maturity_general("icon_maturity_general"),
+ icon_maturity_adult("icon_maturity_adult"),
+ add_landmark_image_enabled("add_landmark_image_enabled"),
add_landmark_image_disabled("add_landmark_image_disabled"),
add_landmark_image_hover("add_landmark_image_hover"),
add_landmark_image_selected("add_landmark_image_selected"),
@@ -185,6 +187,7 @@ LLLocationInputCtrl::Params::Params()
add_landmark_button("add_landmark_button"),
for_sale_button("for_sale_button"),
info_button("info_button"),
+ maturity_icon("maturity_icon"),
voice_icon("voice_icon"),
fly_icon("fly_icon"),
push_icon("push_icon"),
@@ -204,7 +207,9 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p)
mForSaleBtn(NULL),
mInfoBtn(NULL),
mLandmarkImageOn(NULL),
- mLandmarkImageOff(NULL)
+ mLandmarkImageOff(NULL),
+ mIconMaturityGeneral(NULL),
+ mIconMaturityAdult(NULL)
{
// Lets replace default LLLineEditor with LLLocationLineEditor
// to make needed escaping while copying and cutting url
@@ -264,7 +269,20 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p)
mAddLandmarkBtn = LLUICtrlFactory::create<LLButton>(al_params);
enableAddLandmarkButton(true);
addChild(mAddLandmarkBtn);
-
+
+ if (p.icon_maturity_general())
+ {
+ mIconMaturityGeneral = p.icon_maturity_general;
+ }
+ if (p.icon_maturity_adult())
+ {
+ mIconMaturityAdult = p.icon_maturity_adult;
+ }
+
+ LLIconCtrl::Params maturity_icon = p.maturity_icon;
+ mMaturityIcon = LLUICtrlFactory::create<LLIconCtrl>(maturity_icon);
+ addChild(mMaturityIcon);
+
LLButton::Params for_sale_button = p.for_sale_button;
for_sale_button.tool_tip = LLTrans::getString("LocationCtrlForSaleTooltip");
for_sale_button.click_callback.function(
@@ -522,6 +540,25 @@ void LLLocationInputCtrl::draw()
LLComboBox::draw();
}
+void LLLocationInputCtrl::reshape(S32 width, S32 height, BOOL called_from_parent)
+{
+ LLComboBox::reshape(width, height, called_from_parent);
+
+ // Setting cursor to 0 to show the left edge of the text. See EXT-4967.
+ mTextEntry->setCursor(0);
+ if (mTextEntry->hasSelection())
+ {
+ // Deselecting because selection position is changed together with
+ // cursor position change.
+ mTextEntry->deselect();
+ }
+
+ if (isHumanReadableLocationVisible)
+ {
+ positionMaturityIcon();
+ }
+}
+
void LLLocationInputCtrl::onInfoButtonClicked()
{
LLSideTray::getInstance()->showPanel("panel_places", LLSD().with("type", "agent"));
@@ -672,6 +709,34 @@ void LLLocationInputCtrl::refreshLocation()
// store human-readable location to compare it in changeLocationPresentation()
mHumanReadableLocation = location_name;
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();
+ }
}
// returns new right edge
@@ -692,7 +757,7 @@ void LLLocationInputCtrl::refreshParcelIcons()
{
// Our "cursor" moving right to left
S32 x = mAddLandmarkBtn->getRect().mLeft;
-
+
static LLUICachedControl<bool> show_properties("NavBarShowParcelProperties", false);
if (show_properties)
{
@@ -762,7 +827,7 @@ void LLLocationInputCtrl::refreshParcelIcons()
}
mDamageText->setVisible(false);
}
-
+
S32 left_pad, right_pad;
mTextEntry->getTextPadding(&left_pad, &right_pad);
right_pad = mTextEntry->getRect().mRight - x;
@@ -785,6 +850,25 @@ void LLLocationInputCtrl::refreshHealth()
}
}
+void LLLocationInputCtrl::positionMaturityIcon()
+{
+ const LLFontGL* font = mTextEntry->getFont();
+ if (!font)
+ return;
+
+ S32 left_pad, right_pad;
+ mTextEntry->getTextPadding(&left_pad, &right_pad);
+
+ // Calculate the right edge of rendered text + a whitespace.
+ left_pad = left_pad + font->getWidth(mTextEntry->getText()) + font->getWidth(" ");
+
+ LLRect rect = mMaturityIcon->getRect();
+ mMaturityIcon->setRect(rect.setOriginAndSize(left_pad, rect.mBottom, rect.getWidth(), rect.getHeight()));
+
+ // Hide icon if it text area is not width enough to display it, show otherwise.
+ mMaturityIcon->setVisible(rect.mRight < mTextEntry->getRect().getWidth() - right_pad);
+}
+
void LLLocationInputCtrl::rebuildLocationHistory(std::string filter)
{
LLLocationHistory::location_list_t filtered_items;
@@ -885,16 +969,23 @@ void LLLocationInputCtrl::updateWidgetlayout()
void LLLocationInputCtrl::changeLocationPresentation()
{
- //change location presentation only if user does not select/past anything and
- //human-readable region name is being displayed
+ if (!mTextEntry)
+ return;
+
+ //change location presentation only if user does not select/paste anything and
+ //human-readable region name is being displayed
std::string text = mTextEntry->getText();
LLStringUtil::trim(text);
- if(mTextEntry && !mTextEntry->hasSelection() && text == mHumanReadableLocation )
+ if(!mTextEntry->hasSelection() && text == mHumanReadableLocation)
{
//needs unescaped one
mTextEntry->setText(LLAgentUI::buildSLURL(false));
mTextEntry->selectAll();
- }
+
+ mMaturityIcon->setVisible(FALSE);
+
+ isHumanReadableLocationVisible = false;
+ }
}
void LLLocationInputCtrl::onLocationContextMenuItemClicked(const LLSD& userdata)