Added [in]visibility_control support.
This commit is contained in:
@@ -43,6 +43,8 @@ static LLRegisterWidget<LLUICtrl> r("ui_ctrl");
|
||||
|
||||
LLUICtrl::LLUICtrl() :
|
||||
mViewModel(LLViewModelPtr(new LLViewModel)),
|
||||
mMakeVisibleControlVariable(NULL),
|
||||
mMakeInvisibleControlVariable(NULL),
|
||||
mCommitSignal(NULL),
|
||||
mValidateSignal(NULL),
|
||||
mMouseEnterSignal(NULL),
|
||||
@@ -144,6 +146,56 @@ LLViewModel* LLUICtrl::getViewModel() const
|
||||
{
|
||||
return mViewModel;
|
||||
}
|
||||
|
||||
void LLUICtrl::setMakeVisibleControlVariable(LLControlVariable* control)
|
||||
{
|
||||
if (mMakeVisibleControlVariable)
|
||||
{
|
||||
mMakeVisibleControlConnection.disconnect(); // disconnect current signal
|
||||
mMakeVisibleControlVariable = NULL;
|
||||
}
|
||||
if (control)
|
||||
{
|
||||
mMakeVisibleControlVariable = control;
|
||||
mMakeVisibleControlConnection = mMakeVisibleControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getHandle(), std::string("visible")));
|
||||
setVisible(mMakeVisibleControlVariable->getValue().asBoolean());
|
||||
}
|
||||
}
|
||||
|
||||
void LLUICtrl::setMakeInvisibleControlVariable(LLControlVariable* control)
|
||||
{
|
||||
if (mMakeInvisibleControlVariable)
|
||||
{
|
||||
mMakeInvisibleControlConnection.disconnect(); // disconnect current signal
|
||||
mMakeInvisibleControlVariable = NULL;
|
||||
}
|
||||
if (control)
|
||||
{
|
||||
mMakeInvisibleControlVariable = control;
|
||||
mMakeInvisibleControlConnection = mMakeInvisibleControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getHandle(), std::string("invisible")));
|
||||
setVisible(!(mMakeInvisibleControlVariable->getValue().asBoolean()));
|
||||
}
|
||||
}
|
||||
// static
|
||||
bool LLUICtrl::controlListener(const LLSD& newvalue, LLHandle<LLUICtrl> handle, std::string type)
|
||||
{
|
||||
LLUICtrl* ctrl = handle.get();
|
||||
if (ctrl)
|
||||
{
|
||||
if (type == "visible")
|
||||
{
|
||||
ctrl->setVisible(newvalue.asBoolean());
|
||||
return true;
|
||||
}
|
||||
else if (type == "invisible")
|
||||
{
|
||||
ctrl->setVisible(!newvalue.asBoolean());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// virtual
|
||||
BOOL LLUICtrl::setTextArg( const std::string& key, const LLStringExplicit& text )
|
||||
{
|
||||
@@ -532,6 +584,19 @@ void LLUICtrl::initFromXML(LLXMLNodePtr node, LLView* parent)
|
||||
}
|
||||
}
|
||||
LLView::initFromXML(node, parent);
|
||||
|
||||
if(node->getAttributeString("visibility_control",attrib_str) || node->getAttributeString("visiblity_control",attrib_str))
|
||||
{
|
||||
LLControlVariable* control = findControl(attrib_str);
|
||||
if (control)
|
||||
setMakeVisibleControlVariable(control);
|
||||
}
|
||||
if(node->getAttributeString("invisibility_control",attrib_str) || node->getAttributeString("invisiblity_control",attrib_str))
|
||||
{
|
||||
LLControlVariable* control = findControl(attrib_str);
|
||||
if (control)
|
||||
setMakeInvisibleControlVariable(control);
|
||||
}
|
||||
}
|
||||
|
||||
LLXMLNodePtr LLUICtrl::getXML(bool save_children) const
|
||||
|
||||
@@ -80,6 +80,8 @@ public:
|
||||
virtual class LLCtrlSelectionInterface* getSelectionInterface();
|
||||
virtual class LLCtrlListInterface* getListInterface();
|
||||
virtual class LLCtrlScrollInterface* getScrollInterface();
|
||||
void setMakeVisibleControlVariable(LLControlVariable* control);
|
||||
void setMakeInvisibleControlVariable(LLControlVariable* control);
|
||||
|
||||
virtual void setTentative(BOOL b);
|
||||
virtual BOOL getTentative() const;
|
||||
@@ -116,6 +118,7 @@ public:
|
||||
BOOL focusLastItem(BOOL prefer_text_fields = FALSE);
|
||||
|
||||
// Non Virtuals
|
||||
LLHandle<LLUICtrl> getHandle() const { return getDerivedHandle<LLUICtrl>(); }
|
||||
BOOL getIsChrome() const;
|
||||
|
||||
void setTabStop( BOOL b );
|
||||
@@ -151,9 +154,11 @@ public:
|
||||
class CommitCallbackRegistry : public CallbackRegistry<commit_callback_t, CommitCallbackRegistry>{};
|
||||
// the enable callback registry is also used for visiblity callbacks
|
||||
class EnableCallbackRegistry : public CallbackRegistry<enable_callback_t, EnableCallbackRegistry>{};
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
static bool controlListener(const LLSD& newvalue, LLHandle<LLUICtrl> handle, std::string type);
|
||||
|
||||
commit_signal_t* mCommitSignal;
|
||||
enable_signal_t* mValidateSignal;
|
||||
|
||||
@@ -162,6 +167,10 @@ protected:
|
||||
|
||||
LLViewModelPtr mViewModel;
|
||||
|
||||
LLControlVariable* mMakeVisibleControlVariable;
|
||||
boost::signals2::connection mMakeVisibleControlConnection;
|
||||
LLControlVariable* mMakeInvisibleControlVariable;
|
||||
boost::signals2::connection mMakeInvisibleControlConnection;
|
||||
private:
|
||||
|
||||
BOOL mTabStop;
|
||||
|
||||
Reference in New Issue
Block a user