juicysfplugin/Source/Pills.h

81 lines
2.2 KiB
C
Raw Normal View History

2018-02-27 08:25:20 +08:00
//
// Created by Alex Birch on 01/10/2017.
//
#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
using namespace std;
class Pill
: public Component
, public Button::Listener
{
2018-02-27 08:25:20 +08:00
public:
Pill(
AudioProcessorValueTreeState& valueTreeState,
int bank,
bool isFirst,
bool isLast
2018-02-27 08:25:20 +08:00
);
~Pill();
void buttonClicked(Button* button) override;
void resized() override;
void paint(Graphics& g) override;
void bankChanged(int bank);
private:
AudioProcessorValueTreeState& valueTreeState;
int bank;
TextButton textButton;
2018-02-27 08:25:20 +08:00
friend class Pills;
};
class Pills
: public Component
, public ValueTree::Listener
, public AudioProcessorValueTreeState::Listener
{
public:
Pills(
AudioProcessorValueTreeState& valueTreeState
2018-02-27 08:25:20 +08:00
);
~Pills();
2018-02-27 08:25:20 +08:00
void cycle(bool right);
virtual void parameterChanged (const String& parameterID, float newValue) override;
virtual void valueTreePropertyChanged (ValueTree& treeWhosePropertyHasChanged,
const Identifier& property) override;
inline virtual void valueTreeChildAdded (ValueTree& parentTree,
ValueTree& childWhichHasBeenAdded) override {};
inline virtual void valueTreeChildRemoved (ValueTree& parentTree,
ValueTree& childWhichHasBeenRemoved,
int indexFromWhichChildWasRemoved) override {};
inline virtual void valueTreeChildOrderChanged (ValueTree& parentTreeWhoseChildrenHaveMoved,
int oldIndex, int newIndex) override {};
inline virtual void valueTreeParentChanged (ValueTree& treeWhoseParentHasChanged) override {};
inline virtual void valueTreeRedirected (ValueTree& treeWhichHasBeenChanged) override {};
2018-02-27 08:25:20 +08:00
private:
void loadModelFrom(ValueTree& banks);
AudioProcessorValueTreeState& valueTreeState;
2018-02-27 08:25:20 +08:00
vector<unique_ptr<Pill>> pills;
2018-02-27 08:25:20 +08:00
Button *selected;
void updatePillToggleStates();
2018-02-27 08:25:20 +08:00
void populate(int initiallySelectedItem);
void resized() override;
void paint(Graphics& g) override;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pills)
};