- save
This commit is contained in:
parent
ac22ea5e75
commit
a27c62f062
49 changed files with 1171 additions and 385 deletions
65
Source/Veno/GUI/Components/Config/VeNoColour.cpp
Normal file
65
Source/Veno/GUI/Components/Config/VeNoColour.cpp
Normal 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);
|
||||
}
|
||||
27
Source/Veno/GUI/Components/Config/VeNoColour.h
Normal file
27
Source/Veno/GUI/Components/Config/VeNoColour.h
Normal 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
|
||||
34
Source/Veno/GUI/Components/Config/VenoConfigButton.cpp
Normal file
34
Source/Veno/GUI/Components/Config/VenoConfigButton.cpp
Normal 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);
|
||||
}
|
||||
21
Source/Veno/GUI/Components/Config/VenoConfigButton.h
Normal file
21
Source/Veno/GUI/Components/Config/VenoConfigButton.h
Normal 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
|
||||
84
Source/Veno/GUI/Components/Config/VenoPreColours.cpp
Normal file
84
Source/Veno/GUI/Components/Config/VenoPreColours.cpp
Normal 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);
|
||||
}
|
||||
30
Source/Veno/GUI/Components/Config/VenoPreColours.h
Normal file
30
Source/Veno/GUI/Components/Config/VenoPreColours.h
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue