Move click_for_profile into LLNameUI base for use in nameboxes

This allows having a linked name text on profiles without it stealing mouse
This commit is contained in:
Liru Færs
2020-01-24 21:48:15 -05:00
parent a9e2672820
commit 9a53824d6d
6 changed files with 17 additions and 10 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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())
{

View File

@@ -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,

View File

@@ -46,9 +46,10 @@
// statics
std::set<LLNameUI*> 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);
}

View File

@@ -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;
};