Skip to content

Commit

Permalink
XYPad: Add canvas & thumb
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed May 22, 2020
1 parent 4a4a589 commit b655554
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
3 changes: 2 additions & 1 deletion examples/component/XYPad/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
JuceLibraryCode
Builds
Builds
compile_commands.json
10 changes: 8 additions & 2 deletions examples/component/XYPad/Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ namespace tobanteAudio
{
PluginEditor::PluginEditor(PluginProcessor& p) : AudioProcessorEditor(&p), processor(p)
{
addAndMakeVisible(pad_);
setSize(400, 300);
}

PluginEditor::~PluginEditor() { }

void PluginEditor::paint(juce::Graphics& g)
{
auto const color = getLookAndFeel().findColour(juce::ResizableWindow::backgroundColourId);
// auto const color = getLookAndFeel().findColour(juce::ResizableWindow::backgroundColourId);
auto const color = juce::Colour(244, 244, 244);
g.fillAll(color);
}

void PluginEditor::resized() { }
void PluginEditor::resized()
{
auto area = getLocalBounds();
pad_.setBounds(area.reduced(10));
}

} // namespace tobanteAudio
3 changes: 3 additions & 0 deletions examples/component/XYPad/Source/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "PluginProcessor.h"

#include "XYPad.h"

namespace tobanteAudio
{
class PluginEditor : public juce::AudioProcessorEditor
Expand All @@ -16,6 +18,7 @@ class PluginEditor : public juce::AudioProcessorEditor
private:
PluginProcessor& processor;

tobanteAudio::XYPad pad_;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginEditor)
};

Expand Down
37 changes: 37 additions & 0 deletions examples/component/XYPad/Source/XYPad.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

#include <JuceHeader.h>

namespace tobanteAudio
{
class XYPad : public juce::Component
{
public:
XYPad() = default;

~XYPad() override = default;

void paint(juce::Graphics& g) override
{
auto const color = juce::Colour(204, 204, 204);
g.fillAll(color);

auto thumb = juce::Rectangle<float> {20, 20};
thumb.setCentre(data_);
g.setColour(juce::Colours::black);
g.fillEllipse(thumb);
}

void resized() override
{
area_ = getLocalBounds().toFloat();
data_ = area_.getCentre();
}

private:
juce::Point<float> data_ {};
juce::Rectangle<float> area_ {};
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(XYPad)
};

} // namespace tobanteAudio

0 comments on commit b655554

Please sign in to comment.