Skip to content

Commit a5a52bc

Browse files
Add midi content note
1 parent 811e8a4 commit a5a52bc

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/ui/component/editor/MIDIContentViewer.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,38 @@ void MIDIContentViewer::updateNoteImageTemp() {
494494
/** Clear Temp */
495495
this->noteTemp->clear(this->noteTemp->getBounds());
496496
juce::Graphics g(*(this->noteTemp.get()));
497+
int width = this->noteTemp->getWidth(), height = this->noteTemp->getHeight();
497498

498-
/** TODO */
499+
/** Size */
500+
auto screenSize = utils::getScreenSize(this);
501+
float noteCornerSize = screenSize.getHeight() * 0.003;
502+
float noteOutlineThickness = screenSize.getHeight() * 0.001;
503+
504+
/** Colors */
505+
auto& laf = this->getLookAndFeel();
506+
juce::Colour noteOutlineColor = laf.findColour(
507+
juce::Label::ColourIds::outlineColourId);
508+
509+
/** Notes */
510+
int minNoteNum = std::floor(this->keyBottom), maxNoteNum = std::floor(this->keyTop);
511+
for (auto& note : this->midiDataTemp) {
512+
if (note.startSec <= this->secEnd &&
513+
this->secStart <= note.endSec) {
514+
if (note.num >= minNoteNum &&
515+
note.num <= maxNoteNum) {
516+
float startXPos = (note.startSec - this->secStart) / (this->secEnd - this->secStart) * width;
517+
float endXPos = (note.endSec - this->secStart) / (this->secEnd - this->secStart) * width;
518+
float noteYPos = ((note.num + 1) - this->keyTop) / (this->keyBottom - this->keyTop) * height;
519+
juce::Rectangle<float> noteRect(
520+
startXPos, noteYPos,
521+
endXPos - startXPos, (float)this->vItemSize);
522+
g.setColour(this->noteColorGradient[note.channel]);
523+
g.fillRoundedRectangle(noteRect,noteCornerSize);
524+
g.setColour(noteOutlineColor);
525+
g.drawRoundedRectangle(noteRect, noteCornerSize, noteOutlineThickness);
526+
}
527+
}
528+
}
499529
}
500530

501531
std::tuple<double, double> MIDIContentViewer::getHViewArea(double pos, double itemSize) const {

src/ui/lookAndFeel/editor/MidiContentLookAndFeel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ MidiContentLookAndFeel::MidiContentLookAndFeel()
3535
this->setColour(juce::Label::ColourIds::textColourId,
3636
ColorMap::getInstance()->get("ThemeColorA2"));/**< Cursor */
3737
this->setColour(juce::Label::ColourIds::outlineColourId,
38-
ColorMap::getInstance()->get("ThemeColorB3"));
38+
ColorMap::getInstance()->get("ThemeColorB3"));/**< Note Outline */
3939
this->setColour(juce::Label::ColourIds::backgroundWhenEditingColourId,
4040
ColorMap::getInstance()->get("ThemeColorB9"));/**< Notes In High Channel */
4141
this->setColour(juce::Label::ColourIds::textWhenEditingColourId,

0 commit comments

Comments
 (0)