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

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