@@ -406,6 +406,35 @@ void MIDIContentViewer::mouseDown(const juce::MouseEvent& event) {
406
406
this ->noteInsertChannel = Tools::getInstance ()->getMIDIChannel ();
407
407
this ->repaint ();
408
408
}
409
+ /* * Edit Note */
410
+ else if (type == NoteControllerType::Left || type == NoteControllerType::Right) {
411
+ /* * Get Time */
412
+ double time = this ->secStart + (pos.x / this ->getWidth ()) * (this ->secEnd - this ->secStart );
413
+ time = quickAPI::limitTimeSec (time , Tools::getInstance ()->getAdsorb ());
414
+
415
+ /* * Limit Note Length */
416
+ int tempoIndex = quickAPI::getTempoTempIndexBySec (time );
417
+ auto tempo = quickAPI::getTempoData (tempoIndex);
418
+ double minLength = std::get<3 >(tempo) / 64 ;
419
+
420
+ auto & [noteIndex, rect, channel] = this ->noteRectTempList .getReference (index );
421
+ auto & note = this ->midiDataTemp .getReference (noteIndex);
422
+ double noteStartTime = note.startSec ;
423
+ double noteEndTime = note.endSec ;
424
+ if (type == NoteControllerType::Right && time < noteStartTime + minLength) {
425
+ time = noteStartTime + minLength;
426
+ }
427
+ else if (type == NoteControllerType::Left && time > noteEndTime - minLength) {
428
+ time = noteEndTime - minLength;
429
+ }
430
+
431
+ /* * Set Temp */
432
+ this ->noteEditStatus = type;
433
+ this ->noteEditIndex = index ;
434
+ this ->noteEditTime = time ;
435
+ this ->noteEditMinLength = minLength;
436
+ this ->repaint ();
437
+ }
409
438
}
410
439
}
411
440
}
@@ -433,6 +462,24 @@ void MIDIContentViewer::mouseUp(const juce::MouseEvent& event) {
433
462
this ->noteInsertChannel = 0 ;
434
463
this ->repaint ();
435
464
}
465
+
466
+ /* * Edit Time */
467
+ if (this ->noteEditStatus == NoteControllerType::Left || this ->noteEditStatus == NoteControllerType::Right) {
468
+ /* * Set Note Time */
469
+ if (this ->noteEditStatus == NoteControllerType::Left) {
470
+ this ->setNoteStartTime (this ->noteEditIndex , this ->noteEditTime );
471
+ }
472
+ else if (this ->noteEditStatus == NoteControllerType::Right) {
473
+ this ->setNoteEndTime (this ->noteEditIndex , this ->noteEditTime );
474
+ }
475
+
476
+ /* * Reset Temp */
477
+ this ->noteEditStatus = NoteControllerType::None;
478
+ this ->noteEditIndex = -1 ;
479
+ this ->noteEditTime = -1 ;
480
+ this ->noteEditMinLength = -1 ;
481
+ this ->repaint ();
482
+ }
436
483
}
437
484
}
438
485
@@ -487,6 +534,29 @@ void MIDIContentViewer::mouseDrag(const juce::MouseEvent& event) {
487
534
this ->noteInsertPitch = pitch;
488
535
this ->repaint ();
489
536
}
537
+
538
+ /* * Edit Time */
539
+ if (this ->noteEditStatus == NoteControllerType::Left || this ->noteEditStatus == NoteControllerType::Right) {
540
+ /* * Get Time */
541
+ double time = this ->secStart + (pos.x / this ->getWidth ()) * (this ->secEnd - this ->secStart );
542
+ time = quickAPI::limitTimeSec (time , Tools::getInstance ()->getAdsorb ());
543
+
544
+ /* * Limit Note Length */
545
+ auto & [noteIndex, rect, channel] = this ->noteRectTempList .getReference (this ->noteEditIndex );
546
+ auto & note = this ->midiDataTemp .getReference (noteIndex);
547
+ double noteStartTime = note.startSec ;
548
+ double noteEndTime = note.endSec ;
549
+ if (this ->noteEditStatus == NoteControllerType::Right && time < noteStartTime + this ->noteEditMinLength ) {
550
+ time = noteStartTime + this ->noteEditMinLength ;
551
+ }
552
+ else if (this ->noteEditStatus == NoteControllerType::Left && time > noteEndTime - this ->noteEditMinLength ) {
553
+ time = noteEndTime - this ->noteEditMinLength ;
554
+ }
555
+
556
+ /* * Set Temp */
557
+ this ->noteEditTime = time ;
558
+ this ->repaint ();
559
+ }
490
560
}
491
561
}
492
562
@@ -510,6 +580,16 @@ void MIDIContentViewer::mouseExit(const juce::MouseEvent& event) {
510
580
this ->noteInsertChannel = 0 ;
511
581
this ->repaint ();
512
582
}
583
+
584
+ /* * Edit Time */
585
+ if (this ->noteEditStatus == NoteControllerType::Left || this ->noteEditStatus == NoteControllerType::Right) {
586
+ /* * Reset Temp */
587
+ this ->noteEditStatus = NoteControllerType::None;
588
+ this ->noteEditIndex = -1 ;
589
+ this ->noteEditTime = -1 ;
590
+ this ->noteEditMinLength = -1 ;
591
+ this ->repaint ();
592
+ }
513
593
}
514
594
515
595
void MIDIContentViewer::mouseWheelMove (
@@ -549,6 +629,14 @@ void MIDIContentViewer::insertNote(
549
629
}
550
630
}
551
631
632
+ void MIDIContentViewer::setNoteStartTime (int tempIndex, double time) {
633
+ /* * TODO */
634
+ }
635
+
636
+ void MIDIContentViewer::setNoteEndTime (int tempIndex, double time) {
637
+ /* * TODO */
638
+ }
639
+
552
640
void MIDIContentViewer::updateKeyImageTemp () {
553
641
/* * Clear Temp */
554
642
juce::Graphics g (*(this ->keyTemp .get ()));
0 commit comments