From 9a53824d6db09d9ad4c91270d6111028b5501d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liru=20F=C3=A6rs?= Date: Fri, 24 Jan 2020 21:48:15 -0500 Subject: [PATCH] Move click_for_profile into LLNameUI base for use in nameboxes This allows having a linked name text on profiles without it stealing mouse --- indra/newview/llnamebox.cpp | 12 ++++++++---- indra/newview/llnamebox.h | 5 ++++- indra/newview/llnameeditor.cpp | 3 +-- indra/newview/llnameeditor.h | 1 - indra/newview/llnameui.cpp | 3 ++- indra/newview/llnameui.h | 3 ++- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/indra/newview/llnamebox.cpp b/indra/newview/llnamebox.cpp index 032481420..d20e5429f 100644 --- a/indra/newview/llnamebox.cpp +++ b/indra/newview/llnamebox.cpp @@ -42,8 +42,9 @@ LLNameBox::LLNameBox(const std::string& name, const Type& type, const std::string& loading, bool rlv_sensitive, - const std::string& name_system) -: LLNameUI(loading, rlv_sensitive, name_id, type, name_system) + const std::string& name_system, + bool click_for_profile) +: LLNameUI(loading, rlv_sensitive, name_id, type, name_system, click_for_profile) , LLTextBox(name, LLRect(), LLStringUtil::null, nullptr, TRUE) { setClickedCallback(boost::bind(&LLNameUI::showProfile, this)); @@ -80,7 +81,7 @@ BOOL LLNameBox::handleRightMouseDown(S32 x, S32 y, MASK mask) BOOL LLNameBox::handleHover(S32 x, S32 y, MASK mask) { auto handled = LLTextBox::handleHover(x, y, mask); - if (mAllowInteract) + if (mClickForProfile && mAllowInteract) { getWindow()->setCursor(UI_CURSOR_HAND); handled = true; @@ -96,6 +97,7 @@ LLXMLNodePtr LLNameBox::getXML(bool save_children) const node->setName("name_box"); node->createChild("initial_value", TRUE)->setStringValue(mInitialValue); node->createChild("rlv_sensitive", TRUE)->setBoolValue(mRLVSensitive); + node->createChild("click_for_profile", TRUE)->setBoolValue(mClickForProfile); node->createChild("name_system", TRUE)->setStringValue(mNameSystem); return node; @@ -114,7 +116,9 @@ LLView* LLNameBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *f node->getAttribute_bool("rlv_sensitive", rlv_sensitive); std::string name_system; node->getAttributeString("name_system", name_system); - LLNameBox* name_box = new LLNameBox("name_box", id, (Type)type, loading, rlv_sensitive, name_system); + bool click_for_profile = true; + node->getAttribute_bool("click_for_profile", click_for_profile); + LLNameBox* name_box = new LLNameBox("name_box", id, (Type)type, loading, rlv_sensitive, name_system, click_for_profile); name_box->initFromXML(node,parent); return name_box; diff --git a/indra/newview/llnamebox.h b/indra/newview/llnamebox.h index eef31745f..f27d6bbff 100644 --- a/indra/newview/llnamebox.h +++ b/indra/newview/llnamebox.h @@ -49,6 +49,8 @@ public: void setValue(const LLSD& value) override final { LLNameUI::setValue(value); } LLSD getValue() const override final { return LLNameUI::getValue(); } + BOOL handleMouseDown(S32 x, S32 y, MASK mask) override final { return mClickForProfile && mAllowInteract && LLTextBox::handleMouseDown(x, y, mask); } + BOOL handleMouseUp(S32 x, S32 y, MASK mask) override final { return mClickForProfile && mAllowInteract && LLTextBox::handleMouseUp(x, y, mask); } BOOL handleRightMouseDown(S32 x, S32 y, MASK mask) override final; BOOL handleHover(S32 x, S32 y, MASK mask) override final; @@ -57,7 +59,8 @@ public: const Type& type = AVATAR, const std::string& loading = LLStringUtil::null, bool rlv_sensitive = false, - const std::string& name_system = LLStringUtil::null); + const std::string& name_system = LLStringUtil::null, + bool click_for_profile = false); }; #endif diff --git a/indra/newview/llnameeditor.cpp b/indra/newview/llnameeditor.cpp index c695275da..7a10ae3ff 100644 --- a/indra/newview/llnameeditor.cpp +++ b/indra/newview/llnameeditor.cpp @@ -49,9 +49,8 @@ LLNameEditor::LLNameEditor(const std::string& name, const LLRect& rect, bool click_for_profile, const LLFontGL* glfont, S32 max_text_length) -: LLNameUI(loading, rlv_sensitive, name_id, type, name_system) +: LLNameUI(loading, rlv_sensitive, name_id, type, name_system, click_for_profile) , LLLineEditor(name, rect, LLStringUtil::null, glfont, max_text_length) -, mClickForProfile(click_for_profile) { if (!name_id.isNull()) { diff --git a/indra/newview/llnameeditor.h b/indra/newview/llnameeditor.h index 47fa38000..aa6133612 100644 --- a/indra/newview/llnameeditor.h +++ b/indra/newview/llnameeditor.h @@ -40,7 +40,6 @@ class LLNameEditor final : public LLLineEditor , public LLNameUI { - bool mClickForProfile; public: LLNameEditor(const std::string& name, const LLRect& rect, const LLUUID& name_id = LLUUID::null, diff --git a/indra/newview/llnameui.cpp b/indra/newview/llnameui.cpp index 685876b86..221f50c48 100644 --- a/indra/newview/llnameui.cpp +++ b/indra/newview/llnameui.cpp @@ -46,9 +46,10 @@ // statics std::set LLNameUI::sInstances; -LLNameUI::LLNameUI(const std::string& loading, bool rlv_sensitive, const LLUUID& id, const Type& type, const std::string& name_system) +LLNameUI::LLNameUI(const std::string& loading, bool rlv_sensitive, const LLUUID& id, const Type& type, const std::string& name_system, bool click_for_profile) : mNameID(id), mRLVSensitive(rlv_sensitive), mType(NONE), mAllowInteract(false) , mNameSystem(name_system.empty() ? "PhoenixNameSystem" : name_system), mInitialValue(!loading.empty() ? loading : LLTrans::getString("LoadingData")) +, mClickForProfile(click_for_profile) { setType(type); } diff --git a/indra/newview/llnameui.h b/indra/newview/llnameui.h index 1e8da160b..bade1a1cf 100644 --- a/indra/newview/llnameui.h +++ b/indra/newview/llnameui.h @@ -38,7 +38,7 @@ struct LLNameUI : public LFIDBearer { - LLNameUI(const std::string& loading = LLStringUtil::null, bool rlv_sensitive = false, const LLUUID& id = LLUUID::null, const Type& type = AVATAR, const std::string& name_system = LLStringUtil::null); + LLNameUI(const std::string& loading = LLStringUtil::null, bool rlv_sensitive = false, const LLUUID& id = LLUUID::null, const Type& type = AVATAR, const std::string& name_system = LLStringUtil::null, bool click_for_profile = true); virtual ~LLNameUI() { if (mType == GROUP) sInstances.erase(this); @@ -82,4 +82,5 @@ protected: bool mAllowInteract; std::string mInitialValue; std::string mNameSystem; + bool mClickForProfile; };