diff options
Diffstat (limited to 'indra/newview/lllocationinputctrl.cpp')
-rw-r--r-- | indra/newview/lllocationinputctrl.cpp | 514 |
1 files changed, 452 insertions, 62 deletions
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index 00f12ae2eb..04c684b240 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -39,22 +39,28 @@ #include "llbutton.h" #include "llfocusmgr.h" #include "llmenugl.h" +#include "llparcel.h" #include "llstring.h" #include "lltrans.h" #include "lluictrlfactory.h" #include "lltooltip.h" +#include "llnotificationsutil.h" +#include "llregionflags.h" // newview includes -#include "llinventorymodel.h" +#include "llagent.h" +#include "llinventoryobserver.h" #include "lllandmarkactions.h" #include "lllandmarklist.h" #include "lllocationhistory.h" #include "llteleporthistory.h" #include "llsidetray.h" #include "llslurl.h" +#include "llstatusbar.h" // getHealth() #include "lltrans.h" #include "llviewerinventory.h" #include "llviewerparcelmgr.h" +#include "llviewerregion.h" #include "llviewercontrol.h" #include "llviewermenu.h" #include "llurllineeditorctrl.h" @@ -147,30 +153,63 @@ private: LLLocationInputCtrl* mInput; }; +class LLParcelChangeObserver : public LLParcelObserver +{ +public: + LLParcelChangeObserver(LLLocationInputCtrl* input) : mInput(input) {} + +private: + /*virtual*/ void changed() + { + if (mInput) + { + mInput->refreshParcelIcons(); + } + } + + LLLocationInputCtrl* mInput; +}; + //============================================================================ 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"), - add_landmark_button("add_landmark_button"), add_landmark_hpad("add_landmark_hpad", 0), - info_button("info_button") + icon_hpad("icon_hpad", 0), + 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"), + build_icon("build_icon"), + scripts_icon("scripts_icon"), + damage_icon("damage_icon"), + damage_text("damage_text") { } LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) : LLComboBox(p), + mIconHPad(p.icon_hpad), mAddLandmarkHPad(p.add_landmark_hpad), - mInfoBtn(NULL), mLocationContextMenu(NULL), mAddLandmarkBtn(NULL), + 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 @@ -188,13 +227,13 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) params.rect(text_entry_rect); params.default_text(LLStringUtil::null); params.max_length_bytes(p.max_chars); - params.commit_callback.function(boost::bind(&LLComboBox::onTextCommit, this, _2)); params.keystroke_callback(boost::bind(&LLComboBox::onTextEntry, this, _1)); params.handle_edit_keys_directly(true); params.commit_on_focus_lost(false); params.follows.flags(FOLLOWS_ALL); mTextEntry = LLUICtrlFactory::create<LLURLLineEditor>(params); - this->addChild(mTextEntry); + mTextEntry->setContextMenu(NULL); + addChild(mTextEntry); // LLLineEditor is replaced with LLLocationLineEditor // "Place information" button. @@ -230,6 +269,77 @@ 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( + boost::bind(&LLLocationInputCtrl::onForSaleButtonClicked, this)); + mForSaleBtn = LLUICtrlFactory::create<LLButton>( for_sale_button ); + addChild(mForSaleBtn); + + // Parcel property icons + // Must be mouse-opaque so cursor stays as an arrow when hovering to + // see tooltip. + LLIconCtrl::Params voice_icon = p.voice_icon; + voice_icon.tool_tip = LLTrans::getString("LocationCtrlVoiceTooltip"); + voice_icon.mouse_opaque = true; + mParcelIcon[VOICE_ICON] = LLUICtrlFactory::create<LLIconCtrl>(voice_icon); + mParcelIcon[VOICE_ICON]->setMouseDownCallback(boost::bind(&LLLocationInputCtrl::onParcelIconClick, this, VOICE_ICON)); + addChild(mParcelIcon[VOICE_ICON]); + + LLIconCtrl::Params fly_icon = p.fly_icon; + fly_icon.tool_tip = LLTrans::getString("LocationCtrlFlyTooltip"); + fly_icon.mouse_opaque = true; + mParcelIcon[FLY_ICON] = LLUICtrlFactory::create<LLIconCtrl>(fly_icon); + mParcelIcon[FLY_ICON]->setMouseDownCallback(boost::bind(&LLLocationInputCtrl::onParcelIconClick, this, FLY_ICON)); + addChild(mParcelIcon[FLY_ICON]); + + LLIconCtrl::Params push_icon = p.push_icon; + push_icon.tool_tip = LLTrans::getString("LocationCtrlPushTooltip"); + push_icon.mouse_opaque = true; + mParcelIcon[PUSH_ICON] = LLUICtrlFactory::create<LLIconCtrl>(push_icon); + mParcelIcon[PUSH_ICON]->setMouseDownCallback(boost::bind(&LLLocationInputCtrl::onParcelIconClick, this, PUSH_ICON)); + addChild(mParcelIcon[PUSH_ICON]); + + LLIconCtrl::Params build_icon = p.build_icon; + build_icon.tool_tip = LLTrans::getString("LocationCtrlBuildTooltip"); + build_icon.mouse_opaque = true; + mParcelIcon[BUILD_ICON] = LLUICtrlFactory::create<LLIconCtrl>(build_icon); + mParcelIcon[BUILD_ICON]->setMouseDownCallback(boost::bind(&LLLocationInputCtrl::onParcelIconClick, this, BUILD_ICON)); + addChild(mParcelIcon[BUILD_ICON]); + + LLIconCtrl::Params scripts_icon = p.scripts_icon; + scripts_icon.tool_tip = LLTrans::getString("LocationCtrlScriptsTooltip"); + scripts_icon.mouse_opaque = true; + mParcelIcon[SCRIPTS_ICON] = LLUICtrlFactory::create<LLIconCtrl>(scripts_icon); + mParcelIcon[SCRIPTS_ICON]->setMouseDownCallback(boost::bind(&LLLocationInputCtrl::onParcelIconClick, this, SCRIPTS_ICON)); + addChild(mParcelIcon[SCRIPTS_ICON]); + + LLIconCtrl::Params damage_icon = p.damage_icon; + damage_icon.tool_tip = LLTrans::getString("LocationCtrlDamageTooltip"); + damage_icon.mouse_opaque = true; + mParcelIcon[DAMAGE_ICON] = LLUICtrlFactory::create<LLIconCtrl>(damage_icon); + mParcelIcon[DAMAGE_ICON]->setMouseDownCallback(boost::bind(&LLLocationInputCtrl::onParcelIconClick, this, DAMAGE_ICON)); + addChild(mParcelIcon[DAMAGE_ICON]); + + LLTextBox::Params damage_text = p.damage_text; + damage_text.tool_tip = LLTrans::getString("LocationCtrlDamageTooltip"); + damage_text.mouse_opaque = true; + mDamageText = LLUICtrlFactory::create<LLTextBox>(damage_text); + addChild(mDamageText); // Register callbacks and load the location field context menu (NB: the order matters). LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Navbar.Action", boost::bind(&LLLocationInputCtrl::onLocationContextMenuItemClicked, this, _2)); @@ -248,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. @@ -261,7 +385,10 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) mAddLandmarkObserver = new LLAddLandmarkObserver(this); gInventory.addObserver(mRemoveLandmarkObserver); gInventory.addObserver(mAddLandmarkObserver); - + + mParcelChangeObserver = new LLParcelChangeObserver(this); + LLViewerParcelMgr::getInstance()->addObserver(mParcelChangeObserver); + mAddLandmarkTooltip = LLTrans::getString("LocationCtrlAddLandmarkTooltip"); mEditLandmarkTooltip = LLTrans::getString("LocationCtrlEditLandmarkTooltip"); getChild<LLView>("Location History")->setToolTip(LLTrans::getString("LocationCtrlComboBtnTooltip")); @@ -275,6 +402,11 @@ LLLocationInputCtrl::~LLLocationInputCtrl() delete mRemoveLandmarkObserver; delete mAddLandmarkObserver; + LLViewerParcelMgr::getInstance()->removeObserver(mParcelChangeObserver); + delete mParcelChangeObserver; + + mCoordinatesControlConnection.disconnect(); + mParcelPropertiesControlConnection.disconnect(); mParcelMgrConnection.disconnect(); mLocationHistoryConnection.disconnect(); } @@ -294,6 +426,11 @@ void LLLocationInputCtrl::hideList() BOOL LLLocationInputCtrl::handleToolTip(S32 x, S32 y, MASK mask) { + + if(mAddLandmarkBtn->parentPointInView(x,y)) + { + updateAddLandmarkTooltip(); + } // Let the buttons show their tooltips. if (LLUICtrl::handleToolTip(x, y, mask)) { @@ -371,8 +508,8 @@ void LLLocationInputCtrl::setText(const LLStringExplicit& text) if (mTextEntry) { mTextEntry->setText(text); - mHasAutocompletedText = FALSE; } + mHasAutocompletedText = FALSE; } void LLLocationInputCtrl::setFocus(BOOL b) @@ -380,7 +517,9 @@ void LLLocationInputCtrl::setFocus(BOOL b) LLComboBox::setFocus(b); if (mTextEntry && b && !mList->getVisible()) + { mTextEntry->setFocus(TRUE); + } } void LLLocationInputCtrl::handleLoginComplete() @@ -405,17 +544,50 @@ void LLLocationInputCtrl::onFocusLost() mTextEntry->deselect(); } } -void LLLocationInputCtrl::draw(){ - - if(!hasFocus() && gSavedSettings.getBOOL("ShowCoordinatesOption")){ + +void LLLocationInputCtrl::draw() +{ + static LLUICachedControl<bool> show_coords("NavBarShowCoordinates", false); + if(!hasFocus() && show_coords) + { refreshLocation(); } + + static LLUICachedControl<bool> show_icons("NavBarShowParcelProperties", false); + if (show_icons) + { + refreshHealth(); + } 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().insert("type", "agent")); + LLSideTray::getInstance()->showPanel("panel_places", LLSD().with("type", "agent")); +} + +void LLLocationInputCtrl::onForSaleButtonClicked() +{ + handle_buy_land(); } void LLLocationInputCtrl::onAddLandmarkButtonClicked() @@ -432,7 +604,7 @@ void LLLocationInputCtrl::onAddLandmarkButtonClicked() } else { - LLSideTray::getInstance()->showPanel("panel_places", LLSD().insert("type", "create_landmark")); + LLSideTray::getInstance()->showPanel("panel_places", LLSD().with("type", "create_landmark")); } } @@ -492,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); @@ -506,10 +678,12 @@ void LLLocationInputCtrl::onLocationPrearrange(const LLSD& data) mList->mouseOverHighlightNthItem(-1); // Clear highlight on the last selected item. } + bool LLLocationInputCtrl::findTeleportItemsByTitle(const LLTeleportHistoryItem& item, const std::string& filter) { return item.mTitle.find(filter) != std::string::npos; } + void LLLocationInputCtrl::onTextEditorRightClicked(S32 x, S32 y, MASK mask) { if (mLocationContextMenu) @@ -527,6 +701,7 @@ void LLLocationInputCtrl::onTextEditorRightClicked(S32 x, S32 y, MASK mask) void LLLocationInputCtrl::refresh() { refreshLocation(); // update location string + refreshParcelIcons(); updateAddLandmarkButton(); // indicate whether current parcel has been landmarked } @@ -534,8 +709,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; @@ -543,11 +718,178 @@ void LLLocationInputCtrl::refreshLocation() // Update location field. std::string location_name; - LLAgentUI::ELocationFormat format = (gSavedSettings.getBOOL("ShowCoordinatesOption") ? - LLAgentUI::LOCATION_FORMAT_WITHOUT_SIM: LLAgentUI::LOCATION_FORMAT_NORMAL); + LLAgentUI::ELocationFormat format = + (gSavedSettings.getBOOL("NavBarShowCoordinates") + ? LLAgentUI::LOCATION_FORMAT_FULL + : LLAgentUI::LOCATION_FORMAT_NO_COORDS); - if (!LLAgentUI::buildLocationString(location_name, format)) location_name = "Unknown"; + if (!LLAgentUI::buildLocationString(location_name, format)) + { + location_name = "???"; + } + // 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 +static S32 layout_widget(LLUICtrl* widget, S32 right) +{ + if (widget->getVisible()) + { + LLRect rect = widget->getRect(); + rect.mLeft = right - rect.getWidth(); + rect.mRight = right; + widget->setRect( rect ); + right -= rect.getWidth(); + } + return right; +} + +void LLLocationInputCtrl::refreshParcelIcons() +{ + // Our "cursor" moving right to left + S32 x = mAddLandmarkBtn->getRect().mLeft; + + if (gSavedSettings.getBOOL("NavBarShowParcelProperties")) + { + LLViewerParcelMgr* vpm = LLViewerParcelMgr::getInstance(); + + LLViewerRegion* agent_region = gAgent.getRegion(); + LLParcel* agent_parcel = vpm->getAgentParcel(); + if (!agent_region || !agent_parcel) + return; + + LLParcel* current_parcel; + LLViewerRegion* selection_region = vpm->getSelectionRegion(); + LLParcel* selected_parcel = vpm->getParcelSelection()->getParcel(); + + // If agent is in selected parcel we use its properties because + // they are updated more often by LLViewerParcelMgr than agent parcel properties. + // See LLViewerParcelMgr::processParcelProperties(). + // This is needed to reflect parcel restrictions changes without having to leave + // the parcel and then enter it again. See EXT-2987 + if (selected_parcel && selected_parcel->getLocalID() == agent_parcel->getLocalID() + && selection_region == agent_region) + { + current_parcel = selected_parcel; + } + else + { + current_parcel = agent_parcel; + } + + bool allow_buy = vpm->canAgentBuyParcel(current_parcel, false); + 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 ); + mParcelIcon[BUILD_ICON]->setVisible( !allow_build ); + 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) + { + x = layout_widget(mParcelIcon[i], x); + x -= mIconHPad; + } + x = layout_widget(mDamageText, x); + x -= mIconHPad; + } + else + { + mForSaleBtn->setVisible(false); + for (S32 i = 0; i < ICON_COUNT; ++i) + { + mParcelIcon[i]->setVisible(false); + } + mDamageText->setVisible(false); + } + + 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() +{ + // *FIXME: Status bar owns health information, should be in agent + if (gStatusBar) + { + static S32 last_health = -1; + S32 health = gStatusBar->getHealth(); + if (health != last_health) + { + std::string text = llformat("%d%%", health); + mDamageText->setText(text); + last_health = health; + } + } +} + +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) @@ -572,7 +914,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); } @@ -602,11 +944,12 @@ void LLLocationInputCtrl::enableAddLandmarkButton(bool val) // depending on whether current parcel has been landmarked. void LLLocationInputCtrl::updateAddLandmarkButton() { - bool landmark_exists = LLLandmarkActions::landmarkAlreadyExists(); - enableAddLandmarkButton(!landmark_exists); - + enableAddLandmarkButton(LLLandmarkActions::hasParcelLandmark()); +} +void LLLocationInputCtrl::updateAddLandmarkTooltip() +{ std::string tooltip; - if(landmark_exists) + if(LLLandmarkActions::landmarkAlreadyExists()) { tooltip = mEditLandmarkTooltip; } @@ -636,77 +979,82 @@ void LLLocationInputCtrl::updateWidgetlayout() { const LLRect& rect = getLocalRect(); const LLRect& hist_btn_rect = mButton->getRect(); - LLRect info_btn_rect = mInfoBtn->getRect(); - // info button - info_btn_rect.setOriginAndSize( - 2, (rect.getHeight() - info_btn_rect.getHeight()) / 2, - info_btn_rect.getWidth(), info_btn_rect.getHeight()); - mInfoBtn->setRect(info_btn_rect); + // Info button is set in the XUI XML location_input.xml // "Add Landmark" button - { - LLRect al_btn_rect = mAddLandmarkBtn->getRect(); - al_btn_rect.translate( - hist_btn_rect.mLeft - mAddLandmarkHPad - al_btn_rect.getWidth(), - (rect.getHeight() - al_btn_rect.getHeight()) / 2); - mAddLandmarkBtn->setRect(al_btn_rect); - } + LLRect al_btn_rect = mAddLandmarkBtn->getRect(); + al_btn_rect.translate( + hist_btn_rect.mLeft - mIconHPad - al_btn_rect.getWidth(), + (rect.getHeight() - al_btn_rect.getHeight()) / 2); + mAddLandmarkBtn->setRect(al_btn_rect); } void LLLocationInputCtrl::changeLocationPresentation() { - //change location presentation only if user does not select 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() && !LLSLURL::isSLURL(text)) + 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) { std::string item = userdata.asString(); - if (item == std::string("show_coordinates")) + if (item == "show_coordinates") { - gSavedSettings.setBOOL("ShowCoordinatesOption",!gSavedSettings.getBOOL("ShowCoordinatesOption")); + gSavedSettings.setBOOL("NavBarShowCoordinates",!gSavedSettings.getBOOL("NavBarShowCoordinates")); } - else if (item == std::string("landmark")) + else if (item == "show_properties") + { + gSavedSettings.setBOOL("NavBarShowParcelProperties", + !gSavedSettings.getBOOL("NavBarShowParcelProperties")); + } + else if (item == "landmark") { LLViewerInventoryItem* landmark = LLLandmarkActions::findLandmarkForAgentPos(); if(!landmark) { - LLSideTray::getInstance()->showPanel("panel_places", LLSD().insert("type", "create_landmark")); + LLSideTray::getInstance()->showPanel("panel_places", LLSD().with("type", "create_landmark")); } else { LLSideTray::getInstance()->showPanel("panel_places", - LLSD().insert("type", "landmark").insert("id",landmark->getUUID())); + LLSD().with("type", "landmark").with("id",landmark->getUUID())); } } - else if (item == std::string("cut")) + else if (item == "cut") { mTextEntry->cut(); } - else if (item == std::string("copy")) + else if (item == "copy") { mTextEntry->copy(); } - else if (item == std::string("paste")) + else if (item == "paste") { mTextEntry->paste(); } - else if (item == std::string("delete")) + else if (item == "delete") { mTextEntry->deleteSelection(); } - else if (item == std::string("select_all")) + else if (item == "select_all") { mTextEntry->selectAll(); } @@ -716,30 +1064,72 @@ bool LLLocationInputCtrl::onLocationContextMenuItemEnabled(const LLSD& userdata) { std::string item = userdata.asString(); - if (item == std::string("can_cut")) + if (item == "can_cut") { return mTextEntry->canCut(); } - else if (item == std::string("can_copy")) + else if (item == "can_copy") { return mTextEntry->canCopy(); } - else if (item == std::string("can_paste")) + else if (item == "can_paste") { return mTextEntry->canPaste(); } - else if (item == std::string("can_delete")) + else if (item == "can_delete") { return mTextEntry->canDeselect(); } - else if (item == std::string("can_select_all")) + else if (item == "can_select_all") { - return mTextEntry->canSelectAll(); + return mTextEntry->canSelectAll() && (mTextEntry->getLength() > 0); } - else if(item == std::string("show_coordinates")){ - - return gSavedSettings.getBOOL("ShowCoordinatesOption"); + else if(item == "show_coordinates") + { + return gSavedSettings.getBOOL("NavBarShowCoordinates"); } return false; } + +void LLLocationInputCtrl::onParcelIconClick(EParcelIcon icon) +{ + switch (icon) + { + case VOICE_ICON: + LLNotificationsUtil::add("NoVoice"); + break; + case FLY_ICON: + LLNotificationsUtil::add("NoFly"); + break; + case PUSH_ICON: + LLNotificationsUtil::add("PushRestricted"); + break; + case BUILD_ICON: + LLNotificationsUtil::add("NoBuild"); + break; + case SCRIPTS_ICON: + { + LLViewerRegion* region = gAgent.getRegion(); + if(region && region->getRegionFlags() & REGION_FLAGS_ESTATE_SKIP_SCRIPTS) + { + LLNotificationsUtil::add("ScriptsStopped"); + } + else if(region && region->getRegionFlags() & REGION_FLAGS_SKIP_SCRIPTS) + { + LLNotificationsUtil::add("ScriptsNotRunning"); + } + else + { + LLNotificationsUtil::add("NoOutsideScripts"); + } + break; + } + case DAMAGE_ICON: + LLNotificationsUtil::add("NotSafe"); + break; + case ICON_COUNT: + break; + // no default to get compiler warning when a new icon gets added + } +} |