diff options
Diffstat (limited to 'indra/newview/lllocationinputctrl.cpp')
-rw-r--r-- | indra/newview/lllocationinputctrl.cpp | 74 |
1 files changed, 53 insertions, 21 deletions
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index 4e0be81f62..7abb4f4f16 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -38,6 +38,7 @@ // common includes #include "llbutton.h" #include "llfocusmgr.h" +#include "llhelp.h" #include "llmenugl.h" #include "llparcel.h" #include "llstring.h" @@ -177,6 +178,7 @@ static LLDefaultChildRegistry::Register<LLLocationInputCtrl> r("location_input") LLLocationInputCtrl::Params::Params() : icon_maturity_general("icon_maturity_general"), icon_maturity_adult("icon_maturity_adult"), + icon_maturity_moderate("icon_maturity_moderate"), add_landmark_image_enabled("add_landmark_image_enabled"), add_landmark_image_disabled("add_landmark_image_disabled"), add_landmark_image_hover("add_landmark_image_hover"), @@ -186,14 +188,15 @@ LLLocationInputCtrl::Params::Params() add_landmark_button("add_landmark_button"), for_sale_button("for_sale_button"), info_button("info_button"), - maturity_icon("maturity_icon"), + maturity_button("maturity_button"), voice_icon("voice_icon"), fly_icon("fly_icon"), push_icon("push_icon"), build_icon("build_icon"), scripts_icon("scripts_icon"), damage_icon("damage_icon"), - damage_text("damage_text") + damage_text("damage_text"), + maturity_help_topic("maturity_help_topic") { } @@ -208,7 +211,9 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) mLandmarkImageOn(NULL), mLandmarkImageOff(NULL), mIconMaturityGeneral(NULL), - mIconMaturityAdult(NULL) + mIconMaturityAdult(NULL), + mIconMaturityModerate(NULL), + mMaturityHelpTopic(p.maturity_help_topic) { // Lets replace default LLLineEditor with LLLocationLineEditor // to make needed escaping while copying and cutting url @@ -276,10 +281,15 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) { mIconMaturityAdult = p.icon_maturity_adult; } + if(p.icon_maturity_moderate()) + { + mIconMaturityModerate = p.icon_maturity_moderate; + } - LLIconCtrl::Params maturity_icon = p.maturity_icon; - mMaturityIcon = LLUICtrlFactory::create<LLIconCtrl>(maturity_icon); - addChild(mMaturityIcon); + LLButton::Params maturity_button = p.maturity_button; + mMaturityButton = LLUICtrlFactory::create<LLButton>(maturity_button); + addChild(mMaturityButton); + mMaturityButton->setClickedCallback(boost::bind(&LLLocationInputCtrl::onMaturityButtonClicked, this)); LLButton::Params for_sale_button = p.for_sale_button; for_sale_button.tool_tip = LLTrans::getString("LocationCtrlForSaleTooltip"); @@ -576,7 +586,7 @@ void LLLocationInputCtrl::reshape(S32 width, S32 height, BOOL called_from_parent if (isHumanReadableLocationVisible) { - refreshMaturityIcon(); + refreshMaturityButton(); } } @@ -613,6 +623,11 @@ void LLLocationInputCtrl::onAgentParcelChange() refresh(); } +void LLLocationInputCtrl::onMaturityButtonClicked() +{ + LLUI::sHelpImpl->showTopic(mMaturityHelpTopic); +} + void LLLocationInputCtrl::onLandmarkLoaded(LLLandmark* lm) { (void) lm; @@ -736,7 +751,7 @@ void LLLocationInputCtrl::refreshLocation() setText(location_name); isHumanReadableLocationVisible = true; - refreshMaturityIcon(); + refreshMaturityButton(); } // returns new right edge @@ -852,37 +867,54 @@ void LLLocationInputCtrl::refreshHealth() } } -void LLLocationInputCtrl::refreshMaturityIcon() +void LLLocationInputCtrl::refreshMaturityButton() { // Updating maturity rating icon. LLViewerRegion* region = gAgent.getRegion(); if (!region) return; + bool button_visible = true; + LLPointer<LLUIImage> rating_image = NULL; + std::string rating_tooltip; + U8 sim_access = region->getSimAccess(); switch(sim_access) { case SIM_ACCESS_PG: - mMaturityIcon->setValue(mIconMaturityGeneral->getName()); - mMaturityIcon->setVisible(TRUE); + rating_image = mIconMaturityGeneral; + rating_tooltip = LLTrans::getString("LocationCtrlGeneralIconTooltip"); break; case SIM_ACCESS_ADULT: - mMaturityIcon->setValue(mIconMaturityAdult->getName()); - mMaturityIcon->setVisible(TRUE); + rating_image = mIconMaturityAdult; + rating_tooltip = LLTrans::getString("LocationCtrlAdultIconTooltip"); + break; + + case SIM_ACCESS_MATURE: + rating_image = mIconMaturityModerate; + rating_tooltip = LLTrans::getString("LocationCtrlModerateIconTooltip"); break; default: - mMaturityIcon->setVisible(FALSE); + button_visible = false; + break; } - if (mMaturityIcon->getVisible()) + mMaturityButton->setVisible(button_visible); + mMaturityButton->setToolTip(rating_tooltip); + if(rating_image) + { + mMaturityButton->setImageUnselected(rating_image); + mMaturityButton->setImagePressed(rating_image); + } + if (mMaturityButton->getVisible()) { - positionMaturityIcon(); + positionMaturityButton(); } } -void LLLocationInputCtrl::positionMaturityIcon() +void LLLocationInputCtrl::positionMaturityButton() { const LLFontGL* font = mTextEntry->getFont(); if (!font) @@ -894,11 +926,11 @@ void LLLocationInputCtrl::positionMaturityIcon() // 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())); + LLRect rect = mMaturityButton->getRect(); + mMaturityButton->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); + mMaturityButton->setVisible(rect.mRight < mTextEntry->getRect().getWidth() - right_pad); } void LLLocationInputCtrl::rebuildLocationHistory(const std::string& filter) @@ -1014,7 +1046,7 @@ void LLLocationInputCtrl::changeLocationPresentation() mTextEntry->setText(LLAgentUI::buildSLURL(false)); mTextEntry->selectAll(); - mMaturityIcon->setVisible(FALSE); + mMaturityButton->setVisible(FALSE); isHumanReadableLocationVisible = false; } |