diff options
Diffstat (limited to 'indra/newview/lllocationinputctrl.cpp')
-rw-r--r-- | indra/newview/lllocationinputctrl.cpp | 203 |
1 files changed, 162 insertions, 41 deletions
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index 0e93e28f2d..f8f9ea7379 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 @@ -227,6 +232,7 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) params.commit_on_focus_lost(false); params.follows.flags(FOLLOWS_ALL); mTextEntry = LLUICtrlFactory::create<LLURLLineEditor>(params); + mTextEntry->setContextMenu(NULL); addChild(mTextEntry); // LLLineEditor is replaced with LLLocationLineEditor @@ -263,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( @@ -339,6 +358,20 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) getTextEntry()->setRightMouseUpCallback(boost::bind(&LLLocationInputCtrl::onTextEditorRightClicked,this,_2,_3,_4)); updateWidgetlayout(); + // Connecting signal for updating location on "Show Coordinates" setting change. + LLControlVariable* coordinates_control = gSavedSettings.getControl("NavBarShowCoordinates").get(); + if (coordinates_control) + { + mCoordinatesControlConnection = coordinates_control->getSignal()->connect(boost::bind(&LLLocationInputCtrl::refreshLocation, this)); + } + + // Connecting signal for updating parcel icons on "Show Parcel Properties" setting change. + LLControlVariable* parcel_properties_control = gSavedSettings.getControl("NavBarShowParcelProperties").get(); + if (parcel_properties_control) + { + mParcelPropertiesControlConnection = parcel_properties_control->getSignal()->connect(boost::bind(&LLLocationInputCtrl::refreshParcelIcons, this)); + } + // - Make the "Add landmark" button updated when either current parcel gets changed // or a landmark gets created or removed from the inventory. // - Update the location string on parcel change. @@ -372,6 +405,8 @@ LLLocationInputCtrl::~LLLocationInputCtrl() LLViewerParcelMgr::getInstance()->removeObserver(mParcelChangeObserver); delete mParcelChangeObserver; + mCoordinatesControlConnection.disconnect(); + mParcelPropertiesControlConnection.disconnect(); mParcelMgrConnection.disconnect(); mLocationHistoryConnection.disconnect(); } @@ -470,7 +505,10 @@ void LLLocationInputCtrl::onTextEntry(LLLineEditor* line_editor) */ void LLLocationInputCtrl::setText(const LLStringExplicit& text) { - mTextEntry->setText(text); + if (mTextEntry) + { + mTextEntry->setText(text); + } mHasAutocompletedText = FALSE; } @@ -479,7 +517,9 @@ void LLLocationInputCtrl::setFocus(BOOL b) LLComboBox::setFocus(b); if (mTextEntry && b && !mList->getVisible()) + { mTextEntry->setFocus(TRUE); + } } void LLLocationInputCtrl::handleLoginComplete() @@ -521,6 +561,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")); @@ -605,7 +664,7 @@ void LLLocationInputCtrl::onLocationPrearrange(const LLSD& data) value["item_type"] = TELEPORT_HISTORY; value["global_pos"] = result->mGlobalPos.getValue(); std::string region_name = result->mTitle.substr(0, result->mTitle.find(',')); - //TODO*: add Surl to teleportitem or parse region name from title + //TODO*: add slurl to teleportitem or parse region name from title value["tooltip"] = LLSLURL::buildSLURLfromPosGlobal(region_name, result->mGlobalPos, false); add(result->getTitle(), value); @@ -615,6 +674,15 @@ void LLLocationInputCtrl::onLocationPrearrange(const LLSD& data) _1, filter)); } } + if(mList->isEmpty()) + { + /** + * Add a couple of empty items for a better view. + * EXT-5194 + */ + for(int i = 0; i < NUMBER_OF_EMPTY_ITEMS; i++ ) + add("", LLSD()); + } sortByName(); mList->mouseOverHighlightNthItem(-1); // Clear highlight on the last selected item. @@ -650,8 +718,8 @@ void LLLocationInputCtrl::refreshLocation() { // Is one of our children focused? if (LLUICtrl::hasFocus() || mButton->hasFocus() || mList->hasFocus() || - (mTextEntry && mTextEntry->hasFocus()) || (mAddLandmarkBtn->hasFocus())) - + (mTextEntry && mTextEntry->hasFocus()) || + (mAddLandmarkBtn->hasFocus())) { llwarns << "Location input should not be refreshed when having focus" << llendl; return; @@ -671,6 +739,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 @@ -691,17 +787,20 @@ void LLLocationInputCtrl::refreshParcelIcons() { // Our "cursor" moving right to left S32 x = mAddLandmarkBtn->getRect().mLeft; - - static LLUICachedControl<bool> show_properties("NavBarShowParcelProperties", false); - if (show_properties) - { - LLViewerParcelMgr* vpm = LLViewerParcelMgr::getInstance(); - LLViewerRegion* agent_region = gAgent.getRegion(); - LLParcel* agent_parcel = vpm->getAgentParcel(); - if (!agent_region || !agent_parcel) - return; + LLViewerParcelMgr* vpm = LLViewerParcelMgr::getInstance(); + + LLViewerRegion* agent_region = gAgent.getRegion(); + LLParcel* agent_parcel = vpm->getAgentParcel(); + if (!agent_region || !agent_parcel) + return; + + mForSaleBtn->setVisible(vpm->canAgentBuyParcel(agent_parcel, false)); + x = layout_widget(mForSaleBtn, x); + + if (gSavedSettings.getBOOL("NavBarShowParcelProperties")) + { LLParcel* current_parcel; LLViewerRegion* selection_region = vpm->getSelectionRegion(); LLParcel* selected_parcel = vpm->getParcelSelection()->getParcel(); @@ -721,18 +820,14 @@ void LLLocationInputCtrl::refreshParcelIcons() current_parcel = agent_parcel; } - bool allow_buy = vpm->canAgentBuyParcel(current_parcel, false); - bool allow_voice = agent_region->isVoiceEnabled() && current_parcel->getParcelFlagAllowVoice(); - bool allow_fly = !agent_region->getBlockFly() && current_parcel->getAllowFly(); - bool allow_push = !agent_region->getRestrictPushObject() && !current_parcel->getRestrictPushObject(); - bool allow_build = current_parcel->getAllowModify(); // true when anyone is allowed to build. See EXT-4610. - bool allow_scripts = !(agent_region->getRegionFlags() & REGION_FLAGS_SKIP_SCRIPTS) && - !(agent_region->getRegionFlags() & REGION_FLAGS_ESTATE_SKIP_SCRIPTS) && - current_parcel->getAllowOtherScripts(); - bool allow_damage = agent_region->getAllowDamage() || current_parcel->getAllowDamage(); + bool allow_voice = vpm->allowAgentVoice(agent_region, current_parcel); + bool allow_fly = vpm->allowAgentFly(agent_region, current_parcel); + bool allow_push = vpm->allowAgentPush(agent_region, current_parcel); + bool allow_build = vpm->allowAgentBuild(current_parcel); // true when anyone is allowed to build. See EXT-4610. + bool allow_scripts = vpm->allowAgentScripts(agent_region, current_parcel); + bool allow_damage = vpm->allowAgentDamage(agent_region, current_parcel); // Most icons are "block this ability" - mForSaleBtn->setVisible(allow_buy); mParcelIcon[VOICE_ICON]->setVisible( !allow_voice ); mParcelIcon[FLY_ICON]->setVisible( !allow_fly ); mParcelIcon[PUSH_ICON]->setVisible( !allow_push ); @@ -740,11 +835,10 @@ void LLLocationInputCtrl::refreshParcelIcons() mParcelIcon[SCRIPTS_ICON]->setVisible( !allow_scripts ); mParcelIcon[DAMAGE_ICON]->setVisible( allow_damage ); mDamageText->setVisible(allow_damage); - - x = layout_widget(mForSaleBtn, x); + // Padding goes to left of both landmark star and for sale btn x -= mAddLandmarkHPad; - + // Slide the parcel icons rect from right to left, adjusting rectangles for (S32 i = 0; i < ICON_COUNT; ++i) { @@ -756,18 +850,20 @@ void LLLocationInputCtrl::refreshParcelIcons() } else { - mForSaleBtn->setVisible(false); for (S32 i = 0; i < ICON_COUNT; ++i) { mParcelIcon[i]->setVisible(false); } mDamageText->setVisible(false); } - - S32 left_pad, right_pad; - mTextEntry->getTextPadding(&left_pad, &right_pad); - right_pad = mTextEntry->getRect().mRight - x; - mTextEntry->setTextPadding(left_pad, right_pad); + + if (mTextEntry) + { + S32 left_pad, right_pad; + mTextEntry->getTextPadding(&left_pad, &right_pad); + right_pad = mTextEntry->getRect().mRight - x; + mTextEntry->setTextPadding(left_pad, right_pad); + } } void LLLocationInputCtrl::refreshHealth() @@ -786,6 +882,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; @@ -808,7 +923,7 @@ void LLLocationInputCtrl::rebuildLocationHistory(std::string filter) LLSD value; value["tooltip"] = it->getToolTip(); //location history can contain only typed locations - value["item_type"] = TYPED_REGION_SURL; + value["item_type"] = TYPED_REGION_SLURL; value["global_pos"] = it->mGlobalPos.getValue(); add(it->getLocation(), value); } @@ -886,16 +1001,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) @@ -910,7 +1032,6 @@ void LLLocationInputCtrl::onLocationContextMenuItemClicked(const LLSD& userdata) { gSavedSettings.setBOOL("NavBarShowParcelProperties", !gSavedSettings.getBOOL("NavBarShowParcelProperties")); - refreshParcelIcons(); } else if (item == "landmark") { |