- reformat to JUCE-Guidelines
- added Matrix => half working ;)
This commit is contained in:
parent
26a2935e1c
commit
ac22ea5e75
58 changed files with 1220 additions and 799 deletions
|
|
@ -4,40 +4,49 @@
|
|||
|
||||
#include "BaseComponent.h"
|
||||
#include "../../Fonts/Fonts.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
BaseComponent::BaseComponent(const std::string& processId) {
|
||||
BaseComponent::BaseComponent (const std::string& processId)
|
||||
{
|
||||
m_processId = processId;
|
||||
}
|
||||
|
||||
BaseComponent::~BaseComponent() {
|
||||
m_label.reset();
|
||||
BaseComponent::~BaseComponent ()
|
||||
{
|
||||
m_label.reset ();
|
||||
}
|
||||
|
||||
void BaseComponent::addLabel(const std::string &label_text, LabelPosition labelPosition) {
|
||||
void BaseComponent::addLabel (const std::string& label_text, LabelPosition labelPosition)
|
||||
{
|
||||
m_enableLabel = true;
|
||||
m_label = std::make_shared<LabelComponent>(this, label_text);
|
||||
m_label->setPosition(labelPosition);
|
||||
m_label = std::make_shared<LabelComponent> (this, label_text);
|
||||
m_label->setPosition (labelPosition);
|
||||
}
|
||||
|
||||
void BaseComponent::resized() {
|
||||
if (m_enableLabel && m_label != nullptr) {
|
||||
LabelPosition position = m_label->getLabelPosition();
|
||||
if (position == LabelPosition::TOP) {
|
||||
m_label->setBounds(0, 0, getWidth(), 15);
|
||||
} else if (position == LabelPosition::BOTTOM) {
|
||||
m_label->setBounds(0, getHeight() - 20, getWidth(), 15);
|
||||
void BaseComponent::resized ()
|
||||
{
|
||||
if (m_enableLabel && m_label != nullptr)
|
||||
{
|
||||
LabelPosition position = m_label->getLabelPosition ();
|
||||
if (position == LabelPosition::TOP)
|
||||
{
|
||||
m_label->setBounds (0, 0, getWidth (), 15);
|
||||
}
|
||||
else if (position == LabelPosition::BOTTOM)
|
||||
{
|
||||
m_label->setBounds (0, getHeight () - 20, getWidth (), 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BaseComponent::paint(Graphics &g) {
|
||||
g.setFont(VenoFonts::getNormal());
|
||||
void BaseComponent::paint (Graphics& g)
|
||||
{
|
||||
g.setFont (*VenoFonts::getNormal ());
|
||||
}
|
||||
|
||||
void BaseComponent::setParameter(std::string name, std::string group) {
|
||||
m_name = std::move(name);
|
||||
m_group = std::move(group);
|
||||
setName(m_name);
|
||||
void BaseComponent::setParameter (std::string name, std::string group)
|
||||
{
|
||||
m_name = std::move (name);
|
||||
m_group = std::move (group);
|
||||
setName (m_name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,22 +13,21 @@
|
|||
/**
|
||||
* this is the base Component of all VeNo Components... it has all important Methods
|
||||
*/
|
||||
class BaseComponent : public Component {
|
||||
class BaseComponent : public Component
|
||||
{
|
||||
private:
|
||||
std::string m_group;
|
||||
std::string m_name;
|
||||
bool m_enableLabel = false;
|
||||
std::shared_ptr<LabelComponent> m_label;
|
||||
public:
|
||||
explicit BaseComponent(const std::string& processId);
|
||||
~BaseComponent() override;
|
||||
void addLabel(const std::string& label, LabelPosition labelPosition);
|
||||
void setParameter(std::string name, std::string group);
|
||||
void resized() override;
|
||||
void paint(Graphics &g) override;
|
||||
explicit BaseComponent (const std::string& processId);
|
||||
~BaseComponent () override;
|
||||
void addLabel (const std::string& label, LabelPosition labelPosition);
|
||||
void setParameter (std::string name, std::string group);
|
||||
void resized () override;
|
||||
void paint (Graphics& g) override;
|
||||
protected:
|
||||
std::string m_processId;
|
||||
};
|
||||
|
||||
|
||||
#endif //VENO_BASECOMPONENT_H
|
||||
|
|
|
|||
|
|
@ -7,49 +7,56 @@
|
|||
#include "../../../Core/Config.h"
|
||||
#include "../../../Fonts/Fonts.h"
|
||||
|
||||
SidebarLCD::SidebarLCD(const std::string &process_id) : BaseComponent(process_id) {
|
||||
waveform = std::make_unique<Waveforms>(process_id);
|
||||
addAndMakeVisible(*waveform);
|
||||
SidebarLCD::SidebarLCD (const std::string& process_id) : BaseComponent (process_id)
|
||||
{
|
||||
waveform = std::make_unique<Waveforms> (process_id);
|
||||
addAndMakeVisible (*waveform);
|
||||
}
|
||||
|
||||
SidebarLCD::~SidebarLCD() {
|
||||
waveform.reset(nullptr);
|
||||
SidebarLCD::~SidebarLCD ()
|
||||
{
|
||||
waveform.reset (nullptr);
|
||||
}
|
||||
|
||||
void SidebarLCD::drawHeadline(Graphics &g) {
|
||||
float fontSize = VeNo::Utils::setFontSize(12.0f, g) + 2;
|
||||
void SidebarLCD::drawHeadline (Graphics& g)
|
||||
{
|
||||
float fontSize = VeNo::Utils::setFontSize (12.0f, g) + 2;
|
||||
int line = m_innerY + fontSize + 2;
|
||||
g.drawText(">>> VeNo <<<", 0, m_innerY, getWidth() - m_width, fontSize,
|
||||
Justification::centred,
|
||||
true);
|
||||
g.drawLine(0, line, getWidth(), line);
|
||||
g.drawText (">>> VeNo <<<", 0, m_innerY, getWidth () - m_width, fontSize,
|
||||
Justification::centred,
|
||||
true);
|
||||
g.drawLine (0, line, getWidth (), line);
|
||||
}
|
||||
|
||||
void SidebarLCD::drawFooter(Graphics &g) {
|
||||
float fontSize = VeNo::Utils::setFontSize(8.0f, g) + 4;
|
||||
void SidebarLCD::drawFooter (Graphics& g)
|
||||
{
|
||||
float fontSize = VeNo::Utils::setFontSize (8.0f, g) + 4;
|
||||
int space = m_innerY + fontSize;
|
||||
int line = getHeight() - space;
|
||||
g.drawText("by VersusTuneZ", 0, line, getWidth() - m_width, fontSize,
|
||||
Justification::horizontallyCentred,
|
||||
true);
|
||||
g.drawLine(0, line - 4, getWidth(), line - 4);
|
||||
int line = getHeight () - space;
|
||||
g.drawText ("by VersusTuneZ", 0, line, getWidth () - m_width, fontSize,
|
||||
Justification::horizontallyCentred,
|
||||
true);
|
||||
g.drawLine (0, line - 4, getWidth (), line - 4);
|
||||
}
|
||||
|
||||
void SidebarLCD::resized() {
|
||||
float topSpace = (12 * Config::getInstance()->getScale()) + 4 + m_innerY;
|
||||
if (waveform != nullptr) {
|
||||
waveform->setBounds(0, topSpace*2, getWidth(), getHeight() - (topSpace*4));
|
||||
void SidebarLCD::resized ()
|
||||
{
|
||||
float topSpace = (12 * Config::getInstance ()->getScale ()) + 4 + m_innerY;
|
||||
if (waveform != nullptr)
|
||||
{
|
||||
waveform->setBounds (0, topSpace * 2, getWidth (), getHeight () - (topSpace * 4));
|
||||
}
|
||||
}
|
||||
|
||||
void SidebarLCD::paint(Graphics &g) {
|
||||
std::shared_ptr<Theme> theme = Config::getInstance()->getCurrentTheme();
|
||||
auto colour = theme->getColour(ThemeColour::lcd_bg);
|
||||
g.fillAll(colour);
|
||||
void SidebarLCD::paint (Graphics& g)
|
||||
{
|
||||
std::shared_ptr<Theme> theme = Config::getInstance ()->getCurrentTheme ();
|
||||
auto colour = theme->getColour (ThemeColour::lcd_bg);
|
||||
g.fillAll (colour);
|
||||
// background
|
||||
auto accent = theme->getColour(ThemeColour::lcd);
|
||||
g.setColour(accent);
|
||||
g.setFont(VenoFonts::getLCD());
|
||||
drawHeadline(g);
|
||||
drawFooter(g);
|
||||
auto accent = theme->getColour (ThemeColour::lcd);
|
||||
g.setColour (accent);
|
||||
g.setFont (*VenoFonts::getLCD ());
|
||||
drawHeadline (g);
|
||||
drawFooter (g);
|
||||
}
|
||||
|
|
@ -9,24 +9,20 @@
|
|||
#include "../BaseComponent.h"
|
||||
#include "Waveforms.h"
|
||||
|
||||
class SidebarLCD : public BaseComponent {
|
||||
class SidebarLCD : public BaseComponent
|
||||
{
|
||||
private:
|
||||
int m_innerX = 5;
|
||||
int m_innerY = 5;
|
||||
int m_width = m_innerX * 2;
|
||||
public:
|
||||
explicit SidebarLCD(const std::string &process_id);
|
||||
~SidebarLCD();
|
||||
|
||||
void resized() override;
|
||||
void paint(Graphics &g) override;
|
||||
|
||||
explicit SidebarLCD (const std::string& process_id);
|
||||
~SidebarLCD ();
|
||||
void resized () override;
|
||||
void paint (Graphics& g) override;
|
||||
protected:
|
||||
void drawHeadline(Graphics &g);
|
||||
void drawFooter(Graphics &g);
|
||||
|
||||
void drawHeadline (Graphics& g);
|
||||
void drawFooter (Graphics& g);
|
||||
std::unique_ptr<Waveforms> waveform;
|
||||
};
|
||||
|
||||
|
||||
#endif //VENO_SIDEBARLCD_H
|
||||
|
|
|
|||
|
|
@ -9,227 +9,270 @@
|
|||
#include "../../../VenoInstance.h"
|
||||
#include "../../../Fonts/Fonts.h"
|
||||
|
||||
Waveforms::Waveforms(const std::string &processId) : BaseComponent(processId) {
|
||||
m_context.setOpenGLVersionRequired(OpenGLContext::OpenGLVersion::openGL3_2);
|
||||
m_context.setRenderer(this);
|
||||
m_context.setContinuousRepainting(false);
|
||||
m_context.setComponentPaintingEnabled(true);
|
||||
m_context.attachTo(*this);
|
||||
auto fps = Config::getInstance()->getFps();
|
||||
startTimerHz(Config::getInstance()->getFps());
|
||||
std::srand(unsigned(time(nullptr)));
|
||||
pickRandomText = (std::rand() % RANDOM_TEXT_COUNT);
|
||||
Waveforms::Waveforms (const std::string& processId) : BaseComponent (processId)
|
||||
{
|
||||
m_context.setOpenGLVersionRequired (OpenGLContext::OpenGLVersion::openGL3_2);
|
||||
m_context.setRenderer (this);
|
||||
m_context.setContinuousRepainting (false);
|
||||
m_context.setComponentPaintingEnabled (true);
|
||||
m_context.attachTo (*this);
|
||||
auto fps = Config::getInstance ()->getFps ();
|
||||
startTimerHz (Config::getInstance ()->getFps ());
|
||||
std::srand (unsigned (time (nullptr)));
|
||||
pickRandomText = (std::rand () % RANDOM_TEXT_COUNT);
|
||||
m_ticks = 0;
|
||||
// is something that
|
||||
m_time_needed = roundToInt(4000 / (1000 / fps));
|
||||
m_time_needed_startup = roundToInt(1000 / (1000 / fps));
|
||||
m_time_needed = roundToInt (4000 / (1000 / fps));
|
||||
m_time_needed_startup = roundToInt (1000 / (1000 / fps));
|
||||
}
|
||||
|
||||
Waveforms::~Waveforms() {
|
||||
stopTimer();
|
||||
shaderProgram.reset();
|
||||
m_context.detach();
|
||||
Waveforms::~Waveforms ()
|
||||
{
|
||||
stopTimer ();
|
||||
shaderProgram.reset ();
|
||||
m_context.detach ();
|
||||
}
|
||||
|
||||
void Waveforms::newOpenGLContextCreated() {
|
||||
compileOpenGLShaderProgram();
|
||||
void Waveforms::newOpenGLContextCreated ()
|
||||
{
|
||||
compileOpenGLShaderProgram ();
|
||||
}
|
||||
|
||||
void Waveforms::openGLContextClosing() {
|
||||
void Waveforms::openGLContextClosing ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Waveforms::renderOpenGL() {
|
||||
if (!isShowing() || shaderProgram == nullptr || !shaderProgram->getLastError().isEmpty()) {
|
||||
void Waveforms::renderOpenGL ()
|
||||
{
|
||||
if (!isShowing () || shaderProgram == nullptr || !shaderProgram->getLastError ().isEmpty ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto theme = Config::getInstance()->getCurrentTheme();
|
||||
if (theme == nullptr) {
|
||||
auto theme = Config::getInstance ()->getCurrentTheme ();
|
||||
if (theme == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
glViewport(0, 0, getWidth(), getHeight());
|
||||
OpenGLHelpers::clear(theme->getColour(ThemeColour::lcd_bg));
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
shaderProgram->use();
|
||||
auto color = theme->getColour(ThemeColour::lcd);
|
||||
shaderProgram->setUniform("color", color.getFloatRed(), color.getFloatGreen(), color.getFloatBlue(),
|
||||
color.getFloatAlpha());
|
||||
if (m_isWelcome || m_isStarting || m_isChangingData) {
|
||||
glViewport (0, 0, getWidth (), getHeight ());
|
||||
OpenGLHelpers::clear (theme->getColour (ThemeColour::lcd_bg));
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
shaderProgram->use ();
|
||||
auto color = theme->getColour (ThemeColour::lcd);
|
||||
shaderProgram->setUniform ("color", color.getFloatRed (), color.getFloatGreen (), color.getFloatBlue (),
|
||||
color.getFloatAlpha ());
|
||||
if (m_isWelcome || m_isStarting || m_isChangingData)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (m_mode) {
|
||||
switch (m_mode)
|
||||
{
|
||||
case 1:
|
||||
drawAudioOutput();
|
||||
drawAudioOutput ();
|
||||
break;
|
||||
case 2:
|
||||
drawWaveTable();
|
||||
drawWaveTable ();
|
||||
break;
|
||||
case 3:
|
||||
drawSpectrum();
|
||||
drawSpectrum ();
|
||||
break;
|
||||
default:
|
||||
drawPeakMeter();
|
||||
drawPeakMeter ();
|
||||
}
|
||||
}
|
||||
|
||||
void Waveforms::handleAsyncUpdate() {
|
||||
void Waveforms::handleAsyncUpdate ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Waveforms::compileOpenGLShaderProgram() {
|
||||
void Waveforms::compileOpenGLShaderProgram ()
|
||||
{
|
||||
std::unique_ptr<OpenGLShaderProgram> shaderProgramAttempt
|
||||
= std::make_unique<OpenGLShaderProgram>(m_context);
|
||||
|
||||
if (shaderProgramAttempt->addVertexShader({BinaryData::WaveForm_vertex_glsl})
|
||||
&& shaderProgramAttempt->addFragmentShader({BinaryData::WaveForm_fragment_glsl})
|
||||
&& shaderProgramAttempt->link()) {
|
||||
shaderProgram = std::move(shaderProgramAttempt);
|
||||
= std::make_unique<OpenGLShaderProgram> (m_context);
|
||||
if (shaderProgramAttempt->addVertexShader ({BinaryData::WaveForm_vertex_glsl})
|
||||
&& shaderProgramAttempt->addFragmentShader ({BinaryData::WaveForm_fragment_glsl})
|
||||
&& shaderProgramAttempt->link ())
|
||||
{
|
||||
shaderProgram = std::move (shaderProgramAttempt);
|
||||
}
|
||||
}
|
||||
|
||||
void Waveforms::mouseDown(const MouseEvent &e) {
|
||||
if (!m_enableModeToggle) {
|
||||
void Waveforms::mouseDown (const MouseEvent& e)
|
||||
{
|
||||
if (!m_enableModeToggle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_mode++;
|
||||
if (m_mode > 3) {
|
||||
if (m_mode > 3)
|
||||
{
|
||||
m_mode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Waveforms::mouseDrag(const MouseEvent &e) {
|
||||
void Waveforms::mouseDrag (const MouseEvent& e)
|
||||
{
|
||||
//do nothing... you faggot
|
||||
}
|
||||
|
||||
void Waveforms::timerCallback() {
|
||||
if (m_isWelcome || m_isStarting || m_isChangingData || needToClear) {
|
||||
repaint();
|
||||
} else {
|
||||
if (m_context.isAttached()) {
|
||||
m_context.triggerRepaint();
|
||||
void Waveforms::timerCallback ()
|
||||
{
|
||||
if (m_isWelcome || m_isStarting || m_isChangingData || needToClear)
|
||||
{
|
||||
repaint ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_context.isAttached ())
|
||||
{
|
||||
m_context.triggerRepaint ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Waveforms::drawWaveTable() {
|
||||
void Waveforms::drawWaveTable ()
|
||||
{
|
||||
// this will draw the current selected oscillator :D
|
||||
}
|
||||
|
||||
void Waveforms::drawAudioOutput() {
|
||||
void Waveforms::drawAudioOutput ()
|
||||
{
|
||||
// draw audio from the oscillators
|
||||
auto instance = VenoInstance::getInstance(BaseComponent::m_processId);
|
||||
auto buffer = instance->audioBuffer->getBuffer();
|
||||
glBegin(GL_LINE_STRIP);
|
||||
auto instance = VenoInstance::getInstance (BaseComponent::m_processId);
|
||||
auto buffer = instance->audioBuffer->getBuffer ();
|
||||
glBegin (GL_LINE_STRIP);
|
||||
float posX = -1;
|
||||
float inc = 2.0f / buffer.size();
|
||||
for (float i : buffer) {
|
||||
glVertex2f(posX, i);
|
||||
float inc = 2.0f / buffer.size ();
|
||||
for (float i : buffer)
|
||||
{
|
||||
glVertex2f (posX, i);
|
||||
posX += inc;
|
||||
}
|
||||
glEnd();
|
||||
glEnd ();
|
||||
}
|
||||
|
||||
void Waveforms::drawPeakMeter() {
|
||||
auto theme = Config::getInstance()->getCurrentTheme();
|
||||
if (theme == nullptr) {
|
||||
void Waveforms::drawPeakMeter ()
|
||||
{
|
||||
auto theme = Config::getInstance ()->getCurrentTheme ();
|
||||
if (theme == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto instance = VenoInstance::getInstance(BaseComponent::m_processId);
|
||||
instance->audioBuffer->calcPeak();
|
||||
auto instance = VenoInstance::getInstance (BaseComponent::m_processId);
|
||||
instance->audioBuffer->calcPeak ();
|
||||
// draw peak signal
|
||||
auto leftChannel = jmap(Decibels::gainToDecibels(instance->audioBuffer->leftPeak, -80.0f), -80.0f, 6.0f, -1.0f,
|
||||
1.0f);
|
||||
selectColourByPeak(leftChannel);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2f(-0.9f, leftChannel);
|
||||
glVertex2f(-0.9f, -1.0f);
|
||||
glVertex2f(-0.01f, -1.0f);
|
||||
glVertex2f(-0.9f, leftChannel);
|
||||
glVertex2f(-0.01f, leftChannel);
|
||||
glVertex2f(-0.01f, -1.0f);
|
||||
glEnd();
|
||||
auto rightChannel = jmap(Decibels::gainToDecibels(instance->audioBuffer->rightPeak, -80.0f), -80.0f, 6.0f, -1.0f,
|
||||
auto leftChannel = jmap (Decibels::gainToDecibels (instance->audioBuffer->leftPeak, -80.0f), -80.0f, 6.0f, -1.0f,
|
||||
1.0f);
|
||||
selectColourByPeak(rightChannel);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2f(0.9f, rightChannel);
|
||||
glVertex2f(0.9f, -1.0f);
|
||||
glVertex2f(0.01f, -1.0f);
|
||||
glVertex2f(0.9f, rightChannel);
|
||||
glVertex2f(0.01f, rightChannel);
|
||||
glVertex2f(0.01f, -1.0f);
|
||||
glEnd();
|
||||
selectColourByPeak (leftChannel);
|
||||
glBegin (GL_TRIANGLES);
|
||||
glVertex2f (-0.9f, leftChannel);
|
||||
glVertex2f (-0.9f, -1.0f);
|
||||
glVertex2f (-0.01f, -1.0f);
|
||||
glVertex2f (-0.9f, leftChannel);
|
||||
glVertex2f (-0.01f, leftChannel);
|
||||
glVertex2f (-0.01f, -1.0f);
|
||||
glEnd ();
|
||||
auto rightChannel = jmap (Decibels::gainToDecibels (instance->audioBuffer->rightPeak, -80.0f), -80.0f, 6.0f, -1.0f,
|
||||
1.0f);
|
||||
selectColourByPeak (rightChannel);
|
||||
glBegin (GL_TRIANGLES);
|
||||
glVertex2f (0.9f, rightChannel);
|
||||
glVertex2f (0.9f, -1.0f);
|
||||
glVertex2f (0.01f, -1.0f);
|
||||
glVertex2f (0.9f, rightChannel);
|
||||
glVertex2f (0.01f, rightChannel);
|
||||
glVertex2f (0.01f, -1.0f);
|
||||
glEnd ();
|
||||
}
|
||||
|
||||
void Waveforms::paint(Graphics &g) {
|
||||
std::shared_ptr<Theme> theme = Config::getInstance()->getCurrentTheme();
|
||||
auto accent = theme->getColour(ThemeColour::lcd);
|
||||
g.setColour(accent);
|
||||
g.setFont(VenoFonts::getLCD());
|
||||
VeNo::Utils::setFontSize(16.0f, g);
|
||||
if (m_isWelcome) {
|
||||
drawWelcome(g, getWidth(), getHeight(), 0, 0);
|
||||
void Waveforms::paint (Graphics& g)
|
||||
{
|
||||
std::shared_ptr<Theme> theme = Config::getInstance ()->getCurrentTheme ();
|
||||
auto accent = theme->getColour (ThemeColour::lcd);
|
||||
g.setColour (accent);
|
||||
g.setFont (*VenoFonts::getLCD ());
|
||||
VeNo::Utils::setFontSize (16.0f, g);
|
||||
if (m_isWelcome)
|
||||
{
|
||||
drawWelcome (g, getWidth (), getHeight (), 0, 0);
|
||||
m_ticks++;
|
||||
if (m_ticks > m_time_needed_startup) {
|
||||
if (m_ticks > m_time_needed_startup)
|
||||
{
|
||||
m_isWelcome = false;
|
||||
m_ticks = 0;
|
||||
needToClear = true;
|
||||
}
|
||||
} else if (m_isStarting) {
|
||||
g.drawText(m_warmUpText[pickRandomText], 0, 0, getWidth(), getHeight(),
|
||||
Justification::centred, true);
|
||||
}
|
||||
else if (m_isStarting)
|
||||
{
|
||||
g.drawText (m_warmUpText[pickRandomText], 0, 0, getWidth (), getHeight (),
|
||||
Justification::centred, true);
|
||||
m_ticks++;
|
||||
if (m_ticks > m_time_needed_startup) {
|
||||
if (m_ticks > m_time_needed_startup)
|
||||
{
|
||||
m_isStarting = false;
|
||||
m_ticks = 0;
|
||||
needToClear = true;
|
||||
}
|
||||
} else if (m_isChangingData) {
|
||||
drawChangedParameter(g, getWidth(), getHeight(), 0, 0);
|
||||
}
|
||||
else if (m_isChangingData)
|
||||
{
|
||||
drawChangedParameter (g, getWidth (), getHeight (), 0, 0);
|
||||
m_ticks++;
|
||||
if (m_ticks > m_time_needed) {
|
||||
if (m_ticks > m_time_needed)
|
||||
{
|
||||
m_isChangingData = false;
|
||||
m_ticks = 0;
|
||||
needToClear = true;
|
||||
}
|
||||
} else {
|
||||
g.resetToDefaultState();
|
||||
}
|
||||
else
|
||||
{
|
||||
g.resetToDefaultState ();
|
||||
needToClear = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Waveforms::drawChangedParameter(Graphics &g, int w, int h, int x, int y) const {
|
||||
void Waveforms::drawChangedParameter (Graphics& g, int w, int h, int x, int y) const
|
||||
{
|
||||
int halfHeight = h / 2;
|
||||
float font = VeNo::Utils::setFontSize(12, g);
|
||||
g.drawText(changingParameter, x, y + halfHeight - font, w, font, Justification::centred, true);
|
||||
g.drawText(std::to_string(changedValue), x, y + halfHeight + 4, w, font, Justification::centred,
|
||||
true);
|
||||
float font = VeNo::Utils::setFontSize (12, g);
|
||||
g.drawText (changingParameter, x, y + halfHeight - font, w, font, Justification::centred, true);
|
||||
g.drawText (std::to_string (changedValue), x, y + halfHeight + 4, w, font, Justification::centred,
|
||||
true);
|
||||
}
|
||||
|
||||
void Waveforms::drawWelcome(Graphics &g, int w, int h, int x, int y) {
|
||||
float font = VeNo::Utils::setFontSize(12, g);
|
||||
void Waveforms::drawWelcome (Graphics& g, int w, int h, int x, int y)
|
||||
{
|
||||
float font = VeNo::Utils::setFontSize (12, g);
|
||||
int halfHeight = h / 2;
|
||||
g.drawText(m_readyText, x, y + halfHeight - font, w, font, Justification::centred, true);
|
||||
g.drawText(SystemStats::getLogonName(), x, y + halfHeight + 4, w, font, Justification::centred,
|
||||
true);
|
||||
g.drawText (m_readyText, x, y + halfHeight - font, w, font, Justification::centred, true);
|
||||
g.drawText (SystemStats::getLogonName (), x, y + halfHeight + 4, w, font, Justification::centred,
|
||||
true);
|
||||
}
|
||||
|
||||
void Waveforms::drawSpectrum() {
|
||||
void Waveforms::drawSpectrum ()
|
||||
{
|
||||
}
|
||||
|
||||
void Waveforms::selectColourByPeak(float value) {
|
||||
auto theme = Config::getInstance()->getCurrentTheme();
|
||||
if (theme == nullptr) {
|
||||
void Waveforms::selectColourByPeak (float value)
|
||||
{
|
||||
auto theme = Config::getInstance ()->getCurrentTheme ();
|
||||
if (theme == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto color = theme->getColour(ThemeColour::lcd);
|
||||
if (value > 0.8 && value < 0.9) {
|
||||
color = theme->getColour(ThemeColour::warning);
|
||||
auto color = theme->getColour (ThemeColour::lcd);
|
||||
if (value > 0.8 && value < 0.9)
|
||||
{
|
||||
color = theme->getColour (ThemeColour::warning);
|
||||
}
|
||||
if (value > 0.9) {
|
||||
color = theme->getColour(ThemeColour::clip);
|
||||
if (value > 0.9)
|
||||
{
|
||||
color = theme->getColour (ThemeColour::clip);
|
||||
}
|
||||
shaderProgram->setUniform("color", color.getFloatRed(), color.getFloatGreen(), color.getFloatBlue(),
|
||||
color.getFloatAlpha());
|
||||
shaderProgram->setUniform ("color", color.getFloatRed (), color.getFloatGreen (), color.getFloatBlue (),
|
||||
color.getFloatAlpha ());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,17 +9,18 @@
|
|||
#include "../BaseComponent.h"
|
||||
|
||||
#define RANDOM_TEXT_COUNT 5
|
||||
|
||||
// opengl context :D
|
||||
class Waveforms : public BaseComponent,
|
||||
private OpenGLRenderer,
|
||||
private AsyncUpdater,
|
||||
private Timer {
|
||||
private Timer
|
||||
{
|
||||
protected:
|
||||
bool m_enableModeToggle = true;
|
||||
int m_mode = 0;
|
||||
std::string m_readyText = "=WELCOME=";
|
||||
std::string m_warmUpText[RANDOM_TEXT_COUNT] = {"Warmup...", "Mayonnaise", "Dont shake the baby", "Awesome stuff", "drink beer"};
|
||||
std::string m_warmUpText[RANDOM_TEXT_COUNT] = {"Warmup...", "Mayonnaise", "Dont shake the baby", "Awesome stuff",
|
||||
"drink beer"};
|
||||
int pickRandomText = 0;
|
||||
bool m_isWelcome = true;
|
||||
bool m_isStarting = true;
|
||||
|
|
@ -28,46 +29,29 @@ protected:
|
|||
int m_time_needed = 0;
|
||||
bool needToClear = false;
|
||||
public:
|
||||
explicit Waveforms(const std::string &processId);
|
||||
|
||||
~Waveforms() override;
|
||||
|
||||
void newOpenGLContextCreated() override;
|
||||
|
||||
void openGLContextClosing() override;
|
||||
|
||||
void renderOpenGL() override;
|
||||
|
||||
void handleAsyncUpdate() override;
|
||||
|
||||
void mouseDown(const MouseEvent &e) override;
|
||||
|
||||
void mouseDrag(const MouseEvent &e) override;
|
||||
|
||||
void paint(Graphics &g) override;
|
||||
|
||||
explicit Waveforms (const std::string& processId);
|
||||
~Waveforms () override;
|
||||
void newOpenGLContextCreated () override;
|
||||
void openGLContextClosing () override;
|
||||
void renderOpenGL () override;
|
||||
void handleAsyncUpdate () override;
|
||||
void mouseDown (const MouseEvent& e) override;
|
||||
void mouseDrag (const MouseEvent& e) override;
|
||||
void paint (Graphics& g) override;
|
||||
bool m_isChangingData = false;
|
||||
std::string changingParameter = "";
|
||||
float changedValue = 0;
|
||||
|
||||
private:
|
||||
void timerCallback() override;
|
||||
|
||||
void drawWaveTable();
|
||||
|
||||
void drawAudioOutput();
|
||||
void drawSpectrum();
|
||||
|
||||
void drawPeakMeter(); //?!
|
||||
void drawChangedParameter(Graphics &g, int w, int h, int x, int y) const;
|
||||
void drawWelcome(Graphics &g, int w, int h, int x, int y);
|
||||
|
||||
void compileOpenGLShaderProgram();
|
||||
void selectColourByPeak(float value);
|
||||
|
||||
void timerCallback () override;
|
||||
void drawWaveTable ();
|
||||
void drawAudioOutput ();
|
||||
void drawSpectrum ();
|
||||
void drawPeakMeter (); //?!
|
||||
void drawChangedParameter (Graphics& g, int w, int h, int x, int y) const;
|
||||
void drawWelcome (Graphics& g, int w, int h, int x, int y);
|
||||
void compileOpenGLShaderProgram ();
|
||||
void selectColourByPeak (float value);
|
||||
OpenGLContext m_context;
|
||||
std::unique_ptr<OpenGLShaderProgram> shaderProgram;
|
||||
};
|
||||
|
||||
|
||||
#endif //VENO_WAVEFORMS_H
|
||||
|
|
|
|||
|
|
@ -4,29 +4,36 @@
|
|||
|
||||
#include "LabelComponent.h"
|
||||
|
||||
LabelComponent::LabelComponent(Component *parent, std::string name) {
|
||||
LabelComponent::LabelComponent (Component* parent, std::string name)
|
||||
{
|
||||
m_text = name;
|
||||
m_parent = parent;
|
||||
m_label = std::make_shared<Label>(m_parent->getName(), name);
|
||||
m_label = std::make_shared<Label> (m_parent->getName (), name);
|
||||
}
|
||||
|
||||
LabelComponent::~LabelComponent() {
|
||||
m_label.reset();
|
||||
LabelComponent::~LabelComponent ()
|
||||
{
|
||||
m_label.reset ();
|
||||
}
|
||||
|
||||
void LabelComponent::resized() {
|
||||
if (m_label != nullptr) {
|
||||
m_label->setBounds(0, 0, getWidth(), getHeight());
|
||||
void LabelComponent::resized ()
|
||||
{
|
||||
if (m_label != nullptr)
|
||||
{
|
||||
m_label->setBounds (0, 0, getWidth (), getHeight ());
|
||||
}
|
||||
}
|
||||
|
||||
void LabelComponent::paint(Graphics &g) {
|
||||
void LabelComponent::paint (Graphics& g)
|
||||
{
|
||||
}
|
||||
|
||||
void LabelComponent::setPosition(LabelPosition position) {
|
||||
void LabelComponent::setPosition (LabelPosition position)
|
||||
{
|
||||
m_position = position;
|
||||
}
|
||||
|
||||
LabelPosition LabelComponent::getLabelPosition() {
|
||||
LabelPosition LabelComponent::getLabelPosition ()
|
||||
{
|
||||
return m_position;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,28 +7,26 @@
|
|||
|
||||
#include "JuceHeader.h"
|
||||
|
||||
enum LabelPosition {
|
||||
enum LabelPosition
|
||||
{
|
||||
NO_LABEL,
|
||||
TOP,
|
||||
BOTTOM
|
||||
};
|
||||
class LabelComponent : public Component {
|
||||
class LabelComponent : public Component
|
||||
{
|
||||
public:
|
||||
LabelComponent(Component *parent, std::string name);
|
||||
~LabelComponent() override;
|
||||
|
||||
void resized() override;
|
||||
|
||||
void paint(Graphics &g) override;
|
||||
void setPosition(LabelPosition position);
|
||||
LabelPosition getLabelPosition();
|
||||
LabelComponent (Component* parent, std::string name);
|
||||
~LabelComponent () override;
|
||||
void resized () override;
|
||||
void paint (Graphics& g) override;
|
||||
void setPosition (LabelPosition position);
|
||||
LabelPosition getLabelPosition ();
|
||||
protected:
|
||||
private:
|
||||
std::string m_text;
|
||||
Component *m_parent;
|
||||
Component* m_parent;
|
||||
LabelPosition m_position = LabelPosition::NO_LABEL;
|
||||
std::shared_ptr<Label> m_label;
|
||||
};
|
||||
|
||||
|
||||
#endif //VENO_LABELCOMPONENT_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue