undo/redo-support for track-content-objects

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@106 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2006-03-15 08:54:33 +00:00
parent 8d5e274269
commit e81c9700c2
11 changed files with 159 additions and 40 deletions

View File

@@ -127,10 +127,9 @@ public:
inline virtual void setInitValue( const T _value )
{
const bool sr = isRecordingSteps();
setStepRecording( FALSE );
saveStepRecordingState( FALSE );
setValue( _value );
setStepRecording( sr );
restoreStepRecordingState();
}
inline virtual void setValue( const T _value )
@@ -159,11 +158,10 @@ public:
it->fittedValue( value() ) !=
it->value() )
{
const bool sr = it->isRecordingSteps();
it->setStepRecording(
it->saveStepRecordingState(
isRecordingSteps() );
it->setValue( value() );
it->setStepRecording( sr );
it->restoreStepRecordingState();
}
}
}
@@ -244,8 +242,7 @@ public:
protected:
virtual void redoStep( const editStep & _edit_step )
{
const bool sr = isRecordingSteps();
setStepRecording( FALSE );
saveStepRecordingState( FALSE );
#ifndef QT3
setValue( static_cast<T>( value() +
_edit_step.data().value<EDIT_STEP_TYPE>() ) );
@@ -253,7 +250,7 @@ protected:
setValue( static_cast<T>( value() + static_cast<EDIT_STEP_TYPE>(
_edit_step.data().toDouble() ) ) );
#endif
setStepRecording( sr );
restoreStepRecordingState();
}
virtual void undoStep( const editStep & _edit_step )

View File

@@ -57,8 +57,10 @@ class QColorGroup;
typedef int csize;
#define QListViewItem Q3ListViewItem
#define vvector QVector
#define vlist QList
#define vstack QStack
#define vvector QVector
#include <QFileInfo>
@@ -72,8 +74,10 @@ inline QString baseName( const QString & _file )
#else /* QT3 */
#define vvector QValueVector
#define vlist QValueList
#define vstack QValueStack
#define vvector QValueVector
#define QMenu QPopupMenu
#define QAbstractButton QButton

View File

@@ -57,6 +57,7 @@
#include "settings.h"
#include "rubberband.h"
#include "engine.h"
#include "editable_object.h"
class QMenu;
@@ -79,7 +80,7 @@ const Uint16 TCO_BORDER_WIDTH = 1;
class trackContentObject : public selectableObject, public settings,
public engineObject
public editableObject
{
Q_OBJECT
public:
@@ -129,6 +130,9 @@ protected:
void setAutoResizeEnabled( bool _e = FALSE );
float pixelsPerTact( void );
virtual void undoStep( const editStep & _edit_step );
virtual void redoStep( const editStep & _edit_step );
protected slots:
void cut( void );
@@ -153,12 +157,14 @@ private:
textFloat * m_hint;
midiTime m_oldTime;// used for undo/redo while mouse-button is pressed
} ;
class trackContentWidget : public QWidget
class trackContentWidget : public QWidget, public editableObject
{
Q_OBJECT
public:
@@ -200,8 +206,16 @@ protected:
virtual void paintEvent( QPaintEvent * _pe );
virtual void resizeEvent( QResizeEvent * _re );
virtual void undoStep( const editStep & _edit_step );
virtual void redoStep( const editStep & _edit_step );
private:
enum actions
{
ADD_TCO, REMOVE_TCO
} ;
track * getTrack( void );
midiTime getPosition( int _mouse_x );

View File

@@ -54,4 +54,6 @@ typedef Uint16 bpm_t; // tempo (MIN_BPM to MAX_BPM)
typedef Uint16 bitrate_t; // bitrate in kbps
typedef Sint8 fx_ch_t; // FX-channel (0 to MAX_EFFECT_CHANNEL)
typedef Uint32 eo_id_t; // (unique) ID of an editable object
#endif