From 8eb698695309fb97e566043bb30b84034129c869 Mon Sep 17 00:00:00 2001 From: Maymi <159730528+MaymiPR@users.noreply.github.com> Date: Wed, 18 Nov 2026 22:20:51 -0700 Subject: [PATCH] Name the colour literals of the sample view, menus and dialogs as tokens Nineteen hex colours stood at their use sites in WaveformView.cpp and Widgets.cpp, against the rule that every colour of the editor is a token of shared/ui/Theme.h. Each becomes a token with the same value, named for what it paints: the loop's lines and tint, the file markers, the channel icon, the scroll bar's rows, the menu's highlight and shortcut text, the tooltip, the dialog's button and field. No pixel changes: the seven images of docs/screenshots, regenerated after the change, are identical to the committed ones. Co-Authored-By: Claude Fable 5.2 --- plugin/Source/ui/WaveformView.cpp | 12 ++++++------ shared/ui/Theme.h | 19 +++++++++++++++++++ shared/ui/Widgets.cpp | 18 +++++++++--------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/plugin/Source/ui/WaveformView.cpp b/plugin/Source/ui/WaveformView.cpp index 5bbd8f4..7573514 100644 --- a/plugin/Source/ui/WaveformView.cpp +++ b/plugin/Source/ui/WaveformView.cpp @@ -548,12 +548,12 @@ void WaveformView::paint (juce::Graphics& g) const auto sx = fracToX (getValue (id::startOffset)); // FL's loop colours (sampled): START line / tab / label pure red, END a // darker red, the region a dark red tint. Grey versions when not looping. - const auto startCol = looping ? juce::Colour (0xffa78bfa) : juce::Colour (0xff7c7c7c); - const auto endCol = looping ? juce::Colour (0xff6d4fd6) : juce::Colour (0xff4c4c4c); + const auto startCol = looping ? chan::ui::colour::loopStart : chan::ui::colour::loopStartOff; + const auto endCol = looping ? chan::ui::colour::loopEnd : chan::ui::colour::loopEndOff; if (loopShown) { - g.setColour (looping ? juce::Colour (0xff1a1030) : juce::Colour (0xff1a1a1a)); + g.setColour (looping ? chan::ui::colour::loopRegion : chan::ui::colour::loopRegionOff); g.fillRect (juce::Rectangle::leftTopRightBottom (ls, wave.getY(), juce::jmax (ls + 1.0f, le), wave.getBottom())); } drawGrid(); @@ -593,7 +593,7 @@ void WaveformView::paint (juce::Graphics& g) // hanging from the top of the view (FL's look, measured). if (! sample->fileMarkers.empty()) { - g.setColour (juce::Colour (0xffebebeb)); + g.setColour (chan::ui::colour::fileMarker); for (auto m : sample->fileMarkers) { const auto x = std::floor (fracToX ((float) m / (float) sample->getTotalFrames())); @@ -610,7 +610,7 @@ void WaveformView::paint (juce::Graphics& g) // one notch for mono, two for stereo (measured with 16 / 24 / 32-bit files). { const auto iconR = juce::Rectangle (wave.getRight() - 15.0f, wave.getBottom() - 13.0f, 9.0f, 9.0f); - g.setColour (juce::Colour (0xffdfe5e8)); + g.setColour (chan::ui::colour::channelIcon); g.drawRect (iconR.withTrimmedTop (1.0f), 1.0f); if (sample->mono) g.fillRect (iconR.getCentreX() - 1.0f, iconR.getY() - 1.0f, 2.0f, 2.0f); @@ -710,7 +710,7 @@ void WaveformView::paint (juce::Graphics& g) const auto t1 = std::ceil (inner.getX() + viewEnd * inner.getWidth()); for (int row = 0; row < (int) inner.getHeight(); ++row) { - g.setColour (row % 2 == 0 ? juce::Colour (0xff080808) : juce::Colour (0xff0c0c0c)); + g.setColour (row % 2 == 0 ? chan::ui::colour::scrollRowEven : chan::ui::colour::scrollRowOdd); g.fillRect (juce::Rectangle::leftTopRightBottom (inner.getX(), inner.getY() + (float) row, t0, inner.getY() + (float) row + 1.0f)); g.fillRect (juce::Rectangle::leftTopRightBottom (t1, inner.getY() + (float) row, inner.getRight(), inner.getY() + (float) row + 1.0f)); } diff --git a/shared/ui/Theme.h b/shared/ui/Theme.h index 092654f..d08df15 100644 --- a/shared/ui/Theme.h +++ b/shared/ui/Theme.h @@ -144,10 +144,29 @@ namespace chan::ui const juce::Colour fieldEdge { 0xff303030 }; // the preset bar's outline const juce::Colour startFlag { 0xffebebeb }; // Start flag const juce::Colour playBar { 0xffa78bfa }; // playback bar (overview) + const juce::Colour loopStart { 0xffa78bfa }; // the loop's START line, tab and label while looping + const juce::Colour loopEnd { 0xff6d4fd6 }; // its END line, tab and label + const juce::Colour loopRegion { 0xff1a1030 }; // the tint between them + const juce::Colour loopStartOff { 0xff7c7c7c }; // the same three when the loop is not in use + const juce::Colour loopEndOff { 0xff4c4c4c }; + const juce::Colour loopRegionOff { 0xff1a1a1a }; + const juce::Colour fileMarker { 0xffebebeb }; // the tabs of the file's region and slice markers + const juce::Colour channelIcon { 0xffdfe5e8 }; // the mono / stereo icon in the view's corner + const juce::Colour scrollRowEven { 0xff080808 }; // the scroll bar outside the thumb, row by row + const juce::Colour scrollRowOdd { 0xff0c0c0c }; // Menus and dialogs const juce::Colour menuBg { 0xff141414 }; const juce::Colour menuText { 0xffebebeb }; + const juce::Colour menuHighlight { 0xff2e2e2e }; // the row under the mouse + const juce::Colour menuShortcut { 0xffa4a4a4 }; // a menu item's shortcut text + const juce::Colour tooltipText { 0xffebebeb }; // also the knob value popup + const juce::Colour menuButtonText { 0xffebebeb }; // the text of a button that opens a menu + const juce::Colour dialogButtonFrame { 0xff2b2b2b }; // a dialog's button: frame, top edge, darkening fill + const juce::Colour dialogButtonEdge { 0xff383838 }; + const juce::Colour dialogButtonTop { 0xff222222 }; + const juce::Colour dialogButtonBottom { 0xff141414 }; + const juce::Colour dialogField { 0xff141414 }; // a dialog's text field const juce::Colour ledOn { 0xfff472b6 }; // the file name when the sample is missing } diff --git a/shared/ui/Widgets.cpp b/shared/ui/Widgets.cpp index 0817fb7..6e46845 100644 --- a/shared/ui/Widgets.cpp +++ b/shared/ui/Widgets.cpp @@ -379,13 +379,13 @@ LookAndFeel::LookAndFeel() setColour (juce::PopupMenu::backgroundColourId, colour::menuBg); setColour (juce::PopupMenu::textColourId, colour::menuText); setColour (juce::PopupMenu::headerTextColourId, colour::text); - setColour (juce::PopupMenu::highlightedBackgroundColourId, juce::Colour (0xff2e2e2e)); + setColour (juce::PopupMenu::highlightedBackgroundColourId, colour::menuHighlight); setColour (juce::PopupMenu::highlightedTextColourId, juce::Colours::white); setColour (juce::ComboBox::textColourId, colour::comboText); setColour (juce::Label::textColourId, colour::text); setColour (juce::TextButton::textColourOffId, colour::buttonText); setColour (juce::TextButton::textColourOnId, colour::arc); - setColour (juce::TooltipWindow::textColourId, juce::Colour (0xffebebeb)); // also the knob value popup (menu text) + setColour (juce::TooltipWindow::textColourId, colour::tooltipText); setColour (juce::Slider::rotarySliderFillColourId, colour::arc); setColour (juce::TextEditor::highlightColourId, colour::arc.withAlpha (0.4f)); } @@ -605,7 +605,7 @@ void LookAndFeel::drawPopupMenuItemWithOptions (juce::Graphics& g, const juce::R // FL's shortcut text: right-aligned, italic, a little dimmer (FL capture: #A0A5A4) if (item.shortcutKeyDescription.isNotEmpty() && ! dd) { - g.setColour (item.isEnabled ? juce::Colour (0xffa4a4a4) : rmDisabled); + g.setColour (item.isEnabled ? colour::menuShortcut : rmDisabled); g.setFont (f.italicised()); g.drawText (item.shortcutKeyDescription, area.withTrimmedRight (14), juce::Justification::centredRight, false); g.setFont (f); @@ -1268,7 +1268,7 @@ void IconButton::paintButton (juce::Graphics& g, bool highlighted, bool down) const auto w = b.getWidth(); drawButton (g, getLocalBounds(), false, highlighted, down, isEnabled()); // FL: the same push button as Reset - const auto c = isEnabled() ? juce::Colour (0xffebebeb) : colour::dim; + const auto c = isEnabled() ? colour::menuButtonText : colour::dim; g.setColour (c); if (down) g.addTransform (juce::AffineTransform::translation (0.0f, 1.0f)); // FL: a pressed icon drops a pixel @@ -1352,13 +1352,13 @@ namespace void paintDialogButton (juce::Graphics& g, juce::Rectangle button, const juce::String& label, bool hover, bool down) { const auto b = button.toFloat(); - g.setColour (juce::Colour (0xff2b2b2b)); + g.setColour (colour::dialogButtonFrame); g.fillRect (b); - g.setColour (juce::Colour (0xff383838)); + g.setColour (colour::dialogButtonEdge); g.fillRect (b.reduced (1.0f)); const float lift = down ? -0.06f : hover ? 0.06f : 0.0f; - g.setGradientFill (juce::ColourGradient (juce::Colour (0xff222222).brighter (lift), 0.0f, b.getY() + 2.0f, - juce::Colour (0xff141414).brighter (lift), 0.0f, b.getBottom() - 1.0f, false)); + g.setGradientFill (juce::ColourGradient (colour::dialogButtonTop.brighter (lift), 0.0f, b.getY() + 2.0f, + colour::dialogButtonBottom.brighter (lift), 0.0f, b.getBottom() - 1.0f, false)); g.fillRect (b.reduced (1.0f).withTrimmedTop (1.0f)); g.setColour (dlgButtonText); g.setFont (font (dlgSmallEm)); @@ -1679,7 +1679,7 @@ namespace : DialogBase (t), prompt (p), onText (std::move (f)) { editor.setFont (juce::FontOptions (13.0f)); - editor.setColour (juce::TextEditor::backgroundColourId, juce::Colour (0xff141414)); + editor.setColour (juce::TextEditor::backgroundColourId, colour::dialogField); editor.setColour (juce::TextEditor::textColourId, juce::Colours::white); editor.setColour (juce::TextEditor::outlineColourId, colour::arc); editor.setColour (juce::TextEditor::focusedOutlineColourId, colour::arc);