diff options
author | angela <angela@lindenlab.com> | 2009-11-04 11:44:32 +0800 |
---|---|---|
committer | angela <angela@lindenlab.com> | 2009-11-04 11:44:32 +0800 |
commit | 1190b5d9eb6f1e1d698430957b99872abd354f81 (patch) | |
tree | 82915d4b684aaa4cae2d61ebc46a678fcf018c48 /indra/llui | |
parent | b4af6c3da8e5ef3e897cedfb2e1d677a3f37abe9 (diff) | |
parent | 3e3ef5c53d2e73c0836ef6056d222c4c35b8ac2d (diff) |
merge
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llfloater.cpp | 6 | ||||
-rw-r--r-- | indra/llui/llfloater.h | 3 | ||||
-rw-r--r-- | indra/llui/llfloaterreg.cpp | 3 | ||||
-rw-r--r-- | indra/llui/lliconctrl.cpp | 3 | ||||
-rw-r--r-- | indra/llui/lltextbase.cpp | 1 | ||||
-rw-r--r-- | indra/llui/lltextbox.cpp | 26 | ||||
-rw-r--r-- | indra/llui/lltextbox.h | 21 | ||||
-rw-r--r-- | indra/llui/llurlaction.cpp | 12 | ||||
-rw-r--r-- | indra/llui/llurlaction.h | 3 | ||||
-rw-r--r-- | indra/llui/llurlentry.cpp | 58 | ||||
-rw-r--r-- | indra/llui/llurlentry.h | 12 | ||||
-rw-r--r-- | indra/llui/llurlregistry.cpp | 1 |
12 files changed, 129 insertions, 20 deletions
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 8c72b079ee..99aebbcb30 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -772,6 +772,12 @@ LLMultiFloater* LLFloater::getHost() return (LLMultiFloater*)mHostHandle.get(); } +void LLFloater::applySavedVariables() +{ + applyRectControl(); + applyDockState(); +} + void LLFloater::applyRectControl() { if (mRectControl.size() > 1) diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index ef0d06a58e..95c8dd84f6 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -280,6 +280,9 @@ public: protected: void setRectControl(const std::string& rectname) { mRectControl = rectname; }; + + virtual void applySavedVariables(); + void applyRectControl(); void applyDockState(); void storeRectControl(); diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index aca4dc56ee..f8e07913fb 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -134,8 +134,7 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe res->mKey = key; res->setInstanceName(name); - res->applyRectControl(); // Can't apply rect control until setting instance name - res->applyDockState();//same... + res->applySavedVariables(); // Can't apply rect and dock state until setting instance name if (res->mAutoTile && !res->getHost() && index > 0) { const LLRect& cur_rect = res->getRect(); diff --git a/indra/llui/lliconctrl.cpp b/indra/llui/lliconctrl.cpp index 82ffac9580..b1bd2b89a9 100644 --- a/indra/llui/lliconctrl.cpp +++ b/indra/llui/lliconctrl.cpp @@ -123,4 +123,5 @@ void LLIconCtrl::setIconImageDrawSize() mImagep->getImage()->setKnownDrawSize(mDrawWidth, mDrawHeight) ; } } -}
\ No newline at end of file +} + diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 9a26f0b472..e11e5f446e 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1419,6 +1419,7 @@ void LLTextBase::createUrlContextMenu(S32 x, S32 y, const std::string &in_url) registrar.add("Url.OpenExternal", boost::bind(&LLUrlAction::openURLExternal, url)); registrar.add("Url.Execute", boost::bind(&LLUrlAction::executeSLURL, url)); registrar.add("Url.Teleport", boost::bind(&LLUrlAction::teleportToLocation, url)); + registrar.add("Url.ShowOnMap", boost::bind(&LLUrlAction::showLocationOnMap, url)); registrar.add("Url.CopyLabel", boost::bind(&LLUrlAction::copyLabelToClipboard, url)); registrar.add("Url.CopyUrl", boost::bind(&LLUrlAction::copyURLToClipboard, url)); diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 20bceb4675..00f1d833a3 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -45,6 +45,9 @@ LLTextBox::LLTextBox(const LLTextBox::Params& p) mClickedCallback(NULL) {} +LLTextBox::~LLTextBox() +{} + BOOL LLTextBox::handleMouseDown(S32 x, S32 y, MASK mask) { BOOL handled = LLTextBase::handleMouseDown(x, y, mask); @@ -97,6 +100,18 @@ BOOL LLTextBox::handleMouseUp(S32 x, S32 y, MASK mask) return handled; } +BOOL LLTextBox::handleHover(S32 x, S32 y, MASK mask) +{ + BOOL handled = LLTextBase::handleHover(x, y, mask); + if (!handled && mClickedCallback) + { + // Clickable text boxes change the cursor to a hand + LLUI::getWindow()->setCursor(UI_CURSOR_HAND); + return TRUE; + } + return handled; +} + void LLTextBox::setText(const LLStringExplicit& text) { // does string argument insertion @@ -105,6 +120,11 @@ void LLTextBox::setText(const LLStringExplicit& text) LLTextBase::setText(mText.getString()); } +void LLTextBox::setClickedCallback( boost::function<void (void*)> cb, void* userdata /*= NULL */ ) +{ + mClickedCallback = boost::bind(cb, userdata); +} + S32 LLTextBox::getTextPixelWidth() { return getContentsRect().getWidth(); @@ -115,6 +135,12 @@ S32 LLTextBox::getTextPixelHeight() return getContentsRect().getHeight(); } + +LLSD LLTextBox::getValue() const +{ + return LLSD(getText()); +} + BOOL LLTextBox::setTextArg( const std::string& key, const LLStringExplicit& text ) { mText.setArg(key, text); diff --git a/indra/llui/lltextbox.h b/indra/llui/lltextbox.h index da0bcbe972..73f8a7c299 100644 --- a/indra/llui/lltextbox.h +++ b/indra/llui/lltextbox.h @@ -33,8 +33,6 @@ #ifndef LL_LLTEXTBOX_H #define LL_LLTEXTBOX_H -#include "v4color.h" -#include "llstring.h" #include "lluistring.h" #include "lltextbase.h" @@ -54,28 +52,25 @@ protected: friend class LLUICtrlFactory; public: - virtual ~LLTextBox() {} + virtual ~LLTextBox(); - virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); - virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); - /*virtual*/ void setText( const LLStringExplicit& text ); + /*virtual*/ void setText( const LLStringExplicit& text ); void setRightAlign() { mHAlign = LLFontGL::RIGHT; } void setHAlign( LLFontGL::HAlign align ) { mHAlign = align; } - void setClickedCallback( boost::function<void (void*)> cb, void* userdata = NULL ){ mClickedCallback = boost::bind(cb, userdata); } // mouse down and up within button - - //const LLFontGL* getFont() const { return mDefaultFont; } - //void setFont(const LLFontGL* font) { mDefaultFont = font; } + void setClickedCallback( boost::function<void (void*)> cb, void* userdata = NULL ); void reshapeToFitText(); - //const std::string& getText() const { return mText.getString(); } S32 getTextPixelWidth(); S32 getTextPixelHeight(); - virtual LLSD getValue() const { return LLSD(getText()); } - virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text ); + /*virtual*/ LLSD getValue() const; + /*virtual*/ BOOL setTextArg( const std::string& key, const LLStringExplicit& text ); protected: void onUrlLabelUpdated(const std::string &url, const std::string &label); diff --git a/indra/llui/llurlaction.cpp b/indra/llui/llurlaction.cpp index f3401f91f7..679db5e39b 100644 --- a/indra/llui/llurlaction.cpp +++ b/indra/llui/llurlaction.cpp @@ -121,6 +121,18 @@ void LLUrlAction::teleportToLocation(std::string url) } } +void LLUrlAction::showLocationOnMap(std::string url) +{ + LLUrlMatch match; + if (LLUrlRegistry::instance().findUrl(url, match)) + { + if (! match.getLocation().empty()) + { + executeSLURL("secondlife:///app/worldmap/" + match.getLocation()); + } + } +} + void LLUrlAction::copyURLToClipboard(std::string url) { LLView::getWindow()->copyTextToClipboard(utf8str_to_wstring(url)); diff --git a/indra/llui/llurlaction.h b/indra/llui/llurlaction.h index 6b9d565b44..4830cf27ef 100644 --- a/indra/llui/llurlaction.h +++ b/indra/llui/llurlaction.h @@ -67,6 +67,9 @@ public: /// if the Url specifies an SL location, teleport there static void teleportToLocation(std::string url); + /// if the Url specifies an SL location, show it on a map + static void showLocationOnMap(std::string url); + /// perform the appropriate action for left-clicking on a Url static void clickAction(std::string url); diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 52e4229fb4..ddb6c6baff 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -468,6 +468,7 @@ std::string LLUrlEntryTeleport::getLabel(const std::string &url, const LLUrlLabe LLURI uri(url); LLSD path_array = uri.pathArray(); S32 path_parts = path_array.size(); + const std::string label = LLTrans::getString("SLurlLabelTeleport"); if (path_parts == 6) { // handle teleport url with (X,Y,Z) coordinates @@ -475,7 +476,7 @@ std::string LLUrlEntryTeleport::getLabel(const std::string &url, const LLUrlLabe std::string x = path_array[path_parts-3]; std::string y = path_array[path_parts-2]; std::string z = path_array[path_parts-1]; - return "Teleport to " + location + " (" + x + "," + y + "," + z + ")"; + return label + " " + location + " (" + x + "," + y + "," + z + ")"; } else if (path_parts == 5) { @@ -483,20 +484,20 @@ std::string LLUrlEntryTeleport::getLabel(const std::string &url, const LLUrlLabe std::string location = unescapeUrl(path_array[path_parts-3]); std::string x = path_array[path_parts-2]; std::string y = path_array[path_parts-1]; - return "Teleport to " + location + " (" + x + "," + y + ")"; + return label + " " + location + " (" + x + "," + y + ")"; } else if (path_parts == 4) { // handle teleport url with (X) coordinate only std::string location = unescapeUrl(path_array[path_parts-2]); std::string x = path_array[path_parts-1]; - return "Teleport to " + location + " (" + x + ")"; + return label + " " + location + " (" + x + ")"; } else if (path_parts == 3) { // handle teleport url with no coordinates std::string location = unescapeUrl(path_array[path_parts-1]); - return "Teleport to " + location; + return label + " " + location; } return url; @@ -599,3 +600,52 @@ std::string LLUrlEntrySLLabel::getUrl(const std::string &string) return getUrlFromWikiLink(string); } +// +// LLUrlEntryWorldMap Describes secondlife:///<location> URLs +// +LLUrlEntryWorldMap::LLUrlEntryWorldMap() +{ + mPattern = boost::regex("secondlife:///app/worldmap/\\S+/?(\\d+)?/?(\\d+)?/?(\\d+)?/?\\S*", + boost::regex::perl|boost::regex::icase); + mMenuName = "menu_url_map.xml"; + mTooltip = LLTrans::getString("TooltipMapUrl"); +} + +std::string LLUrlEntryWorldMap::getLabel(const std::string &url, const LLUrlLabelCallback &cb) +{ + // + // we handle SLURLs in the following formats: + // - secondlife:///app/worldmap/PLACE/X/Y/Z + // - secondlife:///app/worldmap/PLACE/X/Y + // - secondlife:///app/worldmap/PLACE/X + // + LLURI uri(url); + LLSD path_array = uri.pathArray(); + S32 path_parts = path_array.size(); + if (path_parts < 3) + { + return url; + } + + const std::string label = LLTrans::getString("SLurlLabelShowOnMap"); + std::string location = path_array[2]; + std::string x = (path_parts > 3) ? path_array[3] : "128"; + std::string y = (path_parts > 4) ? path_array[4] : "128"; + std::string z = (path_parts > 5) ? path_array[5] : "0"; + return label + " " + location + " (" + x + "," + y + "," + z + ")"; +} + +std::string LLUrlEntryWorldMap::getLocation(const std::string &url) const +{ + // return the part of the Url after secondlife:///app/worldmap/ part + const std::string search_string = "//app/worldmap/"; + size_t pos = url.find(search_string); + if (pos == std::string::npos) + { + return ""; + } + + pos += search_string.size(); + return url.substr(pos, url.size() - pos); +} + diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h index afb2fdcde9..180ef85673 100644 --- a/indra/llui/llurlentry.h +++ b/indra/llui/llurlentry.h @@ -243,4 +243,16 @@ public: /*virtual*/ std::string getUrl(const std::string &string); }; +/// +/// LLUrlEntryWorldMap Describes a Second Life worldmap Url, e.g., +/// secondlife:///app/worldmap/Ahern/50/50/50 +/// +class LLUrlEntryWorldMap : public LLUrlEntryBase +{ +public: + LLUrlEntryWorldMap(); + /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); + /*virtual*/ std::string getLocation(const std::string &url) const; +}; + #endif diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp index 249c7320d6..60275b60bc 100644 --- a/indra/llui/llurlregistry.cpp +++ b/indra/llui/llurlregistry.cpp @@ -51,6 +51,7 @@ LLUrlRegistry::LLUrlRegistry() registerUrl(new LLUrlEntryGroup()); registerUrl(new LLUrlEntryParcel()); registerUrl(new LLUrlEntryTeleport()); + registerUrl(new LLUrlEntryWorldMap()); registerUrl(new LLUrlEntryObjectIM()); registerUrl(new LLUrlEntryPlace()); registerUrl(new LLUrlEntrySL()); |