summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Litovchuk <slitovchuk@productengine.com>2010-02-05 19:15:12 +0200
committerSergei Litovchuk <slitovchuk@productengine.com>2010-02-05 19:15:12 +0200
commit95147c4529f6effcd1ed0a1d427f8ddeb033670d (patch)
treea15109edf500f89263e04dfca5baf7abbdded716
parenta46a029a70ead8e09810741abaf35c53adbd2763 (diff)
Implemented critical task (EXT-4703) Add maturity icons to the Viewer 2 toolbar.
- Added maturity icons to location bar. - Added getting font used in LLLineEditor. --HG-- branch : product-engine
-rw-r--r--indra/llui/lllineeditor.h2
-rw-r--r--indra/newview/lllocationinputctrl.cpp105
-rw-r--r--indra/newview/lllocationinputctrl.h15
-rw-r--r--indra/newview/skins/default/xui/en/widgets/location_input.xml9
4 files changed, 121 insertions, 10 deletions
diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h
index a06a317f76..f275dfc45a 100644
--- a/indra/llui/lllineeditor.h
+++ b/indra/llui/lllineeditor.h
@@ -207,6 +207,8 @@ public:
const LLColor4& getReadOnlyFgColor() const { return mReadOnlyFgColor.get(); }
const LLColor4& getTentativeFgColor() const { return mTentativeFgColor.get(); }
+ const LLFontGL* getFont() const { return mGLFont; }
+
void setIgnoreArrowKeys(BOOL b) { mIgnoreArrowKeys = b; }
void setIgnoreTab(BOOL b) { mIgnoreTab = b; }
void setPassDelete(BOOL b) { mPassDelete = b; }
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp
index 1b7ad6ab7e..66cc3c6724 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()
{
+ if (!mTextEntry)
+ return;
+
//change location presentation only if user does not select/past 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)
diff --git a/indra/newview/lllocationinputctrl.h b/indra/newview/lllocationinputctrl.h
index a830b33f6f..caa62daa1b 100644
--- a/indra/newview/lllocationinputctrl.h
+++ b/indra/newview/lllocationinputctrl.h
@@ -63,7 +63,9 @@ public:
struct Params
: public LLInitParam::Block<Params, LLComboBox::Params>
{
- Optional<LLUIImage*> add_landmark_image_enabled,
+ Optional<LLUIImage*> icon_maturity_general,
+ icon_maturity_adult,
+ add_landmark_image_enabled,
add_landmark_image_disabled,
add_landmark_image_hover,
add_landmark_image_selected;
@@ -72,7 +74,8 @@ public:
Optional<LLButton::Params> add_landmark_button,
for_sale_button,
info_button;
- Optional<LLIconCtrl::Params> voice_icon,
+ Optional<LLIconCtrl::Params> maturity_icon,
+ voice_icon,
fly_icon,
push_icon,
build_icon,
@@ -89,6 +92,7 @@ public:
/*virtual*/ void onFocusReceived();
/*virtual*/ void onFocusLost();
/*virtual*/ void draw();
+ /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
//========================================================================
// LLUICtrl interface
@@ -131,6 +135,7 @@ private:
void refreshParcelIcons();
// Refresh the value in the health percentage text field
void refreshHealth();
+ void positionMaturityIcon();
void rebuildLocationHistory(std::string filter = "");
bool findTeleportItemsByTitle(const LLTeleportHistoryItem& item, const std::string& filter);
@@ -160,7 +165,8 @@ private:
LLButton* mInfoBtn;
S32 mIconHPad; // pad between all icons
S32 mAddLandmarkHPad; // pad to left of landmark star
-
+
+ LLIconCtrl* mMaturityIcon;
LLIconCtrl* mParcelIcon[ICON_COUNT];
LLTextBox* mDamageText;
@@ -172,11 +178,14 @@ private:
boost::signals2::connection mLocationHistoryConnection;
LLUIImage* mLandmarkImageOn;
LLUIImage* mLandmarkImageOff;
+ LLUIImage* mIconMaturityGeneral;
+ LLUIImage* mIconMaturityAdult;
std::string mAddLandmarkTooltip;
std::string mEditLandmarkTooltip;
// this field holds a human-readable form of the location string, it is needed to be able to compare copy-pated value and real location
std::string mHumanReadableLocation;
+ bool isHumanReadableLocationVisible;
};
#endif
diff --git a/indra/newview/skins/default/xui/en/widgets/location_input.xml b/indra/newview/skins/default/xui/en/widgets/location_input.xml
index 626135642b..1d61447e31 100644
--- a/indra/newview/skins/default/xui/en/widgets/location_input.xml
+++ b/indra/newview/skins/default/xui/en/widgets/location_input.xml
@@ -4,6 +4,8 @@
Currently that doesn't work because LLUIImage::getWidth/getHeight() return 1 for the images.
-->
<location_input font="SansSerifSmall"
+ icon_maturity_general="Parcel_PG_Light"
+ icon_maturity_adult="Parcel_R_Light"
add_landmark_image_enabled="Favorite_Star_Active"
add_landmark_image_disabled="Favorite_Star_Off"
add_landmark_image_hover="Favorite_Star_Over"
@@ -41,6 +43,13 @@
scale_image="false"
top="19"
left="-3" />
+ <maturity_icon
+ name="maturity_icon"
+ width="18"
+ height="16"
+ top="20"
+ follows="left|top"
+ />
<for_sale_button
name="for_sale_btn"
image_unselected="Parcel_ForSale_Light"