@@ -361,11 +361,48 @@ void MIDIContentViewer::paintOverChildren(juce::Graphics& g) {
361
361
}
362
362
363
363
void MIDIContentViewer::mouseDown (const juce::MouseEvent& event) {
364
- if (event.mods .isLeftButtonDown () && event. mods . isAltDown () ) {
364
+ if (event.mods .isLeftButtonDown ()) {
365
365
/* * Move View Area */
366
- this ->viewMoving = true ;
367
- this ->setMouseCursor (juce::MouseCursor::DraggingHandCursor);
368
- this ->dragStartFunc ();
366
+ if (event.mods .isAltDown ()) {
367
+ this ->viewMoving = true ;
368
+ this ->setMouseCursor (juce::MouseCursor::DraggingHandCursor);
369
+ this ->dragStartFunc ();
370
+ }
371
+
372
+ /* * Edit Note */
373
+ else if (Tools::getInstance ()->getType () == Tools::Type::Pencil) {
374
+ auto & pos = event.position ;
375
+
376
+ auto [type, index ] = this ->getNoteController (pos);
377
+
378
+ /* * Add Note */
379
+ if (type == NoteControllerType::None) {
380
+ /* * Get Time */
381
+ double time = this ->secStart + (pos.x / this ->getWidth ()) * (this ->secEnd - this ->secStart );
382
+ time = quickAPI::limitTimeSec (time , Tools::getInstance ()->getAdsorb ());
383
+
384
+ /* * Get Pitch */
385
+ uint8_t pitch = (uint8_t )std::floor (this ->keyTop - (pos.y / this ->getHeight ()) * (this ->keyTop - this ->keyBottom ));
386
+
387
+ /* * Get Length */
388
+ double length = Tools::getInstance ()->getLastNoteLength ();
389
+ if (length <= 0 ) {
390
+ /* * Init Length */
391
+ int tempoIndex = quickAPI::getTempoTempIndexBySec (time );
392
+ auto tempo = quickAPI::getTempoData (tempoIndex);
393
+ length = std::get<3 >(tempo);
394
+
395
+ Tools::getInstance ()->setLastNoteLength (length);
396
+ }
397
+
398
+ /* * Set Temp */
399
+ this ->noteInsertTime = time ;
400
+ this ->noteInsertLength = length;
401
+ this ->noteInsertPitch = pitch;
402
+ this ->noteInsertChannel = Tools::getInstance ()->getMIDIChannel ();
403
+ this ->repaint ();
404
+ }
405
+ }
369
406
}
370
407
}
371
408
@@ -377,6 +414,21 @@ void MIDIContentViewer::mouseUp(const juce::MouseEvent& event) {
377
414
this ->setMouseCursor (juce::MouseCursor::NormalCursor);
378
415
this ->dragEndFunc ();
379
416
}
417
+
418
+ /* * Add Note */
419
+ if (this ->noteInsertTime >= 0 ) {
420
+ /* * Insert Note */
421
+ this ->insertNote (
422
+ this ->noteInsertTime , this ->noteInsertLength ,
423
+ this ->noteInsertPitch , this ->noteInsertChannel );
424
+
425
+ /* * Reset Temp */
426
+ this ->noteInsertTime = -1 ;
427
+ this ->noteInsertLength = -1 ;
428
+ this ->noteInsertPitch = 0 ;
429
+ this ->noteInsertChannel = 0 ;
430
+ this ->repaint ();
431
+ }
380
432
}
381
433
}
382
434
@@ -415,6 +467,22 @@ void MIDIContentViewer::mouseDrag(const juce::MouseEvent& event) {
415
467
int distanceY = event.getDistanceFromDragStartY ();
416
468
this ->dragProcessFunc (distanceX, distanceY, true , true );
417
469
}
470
+
471
+ /* * Add Note */
472
+ auto & pos = event.position ;
473
+ if (this ->noteInsertTime >= 0 ) {
474
+ /* * Get Time */
475
+ double time = this ->secStart + (pos.x / this ->getWidth ()) * (this ->secEnd - this ->secStart );
476
+ time = quickAPI::limitTimeSec (time , Tools::getInstance ()->getAdsorb ());
477
+
478
+ /* * Get Pitch */
479
+ uint8_t pitch = (uint8_t )std::floor (this ->keyTop - (pos.y / this ->getHeight ()) * (this ->keyTop - this ->keyBottom ));
480
+
481
+ /* * Set Temp */
482
+ this ->noteInsertTime = time ;
483
+ this ->noteInsertPitch = pitch;
484
+ this ->repaint ();
485
+ }
418
486
}
419
487
}
420
488
@@ -428,6 +496,16 @@ void MIDIContentViewer::mouseExit(const juce::MouseEvent& event) {
428
496
this ->setMouseCursor (juce::MouseCursor::NormalCursor);
429
497
this ->dragEndFunc ();
430
498
}
499
+
500
+ /* * Add Note */
501
+ if (this ->noteInsertTime >= 0 ) {
502
+ /* * Reset Temp */
503
+ this ->noteInsertTime = -1 ;
504
+ this ->noteInsertLength = -1 ;
505
+ this ->noteInsertPitch = 0 ;
506
+ this ->noteInsertChannel = 0 ;
507
+ this ->repaint ();
508
+ }
431
509
}
432
510
433
511
void MIDIContentViewer::mouseWheelMove (
@@ -450,6 +528,12 @@ void MIDIContentViewer::midiChannelChanged() {
450
528
this ->repaint ();
451
529
}
452
530
531
+ void MIDIContentViewer::insertNote (
532
+ double startTime, double length,
533
+ uint8_t pitch, uint8_t channel) {
534
+ /* * TODO */
535
+ }
536
+
453
537
void MIDIContentViewer::updateKeyImageTemp () {
454
538
/* * Clear Temp */
455
539
juce::Graphics g (*(this ->keyTemp .get ()));
0 commit comments