Display Name UIs as links when they can be interacted with
Adds font style member to line editors, might be useful in the future?
This commit is contained in:
@@ -48,6 +48,17 @@ LLNameBox::LLNameBox(const std::string& name)
|
||||
setClickedCallback(boost::bind(&LLNameBox::showProfile, this));
|
||||
}
|
||||
|
||||
void LLNameBox::displayAsLink(bool link)
|
||||
{
|
||||
static const LLUICachedControl<LLColor4> 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;
|
||||
|
||||
@@ -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(); }
|
||||
|
||||
@@ -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<LLColor4> 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);
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user