commit f6531eb1b3cf8c7556be717112c211d3853d84b2
parent 57cc31c941e0fd776d5dbfd8a71f87837f1d2b7d
Author: jatinchowdhury18 <jatinchowdhury18@gmail.com>
Date: Thu, 24 Jun 2021 10:02:25 -0700
Oversampling menu: show text for both real-time and renderring oversampling choices (#204)
* Oversampling menu: show text for both real-time and renderring oversampling choices
* {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:
4 files changed, 75 insertions(+), 18 deletions(-)
diff --git a/Plugin/Source/GUI/Assets/gui.xml b/Plugin/Source/GUI/Assets/gui.xml
@@ -150,10 +150,10 @@
tooltip="Sets the depth of the tape degradation." slider-type="linear-horizontal"
max-height="70" margin="0" min-height="0" slidertext-width="80"
flex-grow="2.5" flex-shrink="2.5" padding=""/>
- <TextButton flex-align-self="auto" parameter="deg_point1x" max-height="160" background-color="FF31323A"
- button-on-color="FFB41717" button-color="FF33343D" text="0.1x"
- button-off-text="FFFFFFFF" button-on-text="FFFFFFFF" height=""
- width="" min-height="0.0" padding="0" caption-placement="centred"
+ <TextButton flex-align-self="auto" parameter="deg_point1x" max-height="160"
+ background-color="FF31323A" button-on-color="FFB41717" button-color="FF33343D"
+ text="0.1x" button-off-text="FFFFFFFF" button-on-text="FFFFFFFF"
+ height="" width="" min-height="0.0" padding="0" caption-placement="centred"
min-width="" margin="5" caption="" flex-grow="1.0" flex-shrink="0.1"
name="0.1x" lookAndFeel="LookAndFeel_V3" tooltip="Scales the Depth value by 0.1 to allow for more subtle degradation"/>
</View>
@@ -235,13 +235,13 @@
tooltip-text="FFFFFFFF"/>
<View max-height="35" margin="0" padding="0" background-color="FF31323A"
flex-grow="0.1">
- <View background-color="00000000" flex-grow="0.1"/>
- <OversamplingMenu caption="Oversampling" os-param="os" os-mode="os_mode"
- os-off-param="os_render_factor" os-off-mode="os_render_mode"
- os-off-same="os_render_like_realtime" class="Slider"
- caption-size="0" padding="0" combo-text="FFEAA92C" combo-background="00000000"
- max-height="100" margin="" lookAndFeel="ComboBoxLNF" name="Oversampling"
- tooltip="Sets the amount of oversampling used for the hysteresis processing. More oversampling will reduce aliasing artifacts, but requires more CPU resources."/>
+ <View background-color="00000000" flex-grow="0.05"/>
+ <OversamplingMenu caption="Oversampling" os-param="os" os-mode="os_mode" os-off-param="os_render_factor"
+ os-off-mode="os_render_mode" os-off-same="os_render_like_realtime"
+ class="Slider" flex-grow="1.2" caption-size="0" padding="0" combo-text="FFEAA92C"
+ combo-background="00000000" max-height="100" margin="0" lookAndFeel="ComboBoxLNF"
+ name="Oversampling" tooltip="Sets the amount of oversampling used for the hysteresis processing. More oversampling will reduce aliasing artifacts, but requires more CPU resources."
+ border=""/>
<ComboBox lookAndFeel="ComboBoxLNF" padding="0" border="0" background-color="00000000"
name="Hysteresis Mode" caption="Hysteresis Mode" caption-size="0"
combo-text="FFEAA92C" caption-color="FFFFFFFF" max-height="100"
@@ -254,9 +254,9 @@
tooltip="Adds this plugin to a mix group. When the plugin is added to a group, the group parameters will be copied to this plugin, and their parameters will remain in sync."/>
<MixGroupViz flex-grow="0.3" margin="5" padding="0" background-color="00000000"/>
<presets margin="5" padding="0" background-color="00000000" border-color="595C6B"
- radius="" border="" lookAndFeel="PresetsLNF" flex-grow="1.9"
+ radius="" border="" lookAndFeel="PresetsLNF" flex-grow="1.95"
max-height="100"/>
</View>
</View>
</magic>
-
+
+\ No newline at end of file
diff --git a/Plugin/Source/GUI/OversamplingMenu.cpp b/Plugin/Source/GUI/OversamplingMenu.cpp
@@ -20,6 +20,15 @@ OversamplingMenu::OversamplingMenu (foleys::MagicGUIBuilder& builder, const Valu
{ "combo-menu-text-highlight", PopupMenu::highlightedTextColourId } });
addAndMakeVisible (comboBox);
+ comboBox.setLookAndFeel (&lnf);
+
+ for (int i = 0; i < 5; ++i)
+ parameters[i] = nullptr;
+}
+
+OversamplingMenu::~OversamplingMenu()
+{
+ comboBox.setLookAndFeel (nullptr);
}
void OversamplingMenu::update()
@@ -80,7 +89,7 @@ void OversamplingMenu::generateComboBoxMenu()
PopupMenu::Item item;
item.itemID = menuIdx++;
auto* parameter = parameters[4];
- sameAsRT = (int) parameter->convertFrom0to1 (parameter->getValue()) == 1;
+ sameAsRT = parameter != nullptr ? (int) parameter->convertFrom0to1 (parameter->getValue()) == 1 : false;
item.text = "Same as real-time";
item.colour = sameAsRT ? Colour (0xFFEAA92C) : Colours::white;
item.action = [&] { attachments[4]->setValueAsCompleteGesture (1.0f); };
@@ -88,8 +97,12 @@ void OversamplingMenu::generateComboBoxMenu()
}
// add parameter to menus
+ std::pair<String, String> selectedText;
for (int paramIdx = 0; paramIdx < 4; ++paramIdx)
{
+ if (parameters[paramIdx] == nullptr)
+ continue;
+
bool isOfflineParam = paramIdx >= 2;
auto* thisMenu = isOfflineParam ? &offlineMenu : menu;
auto& thisMenuIdx = isOfflineParam ? offlineMenuIdx : menuIdx;
@@ -111,15 +124,22 @@ void OversamplingMenu::generateComboBoxMenu()
thisMenu->addItem (item);
if (isSelected && paramIdx == 0)
- comboBox.setText (item.text);
+ selectedText.first = item.text;
+ else if (isSelected && paramIdx == 2)
+ selectedText.second = item.text;
}
}
+ String comboBoxText = selectedText.first;
+ if (! sameAsRT)
+ comboBoxText += " / " + selectedText.second;
+ comboBox.setText (comboBoxText);
+
menu->addSeparator();
menu->addSubMenu ("Offline:", offlineMenu);
- auto osParam = parameters[0]->convertFrom0to1 (parameters[0]->getValue());
- auto osMode = parameters[1]->convertFrom0to1 (parameters[1]->getValue());
+ auto osParam = parameters[0] != nullptr ? parameters[0]->convertFrom0to1 (parameters[0]->getValue()) : 0;
+ auto osMode = parameters[1] != nullptr ? parameters[1]->convertFrom0to1 (parameters[1]->getValue()) : 0;
auto osIndex = osManager.getOSIndex (osParam, osMode);
auto curLatencyMs = osManager.getLatencyMilliseconds (osIndex);
menu->addSectionHeader ("Current Latency: " + String (curLatencyMs, 3) + " ms");
diff --git a/Plugin/Source/GUI/OversamplingMenu.h b/Plugin/Source/GUI/OversamplingMenu.h
@@ -1,6 +1,7 @@
#pragma once
#include "../Processors/Hysteresis/OversamplingManager.h"
+#include "MyLNF.h"
class OversamplingMenu : public foleys::GuiItem
{
@@ -14,6 +15,7 @@ public:
static const Identifier osOfflineSame;
OversamplingMenu (foleys::MagicGUIBuilder& builder, const ValueTree& node);
+ ~OversamplingMenu();
void update() override;
std::vector<foleys::SettableProperty> getSettableProperties() const override;
@@ -21,6 +23,41 @@ public:
Component* getWrappedComponent() override { return &comboBox; }
private:
+ class OversamplingLNF : public ComboBoxLNF
+ {
+ public:
+ OversamplingLNF() = default;
+
+ void drawComboBox (Graphics& g, int width, int height, bool, int, int, int, int, ComboBox& box) override
+ {
+ auto cornerSize = 5.0f;
+ Rectangle<int> boxBounds (0, 0, width, height);
+
+ g.setColour (box.findColour (ComboBox::backgroundColourId));
+ g.fillRoundedRectangle (boxBounds.toFloat(), cornerSize);
+
+ auto name = box.getName();
+ auto font = getComboBoxFont (box).boldened();
+ g.setColour (Colours::white);
+ g.setFont (font);
+
+ auto nameBox = boxBounds.removeFromLeft (font.getStringWidth (name));
+ g.drawFittedText (name + ": ", nameBox, Justification::left, 1);
+ }
+
+ void positionComboBoxText (ComboBox& box, Label& label) override
+ {
+ auto name = box.getName();
+ auto font = getComboBoxFont (box).boldened();
+ auto b = box.getBounds();
+ b.removeFromLeft (font.getStringWidth (name));
+
+ label.setBounds (b);
+ label.setFont (getComboBoxFont (box).boldened());
+ label.setJustificationType (Justification::centred);
+ }
+ } lnf;
+
void generateComboBoxMenu();
ComboBox comboBox;
diff --git a/Plugin/modules/CMakeLists.txt b/Plugin/modules/CMakeLists.txt
@@ -34,7 +34,6 @@ target_compile_definitions(juce_plugin_modules
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
JUCE_VST3_CAN_REPLACE_VST2=0
- # JUCE_ASIO=1
FOLEYS_SHOW_GUI_EDITOR_PALLETTE=0
FOLEYS_ENABLE_BINARY_DATA=1
JucePlugin_Manufacturer="chowdsp"