Ive been watching https://www.youtube.com/watch?v=_IocXoXUWdQ&ab_channel=TheAudioProgrammer and followed the guide apart from the adding shapes as I would like to add my own graphic. How would I go about this?
editor.h -
/*
==============================================================================
This file contains the basic framework code for a JUCE plugin editor.
==============================================================================
*/
#pragma once
#include <JuceHeader.h>
#include "PluginProcessor.h"
class OtherLookAndFeel : public juce::LookAndFeel_V4
{
public:
void drawRotarySlider (juce::Graphics &g, int x, int y, int width, int height, float sliderPos, float rotaryStartAngle, float rotaryEndAngle, juce::Slider &slider) override
{
/*
// Method 1
float angleInRadians = juce::MathConstants<float>::pi / 4;
float centerX = dial.getWidth() / 2.0f;
float centerY = dial.getHeight() / 2.0f;
dial = juce::ImageCache::getFromMemory(BinaryData::dial_png, BinaryData::dial_pngSize);
g.drawImage(dial, 20, 20, 80, 80, 0, 0, 2000, 1997);
juce::AffineTransform rotation = juce::AffineTransform::rotation(angleInRadians, centerX, centerY);
g.addTransform(rotation);
g.drawImageAt(dial, 0, 0);
*/
/*
//Method 2
float angle = rotaryStartAngle + (sliderPos * (rotaryEndAngle - rotaryStartAngle));
dial = juce::ImageCache::getFromMemory(BinaryData::dial_png, BinaryData::dial_pngSize);
g.drawImage(dial, 20, 20, 80, 80, 0, 0, 2000, 1997);
g.drawImageTransformed(dial, juce::AffineTransform::rotation(angle));
*/
/*
// Method 3
dial = juce::ImageCache::getFromMemory(BinaryData::dial_png ,BinaryData::dial_pngSize);
float angle = rotaryStartAngle + (sliderPos * (rotaryEndAngle - rotaryStartAngle));
g.drawImageTransformed(dial, juce::AffineTransform::rotation(angle, dial.getWidth() /2, dial.getHeight() /2));
*/
}
private:
juce::Image dial;
};
//==============================================================================
/**
*/
class MockGUICW2AudioProcessorEditor : public juce::AudioProcessorEditor
{
public:
MockGUICW2AudioProcessorEditor (MockGUICW2AudioProcessor&);
~MockGUICW2AudioProcessorEditor() override;
//==============================================================================
void paint (juce::Graphics&) override;
void resized() override;
private:
juce::Slider delayTimeDial;
juce::Slider delayFeedbackDial;
juce::Slider delayMixDial;
juce::ImageButton modeButton;
juce::Image buttonA;
juce::Image buttonB;
juce::Image buttonC;
juce::Image background;
juce::Image dial;
OtherLookAndFeel otherLookAndFeel;
MockGUICW2AudioProcessor& audioProcessor;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MockGUICW2AudioProcessorEditor)
};
editor.cpp -
/*
==============================================================================
This file contains the basic framework code for a JUCE plugin editor.
==============================================================================
*/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
MockGUICW2AudioProcessorEditor::MockGUICW2AudioProcessorEditor (MockGUICW2AudioProcessor& p)
: AudioProcessorEditor (&p), audioProcessor (p)
{
setSize (350, 200);
dial = juce::ImageCache::getFromMemory(BinaryData::dial_png ,BinaryData::dial_pngSize);
delayTimeDial.setSliderStyle(juce::Slider::RotaryVerticalDrag);
delayTimeDial.setRange(10.f, 3000.f);
delayTimeDial.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, true, 0, 0);
addAndMakeVisible(&delayTimeDial);
delayTimeDial.setLookAndFeel(&otherLookAndFeel);
delayFeedbackDial.setSliderStyle(juce::Slider::RotaryVerticalDrag);
delayFeedbackDial.setRange(0.f, 1.f);
delayFeedbackDial.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, true, 0, 0);
addAndMakeVisible(&delayFeedbackDial);
delayFeedbackDial.setLookAndFeel(&otherLookAndFeel);
delayMixDial.setSliderStyle(juce::Slider::RotaryVerticalDrag);
delayMixDial.setRange(0.f, 1.f);
delayMixDial.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, true, 0, 0);
addAndMakeVisible(&delayMixDial);
delayMixDial.setLookAndFeel(&otherLookAndFeel);
modeButton.setImages(false, true, true, juce::ImageCache::getFromMemory(BinaryData::buttonA_png, BinaryData::buttonA_pngSize), 1.f, {}, juce::ImageCache::getFromMemory(BinaryData::buttonB_png, BinaryData::buttonB_pngSize), 1.f, {} , juce::ImageCache::getFromMemory(BinaryData::buttonC_png, BinaryData::buttonC_pngSize), 1.f, {});
modeButton.setClickingTogglesState(true);
addAndMakeVisible(&modeButton);
}
MockGUICW2AudioProcessorEditor::~MockGUICW2AudioProcessorEditor()
{
}
//==============================================================================
void MockGUICW2AudioProcessorEditor::paint (juce::Graphics& g)
{
background = juce::ImageCache::getFromMemory(BinaryData::background_png, BinaryData::background_pngSize);
g.drawImage(background, 0, 0, 350, 200, 0, 0, 1848, 1053);
}
void MockGUICW2AudioProcessorEditor::resized()
{
delayTimeDial.setBounds(0, 10, 100, 100);
delayFeedbackDial.setBounds(120, 10, 100, 100);
delayMixDial.setBounds(238, 10, 100, 100);
modeButton.setBounds(310, 162, 25, 25);
}
