summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorRichard Nelson <none@none>2010-05-26 13:14:47 -0700
committerRichard Nelson <none@none>2010-05-26 13:14:47 -0700
commit7435ff08b5f548d6e5c61129179c70d99177cc45 (patch)
tree2f6cf43a53080567f723730041a006024974665a /indra/llui
parent0ebdba45f6fbcecfe0aa63bb37ddcde2efba6d87 (diff)
DEV-50271 FIX SLURL support for non-clickable display names
separate mIsLink from mLink to support non-clickable urls (e.g. secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/completename)
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llstyle.cpp6
-rw-r--r--indra/llui/llstyle.h2
-rw-r--r--indra/llui/lltextbase.cpp2
-rw-r--r--indra/llui/lltextbase.h1
-rw-r--r--indra/llui/llurlentry.cpp9
-rw-r--r--indra/llui/llurlentry.h4
-rw-r--r--indra/llui/llurlmatch.cpp7
-rw-r--r--indra/llui/llurlmatch.h6
-rw-r--r--indra/llui/llurlregistry.cpp6
-rw-r--r--indra/llui/tests/llurlmatch_test.cpp30
10 files changed, 30 insertions, 43 deletions
diff --git a/indra/llui/llstyle.cpp b/indra/llui/llstyle.cpp
index b8f93b6a0e..5965ca6fb5 100644
--- a/indra/llui/llstyle.cpp
+++ b/indra/llui/llstyle.cpp
@@ -44,7 +44,8 @@ LLStyle::Params::Params()
color("color", LLColor4::black),
font("font", LLFontGL::getFontMonospace()),
image("image"),
- link_href("href")
+ link_href("href"),
+ is_link("is_link")
{}
@@ -57,6 +58,7 @@ LLStyle::LLStyle(const LLStyle::Params& p)
mReadOnlyColor(p.readonly_color()),
mFont(p.font()),
mLink(p.link_href),
+ mIsLink(p.is_link.isProvided() ? p.is_link : !p.link_href().empty()),
mDropShadow(p.drop_shadow),
mImagep(p.image())
{}
@@ -79,7 +81,7 @@ void LLStyle::setLinkHREF(const std::string& href)
BOOL LLStyle::isLink() const
{
- return mLink.size();
+ return mIsLink;
}
BOOL LLStyle::isVisible() const
diff --git a/indra/llui/llstyle.h b/indra/llui/llstyle.h
index 2067e8e8be..0ca1f2027e 100644
--- a/indra/llui/llstyle.h
+++ b/indra/llui/llstyle.h
@@ -51,6 +51,7 @@ public:
Optional<const LLFontGL*> font;
Optional<LLUIImage*> image;
Optional<std::string> link_href;
+ Optional<bool> is_link;
Params();
};
LLStyle(const Params& p = Params());
@@ -113,6 +114,7 @@ private:
std::string mFontName;
const LLFontGL* mFont; // cached for performance
std::string mLink;
+ bool mIsLink;
LLUIImagePtr mImagep;
};
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 915b0427ba..8fc6f16702 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1794,7 +1794,7 @@ void LLTextBase::replaceUrl(const std::string &url,
seg->setEnd(seg_start + seg_length);
// if we find a link with our Url, then replace the label
- if (style->isLink() && style->getLinkHREF() == url)
+ if (style->getLinkHREF() == url)
{
S32 start = seg->getStart();
S32 end = seg->getEnd();
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index 3a3a5d0e20..ddf604c195 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -315,6 +315,7 @@ protected:
void updateRects();
void needsScroll() { mScrollNeeded = TRUE; }
+ struct URLLabelCallback;
// Replace a URL with a new icon and label, for example, when
// avatar names are looked up.
void replaceUrl(const std::string &url, const std::string &label, const std::string& icon);
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index 60566f457d..13fd20faf8 100644
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -49,7 +49,6 @@ std::string localize_slapp_label(const std::string& url, const std::string& full
LLUrlEntryBase::LLUrlEntryBase()
-: mDisabledLink(false)
{}
LLUrlEntryBase::~LLUrlEntryBase()
@@ -493,9 +492,7 @@ std::string LLUrlEntryAgent::getIcon(const std::string &url)
// x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/(completename|displayname|username)
//
LLUrlEntryAgentName::LLUrlEntryAgentName()
-{
- mDisabledLink = true;
-}
+{}
void LLUrlEntryAgentName::onAvatarNameCache(const LLUUID& id,
const LLAvatarName& av_name)
@@ -544,7 +541,7 @@ std::string LLUrlEntryAgentName::getLabel(const std::string &url, const LLUrlLab
LLStyle::Params LLUrlEntryAgentName::getStyle() const
{
// don't override default colors
- return LLStyle::Params();
+ return LLStyle::Params().is_link(false);
}
//
@@ -949,7 +946,6 @@ LLUrlEntryNoLink::LLUrlEntryNoLink()
{
mPattern = boost::regex("<nolink>[^<]*</nolink>",
boost::regex::perl|boost::regex::icase);
- mDisabledLink = true;
}
std::string LLUrlEntryNoLink::getUrl(const std::string &url) const
@@ -976,7 +972,6 @@ LLUrlEntryIcon::LLUrlEntryIcon()
{
mPattern = boost::regex("<icon\\s*>\\s*([^<]*)?\\s*</icon\\s*>",
boost::regex::perl|boost::regex::icase);
- mDisabledLink = true;
}
std::string LLUrlEntryIcon::getUrl(const std::string &url) const
diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h
index ca4562cee0..5be3c6a45b 100644
--- a/indra/llui/llurlentry.h
+++ b/indra/llui/llurlentry.h
@@ -95,9 +95,6 @@ public:
/// Return the name of a SL location described by this Url, if any
virtual std::string getLocation(const std::string &url) const { return ""; }
- /// is this a match for a URL that should not be hyperlinked?
- bool isLinkDisabled() const { return mDisabledLink; }
-
protected:
std::string getIDStringFromUrl(const std::string &url) const;
std::string escapeUrl(const std::string &url) const;
@@ -117,7 +114,6 @@ protected:
std::string mMenuName;
std::string mTooltip;
std::multimap<std::string, LLUrlEntryObserver> mObservers;
- bool mDisabledLink;
};
///
diff --git a/indra/llui/llurlmatch.cpp b/indra/llui/llurlmatch.cpp
index dcfdd70b42..51fca6d7c0 100644
--- a/indra/llui/llurlmatch.cpp
+++ b/indra/llui/llurlmatch.cpp
@@ -42,16 +42,14 @@ LLUrlMatch::LLUrlMatch() :
mTooltip(""),
mIcon(""),
mMenuName(""),
- mLocation(""),
- mDisabledLink(false)
+ mLocation("")
{
}
void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url,
const std::string &label, const std::string &tooltip,
const std::string &icon, const LLStyle::Params& style,
- const std::string &menu, const std::string &location,
- bool disabled_link)
+ const std::string &menu, const std::string &location)
{
mStart = start;
mEnd = end;
@@ -63,5 +61,4 @@ void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url,
mStyle.link_href = url;
mMenuName = menu;
mLocation = location;
- mDisabledLink = disabled_link;
}
diff --git a/indra/llui/llurlmatch.h b/indra/llui/llurlmatch.h
index 293935e251..3b15a156a8 100644
--- a/indra/llui/llurlmatch.h
+++ b/indra/llui/llurlmatch.h
@@ -83,14 +83,11 @@ public:
/// return the SL location that this Url describes, or "" if none.
std::string getLocation() const { return mLocation; }
- /// is this a match for a URL that should not be hyperlinked?
- bool isLinkDisabled() const { return mDisabledLink; }
-
/// Change the contents of this match object (used by LLUrlRegistry)
void setValues(U32 start, U32 end, const std::string &url, const std::string &label,
const std::string &tooltip, const std::string &icon,
const LLStyle::Params& style, const std::string &menu,
- const std::string &location, bool disabled_link);
+ const std::string &location);
private:
U32 mStart;
@@ -102,7 +99,6 @@ private:
std::string mMenuName;
std::string mLocation;
LLStyle::Params mStyle;
- bool mDisabledLink;
};
#endif
diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp
index f61603545f..f119233f8f 100644
--- a/indra/llui/llurlregistry.cpp
+++ b/indra/llui/llurlregistry.cpp
@@ -192,8 +192,7 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL
match_entry->getIcon(url),
match_entry->getStyle(),
match_entry->getMenuName(),
- match_entry->getLocation(url),
- match_entry->isLinkDisabled());
+ match_entry->getLocation(url));
return true;
}
@@ -226,8 +225,7 @@ bool LLUrlRegistry::findUrl(const LLWString &text, LLUrlMatch &match, const LLUr
match.getIcon(),
match.getStyle(),
match.getMenuName(),
- match.getLocation(),
- match.isLinkDisabled());
+ match.getLocation());
return true;
}
return false;
diff --git a/indra/llui/tests/llurlmatch_test.cpp b/indra/llui/tests/llurlmatch_test.cpp
index 10c44a9073..d6ef5132c8 100644
--- a/indra/llui/tests/llurlmatch_test.cpp
+++ b/indra/llui/tests/llurlmatch_test.cpp
@@ -176,7 +176,7 @@ namespace tut
LLUrlMatch match;
ensure("empty()", match.empty());
- match.setValues(0, 1, "http://secondlife.com", "Second Life", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(0, 1, "http://secondlife.com", "Second Life", "", "", LLStyle::Params(), "", "");
ensure("! empty()", ! match.empty());
}
@@ -189,7 +189,7 @@ namespace tut
LLUrlMatch match;
ensure_equals("getStart() == 0", match.getStart(), 0);
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure_equals("getStart() == 10", match.getStart(), 10);
}
@@ -202,7 +202,7 @@ namespace tut
LLUrlMatch match;
ensure_equals("getEnd() == 0", match.getEnd(), 0);
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure_equals("getEnd() == 20", match.getEnd(), 20);
}
@@ -215,10 +215,10 @@ namespace tut
LLUrlMatch match;
ensure_equals("getUrl() == ''", match.getUrl(), "");
- match.setValues(10, 20, "http://slurl.com/", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "http://slurl.com/", "", "", "", LLStyle::Params(), "", "");
ensure_equals("getUrl() == 'http://slurl.com/'", match.getUrl(), "http://slurl.com/");
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure_equals("getUrl() == '' (2)", match.getUrl(), "");
}
@@ -231,10 +231,10 @@ namespace tut
LLUrlMatch match;
ensure_equals("getLabel() == ''", match.getLabel(), "");
- match.setValues(10, 20, "", "Label", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "Label", "", "", LLStyle::Params(), "", "");
ensure_equals("getLabel() == 'Label'", match.getLabel(), "Label");
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure_equals("getLabel() == '' (2)", match.getLabel(), "");
}
@@ -247,10 +247,10 @@ namespace tut
LLUrlMatch match;
ensure_equals("getTooltip() == ''", match.getTooltip(), "");
- match.setValues(10, 20, "", "", "Info", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "Info", "", LLStyle::Params(), "", "");
ensure_equals("getTooltip() == 'Info'", match.getTooltip(), "Info");
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure_equals("getTooltip() == '' (2)", match.getTooltip(), "");
}
@@ -263,10 +263,10 @@ namespace tut
LLUrlMatch match;
ensure_equals("getIcon() == ''", match.getIcon(), "");
- match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "", "");
ensure_equals("getIcon() == 'Icon'", match.getIcon(), "Icon");
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure_equals("getIcon() == '' (2)", match.getIcon(), "");
}
@@ -279,10 +279,10 @@ namespace tut
LLUrlMatch match;
ensure("getMenuName() empty", match.getMenuName().empty());
- match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "", false);
+ match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "");
ensure_equals("getMenuName() == \"xui_file.xml\"", match.getMenuName(), "xui_file.xml");
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure("getMenuName() empty (2)", match.getMenuName().empty());
}
@@ -295,10 +295,10 @@ namespace tut
LLUrlMatch match;
ensure("getLocation() empty", match.getLocation().empty());
- match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "Paris", false);
+ match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "Paris");
ensure_equals("getLocation() == \"Paris\"", match.getLocation(), "Paris");
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure("getLocation() empty (2)", match.getLocation().empty());
}
}