This commit is contained in:
Maurice Grönwoldt 2020-06-14 21:14:28 +02:00
commit a27c62f062
44 changed files with 1170 additions and 384 deletions

View file

@ -4,11 +4,11 @@
#include "VenoMatrix.h"
VenoMatrix::VenoMatrix (const std::string& processId) : m_processId (processId)
VenoMatrix::VenoMatrix (const std::string& processId) : m_processId(processId)
{
for (auto& m_slot : m_slots)
{
m_slot = new VenoMatrixSlot ();
m_slot = new VenoMatrixSlot();
}
}
@ -27,22 +27,22 @@ VenoMatrixSlot* VenoMatrix::getSlotById (int id)
void VenoMatrix::removeModulateValue (const std::string& name)
{
m_modulationValues.erase (name);
m_modulationValues.erase(name);
}
void VenoMatrix::removeModulator (const std::string& name)
{
m_modulators.erase (name);
m_modulators.erase(name);
}
void VenoMatrix::addModulateValue (const std::string& name, ModulateValue* modulateValue)
{
m_modulationValues.emplace (std::pair<const std::string&, ModulateValue*> (name, modulateValue));
m_modulationValues.emplace(std::pair<const std::string&, ModulateValue*>(name, modulateValue));
}
void VenoMatrix::addModulator (const std::string& name, Modulator* modulator)
{
m_modulators.emplace (std::pair<const std::string&, Modulator*> (name, modulator));
m_modulators.emplace(std::pair<const std::string&, Modulator*>(name, modulator));
}
void VenoMatrix::updateSlots ()
@ -53,26 +53,26 @@ void VenoMatrix::updateSlots ()
{
continue;
}
if (m_modulators.find (m_slot->sourceName) != m_modulators.end ())
if (m_modulators.find(m_slot->sourceName) != m_modulators.end())
{
auto modulator = m_modulators[m_slot->sourceName];
if (modulator == nullptr)
{
continue;
}
modulator->update ();
modulator->update();
for (auto& value : m_slot->targets)
{
if (value.name != "none")
{
if (m_modulationValues.find (value.name) != m_modulationValues.end ())
if (m_modulationValues.find(value.name) != m_modulationValues.end())
{
auto modValue = m_modulationValues[value.name];
if (modValue == nullptr)
{
continue;
}
modValue->addValue (modulator->getValue () * value.amount);
modValue->addValue(modulator->getValue() * value.amount);
}
}
}

View file

@ -6,6 +6,6 @@
#include <utility>
SynthInstance::SynthInstance (std::string processId)
: m_processId (std::move (processId))
: m_processId(std::move(processId))
{
}

View file

@ -12,18 +12,18 @@ VenoBuffer::VenoBuffer ()
VenoBuffer::~VenoBuffer ()
{
buffer.clear ();
right.clear ();
left.clear ();
buffer.clear();
right.clear();
left.clear();
}
void VenoBuffer::reset (int size)
{
if (size != buffer.size ())
if (size != buffer.size())
{
buffer.resize (size);
right.resize (size);
left.resize (size);
buffer.resize(size);
right.resize(size);
left.resize(size);
}
// reset to 0 dc :D
for (int i = 0; i < size; ++i)
@ -54,11 +54,11 @@ void VenoBuffer::addRightSample (float value, int index)
void VenoBuffer::calcPeak ()
{
for (int i = 0; i < buffer.size (); ++i)
for (int i = 0; i < buffer.size(); ++i)
{
auto l = std::abs (left[i]);
auto r = std::abs (right[i]);
auto m = std::abs (buffer[i]);
auto l = std::abs(left[i]);
auto r = std::abs(right[i]);
auto m = std::abs(buffer[i]);
if (m > monoPeak)
{
monoPeak = m;

View file

@ -12,7 +12,7 @@ void generateSaw (WaveTableGroup* group)
{
return;
}
int tableLen = findTableLen ();
int tableLen = findTableLen();
int idx;
auto* freqWaveRe = new double[tableLen];
auto* freqWaveIm = new double[tableLen];
@ -26,6 +26,6 @@ void generateSaw (WaveTableGroup* group)
freqWaveRe[idx] = 1.0 / idx; // sawtooth spectrum
freqWaveRe[tableLen - idx] = -freqWaveRe[idx]; // mirror
}
fillTables (group, freqWaveRe, freqWaveIm, tableLen);
VeNo::Logger::infoDebugMessage ("Generated clean Saw Wave");
fillTables(group, freqWaveRe, freqWaveIm, tableLen);
VeNo::Logger::infoDebugMessage("Generated clean Saw Wave");
}

View file

@ -51,8 +51,8 @@ void fft (int N, double* ar, double* ai)
LE *= 2; // (LE = 2^L)
Ur = 1.0;
Ui = 0.;
Wr = std::cos (M_PI / (float) LE1);
Wi = -std::sin (M_PI / (float) LE1); // Cooley, Lewis, and Welch have "+" here
Wr = std::cos(M_PI / (float) LE1);
Wi = -std::sin(M_PI / (float) LE1); // Cooley, Lewis, and Welch have "+" here
for (j = 1; j <= LE1; j++)
{
for (i = j; i <= N; i += LE)
@ -74,14 +74,14 @@ void fft (int N, double* ar, double* ai)
float makeWaveTable (WaveTableGroup* group, int len, double* ar, double* ai, double scale, double topFreq)
{
fft (len, ar, ai);
fft(len, ar, ai);
if (scale == 0.0)
{
// calc normal
double max = 0;
for (int idx = 0; idx < len; idx++)
{
double temp = fabs (ai[idx]);
double temp = fabs(ai[idx]);
if (max < temp)
max = temp;
}
@ -94,7 +94,7 @@ float makeWaveTable (WaveTableGroup* group, int len, double* ar, double* ai, dou
wave[idx] = ai[idx] * scale;
if (group->m_numWaveTables < WaveTableGroup::numWaveTableSlots)
{
auto table = group->m_WaveTables[group->m_numWaveTables] = new WaveTableObject ();
auto table = group->m_WaveTables[group->m_numWaveTables] = new WaveTableObject();
float* waveTable = group->m_WaveTables[group->m_numWaveTables]->m_waveTable = new float[len + 1];
table->m_waveTableLen = len;
table->m_topFreq = topFreq;
@ -121,7 +121,7 @@ int fillTables (WaveTableGroup* group, double* freqWaveRe, double* freqWaveIm, i
freqWaveRe[numSamples >> 1] = freqWaveIm[numSamples >> 1] = 0.0;
int maxHarmonic = numSamples >> 1;
const double minVal = 0.000001; // -120 dB
while ((fabs (freqWaveRe[maxHarmonic]) + fabs (freqWaveIm[maxHarmonic]) < minVal) && maxHarmonic) --maxHarmonic;
while ((fabs(freqWaveRe[maxHarmonic]) + fabs(freqWaveIm[maxHarmonic]) < minVal) && maxHarmonic) --maxHarmonic;
double topFreq = 2.0 / 3.0 / maxHarmonic;
double* ar = new double[numSamples];
double* ai = new double[numSamples];
@ -141,7 +141,7 @@ int fillTables (WaveTableGroup* group, double* freqWaveRe, double* freqWaveIm, i
}
// make the wavetable
scale = makeWaveTable (group, numSamples, ar, ai, scale, topFreq);
scale = makeWaveTable(group, numSamples, ar, ai, scale, topFreq);
numTables++;
// prepare for next table
@ -153,11 +153,11 @@ int fillTables (WaveTableGroup* group, double* freqWaveRe, double* freqWaveIm, i
float getNextRand ()
{
return std::rand () / double (RAND_MAX);
return std::rand() / double(RAND_MAX);
}
int findTableLen ()
{
int maxHarms = AudioConfig::getInstance ()->getSampleRate () / (5.0 * 20) + 0.5;
return VeNo::Utils::nextPowerOfTwo (maxHarms) * 2;
int maxHarms = AudioConfig::getInstance()->getSampleRate() / (5.0 * 20) + 0.5;
return VeNo::Utils::nextPowerOfTwo(maxHarms) * 2;
}

View file

@ -9,25 +9,25 @@
void WaveTableGenerator::init ()
{
//if the sampleRate changed... the WaveTables are not harmonic Save anymore and are needed to rebuild... pls stay save later!
if (AudioConfig::getInstance ()->isNeedToReInit ())
if (AudioConfig::getInstance()->isNeedToReInit())
{
cleanTables ();
AudioConfig::getInstance ()->setNeedToReInit (false);
cleanTables();
AudioConfig::getInstance()->setNeedToReInit(false);
}
if (m_isInit)
{
return;
}
m_waveTables[WaveForms::SAW] = new WaveTableGroup ();
m_waveTables[WaveForms::SINE] = new WaveTableGroup ();
m_waveTables[WaveForms::SQUARE] = new WaveTableGroup ();
m_waveTables[WaveForms::TRIANGLE] = new WaveTableGroup ();
m_waveTables[WaveForms::wSaw] = new WaveTableGroup ();
m_waveTables[WaveForms::wSQUARE] = new WaveTableGroup ();
m_waveTables[WaveForms::SYNTHONE] = new WaveTableGroup ();
m_waveTables[WaveForms::SYNTHTWO] = new WaveTableGroup ();
m_waveTables[WaveForms::VENOX] = new WaveTableGroup ();
generateSaw (m_waveTables[WaveForms::SAW]);
m_waveTables[WaveForms::SAW] = new WaveTableGroup();
m_waveTables[WaveForms::SINE] = new WaveTableGroup();
m_waveTables[WaveForms::SQUARE] = new WaveTableGroup();
m_waveTables[WaveForms::TRIANGLE] = new WaveTableGroup();
m_waveTables[WaveForms::wSaw] = new WaveTableGroup();
m_waveTables[WaveForms::wSQUARE] = new WaveTableGroup();
m_waveTables[WaveForms::SYNTHONE] = new WaveTableGroup();
m_waveTables[WaveForms::SYNTHTWO] = new WaveTableGroup();
m_waveTables[WaveForms::VENOX] = new WaveTableGroup();
generateSaw(m_waveTables[WaveForms::SAW]);
m_isInit = true;
}
@ -35,7 +35,7 @@ WaveTableGroup* WaveTableGenerator::getGroup (int id)
{
if (!m_isInit)
{
init ();
init();
}
if (id < 40)
{

View file

@ -43,16 +43,16 @@ void AudioConfig::setNeedToReInit (bool _needToReInit)
std::shared_ptr<AudioConfig> AudioConfig::getInstance ()
{
if (AudioConfig::m_instance == nullptr)
AudioConfig::m_instance = std::make_shared<AudioConfig> ();
AudioConfig::m_instance = std::make_shared<AudioConfig>();
return m_instance;
}
void AudioConfig::initWaveTables ()
{
WaveTableGenerator::getInstance ().init ();
WaveTableGenerator::getInstance().init();
}
AudioConfig::~AudioConfig ()
{
WaveTableGenerator::getInstance ().cleanTables ();
WaveTableGenerator::getInstance().cleanTables();
}

View file

@ -4,23 +4,26 @@
#include "Config.h"
#include "../Fonts/Fonts.h"
#include "../GUI/GUIParts/Sidebar/VenoLogo.h"
#include "../Utils.h"
std::shared_ptr<Config> Config::m_instance = nullptr;
Config::Config ()
{
// i want to load the m_config file here...
initConfig ();
m_theme = std::make_shared<Theme> (m_config);
m_theme->init ();
m_fps = m_config->getIntValue ("waveform_fps", 60);
initConfig();
m_theme = std::make_shared<Theme>(m_config);
m_theme->init();
m_fps = m_config->getIntValue("waveform_fps", 60);
startTimer(5000);
}
void Config::saveAll ()
{
if (m_config != nullptr)
{
m_config->saveIfNeeded ();
m_config->saveIfNeeded();
}
}
@ -39,7 +42,8 @@ void Config::initConfig ()
options.applicationName = "config";
options.folderName = "veno";
options.filenameSuffix = "xml";
m_config = std::make_unique<PropertiesFile> (options);
m_config = std::make_unique<PropertiesFile>(options);
m_scale = (float) m_config->getDoubleValue("scale", 1.0);
}
std::shared_ptr<Theme> Config::getCurrentTheme ()
@ -47,24 +51,29 @@ std::shared_ptr<Theme> Config::getCurrentTheme ()
return m_theme;
}
double Config::getScale ()
double Config::getScale () const
{
return 1;
return m_scale;
}
void Config::setColourForIndex (Colour* colour, ThemeColour index)
{
if (m_theme)
{
m_theme->setColour (index, colour);
m_theme->setColour(index, colour);
}
}
Config::~Config ()
{
m_config->save ();
m_theme.reset ();
m_config.reset ();
m_config->save();
m_config->setNeedsToBeSaved(false);
m_theme.reset();
m_config.reset();
m_lookHandler.reset();
stopTimer();
VenoFonts::destroyAll();
VenoLogo::deleteInstance();
}
//LEAK DETECTOR FIX!
@ -75,10 +84,9 @@ void Config::registerEditor (AudioProcessorEditor* editor, const std::string& na
void Config::removeEditor (const std::string& name)
{
m_editors.erase (name);
if (m_editors.empty ())
m_editors.erase(name);
if (m_editors.empty())
{
VenoFonts::destroyAll ();
m_instance = nullptr;
}
}
@ -86,13 +94,13 @@ void Config::removeEditor (const std::string& name)
//for LCD :P let's be a bit funny xD
int Config::getEditorCount ()
{
return m_editors.size ();
return m_editors.size();
}
std::shared_ptr<Config> Config::getInstance ()
{
if (m_instance == nullptr)
m_instance = std::make_shared<Config> ();
m_instance = std::make_shared<Config>();
return m_instance;
}
@ -100,3 +108,38 @@ int Config::getFps () const
{
return m_fps;
}
void Config::setScale (float value)
{
value = VeNo::Utils::clamp(value, 0.5f, 2.5f);
m_scale = value;
m_config->setValue("scale", m_scale);
m_config->setNeedsToBeSaved(true);
for (auto& editor : m_editors)
{
editor.second->setSize(1200 * m_scale, 700 * m_scale);
}
}
void Config::timerCallback ()
{
m_config->saveIfNeeded();
}
void Config::repaintAll ()
{
for (auto& editor : m_editors)
{
if (editor.second->isShowing())
{
editor.second->repaint();
}
}
}
void Config::setFps (float value)
{
m_fps = VeNo::Utils::clamp(value, 15, 90);
m_config->setValue("waveform_fps", m_fps);
m_config->setNeedsToBeSaved(true);
}

View file

@ -10,7 +10,7 @@
#include "../GUI/Theme/Theme.h"
#include <memory>
class Config
class Config : public Timer
{
private:
std::shared_ptr<PropertiesFile> m_config = nullptr;
@ -18,14 +18,16 @@ private:
static std::shared_ptr<Config> m_instance;
int m_currentLook = 0; //nah move the bitch logic from current to next
std::unordered_map<std::string, AudioProcessorEditor*> m_editors;
int m_fps = 60;
std::shared_ptr<LookHandler> m_lookHandler;
public:
int m_fps = 60;
float m_scale = 1.0f;
static std::shared_ptr<Config> getInstance ();
void saveAll ();
int getCurrentLook ();
void setColourForIndex (Colour* colour, ThemeColour index);
std::shared_ptr<Theme> getCurrentTheme ();
double getScale ();
double getScale () const;
// can be public but doesnt need!
Config ();
~Config ();
@ -33,6 +35,10 @@ public:
void removeEditor (const std::string& name);
int getEditorCount ();
int getFps () const;
void setScale(float value);
void setFps(float value);
void timerCallback () override;
void repaintAll();
protected:
void initConfig ();
};

View file

@ -0,0 +1,16 @@
//
// Created by versustune on 14.06.20.
//
#include "VeNoState.h"
VeNoState::VeNoState (std::string pid)
{
m_pid = pid;
}
VeNoState::~VeNoState ()
{
delete configScreen;
configScreen = nullptr;
}

View file

@ -0,0 +1,20 @@
//
// Created by versustune on 14.06.20.
//
#ifndef VENO_VENOSTATE_H
#define VENO_VENOSTATE_H
#include <string>
#include "../GUI/GUIParts/ConfigScreen/VenoConfigScreen.h"
class VeNoState
{
protected:
std::string m_pid = "";
public:
VeNoState(std::string pid);
~VeNoState();
VenoConfigScreen* configScreen = nullptr;
};
#endif //VENO_VENOSTATE_H

View file

@ -4,23 +4,23 @@
#include "Fonts.h"
VenoFonts* VenoFonts::instance = new VenoFonts ();
VenoFonts* VenoFonts::instance = new VenoFonts();
Font* VenoFonts::getNormal ()
{
return getInstance ()->arvo;
return getInstance()->arvo;
}
Font* VenoFonts::getLCD ()
{
return getInstance ()->lcdFont;
return getInstance()->lcdFont;
}
VenoFonts* VenoFonts::getInstance ()
{
if (instance == nullptr)
{
instance = new VenoFonts ();
instance = new VenoFonts();
}
return instance;
}
@ -33,10 +33,10 @@ void VenoFonts::destroyAll ()
VenoFonts::VenoFonts ()
{
arvo = new Font (Typeface::createSystemTypefaceFor (BinaryData::arvo_ttf,
BinaryData::arvo_ttfSize));
lcdFont = new Font (Typeface::createSystemTypefaceFor (BinaryData::lcd_ttf,
BinaryData::lcd_ttfSize));
arvo = new Font(Typeface::createSystemTypefaceFor(BinaryData::arvo_ttf,
BinaryData::arvo_ttfSize));
lcdFont = new Font(Typeface::createSystemTypefaceFor(BinaryData::lcd_ttf,
BinaryData::lcd_ttfSize));
}
VenoFonts::~VenoFonts ()

View file

@ -3,6 +3,7 @@
//
#include "BaseComponent.h"
#include "../../Utils.h"
#include "../../Fonts/Fonts.h"
#include <utility>
@ -13,40 +14,42 @@ BaseComponent::BaseComponent (const std::string& processId)
BaseComponent::~BaseComponent ()
{
m_label.reset ();
m_label.reset();
}
void BaseComponent::addLabel (const std::string& label_text, LabelPosition labelPosition)
{
m_enableLabel = true;
m_label = std::make_shared<LabelComponent> (this, label_text);
m_label->setPosition (labelPosition);
m_label = std::make_shared<LabelComponent>(this, label_text);
m_label->setPosition(labelPosition);
addAndMakeVisible(*m_label);
}
void BaseComponent::resized ()
{
if (m_enableLabel && m_label != nullptr)
{
LabelPosition position = m_label->getLabelPosition ();
LabelPosition position = m_label->getLabelPosition();
if (position == LabelPosition::TOP)
{
m_label->setBounds (0, 0, getWidth (), 15);
m_label->setBounds(0, 0, getWidth(), VeNo::Utils::getCalculatedHeight(15));
}
else if (position == LabelPosition::BOTTOM)
{
m_label->setBounds (0, getHeight () - 20, getWidth (), 15);
auto height = VeNo::Utils::getCalculatedHeight(15);
m_label->setBounds(0, getHeight() - height, getWidth(), height);
}
}
}
void BaseComponent::paint (Graphics& g)
{
g.setFont (*VenoFonts::getNormal ());
g.setFont(*VenoFonts::getNormal());
}
void BaseComponent::setParameter (std::string name, std::string group)
{
m_name = std::move (name);
m_group = std::move (group);
setName (m_name);
m_name = std::move(name);
m_group = std::move(group);
setName(m_name);
}

View file

@ -19,7 +19,6 @@ private:
std::string m_group;
std::string m_name;
bool m_enableLabel = false;
std::shared_ptr<LabelComponent> m_label;
public:
explicit BaseComponent (const std::string& processId);
~BaseComponent () override;
@ -29,5 +28,6 @@ public:
void paint (Graphics& g) override;
protected:
std::string m_processId;
std::shared_ptr<LabelComponent> m_label;
};
#endif //VENO_BASECOMPONENT_H

View file

@ -0,0 +1,65 @@
//
// Created by versustune on 14.06.20.
//
#include "VeNoColour.h"
#include <utility>
#include "../../../Core/Config.h"
#include "../../../Utils.h"
using ColourOption = ColourSelector::ColourSelectorOptions;
VeNoColour::~VeNoColour ()
{
BaseComponent::m_label.reset();
m_selector.reset();
}
VeNoColour::VeNoColour (const std::string& processId, ThemeColour index)
: BaseComponent(processId)
{
m_index = index;
m_selector = std::make_unique<ColourSelector>(
ColourOption::showColourAtTop|ColourOption::editableColour|ColourOption::showColourspace);
m_selector->setCurrentColour(Config::getInstance()->getCurrentTheme()->getColour(index),
NotificationType::dontSendNotification);
m_selector->addChangeListener(this);
m_selector->setOpaque(false);
addAndMakeVisible(*m_selector);
}
void VeNoColour::setName (std::string name)
{
m_name = std::move(name);
if (BaseComponent::m_label == nullptr)
{
BaseComponent::addLabel(m_name, LabelPosition::TOP);
}
}
void VeNoColour::changeListenerCallback (ChangeBroadcaster* source)
{
auto selector = m_selector->getCurrentColour();
auto* colour = new Colour(selector.getRed(), selector.getGreen(), selector.getBlue(),
1.0f);
Config::getInstance()->getCurrentTheme()->setColour(m_index, colour);
Config::getInstance()->repaintAll();
}
void VeNoColour::resized ()
{
auto h = VeNo::Utils::getCalculatedHeight(30);
if (BaseComponent::m_label != nullptr)
{
BaseComponent::m_label->setBounds(0, 0, getWidth(), h);
}
if (m_selector != nullptr)
{
m_selector->setBounds(0, h, getWidth(), getHeight() - h);
}
}
void VeNoColour::paint (Graphics& g)
{
g.setColour(Colours::white);
BaseComponent::paint(g);
}

View file

@ -0,0 +1,27 @@
//
// Created by versustune on 14.06.20.
//
#ifndef VENO_VENOCOLOUR_H
#define VENO_VENOCOLOUR_H
#include "JuceHeader.h"
#include "../BaseComponent.h"
#include "../../Theme/Theme.h"
class VeNoColour : public BaseComponent, ChangeListener
{
private:
ThemeColour m_index;
std::unique_ptr<ColourSelector> m_selector;
std::string m_name;
public:
explicit VeNoColour (const std::string& processId, ThemeColour index);
~VeNoColour () override;
void setName(std::string name);
void resized () override;
void paint (Graphics& g) override;
private:
void changeListenerCallback (ChangeBroadcaster* source) override;
};
#endif //VENO_VENOCOLOUR_H

View file

@ -0,0 +1,34 @@
//
// Created by versustune on 14.06.20.
//
#include "VenoConfigButton.h"
#include "../../../Core/Config.h"
#include "../../../Utils.h"
#include "../../../VenoInstance.h"
#include "../../../Utils/Logger.h"
VenoConfigButton::VenoConfigButton (const std::string& processId) : BaseComponent(processId)
{
setMouseCursor(MouseCursor::PointingHandCursor);
}
void VenoConfigButton::paint (Graphics& g)
{
auto theme = Config::getInstance()->getCurrentTheme();
VeNo::Utils::setFontSize(16.0f, g);
g.setColour(theme->getColour(ThemeColour::accent));
g.drawRect(0, 0, getWidth(), getHeight());
g.drawFittedText("Config", 0, 0, getWidth(), getHeight(), Justification::centred, 1, 1);
}
void VenoConfigButton::mouseDown (const MouseEvent& event)
{
// open Window on click :)
auto state = VenoInstance::getInstance(m_processId)->state;
if (state->configScreen != nullptr)
{
return;
}
state->configScreen = new VenoConfigScreen(m_processId);
}

View file

@ -0,0 +1,21 @@
//
// Created by versustune on 14.06.20.
//
#ifndef VENO_VENOCONFIGBUTTON_H
#define VENO_VENOCONFIGBUTTON_H
#include "JuceHeader.h"
#include "../BaseComponent.h"
class VenoConfigButton : public BaseComponent
{
public:
VenoConfigButton (const std::string& processId);
~VenoConfigButton() = default;
void paint (Graphics& g) override;
void mouseDown (const MouseEvent& event) override;
private:
};
#endif //VENO_VENOCONFIGBUTTON_H

View file

@ -0,0 +1,84 @@
//
// Created by versustune on 14.06.20.
//
#include "VenoPreColours.h"
#include "../../../Core/Config.h"
VenoPreColours::VenoPreColours (const std::string& processId) : BaseComponent(processId)
{
initSliders();
initButtons();
}
VenoPreColours::~VenoPreColours ()
{
m_scaleSlider.reset();
m_fpsSlider.reset();
for (int i = 0; i < 4; ++i)
{
m_pre[i].reset();
}
}
void VenoPreColours::initSliders ()
{
m_fpsSlider = std::make_shared<Slider>();
m_fpsSlider->setRange(15, 90, 1);
m_fpsSlider->setValue(Config::getInstance()->getFps());
m_fpsSlider->setSliderStyle(Slider::SliderStyle::LinearHorizontal);
m_fpsSlider->setTooltip("FPS");
m_scaleSlider = std::make_shared<Slider>();
m_scaleSlider->setRange(0.5f, 2.5f, 0.1);
m_scaleSlider->setValue(Config::getInstance()->getScale());
m_scaleSlider->setSliderStyle(Slider::SliderStyle::LinearHorizontal);
m_scaleSlider->setTooltip("Scale");
m_scaleSlider->addListener(this);
m_fpsSlider->addListener(this);
addAndMakeVisible(*m_fpsSlider);
addAndMakeVisible(*m_scaleSlider);
}
void VenoPreColours::sliderValueChanged (Slider* slider)
{
if (slider == m_fpsSlider.get())
{
Config::getInstance()->setFps(slider->getValue());
}
if (slider == m_scaleSlider.get())
{
Config::getInstance()->setScale(slider->getValue());
}
}
void VenoPreColours::initButtons ()
{
//4
m_pre.resize(4);
for (int i = 0; i < 4; ++i)
{
m_pre[i] = std::make_unique<TextButton>(m_names[i]);
m_pre[i]->addListener(this);
addAndMakeVisible(m_pre[i].get());
}
}
void VenoPreColours::buttonClicked (Button* button)
{
auto text = button->getButtonText().toStdString();
Config::getInstance()->getCurrentTheme()->setDefault(text);
}
void VenoPreColours::resized ()
{
auto bounds = Rectangle<int>();
bounds.setBounds(0,0,getWidth(), getHeight()-100);
auto bWidth = (getWidth()-80) / 4;
for (int i = 0; i < 4 ; ++i)
{
m_pre[i]->setBounds((bWidth * i) + 40, 110, bWidth, 50);
}
// set slider and button position
m_fpsSlider->setBounds(20, 0, getWidth()-40, 50);
m_scaleSlider->setBounds(20, 50, getWidth()-40, 50);
}

View file

@ -0,0 +1,30 @@
//
// Created by versustune on 14.06.20.
//
#ifndef VENO_VENOPRECOLOURS_H
#define VENO_VENOPRECOLOURS_H
#include "JuceHeader.h"
#include "../../Components/BaseComponent.h"
class VenoPreColours : public BaseComponent, public Slider::Listener, Button::Listener
{
public:
VenoPreColours (const std::string& processId);
~VenoPreColours();
void initSliders();
void initButtons();
void sliderValueChanged (Slider* slider) override;
void resized () override;
private:
void buttonClicked (Button* button) override;
protected:
std::shared_ptr<Slider> m_fpsSlider;
std::shared_ptr<Slider> m_scaleSlider;
std::vector<std::unique_ptr<TextButton>> m_pre;
std::string m_names[4]{
"LED", "Blood", "Orange Dream", "Ocean"
};
};
#endif //VENO_VENOPRECOLOURS_H

Some files were not shown because too many files have changed in this diff Show more