From 1842a6cfeb0b7f2a6446926a1edf990e55654a15 Mon Sep 17 00:00:00 2001 From: hellerve Date: Mon, 19 Jun 2017 16:59:27 -0400 Subject: [PATCH] initial: added first widget --- .gitignore | 1 + Source/LookAndFeel.h | 51 ++++++++++++++++++ Source/PluginEditor.cpp | 24 +++++---- Source/PluginEditor.h | 6 +++ Source/PluginProcessor.cpp | 47 ++++------------- test.RPP | 105 +++++++++++++++++++++++++++++++++++++ 6 files changed, 185 insertions(+), 49 deletions(-) create mode 100644 Source/LookAndFeel.h create mode 100644 test.RPP diff --git a/.gitignore b/.gitignore index 7950ae2..d15b6a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ JuceLibraryCode/ Builds/ +*bak diff --git a/Source/LookAndFeel.h b/Source/LookAndFeel.h new file mode 100644 index 0000000..f737db9 --- /dev/null +++ b/Source/LookAndFeel.h @@ -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; +}; diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 98ec375..5b68828 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -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); } diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 06d292e..11c01d6 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -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) }; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 1f8a551..16fee5a 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -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. diff --git a/test.RPP b/test.RPP new file mode 100644 index 0000000..3ae1102 --- /dev/null +++ b/test.RPP @@ -0,0 +1,105 @@ + + + RENDER_FILE "" + RENDER_PATTERN "" + RENDER_FMT 0 2 0 + RENDER_1X 0 + RENDER_RANGE 1 0 0 18 1000 + RENDER_RESAMPLE 3 0 1 + RENDER_ADDTOPROJ 0 + RENDER_STEMS 0 + RENDER_DITHER 0 + TIMELOCKMODE 1 + TEMPOENVLOCKMODE 1 + ITEMMIX 0 + DEFPITCHMODE 589824 + TAKELANE 1 + SAMPLERATE 44100 0 0 + + LOCK 1 + + GLOBAL_AUTO -1 + TEMPO 120 4 4 + PLAYRATE 1 0 0.25 4 + SELECTION 0 0 + SELECTION2 0 0 + MASTERAUTOMODE 0 + MASTERTRACKHEIGHT 0 + MASTERPEAKCOL 16576 + MASTERMUTESOLO 0 + MASTERTRACKVIEW 0 0.6667 0.5 0.5 0 0 0 + MASTERHWOUT 0 0 1 0 0 0 0 -1 + MASTER_NCH 2 2 + MASTER_VOLUME 1 0 -1 -1 1 + MASTER_FX 1 + MASTER_SEL 0 + + FLOATPOS 0 0 0 0 + FXID {3568A34C-460C-D046-82F7-7D87378ABB20} + WAK 0 + > + + + +>