Remove mCommitCallback, mValidateCallback, and mCallbackUserData and related functions from LLUICtrl and derived classes

This commit is contained in:
Lirusaito
2013-06-26 11:16:44 -04:00
parent d7d5925fd1
commit f6df34e40a
8 changed files with 12 additions and 45 deletions

View File

@@ -291,9 +291,8 @@ void LLMultiSliderCtrl::onEditorCommit(const LLSD& value)
val = (F32) atof( text.c_str() ); val = (F32) atof( text.c_str() );
if( mMultiSlider->getMinValue() <= val && val <= mMultiSlider->getMaxValue() ) if( mMultiSlider->getMinValue() <= val && val <= mMultiSlider->getMaxValue() )
{ {
setCurSliderValue( val ); setCurSliderValue( val ); // set the value temporarily so that the callback can retrieve it.
if( (!mValidateCallback || mValidateCallback( this, mCallbackUserData )) && if( !mValidateSignal || (*(mValidateSignal))( this, val ) )
(!mValidateSignal || (*(mValidateSignal))(this, val)))
{ {
success = TRUE; success = TRUE;
} }
@@ -322,8 +321,7 @@ void LLMultiSliderCtrl::onSliderCommit(const LLSD& value)
F32 new_val = mMultiSlider->getCurSliderValue(); F32 new_val = mMultiSlider->getCurSliderValue();
mCurValue = new_val; // set the value temporarily so that the callback can retrieve it. mCurValue = new_val; // set the value temporarily so that the callback can retrieve it.
if( (!mValidateCallback || mValidateCallback( this, mCallbackUserData )) && if( !mValidateSignal || (*(mValidateSignal))( this, new_val ) )
(!mValidateSignal || (*mValidateSignal)(this, new_val ) ))
{ {
success = TRUE; success = TRUE;
} }

View File

@@ -767,9 +767,9 @@ void LLPanel::childSetCommitCallback(const std::string& id, boost::function<void
} }
} }
void LLPanel::childSetValidate(const std::string& id, BOOL (*cb)(LLUICtrl*, void*)) void LLPanel::childSetValidate(const std::string& id, boost::function<bool (const LLSD& data)> cb)
{ {
LLUICtrl* child = getChild<LLUICtrl>(id, true); LLUICtrl* child = findChild<LLUICtrl>(id);
if (child) if (child)
{ {
child->setValidateBeforeCommit(cb); child->setValidateBeforeCommit(cb);

View File

@@ -176,7 +176,7 @@ public:
// a named callback and reference it in XML. // a named callback and reference it in XML.
void childSetCommitCallback(const std::string& id, boost::function<void (LLUICtrl*,void*)> cb, void* data = NULL); void childSetCommitCallback(const std::string& id, boost::function<void (LLUICtrl*,void*)> cb, void* data = NULL);
void childSetValidate(const std::string& id, BOOL (*cb)(LLUICtrl*, void*) ); void childSetValidate(const std::string& id, boost::function<bool (const LLSD& data)> cb );
void childSetColor(const std::string& id, const LLColor4& color); void childSetColor(const std::string& id, const LLColor4& color);
void childSetAlpha(const std::string& id, F32 alpha); void childSetAlpha(const std::string& id, F32 alpha);

View File

@@ -227,9 +227,8 @@ void LLSliderCtrl::onEditorCommit( LLUICtrl* ctrl, const LLSD& userdata )
val = (F32) atof( text.c_str() ); val = (F32) atof( text.c_str() );
if( self->mSlider->getMinValue() <= val && val <= self->mSlider->getMaxValue() ) if( self->mSlider->getMinValue() <= val && val <= self->mSlider->getMaxValue() )
{ {
self->setValue( val ); self->setValue( val ); // set the value temporarily so that the callback can retrieve it.
if( (!self->mValidateCallback || self->mValidateCallback( self, self->mCallbackUserData )) && if( !self->mValidateSignal || (*(self->mValidateSignal))( self, val ) )
(!self->mValidateSignal || (*(self->mValidateSignal))( self, val )))
{ {
success = TRUE; success = TRUE;
} }
@@ -263,8 +262,7 @@ void LLSliderCtrl::onSliderCommit( LLUICtrl* ctrl, const LLSD& userdata )
F32 new_val = self->mSlider->getValueF32(); F32 new_val = self->mSlider->getValueF32();
self->mValue = new_val; // set the value temporarily so that the callback can retrieve it. self->mValue = new_val; // set the value temporarily so that the callback can retrieve it.
if( (!self->mValidateCallback || self->mValidateCallback( self, self->mCallbackUserData )) && if( !self->mValidateSignal || (*(self->mValidateSignal))( self, new_val ) )
(!self->mValidateSignal || (*(self->mValidateSignal))( self, new_val )))
{ {
success = TRUE; success = TRUE;
} }

View File

@@ -198,8 +198,7 @@ void LLSpinCtrl::onUpBtn( const LLSD& data )
F32 saved_val = (F32)getValue().asReal(); F32 saved_val = (F32)getValue().asReal();
setValue(val); setValue(val);
if( (mValidateCallback && !mValidateCallback( this, mCallbackUserData ) ) || if( mValidateSignal && !(*mValidateSignal)( this, val ) )
(mValidateSignal && !(*mValidateSignal)( this, val ) ))
{ {
setValue( saved_val ); setValue( saved_val );
reportInvalidData(); reportInvalidData();
@@ -227,8 +226,7 @@ void LLSpinCtrl::onDownBtn( const LLSD& data )
F32 saved_val = (F32)getValue().asReal(); F32 saved_val = (F32)getValue().asReal();
setValue(val); setValue(val);
if( (mValidateCallback && !mValidateCallback( this, mCallbackUserData ) ) || if( mValidateSignal && !(*mValidateSignal)( this, val ) )
(mValidateSignal && !(*mValidateSignal)( this, val ) ))
{ {
setValue( saved_val ); setValue( saved_val );
reportInvalidData(); reportInvalidData();
@@ -317,9 +315,7 @@ void LLSpinCtrl::onEditorCommit( const LLSD& data )
F32 saved_val = mValue; F32 saved_val = mValue;
mValue = val; mValue = val;
if( !mValidateSignal || (*mValidateSignal)( this, val ) )
if( (!mValidateCallback || mValidateCallback( this, mCallbackUserData )) &&
(!mValidateSignal || (*mValidateSignal)(this, val) ))
{ {
success = TRUE; success = TRUE;
onCommit(); onCommit();

View File

@@ -139,7 +139,6 @@ private:
std::vector<S32> mLineLengthList; std::vector<S32> mLineLengthList;
callback_t mClickedCallback; callback_t mClickedCallback;
void* mCallbackUserData;
}; };
#endif #endif

View File

@@ -45,9 +45,6 @@ LLUICtrl::LLUICtrl() :
mViewModel(LLViewModelPtr(new LLViewModel)), mViewModel(LLViewModelPtr(new LLViewModel)),
mCommitSignal(NULL), mCommitSignal(NULL),
mValidateSignal(NULL), mValidateSignal(NULL),
mCommitCallback(NULL),
mValidateCallback(NULL),
mCallbackUserData(NULL),
mTentative(FALSE), mTentative(FALSE),
mTabStop(TRUE), mTabStop(TRUE),
mIsChrome(FALSE) mIsChrome(FALSE)
@@ -62,10 +59,7 @@ LLUICtrl::LLUICtrl(const std::string& name, const LLRect rect, BOOL mouse_opaque
LLView( name, rect, mouse_opaque, reshape ), LLView( name, rect, mouse_opaque, reshape ),
mCommitSignal(NULL), mCommitSignal(NULL),
mValidateSignal(NULL), mValidateSignal(NULL),
mCommitCallback(NULL),
mViewModel(LLViewModelPtr(new LLViewModel)), mViewModel(LLViewModelPtr(new LLViewModel)),
mValidateCallback( NULL ),
mCallbackUserData( NULL ),
mTentative( FALSE ), mTentative( FALSE ),
mTabStop( TRUE ), mTabStop( TRUE ),
mIsChrome(FALSE) mIsChrome(FALSE)
@@ -90,10 +84,6 @@ LLUICtrl::~LLUICtrl()
void LLUICtrl::onCommit() void LLUICtrl::onCommit()
{ {
if( mCommitCallback )
{
mCommitCallback( this, mCallbackUserData );
}
if (mCommitSignal) if (mCommitSignal)
(*mCommitSignal)(this, getValue()); (*mCommitSignal)(this, getValue());
} }

View File

@@ -50,9 +50,6 @@ public:
typedef boost::signals2::signal<void (LLUICtrl* ctrl, const LLSD& param)> commit_signal_t; 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 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);
LLUICtrl(); LLUICtrl();
LLUICtrl( const std::string& name, const LLRect rect = LLRect(), BOOL mouse_opaque = TRUE, LLUICtrl( const std::string& name, const LLRect rect = LLRect(), BOOL mouse_opaque = TRUE,
commit_callback_t commit_callback = NULL, commit_callback_t commit_callback = NULL,
@@ -126,13 +123,6 @@ public:
boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb ); boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb );
boost::signals2::connection setValidateCallback( const enable_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; }
void setCommitCallback( void (*cb)(LLUICtrl*, void*) ) { mCommitCallback = cb; }
void setValidateBeforeCommit( BOOL(*cb)(LLUICtrl*, void*) ) { mValidateCallback = cb; }
// *TODO: Deprecate; for backwards compatability only: // *TODO: Deprecate; for backwards compatability only:
boost::signals2::connection setCommitCallback( boost::function<void (LLUICtrl*,void*)> cb, void* data); boost::signals2::connection setCommitCallback( boost::function<void (LLUICtrl*,void*)> cb, void* data);
boost::signals2::connection setValidateBeforeCommit( boost::function<bool (const LLSD& data)> cb ); boost::signals2::connection setValidateBeforeCommit( boost::function<bool (const LLSD& data)> cb );
@@ -155,10 +145,6 @@ protected:
enable_signal_t* mValidateSignal; enable_signal_t* mValidateSignal;
LLViewModelPtr mViewModel; LLViewModelPtr mViewModel;
void (*mCommitCallback)( LLUICtrl* ctrl, void* userdata );
BOOL (*mValidateCallback)( LLUICtrl* ctrl, void* userdata );
void* mCallbackUserData;
private: private: