@@ -253,6 +253,7 @@ void MIDIContentViewer::paint(juce::Graphics& g) {
253253 juce::MidiKeyboardComponent::ColourIds::textLabelColourId + 3 );
254254 juce::Colour noteBaseColor = laf.findColour (
255255 juce::Label::ColourIds::backgroundColourId);
256+ juce::Colour noteEditColor = juce::Colours::white.withAlpha (0 .6f );
256257
257258 /* * Font */
258259 juce::Font noteLabelFont (juce::FontOptions{ noteFontHeight });
@@ -277,7 +278,7 @@ void MIDIContentViewer::paint(juce::Graphics& g) {
277278 g.drawImageAt (*(this ->noteTemp .get ()), 0 , 0 );
278279 }
279280
280- /* * Editing Note */
281+ /* * Add Note */
281282 constexpr float editingNoteOpaque = 0 .5f ;
282283 if (this ->noteInsertTime >= 0 && this ->noteInsertLength > 0 ) {
283284 int minNoteNum = std::floor (this ->keyBottom ), maxNoteNum = std::floor (this ->keyTop );
@@ -315,6 +316,62 @@ void MIDIContentViewer::paint(juce::Graphics& g) {
315316 }
316317 }
317318 }
319+
320+ /* * Edit Note Time */
321+ else if (this ->noteEditStatus == NoteControllerType::Left
322+ || this ->noteEditStatus == NoteControllerType::Right) {
323+ if (this ->noteEditIndex > -1 ) {
324+ /* * Get Note */
325+ auto & [noteIndex, rect, channel] = this ->noteRectTempList .getReference (this ->noteEditIndex );
326+ auto & note = this ->midiDataTemp .getReference (noteIndex);
327+ double noteStartTime = note.startSec ;
328+ double noteEndTime = note.endSec ;
329+ uint8_t notePitch = note.num ;
330+
331+ /* * Note Rect */
332+ float startXPos = (noteStartTime - this ->secStart ) / (this ->secEnd - this ->secStart ) * width;
333+ float endXPos = (noteEndTime - this ->secStart ) / (this ->secEnd - this ->secStart ) * width;
334+ float noteYPos = ((notePitch + 1 ) - this ->keyTop ) / (this ->keyBottom - this ->keyTop ) * height;
335+ juce::Rectangle<float > noteRect (
336+ startXPos, noteYPos,
337+ endXPos - startXPos, (float )this ->vItemSize );
338+
339+ /* * Cover Note */
340+ g.setColour (noteEditColor);
341+ g.fillRoundedRectangle (noteRect, noteCornerSize);
342+
343+ /* * New Note Rect */
344+ float newStartXPos = (this ->noteEditStatus == NoteControllerType::Left)
345+ ? (this ->noteEditTime - this ->secStart ) / (this ->secEnd - this ->secStart ) * width
346+ : startXPos;
347+ float newEndXPos = (this ->noteEditStatus == NoteControllerType::Right)
348+ ? (this ->noteEditTime - this ->secStart ) / (this ->secEnd - this ->secStart ) * width
349+ : endXPos;
350+ juce::Rectangle<float > newNoteRect (
351+ newStartXPos, noteYPos,
352+ newEndXPos - newStartXPos, (float )this ->vItemSize );
353+
354+ /* * Draw New Note */
355+ g.setColour (noteBaseColor);
356+ g.fillRoundedRectangle (newNoteRect, noteCornerSize);
357+ g.setColour (this ->noteColorGradient [channel - 1 ].withAlpha (editingNoteOpaque));
358+ g.fillRoundedRectangle (newNoteRect, noteCornerSize);
359+ g.setColour (noteOutlineColor.withAlpha (editingNoteOpaque));
360+ g.drawRoundedRectangle (newNoteRect, noteCornerSize, noteOutlineThickness);
361+
362+ /* * Note Name */
363+ juce::String noteName = this ->keyNames [notePitch % this ->keyMasks .size ()] + juce::String{ notePitch / this ->keyMasks .size () };
364+ float noteNameWidth = juce::TextLayout::getStringWidth (noteLabelFont, noteName);
365+ if ((noteNameWidth + notePaddingWidth * 2 ) <= newNoteRect.getWidth ()
366+ && (noteFontHeight + notePaddingHeight * 2 ) <= newNoteRect.getHeight ()) {
367+ juce::Rectangle<float > noteLabelRect = newNoteRect.withWidth (noteNameWidth + notePaddingWidth * 2 );
368+ g.setFont (noteLabelFont);
369+ g.setColour (this ->noteLabelColorGradient [channel - 1 ].withAlpha (editingNoteOpaque));
370+ g.drawFittedText (noteName, noteLabelRect.toNearestInt (),
371+ juce::Justification::centred, 1 , 0 .75f );
372+ }
373+ }
374+ }
318375}
319376
320377void MIDIContentViewer::paintOverChildren (juce::Graphics& g) {
0 commit comments