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;
|
|
|
|
|
2019-07-14 21:19:27 +08:00
|
|
|
class Pill
|
|
|
|
: public Button::Listener
|
|
|
|
, public AudioProcessorValueTreeState::Listener
|
|
|
|
{
|
2018-02-27 08:25:20 +08:00
|
|
|
public:
|
2019-07-14 21:19:27 +08:00
|
|
|
Pill(
|
|
|
|
AudioProcessorValueTreeState& valueTreeState,
|
|
|
|
int bank,
|
|
|
|
bool isFirst,
|
|
|
|
bool isLast
|
2018-02-27 08:25:20 +08:00
|
|
|
);
|
2019-07-14 21:19:27 +08:00
|
|
|
~Pill();
|
|
|
|
|
|
|
|
void buttonClicked (Button* button) override;
|
|
|
|
|
|
|
|
virtual void parameterChanged (const String& parameterID, float newValue) override;
|
|
|
|
private:
|
|
|
|
void loadToggleState();
|
|
|
|
|
|
|
|
AudioProcessorValueTreeState& valueTreeState;
|
|
|
|
int bank;
|
|
|
|
TextButton textButton;
|
2018-02-27 08:25:20 +08:00
|
|
|
|
2019-07-14 21:19:27 +08:00
|
|
|
friend class Pills;
|
2019-07-15 00:22:36 +08:00
|
|
|
};
|
2019-07-14 21:19:27 +08:00
|
|
|
|
|
|
|
class Pills
|
|
|
|
: public Component
|
|
|
|
, public ValueTree::Listener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Pills(
|
|
|
|
AudioProcessorValueTreeState& valueTreeState
|
|
|
|
// string label
|
|
|
|
// const vector<string> &items,
|
|
|
|
// const function<void (int)> &onItemSelected,
|
|
|
|
// const function<int (const string&)> &itemToIDMapper,
|
|
|
|
// int initiallySelectedItem
|
2018-02-27 08:25:20 +08:00
|
|
|
);
|
2019-07-14 21:19:27 +08:00
|
|
|
~Pills();
|
2018-02-27 08:25:20 +08:00
|
|
|
|
2019-07-14 21:19:27 +08:00
|
|
|
// void setItems(
|
|
|
|
// const vector<string> &items,
|
|
|
|
// int initiallySelectedItem
|
|
|
|
// );
|
|
|
|
|
|
|
|
// void buttonClicked (Button* button) override;
|
2018-02-27 08:25:20 +08:00
|
|
|
void cycle(bool right);
|
|
|
|
|
2019-07-14 21:19:27 +08:00
|
|
|
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:
|
2019-07-14 21:19:27 +08:00
|
|
|
void loadModelFrom(ValueTree& banks);
|
|
|
|
|
|
|
|
AudioProcessorValueTreeState& valueTreeState;
|
|
|
|
// string label;
|
|
|
|
// vector<string> items;
|
|
|
|
// function<void (int)> onItemSelected;
|
|
|
|
// function<int (const string&)> itemToIDMapper;
|
2018-02-27 08:25:20 +08:00
|
|
|
|
2019-07-14 21:19:27 +08:00
|
|
|
// OwnedArray<Pill> buttons;
|
|
|
|
vector<unique_ptr<Pill>> pills;
|
2018-02-27 08:25:20 +08:00
|
|
|
Button *selected;
|
|
|
|
|
2019-07-14 21:19:27 +08:00
|
|
|
// Pill* addToList (Pill* newButton);
|
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)
|
2019-07-15 00:22:36 +08:00
|
|
|
};
|