render pills. use cheat to notify that tree of presets/banks has changed.
This commit is contained in:
parent
11d7296813
commit
99bb294ece
|
@ -379,6 +379,8 @@ void FluidSynthModel::loadFont(const String &absPath) {
|
|||
// valueTreeState.state.getChildWithName("presets") = presets;
|
||||
valueTreeState.state.getChildWithName("banks").copyPropertiesAndChildrenFrom(banks, nullptr);
|
||||
valueTreeState.state.getChildWithName("presets").copyPropertiesAndChildrenFrom(presets, nullptr);
|
||||
valueTreeState.state.getChildWithName("banks").sendPropertyChangeMessage("synthetic");
|
||||
valueTreeState.state.getChildWithName("presets").sendPropertyChangeMessage("synthetic");
|
||||
|
||||
#if JUCE_DEBUG
|
||||
unique_ptr<XmlElement> xml{valueTreeState.state.createXml()};
|
||||
|
|
|
@ -19,6 +19,7 @@ Pill::Pill(
|
|||
, bank{bank}
|
||||
, textButton{String(bank)}
|
||||
{
|
||||
setOpaque(true);
|
||||
textButton.setConnectedEdges (
|
||||
(isFirst ? 0 : Button::ConnectedOnLeft)
|
||||
| (isLast ? 0 : Button::ConnectedOnRight)
|
||||
|
@ -27,11 +28,23 @@ Pill::Pill(
|
|||
loadToggleState();
|
||||
textButton.setClickingTogglesState(true);
|
||||
|
||||
addAndMakeVisible(textButton);
|
||||
|
||||
valueTreeState.addParameterListener("bank", this);
|
||||
// valueTreeState.state.addListener(this);
|
||||
textButton.addListener(this);
|
||||
}
|
||||
|
||||
void Pill::paint (Graphics& g)
|
||||
{
|
||||
// (Our component is opaque, so we must completely fill the background with a solid colour)
|
||||
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
|
||||
}
|
||||
|
||||
void Pill::resized() {
|
||||
textButton.setBounds(getLocalBounds());
|
||||
}
|
||||
|
||||
Pill::~Pill() {
|
||||
valueTreeState.removeParameterListener("bank", this);
|
||||
// valueTreeState.state.removeListener(this);
|
||||
|
@ -101,8 +114,10 @@ void Pills::valueTreePropertyChanged(
|
|||
ValueTree& treeWhosePropertyHasChanged,
|
||||
const Identifier& property) {
|
||||
if (treeWhosePropertyHasChanged.getType() == StringRef("banks")) {
|
||||
if (property == StringRef("synthetic")) {
|
||||
loadModelFrom(treeWhosePropertyHasChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Pills::loadModelFrom(ValueTree& banks) {
|
||||
|
@ -114,13 +129,15 @@ void Pills::loadModelFrom(ValueTree& banks) {
|
|||
// rows.push_back(unique_ptr<Pill>(new Pill(), [](Pill* pill) {
|
||||
// pill->remo
|
||||
// }));
|
||||
pills.push_back(
|
||||
make_unique<Pill>(
|
||||
unique_ptr<Pill> pill{make_unique<Pill>(
|
||||
valueTreeState,
|
||||
num,
|
||||
i == 0,
|
||||
i == numChildren - 1));
|
||||
i == numChildren - 1)};
|
||||
addAndMakeVisible(pill.get());
|
||||
pills.push_back(move(pill));
|
||||
}
|
||||
resized();
|
||||
}
|
||||
|
||||
// void Pills::populate(int initiallySelectedItem) {
|
||||
|
@ -210,7 +227,7 @@ void Pills::resized() {
|
|||
Rectangle<int> r2 (getLocalBounds());
|
||||
r2.removeFromLeft(equalWidth * index);
|
||||
r2.removeFromRight(equalWidth * (static_cast<int>(pills.size())-index-1));
|
||||
pill->textButton.setBounds (r2);
|
||||
pill->setBounds(r2);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
using namespace std;
|
||||
|
||||
class Pill
|
||||
: public Button::Listener
|
||||
: public Component
|
||||
, public Button::Listener
|
||||
, public AudioProcessorValueTreeState::Listener
|
||||
{
|
||||
public:
|
||||
|
@ -23,6 +24,9 @@ public:
|
|||
|
||||
void buttonClicked (Button* button) override;
|
||||
|
||||
void resized() override;
|
||||
void paint(Graphics& g) override;
|
||||
|
||||
virtual void parameterChanged (const String& parameterID, float newValue) override;
|
||||
private:
|
||||
void loadToggleState();
|
||||
|
|
|
@ -73,7 +73,7 @@ JuicySFAudioProcessorEditor::JuicySFAudioProcessorEditor(
|
|||
tablesComponent.setWantsKeyboardFocus(false);
|
||||
|
||||
setWantsKeyboardFocus(true);
|
||||
addAndMakeVisible (midiKeyboard);
|
||||
addAndMakeVisible(midiKeyboard);
|
||||
|
||||
addAndMakeVisible(slidersComponent);
|
||||
addAndMakeVisible(tablesComponent);
|
||||
|
|
|
@ -73,8 +73,8 @@ AudioProcessorValueTreeState::ParameterLayout JuicySFAudioProcessor::createParam
|
|||
// make_unique<AudioParameterInt>("uiHeightTemp", "height of this plugin's GUI. Editor writes here on change (e.g. on window resize). Processor copies this into Persist before any save.", GuiConstants::minHeight, GuiConstants::maxHeight, GuiConstants::minHeight, "UI Height Temp" ),
|
||||
// make_unique<AudioParameterInt>("uiWidth", "width of this plugin's GUI", GuiConstants::minWidth, GuiConstants::maxWidth, GuiConstants::minWidth, "UI Width" ),
|
||||
// make_unique<AudioParameterInt>("uiHeight", "height of this plugin's GUI", GuiConstants::minHeight, GuiConstants::maxHeight, GuiConstants::minHeight, "UI Height" ),
|
||||
// todo: check whether bank really is 0-127
|
||||
make_unique<AudioParameterInt>("bank", "which bank is selected in the soundfont", MidiConstants::midiMinValue, MidiConstants::midiMaxValue, MidiConstants::midiMinValue, "Bank" ),
|
||||
// SoundFont 2.4 spec section 7.2: zero through 127, or 128.
|
||||
make_unique<AudioParameterInt>("bank", "which bank is selected in the soundfont", MidiConstants::midiMinValue, 128, MidiConstants::midiMinValue, "Bank" ),
|
||||
// note: banks may be sparse, and lack a 0th preset. so defend against this.
|
||||
make_unique<AudioParameterInt>("preset", "which patch (aka patch, program, instrument) is selected in the soundfont", MidiConstants::midiMinValue, MidiConstants::midiMaxValue, MidiConstants::midiMinValue, "Preset" ),
|
||||
make_unique<AudioParameterInt>("attack", "volume envelope attack time", MidiConstants::midiMinValue, MidiConstants::midiMaxValue, MidiConstants::midiMinValue, "A" ),
|
||||
|
|
|
@ -120,19 +120,52 @@ void TableComponent::parameterChanged(const String& parameterID, float newValue)
|
|||
}
|
||||
}
|
||||
|
||||
// void TableComponent::valueTreePropertyChanged(
|
||||
// ValueTree& treeWhosePropertyHasChanged,
|
||||
// const Identifier& property) {
|
||||
// if (treeWhosePropertyHasChanged.getType() == StringRef("presets")) {
|
||||
// loadModelFrom(treeWhosePropertyHasChanged);
|
||||
void TableComponent::valueTreePropertyChanged(
|
||||
ValueTree& treeWhosePropertyHasChanged,
|
||||
const Identifier& property) {
|
||||
if (treeWhosePropertyHasChanged.getType() == StringRef("presets")) {
|
||||
if (property == StringRef("synthetic")) {
|
||||
loadModelFrom(treeWhosePropertyHasChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// void TableComponent::valueTreeParentChanged(ValueTree& treeWhoseParentHasChanged) {
|
||||
// if (treeWhoseParentHasChanged.getType() == StringRef("presets")) {
|
||||
// loadModelFrom(treeWhoseParentHasChanged);
|
||||
// }
|
||||
// }
|
||||
|
||||
void TableComponent::valueTreeParentChanged(ValueTree& treeWhoseParentHasChanged) {
|
||||
if (treeWhoseParentHasChanged.getType() == StringRef("presets")) {
|
||||
loadModelFrom(treeWhoseParentHasChanged);
|
||||
}
|
||||
}
|
||||
// void TableComponent::valueTreePropertyChanged(
|
||||
// ValueTree& treeWhosePropertyHasChanged,
|
||||
// const Identifier& property) {
|
||||
// DEBUG_PRINT(treeWhosePropertyHasChanged.getType().toString());
|
||||
// }
|
||||
// void TableComponent::valueTreeChildAdded(
|
||||
// ValueTree& parentTree,
|
||||
// ValueTree& childWhichHasBeenAdded) {
|
||||
// DEBUG_PRINT(parentTree.getType().toString());
|
||||
// }
|
||||
// void TableComponent::valueTreeChildRemoved(
|
||||
// ValueTree& parentTree,
|
||||
// ValueTree& childWhichHasBeenRemoved,
|
||||
// int indexFromWhichChildWasRemoved) {
|
||||
// DEBUG_PRINT(parentTree.getType().toString());
|
||||
// }
|
||||
// void TableComponent::valueTreeChildOrderChanged(
|
||||
// ValueTree& parentTreeWhoseChildrenHaveMoved,
|
||||
// int oldIndex,
|
||||
// int newIndex) {
|
||||
// DEBUG_PRINT(parentTreeWhoseChildrenHaveMoved.getType().toString());
|
||||
// }
|
||||
// void TableComponent::valueTreeParentChanged(
|
||||
// ValueTree& treeWhoseParentHasChanged) {
|
||||
// DEBUG_PRINT(treeWhoseParentHasChanged.getType().toString());
|
||||
// }
|
||||
// void TableComponent::valueTreeRedirected(
|
||||
// ValueTree& treeWhichHasBeenChanged) {
|
||||
// DEBUG_PRINT(treeWhichHasBeenChanged.getType().toString());
|
||||
// }
|
||||
|
||||
// void TableComponent::setRows(const vector<vector<string>>& rows, int initiallySelectedRow) {
|
||||
// this->rows = rows;
|
||||
|
|
|
@ -79,8 +79,8 @@ public:
|
|||
|
||||
virtual void parameterChanged (const String& parameterID, float newValue) override;
|
||||
|
||||
inline virtual void valueTreePropertyChanged (ValueTree& treeWhosePropertyHasChanged,
|
||||
const Identifier& property) 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,
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
int indexFromWhichChildWasRemoved) override {};
|
||||
inline virtual void valueTreeChildOrderChanged (ValueTree& parentTreeWhoseChildrenHaveMoved,
|
||||
int oldIndex, int newIndex) override {};
|
||||
virtual void valueTreeParentChanged (ValueTree& treeWhoseParentHasChanged) override;
|
||||
inline virtual void valueTreeParentChanged (ValueTree& treeWhoseParentHasChanged) override {};
|
||||
inline virtual void valueTreeRedirected (ValueTree& treeWhichHasBeenChanged) override {};
|
||||
private:
|
||||
void loadModelFrom(ValueTree& presets);
|
||||
|
|
Loading…
Reference in New Issue
Block a user