Request: Underline links when hovering over them, for distinguishability
This commit is contained in:
@@ -1581,6 +1581,7 @@ BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask)
|
|||||||
{
|
{
|
||||||
BOOL handled = FALSE;
|
BOOL handled = FALSE;
|
||||||
|
|
||||||
|
auto old_hover = mHoverSegment;
|
||||||
mHoverSegment = NULL;
|
mHoverSegment = NULL;
|
||||||
if(hasMouseCapture() )
|
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()))
|
if (mOnScrollEndCallback && mOnScrollEndData && (mScrollbar->getDocPos() == mScrollbar->getDocPosMax()))
|
||||||
{
|
{
|
||||||
mOnScrollEndCallback(mOnScrollEndData);
|
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);
|
LLStyleSP link_style(style ? new LLStyle(*style) : new LLStyle);
|
||||||
link_style->setColor(link_color);
|
link_style->setColor(link_color);
|
||||||
link_style->setLinkHREF(match.getUrl());
|
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,
|
while (!text.empty() && LLUrlRegistry::instance().findUrl(text, match,
|
||||||
boost::bind(&LLTextEditor::replaceUrl, this, _1, _2, _3)))
|
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'));
|
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;
|
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);
|
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
|
// Save old state
|
||||||
BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax());
|
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));
|
LLStyleSP sp(new LLStyle(*highlight_params));
|
||||||
LLTextSegmentPtr segmentp;
|
LLTextSegmentPtr segmentp;
|
||||||
segmentp = new LLTextSegment(sp, cur_length, cur_length + wide_text.size());
|
segmentp = new LLTextSegment(sp, cur_length, cur_length + wide_text.size());
|
||||||
|
if (underline_on_hover) segmentp->setUnderlineOnHover(true);
|
||||||
mSegments.push_back(segmentp);
|
mSegments.push_back(segmentp);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -4537,6 +4547,7 @@ void LLTextEditor::appendAndHighlightTextImpl(const std::string& new_text, S32 h
|
|||||||
S32 segment_start = old_length;
|
S32 segment_start = old_length;
|
||||||
S32 segment_end = old_length + wide_text.size();
|
S32 segment_end = old_length + wide_text.size();
|
||||||
LLTextSegmentPtr segment = new LLTextSegment(stylep, segment_start, segment_end);
|
LLTextSegmentPtr segment = new LLTextSegment(stylep, segment_start, segment_end);
|
||||||
|
if (underline_on_hover) segment->setUnderlineOnHover(true);
|
||||||
mSegments.push_back(segment);
|
mSegments.push_back(segment);
|
||||||
}
|
}
|
||||||
else // If no style, still make a segment,
|
else // If no style, still make a segment,
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ public:
|
|||||||
|
|
||||||
void appendLineBreakSegment();
|
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);
|
void replaceUrl(const std::string& url, const std::string& label, const std::string& icon);
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ public:
|
|||||||
const LLColor4 &color,
|
const LLColor4 &color,
|
||||||
const std::string& font_name = LLStringUtil::null);
|
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
|
// Removes text from the end of document
|
||||||
// Does not change highlight or cursor position.
|
// Does not change highlight or cursor position.
|
||||||
@@ -634,6 +634,8 @@ public:
|
|||||||
void setStyle(const LLStyleSP &style) { mStyle = style; }
|
void setStyle(const LLStyleSP &style) { mStyle = style; }
|
||||||
void setIsDefault(BOOL b) { mIsDefault = b; }
|
void setIsDefault(BOOL b) { mIsDefault = b; }
|
||||||
BOOL getIsDefault() const { return mIsDefault; }
|
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; }
|
void setToken( LLKeywordToken* token ) { mToken = token; }
|
||||||
LLKeywordToken* getToken() const { return mToken; }
|
LLKeywordToken* getToken() const { return mToken; }
|
||||||
BOOL getToolTip( std::string& msg ) const;
|
BOOL getToolTip( std::string& msg ) const;
|
||||||
@@ -655,6 +657,7 @@ private:
|
|||||||
S32 mEnd;
|
S32 mEnd;
|
||||||
LLKeywordToken* mToken;
|
LLKeywordToken* mToken;
|
||||||
BOOL mIsDefault;
|
BOOL mIsDefault;
|
||||||
|
bool mUnderlineOnHover = false;
|
||||||
std::string mTooltip;
|
std::string mTooltip;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user