Request: Underline links when hovering over them, for distinguishability

This commit is contained in:
Lirusaito
2019-01-20 14:25:56 -05:00
parent 413c24bde8
commit 8a08964755
2 changed files with 20 additions and 6 deletions

View File

@@ -1581,6 +1581,7 @@ BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask)
{
BOOL handled = FALSE;
auto old_hover = mHoverSegment;
mHoverSegment = NULL;
if(hasMouseCapture() )
{
@@ -1665,6 +1666,14 @@ BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask)
}
}
if (old_hover != mHoverSegment)
{
if (old_hover)
old_hover->underlineOnHover(false);
if (mHoverSegment)
mHoverSegment->underlineOnHover(true);
}
if (mOnScrollEndCallback && mOnScrollEndData && (mScrollbar->getDocPos() == mScrollbar->getDocPosMax()))
{
mOnScrollEndCallback(mOnScrollEndData);
@@ -4269,7 +4278,7 @@ void LLTextEditor::appendTextImpl(const std::string &new_text, const LLStyleSP s
LLStyleSP link_style(style ? new LLStyle(*style) : new LLStyle);
link_style->setColor(link_color);
link_style->setLinkHREF(match.getUrl());
appendAndHighlightText(link, part, link_style);
appendAndHighlightText(link, part, link_style, match.underlineOnHoverOnly());
};
while (!text.empty() && LLUrlRegistry::instance().findUrl(text, match,
boost::bind(&LLTextEditor::replaceUrl, this, _1, _2, _3)))
@@ -4387,7 +4396,7 @@ void LLTextEditor::appendLineBreakSegment(/*const LLStyle::Params& style_params*
insertStringNoUndo(getLength(), LLWString(1, '\n'));
}
void LLTextEditor::appendAndHighlightText(const std::string& new_text, S32 highlight_part, const LLStyleSP stylep)
void LLTextEditor::appendAndHighlightText(const std::string& new_text, S32 highlight_part, const LLStyleSP stylep, bool underline_on_hover)
{
if (new_text.empty()) return;
@@ -4407,7 +4416,7 @@ void LLTextEditor::appendAndHighlightText(const std::string& new_text, S32 highl
}*/
std::string str = std::string(new_text,start,new_text.length()-start);
appendAndHighlightTextImpl(str,highlight_part, stylep);
appendAndHighlightTextImpl(str,highlight_part, stylep, underline_on_hover);
}
@@ -4478,7 +4487,7 @@ void LLTextEditor::replaceUrl(const std::string &url,
}
void LLTextEditor::appendAndHighlightTextImpl(const std::string& new_text, S32 highlight_part, const LLStyleSP stylep)
void LLTextEditor::appendAndHighlightTextImpl(const std::string& new_text, S32 highlight_part, const LLStyleSP stylep, bool underline_on_hover)
{
// Save old state
BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax());
@@ -4519,6 +4528,7 @@ void LLTextEditor::appendAndHighlightTextImpl(const std::string& new_text, S32 h
LLStyleSP sp(new LLStyle(*highlight_params));
LLTextSegmentPtr segmentp;
segmentp = new LLTextSegment(sp, cur_length, cur_length + wide_text.size());
if (underline_on_hover) segmentp->setUnderlineOnHover(true);
mSegments.push_back(segmentp);
}
return;
@@ -4537,6 +4547,7 @@ void LLTextEditor::appendAndHighlightTextImpl(const std::string& new_text, S32 h
S32 segment_start = old_length;
S32 segment_end = old_length + wide_text.size();
LLTextSegmentPtr segment = new LLTextSegment(stylep, segment_start, segment_end);
if (underline_on_hover) segment->setUnderlineOnHover(true);
mSegments.push_back(segment);
}
else // If no style, still make a segment,

View File

@@ -187,7 +187,7 @@ public:
void appendLineBreakSegment();
void appendAndHighlightText(const std::string& new_text, S32 highlight_part, const LLStyleSP stylep);
void appendAndHighlightText(const std::string& new_text, S32 highlight_part, const LLStyleSP stylep, bool underline_on_hover = false);
void replaceUrl(const std::string& url, const std::string& label, const std::string& icon);
@@ -196,7 +196,7 @@ public:
const LLColor4 &color,
const std::string& font_name = LLStringUtil::null);
void appendAndHighlightTextImpl(const std::string& new_text, S32 highlight_part, const LLStyleSP stylep);
void appendAndHighlightTextImpl(const std::string& new_text, S32 highlight_part, const LLStyleSP stylep, bool underline_on_hover = false);
// Removes text from the end of document
// Does not change highlight or cursor position.
@@ -634,6 +634,8 @@ public:
void setStyle(const LLStyleSP &style) { mStyle = style; }
void setIsDefault(BOOL b) { mIsDefault = b; }
BOOL getIsDefault() const { return mIsDefault; }
void setUnderlineOnHover(bool b) { mUnderlineOnHover = b; }
void underlineOnHover(bool hover) { if (mUnderlineOnHover) mStyle->mUnderline = hover; }
void setToken( LLKeywordToken* token ) { mToken = token; }
LLKeywordToken* getToken() const { return mToken; }
BOOL getToolTip( std::string& msg ) const;
@@ -655,6 +657,7 @@ private:
S32 mEnd;
LLKeywordToken* mToken;
BOOL mIsDefault;
bool mUnderlineOnHover = false;
std::string mTooltip;
};