From 6f407f2cf257fd6ec9b114ae44bba27bd5b43c7e Mon Sep 17 00:00:00 2001 From: Mario Kruselj Date: Thu, 31 Mar 2022 20:13:18 +0200 Subject: [PATCH] Add VKB wheel skin colors, tweak design and positioning Closes #5746 --- .../data/skins/dark-mode.surge-skin/skin.xml | 6 +++ src/common/SkinColors.cpp | 6 +++ src/common/SkinColors.h | 5 +++ src/surge-xt/SurgeSynthEditor.cpp | 44 ++++++++----------- src/surge-xt/gui/SurgeJUCELookAndFeel.cpp | 9 +++- src/surge-xt/gui/SurgeJUCELookAndFeel.h | 4 ++ 6 files changed, 46 insertions(+), 28 deletions(-) diff --git a/resources/data/skins/dark-mode.surge-skin/skin.xml b/resources/data/skins/dark-mode.surge-skin/skin.xml index 6c9d7ad8ff2..b92c9ec7e1c 100644 --- a/resources/data/skins/dark-mode.surge-skin/skin.xml +++ b/resources/data/skins/dark-mode.surge-skin/skin.xml @@ -147,6 +147,12 @@ + + + + + + diff --git a/src/common/SkinColors.cpp b/src/common/SkinColors.cpp index d487ab79077..614a0279c64 100644 --- a/src/common/SkinColors.cpp +++ b/src/common/SkinColors.cpp @@ -452,6 +452,12 @@ namespace VirtualKeyboard { const Surge::Skin::Color Text("vkb.text", 0x000000, 0xFF), Shadow("vkb.shadow", 0x40000000); +namespace Wheel +{ +const Surge::Skin::Color Background("vkb.wheel.background", 0xFFFFFF), + Border("vkb.wheel.border", 0x979797), Value("vkb.wheel.value", 0xFF9000); +} + namespace Key { const Surge::Skin::Color Black("vkb.key.black", 0x000000, 0xFF), White("vkb.key.white", 0xFFFFFF), diff --git a/src/common/SkinColors.h b/src/common/SkinColors.h index 4aeef23bde3..e1c160c34b8 100644 --- a/src/common/SkinColors.h +++ b/src/common/SkinColors.h @@ -369,6 +369,11 @@ namespace VirtualKeyboard { extern const Surge::Skin::Color Text, Shadow; +namespace Wheel +{ +extern const Surge::Skin::Color Background, Border, Value; +} + namespace Key { extern const Surge::Skin::Color Black, White, Separator, MouseOver, Pressed; diff --git a/src/surge-xt/SurgeSynthEditor.cpp b/src/surge-xt/SurgeSynthEditor.cpp index fc4c73eb7f3..138e94a0717 100644 --- a/src/surge-xt/SurgeSynthEditor.cpp +++ b/src/surge-xt/SurgeSynthEditor.cpp @@ -27,34 +27,27 @@ struct VKeyboardWheel : public juce::Component int value{0}; void paint(juce::Graphics &g) override { - auto wheelSz = getLocalBounds().reduced(1, 2); - g.setColour(juce::Colour(15, 15, 15)); + auto wheelSz = getLocalBounds().reduced(2, 3); + + g.setColour(findColour(SurgeJUCELookAndFeel::SurgeColourIds::wheelBgId)); g.fillRect(wheelSz); - g.setColour(juce::Colour(80, 80, 80)); - g.drawRect(wheelSz); + g.setColour(findColour(SurgeJUCELookAndFeel::SurgeColourIds::wheelBorderId)); + g.drawRect(wheelSz.expanded(1, 1)); float p = 1.0 * value / range; + if (!unipolar) + { p = 1.0 * (value + range) / (2 * range); + } // y direction is flipped p = 1 - p; - int nTicks = 10; - float shift = 1.0 * p / nTicks; - - for (int i = 0; i < nTicks; ++i) - { - int lev = 150 - (i + p) * 50.0 / (nTicks); - g.setColour(juce::Colour(lev, lev, lev)); - float yp = (i + p * nTicks - floor(p * nTicks)) * wheelSz.getHeight() / nTicks + - wheelSz.getY(); - g.drawLine(wheelSz.getX(), yp, wheelSz.getRight(), yp); - } + float cp = wheelSz.getY() + p * (wheelSz.getHeight() - 4); + auto r = wheelSz.withHeight(2).translated(0, cp - 2).reduced(1, 0); - float cp = wheelSz.getY() + p * wheelSz.getHeight(); - auto r = wheelSz.withHeight(3).translated(0, cp - 3); - g.setColour(juce::Colours::yellow); + g.setColour(findColour(SurgeJUCELookAndFeel::SurgeColourIds::wheelValueId)); g.fillRect(r); } @@ -281,27 +274,26 @@ void SurgeSynthEditor::resized() auto y = adapter->getWindowSizeY(); auto x = addTempo ? 50 : 0; auto wheels = 32; + auto margin = 6; int tempoHeight = 14, typeinHeight = 18, yOffset = -2; int tempoBlockHeight = tempoHeight + typeinHeight; int tempoBlockYPos = ((extraYSpaceForVirtualKeyboard - tempoBlockHeight) / 2) + yOffset; auto xf = juce::AffineTransform().scaled(applyZoomFactor); - auto r = juce::Rectangle(x + wheels, y, adapter->getWindowSizeX() - x - wheels, + auto r = juce::Rectangle(x + wheels + margin, y, + adapter->getWindowSizeX() - x - wheels - margin, extraYSpaceForVirtualKeyboard); - // std::cout << "B4 " << r.toString() << std::endl; - // r = r.transformedBy(xf); - // std::cout << "AT " << r.toString() << std::endl; keyboard->setBounds(r); - keyboard->setTransform(xf); // juce::AffineTransform().scaled(1.05)); + keyboard->setTransform(xf); keyboard->setVisible(true); auto pmr = juce::Rectangle(x, y, wheels / 2, extraYSpaceForVirtualKeyboard); pitchwheel->setBounds(pmr); - pitchwheel->setTransform(xf); // juce::AffineTransform().scaled(1.05)); + pitchwheel->setTransform(xf); pitchwheel->setVisible(true); - pmr = pmr.translated(wheels / 2, 0); + pmr = pmr.translated((wheels / 2) + margin / 3, 0); modwheel->setBounds(pmr); - modwheel->setTransform(xf); // juce::AffineTransform().scaled(1.05)); + modwheel->setTransform(xf); modwheel->setVisible(true); if (addTempo) diff --git a/src/surge-xt/gui/SurgeJUCELookAndFeel.cpp b/src/surge-xt/gui/SurgeJUCELookAndFeel.cpp index baba36aeec0..2b5933fea4c 100644 --- a/src/surge-xt/gui/SurgeJUCELookAndFeel.cpp +++ b/src/surge-xt/gui/SurgeJUCELookAndFeel.cpp @@ -30,8 +30,6 @@ using namespace juce; void SurgeJUCELookAndFeel::onSkinChanged() { setColour(topWindowBorderId, skin->getColor(Colors::Dialog::Titlebar::Background)); - setColour(tempoTypeinTextId, Colours::black); - setColour(tempoTypeinHighlightId, Colours::red); setColour(DocumentWindow::backgroundColourId, Colour(48, 48, 48)); setColour(TextButton::buttonColourId, Colour(32, 32, 32)); @@ -102,6 +100,13 @@ void SurgeJUCELookAndFeel::onSkinChanged() setColour(SurgeJUCELookAndFeel::SurgeColourIds::tempoTypeinTextId, skin->getColor(Colors::Dialog::Entry::Text)); + setColour(SurgeJUCELookAndFeel::SurgeColourIds::wheelBgId, + skin->getColor(Colors::VirtualKeyboard::Wheel::Background)); + setColour(SurgeJUCELookAndFeel::SurgeColourIds::wheelBorderId, + skin->getColor(Colors::VirtualKeyboard::Wheel::Border)); + setColour(SurgeJUCELookAndFeel::SurgeColourIds::wheelValueId, + skin->getColor(Colors::VirtualKeyboard::Wheel::Value)); + setColour(MidiKeyboardComponent::textLabelColourId, skin->getColor(Colors::VirtualKeyboard::Text)); setColour(MidiKeyboardComponent::shadowColourId, diff --git a/src/surge-xt/gui/SurgeJUCELookAndFeel.h b/src/surge-xt/gui/SurgeJUCELookAndFeel.h index ece4ef68ad5..aeafcbe3429 100644 --- a/src/surge-xt/gui/SurgeJUCELookAndFeel.h +++ b/src/surge-xt/gui/SurgeJUCELookAndFeel.h @@ -62,6 +62,10 @@ class SurgeJUCELookAndFeel : public juce::LookAndFeel_V4, public Surge::GUI::Ski tempoTypeinBorderId, tempoTypeinHighlightId, tempoTypeinTextId, + + wheelBgId, + wheelBorderId, + wheelValueId, }; int lastDark{-1};