first commit

This commit is contained in:
VersusTune 2020-04-03 13:23:19 +02:00
commit 452c5cabba
20 changed files with 863 additions and 0 deletions

View file

@ -0,0 +1,57 @@
//
// Created by versustune on 22.03.20.
//
#ifndef VENO_AUDIOCONFIG_H
#define VENO_AUDIOCONFIG_H
#include "JuceHeader.h"
/**
* holds SampleRate and other needed sound information's :)
*/
class AudioConfig {
private:
static std::shared_ptr<AudioConfig> instance;
float sampleRate = 44100;
float bufferSize = 512; //maybe we need that... but this will update always!
bool needToReInit = false; //this is to reInit the Oscillators, ADSR and other stuff
public:
static std::shared_ptr<AudioConfig> getInstance() {
if (!instance)
instance = std::make_shared<AudioConfig>();
return instance;
}
float getSampleRate() const {
return sampleRate;
}
void setSampleRate(float _sampleRate) {
if (sampleRate != _sampleRate) {
sampleRate = _sampleRate;
needToReInit = true;
}
}
float getBufferSize() const {
return bufferSize;
}
void setBufferSize(float _bufferSize) {
AudioConfig::bufferSize = _bufferSize;
}
bool isNeedToReInit() const {
return needToReInit;
}
void setNeedToReInit(bool _needToReInit) {
AudioConfig::needToReInit = _needToReInit;
}
protected:
};
#endif //VENO_AUDIOCONFIG_H

View file

@ -0,0 +1,73 @@
//
// Created by versustune on 01.03.20.
//
#include "Config.h"
std::shared_ptr<Config> Config::instance = nullptr;
Config::Config() {
// i want to load the config file here...
initConfig();
theme = std::make_shared<Theme>(config);
theme->init();
}
void Config::saveAll() {
if (config != nullptr) {
config->saveIfNeeded();
}
}
int Config::getCurrentLook() {
if (currentLook > 1) {
currentLook = 0;
}
return currentLook;
}
void Config::initConfig() {
PropertiesFile::Options options;
options.applicationName = "config";
options.folderName = "veno";
options.filenameSuffix = "xml";
config = std::make_unique<PropertiesFile>(options);
}
std::shared_ptr<Theme> Config::getCurrentTheme() {
return theme;
}
double Config::getScale() {
return 0;
}
void Config::setColourForIndex(Colour *colour, ThemeColour index) {
if (theme) {
theme->setColour(index, colour);
}
}
Config::~Config() {
config->save();
theme.reset();
config.reset();
}
//LEAK DETECTOR FIX!
void Config::registerEditor(AudioProcessorEditor *editor, const std::string &name) {
editors[name] = editor;
}
void Config::removeEditor(const std::string &name) {
editors.erase(name);
if (editors.empty()) {
instance = nullptr;
}
}
//for LCD :P let's be a bit funny xD
int Config::getEditorCount() {
editors.size();
}

52
Source/Veno/Core/Config.h Normal file
View file

@ -0,0 +1,52 @@
//
// Created by versustune on 01.03.20.
//
#ifndef VENO_CONFIG_H
#define VENO_CONFIG_H
#include "JuceHeader.h"
#include "../GUI/LookAndFeel/LookHandler.h"
#include "../GUI/Theme/Theme.h"
#include <memory>
class Config {
private:
std::shared_ptr<PropertiesFile> config = nullptr;
std::shared_ptr<Theme> theme = nullptr;
static std::shared_ptr<Config> instance;
int currentLook = 0; //nah move the bitch logic from current to next
std::unordered_map<std::string, AudioProcessorEditor *> editors;
public:
static std::shared_ptr<Config> getInstance() {
if (!instance)
instance = std::make_shared<Config>();
return instance;
}
void saveAll();
int getCurrentLook();
void setColourForIndex(Colour *colour, ThemeColour index);
std::shared_ptr<Theme> getCurrentTheme();
double getScale();
// can be public but doesnt need!
Config();
~Config();
void registerEditor(AudioProcessorEditor *editor, const std::string& name);
void removeEditor(const std::string& name);
int getEditorCount();
protected:
void initConfig();
};
#endif //VENO_CONFIG_H

View file

@ -0,0 +1,5 @@
//
// Created by versustune on 17.03.20.
//
#include "BaseComponent.h"

View file

@ -0,0 +1,25 @@
//
// Created by versustune on 17.03.20.
//
#ifndef VENO_BASECOMPONENT_H
#define VENO_BASECOMPONENT_H
#include "JuceHeader.h"
#include <string>
/**
* this is the base Component of all VeNo Components... it has all important Methods
*/
class BaseComponent : public Component {
private:
std::string prefix;
public:
BaseComponent() = default;
~BaseComponent() = default;
protected:
};
#endif //VENO_BASECOMPONENT_H

View file

@ -0,0 +1,5 @@
//
// Created by versustune on 17.03.20.
//
#include "CrazyLook.h"

View file

@ -0,0 +1,17 @@
//
// Created by versustune on 17.03.20.
//
#ifndef VENO_CRAZYLOOK_H
#define VENO_CRAZYLOOK_H
#include "JuceHeader.h"
class CrazyLook : public LookAndFeel_V4 {
private:
public:
protected:
};
#endif //VENO_CRAZYLOOK_H

View file

@ -0,0 +1,5 @@
//
// Created by versustune on 17.03.20.
//
#include "FlatLook.h"

View file

@ -0,0 +1,17 @@
//
// Created by versustune on 17.03.20.
//
#ifndef VENO_FLATLOOK_H
#define VENO_FLATLOOK_H
#include "JuceHeader.h"
class FlatLook : public LookAndFeel_V4 {
private:
public:
protected:
};
#endif //VENO_FLATLOOK_H

View file

@ -0,0 +1,20 @@
//
// Created by versustune on 17.03.20.
//
#include "LookHandler.h"
#include "../../Core/Config.h"
LookHandler::LookHandler() {
selectLook(Config::getInstance()->getCurrentLook());
}
LookHandler::~LookHandler() {
//delete this shit!
delete feels[0];
delete feels[1];
}
void LookHandler::selectLook(int index) {
currentLook = index;
}

View file

@ -0,0 +1,30 @@
//
// Created by versustune on 17.03.20.
//
#ifndef VENO_LOOKHANDLER_H
#define VENO_LOOKHANDLER_H
#include "JuceHeader.h"
#include "CrazyLook.h"
#include "FlatLook.h"
#include <memory>
/**
* overwrite the basic look and feel based on the selected Look and Feel :)
*/
class LookHandler : public LookAndFeel_V4 {
private:
std::shared_ptr<LookAndFeel_V4> look;
int currentLook = 0;
public:
LookHandler();
~LookHandler();
void selectLook(int index);
protected:
//currently both available themes are CrazyLook <-- (this is a fun one xD) and FlatLook
LookAndFeel_V4 *feels[2] = {new FlatLook(), new CrazyLook()};
};
#endif //VENO_LOOKHANDLER_H

View file

@ -0,0 +1,50 @@
//
// Created by versustune on 01.03.20.
//
#include "Theme.h"
#include "ThemePresets.cpp"
Theme::Theme(std::shared_ptr<PropertiesFile> file) {
configFile = file;
}
Theme::~Theme() {
colours.clear();
configFile.reset();
}
void Theme::setColour(ThemeColour index, Colour *colour) {
auto c = colours[index];
if (c) {
delete c;
colours[index] = colour;
} else {
colours[index] = colour;
}
configFile->setValue(ThemeColourToString(index), colour->toString());
configFile->save();
}
void Theme::init() {
setLEDTheme(this);
getColourFromConfig(ThemeColour::bg);
getColourFromConfig(ThemeColour::bg_two);
getColourFromConfig(ThemeColour::accent);
getColourFromConfig(ThemeColour::accent_two);
getColourFromConfig(ThemeColour::warning);
getColourFromConfig(ThemeColour::clip);
getColourFromConfig(ThemeColour::lcd_bg);
getColourFromConfig(ThemeColour::lcd);
}
void Theme::getColourFromConfig(ThemeColour index) {
std::string key = ThemeColourToString(index);
if (configFile->containsKey(key)) {
auto baseColour = Colour::fromString(configFile->getValue(key));
auto *colour = new Colour(baseColour.getRed(), baseColour.getGreen(), baseColour.getBlue());
setColour(index, colour);
}
}

View file

@ -0,0 +1,30 @@
//
// Created by versustune on 01.03.20.
//
#ifndef VENO_THEME_H
#define VENO_THEME_H
#include "JuceHeader.h"
#include <vector>
enum class ThemeColour {
bg = 0, bg_two, accent, accent_two, warning, clip, lcd_bg, lcd
};
class Theme {
private:
public:
Theme(std::shared_ptr<PropertiesFile> file);
~Theme();
void setColour(ThemeColour index, Colour *colour);
void init();
void getColourFromConfig(ThemeColour index);
protected:
std::map<ThemeColour, Colour*> colours;
std::shared_ptr<PropertiesFile> configFile;
};
#endif //VENO_THEME_H

View file

@ -0,0 +1,37 @@
#include "Theme.h"
/*
* this file holds function that read some presets
* in the current Theme class
* so we doesn't have lot's of classes that only save some hex codes... and make the coding harder
* also good on this is that the user can slightly change the preset theme and doesn't have to make all of them himself
*
* maybe i want a double look and feel... that's make it easier to implement different knob styles, slider styles and co
*/
void setLEDTheme(Theme *theme) {
theme->setColour(ThemeColour::bg, new Colour(41, 47, 54));
theme->setColour(ThemeColour::bg_two, new Colour(217, 217, 217));
theme->setColour(ThemeColour::accent, new Colour(169, 208, 142));
theme->setColour(ThemeColour::accent_two, new Colour(139, 171, 117));
theme->setColour(ThemeColour::clip, new Colour(255, 23, 68));
theme->setColour(ThemeColour::warning, new Colour(255, 143, 0));
theme->setColour(ThemeColour::lcd_bg, new Colour(21, 21, 21));
theme->setColour(ThemeColour::lcd, new Colour(169, 208, 142));
}
std::string ThemeColourToString(ThemeColour index) {
switch (index)
{
case ThemeColour::bg: return "colour_bg";
case ThemeColour::bg_two: return "colour_bg_two";
case ThemeColour::accent: return "colour_accent";
case ThemeColour::accent_two: return "colour_accent_two";
case ThemeColour::clip: return "colour_clip";
case ThemeColour::warning: return "colour_warning";
case ThemeColour::lcd_bg: return "colour_lcd_bg";
case ThemeColour::lcd: return "colour_lcd";
default: return "";
}
}