From 5f309fdcf71e374ce02b60a574ff22cc52b03cdb Mon Sep 17 00:00:00 2001 From: Ansariel Date: Thu, 20 Aug 2020 00:32:27 +0200 Subject: [PATCH] More banging at name SLURL underlining on hover in chat history --- indra/llui/llstyle.cpp | 4 ++-- indra/llui/llstyle.h | 2 +- indra/llui/lltextbase.cpp | 23 +++++++++++----------- indra/newview/fschathistory.cpp | 35 ++++++++++++++++++++++++--------- 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/indra/llui/llstyle.cpp b/indra/llui/llstyle.cpp index 8c4d3a5c6b..020c4e553d 100644 --- a/indra/llui/llstyle.cpp +++ b/indra/llui/llstyle.cpp @@ -33,7 +33,7 @@ #include "llui.h" LLStyle::Params::Params() -: visible("visible", true), + : visible("visible", true), drop_shadow("drop_shadow", LLFontGL::NO_SHADOW), color("color", LLColor4::black), readonly_color("readonly_color", LLColor4::black), @@ -44,7 +44,7 @@ LLStyle::Params::Params() is_link("is_link"), // Don't highlight URLs on hover if font style contains underline use_default_link_style("use_default_link_style", true), - is_chat_header("is_chat_header", false) + can_underline_on_hover("can_underline_on_hover", true) // {} diff --git a/indra/llui/llstyle.h b/indra/llui/llstyle.h index 2fe9117509..1678d434d8 100644 --- a/indra/llui/llstyle.h +++ b/indra/llui/llstyle.h @@ -50,7 +50,7 @@ public: Optional is_link; // Don't highlight URLs on hover if font style contains underline Optional use_default_link_style; - Optional is_chat_header; + Optional can_underline_on_hover; // Params(); }; diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index d0f4f69023..822b2bf50c 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -2260,15 +2260,7 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para //link_params.overwriteFrom(match.getStyle()); if (input_params.use_default_link_style) { - LLUIColor color(link_params.color()); - LLUIColor readonly_color(link_params.readonly_color()); - bool is_chat_header = link_params.is_chat_header(); link_params.overwriteFrom(match.getStyle()); - if (is_chat_header) - { - link_params.color = color; - link_params.readonly_color = readonly_color; - } } // @@ -2309,7 +2301,7 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para // FIRE-11437 - Don't supress font style for chat history name links //appendAndHighlightTextImpl(match.getLabel(), part, link_params, match.underlineOnHoverOnly()); appendAndHighlightTextImpl(match.getLabel(), part, link_params, - input_params.use_default_link_style ? match.underlineOnHoverOnly() : false); + input_params.can_underline_on_hover ? match.underlineOnHoverOnly() : false); // bool tooltip_required = !match.getTooltip().empty(); @@ -2330,7 +2322,7 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para static LLUIColor query_part_color = LLUIColorTable::getInstance()->getColor("UriQueryPartColor", LLColor4::grey); link_params.color = query_part_color; link_params.readonly_color = query_part_color; - appendAndHighlightTextImpl(label, part, link_params, input_params.use_default_link_style ? match.underlineOnHoverOnly() : false); + appendAndHighlightTextImpl(label, part, link_params, input_params.can_underline_on_hover ? match.underlineOnHoverOnly() : false); // // set the tooltip for the query part of url @@ -2506,7 +2498,16 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig LLTextSegmentPtr segmentp; if (underline_on_hover_only || mSkipLinkUnderline) { - highlight_params.font.style("NORMAL"); + // Only reset underline font style + //highlight_params.font.style("NORMAL"); + std::string normal_font_style(highlight_params.font.style()); + LLStringUtil::replaceString(normal_font_style, "UNDERLINE", ""); + if (normal_font_style.empty()) + { + normal_font_style = "NORMAL"; + } + highlight_params.font.style(normal_font_style); + // LLStyleConstSP normal_sp(new LLStyle(highlight_params)); segmentp = new LLOnHoverChangeableTextSegment(sp, normal_sp, cur_length, cur_length + wide_text.size(), *this); } diff --git a/indra/newview/fschathistory.cpp b/indra/newview/fschathistory.cpp index d800a0c7a5..e9e8fd8adc 100644 --- a/indra/newview/fschathistory.cpp +++ b/indra/newview/fschathistory.cpp @@ -1255,12 +1255,14 @@ void FSChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL LLStyle::Params name_params(body_message_params); name_params.color(name_color); name_params.readonly_color(name_color); - name_params.is_chat_header(true); + std::string name_font_style_postfix = use_plain_text_chat_history ? "UNDERLINE" : ""; + name_params.font.style = name_font_style_postfix; // This will be used when hovering the name (LLTextBase::appendAndHighlightTextImpl() will filter it out) + std::string delimiter_style = "NORMAL"; // FS:LO FIRE-2899 - Faded text for IMs in nearby chat F32 FSIMChatHistoryFade = gSavedSettings.getF32("FSIMChatHistoryFade"); - if(FSIMChatHistoryFade > 1.0f) + if (FSIMChatHistoryFade > 1.0f) { FSIMChatHistoryFade = 1.0f; gSavedSettings.setF32("FSIMChatHistoryFade",FSIMChatHistoryFade); @@ -1291,22 +1293,24 @@ void FSChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL delimiter = LLStringUtil::null; // italics for emotes -Zi - if(gSavedSettings.getBOOL("EmotesUseItalic")) + if (gSavedSettings.getBOOL("EmotesUseItalic")) { body_message_params.font.style = "ITALIC"; - name_params.font.style = "ITALIC"; + name_params.font.style = "ITALIC" + name_font_style_postfix; } } if (chat.mChatType == CHAT_TYPE_WHISPER && gSavedSettings.getBOOL("FSEmphasizeShoutWhisper")) { body_message_params.font.style = "ITALIC"; - name_params.font.style = "ITALIC"; + name_params.font.style = "ITALIC" + name_font_style_postfix; + delimiter_style = "ITALIC"; } else if(chat.mChatType == CHAT_TYPE_SHOUT && gSavedSettings.getBOOL("FSEmphasizeShoutWhisper")) { body_message_params.font.style = "BOLD"; - name_params.font.style = "BOLD"; + name_params.font.style = "BOLD" + name_font_style_postfix; + delimiter_style = "BOLD"; } bool message_from_log = chat.mChatStyle == CHAT_STYLE_HISTORY; @@ -1326,11 +1330,23 @@ void FSChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL U32 moderator_body_style_value = gSavedSettings.getU32("FSModTextStyle"); std::string moderator_name_style = applyModeratorStyle(moderator_name_style_value); std::string moderator_body_style = applyModeratorStyle(moderator_body_style_value); + std::string moderator_timestamp_style = moderator_name_style; if (chat.mChatStyle == CHAT_STYLE_MODERATOR) { moderator_style_active = true; + delimiter_style = moderator_name_style; + if (moderator_name_style_value < UNDERLINE) + { + // Need to add "UNDERLINE" here because we want to underline the name on hover + moderator_name_style += name_font_style_postfix; + } + else + { + // Always contains underline - don't show it on hover only + name_params.can_underline_on_hover = false; + } name_params.font.style(moderator_name_style); body_message_params.font.style(moderator_body_style); @@ -1339,6 +1355,7 @@ void FSChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL if ( (ITALIC & moderator_name_style_value) != ITALIC )//HG: if ITALIC isn't one of the styles... add it { moderator_name_style += "ITALIC"; + moderator_timestamp_style += "ITALIC"; name_params.font.style(moderator_name_style); } if ( (ITALIC & moderator_body_style_value) != ITALIC ) @@ -1374,7 +1391,7 @@ void FSChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL // FS-1734 seperate name and text styles for moderator if ( moderator_style_active ) { - timestamp_style.font.style(moderator_name_style); + timestamp_style.font.style(moderator_timestamp_style); } // FS-1734 seperate name and text styles for moderator appendText("[" + chat.mTimeStr + "] ", prependNewLineState, timestamp_style); @@ -1447,7 +1464,7 @@ void FSChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL } } - name_params.use_default_link_style = (!moderator_style_active || moderator_name_style_value == 0); + name_params.use_default_link_style = false; name_params.link_href = LLSLURL("agent", chat.mFromID, "inspect").getSLURLString(); if (from_me && gSavedSettings.getBOOL("FSChatHistoryShowYou")) @@ -1465,7 +1482,7 @@ void FSChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL if (delimiter.length() > 0 && delimiter[0] == ':') { LLStyle::Params delimiter_params(body_message_params); - delimiter_params.font.style = name_params.font.style; + delimiter_params.font.style = delimiter_style; appendText(":", prependNewLineState, delimiter_params); prependNewLineState = false;