1 #ifndef UNDOACTIONS_H 2 #define UNDOACTIONS_H 3 4 #include <QtGui> 5 #if QT_VERSION >= 0x050000 6 # include <QtWidgets> 7 #endif 8 #include <QDebug> 9 #include <QUndoCommand> 10 #include <QPoint> 11 #include <hydrogen/basics/note.h> 12 #include <hydrogen/basics/pattern.h> 13 #include <hydrogen/basics/automation_path.h> 14 15 #include "HydrogenApp.h" 16 #include "SongEditor/SongEditor.h" 17 #include "SongEditor/SongEditorPanel.h" 18 #include "SongEditor/PatternFillDialog.h" 19 20 #include "PatternEditor/NotePropertiesRuler.h" 21 #include "PatternEditor/DrumPatternEditor.h" 22 #include "PatternEditor/PatternEditorPanel.h" 23 #include "PatternEditor/NotePropertiesRuler.h" 24 #include "Widgets/AutomationPathView.h" 25 26 27 //===================================================================================================================================== 28 //song editor commands 29 class SE_addPatternAction : public QUndoCommand 30 { 31 public: SE_addPatternAction(int nColumn,int nRow,unsigned nColumnIndex)32 SE_addPatternAction( int nColumn, int nRow, unsigned nColumnIndex ){ 33 setText( QString( "Add Pattern ( %1, %2 )" ).arg( nColumn ).arg( nRow ) ); 34 __nColumn = nColumn; 35 __nRow = nRow; 36 __nColumnIndex = nColumnIndex; 37 } undo()38 virtual void undo() 39 { 40 //qDebug() << "add Pattern Undo "; 41 HydrogenApp* h2app = HydrogenApp::get_instance(); 42 h2app->getSongEditorPanel()->getSongEditor()->deletePattern( __nColumn, __nRow , __nColumnIndex ); 43 } redo()44 virtual void redo() 45 { 46 //qDebug() << "add Pattern Redo " ; 47 HydrogenApp* h2app = HydrogenApp::get_instance(); 48 h2app->getSongEditorPanel()->getSongEditor()->addPattern( __nColumn, __nRow ); 49 } 50 private: 51 int __nColumn; 52 int __nRow; 53 unsigned __nColumnIndex; 54 }; 55 56 57 class SE_deletePatternAction : public QUndoCommand 58 { 59 public: SE_deletePatternAction(int nColumn,int nRow,unsigned nColumnIndex)60 SE_deletePatternAction( int nColumn, int nRow, unsigned nColumnIndex ){ 61 setText( QString( "Delete Pattern ( %1, %2 )" ).arg( nColumn ).arg( nRow ) ); 62 __nColumn = nColumn; 63 __nRow = nRow; 64 __nColumnIndex = nColumnIndex; 65 } undo()66 virtual void undo() 67 { 68 //qDebug() << "Delete pattern Undo "; 69 HydrogenApp* h2app = HydrogenApp::get_instance(); 70 h2app->getSongEditorPanel()->getSongEditor()->addPattern( __nColumn, __nRow ); 71 } redo()72 virtual void redo() 73 { 74 //qDebug() << "Delete pattern Redo " ; 75 HydrogenApp* h2app = HydrogenApp::get_instance(); 76 h2app->getSongEditorPanel()->getSongEditor()->deletePattern( __nColumn, __nRow, __nColumnIndex ); 77 } 78 private: 79 int __nColumn; 80 int __nRow; 81 unsigned __nColumnIndex; 82 }; 83 84 85 class SE_movePatternListItemAction : public QUndoCommand 86 { 87 public: SE_movePatternListItemAction(int nSourcePattern,int nTargetPattern)88 SE_movePatternListItemAction( int nSourcePattern , int nTargetPattern ){ 89 setText( QString( "Move pattern list item ( %1, %2 )" ).arg( nSourcePattern ).arg( nTargetPattern ) ); 90 __nSourcePattern = nSourcePattern; 91 __nTargetPattern = nTargetPattern; 92 } undo()93 virtual void undo() 94 { 95 //qDebug() << "Move Pattern List Item Undo "; 96 HydrogenApp* h2app = HydrogenApp::get_instance(); 97 h2app->getSongEditorPanel()->getSongEditorPatternList()->movePatternLine( __nTargetPattern, __nSourcePattern ); 98 } redo()99 virtual void redo() 100 { 101 //qDebug() << "Move Pattern List Item redo " ; 102 HydrogenApp* h2app = HydrogenApp::get_instance(); 103 h2app->getSongEditorPanel()->getSongEditorPatternList()->movePatternLine( __nSourcePattern , __nTargetPattern ); 104 } 105 private: 106 int __nSourcePattern; 107 int __nTargetPattern; 108 }; 109 110 111 class SE_deletePatternSequenceAction : public QUndoCommand 112 { 113 public: SE_deletePatternSequenceAction(QString pFilename)114 SE_deletePatternSequenceAction( QString pFilename ){ 115 setText( QString( "Delete complete pattern-sequence" ) ); 116 __pFilename = pFilename ; 117 } undo()118 virtual void undo() 119 { 120 //qDebug() << "Delete complete pattern-sequence undo"; 121 HydrogenApp* h2app = HydrogenApp::get_instance(); 122 h2app->getSongEditorPanel()->restoreGroupVector( __pFilename ); 123 } 124 redo()125 virtual void redo() 126 { 127 //qDebug() << "Delete complete pattern-sequence redo " ; 128 HydrogenApp* h2app = HydrogenApp::get_instance(); 129 h2app->getSongEditorPanel()->getSongEditor()->clearThePatternSequenceVector( __pFilename ); 130 } 131 private: 132 QString __pFilename; 133 }; 134 135 class SE_deletePatternFromListAction : public QUndoCommand 136 { 137 public: SE_deletePatternFromListAction(QString patternFilename,QString sequenceFileName,int patternPosition)138 SE_deletePatternFromListAction( QString patternFilename , QString sequenceFileName, int patternPosition ){ 139 setText( QString( "Delete pattern from list" ) ); 140 __patternFilename = patternFilename; 141 __sequenceFileName = sequenceFileName; 142 __patternPosition = patternPosition; 143 } undo()144 virtual void undo() 145 { 146 //qDebug() << "Delete pattern from list undo"; 147 HydrogenApp* h2app = HydrogenApp::get_instance(); 148 h2app->getSongEditorPanel()->getSongEditorPatternList()->restoreDeletedPatternsFromList( __patternFilename, __sequenceFileName, __patternPosition ); 149 h2app->getSongEditorPanel()->restoreGroupVector( __sequenceFileName ); 150 h2app->getSongEditorPanel()->getSongEditor()->updateEditorandSetTrue(); 151 } 152 redo()153 virtual void redo() 154 { 155 //qDebug() << "Delete pattern from list redo" ; 156 HydrogenApp* h2app = HydrogenApp::get_instance(); 157 h2app->getSongEditorPanel()->getSongEditorPatternList()->deletePatternFromList( __patternFilename, __sequenceFileName, __patternPosition ); 158 } 159 private: 160 QString __patternFilename; 161 QString __sequenceFileName; 162 int __patternPosition; 163 }; 164 165 class SE_modifyPatternPropertiesAction : public QUndoCommand 166 { 167 public: SE_modifyPatternPropertiesAction(QString oldPatternName,QString oldPatternInfo,QString oldPatternCategory,QString newPatternName,QString newPatternInfo,QString newPatternCategory,int patternNr)168 SE_modifyPatternPropertiesAction( QString oldPatternName ,QString oldPatternInfo, QString oldPatternCategory, QString newPatternName , QString newPatternInfo, QString newPatternCategory, int patternNr ){ 169 setText( QString( "Modify pattern properties" ) ); 170 __oldPatternName = oldPatternName; 171 __oldPatternCategory = oldPatternCategory; 172 __oldPatternInfo = oldPatternInfo; 173 __newPatternName = newPatternName; 174 __newPatternInfo = newPatternInfo; 175 __newPatternCategory = newPatternCategory; 176 __patternNr = patternNr; 177 } undo()178 virtual void undo() 179 { 180 //qDebug() << "Modify pattern properties undo"; 181 HydrogenApp* h2app = HydrogenApp::get_instance(); 182 h2app->getSongEditorPanel()->getSongEditorPatternList()->revertPatternPropertiesDialogSettings( __oldPatternName, __oldPatternInfo, __oldPatternCategory, __patternNr ); 183 } 184 redo()185 virtual void redo() 186 { 187 //qDebug() << "Modify pattern properties redo" ; 188 HydrogenApp* h2app = HydrogenApp::get_instance(); 189 h2app->getSongEditorPanel()->getSongEditorPatternList()->acceptPatternPropertiesDialogSettings( __newPatternName, __newPatternInfo, __newPatternCategory, __patternNr ); 190 } 191 private: 192 QString __oldPatternName; 193 QString __oldPatternInfo; 194 QString __oldPatternCategory; 195 196 QString __newPatternName; 197 QString __newPatternInfo; 198 QString __newPatternCategory; 199 int __patternNr; 200 }; 201 202 203 class SE_copyPatternAction : public QUndoCommand 204 { 205 public: SE_copyPatternAction(QString patternFilename,int patternPosition)206 SE_copyPatternAction( QString patternFilename, int patternPosition ){ 207 setText( QString( "Copy pattern" ) ); 208 __patternFilename = patternFilename; 209 __patternPosition = patternPosition; 210 } undo()211 virtual void undo() 212 { 213 //qDebug() << "copy pattern undo"; 214 HydrogenApp* h2app = HydrogenApp::get_instance(); 215 h2app->getSongEditorPanel()->deletePattern( __patternPosition ); 216 } 217 redo()218 virtual void redo() 219 { 220 //qDebug() << "copy pattern redo" ; 221 HydrogenApp* h2app = HydrogenApp::get_instance(); 222 h2app->getSongEditorPanel()->getSongEditorPatternList()->patternPopup_copyAction( __patternFilename, __patternPosition ); 223 } 224 private: 225 QString __patternFilename; 226 int __patternPosition; 227 }; 228 229 class SE_insertPatternAction : public QUndoCommand 230 { 231 public: SE_insertPatternAction(int patternPosition,H2Core::Pattern * pPattern)232 SE_insertPatternAction( int patternPosition, H2Core::Pattern* pPattern ) 233 { 234 setText( QString( "Add pattern" ) ); 235 __patternPosition = patternPosition; 236 __newPattern = pPattern; 237 } ~SE_insertPatternAction()238 ~SE_insertPatternAction() 239 { 240 delete __newPattern; 241 } undo()242 virtual void undo() 243 { 244 //qDebug() << "Add pattern undo"; 245 HydrogenApp* h2app = HydrogenApp::get_instance(); 246 h2app->getSongEditorPanel()->deletePattern( __patternPosition ); 247 } redo()248 virtual void redo() 249 { 250 //qDebug() << "Add pattern redo" ; 251 HydrogenApp* h2app = HydrogenApp::get_instance(); 252 h2app->getSongEditorPanel()->insertPattern( __patternPosition, new H2Core::Pattern( __newPattern ) ); 253 } 254 private: 255 H2Core::Pattern* __newPattern; 256 257 int __patternPosition; 258 }; 259 260 class SE_loadPatternAction : public QUndoCommand 261 { 262 public: SE_loadPatternAction(QString patternName,QString oldPatternName,QString sequenceFileName,int patternPosition,bool dragFromList)263 SE_loadPatternAction( QString patternName, QString oldPatternName, QString sequenceFileName, int patternPosition, bool dragFromList){ 264 setText( QString( "Load/drag pattern" ) ); 265 __patternName = patternName; 266 __oldPatternName = oldPatternName; 267 __sequenceFileName = sequenceFileName; 268 __patternPosition = patternPosition; 269 __dragFromList = dragFromList; 270 } undo()271 virtual void undo() 272 { 273 //qDebug() << "Load/drag pattern undo" << __dragFromList; 274 HydrogenApp* h2app = HydrogenApp::get_instance(); 275 if( __dragFromList ){ 276 h2app->getSongEditorPanel()->getSongEditorPatternList()->deletePatternFromList( __oldPatternName, __sequenceFileName, __patternPosition ); 277 }else 278 { 279 h2app->getSongEditorPanel()->getSongEditorPatternList()->restoreDeletedPatternsFromList( __oldPatternName, __sequenceFileName, __patternPosition ); 280 h2app->getSongEditorPanel()->deletePattern( __patternPosition +1 ); 281 } 282 h2app->getSongEditorPanel()->restoreGroupVector( __sequenceFileName ); 283 h2app->getSongEditorPanel()->getSongEditor()->updateEditorandSetTrue(); 284 } 285 redo()286 virtual void redo() 287 { 288 //qDebug() << "Load/drag pattern redo" << __dragFromList << __patternPosition; 289 HydrogenApp* h2app = HydrogenApp::get_instance(); 290 if(!__dragFromList){ 291 h2app->getSongEditorPanel()->getSongEditorPatternList()->deletePatternFromList( __oldPatternName, __sequenceFileName, __patternPosition ); 292 } 293 h2app->getSongEditorPanel()->getSongEditorPatternList()->loadPatternAction( __patternName, __patternPosition ); 294 } 295 private: 296 QString __patternName; 297 QString __oldPatternName; 298 QString __sequenceFileName; 299 int __patternPosition; 300 bool __dragFromList; 301 }; 302 303 304 class SE_fillRangePatternAction : public QUndoCommand 305 { 306 public: SE_fillRangePatternAction(FillRange * pRange,int nPattern)307 SE_fillRangePatternAction( FillRange* pRange, int nPattern ){ 308 setText( QString( "Fill/remove range of pattern" ) ); 309 __pRange = pRange; 310 __from = pRange->fromVal; 311 __to = pRange->toVal; 312 __bInsert = pRange->bInsert; 313 __nPattern = nPattern; 314 } undo()315 virtual void undo() 316 { 317 //qDebug() << "fill/remove range of undo"; 318 HydrogenApp* h2app = HydrogenApp::get_instance(); 319 bool insert; 320 if( __bInsert ){ 321 insert = false; 322 }else 323 { 324 insert = true; 325 } 326 __pRange->bInsert = insert; 327 __pRange->fromVal = __from; 328 __pRange->toVal = __to; 329 h2app->getSongEditorPanel()->getSongEditorPatternList()->fillRangeWithPattern( __pRange, __nPattern); 330 } 331 redo()332 virtual void redo() 333 { 334 //qDebug() << "fill/remove range of redo"; 335 HydrogenApp* h2app = HydrogenApp::get_instance(); 336 __pRange->bInsert = __bInsert; 337 __pRange->fromVal = __from; 338 __pRange->toVal = __to; 339 h2app->getSongEditorPanel()->getSongEditorPatternList()->fillRangeWithPattern( __pRange, __nPattern); 340 } 341 private: 342 FillRange* __pRange; 343 int __from; 344 int __to; 345 bool __bInsert; 346 int __nPattern; 347 }; 348 349 class SE_movePatternCellAction : public QUndoCommand 350 { 351 public: SE_movePatternCellAction(std::vector<QPoint> movingCells,std::vector<QPoint> selectedCells,std::vector<QPoint> existingCells,bool bIsCtrlPressed)352 SE_movePatternCellAction( std::vector<QPoint> movingCells, std::vector<QPoint> selectedCells, std::vector<QPoint> existingCells, bool bIsCtrlPressed ){ 353 setText( QString( "Move/copy selected cells" ) ); 354 __selectedCells = selectedCells; 355 __movingCells = movingCells; 356 __existingCells = existingCells; 357 __bIsCtrlPressed = bIsCtrlPressed; 358 359 } undo()360 virtual void undo() 361 { 362 //qDebug() << "move/copy selected cells undo"; 363 HydrogenApp* h2app = HydrogenApp::get_instance(); 364 h2app->getSongEditorPanel()->getSongEditor()->movePatternCellAction( __selectedCells, __movingCells, __existingCells, __bIsCtrlPressed, true ); 365 } 366 redo()367 virtual void redo() 368 { 369 //qDebug() << "move/copy selected cells redo"; 370 HydrogenApp* h2app = HydrogenApp::get_instance(); 371 h2app->getSongEditorPanel()->getSongEditor()->movePatternCellAction( __movingCells, __selectedCells, __existingCells, __bIsCtrlPressed, false ); 372 } 373 private: 374 std::vector<QPoint> __selectedCells; 375 std::vector<QPoint> __movingCells; 376 std::vector<QPoint> __existingCells; 377 bool __bIsCtrlPressed; 378 }; 379 380 class SE_editTimeLineAction : public QUndoCommand 381 { 382 public: SE_editTimeLineAction(int newPosition,float oldBpm,float newBpm)383 SE_editTimeLineAction( int newPosition, float oldBpm, float newBpm ){ 384 setText( QString( "Edit timeline tempo" ) ); 385 __newPosition = newPosition; 386 __oldBpm = oldBpm; 387 __newBpm = newBpm; 388 389 } undo()390 virtual void undo() 391 { 392 //qDebug() << "edit timeline tempo undo"; 393 HydrogenApp* h2app = HydrogenApp::get_instance(); 394 if(__oldBpm >-1 ){ 395 h2app->getSongEditorPanel()->getSongEditorPositionRuler()->editTimeLineAction( __newPosition, __oldBpm ); 396 }else 397 { 398 h2app->getSongEditorPanel()->getSongEditorPositionRuler()->deleteTimeLinePosition( __newPosition ); 399 } 400 } 401 redo()402 virtual void redo() 403 { 404 //qDebug() << "edit timeline tempo redo"; 405 HydrogenApp* h2app = HydrogenApp::get_instance(); 406 h2app->getSongEditorPanel()->getSongEditorPositionRuler()->editTimeLineAction( __newPosition, __newBpm ); 407 } 408 private: 409 int __newPosition; 410 float __oldBpm; 411 float __newBpm; 412 }; 413 414 //~song editor commands 415 //===================================================================================================================================== 416 //time line commands 417 418 class SE_deleteTimeLineAction : public QUndoCommand 419 { 420 public: SE_deleteTimeLineAction(int newPosition,float oldBpm)421 SE_deleteTimeLineAction( int newPosition, float oldBpm ){ 422 setText( QString( "Delete timeline tempo" ) ); 423 __newPosition = newPosition; 424 __oldBpm = oldBpm; 425 426 } undo()427 virtual void undo() 428 { 429 //qDebug() << "delete timeline tempo undo"; 430 HydrogenApp* h2app = HydrogenApp::get_instance(); 431 h2app->getSongEditorPanel()->getSongEditorPositionRuler()->editTimeLineAction( __newPosition, __oldBpm ); 432 433 } 434 redo()435 virtual void redo() 436 { 437 //qDebug() << "delete timeline tempo redo"; 438 HydrogenApp* h2app = HydrogenApp::get_instance(); 439 h2app->getSongEditorPanel()->getSongEditorPositionRuler()->deleteTimeLinePosition( __newPosition ); 440 } 441 private: 442 int __newPosition; 443 float __oldBpm; 444 float __newBpm; 445 }; 446 447 class SE_editTagAction : public QUndoCommand 448 { 449 public: SE_editTagAction(QString text,QString oldText,int position)450 SE_editTagAction( QString text, QString oldText, int position ){ 451 setText( "Edit timeline tag" ); 452 __text = text; 453 __oldText = oldText; 454 __position = position; 455 456 } undo()457 virtual void undo() 458 { 459 //qDebug() << "edit timeline tag undo"; 460 HydrogenApp* h2app = HydrogenApp::get_instance(); 461 if( __oldText != "" ){ 462 h2app->getSongEditorPanel()->getSongEditorPositionRuler()->editTagAction( __oldText, __position , __text ); 463 }else 464 { 465 h2app->getSongEditorPanel()->getSongEditorPositionRuler()->deleteTagAction( __text, __position ); 466 } 467 468 } 469 redo()470 virtual void redo() 471 { 472 //qDebug() << "edit timeline tag redo"; 473 HydrogenApp* h2app = HydrogenApp::get_instance(); 474 if( __text == "" ){ 475 h2app->getSongEditorPanel()->getSongEditorPositionRuler()->deleteTagAction( __oldText, __position ); 476 }else 477 { 478 h2app->getSongEditorPanel()->getSongEditorPositionRuler()->editTagAction( __text, __position, __oldText ); 479 } 480 } 481 private: 482 QString __text; 483 QString __oldText; 484 int __position; 485 }; 486 487 //~time line commands 488 //===================================================================================================================================== 489 //pattern editor commands 490 491 class SE_addNoteAction : public QUndoCommand 492 { 493 public: SE_addNoteAction(int nColumn,int nRow,int selectedPatternNumber,int oldLength,float oldVelocity,float oldPan_L,float oldPan_R,float oldLeadLag,int oldNoteKeyVal,int oldOctaveKeyVal,bool noteExisted,bool listen,bool isMidi,bool isInstrumentMode)494 SE_addNoteAction( int nColumn, 495 int nRow, 496 int selectedPatternNumber, 497 int oldLength, 498 float oldVelocity, 499 float oldPan_L, 500 float oldPan_R, 501 float oldLeadLag, 502 int oldNoteKeyVal, 503 int oldOctaveKeyVal, 504 bool noteExisted, 505 bool listen, 506 bool isMidi, 507 bool isInstrumentMode){ 508 509 if( noteExisted ){ 510 setText( QString( "Delete note ( %1, %2)" ).arg( nColumn ).arg( nRow ) ); 511 } else { 512 setText( QString( "Add note ( %1, %2)" ).arg( nColumn ).arg( nRow ) ); 513 } 514 __nColumn = nColumn; 515 __nRow = nRow; 516 __selectedPatternNumber = selectedPatternNumber; 517 __oldLength = oldLength; 518 __oldVelocity = oldVelocity; 519 __oldPan_L = oldPan_L; 520 __oldPan_R = oldPan_R; 521 __oldLeadLag = oldLeadLag; 522 __oldNoteKeyVal = oldNoteKeyVal; 523 __oldOctaveKeyVal = oldOctaveKeyVal; 524 __listen = listen; 525 __isMidi = isMidi; 526 __isInstrumentMode = isInstrumentMode; 527 } undo()528 virtual void undo() 529 { 530 //qDebug() << "Add note Undo "; 531 HydrogenApp* h2app = HydrogenApp::get_instance(); 532 __isMidi = false; // undo is never a midi event. 533 h2app->getPatternEditorPanel()->getDrumPatternEditor()->addOrDeleteNoteAction( __nColumn, 534 __nRow, 535 __selectedPatternNumber, 536 __oldLength, 537 __oldVelocity, 538 __oldPan_L, 539 __oldPan_R, 540 __oldLeadLag, 541 __oldNoteKeyVal, 542 __oldOctaveKeyVal, 543 __listen, 544 __isMidi, 545 __isInstrumentMode, 546 false ); 547 } redo()548 virtual void redo() 549 { 550 //qDebug() << "Add Note Redo " ; 551 HydrogenApp* h2app = HydrogenApp::get_instance(); 552 h2app->getPatternEditorPanel()->getDrumPatternEditor()->addOrDeleteNoteAction( __nColumn, 553 __nRow, 554 __selectedPatternNumber, 555 __oldLength, 556 __oldVelocity, 557 __oldPan_L, 558 __oldPan_R, 559 __oldLeadLag, 560 __oldNoteKeyVal, 561 __oldOctaveKeyVal, 562 __listen, 563 __isMidi, 564 __isInstrumentMode, 565 false ); 566 } 567 private: 568 int __nColumn; 569 int __nRow; 570 int __selectedPatternNumber; 571 int __oldLength; 572 float __oldVelocity; 573 float __oldPan_L; 574 float __oldPan_R; 575 float __oldLeadLag; 576 int __oldNoteKeyVal; 577 int __oldOctaveKeyVal; 578 bool __listen; 579 bool __isMidi; 580 bool __isInstrumentMode; 581 }; 582 583 584 class SE_addNoteRightClickAction : public QUndoCommand 585 { 586 public: SE_addNoteRightClickAction(int nColumn,int nRow,int selectedPatternNumber)587 SE_addNoteRightClickAction( int nColumn, int nRow, int selectedPatternNumber ){ 588 setText( QString( "Add pattern editor NOTE_OFF note ( %1, %2 )" ).arg( nColumn ).arg( nRow ) ); 589 __nColumn = nColumn; 590 __nRow = nRow; 591 __selectedPatternNumber = selectedPatternNumber; 592 } undo()593 virtual void undo() 594 { 595 //qDebug() << "Add off note Note Undo "; 596 HydrogenApp* h2app = HydrogenApp::get_instance(); 597 h2app->getPatternEditorPanel()->getDrumPatternEditor()->addOrDeleteNoteAction( __nColumn, __nRow, __selectedPatternNumber, -1, 0.8f, 0.5f, 0.5f, 0.0, 0, 0, false, false, false, true); 598 } redo()599 virtual void redo() 600 { 601 //qDebug() << "Add off note Note Redo " ; 602 HydrogenApp* h2app = HydrogenApp::get_instance(); 603 h2app->getPatternEditorPanel()->getDrumPatternEditor()->addOrDeleteNoteAction( __nColumn, __nRow, __selectedPatternNumber, -1, 0.8f, 0.5f, 0.5f, 0.0, 0, 0, false, false, false, true); 604 } 605 private: 606 int __nColumn; 607 int __nRow; 608 int __selectedPatternNumber; 609 }; 610 611 class SE_editNoteLenghtAction : public QUndoCommand 612 { 613 public: SE_editNoteLenghtAction(int nColumn,int nRealColumn,int row,int length,int oldLength,int selectedPatternNumber)614 SE_editNoteLenghtAction( int nColumn, int nRealColumn, int row, int length, int oldLength, int selectedPatternNumber ){ 615 setText( QString( "Change note length" ) ); 616 __nColumn = nColumn; 617 __nRealColumn = nRealColumn; 618 __row = row; 619 __length = length; 620 __oldLength = oldLength; 621 __selectedPatternNumber = selectedPatternNumber; 622 } undo()623 virtual void undo() 624 { 625 //qDebug() << "Change note length Undo "; 626 HydrogenApp* h2app = HydrogenApp::get_instance(); 627 h2app->getPatternEditorPanel()->getDrumPatternEditor()->editNoteLengthAction( __nColumn, __nRealColumn, __row, __oldLength, __selectedPatternNumber ); 628 } redo()629 virtual void redo() 630 { 631 //qDebug() << "Change note length Redo " ; 632 HydrogenApp* h2app = HydrogenApp::get_instance(); 633 h2app->getPatternEditorPanel()->getDrumPatternEditor()->editNoteLengthAction( __nColumn, __nRealColumn, __row, __length, __selectedPatternNumber ); 634 } 635 private: 636 int __nColumn; 637 int __nRealColumn; 638 int __row; 639 int __oldLength; 640 int __length; 641 int __selectedPatternNumber; 642 }; 643 644 645 class SE_clearNotesPatternEditorAction : public QUndoCommand 646 { 647 public: SE_clearNotesPatternEditorAction(std::list<H2Core::Note * > noteList,int nSelectedInstrument,int selectedPatternNumber)648 SE_clearNotesPatternEditorAction( std::list< H2Core::Note* > noteList, int nSelectedInstrument, int selectedPatternNumber ){ 649 setText( QString( "Clear notes" ) ); 650 651 std::list < H2Core::Note *>::iterator pos; 652 for ( pos = noteList.begin(); pos != noteList.end(); ++pos){ 653 H2Core::Note *pNote; 654 pNote = new H2Core::Note(*pos); 655 assert( pNote ); 656 __noteList.push_back( pNote ); 657 } 658 659 __nSelectedInstrument = nSelectedInstrument; 660 __selectedPatternNumber = selectedPatternNumber; 661 } 662 ~SE_clearNotesPatternEditorAction()663 ~SE_clearNotesPatternEditorAction(){ 664 //qDebug() << "delete left notes "; 665 while ( __noteList.size() ) { 666 delete __noteList.front(); 667 __noteList.pop_front(); 668 } 669 670 } 671 undo()672 virtual void undo() 673 { 674 //qDebug() << "clear note sequence Undo "; 675 HydrogenApp* h2app = HydrogenApp::get_instance(); 676 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionClearNotesUndoAction( __noteList, __nSelectedInstrument, __selectedPatternNumber ); 677 } redo()678 virtual void redo() 679 { 680 //qDebug() << "clear note sequence Redo " ; 681 HydrogenApp* h2app = HydrogenApp::get_instance(); 682 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionClearNotesRedoAction( __nSelectedInstrument, __selectedPatternNumber ); 683 } 684 private: 685 std::list< H2Core::Note* > __noteList; 686 int __nSelectedInstrument; 687 int __selectedPatternNumber; 688 }; 689 690 class SE_pasteNotesPatternEditorAction : public QUndoCommand 691 { 692 public: SE_pasteNotesPatternEditorAction(const std::list<H2Core::Pattern * > & patternList)693 SE_pasteNotesPatternEditorAction(const std::list<H2Core::Pattern*> & patternList) 694 { 695 //qDebug() << "paste note sequence Create "; 696 setText( QString( "Paste instrument notes" ) ); 697 698 std::list < H2Core::Pattern *>::const_iterator pos; 699 for ( pos = patternList.begin(); pos != patternList.end(); ++pos) 700 { 701 H2Core::Pattern *pPattern = *pos; 702 assert( pPattern ); 703 __patternList.push_back(pPattern); 704 } 705 } 706 ~SE_pasteNotesPatternEditorAction()707 ~SE_pasteNotesPatternEditorAction() 708 { 709 //qDebug() << "paste note sequence Destroy "; 710 while ( __patternList.size() > 0) 711 { 712 delete __patternList.front(); 713 __patternList.pop_front(); 714 } 715 while ( __appliedList.size() > 0) 716 { 717 delete __appliedList.front(); 718 __appliedList.pop_front(); 719 } 720 } 721 undo()722 virtual void undo() 723 { 724 //qDebug() << "paste note sequence Undo "; 725 HydrogenApp* h2app = HydrogenApp::get_instance(); 726 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionPasteNotesUndoAction( __appliedList ); 727 } 728 redo()729 virtual void redo() 730 { 731 //qDebug() << "paste note sequence Redo " ; 732 HydrogenApp* h2app = HydrogenApp::get_instance(); 733 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionPasteNotesRedoAction( __patternList, __appliedList ); 734 } 735 736 private: 737 std::list< H2Core::Pattern* > __patternList; 738 std::list< H2Core::Pattern* > __appliedList; 739 }; 740 741 742 class SE_fillNotesRightClickAction : public QUndoCommand 743 { 744 public: SE_fillNotesRightClickAction(QStringList notePositions,int nSelectedInstrument,int selectedPatternNumber)745 SE_fillNotesRightClickAction( QStringList notePositions, int nSelectedInstrument, int selectedPatternNumber ){ 746 setText( QString( "Fill notes" ) ); 747 __notePositions = notePositions; 748 __nSelectedInstrument= nSelectedInstrument; 749 __selectedPatternNumber = selectedPatternNumber; 750 } undo()751 virtual void undo() 752 { 753 //qDebug() << "fill notes Undo "; 754 HydrogenApp* h2app = HydrogenApp::get_instance(); 755 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionFillNotesUndoAction( __notePositions, __nSelectedInstrument, __selectedPatternNumber ); 756 } redo()757 virtual void redo() 758 { 759 //qDebug() << "fill notes Redo " ; 760 HydrogenApp* h2app = HydrogenApp::get_instance(); 761 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionFillNotesRedoAction( __notePositions, __nSelectedInstrument, __selectedPatternNumber ); 762 } 763 private: 764 QStringList __notePositions; 765 int __nSelectedInstrument; 766 int __selectedPatternNumber; 767 }; 768 769 770 class SE_randomVelocityRightClickAction : public QUndoCommand 771 { 772 public: SE_randomVelocityRightClickAction(QStringList noteVeloValue,QStringList oldNoteVeloValue,int nSelectedInstrument,int selectedPatternNumber)773 SE_randomVelocityRightClickAction( QStringList noteVeloValue, QStringList oldNoteVeloValue, int nSelectedInstrument, int selectedPatternNumber ){ 774 setText( QString( "Random velocity" ) ); 775 __noteVeloValue = noteVeloValue; 776 __oldNoteVeloValue = oldNoteVeloValue; 777 __nSelectedInstrument= nSelectedInstrument; 778 __selectedPatternNumber = selectedPatternNumber; 779 } undo()780 virtual void undo() 781 { 782 //qDebug() << "Random velocity Undo "; 783 HydrogenApp* h2app = HydrogenApp::get_instance(); 784 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionRandomVelocityAction( __oldNoteVeloValue, __nSelectedInstrument, __selectedPatternNumber ); 785 } redo()786 virtual void redo() 787 { 788 //qDebug() << "Random velocity Redo " ; 789 HydrogenApp* h2app = HydrogenApp::get_instance(); 790 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionRandomVelocityAction( __noteVeloValue, __nSelectedInstrument, __selectedPatternNumber ); 791 } 792 private: 793 QStringList __noteVeloValue; 794 QStringList __oldNoteVeloValue; 795 int __nSelectedInstrument; 796 int __selectedPatternNumber; 797 }; 798 799 800 801 class SE_moveInstrumentAction : public QUndoCommand 802 { 803 public: SE_moveInstrumentAction(int nSourceInstrument,int nTargetInstrument)804 SE_moveInstrumentAction( int nSourceInstrument, int nTargetInstrument ){ 805 setText( QString( "Move instrument" ) ); 806 __nSourceInstrument = nSourceInstrument; 807 __nTargetInstrument = nTargetInstrument; 808 } undo()809 virtual void undo() 810 { 811 //qDebug() << "move Instrument Undo "; 812 HydrogenApp* h2app = HydrogenApp::get_instance(); 813 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionMoveInstrumentAction( __nTargetInstrument, __nSourceInstrument ); 814 } redo()815 virtual void redo() 816 { 817 //qDebug() << "move Instrument Redo " ; 818 HydrogenApp* h2app = HydrogenApp::get_instance(); 819 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionMoveInstrumentAction( __nSourceInstrument, __nTargetInstrument ); 820 } 821 private: 822 int __nSourceInstrument; 823 int __nTargetInstrument; 824 }; 825 826 class SE_dragInstrumentAction : public QUndoCommand 827 { 828 public: SE_dragInstrumentAction(QString sDrumkitName,QString sInstrumentName,int nTargetInstrument)829 SE_dragInstrumentAction( QString sDrumkitName, QString sInstrumentName, int nTargetInstrument){ 830 setText( QString( "Drop instrument" ) ); 831 __sDrumkitName = sDrumkitName; 832 __sInstrumentName = sInstrumentName; 833 __nTargetInstrument = nTargetInstrument; 834 __addedComponents = new std::vector<int>(); 835 } 836 ~SE_dragInstrumentAction()837 ~SE_dragInstrumentAction() 838 { 839 delete __addedComponents; 840 } 841 undo()842 virtual void undo() 843 { 844 //qDebug() << "drop Instrument Undo "; 845 HydrogenApp* h2app = HydrogenApp::get_instance(); 846 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionDropInstrumentUndoAction( __nTargetInstrument, __addedComponents ); 847 } 848 redo()849 virtual void redo() 850 { 851 //qDebug() << "drop Instrument Redo " ; 852 HydrogenApp* h2app = HydrogenApp::get_instance(); 853 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionDropInstrumentRedoAction( __sDrumkitName, __sInstrumentName, __nTargetInstrument, __addedComponents ); 854 } 855 856 private: 857 QString __sDrumkitName; 858 QString __sInstrumentName; 859 int __nTargetInstrument; 860 std::vector<int>* __addedComponents; 861 }; 862 863 864 class SE_deleteInstrumentAction : public QUndoCommand 865 { 866 public: SE_deleteInstrumentAction(std::list<H2Core::Note * > noteList,QString drumkitName,QString instrumentName,int nSelectedInstrument)867 SE_deleteInstrumentAction( std::list< H2Core::Note* > noteList, QString drumkitName, QString instrumentName, int nSelectedInstrument ){ 868 setText( QString( "Delete instrument " ) ); 869 870 std::list < H2Core::Note *>::iterator pos; 871 for ( pos = noteList.begin(); pos != noteList.end(); ++pos){ 872 H2Core::Note *pNote; 873 pNote = new H2Core::Note(*pos); 874 assert( pNote ); 875 __noteList.push_back( pNote ); 876 } 877 __drumkitName = drumkitName; 878 __instrumentName = instrumentName; 879 __nSelectedInstrument = nSelectedInstrument; 880 } 881 ~SE_deleteInstrumentAction()882 ~SE_deleteInstrumentAction(){ 883 //qDebug() << "delete left notes "; 884 while ( __noteList.size() ) { 885 delete __noteList.front(); 886 __noteList.pop_front(); 887 } 888 889 } 890 undo()891 virtual void undo() 892 { 893 //qDebug() << "delete Instrument Undo "; 894 HydrogenApp* h2app = HydrogenApp::get_instance(); 895 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionDeleteInstrumentUndoAction( __noteList, __nSelectedInstrument, __instrumentName, __drumkitName ); 896 } redo()897 virtual void redo() 898 { 899 //qDebug() << "delete Instrument Redo " ; 900 HydrogenApp* h2app = HydrogenApp::get_instance(); 901 //delete an instrument from list 902 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionDropInstrumentUndoAction( __nSelectedInstrument, new std::vector<int>() ); 903 } 904 private: 905 std::list< H2Core::Note* > __noteList; 906 QString __instrumentName; 907 QString __drumkitName; 908 int __nSelectedInstrument; 909 }; 910 911 912 913 class SE_mainMenuAddInstrumentAction : public QUndoCommand 914 { 915 public: SE_mainMenuAddInstrumentAction()916 SE_mainMenuAddInstrumentAction(){ 917 setText( QString( "Drop instrument" ) ); 918 } undo()919 virtual void undo() 920 { 921 //qDebug() << "drop Instrument Undo "; 922 HydrogenApp* h2app = HydrogenApp::get_instance(); 923 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionAddEmptyInstrumentUndo(); 924 } redo()925 virtual void redo() 926 { 927 //qDebug() << "drop Instrument Redo " ; 928 HydrogenApp* h2app = HydrogenApp::get_instance(); 929 h2app->getPatternEditorPanel()->getDrumPatternEditor()->functionAddEmptyInstrumentRedo(); 930 } 931 private: 932 }; 933 934 //~pattern editor commands 935 //===================================================================================================================================== 936 //piano roll editor commands 937 938 939 class SE_addNotePianoRollAction : public QUndoCommand 940 { 941 public: SE_addNotePianoRollAction(int nColumn,int pressedLine,int selectedPatternNumber,int nSelectedInstrumentnumber,int oldLength,float oldVelocity,float oldPan_L,float oldPan_R,float oldLeadLag,int oldNoteKeyVal,int oldOctaveKeyVal)942 SE_addNotePianoRollAction( int nColumn, 943 int pressedLine, 944 int selectedPatternNumber, 945 int nSelectedInstrumentnumber, 946 int oldLength, 947 float oldVelocity, 948 float oldPan_L, 949 float oldPan_R, 950 float oldLeadLag, 951 int oldNoteKeyVal, 952 int oldOctaveKeyVal ){ 953 setText( QString( "Add piano roll note ( %1, %2 )" ).arg( nColumn ).arg( pressedLine ) ); 954 __nColumn = nColumn; 955 __pressedLine = pressedLine; 956 __selectedPatternNumber = selectedPatternNumber; 957 __nSelectedInstrumentnumber = nSelectedInstrumentnumber; 958 __oldLength = oldLength; 959 __oldVelocity = oldVelocity; 960 __oldPan_L = oldPan_L; 961 __oldPan_R = oldPan_R; 962 __oldLeadLag = oldLeadLag; 963 __oldNoteKeyVal = oldNoteKeyVal; 964 __oldOctaveKeyVal = oldOctaveKeyVal; 965 966 } undo()967 virtual void undo() 968 { 969 //qDebug() << "Add Piano Roll note Undo "; 970 HydrogenApp* h2app = HydrogenApp::get_instance(); 971 h2app->getPatternEditorPanel()->getPianoRollEditor()->addOrDeleteNoteAction( __nColumn, 972 __pressedLine, 973 __selectedPatternNumber, 974 __nSelectedInstrumentnumber, 975 __oldLength, 976 __oldVelocity, 977 __oldPan_L, 978 __oldPan_R, 979 __oldLeadLag, 980 __oldNoteKeyVal, 981 __oldOctaveKeyVal, 982 false ); 983 } redo()984 virtual void redo() 985 { 986 //qDebug() << "Add Piano Roll Note Redo " ; 987 HydrogenApp* h2app = HydrogenApp::get_instance(); 988 h2app->getPatternEditorPanel()->getPianoRollEditor()->addOrDeleteNoteAction( __nColumn, 989 __pressedLine, 990 __selectedPatternNumber, 991 __nSelectedInstrumentnumber, 992 __oldLength, 993 __oldVelocity, 994 __oldPan_L, 995 __oldPan_R, 996 __oldLeadLag, 997 __oldNoteKeyVal, 998 __oldOctaveKeyVal, 999 false ); 1000 } 1001 private: 1002 int __nColumn; 1003 int __pressedLine; 1004 int __selectedPatternNumber; 1005 int __nSelectedInstrumentnumber; 1006 int __oldLength; 1007 float __oldVelocity; 1008 float __oldPan_L; 1009 float __oldPan_R; 1010 float __oldLeadLag; 1011 int __oldNoteKeyVal; 1012 int __oldOctaveKeyVal; 1013 }; 1014 1015 class SE_addPianoRollNoteOffAction : public QUndoCommand 1016 { 1017 public: SE_addPianoRollNoteOffAction(int nColumn,int pressedLine,int selectedPatternNumber,int nSelectedInstrumentnumber)1018 SE_addPianoRollNoteOffAction( int nColumn, int pressedLine, int selectedPatternNumber, int nSelectedInstrumentnumber ){ 1019 setText( QString( "Add piano roll NOTE_OFF note ( %1, %2 )" ).arg( nColumn ).arg( pressedLine ) ); 1020 __nColumn = nColumn; 1021 __pressedLine = pressedLine; 1022 __selectedPatternNumber = selectedPatternNumber; 1023 __nSelectedInstrumentnumber = nSelectedInstrumentnumber; 1024 } undo()1025 virtual void undo() 1026 { 1027 //qDebug() << "Add off note Note Undo "; 1028 HydrogenApp* h2app = HydrogenApp::get_instance(); 1029 h2app->getPatternEditorPanel()->getPianoRollEditor()->addOrDeleteNoteAction( __nColumn, __pressedLine, __selectedPatternNumber, __nSelectedInstrumentnumber, -1, 0.8f, 0.5f, 0.5f, 0.0, 0, 0 , true); 1030 } redo()1031 virtual void redo() 1032 { 1033 //qDebug() << "Add off note Note Redo " ; 1034 HydrogenApp* h2app = HydrogenApp::get_instance(); 1035 h2app->getPatternEditorPanel()->getPianoRollEditor()->addOrDeleteNoteAction( __nColumn, __pressedLine, __selectedPatternNumber, __nSelectedInstrumentnumber, -1, 0.8f, 0.5f, 0.5f, 0.0, 0, 0, true); 1036 1037 } 1038 private: 1039 int __nColumn; 1040 int __pressedLine; 1041 int __selectedPatternNumber; 1042 int __nSelectedInstrumentnumber; 1043 }; 1044 1045 1046 class SE_editPianoRollNoteLengthAction : public QUndoCommand 1047 { 1048 public: SE_editPianoRollNoteLengthAction(int nColumn,int nRealColumn,int length,int oldLength,int selectedPatternNumber,int nSelectedInstrumentnumber,int pressedLine)1049 SE_editPianoRollNoteLengthAction( int nColumn, int nRealColumn, int length, int oldLength, int selectedPatternNumber, int nSelectedInstrumentnumber, int pressedLine){ 1050 setText( QString( "Change piano roll note length " ) ); 1051 __nColumn = nColumn; 1052 __nRealColumn = nRealColumn; 1053 __length = length; 1054 __oldLength = oldLength; 1055 __selectedPatternNumber = selectedPatternNumber; 1056 __nSelectedInstrumentnumber = nSelectedInstrumentnumber; 1057 __pressedLine = pressedLine; 1058 } undo()1059 virtual void undo() 1060 { 1061 //qDebug() << "Change note length Piano Roll Undo "; 1062 HydrogenApp* h2app = HydrogenApp::get_instance(); 1063 h2app->getPatternEditorPanel()->getPianoRollEditor()->editNoteLengthAction( __nColumn, __nRealColumn, __oldLength, __selectedPatternNumber, __nSelectedInstrumentnumber, __pressedLine); 1064 } redo()1065 virtual void redo() 1066 { 1067 //qDebug() << "Change note length Piano RollRedo " ; 1068 HydrogenApp* h2app = HydrogenApp::get_instance(); 1069 h2app->getPatternEditorPanel()->getPianoRollEditor()->editNoteLengthAction( __nColumn, 1070 __nRealColumn, 1071 __length, 1072 __selectedPatternNumber, 1073 __nSelectedInstrumentnumber, 1074 __pressedLine ); 1075 } 1076 private: 1077 int __nColumn; 1078 int __nRealColumn; 1079 int __oldLength; 1080 int __length; 1081 int __selectedPatternNumber; 1082 int __nSelectedInstrumentnumber; 1083 int __pressedLine; 1084 }; 1085 1086 class SE_editNotePropertiesPianoRollAction : public QUndoCommand 1087 { 1088 public: SE_editNotePropertiesPianoRollAction(int nColumn,int nRealColumn,int selectedPatternNumber,int selectedInstrumentnumber,float velocity,float oldVelocity,float pan_L,float oldPan_L,float pan_R,float oldPan_R,float leadLag,float oldLeadLag,int pressedLine)1089 SE_editNotePropertiesPianoRollAction( int nColumn, 1090 int nRealColumn, 1091 int selectedPatternNumber, 1092 int selectedInstrumentnumber, 1093 float velocity, 1094 float oldVelocity, 1095 float pan_L, 1096 float oldPan_L, 1097 float pan_R, 1098 float oldPan_R, 1099 float leadLag, 1100 float oldLeadLag, 1101 int pressedLine ){ 1102 setText( QString( "Change note properties piano roll" ) ); 1103 __nColumn = nColumn; 1104 __nRealColumn = nRealColumn; 1105 __selectedPatternNumber = selectedPatternNumber; 1106 __nSelectedInstrumentnumber = selectedInstrumentnumber; 1107 __velocity = velocity; 1108 __oldVelocity = oldVelocity; 1109 __pan_L = pan_L; 1110 __oldPan_L = oldPan_L; 1111 __pan_R = pan_R; 1112 __oldPan_R = oldPan_R; 1113 __leadLag = leadLag; 1114 __oldLeadLag = oldLeadLag; 1115 __pressedLine = pressedLine; 1116 } undo()1117 virtual void undo() 1118 { 1119 //qDebug() << "Change Note properties Piano Roll Undo "; 1120 HydrogenApp* h2app = HydrogenApp::get_instance(); 1121 h2app->getPatternEditorPanel()->getPianoRollEditor()->editNotePropertiesAction( __nColumn, 1122 __nRealColumn, 1123 __selectedPatternNumber, 1124 __nSelectedInstrumentnumber, 1125 __oldVelocity, 1126 __oldPan_L, 1127 __oldPan_R, 1128 __oldLeadLag, 1129 __pressedLine ); 1130 } redo()1131 virtual void redo() 1132 { 1133 //qDebug() << "Change Note properties Piano RollRedo " ; 1134 HydrogenApp* h2app = HydrogenApp::get_instance(); 1135 h2app->getPatternEditorPanel()->getPianoRollEditor()->editNotePropertiesAction( __nColumn, 1136 __nRealColumn, 1137 __selectedPatternNumber, 1138 __nSelectedInstrumentnumber, 1139 __velocity, 1140 __pan_L, 1141 __pan_R, 1142 __leadLag, 1143 __pressedLine ); 1144 } 1145 1146 private: 1147 int __nColumn; 1148 int __nRealColumn; 1149 int __selectedPatternNumber; 1150 int __nSelectedInstrumentnumber; 1151 float __velocity; 1152 float __oldVelocity; 1153 float __pan_L; 1154 float __oldPan_L; 1155 float __pan_R; 1156 float __oldPan_R; 1157 float __leadLag; 1158 float __oldLeadLag; 1159 int __pressedLine; 1160 }; 1161 1162 //~piano roll editor commands 1163 //===================================================================================================================================== 1164 //Note Properties Ruler commands 1165 1166 class SE_editNotePropertiesVolumeAction : public QUndoCommand 1167 { 1168 public: 1169 SE_editNotePropertiesVolumeAction(int undoColumn,QString mode,int nSelectedPatternNumber,int nSelectedInstrument,float velocity,float oldVelocity,float pan_L,float oldPan_L,float pan_R,float oldPan_R,float leadLag,float oldLeadLag,float probability,float oldProbability,int noteKeyVal,int oldNoteKeyVal,int octaveKeyVal,int oldOctaveKeyVal)1170 SE_editNotePropertiesVolumeAction( int undoColumn, 1171 QString mode, 1172 int nSelectedPatternNumber, 1173 int nSelectedInstrument, 1174 float velocity, 1175 float oldVelocity, 1176 float pan_L, 1177 float oldPan_L, 1178 float pan_R, 1179 float oldPan_R, 1180 float leadLag, 1181 float oldLeadLag, 1182 float probability, 1183 float oldProbability, 1184 int noteKeyVal, 1185 int oldNoteKeyVal, 1186 int octaveKeyVal, 1187 int oldOctaveKeyVal) 1188 { 1189 1190 1191 setText( QString( "Edit note property " + mode.toLower() ) ); 1192 __undoColumn = undoColumn; 1193 __mode = mode; 1194 __nSelectedPatternNumber = nSelectedPatternNumber; 1195 __nSelectedInstrument = nSelectedInstrument; 1196 __velocity = velocity; 1197 __oldVelocity = oldVelocity; 1198 __pan_L = pan_L; 1199 __oldPan_L = oldPan_L; 1200 __pan_R = pan_R; 1201 __oldPan_R = oldPan_R; 1202 __leadLag = leadLag; 1203 __oldLeadLag = oldLeadLag; 1204 __probability = probability; 1205 __oldProbability = oldProbability; 1206 __noteKeyVal = noteKeyVal; 1207 __oldNoteKeyVal = oldNoteKeyVal; 1208 __octaveKeyVal = octaveKeyVal; 1209 __oldOctaveKeyVal = oldOctaveKeyVal; 1210 1211 } undo()1212 virtual void undo() 1213 { 1214 //qDebug() << "edit note property Undo "; 1215 HydrogenApp* h2app = HydrogenApp::get_instance(); 1216 1217 h2app->getPatternEditorPanel()->getDrumPatternEditor()->undoRedoAction( __undoColumn, 1218 __mode, 1219 __nSelectedPatternNumber, 1220 __nSelectedInstrument, 1221 __oldVelocity, 1222 __oldPan_L, 1223 __oldPan_R, 1224 __oldLeadLag, 1225 __oldProbability, 1226 __oldNoteKeyVal, 1227 __oldOctaveKeyVal ); 1228 } redo()1229 virtual void redo() 1230 { 1231 //qDebug() << "edit note property Redo " ; 1232 HydrogenApp* h2app = HydrogenApp::get_instance(); 1233 h2app->getPatternEditorPanel()->getDrumPatternEditor()->undoRedoAction( __undoColumn, 1234 __mode, 1235 __nSelectedPatternNumber, 1236 __nSelectedInstrument, 1237 __velocity, 1238 __pan_L, 1239 __pan_R, 1240 __leadLag, 1241 __probability, 1242 __noteKeyVal, 1243 __octaveKeyVal ); 1244 } 1245 private: 1246 1247 1248 int __undoColumn; 1249 QString __mode; 1250 int __nSelectedPatternNumber; 1251 int __nSelectedInstrument; 1252 float __velocity; 1253 float __oldVelocity; 1254 float __pan_L; 1255 float __oldPan_L; 1256 float __pan_R; 1257 float __oldPan_R; 1258 float __leadLag; 1259 float __oldLeadLag; 1260 float __probability; 1261 float __oldProbability; 1262 int __noteKeyVal; 1263 int __oldNoteKeyVal; 1264 int __octaveKeyVal; 1265 int __oldOctaveKeyVal; 1266 int __selectedPatternNumber; 1267 int __nSelectedInstrumentnumber; 1268 }; 1269 1270 //~Note Properties Ruler commands 1271 //===================================================================================================================================== 1272 1273 1274 1275 class SE_automationPathAddPointAction : public QUndoCommand 1276 { 1277 public: SE_automationPathAddPointAction(H2Core::AutomationPath * path,float x,float y)1278 SE_automationPathAddPointAction( H2Core::AutomationPath *path, float x, float y) 1279 { 1280 setText( QString( "Add point" ) ); 1281 __path = path; 1282 __x = x; 1283 __y = y; 1284 } 1285 undo()1286 virtual void undo() 1287 { 1288 __path->remove_point( __x ); 1289 1290 HydrogenApp* h2app = HydrogenApp::get_instance(); 1291 h2app->getSongEditorPanel()->getAutomationPathView()->update(); 1292 } 1293 redo()1294 virtual void redo() 1295 { 1296 __path->add_point( __x, __y ); 1297 1298 HydrogenApp* h2app = HydrogenApp::get_instance(); 1299 h2app->getSongEditorPanel()->getAutomationPathView()->update(); 1300 } 1301 private: 1302 H2Core::AutomationPath* __path; 1303 float __x; 1304 float __y; 1305 }; 1306 1307 1308 class SE_automationPathRemovePointAction : public QUndoCommand 1309 { 1310 public: SE_automationPathRemovePointAction(H2Core::AutomationPath * path,float x,float y)1311 SE_automationPathRemovePointAction( H2Core::AutomationPath *path, float x, float y) 1312 { 1313 setText( QString( "Remove point" ) ); 1314 __path = path; 1315 __x = x; 1316 __y = y; 1317 } 1318 redo()1319 virtual void redo() 1320 { 1321 __path->remove_point( __x ); 1322 1323 HydrogenApp* h2app = HydrogenApp::get_instance(); 1324 h2app->getSongEditorPanel()->getAutomationPathView()->update(); 1325 } 1326 undo()1327 virtual void undo() 1328 { 1329 __path->add_point( __x, __y ); 1330 1331 HydrogenApp* h2app = HydrogenApp::get_instance(); 1332 h2app->getSongEditorPanel()->getAutomationPathView()->update(); 1333 } 1334 private: 1335 H2Core::AutomationPath* __path; 1336 float __x; 1337 float __y; 1338 }; 1339 1340 1341 class SE_automationPathMovePointAction : public QUndoCommand 1342 { 1343 public: SE_automationPathMovePointAction(H2Core::AutomationPath * path,float ox,float oy,float tx,float ty)1344 SE_automationPathMovePointAction( H2Core::AutomationPath *path, float ox, float oy, float tx, float ty) 1345 { 1346 setText( QString( "Move point" ) ); 1347 __path = path; 1348 __ox = ox; 1349 __oy = oy; 1350 __tx = tx; 1351 __ty = ty; 1352 } 1353 redo()1354 virtual void redo() 1355 { 1356 __path->remove_point( __ox ); 1357 __path->add_point( __tx, __ty ); 1358 1359 HydrogenApp* h2app = HydrogenApp::get_instance(); 1360 h2app->getSongEditorPanel()->getAutomationPathView()->update(); 1361 } 1362 undo()1363 virtual void undo() 1364 { 1365 __path->remove_point( __tx ); 1366 __path->add_point( __ox, __oy ); 1367 1368 HydrogenApp* h2app = HydrogenApp::get_instance(); 1369 h2app->getSongEditorPanel()->getAutomationPathView()->update(); 1370 } 1371 private: 1372 H2Core::AutomationPath* __path; 1373 float __ox; 1374 float __oy; 1375 float __tx; 1376 float __ty; 1377 }; 1378 1379 #endif // UNDOACTIONS_H 1380