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

@ -0,0 +1,77 @@
//
// Created by versustune on 14.06.20.
//
#include "ConfigComponent.h"
#include <utility>
ConfigComponent::ConfigComponent (std::string pid)
{
m_pid = std::move(pid);
m_colors.resize(8);
auto theme = Config::getInstance()->getCurrentTheme();
for (int i = 0; i < 8; i++)
{
m_colors[i] = std::make_unique<VeNoColour>(pid, getColorForId(i));
m_colors[i]->setName(m_names[i]);
addAndMakeVisible(m_colors[i].get());
}
m_preColours = std::make_unique<VenoPreColours>(pid);
addAndMakeVisible(*m_preColours);
flexBox.flexDirection = FlexBox::Direction::row;
flexBox.justifyContent = FlexBox::JustifyContent::flexStart;
flexBox.flexWrap = FlexBox::Wrap::wrap;
auto w = 200;
auto h = 100;
for (auto& color : m_colors)
{
auto item = FlexItem(w, h, *color);
item.margin = FlexItem::Margin(5, 5, 5, 5);
flexBox.items.add(item);
}
}
ConfigComponent::~ConfigComponent ()
{
for (auto& color : m_colors)
{
color.reset();
}
m_colors.clear();
}
ThemeColour ConfigComponent::getColorForId (int id)
{
switch (id)
{
default:
return ThemeColour::bg;
case 1:
return ThemeColour::bg_two;
case 2:
return ThemeColour::accent;
case 3:
return ThemeColour::accent_two;
case 4:
return ThemeColour::warning;
case 5:
return ThemeColour::clip;
case 6:
return ThemeColour::lcd_bg;
case 7:
return ThemeColour::lcd;
}
}
void ConfigComponent::paint (Graphics& g)
{
g.fillAll(Colours::black);
}
void ConfigComponent::resized ()
{
auto bounds = Rectangle<int>();
bounds.setBounds(0,0,getWidth(), getHeight()-200);
flexBox.performLayout(bounds);
m_preColours->setBounds(0, getHeight() - 200, getWidth(), 200);
}

View file

@ -0,0 +1,30 @@
//
// Created by versustune on 14.06.20.
//
#ifndef VENO_CONFIGCOMPONENT_H
#define VENO_CONFIGCOMPONENT_H
#include "JuceHeader.h"
#include "../../../Core/Config.h"
#include "../../Components/Config/VeNoColour.h"
#include "../../Components/Config/VenoPreColours.h"
class ConfigComponent : public Component
{
public:
explicit ConfigComponent(std::string pid);
~ConfigComponent() override;
void paint (Graphics& g) override;
void resized () override;
protected:
static ThemeColour getColorForId(int id);
std::string m_pid;
std::string m_names[8]{
"Background", "BackgroundTwo", "Accent", "Accent Two", "Warning", "Clip", "LCD Background", "LCD"
};
std::vector<std::unique_ptr<VeNoColour>> m_colors;
std::unique_ptr<VenoPreColours> m_preColours;
FlexBox flexBox;
};
#endif //VENO_CONFIGCOMPONENT_H

View file

@ -0,0 +1,49 @@
//
// Created by versustune on 14.06.20.
//
#include "VenoConfigScreen.h"
#include "../../../VenoInstance.h"
VenoConfigScreen::VenoConfigScreen (const std::string& pid) : DocumentWindow("VeNo Config", Colours::black,
DocumentWindow::closeButton, true)
{
m_pid = pid;
auto w = 840;
auto h = 800;
component = std::make_shared<ConfigComponent>(pid);
component->setSize(w, h);
m_lookHandler = std::make_unique<LookHandler>();
component->setLookAndFeel(m_lookHandler->getLook());
centreWithSize(w, h);
setAlwaysOnTop(true);
setContentOwned(component.get(), false);
setResizable(false, false);
setUsingNativeTitleBar(true);
setVisible(true);
}
VenoConfigScreen::~VenoConfigScreen ()
{
component->setLookAndFeel(nullptr);
m_lookHandler.reset();
component.reset();
}
void VenoConfigScreen::closeButtonPressed ()
{
auto state = VenoInstance::getInstance(m_pid)->state;
if (state != nullptr && state->configScreen != nullptr)
{
delete state->configScreen;
state->configScreen = nullptr;
}
}
void VenoConfigScreen::paint (Graphics& graphics)
{
}
void VenoConfigScreen::resized ()
{
}

View file

@ -0,0 +1,28 @@
//
// Created by versustune on 14.06.20.
//
#ifndef VENO_VENOCONFIGSCREEN_H
#define VENO_VENOCONFIGSCREEN_H
#include "JuceHeader.h"
#include "../../../Core/Config.h"
#include "../../Components/Config/VeNoColour.h"
#include "ConfigComponent.h"
class VenoConfigScreen : public DocumentWindow
{
public:
explicit VenoConfigScreen (const std::string& pid);
~VenoConfigScreen () override;
void closeButtonPressed () override;
void paint (Graphics& graphics) override;
void resized () override;
private:
std::string m_pid;
std::shared_ptr<ConfigComponent> component;
std::unique_ptr<LookHandler> m_lookHandler;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VenoConfigScreen)
};
#endif //VENO_VENOCONFIGSCREEN_H

View file

@ -3,3 +3,48 @@
//
#include "Sidebar.h"
#include "VenoLogo.h"
#include "../../../Utils.h"
Sidebar::Sidebar (const std::string& processId) : BaseComponent(processId)
{
m_lcd = std::make_unique<SidebarLCD>(processId);
m_configButton = std::make_unique<VenoConfigButton>(processId);
addAndMakeVisible(*m_lcd);
addAndMakeVisible(*m_configButton);
}
Sidebar::~Sidebar ()
{
m_lcd.reset(nullptr);
m_configButton.reset(nullptr);
}
void Sidebar::resized ()
{
if (m_lcd != nullptr)
{
m_lcd->setBounds(0, (getWidth() / 5) + 30, getWidth(), VeNo::Utils::getCalculatedHeight(175));
}
if (m_configButton != nullptr)
{
auto height = VeNo::Utils::getCalculatedHeight(30);
auto margin = VeNo::Utils::getCalculatedWidth(10);
m_configButton->setBounds(margin, getHeight()-height-margin, (getWidth()/2)-(margin*2), height);
}
}
void Sidebar::paint (Graphics& g)
{
auto logo = VenoLogo::getInstance()->getLogo();
if (logo.isValid())
{
float height = getWidth() / 5;
g.drawImage(logo, 0, 15, getWidth(), height, 0, 0, 500, 100);
}
else
{
g.setFont(getWidth() / 4);
g.drawSingleLineText("VeNo", 0, 25);
}
}

View file

@ -7,13 +7,21 @@
#include "JuceHeader.h"
#include "../../Components/BaseComponent.h"
#include "../../Components/LCD/SidebarLCD.h"
#include "SidebarMixer.h"
#include "../../Components/Config/VenoConfigButton.h"
class Sidebar : public BaseComponent
{
private:
public:
Sidebar ();
~Sidebar ();
Sidebar (const std::string& processId);
~Sidebar () override;
void resized () override;
void paint (Graphics& g) override;
protected:
std::unique_ptr<SidebarLCD> m_lcd;
std::unique_ptr<SidebarMixer> m_mixer;
std::unique_ptr<VenoConfigButton> m_configButton;
};
#endif //VENO_SIDEBAR_H

View file

@ -0,0 +1,36 @@
//
// Created by versustune on 14.06.20.
//
#include "VenoLogo.h"
VenoLogo* VenoLogo::instance = nullptr;
VenoLogo* VenoLogo::getInstance ()
{
if (instance == nullptr)
{
instance = new VenoLogo();
}
return instance;
}
VenoLogo::VenoLogo ()
{
MemoryOutputStream mo;
auto result = Base64::convertFromBase64(mo, base64logo);
if (result)
{
realLogo = juce::PNGImageFormat::loadFrom(mo.getData(), mo.getDataSize());
}
}
Image VenoLogo::getLogo ()
{
return getInstance()->realLogo;
}
void VenoLogo::deleteInstance ()
{
delete instance;
}

File diff suppressed because one or more lines are too long