From 9824cc7068e79a3e8e6991d357fedb8c3b7ed121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liru=20F=C3=A6rs?= Date: Thu, 10 Oct 2019 03:31:31 -0400 Subject: [PATCH] Display Name UIs as links when they can be interacted with Adds font style member to line editors, might be useful in the future? --- indra/llui/lllineeditor.cpp | 14 +++++++------- indra/llui/lllineeditor.h | 1 + indra/llui/lltextbox.h | 2 +- indra/newview/llnamebox.cpp | 11 +++++++++++ indra/newview/llnamebox.h | 1 + indra/newview/llnameeditor.cpp | 10 ++++++++++ indra/newview/llnameeditor.h | 1 + indra/newview/llnameui.cpp | 7 +++++++ indra/newview/llnameui.h | 1 + 9 files changed, 40 insertions(+), 8 deletions(-) diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 9916c9465..9ac4cca54 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -1895,7 +1895,7 @@ void LLLineEditor::draw() rendered_pixels_right, text_bottom, text_color, LLFontGL::LEFT, LLFontGL::BOTTOM, - LLFontGL::NORMAL, + mFontStyle, LLFontGL::NO_SHADOW, select_left - mScrollHPos, mMaxHPixels - ll_round(rendered_pixels_right), @@ -1916,7 +1916,7 @@ void LLLineEditor::draw() rendered_pixels_right, text_bottom, tmp_color, LLFontGL::LEFT, LLFontGL::BOTTOM, - LLFontGL::NORMAL, + mFontStyle, LLFontGL::NO_SHADOW, select_right - mScrollHPos - rendered_text, mMaxHPixels - ll_round(rendered_pixels_right), @@ -1931,7 +1931,7 @@ void LLLineEditor::draw() rendered_pixels_right, text_bottom, text_color, LLFontGL::LEFT, LLFontGL::BOTTOM, - LLFontGL::NORMAL, + mFontStyle, LLFontGL::NO_SHADOW, S32_MAX, mMaxHPixels - ll_round(rendered_pixels_right), @@ -1945,7 +1945,7 @@ void LLLineEditor::draw() rendered_pixels_right, text_bottom, text_color, LLFontGL::LEFT, LLFontGL::BOTTOM, - LLFontGL::NORMAL, + mFontStyle, LLFontGL::NO_SHADOW, S32_MAX, mMaxHPixels - ll_round(rendered_pixels_right), @@ -1987,7 +1987,7 @@ void LLLineEditor::draw() mGLFont->render(mText, getCursor(), (F32)(cursor_left + UI_LINEEDITOR_CURSOR_THICKNESS / 2), text_bottom, tmp_color, LLFontGL::LEFT, LLFontGL::BOTTOM, - LLFontGL::NORMAL, + mFontStyle, LLFontGL::NO_SHADOW, 1); } @@ -2013,7 +2013,7 @@ void LLLineEditor::draw() label_color, LLFontGL::LEFT, LLFontGL::BOTTOM, - LLFontGL::NORMAL, + mFontStyle, LLFontGL::NO_SHADOW, S32_MAX, mMaxHPixels - ll_round(rendered_pixels_right), @@ -2038,7 +2038,7 @@ void LLLineEditor::draw() label_color, LLFontGL::LEFT, LLFontGL::BOTTOM, - LLFontGL::NORMAL, + mFontStyle, LLFontGL::NO_SHADOW, S32_MAX, mMaxHPixels - ll_round(rendered_pixels_right), diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index c6712b7cf..fb83649f1 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -315,6 +315,7 @@ protected: LLViewBorder* mBorder; const LLFontGL* mGLFont; + U8 mFontStyle = LLFontGL::NORMAL; S32 mMaxLengthBytes; // Max length of the UTF8 string in bytes S32 mCursorPos; // I-beam is just after the mCursorPos-th character. S32 mScrollHPos; // Horizontal offset from the start of mText. Used for scrolling. diff --git a/indra/llui/lltextbox.h b/indra/llui/lltextbox.h index b64b7fcb0..27215a20c 100644 --- a/indra/llui/lltextbox.h +++ b/indra/llui/lltextbox.h @@ -113,6 +113,7 @@ private: void setLineLengths(); void drawText(S32 x, S32 y, const LLColor4& color ); +protected: LLUIString mText; const LLFontGL* mFontGL; LLColor4 mTextColor; @@ -139,7 +140,6 @@ private: LLFontGL::VAlign mVAlign; std::vector mLineLengthList; -protected: callback_t mClickedCallback; }; diff --git a/indra/newview/llnamebox.cpp b/indra/newview/llnamebox.cpp index d73a1ae6d..ed6768365 100644 --- a/indra/newview/llnamebox.cpp +++ b/indra/newview/llnamebox.cpp @@ -48,6 +48,17 @@ LLNameBox::LLNameBox(const std::string& name) setClickedCallback(boost::bind(&LLNameBox::showProfile, this)); } +void LLNameBox::displayAsLink(bool link) +{ + static const LLUICachedControl color("HTMLAgentColor"); + setColor(link ? color : LLUI::sColorsGroup->getColor("LabelTextColor")); + setDisabledColor(link ? color : LLUI::sColorsGroup->getColor("LabelDisabledColor")); + if (link) + mFontStyle |= LLFontGL::UNDERLINE; + else + mFontStyle &= ~LLFontGL::UNDERLINE; +} + void LLNameBox::showProfile() { if (!mAllowInteract) return; diff --git a/indra/newview/llnamebox.h b/indra/newview/llnamebox.h index 220db59f6..2ea39f6f0 100644 --- a/indra/newview/llnamebox.h +++ b/indra/newview/llnamebox.h @@ -44,6 +44,7 @@ public: virtual void initFromXML(LLXMLNodePtr node, LLView* parent); static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); + void displayAsLink(bool link) override final; void setText(const std::string& text) override final { LLTextBox::setText(text); } void setValue(const LLSD& value) override final { LLNameUI::setValue(value); } LLSD getValue() const override final { return LLNameUI::getValue(); } diff --git a/indra/newview/llnameeditor.cpp b/indra/newview/llnameeditor.cpp index 7d507509c..6062684d7 100644 --- a/indra/newview/llnameeditor.cpp +++ b/indra/newview/llnameeditor.cpp @@ -76,6 +76,16 @@ BOOL LLNameEditor::handleRightMouseDown(S32 x, S32 y, MASK mask) return LLLineEditor::handleRightMouseDown(x, y, mask); } +void LLNameEditor::displayAsLink(bool link) +{ + static const LLUICachedControl color("HTMLAgentColor"); + setReadOnlyFgColor(link ? color : LLUI::sColorsGroup->getColor("TextFgReadOnlyColor")); + if (link) + mFontStyle |= LLFontGL::UNDERLINE; + else + mFontStyle &= ~LLFontGL::UNDERLINE; +} + void LLNameEditor::setText(const std::string& text) { setToolTip(text); diff --git a/indra/newview/llnameeditor.h b/indra/newview/llnameeditor.h index 0a64d2b77..7d566526d 100644 --- a/indra/newview/llnameeditor.h +++ b/indra/newview/llnameeditor.h @@ -57,6 +57,7 @@ public: void setValue(const LLSD& value) override final { LLNameUI::setValue(value); } LLSD getValue() const override final { return LLNameUI::getValue(); } + void displayAsLink(bool link) override final; void setText(const std::string& text) override final; }; diff --git a/indra/newview/llnameui.cpp b/indra/newview/llnameui.cpp index 15dcc5c91..1f1f13874 100644 --- a/indra/newview/llnameui.cpp +++ b/indra/newview/llnameui.cpp @@ -65,9 +65,14 @@ void LLNameUI::setNameID(const LLUUID& name_id, bool is_group) mIsGroup = is_group; if (mAllowInteract = mNameID.notNull()) + { setNameText(); + } else + { setText(LLTrans::getString(mIsGroup ? "GroupNameNone" : "AvatarNameNobody")); + displayAsLink(false); + } } void LLNameUI::setNameText() @@ -99,6 +104,8 @@ void LLNameUI::setNameText() else mAllowInteract = true; } + displayAsLink(mAllowInteract); + // Got the name already? Set it. // Otherwise it will be set later in refresh(). setText(got_name ? name : mInitialValue); diff --git a/indra/newview/llnameui.h b/indra/newview/llnameui.h index 1fecd668f..99616e9d7 100644 --- a/indra/newview/llnameui.h +++ b/indra/newview/llnameui.h @@ -58,6 +58,7 @@ struct LLNameUI : public LFIDBearer void setShowCompleteName(bool show) { mShowCompleteName = show; } + virtual void displayAsLink(bool link) = 0; // Override to make the name display as a link virtual void setText(const std::string& text) = 0; // Take either UUID or a map of "id" to UUID and "group" to boolean