root/branches/undo/gui/src/UndoActions.h @ 1540

Revision 1540, 24.8 KB (checked in by wolke, 3 years ago)

fix left note properties if delete note get undo.

Line 
1#ifndef UNDOACTIONS_H
2#define UNDOACTIONS_H
3
4#include <QtGui>
5#include <QDebug>
6#include <QUndoCommand>
7#include <QPoint>
8
9#include "HydrogenApp.h"
10#include "SongEditor/SongEditor.h"
11#include "SongEditor/SongEditorPanel.h"
12#include "PatternFillDialog.h"
13
14#include "PatternEditor/NotePropertiesRuler.h"
15#include "PatternEditor/DrumPatternEditor.h"
16#include "PatternEditor/PatternEditorPanel.h"
17#include "PatternEditor/NotePropertiesRuler.h"
18
19
20//=====================================================================================================================================
21//test commands
22class TestAction : public QUndoCommand
23{
24public:
25    TestAction( const QString &text)
26        :  m_text(text) { setText("append text"); }
27    virtual void undo()
28        { qDebug() << "Undo " << m_text; }
29    virtual void redo()
30        { qDebug() << "Redo " <<  m_text; }
31private:
32    QString m_text;
33};
34
35//~test commands
36//=====================================================================================================================================
37//song editor commands
38class SE_addPatternAction : public QUndoCommand
39{
40public:
41    SE_addPatternAction( int nColumn, int nRow, unsigned nColumnIndex ){
42        setText( QString( "Add Pattern ( %1, %2 )" ).arg( nColumn ).arg( nRow ) );
43        //setText("add Pattern");
44        __nColumn = nColumn;
45        __nRow = nRow;
46        __nColumnIndex = nColumnIndex;
47    }
48    virtual void undo()
49        {
50            qDebug() << "add Pattern Undo ";
51            HydrogenApp* h2app = HydrogenApp::get_instance();
52            h2app->getSongEditorPanel()->getSongEditor()->deletePattern( __nColumn, __nRow , __nColumnIndex );
53        }
54    virtual void redo()
55        {
56            qDebug() << "add Pattern Redo " ;
57            HydrogenApp* h2app = HydrogenApp::get_instance();
58            h2app->getSongEditorPanel()->getSongEditor()->addPattern( __nColumn, __nRow );
59        }
60private:
61    int __nColumn;
62    int __nRow;
63    unsigned __nColumnIndex;
64};
65
66
67class SE_deletePatternAction : public QUndoCommand
68{
69public:
70    SE_deletePatternAction( int nColumn, int nRow, unsigned nColumnIndex ){
71        setText( QString( "Delete Pattern ( %1, %2 )" ).arg( nColumn ).arg( nRow ) );
72//      setText("delete Pattern");
73        __nColumn = nColumn;
74        __nRow = nRow;
75        __nColumnIndex = nColumnIndex;
76    }
77    virtual void undo()
78        {
79            qDebug() << "Delete pattern Undo ";
80            HydrogenApp* h2app = HydrogenApp::get_instance();
81            h2app->getSongEditorPanel()->getSongEditor()->addPattern( __nColumn, __nRow );
82        }
83    virtual void redo()
84        {
85            qDebug() << "Delete pattern Redo " ;
86            HydrogenApp* h2app = HydrogenApp::get_instance();
87            h2app->getSongEditorPanel()->getSongEditor()->deletePattern( __nColumn, __nRow, __nColumnIndex );
88        }
89private:
90    int __nColumn;
91    int __nRow;
92    unsigned __nColumnIndex;
93};
94
95
96class SE_movePatternListItemAction : public QUndoCommand
97{
98public:
99    SE_movePatternListItemAction(  int nSourcePattern , int nTargetPattern ){
100        setText( QString( "Move Pattern List Item ( %1, %2 )" ).arg( nSourcePattern ).arg( nTargetPattern ) );
101//      setText("delete Pattern");
102        __nSourcePattern = nSourcePattern;
103        __nTargetPattern = nTargetPattern;
104    }
105    virtual void undo()
106        {
107            qDebug() << "Move Pattern List Item Undo ";
108            HydrogenApp* h2app = HydrogenApp::get_instance();
109            h2app->getSongEditorPanel()->getSongEditorPatternList()->movePatternLine( __nTargetPattern, __nSourcePattern );
110        }
111    virtual void redo()
112        {
113            qDebug() << "Move Pattern List Item redo " ;
114            HydrogenApp* h2app = HydrogenApp::get_instance();
115            h2app->getSongEditorPanel()->getSongEditorPatternList()->movePatternLine( __nSourcePattern , __nTargetPattern );
116        }
117private:
118    int __nSourcePattern;
119    int __nTargetPattern;
120};
121
122
123class SE_deletePatternSequenceAction : public QUndoCommand
124{
125public:
126    SE_deletePatternSequenceAction(  QString pFilename ){
127        setText( QString( "Delete complete pattern-sequence" ) );
128        __pFilename = pFilename ;
129    }
130    virtual void undo()
131        {
132                qDebug() << "Delete complete pattern-sequence  undo";
133                HydrogenApp* h2app = HydrogenApp::get_instance();
134                h2app->getSongEditorPanel()->restoreGroupVector( __pFilename );
135        }
136
137    virtual void redo()
138        {
139                qDebug() << "Delete complete pattern-sequence redo " ;
140                HydrogenApp* h2app = HydrogenApp::get_instance();
141                h2app->getSongEditorPanel()->getSongEditor()->clearThePatternSequenseVector( __pFilename );
142        }
143private:
144        QString __pFilename;
145};
146
147class SE_deletePatternFromListAction : public QUndoCommand
148{
149public:
150    SE_deletePatternFromListAction(  QString patternFilename , QString sequenceFileName, int patternPosition ){
151        setText( QString( "Delete pattern from list" ) );
152        __patternFilename =  patternFilename;
153        __sequenceFileName = sequenceFileName;
154        __patternPosition = patternPosition;
155    }
156    virtual void undo()
157        {
158                qDebug() << "Delete pattern from list undo";
159                HydrogenApp* h2app = HydrogenApp::get_instance();
160                h2app->getSongEditorPanel()->getSongEditorPatternList()->restoreDeletedPatternsFromList( __patternFilename, __sequenceFileName, __patternPosition );
161                h2app->getSongEditorPanel()->restoreGroupVector( __sequenceFileName );
162                h2app->getSongEditorPanel()->getSongEditor()->updateEditorandSetTrue();
163        }
164
165    virtual void redo()
166        {
167                qDebug() << "Delete pattern from list redo" ;
168                HydrogenApp* h2app = HydrogenApp::get_instance();
169                h2app->getSongEditorPanel()->getSongEditorPatternList()->deletePatternFromList( __patternFilename, __sequenceFileName, __patternPosition );
170        }
171private:
172        QString __patternFilename;
173        QString __sequenceFileName;
174        int __patternPosition;
175};
176
177class SE_modifyPatternPropertiesAction : public QUndoCommand
178{
179public:
180    SE_modifyPatternPropertiesAction(  QString oldPatternName , QString oldPatternCategory, QString newPatternName , QString newPatternCategory, int patternNr ){
181        setText( QString( "Modify pattern properties" ) );
182        __oldPatternName =  oldPatternName;
183        __oldPatternCategory = oldPatternCategory;
184        __newPatternName =  newPatternName;
185        __newPatternCategory = newPatternCategory;
186        __patternNr = patternNr;
187    }
188    virtual void undo()
189        {
190                qDebug() << "Modify pattern properties undo";
191                HydrogenApp* h2app = HydrogenApp::get_instance();
192                h2app->getSongEditorPanel()->getSongEditorPatternList()->revertPatternPropertiesDialogSettings( __oldPatternName, __oldPatternCategory, __patternNr );
193        }
194
195    virtual void redo()
196        {
197                qDebug() << "Modify pattern properties redo" ;
198                HydrogenApp* h2app = HydrogenApp::get_instance();
199                h2app->getSongEditorPanel()->getSongEditorPatternList()->acceptPatternPropertiesDialogSettings( __newPatternName, __newPatternCategory, __patternNr );
200        }
201private:
202        QString __oldPatternName;
203        QString __oldPatternCategory;
204        QString __newPatternName;
205        QString __newPatternCategory;
206        int __patternNr;
207};
208
209class SE_addEmptyPatternAction : public QUndoCommand
210{
211public:
212    SE_addEmptyPatternAction(  QString newPatternName , QString newPatternCategory , int patternPosition){
213        setText( QString( "Add/Copy pattern" ) );
214        __newPatternName =  newPatternName;
215        __newPatternCategory = newPatternCategory;
216        __patternPosition = patternPosition;
217    }
218    virtual void undo()
219        {
220                qDebug() << "Add/copy pattern undo";
221                HydrogenApp* h2app = HydrogenApp::get_instance();
222                h2app->getSongEditorPanel()->revertaddEmptyPattern( __patternPosition );
223        }
224
225    virtual void redo()
226        {
227                qDebug() << "Add/copy pattern redo" ;
228                HydrogenApp* h2app = HydrogenApp::get_instance();
229                h2app->getSongEditorPanel()->addEmptyPattern( __newPatternName ,__newPatternCategory, __patternPosition );
230        }
231private:
232        QString __newPatternName;
233        QString __newPatternCategory;
234        int __patternPosition;
235};
236
237class SE_loadPatternAction : public QUndoCommand
238{
239public:
240    SE_loadPatternAction(  QString patternName, QString oldPatternName, QString sequenceFileName, int patternPosition){
241        setText( QString( "Load/drag pattern" ) );
242        __patternName =  patternName;
243        __oldPatternName = oldPatternName;
244        __sequenceFileName = sequenceFileName;
245        __patternPosition = patternPosition;
246    }
247    virtual void undo()
248        {
249                qDebug() << "Load/drag pattern undo";
250                HydrogenApp* h2app = HydrogenApp::get_instance();
251                h2app->getSongEditorPanel()->getSongEditorPatternList()->restoreDeletedPatternsFromList( __oldPatternName, __sequenceFileName, __patternPosition );
252                h2app->getSongEditorPanel()->revertaddEmptyPattern( __patternPosition +2 );
253                h2app->getSongEditorPanel()->restoreGroupVector( __sequenceFileName );
254                h2app->getSongEditorPanel()->getSongEditor()->updateEditorandSetTrue();
255        }
256
257    virtual void redo()
258        {
259                qDebug() <<  "Load/drag pattern redo";
260                HydrogenApp* h2app = HydrogenApp::get_instance();
261                h2app->getSongEditorPanel()->getSongEditorPatternList()->deletePatternFromList( __oldPatternName, __sequenceFileName, __patternPosition );
262                h2app->getSongEditorPanel()->getSongEditorPatternList()->loadPatternAction( __patternName, __patternPosition  );
263        }
264private:
265        QString __patternName;
266        QString __oldPatternName;
267        QString __sequenceFileName;
268        int __patternPosition;
269};
270
271
272class SE_fillRangePatternAction : public QUndoCommand
273{
274public:
275    SE_fillRangePatternAction( FillRange* pRange, int nPattern ){
276        setText( QString( "fill/remove range of pattern" ) );
277        __pRange = pRange;
278        __from = pRange->fromVal;
279        __to = pRange->toVal;
280        __bInsert = pRange->bInsert;
281        __nPattern = nPattern;
282    }
283    virtual void undo()
284        {
285                qDebug() << "fill/remove range of undo";
286                HydrogenApp* h2app = HydrogenApp::get_instance();
287                bool insert;
288                if( __bInsert ){
289                        insert = false;
290                }else
291                {
292                        insert = true;
293                }
294                __pRange->bInsert = insert;
295                __pRange->fromVal = __from;
296                __pRange->toVal = __to;
297                h2app->getSongEditorPanel()->getSongEditorPatternList()->fillRangeWithPattern( __pRange, __nPattern);
298        }
299
300    virtual void redo()
301        {
302                qDebug() <<  "fill/remove range of redo";
303                HydrogenApp* h2app = HydrogenApp::get_instance();
304                __pRange->bInsert = __bInsert;
305                __pRange->fromVal = __from;
306                __pRange->toVal = __to;
307                h2app->getSongEditorPanel()->getSongEditorPatternList()->fillRangeWithPattern( __pRange, __nPattern);
308        }
309private:
310        FillRange* __pRange;
311        int __from;
312        int __to;
313        bool __bInsert;
314        int __nPattern;
315};
316
317class SE_movePatternCellAction : public QUndoCommand
318{
319public:
320    SE_movePatternCellAction( std::vector<QPoint> movingCells, std::vector<QPoint> selectedCells, bool bIsCtrlPressed ){
321        setText( QString( "move/copy selected cells" ) );
322        __selectedCells = selectedCells;
323        __movingCells = movingCells;
324        __bIsCtrlPressed = bIsCtrlPressed;
325       
326    }
327    virtual void undo()
328        {
329                qDebug() <<  "move/copy selected cells undo";
330                HydrogenApp* h2app = HydrogenApp::get_instance();
331                h2app->getSongEditorPanel()->getSongEditor()->movePatternCellAction( __selectedCells, __movingCells, __bIsCtrlPressed, true );
332        }
333
334    virtual void redo()
335        {
336                qDebug() <<  "move/copy selected cells redo";
337                HydrogenApp* h2app = HydrogenApp::get_instance();
338                h2app->getSongEditorPanel()->getSongEditor()->movePatternCellAction( __movingCells, __selectedCells, __bIsCtrlPressed, false );
339        }
340private:
341        std::vector<QPoint> __selectedCells;
342        std::vector<QPoint> __movingCells;
343        bool __bIsCtrlPressed;
344};
345
346class SE_editTimeLineAction : public QUndoCommand
347{
348public:
349    SE_editTimeLineAction( int newPosition, float oldBpm, float newBpm ){
350        setText( QString( "edit timeline tempo" ) );
351        __newPosition = newPosition;
352        __oldBpm = oldBpm;
353        __newBpm = newBpm;
354       
355    }
356    virtual void undo()
357        {
358                qDebug() <<  "edit timeline tempo undo";
359                HydrogenApp* h2app = HydrogenApp::get_instance();
360                if(__oldBpm >-1 ){
361                        h2app->getSongEditorPanel()->getSongEditorPositionRuler()->editTimeLineAction( __newPosition, __oldBpm );
362                }else
363                {
364                        h2app->getSongEditorPanel()->getSongEditorPositionRuler()->deleteTimeLinePosition( __newPosition );
365                }
366        }
367
368    virtual void redo()
369        {
370                qDebug() <<  "edit timeline tempo redo";
371                HydrogenApp* h2app = HydrogenApp::get_instance();
372                h2app->getSongEditorPanel()->getSongEditorPositionRuler()->editTimeLineAction( __newPosition, __newBpm );
373        }
374private:
375        int __newPosition;
376        float __oldBpm;
377        float __newBpm;
378};
379
380//~song editor commands
381//=====================================================================================================================================
382//time line commands
383
384class SE_deleteTimeLineAction : public QUndoCommand
385{
386public:
387    SE_deleteTimeLineAction( int newPosition, float oldBpm ){
388        setText( QString( "delete timeline tempo" ) );
389        __newPosition = newPosition;
390        __oldBpm = oldBpm;
391       
392    }
393    virtual void undo()
394        {
395                qDebug() <<  "delete timeline tempo undo";
396                HydrogenApp* h2app = HydrogenApp::get_instance();
397                h2app->getSongEditorPanel()->getSongEditorPositionRuler()->editTimeLineAction( __newPosition, __oldBpm );
398               
399        }
400
401    virtual void redo()
402        {
403                qDebug() <<  "delete timeline tempo redo";
404                HydrogenApp* h2app = HydrogenApp::get_instance();
405                h2app->getSongEditorPanel()->getSongEditorPositionRuler()->deleteTimeLinePosition( __newPosition );
406        }
407private:
408        int __newPosition;
409        float __oldBpm;
410        float __newBpm;
411};
412
413class SE_editTagAction : public QUndoCommand
414{
415public:
416    SE_editTagAction( QString text, QString oldText, int position ){
417        setText( "edit timeline tag" );
418        __text = text;
419        __oldText = oldText;
420        __position = position;
421       
422    }
423    virtual void undo()
424        {
425                qDebug() <<  "edit timeline tag undo";
426                HydrogenApp* h2app = HydrogenApp::get_instance();
427                if( __oldText != "" ){
428                        h2app->getSongEditorPanel()->getSongEditorPositionRuler()->editTagAction( __oldText, __position , __text );
429                }else
430                {
431                        h2app->getSongEditorPanel()->getSongEditorPositionRuler()->deleteTagAction( __text,  __position );
432                }
433               
434        }
435
436    virtual void redo()
437        {
438                qDebug() <<  "edit timeline tag redo";
439                HydrogenApp* h2app = HydrogenApp::get_instance();
440                if( __text == "" ){
441                        h2app->getSongEditorPanel()->getSongEditorPositionRuler()->deleteTagAction( __oldText,  __position );
442                }else
443                {
444                        h2app->getSongEditorPanel()->getSongEditorPositionRuler()->editTagAction( __text, __position, __oldText );
445                }
446        }
447private:
448        QString __text;
449        QString __oldText;
450        int __position;
451};
452
453//~time line commands
454//=====================================================================================================================================
455//pattern editor commands
456
457class SE_addNoteAction : public QUndoCommand
458{
459public:
460        SE_addNoteAction(  int nColumn,
461                           int nRow,
462                           int selectedPatternNumber,
463                           int oldLength,
464                           float oldVelocity,
465                           float oldPan_L,
466                           float oldPan_R,
467                           float oldLeadLag,
468                           int oldNoteKeyVal,
469                           int oldOctaveKeyVal ){
470        setText( QString( "Add Note ( %1, %2)" ).arg( nColumn ).arg( nRow ) );
471        //setText("add Pattern");
472        __nColumn = nColumn;
473        __nRow = nRow;
474        __selectedPatternNumber = selectedPatternNumber;
475        __oldLength = oldLength;
476        __oldVelocity = oldVelocity;
477        __oldPan_L = oldPan_L;
478        __oldPan_R = oldPan_R;
479        __oldLeadLag = oldLeadLag;
480        __oldNoteKeyVal = oldNoteKeyVal;
481        __oldOctaveKeyVal = oldOctaveKeyVal;
482        }
483        virtual void undo()
484        {
485                qDebug() << "Add note Undo ";
486                HydrogenApp* h2app = HydrogenApp::get_instance();
487                h2app->getPatternEditorPanel()->getDrumPatternEditor()->addOrDeleteNoteAction(  __nColumn,
488                                                                                                __nRow,
489                                                                                                __selectedPatternNumber,
490                                                                                                __oldLength,
491                                                                                                __oldVelocity,
492                                                                                                __oldPan_L,
493                                                                                                __oldPan_R,
494                                                                                                __oldLeadLag,
495                                                                                                __oldNoteKeyVal,
496                                                                                                __oldOctaveKeyVal );
497        }
498        virtual void redo()
499        {
500                qDebug() << "Add Note Redo " ;
501                HydrogenApp* h2app = HydrogenApp::get_instance();
502                h2app->getPatternEditorPanel()->getDrumPatternEditor()->addOrDeleteNoteAction(  __nColumn,
503                                                                                                __nRow,
504                                                                                                __selectedPatternNumber,
505                                                                                                __oldLength,
506                                                                                                __oldVelocity,
507                                                                                                __oldPan_L,
508                                                                                                __oldPan_R,
509                                                                                                __oldLeadLag,
510                                                                                                __oldNoteKeyVal,
511                                                                                                __oldOctaveKeyVal );
512        }
513private:
514        int __nColumn;
515        int __nRow;
516        int __selectedPatternNumber;
517        int __oldLength;
518        float __oldVelocity;
519        float __oldPan_L;
520        float __oldPan_R;
521        float __oldLeadLag;
522        int __oldNoteKeyVal;
523        int __oldOctaveKeyVal;
524};
525
526
527class SE_addNoteRightClickAction : public QUndoCommand
528{
529public:
530        SE_addNoteRightClickAction( int nColumn, int nRow, int selectedPatternNumber ){
531        setText( QString( "Add off note Note ( %1, %2 )" ).arg( nColumn ).arg( nRow ) );
532        //setText("add Pattern");
533        __nColumn = nColumn;
534        __nRow = nRow;
535        __selectedPatternNumber = selectedPatternNumber;
536        }
537        virtual void undo()
538        {
539                qDebug() << "Add off note Note Undo ";
540                HydrogenApp* h2app = HydrogenApp::get_instance();
541                h2app->getPatternEditorPanel()->getDrumPatternEditor()->addOrDeleteNoteAction( __nColumn, __nRow, __selectedPatternNumber, -1, 0.8f, 0.5f, 0.5f, 0.0, 0, 0 );
542        }
543        virtual void redo()
544        {
545                qDebug() << "Add off note Note Redo " ;
546                HydrogenApp* h2app = HydrogenApp::get_instance();
547                h2app->getPatternEditorPanel()->getDrumPatternEditor()->addNoteRightClickAction( __nColumn, __nRow, __selectedPatternNumber );
548        }
549private:
550        int __nColumn;
551        int __nRow;
552        int __selectedPatternNumber;
553};
554
555class SE_editNoteLenghtAction : public QUndoCommand
556{
557public:
558        SE_editNoteLenghtAction( int nColumn, int nRealColumn, int row, int length, int oldLength, int selectedPatternNumber ){
559        setText( QString( "Change note length" ) );
560        __nColumn = nColumn;
561        __nRealColumn = nRealColumn;
562        __row = row;
563        __length = length;
564        __oldLength = oldLength;
565        __selectedPatternNumber = selectedPatternNumber;
566        }
567        virtual void undo()
568        {
569                qDebug() << "Change note length Undo ";
570                HydrogenApp* h2app = HydrogenApp::get_instance();
571                h2app->getPatternEditorPanel()->getDrumPatternEditor()->editNoteLenghtAction( __nColumn,  __nRealColumn, __row, __oldLength, __selectedPatternNumber );
572        }
573        virtual void redo()
574        {
575                qDebug() << "Change note length Redo " ;
576                HydrogenApp* h2app = HydrogenApp::get_instance();
577                h2app->getPatternEditorPanel()->getDrumPatternEditor()->editNoteLenghtAction( __nColumn,  __nRealColumn, __row, __length, __selectedPatternNumber );
578        }
579private:
580        int __nColumn;
581        int __nRealColumn;
582        int __row;
583        int __oldLength;
584        int __length;
585        int __selectedPatternNumber;
586};
587
588//~pattern editor commands
589//=====================================================================================================================================
590//piano roll editor commands
591
592class SE_addNotePianoRollAction : public QUndoCommand
593{
594public:
595        SE_addNotePianoRollAction( int nColumn,
596                                   int pressedLine,
597                                   int selectedPatternNumber,
598                                   int nSelectedInstrumentnumber,
599                                   int oldLength,
600                                   float oldVelocity,
601                                   float oldPan_L,
602                                   float oldPan_R,
603                                   float oldLeadLag,
604                                   int oldNoteKeyVal,
605                                   int oldOctaveKeyVal ){
606        setText( QString( "Add Piano Roll Note ( %1, %2 )" ).arg( nColumn ).arg( pressedLine ) );
607        //setText("add Pattern");
608        __nColumn = nColumn;
609        __pressedLine = pressedLine;
610        __selectedPatternNumber = selectedPatternNumber;
611        __nSelectedInstrumentnumber = nSelectedInstrumentnumber;
612        __oldLength = oldLength;
613        __oldVelocity = oldVelocity;
614        __oldPan_L = oldPan_L;
615        __oldPan_R = oldPan_R;
616        __oldLeadLag = oldLeadLag;
617        __oldNoteKeyVal = oldNoteKeyVal;
618        __oldOctaveKeyVal = oldOctaveKeyVal;
619
620        }
621        virtual void undo()
622        {
623                qDebug() << "Add Piano Roll note Undo ";
624                HydrogenApp* h2app = HydrogenApp::get_instance();
625                h2app->getPatternEditorPanel()->getPianoRollEditor()->addOrDeleteNoteAction( __nColumn,
626                                                                                             __pressedLine,
627                                                                                             __selectedPatternNumber,
628                                                                                             __nSelectedInstrumentnumber,
629                                                                                             __oldLength,
630                                                                                             __oldVelocity,
631                                                                                             __oldPan_L,
632                                                                                             __oldPan_R,
633                                                                                             __oldLeadLag,
634                                                                                             __oldNoteKeyVal,
635                                                                                             __oldOctaveKeyVal );
636        }
637        virtual void redo()
638        {
639                qDebug() << "Add Piano Roll Note Redo " ;
640                HydrogenApp* h2app = HydrogenApp::get_instance();
641                h2app->getPatternEditorPanel()->getPianoRollEditor()->addOrDeleteNoteAction( __nColumn,
642                                                                                             __pressedLine,
643                                                                                             __selectedPatternNumber,
644                                                                                             __nSelectedInstrumentnumber,
645                                                                                             __oldLength,
646                                                                                             __oldVelocity,
647                                                                                             __oldPan_L,
648                                                                                             __oldPan_R,
649                                                                                             __oldLeadLag,
650                                                                                             __oldNoteKeyVal,
651                                                                                             __oldOctaveKeyVal );
652        }
653private:
654        int __nColumn;
655        int __pressedLine;
656        int __selectedPatternNumber;
657        int __nSelectedInstrumentnumber;
658        int __oldLength;
659        float __oldVelocity;
660        float __oldPan_L;
661        float __oldPan_R;
662        float __oldLeadLag;
663        int __oldNoteKeyVal;
664        int __oldOctaveKeyVal;
665};
666
667class SE_addNoteRightClickPianoRollAction : public QUndoCommand
668{
669public:
670        SE_addNoteRightClickPianoRollAction( int nColumn, int pressedLine, int selectedPatternNumber, int nSelectedInstrumentnumber ){
671        setText( QString( "Add off note Note ( %1, %2 )" ).arg( nColumn ).arg( pressedLine ) );
672        //setText("add Pattern");
673        __nColumn = nColumn;
674        __pressedLine = pressedLine;
675        __selectedPatternNumber = selectedPatternNumber;
676        __nSelectedInstrumentnumber = nSelectedInstrumentnumber;
677        }
678        virtual void undo()
679        {
680                qDebug() << "Add off note Note Undo ";
681                HydrogenApp* h2app = HydrogenApp::get_instance();
682                h2app->getPatternEditorPanel()->getPianoRollEditor()->addOrDeleteNoteAction( __nColumn, __pressedLine, __selectedPatternNumber,  __nSelectedInstrumentnumber, -1, 0.8f, 0.5f, 0.5f, 0.0, 0, 0 );
683        }
684        virtual void redo()
685        {
686                qDebug() << "Add off note Note Redo " ;
687                HydrogenApp* h2app = HydrogenApp::get_instance();
688                h2app->getPatternEditorPanel()->getPianoRollEditor()->addNoteRightClickAction( __nColumn, __pressedLine, __selectedPatternNumber,  __nSelectedInstrumentnumber);
689        }
690private:
691        int __nColumn;
692        int __pressedLine;
693        int __selectedPatternNumber;
694        int __nSelectedInstrumentnumber;
695};
696
697
698class SE_editNoteLenghtPianoRollAction : public QUndoCommand
699{
700public:
701        SE_editNoteLenghtPianoRollAction( int nColumn, int nRealColumn, int length, int oldLength, int selectedPatternNumber, int nSelectedInstrumentnumber ){
702        setText( QString( "Change note length Piano Roll" ) );
703        __nColumn = nColumn;
704        __nRealColumn = nRealColumn;
705        __length = length;
706        __oldLength = oldLength;
707        __selectedPatternNumber = selectedPatternNumber;
708        __nSelectedInstrumentnumber = nSelectedInstrumentnumber;
709        }
710        virtual void undo()
711        {
712                qDebug() << "Change note length Piano Roll Undo ";
713                HydrogenApp* h2app = HydrogenApp::get_instance();
714                h2app->getPatternEditorPanel()->getPianoRollEditor()->editNoteLenghtAction( __nColumn, __nRealColumn, __oldLength, __selectedPatternNumber, __nSelectedInstrumentnumber );
715        }
716        virtual void redo()
717        {
718                qDebug() << "Change note length Piano RollRedo " ;
719                HydrogenApp* h2app = HydrogenApp::get_instance();
720                h2app->getPatternEditorPanel()->getPianoRollEditor()->editNoteLenghtAction( __nColumn,  __nRealColumn, __length, __selectedPatternNumber, __nSelectedInstrumentnumber );
721        }
722private:
723        int __nColumn;
724        int __nRealColumn;
725        int __oldLength;
726        int __length;
727        int __selectedPatternNumber;
728        int __nSelectedInstrumentnumber;
729};
730
731//~piano roll editor commands
732//=====================================================================================================================================
733//Note Properties Ruler commands
734
735class SE_editNotePropertiesVolumeAction : public QUndoCommand
736{
737public:
738
739        SE_editNotePropertiesVolumeAction( int undoColumn,
740                                           QString mode,
741                                           int nSelectedPatternNumber,
742                                           int nSelectedInstrument,
743                                           float velocity,
744                                           float oldVelocity,
745                                           float pan_L,
746                                           float oldPan_L,
747                                           float pan_R,
748                                           float oldPan_R,
749                                           float leadLag,
750                                           float oldLeadLag,
751                                           int noteKeyVal,
752                                           int oldNoteKeyVal,
753                                           int octaveKeyVal,
754                                           int oldOctaveKeyVal)
755        {
756
757
758        setText( QString( "edit note property" ) );
759        __undoColumn = undoColumn;
760        __mode = mode;
761        __nSelectedPatternNumber = nSelectedPatternNumber;
762        __nSelectedInstrument = nSelectedInstrument;
763        __velocity = velocity;
764        __oldVelocity = oldVelocity;
765        __pan_L = pan_L;
766        __oldPan_L = oldPan_L;
767        __pan_R = pan_R;
768        __oldPan_R = oldPan_R;
769        __leadLag = leadLag;
770        __oldLeadLag = oldLeadLag;
771        __noteKeyVal = noteKeyVal;
772        __oldNoteKeyVal = oldNoteKeyVal;
773        __octaveKeyVal = octaveKeyVal;
774        __oldOctaveKeyVal = oldOctaveKeyVal;
775       
776        }
777        virtual void undo()
778        {
779                qDebug() << "edit note property Undo ";
780                HydrogenApp* h2app = HydrogenApp::get_instance();
781       
782                h2app->getPatternEditorPanel()->getDrumPatternEditor()->undoRedoAction( __undoColumn,
783                                                                                        __mode,
784                                                                                        __nSelectedPatternNumber,
785                                                                                        __nSelectedInstrument,
786                                                                                        __oldVelocity,
787                                                                                        __oldPan_L,
788                                                                                        __oldPan_R,
789                                                                                        __oldLeadLag,
790                                                                                        __oldNoteKeyVal,
791                                                                                        __oldOctaveKeyVal );
792        }
793        virtual void redo()
794        {
795                qDebug() << "edit note property Redo " ;
796                HydrogenApp* h2app = HydrogenApp::get_instance();
797                h2app->getPatternEditorPanel()->getDrumPatternEditor()->undoRedoAction( __undoColumn,
798                                                                                        __mode,
799                                                                                        __nSelectedPatternNumber,
800                                                                                        __nSelectedInstrument,
801                                                                                        __velocity,
802                                                                                        __pan_L,
803                                                                                        __pan_R,
804                                                                                        __leadLag,
805                                                                                        __noteKeyVal,
806                                                                                        __octaveKeyVal );
807        }
808private:
809
810
811        int __undoColumn;
812        QString __mode;
813        int __nSelectedPatternNumber;
814        int __nSelectedInstrument;
815        float __velocity;
816        float __oldVelocity;
817        float __pan_L;
818        float __oldPan_L;
819        float __pan_R;
820        float __oldPan_R;
821        float __leadLag;
822        float __oldLeadLag;
823        int __noteKeyVal;
824        int __oldNoteKeyVal;
825        int __octaveKeyVal;
826        int __oldOctaveKeyVal;
827        int __selectedPatternNumber;
828        int __nSelectedInstrumentnumber;
829
830
831
832};
833#endif // UNDOACTIONS_H
Note: See TracBrowser for help on using the browser.