void updateButtonTickColour() const noexcept { auto alpha = valueWithDefault->isUsingDefault() ? 0.4f : 1.0f; auto baseColour = buttonToControl->findColour (ToggleButton::tickColourId); buttonToControl->setColour (ToggleButton::tickColourId, baseColour.withAlpha (alpha)); }
//============================================================================== void paintListBoxItem (int rowNumber, Graphics& g, int width, int height, bool rowIsSelected) override { Rectangle<int> bounds (0, 0, width, height); auto textColour = findColour (Label::textColourId); g.setColour (textColour.withAlpha (0.4f)); if (rowNumber == 0) g.fillRect (bounds.removeFromTop (2).reduced (7, 0)); g.fillRect (bounds.removeFromBottom (2).reduced (7, 0)); if (rowIsSelected) { g.setColour (findColour (TextEditor::highlightColourId).withAlpha (0.4f)); g.fillRect (bounds); textColour = findColour (TextEditor::highlightedTextColourId); } g.setColour (textColour); if (selectedCategory.isEmpty()) { if (isPositiveAndBelow (rowNumber, JUCEDemos::getCategories().size())) g.drawFittedText (JUCEDemos::getCategories()[rowNumber].name, bounds, Justification::centred, 1); } else { auto& category = JUCEDemos::getCategory (selectedCategory); if (isPositiveAndBelow (rowNumber, category.demos.size())) g.drawFittedText (category.demos[rowNumber].demoFile.getFileName(), bounds, Justification::centred, 1); } }
void MidiKeyboardComponent::paint (Graphics& g) { g.fillAll (findColour (whiteNoteColourId)); auto lineColour = findColour (keySeparatorLineColourId); auto textColour = findColour (textLabelColourId); for (int octave = 0; octave < 128; octave += 12) { for (int white = 0; white < 7; ++white) { auto noteNum = octave + whiteNotes[white]; if (noteNum >= rangeStart && noteNum <= rangeEnd) drawWhiteNote (noteNum, g, getRectangleForKey (noteNum), state.isNoteOnForChannels (midiInChannelMask, noteNum), mouseOverNotes.contains (noteNum), lineColour, textColour); } } float x1 = 0.0f, y1 = 0.0f, x2 = 0.0f, y2 = 0.0f; auto width = getWidth(); auto height = getHeight(); if (orientation == verticalKeyboardFacingLeft) { x1 = width - 1.0f; x2 = width - 5.0f; } else if (orientation == verticalKeyboardFacingRight) x2 = 5.0f; else y2 = 5.0f; auto x = getKeyPos (rangeEnd).getEnd(); auto shadowCol = findColour (shadowColourId); if (! shadowCol.isTransparent()) { g.setGradientFill (ColourGradient (shadowCol, x1, y1, shadowCol.withAlpha (0.0f), x2, y2, false)); switch (orientation) { case horizontalKeyboard: g.fillRect (0.0f, 0.0f, x, 5.0f); break; case verticalKeyboardFacingLeft: g.fillRect (width - 5.0f, 0.0f, 5.0f, x); break; case verticalKeyboardFacingRight: g.fillRect (0.0f, 0.0f, 5.0f, x); break; default: break; } } if (! lineColour.isTransparent()) { g.setColour (lineColour); switch (orientation) { case horizontalKeyboard: g.fillRect (0.0f, height - 1.0f, x, 1.0f); break; case verticalKeyboardFacingLeft: g.fillRect (0.0f, 0.0f, 1.0f, x); break; case verticalKeyboardFacingRight: g.fillRect (width - 1.0f, 0.0f, 1.0f, x); break; default: break; } } auto blackNoteColour = findColour (blackNoteColourId); for (int octave = 0; octave < 128; octave += 12) { for (int black = 0; black < 5; ++black) { auto noteNum = octave + blackNotes[black]; if (noteNum >= rangeStart && noteNum <= rangeEnd) drawBlackNote (noteNum, g, getRectangleForKey (noteNum), state.isNoteOnForChannels (midiInChannelMask, noteNum), mouseOverNotes.contains (noteNum), blackNoteColour); } } }