Merge NameBox initialization up to NameEditor's initialization

This commit is contained in:
Liru Færs
2019-11-17 22:34:44 -05:00
parent cfdcb8b3df
commit c5bf72f0b3
2 changed files with 26 additions and 23 deletions

View File

@@ -37,11 +37,20 @@
static LLRegisterWidget<LLNameBox> r("name_box");
LLNameBox::LLNameBox(const std::string& name)
: LLNameUI()
LLNameBox::LLNameBox(const std::string& name,
const LLUUID& name_id,
bool is_group,
const std::string& loading,
bool rlv_sensitive)
: LLNameUI(loading, rlv_sensitive, name_id, is_group)
, LLTextBox(name, LLRect(), LLStringUtil::null, nullptr, TRUE)
{
setClickedCallback(boost::bind(&LLNameUI::showProfile, this));
if (!name_id.isNull())
{
setNameID(name_id, is_group);
}
else setText(mInitialValue);
}
void LLNameBox::displayAsLink(bool link)
@@ -79,25 +88,19 @@ BOOL LLNameBox::handleHover(S32 x, S32 y, MASK mask)
return handled;
}
// virtual
void LLNameBox::initFromXML(LLXMLNodePtr node, LLView* parent)
{
LLTextBox::initFromXML(node, parent);
node->getAttributeString("initial_value", mInitialValue);
setText(mInitialValue);
node->getAttribute_bool("rlv_sensitive", mRLVSensitive);
if (node->hasAttribute("is_group"))
{
bool is_group;
node->getAttribute_bool("is_group", is_group);
setIsGroup(is_group);
}
}
// static
LLView* LLNameBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
LLNameBox* name_box = new LLNameBox("name_box");
bool is_group = false;
node->getAttribute_bool("is_group", is_group);
LLUUID id;
node->getAttributeUUID("id", id);
std::string loading;
node->getAttributeString("initial_value", loading);
bool rlv_sensitive = false;
node->getAttribute_bool("rlv_sensitive", rlv_sensitive);
LLNameBox* name_box = new LLNameBox("name_box", id, is_group, loading, rlv_sensitive);
name_box->initFromXML(node,parent);
return name_box;
}

View File

@@ -41,7 +41,6 @@ class LLNameBox final
, public LLNameUI
{
public:
virtual void initFromXML(LLXMLNodePtr node, LLView* parent);
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
void displayAsLink(bool link) override final;
@@ -52,10 +51,11 @@ public:
BOOL handleRightMouseDown(S32 x, S32 y, MASK mask) override final;
BOOL handleHover(S32 x, S32 y, MASK mask) override final;
protected:
LLNameBox(const std::string& name);
friend class LLUICtrlFactory;
LLNameBox(const std::string& name,
const LLUUID& name_id = LLUUID::null,
bool is_group = false,
const std::string& loading = LLStringUtil::null,
bool rlv_sensitive = false);
};
#endif