2018-02-27 08:17:12 +08:00
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
This file was auto-generated!
|
|
|
|
|
|
|
|
It contains the basic framework code for a JUCE plugin editor.
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "PluginProcessor.h"
|
|
|
|
#include "PluginEditor.h"
|
2019-07-02 06:55:14 +08:00
|
|
|
#include "GuiConstants.h"
|
2018-02-27 08:17:12 +08:00
|
|
|
|
|
|
|
//==============================================================================
|
2019-07-04 06:38:56 +08:00
|
|
|
JuicySFAudioProcessorEditor::JuicySFAudioProcessorEditor(JuicySFAudioProcessor& p, AudioProcessorValueTreeState& valueTreeState)
|
2019-07-02 06:55:14 +08:00
|
|
|
: AudioProcessorEditor{&p},
|
|
|
|
processor{p},
|
2019-07-04 06:38:56 +08:00
|
|
|
valueTreeState{valueTreeState},
|
2019-07-07 07:22:47 +08:00
|
|
|
sharedParams{p.getSharedParams()},
|
2019-07-02 06:55:14 +08:00
|
|
|
midiKeyboard{p.keyboardState, SurjectiveMidiKeyboardComponent::horizontalKeyboard},
|
2019-07-07 07:22:47 +08:00
|
|
|
tablesComponent{valueTreeState, p.getFluidSynthModel()},
|
|
|
|
filePicker{valueTreeState, p.getFluidSynthModel()},
|
|
|
|
slidersComponent{p.getSharedParams(), valueTreeState, p.getFluidSynthModel()}
|
2018-02-27 08:17:12 +08:00
|
|
|
{
|
2018-02-27 08:25:20 +08:00
|
|
|
// set resize limits for this plug-in
|
2019-07-02 06:55:14 +08:00
|
|
|
setResizeLimits(
|
|
|
|
GuiConstants::minWidth,
|
|
|
|
GuiConstants::minHeight,
|
|
|
|
GuiConstants::maxWidth,
|
|
|
|
GuiConstants::maxHeight);
|
2018-02-27 08:25:20 +08:00
|
|
|
|
2019-07-07 07:22:47 +08:00
|
|
|
setSize(sharedParams.getUiWidth(), sharedParams.getUiHeight());
|
2018-03-19 07:35:29 +08:00
|
|
|
|
2018-04-10 07:11:22 +08:00
|
|
|
// processor.subscribeToStateChanges(this);
|
2018-02-27 08:25:20 +08:00
|
|
|
|
|
|
|
midiKeyboard.setName ("MIDI Keyboard");
|
|
|
|
|
|
|
|
midiKeyboard.setWantsKeyboardFocus(false);
|
|
|
|
tablesComponent.setWantsKeyboardFocus(false);
|
|
|
|
|
|
|
|
setWantsKeyboardFocus(true);
|
|
|
|
addAndMakeVisible (midiKeyboard);
|
|
|
|
|
2019-06-30 17:59:07 +08:00
|
|
|
addAndMakeVisible(slidersComponent);
|
2018-02-27 08:25:20 +08:00
|
|
|
addAndMakeVisible(tablesComponent);
|
|
|
|
addAndMakeVisible(filePicker);
|
2019-06-30 17:59:07 +08:00
|
|
|
|
2018-02-27 08:17:12 +08:00
|
|
|
}
|
|
|
|
|
2018-02-28 07:34:22 +08:00
|
|
|
JuicySFAudioProcessorEditor::~JuicySFAudioProcessorEditor()
|
2018-02-27 08:17:12 +08:00
|
|
|
{
|
2018-04-10 07:11:22 +08:00
|
|
|
// processor.unsubscribeFromStateChanges(this);
|
2018-03-19 07:35:29 +08:00
|
|
|
}
|
|
|
|
|
2018-04-10 07:11:22 +08:00
|
|
|
//void JuicySFAudioProcessorEditor::getStateInformation (XmlElement& xml) {
|
|
|
|
// // save
|
|
|
|
// xml.setAttribute ("uiWidth", getWidth());
|
|
|
|
// xml.setAttribute ("uiHeight", getHeight());
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void JuicySFAudioProcessorEditor::setStateInformation (XmlElement* xmlState) {
|
|
|
|
// // load
|
|
|
|
// setSize (xmlState->getIntAttribute ("uiWidth", getWidth()),
|
|
|
|
// xmlState->getIntAttribute ("uiHeight", getHeight()));
|
|
|
|
//}
|
2018-02-27 08:17:12 +08:00
|
|
|
|
|
|
|
//==============================================================================
|
2018-02-28 07:34:22 +08:00
|
|
|
void JuicySFAudioProcessorEditor::paint (Graphics& g)
|
2018-02-27 08:17:12 +08:00
|
|
|
{
|
|
|
|
// (Our component is opaque, so we must completely fill the background with a solid colour)
|
|
|
|
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
|
|
|
|
|
2018-02-27 08:25:20 +08:00
|
|
|
// g.setColour (Colours::white);
|
|
|
|
// g.setFont (15.0f);
|
|
|
|
// g.drawFittedText ("Hello World!", getLocalBounds(), Justification::centred, 1);
|
|
|
|
|
|
|
|
if (!focusInitialized) {
|
|
|
|
if (!hasKeyboardFocus(false) && isVisible()) {
|
|
|
|
grabKeyboardFocus();
|
|
|
|
}
|
|
|
|
if (getCurrentlyFocusedComponent() == this) {
|
|
|
|
focusInitialized = true;
|
|
|
|
}
|
|
|
|
}
|
2018-02-27 08:17:12 +08:00
|
|
|
}
|
|
|
|
|
2018-02-28 07:34:22 +08:00
|
|
|
void JuicySFAudioProcessorEditor::resized()
|
2018-02-27 08:17:12 +08:00
|
|
|
{
|
2019-06-30 17:59:07 +08:00
|
|
|
const int padding{8};
|
|
|
|
const int pianoHeight{70};
|
|
|
|
const int filePickerHeight{25};
|
2019-07-01 04:40:24 +08:00
|
|
|
// const int slidersHeight{150};
|
2019-06-30 18:39:39 +08:00
|
|
|
Rectangle<int> r{getLocalBounds()};
|
2018-02-27 08:25:20 +08:00
|
|
|
filePicker.setBounds(r.removeFromTop(filePickerHeight + padding).reduced(padding, 0).withTrimmedTop(padding));
|
2019-06-30 17:59:07 +08:00
|
|
|
|
|
|
|
// Rectangle<int> r2 (getLocalBounds());
|
|
|
|
// slidersComponent.setBounds(r2.removeFromLeft(filePickerWidth + padding).reduced(padding, 0).withTrimmedLeft(padding));
|
|
|
|
|
2018-02-27 08:25:20 +08:00
|
|
|
midiKeyboard.setBounds (r.removeFromBottom (pianoHeight).reduced(padding, 0));
|
2019-06-30 18:39:39 +08:00
|
|
|
|
|
|
|
Rectangle<int> rContent{r.reduced(0, padding)};
|
|
|
|
slidersComponent.setBounds(rContent.removeFromRight(slidersComponent.getDesiredWidth() + padding).withTrimmedRight(padding));
|
|
|
|
|
|
|
|
tablesComponent.setBounds(rContent);
|
|
|
|
|
2019-07-07 07:22:47 +08:00
|
|
|
sharedParams.setUiWidth(getWidth());
|
|
|
|
sharedParams.setUiHeight(getHeight());
|
2018-04-10 07:11:22 +08:00
|
|
|
|
2018-02-27 08:25:20 +08:00
|
|
|
// Rectangle<int> r2 (getLocalBounds());
|
|
|
|
// r2.reduce(0, padding);
|
|
|
|
// r2.removeFromBottom(pianoHeight);
|
|
|
|
// r2.removeFromTop(filePickerHeight);
|
|
|
|
// tablesComponent.setBounds (r2);
|
|
|
|
//
|
|
|
|
// Rectangle<int> r3 (getLocalBounds());
|
|
|
|
// r3.removeFromTop(filePickerHeight);
|
|
|
|
//
|
|
|
|
// filePicker.setBounds(r3);
|
2018-02-27 08:17:12 +08:00
|
|
|
}
|
2018-02-27 08:25:20 +08:00
|
|
|
|
2018-02-28 07:34:22 +08:00
|
|
|
bool JuicySFAudioProcessorEditor::keyPressed(const KeyPress &key) {
|
2018-02-27 08:25:20 +08:00
|
|
|
// if (!hasKeyboardFocus(false))
|
|
|
|
// return false;
|
|
|
|
// if (key.getKeyCode() == KeyPress::upKey){
|
|
|
|
// }
|
|
|
|
// cout << "hey\n";
|
|
|
|
const int cursorKeys[] = {
|
|
|
|
KeyPress::leftKey,
|
|
|
|
KeyPress::rightKey,
|
|
|
|
KeyPress::upKey,
|
|
|
|
KeyPress::downKey
|
|
|
|
};
|
|
|
|
if (any_of(
|
|
|
|
begin(cursorKeys),
|
|
|
|
end(cursorKeys),
|
|
|
|
[&](int i) { return i == key.getKeyCode(); }
|
|
|
|
)) {
|
|
|
|
return tablesComponent.keyPressed(key);
|
|
|
|
} else {
|
|
|
|
return midiKeyboard.keyPressed(key);
|
|
|
|
}
|
|
|
|
// for(auto childComponent : getChildren()) {
|
|
|
|
// if (childComponent->keyPressed(key)) return true;
|
|
|
|
// }
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-02-28 07:34:22 +08:00
|
|
|
bool JuicySFAudioProcessorEditor::keyStateChanged (bool isKeyDown) {
|
2018-02-27 08:25:20 +08:00
|
|
|
return midiKeyboard.keyStateChanged(isKeyDown);
|
|
|
|
// for(auto childComponent : getChildren()) {
|
|
|
|
// if (childComponent->keyStateChanged(isKeyDown)) return true;
|
|
|
|
// }
|
|
|
|
// return false;
|
2018-03-19 07:35:29 +08:00
|
|
|
}
|
2018-04-11 07:08:15 +08:00
|
|
|
|
2018-04-11 07:52:44 +08:00
|
|
|
FilePickerFragment& JuicySFAudioProcessorEditor::getFilePicker() {
|
|
|
|
return filePicker;
|
2019-07-02 06:55:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SlidersFragment& JuicySFAudioProcessorEditor::getSliders() {
|
|
|
|
return slidersComponent;
|
2019-07-03 06:27:56 +08:00
|
|
|
}
|