diff options
author | Andrew Dyukov <adyukov@productengine.com> | 2010-07-26 18:10:29 +0300 |
---|---|---|
committer | Andrew Dyukov <adyukov@productengine.com> | 2010-07-26 18:10:29 +0300 |
commit | 0c8cddecc16d5bd25a2eb5159333ada1dec59259 (patch) | |
tree | b63308e612da0a6fdab7d4192ae4c51082404795 /indra/llui/lltextbase.cpp | |
parent | 20d55088894fa47f4320616f8c5b71afd16e98a0 (diff) |
EXT-8010 FIXED Implemented special behaviour of avatar links.
Avatar links are now underlined only on hover. Also they have the same color as other links.
- Underlining text and getting it back to normal are done in handleHover() and draw() of new LLOnHoverChangeableTextSegment
class derived from LLNormalTextSegment. This class has two pointers to styles- one for style which will be used for text
on hover, and another otherwise. This special type of text segment is used if link's boolean member mUnderlineOnHoverOnly
is true. So it is URL's flag depending on which textbase adds new text segment(like it currently happens with mDisabledLink).
- Changed avatar link color in colors.xml to emphasis (because it was white before and was inconsistent with other links).
Reviewed by Richard Nelson at https://codereview.productengine.com/secondlife/r/749/
--HG--
branch : product-engine
Diffstat (limited to 'indra/llui/lltextbase.cpp')
-rw-r--r-- | indra/llui/lltextbase.cpp | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 617c496d6a..34d58db7f8 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1642,7 +1642,7 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para } else { - appendAndHighlightText(match.getLabel(), part, link_params); + appendAndHighlightText(match.getLabel(), part, link_params, match.underlineOnHoverOnly()); // set the tooltip for the Url label if (! match.getTooltip().empty()) @@ -1725,7 +1725,7 @@ void LLTextBase::appendWidget(const LLInlineViewSegment::Params& params, const s insertStringNoUndo(getLength(), widget_wide_text, &segments); } -void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params) +void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, bool underline_on_hover_only) { // Save old state S32 selection_start = mSelectionStart; @@ -1756,7 +1756,17 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig S32 cur_length = getLength(); LLStyleConstSP sp(new LLStyle(highlight_params)); - LLTextSegmentPtr segmentp = new LLNormalTextSegment(sp, cur_length, cur_length + wide_text.size(), *this); + LLTextSegmentPtr segmentp; + if(underline_on_hover_only) + { + highlight_params.font.style("NORMAL"); + LLStyleConstSP normal_sp(new LLStyle(highlight_params)); + segmentp = new LLOnHoverChangeableTextSegment(sp, normal_sp, cur_length, cur_length + wide_text.size(), *this); + } + else + { + segmentp = new LLNormalTextSegment(sp, cur_length, cur_length + wide_text.size(), *this); + } segment_vec_t segments; segments.push_back(segmentp); insertStringNoUndo(cur_length, wide_text, &segments); @@ -1771,7 +1781,17 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig S32 segment_start = old_length; S32 segment_end = old_length + wide_text.size(); LLStyleConstSP sp(new LLStyle(style_params)); - segments.push_back(new LLNormalTextSegment(sp, segment_start, segment_end, *this )); + if (underline_on_hover_only) + { + LLStyle::Params normal_style_params(style_params); + normal_style_params.font.style("NORMAL"); + LLStyleConstSP normal_sp(new LLStyle(normal_style_params)); + segments.push_back(new LLOnHoverChangeableTextSegment(sp, normal_sp, segment_start, segment_end, *this )); + } + else + { + segments.push_back(new LLNormalTextSegment(sp, segment_start, segment_end, *this )); + } insertStringNoUndo(getLength(), wide_text, &segments); } @@ -1795,7 +1815,7 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig } } -void LLTextBase::appendAndHighlightText(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params) +void LLTextBase::appendAndHighlightText(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, bool underline_on_hover_only) { if (new_text.empty()) return; @@ -1807,7 +1827,7 @@ void LLTextBase::appendAndHighlightText(const std::string &new_text, S32 highlig if(pos!=start) { std::string str = std::string(new_text,start,pos-start); - appendAndHighlightTextImpl(str,highlight_part, style_params); + appendAndHighlightTextImpl(str,highlight_part, style_params, underline_on_hover_only); } appendLineBreakSegment(style_params); start = pos+1; @@ -1815,7 +1835,7 @@ void LLTextBase::appendAndHighlightText(const std::string &new_text, S32 highlig } std::string str = std::string(new_text,start,new_text.length()-start); - appendAndHighlightTextImpl(str,highlight_part, style_params); + appendAndHighlightTextImpl(str,highlight_part, style_params, underline_on_hover_only); } @@ -2675,6 +2695,30 @@ void LLNormalTextSegment::dump() const llendl; } +// +// LLOnHoverChangeableTextSegment +// + +LLOnHoverChangeableTextSegment::LLOnHoverChangeableTextSegment( LLStyleConstSP style, LLStyleConstSP normal_style, S32 start, S32 end, LLTextBase& editor ): + LLNormalTextSegment(normal_style, start, end, editor), + mHoveredStyle(style), + mNormalStyle(normal_style){} + +/*virtual*/ +F32 LLOnHoverChangeableTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect) +{ + F32 result = LLNormalTextSegment::draw(start, end, selection_start, selection_end, draw_rect); + mStyle = mNormalStyle; + return result; +} + +/*virtual*/ +BOOL LLOnHoverChangeableTextSegment::handleHover(S32 x, S32 y, MASK mask) +{ + mStyle = mHoveredStyle; + return LLNormalTextSegment::handleHover(x, y, mask); +} + // // LLInlineViewSegment |