bugfixes
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@105 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
15
ChangeLog
15
ChangeLog
@@ -1,3 +1,18 @@
|
||||
2006-03-14 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* include/automatable_object.h:
|
||||
* include/automatable_button.h:
|
||||
* include/knob.h:
|
||||
* src/widgets/automatable_button.cpp:
|
||||
* src/widgets/knob.cpp:
|
||||
added second template-parameter to automatableObject which specifies
|
||||
the type to be used for internal calculations (neccessary for working
|
||||
undo/redo-implementation for bool-objects like buttons)
|
||||
|
||||
* include/led_checkbox.h:
|
||||
* src/widgets/led_checkbox.cpp:
|
||||
fixed some bugs
|
||||
|
||||
2006-03-13 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* include/main_window.h:
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
class automatableButtonGroup;
|
||||
|
||||
|
||||
class automatableButton : public QWidget, public automatableObject<bool>
|
||||
class automatableButton : public QWidget, public automatableObject<bool,
|
||||
signed char>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -58,6 +59,8 @@ public:
|
||||
return( value() );
|
||||
}
|
||||
|
||||
virtual void setValue( const bool _on );
|
||||
|
||||
inline void setToggleButton( bool _on )
|
||||
{
|
||||
m_toggleButton = _on;
|
||||
@@ -67,7 +70,10 @@ public:
|
||||
|
||||
public slots:
|
||||
virtual void toggle( void );
|
||||
virtual void setChecked( bool _on );
|
||||
virtual void setChecked( bool _on )
|
||||
{
|
||||
setValue( _on );
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@@ -32,10 +32,12 @@
|
||||
#include "templates.h"
|
||||
|
||||
|
||||
template<typename T>
|
||||
template<typename T, typename EDIT_STEP_TYPE = T>
|
||||
class automatableObject : public editableObject
|
||||
{
|
||||
public:
|
||||
typedef automatableObject<T, EDIT_STEP_TYPE> autoObj;
|
||||
|
||||
automatableObject( engine * _engine, const T _val = 0, const T _min = 0,
|
||||
const T _max = 0,
|
||||
const T _step = defaultRelStep() ) :
|
||||
@@ -139,21 +141,27 @@ public:
|
||||
if( old_val != m_value )
|
||||
{
|
||||
// add changes to history so user can undo it
|
||||
addStep( editStep( 0, m_value - old_val ) );
|
||||
addStep( editStep( 0, static_cast<EDIT_STEP_TYPE>(
|
||||
m_value ) -
|
||||
static_cast<EDIT_STEP_TYPE>(
|
||||
old_val ) ) );
|
||||
|
||||
// notify linked objects
|
||||
|
||||
// doesn't work because of implicit typename T
|
||||
// for( autoObjVector::iterator it = m_linkedObjects.begin();
|
||||
// it != m_linkedObjects.end(); ++it )
|
||||
// for( autoObjVector::iterator it =
|
||||
// m_linkedObjects.begin();
|
||||
// it != m_linkedObjects.end(); ++it )
|
||||
for( csize i = 0; i < m_linkedObjects.size(); ++i )
|
||||
{
|
||||
automatableObject<T> * it = m_linkedObjects[i];
|
||||
autoObj * it = m_linkedObjects[i];
|
||||
if( value() != it->value() &&
|
||||
it->fittedValue( value() ) != it->value() )
|
||||
it->fittedValue( value() ) !=
|
||||
it->value() )
|
||||
{
|
||||
const bool sr = it->isRecordingSteps();
|
||||
it->setStepRecording( isRecordingSteps() );
|
||||
it->setStepRecording(
|
||||
isRecordingSteps() );
|
||||
it->setValue( value() );
|
||||
it->setStepRecording( sr );
|
||||
}
|
||||
@@ -177,7 +185,7 @@ public:
|
||||
qSwap<T>( m_minValue, m_maxValue );
|
||||
}
|
||||
// re-adjust value
|
||||
automatableObject<T>::setInitValue( value() );
|
||||
autoObj::setInitValue( value() );
|
||||
}
|
||||
|
||||
inline virtual void setStep( const T _step )
|
||||
@@ -209,7 +217,7 @@ public:
|
||||
m_step = _step;
|
||||
}
|
||||
|
||||
inline void linkObject( automatableObject<T> * _object )
|
||||
inline void linkObject( autoObj * _object )
|
||||
{
|
||||
if( qFind( m_linkedObjects.begin(), m_linkedObjects.end(),
|
||||
_object ) == m_linkedObjects.end() )
|
||||
@@ -218,15 +226,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
inline void unlinkObject( automatableObject<T> * _object )
|
||||
inline void unlinkObject( autoObj * _object )
|
||||
{
|
||||
m_linkedObjects.erase( qFind( m_linkedObjects.begin(),
|
||||
m_linkedObjects.end(),
|
||||
_object ) );
|
||||
}
|
||||
|
||||
static inline void linkObjects( automatableObject<T> * _object1,
|
||||
automatableObject<T> * _object2 )
|
||||
static inline void linkObjects( autoObj * _object1,
|
||||
autoObj * _object2 )
|
||||
{
|
||||
_object1->linkObject( _object2 );
|
||||
_object2->linkObject( _object1 );
|
||||
@@ -239,10 +247,11 @@ protected:
|
||||
const bool sr = isRecordingSteps();
|
||||
setStepRecording( FALSE );
|
||||
#ifndef QT3
|
||||
setValue( value() + _edit_step.data().value<T>() );
|
||||
setValue( static_cast<T>( value() +
|
||||
_edit_step.data().value<EDIT_STEP_TYPE>() ) );
|
||||
#else
|
||||
setValue( value() + static_cast<T>(
|
||||
_edit_step.data().toDouble() ) );
|
||||
setValue( static_cast<T>( value() + static_cast<EDIT_STEP_TYPE>(
|
||||
_edit_step.data().toDouble() ) ) );
|
||||
#endif
|
||||
setStepRecording( sr );
|
||||
}
|
||||
@@ -251,10 +260,11 @@ protected:
|
||||
{
|
||||
#ifndef QT3
|
||||
redoStep( editStep( _edit_step.actionID(),
|
||||
-_edit_step.data().value<T>() ) );
|
||||
-_edit_step.data().value<EDIT_STEP_TYPE>() ) );
|
||||
#else
|
||||
redoStep( editStep( _edit_step.actionID(),
|
||||
static_cast<T>( -_edit_step.data().toDouble() ) ) );
|
||||
static_cast<EDIT_STEP_TYPE>(
|
||||
-_edit_step.data().toDouble() ) ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -273,7 +283,7 @@ private:
|
||||
T m_maxValue;
|
||||
T m_step;
|
||||
|
||||
typedef vvector<automatableObject<T> *> autoObjVector;
|
||||
typedef vvector<autoObj *> autoObjVector;
|
||||
autoObjVector m_linkedObjects;
|
||||
|
||||
} ;
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
inline virtual void setInitValue( const float _val )
|
||||
{
|
||||
m_initValue = _val;
|
||||
automatableObject<float>::setInitValue( _val );
|
||||
autoObj::setInitValue( _val );
|
||||
}
|
||||
|
||||
virtual void setValue( const float _x );
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
automatableButton::automatableButton( QWidget * _parent, engine * _engine ) :
|
||||
QWidget( _parent ),
|
||||
automatableObject<bool>( _engine, FALSE, TRUE, FALSE ),
|
||||
autoObj( _engine, FALSE, TRUE, FALSE ),
|
||||
m_group( NULL ),
|
||||
m_toggleButton( FALSE )
|
||||
{
|
||||
@@ -106,11 +106,11 @@ void automatableButton::toggle( void )
|
||||
|
||||
|
||||
|
||||
void automatableButton::setChecked( bool _on )
|
||||
void automatableButton::setValue( const bool _on )
|
||||
{
|
||||
if( _on != isChecked() )
|
||||
if( _on != value() )
|
||||
{
|
||||
setValue( _on );
|
||||
autoObj::setValue( _on );
|
||||
update();
|
||||
emit( toggled( value() ) );
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ groupBox::groupBox( const QString & _caption, QWidget * _parent,
|
||||
updatePixmap();
|
||||
|
||||
m_led = new pixmapButton( this, eng() );
|
||||
m_led->setToggleButton( TRUE );
|
||||
m_led->move( 2, 3 );
|
||||
m_led->setActiveGraphic( embed::getIconPixmap( "led_green" ) );
|
||||
m_led->setInactiveGraphic( embed::getIconPixmap( "led_off" ) );
|
||||
|
||||
@@ -94,7 +94,7 @@ knob::knob( int _knob_num, QWidget * _parent, const QString & _name,
|
||||
, _name.ascii()
|
||||
#endif
|
||||
),
|
||||
automatableObject<float>( _engine ),
|
||||
autoObj( _engine ),
|
||||
m_mouseOffset( 0.0f ),
|
||||
m_buttonPressed( FALSE ),
|
||||
m_angle( 0.0f ),
|
||||
@@ -606,7 +606,7 @@ void knob::setPosition( const QPoint & _p )
|
||||
void knob::setValue( const float _x )
|
||||
{
|
||||
const float prev_value = value();
|
||||
automatableObject<float>::setValue( _x );
|
||||
autoObj::setValue( _x );
|
||||
if( prev_value != value() )
|
||||
{
|
||||
valueChange();
|
||||
@@ -614,27 +614,12 @@ void knob::setValue( const float _x )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void knob::fitValue( float _val )
|
||||
{
|
||||
setValue( _val );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void knob::incValue( int _steps )
|
||||
{
|
||||
setValue( m_value + float( _steps ) * m_step );
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
void knob::setRange( const float _min, const float _max, const float _step )
|
||||
{
|
||||
bool rchg = ( ( maxValue() != _max ) || ( minValue() != _min ) );
|
||||
automatableObject<float>::setRange( _min, _max, _step );
|
||||
autoObj::setRange( _min, _max, _step );
|
||||
|
||||
m_pageSize = tMax<float>( ( maxValue() - minValue() ) / 100.0f,
|
||||
step() );
|
||||
@@ -646,86 +631,6 @@ void knob::setRange( const float _min, const float _max, const float _step )
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
|
||||
void knob::setNewValue( float _x, bool _align )
|
||||
{
|
||||
m_prevValue = m_value;
|
||||
|
||||
m_value = tLimit( _x, m_minValue, m_maxValue );
|
||||
|
||||
m_exactPrevValue = m_exactValue;
|
||||
m_exactValue = m_value;
|
||||
|
||||
// align to grid
|
||||
if( _align )
|
||||
{
|
||||
if( m_step != 0.0 )
|
||||
{
|
||||
m_value = floorf( m_value / m_step ) * m_step;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_value = m_minValue;
|
||||
}
|
||||
|
||||
// correct rounding error at the border
|
||||
if( tAbs<float>( m_value - m_maxValue ) < MinEps *
|
||||
tAbs<float>( m_step ) )
|
||||
{
|
||||
m_value = m_maxValue;
|
||||
}
|
||||
|
||||
// correct rounding error if value = 0
|
||||
if( tAbs<float>( m_value ) < MinEps * tAbs<float>( m_step ) )
|
||||
{
|
||||
m_value = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
if( m_prevValue != m_value )
|
||||
{
|
||||
valueChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void knob::setStep( float _vstep )
|
||||
{
|
||||
float intv = m_maxValue - m_minValue;
|
||||
|
||||
float newStep;
|
||||
|
||||
if( _vstep == 0.0 )
|
||||
{
|
||||
newStep = intv * DefaultRelStep;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ( intv > 0 ) && ( _vstep < 0 ) || ( intv < 0 ) &&
|
||||
( _vstep > 0 ) )
|
||||
{
|
||||
newStep = -_vstep;
|
||||
}
|
||||
else
|
||||
{
|
||||
newStep = _vstep;
|
||||
}
|
||||
if( tAbs<float>( newStep ) <
|
||||
tAbs<float>( MinRelStep * intv ) )
|
||||
{
|
||||
newStep = MinRelStep * intv;
|
||||
}
|
||||
}
|
||||
if( newStep != m_step )
|
||||
{
|
||||
m_step = newStep;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
lcdSpinBox::lcdSpinBox( int _min, int _max, int _num_digits,
|
||||
QWidget * _parent, engine * _engine ) :
|
||||
QWidget( _parent ),
|
||||
automatableObject<int>( _engine, 0, _min, _max ),
|
||||
autoObj( _engine, 0, _min, _max ),
|
||||
m_label( NULL ),
|
||||
m_origMousePos()
|
||||
{
|
||||
@@ -80,7 +80,7 @@ lcdSpinBox::~lcdSpinBox()
|
||||
|
||||
void lcdSpinBox::setStep( const int _step )
|
||||
{
|
||||
automatableObject<int>::setStep( tMax( _step, 1 ) );
|
||||
autoObj::setStep( tMax( _step, 1 ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ void lcdSpinBox::setStep( const int _step )
|
||||
|
||||
void lcdSpinBox::setValue( const int _value )
|
||||
{
|
||||
automatableObject<int>::setValue( _value );
|
||||
autoObj::setValue( _value );
|
||||
QString s = m_textForValue[value()];
|
||||
if( s == "" )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user