AnalogTapeModel

Physical modelling signal processing for analog tape recording
Log | Files | Refs | Submodules | README | LICENSE

commit 1fbd5698e2403a6f68c233ea5f67530a45b5c6b4
parent 981c44523e7da6af525054ce38be096b2c9ea426
Author: jatinchowdhury18 <jatinchowdhury18@gmail.com>
Date:   Tue,  9 Mar 2021 00:59:24 -0800

Add arrow buttons for preset selector (#153)

* Add arrow buttons for preset selector

* Fix preset arrow selection range

* Update Changelog

* {Apply clang-format}

Co-authored-by: jatinchowdhury18 <jatinchowdhury18@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Diffstat:
MCHANGELOG.md | 2++
MPlugin/Source/CMakeLists.txt | 2++
APlugin/Source/GUI/Assets/LeftArrow.svg | 3+++
APlugin/Source/GUI/Assets/RightArrow.svg | 3+++
MPlugin/Source/GUI/MyLNF.h | 3+--
MPlugin/Source/Presets/PresetComp.cpp | 39+++++++++++++++++++++++++++++++++++----
MPlugin/Source/Presets/PresetComp.h | 3+++
7 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -3,9 +3,11 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +- Added Azimuth parameter for playhead loss controls. - Added Variance and Drift parameters for Wow control. - Fixed stability issue in tone filters. - Improved parameter names for automation menus. +- Added arrows for preset menu. - Fixed GUI freezing bug in Cakewalk. - Fixed gain staging bug in Renoise. - Migrated build pipeline to CMake. diff --git a/Plugin/Source/CMakeLists.txt b/Plugin/Source/CMakeLists.txt @@ -18,6 +18,8 @@ juce_add_binary_data(BinaryData SOURCES GUI/Assets/knob.svg GUI/Assets/pointer.svg GUI/Assets/powerswitch.svg + GUI/Assets/LeftArrow.svg + GUI/Assets/RightArrow.svg GUI/Assets/RobotoCondensed-Bold.ttf GUI/Assets/RobotoCondensed-Regular.ttf diff --git a/Plugin/Source/GUI/Assets/LeftArrow.svg b/Plugin/Source/GUI/Assets/LeftArrow.svg @@ -0,0 +1,3 @@ +<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> +<path d="M9.53262e-08 8L12 1.0718L12 14.9282L9.53262e-08 8Z" fill="white"/> +</svg> diff --git a/Plugin/Source/GUI/Assets/RightArrow.svg b/Plugin/Source/GUI/Assets/RightArrow.svg @@ -0,0 +1,3 @@ +<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> +<path d="M16 8L4 14.9282L4 1.0718L16 8Z" fill="white"/> +</svg> diff --git a/Plugin/Source/GUI/MyLNF.h b/Plugin/Source/GUI/MyLNF.h @@ -78,8 +78,7 @@ public: void positionComboBoxText (ComboBox& box, Label& label) override { - auto b = box.getBounds(); - label.setBounds (b); + label.setBounds (3, 1, box.getWidth(), box.getHeight() - 2); label.setFont (getComboBoxFont (box).boldened()); } diff --git a/Plugin/Source/Presets/PresetComp.cpp b/Plugin/Source/Presets/PresetComp.cpp @@ -1,7 +1,9 @@ #include "PresetComp.h" PresetComp::PresetComp (ChowtapeModelAudioProcessor& proc, PresetManager& manager) : proc (proc), - manager (manager) + manager (manager), + presetsLeft ("", DrawableButton::ImageOnButtonBackground), + presetsRight ("", DrawableButton::ImageOnButtonBackground) { manager.addListener (this); @@ -26,6 +28,29 @@ PresetComp::PresetComp (ChowtapeModelAudioProcessor& proc, PresetManager& manage presetNameEditor.setMultiLine (false, false); presetNameEditor.setJustification (Justification::centred); + auto setupButton = [=, &manager] (DrawableButton& button, Drawable* image, int presetOffset) { + addAndMakeVisible (button); + button.setImages (image, image, image); + button.setWantsKeyboardFocus (false); + button.setColour (ComboBox::outlineColourId, Colours::transparentBlack); + button.setColour (TextButton::buttonColourId, Colours::transparentBlack); + button.onClick = [=, &manager] { + auto idx = presetBox.getSelectedId() + presetOffset; + while (idx <= 0) + idx += manager.getNumPresets(); + while (idx > manager.getNumPresets()) + idx -= manager.getNumPresets(); + + presetBox.setSelectedId (idx, sendNotification); + }; + }; + + std::unique_ptr<Drawable> leftImage (Drawable::createFromImageData (BinaryData::LeftArrow_svg, BinaryData::LeftArrow_svgSize)); + std::unique_ptr<Drawable> rightImage (Drawable::createFromImageData (BinaryData::RightArrow_svg, BinaryData::RightArrow_svgSize)); + + setupButton (presetsLeft, leftImage.get(), -1); + setupButton (presetsRight, rightImage.get(), 1); + presetUpdated(); presetBox.onChange = [=, &proc] { const auto selectedId = presetBox.getSelectedId(); @@ -107,13 +132,19 @@ void PresetComp::paint (Graphics& g) presetBox.setColour (PopupMenu::ColourIds::backgroundColourId, findColour (backgroundColourId)); g.setColour (findColour (backgroundColourId)); - g.fillRoundedRectangle (getLocalBounds().toFloat(), cornerSize); + + g.fillRoundedRectangle (getLocalBounds().toFloat().reduced (22.0f, 0.0f), cornerSize); } void PresetComp::resized() { - presetBox.setBounds (getLocalBounds()); - presetNameEditor.setBounds (getLocalBounds()); + auto b = getLocalBounds(); + presetsLeft.setBounds (b.removeFromLeft (20)); + presetsRight.setBounds (b.removeFromRight (20)); + + Rectangle<int> presetsBound { 22, 0, getWidth() - 44, getHeight() }; + presetBox.setBounds (presetsBound); + presetNameEditor.setBounds (presetsBound); repaint(); } diff --git a/Plugin/Source/Presets/PresetComp.h b/Plugin/Source/Presets/PresetComp.h @@ -28,9 +28,12 @@ private: ChowtapeModelAudioProcessor& proc; PresetManager& manager; + ComboBox presetBox; TextEditor presetNameEditor; + DrawableButton presetsLeft, presetsRight; + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PresetComp) };