initial: added first widget
This commit is contained in:
51
Source/LookAndFeel.h
Normal file
51
Source/LookAndFeel.h
Normal file
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// LookAndFeel.h
|
||||
// lampshade
|
||||
//
|
||||
// Created by Veit Heller on 19.06.17.
|
||||
//
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
|
||||
class LampshadeLookAndFeel : public LookAndFeel_V4 {
|
||||
public:
|
||||
void drawLinearSlider (Graphics& g,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
float sliderPos,
|
||||
float minSliderPos,
|
||||
float maxSliderPos,
|
||||
const Slider::SliderStyle s,
|
||||
Slider& slider) override
|
||||
{
|
||||
g.setColour(fillColor);
|
||||
g.fillRect((int)(x-minSliderPos), y, (int)(width+minSliderPos+maxSliderPos), height);
|
||||
drawLinearSliderThumb(g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, s, slider);
|
||||
}
|
||||
|
||||
void drawLinearSliderThumb(Graphics & g,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
float sliderPos,
|
||||
float minSliderPos,
|
||||
float maxSliderPos,
|
||||
const Slider::SliderStyle ,
|
||||
Slider& slider) override {
|
||||
g.setColour(sliderColor);
|
||||
int nwidth = width+minSliderPos+maxSliderPos;
|
||||
g.fillRect((int)(x-minSliderPos), y, (int)(nwidth*((sliderPos-minSliderPos)/width)), height);
|
||||
}
|
||||
|
||||
Label* createSliderTextBox(Slider&) override { return nullptr; }
|
||||
|
||||
private:
|
||||
Colour fillColor = Colours::yellow;
|
||||
Colour sliderColor = Colours::red;
|
||||
};
|
@@ -12,13 +12,15 @@
|
||||
#include "PluginEditor.h"
|
||||
|
||||
|
||||
|
||||
//==============================================================================
|
||||
LampshadeAudioProcessorEditor::LampshadeAudioProcessorEditor (LampshadeAudioProcessor& p)
|
||||
: AudioProcessorEditor (&p), processor (p)
|
||||
: AudioProcessorEditor (&p), processor (p), nlines (3), lineThickness(4)
|
||||
{
|
||||
// Make sure that before the constructor has finished, you've set the
|
||||
// editor's size to whatever you need it to be.
|
||||
setSize (400, 300);
|
||||
component.setTextBoxStyle(Slider::NoTextBox, true, 0, 0);
|
||||
setSize(400, 300);
|
||||
component.setLookAndFeel(gui);
|
||||
addAndMakeVisible(component);
|
||||
}
|
||||
|
||||
LampshadeAudioProcessorEditor::~LampshadeAudioProcessorEditor()
|
||||
@@ -29,15 +31,15 @@ LampshadeAudioProcessorEditor::~LampshadeAudioProcessorEditor()
|
||||
void LampshadeAudioProcessorEditor::paint (Graphics& g)
|
||||
{
|
||||
// (Our component is opaque, so we must completely fill the background with a solid colour)
|
||||
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
|
||||
|
||||
g.setColour (Colours::white);
|
||||
g.setFont (15.0f);
|
||||
g.drawFittedText ("Hello World!", getLocalBounds(), Justification::centred, 1);
|
||||
g.fillAll(Colours::white);
|
||||
|
||||
for (int i = 1; i < nlines; i++) {
|
||||
g.drawLine(0, getHeight()*((float)i / nlines), getWidth(), getHeight()*((float)i / nlines), lineThickness);
|
||||
g.drawLine(getWidth()*((float) i /nlines), 0, getWidth()*((float) i /nlines), getHeight(), lineThickness);
|
||||
}
|
||||
}
|
||||
|
||||
void LampshadeAudioProcessorEditor::resized()
|
||||
{
|
||||
// This is generally where you'll want to lay out the positions of any
|
||||
// subcomponents in your editor..
|
||||
component.setBounds(getWidth()/nlines+lineThickness/2, getHeight()/nlines+lineThickness/2, getWidth()/nlines-lineThickness+1, getHeight()/nlines-lineThickness);
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
#include "PluginProcessor.h"
|
||||
#include "LookAndFeel.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
@@ -31,6 +32,11 @@ private:
|
||||
// This reference is provided as a quick way for your editor to
|
||||
// access the processor object that created it.
|
||||
LampshadeAudioProcessor& processor;
|
||||
LampshadeLookAndFeel* gui = new LampshadeLookAndFeel();
|
||||
int nlines;
|
||||
int lineThickness;
|
||||
|
||||
Slider component;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LampshadeAudioProcessorEditor)
|
||||
};
|
||||
|
@@ -1,18 +1,7 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file was auto-generated!
|
||||
|
||||
It contains the basic framework code for a JUCE plugin processor.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#include "PluginProcessor.h"
|
||||
#include "PluginEditor.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
LampshadeAudioProcessor::LampshadeAudioProcessor()
|
||||
#ifndef JucePlugin_PreferredChannelConfigurations
|
||||
: AudioProcessor (BusesProperties()
|
||||
@@ -31,7 +20,6 @@ LampshadeAudioProcessor::~LampshadeAudioProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
const String LampshadeAudioProcessor::getName() const
|
||||
{
|
||||
return JucePlugin_Name;
|
||||
@@ -48,11 +36,7 @@ bool LampshadeAudioProcessor::acceptsMidi() const
|
||||
|
||||
bool LampshadeAudioProcessor::producesMidi() const
|
||||
{
|
||||
#if JucePlugin_ProducesMidiOutput
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
double LampshadeAudioProcessor::getTailLengthSeconds() const
|
||||
@@ -62,8 +46,7 @@ double LampshadeAudioProcessor::getTailLengthSeconds() const
|
||||
|
||||
int LampshadeAudioProcessor::getNumPrograms()
|
||||
{
|
||||
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
|
||||
// so this should be at least 1, even if you're not really implementing programs.
|
||||
return 1;
|
||||
}
|
||||
|
||||
int LampshadeAudioProcessor::getCurrentProgram()
|
||||
@@ -84,31 +67,22 @@ void LampshadeAudioProcessor::changeProgramName (int index, const String& newNam
|
||||
{
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void LampshadeAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
|
||||
{
|
||||
// Use this method as the place to do any pre-playback
|
||||
// initialisation that you need..
|
||||
}
|
||||
|
||||
void LampshadeAudioProcessor::releaseResources()
|
||||
{
|
||||
// When playback stops, you can use this as an opportunity to free up any
|
||||
// spare memory, etc.
|
||||
}
|
||||
|
||||
#ifndef JucePlugin_PreferredChannelConfigurations
|
||||
bool LampshadeAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
|
||||
{
|
||||
#if JucePlugin_IsMidiEffect
|
||||
ignoreUnused (layouts);
|
||||
return true;
|
||||
#else
|
||||
// This is the place where you check if the layout is supported.
|
||||
// In this template code we only support mono or stereo.
|
||||
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
|
||||
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
|
||||
return false;
|
||||
// This is the place where you check if the layout is supported.
|
||||
// In this template code we only support mono or stereo.
|
||||
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
|
||||
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
|
||||
return false;
|
||||
|
||||
// This checks if the input layout matches the output layout
|
||||
#if ! JucePlugin_IsSynth
|
||||
@@ -117,7 +91,6 @@ bool LampshadeAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts
|
||||
#endif
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -139,16 +112,15 @@ void LampshadeAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffe
|
||||
// audio processing...
|
||||
for (int channel = 0; channel < totalNumInputChannels; ++channel)
|
||||
{
|
||||
float* channelData = buffer.getWritePointer (channel);
|
||||
//float* channelData = buffer.getWritePointer (channel);
|
||||
|
||||
// ..do something to the data...
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool LampshadeAudioProcessor::hasEditor() const
|
||||
{
|
||||
return true; // (change this to false if you choose to not supply an editor)
|
||||
return true;
|
||||
}
|
||||
|
||||
AudioProcessorEditor* LampshadeAudioProcessor::createEditor()
|
||||
@@ -156,7 +128,6 @@ AudioProcessorEditor* LampshadeAudioProcessor::createEditor()
|
||||
return new LampshadeAudioProcessorEditor (*this);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void LampshadeAudioProcessor::getStateInformation (MemoryBlock& destData)
|
||||
{
|
||||
// You should use this method to store your parameters in the memory block.
|
||||
|
Reference in New Issue
Block a user