Added new setCommitCallback and setValidateCallback to LLUICtrl, using boost::signals2. Kept legacy variants for now since they are just used too frequently to remove right now.
This commit is contained in:
@@ -42,6 +42,8 @@ static LLRegisterWidget<LLUICtrl> r("ui_ctrl");
|
||||
// NOTE: the LLFocusableElement implementation has been moved to llfocusmgr.cpp, to mirror the header where the class is defined.
|
||||
|
||||
LLUICtrl::LLUICtrl() :
|
||||
mCommitSignal(NULL),
|
||||
mValidateSignal(NULL),
|
||||
mCommitCallback(NULL),
|
||||
mLostTopCallback(NULL),
|
||||
mValidateCallback(NULL),
|
||||
@@ -59,7 +61,9 @@ LLUICtrl::LLUICtrl(const std::string& name, const LLRect& rect, BOOL mouse_opaqu
|
||||
: // can't make this automatically follow top and left, breaks lots
|
||||
// of buttons in the UI. JC 7/20/2002
|
||||
LLView( name, rect, mouse_opaque, reshape ),
|
||||
mCommitCallback( on_commit_callback) ,
|
||||
mCommitSignal(NULL),
|
||||
mValidateSignal(NULL),
|
||||
mCommitCallback( on_commit_callback),
|
||||
mLostTopCallback( NULL ),
|
||||
mValidateCallback( NULL ),
|
||||
mCallbackUserData( callback_userdata ),
|
||||
@@ -78,6 +82,9 @@ LLUICtrl::~LLUICtrl()
|
||||
llwarns << "UI Control holding top ctrl deleted: " << getName() << ". Top view removed." << llendl;
|
||||
gFocusMgr.removeTopCtrlWithoutCallback( this );
|
||||
}
|
||||
|
||||
delete mCommitSignal;
|
||||
delete mValidateSignal;
|
||||
}
|
||||
|
||||
void LLUICtrl::onCommit()
|
||||
@@ -555,3 +562,15 @@ void LLUICtrl::setMinValue(LLSD min_value)
|
||||
// virtual
|
||||
void LLUICtrl::setMaxValue(LLSD max_value)
|
||||
{ }
|
||||
|
||||
boost::signals2::connection LLUICtrl::setCommitCallback( const commit_signal_t::slot_type& cb )
|
||||
{
|
||||
if (!mCommitSignal) mCommitSignal = new commit_signal_t();
|
||||
return mCommitSignal->connect(cb);
|
||||
}
|
||||
|
||||
boost::signals2::connection LLUICtrl::setValidateCallback( const enable_signal_t::slot_type& cb )
|
||||
{
|
||||
if (!mValidateSignal) mValidateSignal = new enable_signal_t();
|
||||
return mValidateSignal->connect(cb);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@ class LLUICtrl
|
||||
: public LLView
|
||||
{
|
||||
public:
|
||||
typedef boost::signals2::signal<void (LLUICtrl* ctrl, const LLSD& param)> commit_signal_t;
|
||||
typedef boost::signals2::signal<bool (LLUICtrl* ctrl, const LLSD& param), boost_boolean_combiner> enable_signal_t;
|
||||
|
||||
typedef void (*LLUICtrlCallback)(LLUICtrl* ctrl, void* userdata);
|
||||
typedef BOOL (*LLUICtrlValidate)(LLUICtrl* ctrl, void* userdata);
|
||||
|
||||
@@ -111,6 +114,12 @@ public:
|
||||
|
||||
LLUICtrl* getParentUICtrl() const;
|
||||
|
||||
//Start using these!
|
||||
boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb );
|
||||
boost::signals2::connection setValidateCallback( const enable_signal_t::slot_type& cb );
|
||||
|
||||
// *TODO: Deprecate; for backwards compatability only:
|
||||
//Keeping userdata around with legacy setCommitCallback because it's used ALL OVER THE PLACE.
|
||||
void* getCallbackUserData() const { return mCallbackUserData; }
|
||||
void setCallbackUserData( void* data ) { mCallbackUserData = data; }
|
||||
|
||||
@@ -132,6 +141,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
commit_signal_t* mCommitSignal;
|
||||
enable_signal_t* mValidateSignal;
|
||||
void (*mCommitCallback)( LLUICtrl* ctrl, void* userdata );
|
||||
void (*mLostTopCallback)( LLUICtrl* ctrl, void* userdata );
|
||||
BOOL (*mValidateCallback)( LLUICtrl* ctrl, void* userdata );
|
||||
|
||||
Reference in New Issue
Block a user