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

View file

@ -3,6 +3,9 @@
#include "Veno/Core/Config.h" #include "Veno/Core/Config.h"
#include "Veno/Utils/Logger.h" #include "Veno/Utils/Logger.h"
#include "Veno/Fonts/Fonts.h" #include "Veno/Fonts/Fonts.h"
#include "Veno/Utils.h"
#define SIDEBAR_WIDTH 300
VenoAudioProcessorEditor::VenoAudioProcessorEditor (VenoAudioProcessor& p) VenoAudioProcessorEditor::VenoAudioProcessorEditor (VenoAudioProcessor& p)
: AudioProcessorEditor(&p), processor(p) : AudioProcessorEditor(&p), processor(p)
@ -10,29 +13,33 @@ VenoAudioProcessorEditor::VenoAudioProcessorEditor (VenoAudioProcessor& p)
m_id = p.m_id; m_id = p.m_id;
Config::getInstance()->registerEditor(this, m_id); Config::getInstance()->registerEditor(this, m_id);
LookAndFeel::setDefaultLookAndFeel(m_look); LookAndFeel::setDefaultLookAndFeel(m_look);
waveform = std::make_unique<SidebarLCD> (m_id); m_sidebar = std::make_unique<Sidebar>(m_id);
setSize (600, 400); setSize(1200 * Config::getInstance()->getScale(), 700 * Config::getInstance()->getScale());
addAndMakeVisible (*waveform); addAndMakeVisible(*m_sidebar);
} }
VenoAudioProcessorEditor::~VenoAudioProcessorEditor () VenoAudioProcessorEditor::~VenoAudioProcessorEditor ()
{ {
LookAndFeel::setDefaultLookAndFeel(nullptr); LookAndFeel::setDefaultLookAndFeel(nullptr);
waveform.reset (nullptr); m_sidebar.reset(nullptr);
delete m_look; delete m_look;
Config::getInstance()->removeEditor(m_id); Config::getInstance()->removeEditor(m_id);
} }
void VenoAudioProcessorEditor::paint (Graphics& g) void VenoAudioProcessorEditor::paint (Graphics& g)
{ {
auto theme = Config::getInstance()->getCurrentTheme();
g.setFont(*VenoFonts::getNormal()); g.setFont(*VenoFonts::getNormal());
g.fillAll (Colour (0, 0, 0)); g.fillAll(theme->getColour(ThemeColour::bg_two));
g.setColour(theme->getColour(ThemeColour::bg));
g.fillRect(0, 0, VeNo::Utils::getCalculatedWidth(SIDEBAR_WIDTH), getHeight());
g.setColour(theme->getColour(ThemeColour::accent));
} }
void VenoAudioProcessorEditor::resized () void VenoAudioProcessorEditor::resized ()
{ {
if (waveform != nullptr) if (m_sidebar != nullptr)
{ {
waveform->setBounds (0, 0, getWidth (), getHeight ()); m_sidebar->setBounds(0, 0, VeNo::Utils::getCalculatedWidth(SIDEBAR_WIDTH), getHeight());
} }
} }

View file

@ -3,7 +3,7 @@
#include <JuceHeader.h> #include <JuceHeader.h>
#include "PluginProcessor.h" #include "PluginProcessor.h"
#include "Veno/GUI/LookAndFeel/LookHandler.h" #include "Veno/GUI/LookAndFeel/LookHandler.h"
#include "Veno/GUI/Components/LCD/SidebarLCD.h" #include "Veno/GUI/GUIParts/Sidebar/Sidebar.h"
class VenoAudioProcessorEditor : public AudioProcessorEditor class VenoAudioProcessorEditor : public AudioProcessorEditor
{ {
@ -16,6 +16,6 @@ private:
VenoAudioProcessor& processor; VenoAudioProcessor& processor;
std::string m_id = ""; std::string m_id = "";
LookAndFeel_V4* m_look = new LookHandler(); LookAndFeel_V4* m_look = new LookHandler();
std::unique_ptr<SidebarLCD> waveform; std::unique_ptr<Sidebar> m_sidebar;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VenoAudioProcessorEditor) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VenoAudioProcessorEditor)
}; };

View file

@ -3,57 +3,35 @@
#include <JuceHeader.h> #include <JuceHeader.h>
#include "Veno/VenoInstance.h" #include "Veno/VenoInstance.h"
class VenoAudioProcessor : public AudioProcessor { class VenoAudioProcessor : public AudioProcessor
{
public: public:
//============================================================================== //==============================================================================
VenoAudioProcessor (); VenoAudioProcessor ();
~VenoAudioProcessor (); ~VenoAudioProcessor ();
void prepareToPlay (double sampleRate, int samplesPerBlock) override; void prepareToPlay (double sampleRate, int samplesPerBlock) override;
void releaseResources () override; void releaseResources () override;
#ifndef JucePlugin_PreferredChannelConfigurations #ifndef JucePlugin_PreferredChannelConfigurations
bool isBusesLayoutSupported (const BusesLayout& layouts) const override; bool isBusesLayoutSupported (const BusesLayout& layouts) const override;
#endif #endif
void processBlock (AudioBuffer<float>&, MidiBuffer&) override; void processBlock (AudioBuffer<float>&, MidiBuffer&) override;
AudioProcessorEditor* createEditor () override; AudioProcessorEditor* createEditor () override;
bool hasEditor () const override; bool hasEditor () const override;
const String getName () const override; const String getName () const override;
bool acceptsMidi () const override; bool acceptsMidi () const override;
bool producesMidi () const override; bool producesMidi () const override;
bool isMidiEffect () const override; bool isMidiEffect () const override;
double getTailLengthSeconds () const override; double getTailLengthSeconds () const override;
int getNumPrograms () override; int getNumPrograms () override;
int getCurrentProgram () override; int getCurrentProgram () override;
void setCurrentProgram (int index) override; void setCurrentProgram (int index) override;
const String getProgramName (int index) override; const String getProgramName (int index) override;
void changeProgramName (int index, const String& newName) override; void changeProgramName (int index, const String& newName) override;
void getStateInformation (MemoryBlock& destData) override; void getStateInformation (MemoryBlock& destData) override;
void setStateInformation (const void* data, int sizeInBytes) override; void setStateInformation (const void* data, int sizeInBytes) override;
// Variable to communicate with the GUI and the Processor // Variable to communicate with the GUI and the Processor
std::string m_id = Uuid().toString().toStdString(); std::string m_id = Uuid().toString().toStdString();
std::shared_ptr<VenoInstance> instance; std::shared_ptr<VenoInstance> instance;
private: private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VenoAudioProcessor) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VenoAudioProcessor)
}; };

View file

@ -4,6 +4,8 @@
#include "Config.h" #include "Config.h"
#include "../Fonts/Fonts.h" #include "../Fonts/Fonts.h"
#include "../GUI/GUIParts/Sidebar/VenoLogo.h"
#include "../Utils.h"
std::shared_ptr<Config> Config::m_instance = nullptr; std::shared_ptr<Config> Config::m_instance = nullptr;
@ -14,6 +16,7 @@ Config::Config ()
m_theme = std::make_shared<Theme>(m_config); m_theme = std::make_shared<Theme>(m_config);
m_theme->init(); m_theme->init();
m_fps = m_config->getIntValue("waveform_fps", 60); m_fps = m_config->getIntValue("waveform_fps", 60);
startTimer(5000);
} }
void Config::saveAll () void Config::saveAll ()
@ -40,6 +43,7 @@ void Config::initConfig ()
options.folderName = "veno"; options.folderName = "veno";
options.filenameSuffix = "xml"; 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 () std::shared_ptr<Theme> Config::getCurrentTheme ()
@ -47,9 +51,9 @@ std::shared_ptr<Theme> Config::getCurrentTheme ()
return m_theme; return m_theme;
} }
double Config::getScale () double Config::getScale () const
{ {
return 1; return m_scale;
} }
void Config::setColourForIndex (Colour* colour, ThemeColour index) void Config::setColourForIndex (Colour* colour, ThemeColour index)
@ -63,8 +67,13 @@ void Config::setColourForIndex (Colour* colour, ThemeColour index)
Config::~Config () Config::~Config ()
{ {
m_config->save(); m_config->save();
m_config->setNeedsToBeSaved(false);
m_theme.reset(); m_theme.reset();
m_config.reset(); m_config.reset();
m_lookHandler.reset();
stopTimer();
VenoFonts::destroyAll();
VenoLogo::deleteInstance();
} }
//LEAK DETECTOR FIX! //LEAK DETECTOR FIX!
@ -78,7 +87,6 @@ void Config::removeEditor (const std::string& name)
m_editors.erase(name); m_editors.erase(name);
if (m_editors.empty()) if (m_editors.empty())
{ {
VenoFonts::destroyAll ();
m_instance = nullptr; m_instance = nullptr;
} }
} }
@ -100,3 +108,38 @@ int Config::getFps () const
{ {
return m_fps; 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 "../GUI/Theme/Theme.h"
#include <memory> #include <memory>
class Config class Config : public Timer
{ {
private: private:
std::shared_ptr<PropertiesFile> m_config = nullptr; std::shared_ptr<PropertiesFile> m_config = nullptr;
@ -18,14 +18,16 @@ private:
static std::shared_ptr<Config> m_instance; static std::shared_ptr<Config> m_instance;
int m_currentLook = 0; //nah move the bitch logic from current to next int m_currentLook = 0; //nah move the bitch logic from current to next
std::unordered_map<std::string, AudioProcessorEditor*> m_editors; std::unordered_map<std::string, AudioProcessorEditor*> m_editors;
int m_fps = 60; std::shared_ptr<LookHandler> m_lookHandler;
public: public:
int m_fps = 60;
float m_scale = 1.0f;
static std::shared_ptr<Config> getInstance (); static std::shared_ptr<Config> getInstance ();
void saveAll (); void saveAll ();
int getCurrentLook (); int getCurrentLook ();
void setColourForIndex (Colour* colour, ThemeColour index); void setColourForIndex (Colour* colour, ThemeColour index);
std::shared_ptr<Theme> getCurrentTheme (); std::shared_ptr<Theme> getCurrentTheme ();
double getScale (); double getScale () const;
// can be public but doesnt need! // can be public but doesnt need!
Config (); Config ();
~Config (); ~Config ();
@ -33,6 +35,10 @@ public:
void removeEditor (const std::string& name); void removeEditor (const std::string& name);
int getEditorCount (); int getEditorCount ();
int getFps () const; int getFps () const;
void setScale(float value);
void setFps(float value);
void timerCallback () override;
void repaintAll();
protected: protected:
void initConfig (); 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

@ -3,6 +3,7 @@
// //
#include "BaseComponent.h" #include "BaseComponent.h"
#include "../../Utils.h"
#include "../../Fonts/Fonts.h" #include "../../Fonts/Fonts.h"
#include <utility> #include <utility>
@ -21,6 +22,7 @@ void BaseComponent::addLabel (const std::string& label_text, LabelPosition label
m_enableLabel = true; m_enableLabel = true;
m_label = std::make_shared<LabelComponent>(this, label_text); m_label = std::make_shared<LabelComponent>(this, label_text);
m_label->setPosition(labelPosition); m_label->setPosition(labelPosition);
addAndMakeVisible(*m_label);
} }
void BaseComponent::resized () void BaseComponent::resized ()
@ -30,11 +32,12 @@ void BaseComponent::resized ()
LabelPosition position = m_label->getLabelPosition(); LabelPosition position = m_label->getLabelPosition();
if (position == LabelPosition::TOP) 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) 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);
} }
} }
} }

View file

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

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