2
0
Fork 0

Merge pull request #39 from reales/development

Development
This commit is contained in:
reales 2020-12-13 19:10:21 +01:00 committed by GitHub
commit a4fcb10e10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 107 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View file

@ -23,6 +23,23 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil
banks (processor.getBankFiles())
{
// skinFolder = ownerFilter.getCurrentSkinFolder(); // initialized above
commandManager.registerAllCommandsForTarget(this);
commandManager.setFirstCommandTarget(this);
// reset KeyPressMappingSet
commandManager.getKeyMappings()->resetToDefaultMappings();
// having set up the default key-mappings, you might now want to load the last set
// of mappings that the user configured.
//commandManager.getKeyMappings()->restoreFromXml(lastSavedKeyMappingsXML);
// Now tell our top-level window to send any keypresses that arrive to the
// KeyPressMappingSet, which will use them to invoke the appropriate commands.
//addKeyListener(commandManager.getKeyMappings());
getTopLevelComponent()->addKeyListener (commandManager.getKeyMappings());
//Timer::callAfterDelay (100, [this] { this->grabKeyboardFocus(); }); // ensure that key presses are sent to the KeyPressTarget object
startTimer(100);
loadSkin (processor);
repaint();
@ -47,9 +64,15 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
return;
}
//if (coords.createInputStream())
XmlDocument skin (coords);
auto doc = skin.getDocumentElement();
if (doc) {
if (!doc) {
notLoadSkin = true;
setSize (1440, 450);
}
else {
if (doc->getTagName() == "PROPERTIES"){
@ -483,7 +506,7 @@ void ObxdAudioProcessorEditor::updateFromHost() {
}
// Set to unlearn to false
if ( midiUnlearnButton->getToggleState()) {
if ( midiUnlearnButton && midiUnlearnButton->getToggleState()) {
midiUnlearnButton->setToggleState(false, NotificationType:: sendNotification);
}
@ -511,7 +534,7 @@ void ObxdAudioProcessorEditor::paint(Graphics& g)
const File mainFile(skinFolder.getChildFile("main@2x.png"));
#endif
if (skinFolder.exists() && mainFile.exists())
if (!notLoadSkin && skinFolder.exists() && mainFile.exists())
{
const Image image = ImageCache::getFromFile(mainFile);

View file

@ -18,7 +18,14 @@
#include "Gui/TooglableButton.h"
#include "Gui/ButtonList.h"
enum KeyPressCommandIDs
{
buttonNextProgram = 1,
buttonPrevProgram,
buttonPadNextProgram,
buttonPadPrevProgram,
};
//==============================================================================
/**
*/
@ -28,6 +35,9 @@ class ObxdAudioProcessorEditor : public AudioProcessorEditor
// , public Slider::Listener
, public Button::Listener
// , public ComboBox::Listener
, public ApplicationCommandTarget
, public Timer
{
public:
ObxdAudioProcessorEditor(ObxdAudioProcessor& ownerFilter);
@ -42,7 +52,73 @@ public:
//==============================================================================
void changeListenerCallback (ChangeBroadcaster* source) override;
void buttonClicked (Button *) override;
//bool keyPressed(const KeyPress & press) override;
void timerCallback() override {
this->grabKeyboardFocus();
}
ApplicationCommandTarget* getNextCommandTarget() override {
return nullptr;
};
void getAllCommands (Array<CommandID>& commands) override {
Array<CommandID> ids { KeyPressCommandIDs::buttonNextProgram, KeyPressCommandIDs::buttonPrevProgram,
KeyPressCommandIDs::buttonPadNextProgram, KeyPressCommandIDs::buttonPadPrevProgram
};
commands.addArray (ids);
};
void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result) override {
switch (commandID)
{
case KeyPressCommandIDs::buttonNextProgram:
result.setInfo ("Move up", "Move the button + ", "Button", 0);
result.addDefaultKeypress ('+', 0);
result.setActive (true);
break;
case KeyPressCommandIDs::buttonPrevProgram:
result.setInfo ("Move right", "Move the button - ", "Button", 0);
result.addDefaultKeypress ('-', 0);
result.setActive (true);
break;
case KeyPressCommandIDs::buttonPadNextProgram:
result.setInfo ("Move down", "Move the button Pad + ", "Button", 0);
result.addDefaultKeypress (KeyPress::numberPadAdd, 0);
result.setActive (true);
break;
case KeyPressCommandIDs::buttonPadPrevProgram:
result.setInfo ("Move left", "Move the button Pad -", "Button", 0);
result.addDefaultKeypress (KeyPress::numberPadSubtract, 0);
result.setActive (true);
break;
default:
break;
}
};
bool perform (const InvocationInfo& info) override {
switch (info.commandID)
{
case KeyPressCommandIDs::buttonNextProgram:
case KeyPressCommandIDs::buttonPadNextProgram:
nextProgram();
break;
case KeyPressCommandIDs::buttonPrevProgram:
case KeyPressCommandIDs::buttonPadPrevProgram:
prevProgram();
break;
default:
return false;
}
return true;
};/*
bool keyPressed (const KeyPress& key,
Component* originatingComponent) override {
DBG("--- " << key.getKeyCode());
};*/
void nextProgram();
void prevProgram();
private:
Knob* addKnob (int x, int y, int d, ObxdAudioProcessor& filter, int parameter, String name, float defval);
void placeLabel (int x, int y, String text);
@ -143,11 +219,15 @@ private:
OwnedArray<PopupMenu> popupMenus;
bool notLoadSkin = false;
int progStart;
int bankStart;
int skinStart;
Array<File> skins;
Array<File> banks;
// Command manager
ApplicationCommandManager commandManager;
};
#endif // PLUGINEDITOR_H_INCLUDED