diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2009-08-14 14:44:36 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2009-08-14 14:44:36 -0400 |
commit | 21bfcbde7ec6e6b3e8a92237b7c33879216c4e82 (patch) | |
tree | 5346bb05d7f74d2f2021883ff0ee4f32bbb56f4a /indra/newview/lllocationinputctrl.cpp | |
parent | 2da8eb43d57ae6876f9955386f604f2c56849211 (diff) | |
parent | aff85ed92c5aad3a9445cf4ec5447cc56c44dfc0 (diff) |
Merge changes
Diffstat (limited to 'indra/newview/lllocationinputctrl.cpp')
-rw-r--r-- | indra/newview/lllocationinputctrl.cpp | 68 |
1 files changed, 51 insertions, 17 deletions
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index 3880ea91eb..e2dc7d69a1 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -55,7 +55,7 @@ #include "llviewerinventory.h" #include "llviewerparcelmgr.h" #include "llviewercontrol.h" - +#include "llurllineeditorctrl.h" //============================================================================ /* * "ADD LANDMARK" BUTTON UPDATING LOGIC @@ -163,12 +163,38 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) mInfoBtn(NULL), mAddLandmarkBtn(NULL) { + // Lets replace default LLLineEditor with LLLocationLineEditor + // to make needed escaping while copying and cutting url + this->removeChild(mTextEntry); + delete mTextEntry; + + // Can't access old mTextEntry fields as they are protected, so lets build new params + // That is C&P from LLComboBox::createLineEditor function + static LLUICachedControl<S32> drop_shadow_button ("DropShadowButton", 0); + S32 arrow_width = mArrowImage ? mArrowImage->getWidth() : 0; + LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0); + text_entry_rect.mRight -= llmax(8,arrow_width) + 2 * drop_shadow_button; + + LLLineEditor::Params params = p.combo_editor; + 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.focus_lost_callback(NULL); + 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); + // LLLineEditor is replaced with LLLocationLineEditor + // "Place information" button. LLButton::Params info_params = p.info_button; mInfoBtn = LLUICtrlFactory::create<LLButton>(info_params); mInfoBtn->setClickedCallback(boost::bind(&LLLocationInputCtrl::onInfoButtonClicked, this)); addChild(mInfoBtn); - + // "Add landmark" button. LLButton::Params al_params = p.add_landmark_button; if (p.add_landmark_image_enabled()) @@ -187,6 +213,7 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) addChild(mAddLandmarkBtn); setPrearrangeCallback(boost::bind(&LLLocationInputCtrl::onLocationPrearrange, this, _2)); + getTextEntry()->setMouseUpCallback(boost::bind(&LLLocationInputCtrl::onTextEditorMouseUp, this, _2,_3,_4)); updateWidgetlayout(); @@ -234,17 +261,20 @@ BOOL LLLocationInputCtrl::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* // Let the buttons show their tooltips. if (LLUICtrl::handleToolTip(x, y, msg, sticky_rect_screen) && !msg.empty()) { - return TRUE; - } + if (mList->getRect().pointInRect(x, y)) { + LLLocationHistory* lh = LLLocationHistory::getInstance(); + const std::string tooltip = lh->getToolTip(msg); - // Cursor is above the text entry. - msg = LLUI::sShowXUINames ? getShowNamesToolTip() : gAgent.getSLURL(); - if (mTextEntry && sticky_rect_screen) - { - *sticky_rect_screen = mTextEntry->calcScreenRect(); + if (!tooltip.empty()) { + msg = tooltip; + } + } + + return TRUE; } - return TRUE; + msg = LLUI::sShowXUINames ? getShowNamesToolTip() : ""; + return mTextEntry->getRect().pointInRect(x, y); } BOOL LLLocationInputCtrl::handleKeyHere(KEY key, MASK mask) @@ -321,19 +351,19 @@ void LLLocationInputCtrl::handleLoginComplete() void LLLocationInputCtrl::onFocusReceived() { prearrangeList(); - setText(gAgent.getSLURL()); - if (mTextEntry) - mTextEntry->endSelection(); // we don't want handleMouseUp() to "finish" the selection } void LLLocationInputCtrl::onFocusLost() { LLUICtrl::onFocusLost(); refreshLocation(); + if(mTextEntry->hasSelection()){ + mTextEntry->deselect(); + } } void LLLocationInputCtrl::draw(){ - if(!hasFocus()){ + if(!hasFocus() && gSavedSettings.getBOOL("ShowCoordinatesOption")){ refreshLocation(); } LLComboBox::draw(); @@ -347,9 +377,6 @@ void LLLocationInputCtrl::onInfoButtonClicked() void LLLocationInputCtrl::onAddLandmarkButtonClicked() { LLSideTray::getInstance()->showPanel("panel_places", LLSD().insert("type", "create_landmark")); - - // Floater "Add Landmark" functionality moved to Side Tray - //LLFloaterReg::showInstance("add_landmark"); } void LLLocationInputCtrl::onAgentParcelChange() @@ -374,6 +401,13 @@ void LLLocationInputCtrl::onLocationPrearrange(const LLSD& data) rebuildLocationHistory(filter); mList->mouseOverHighlightNthItem(-1); // Clear highlight on the last selected item. } +void LLLocationInputCtrl::onTextEditorMouseUp(S32 x, S32 y, MASK mask) +{ + if (!mTextEntry->hasSelection()) { + setText(gAgent.getUnescapedSLURL()); + mTextEntry->selectAll(); + } +} void LLLocationInputCtrl::refresh() { |