set displayed filepath when loading in state
This commit is contained in:
parent
114bb2f10a
commit
e8177d51cd
|
@ -235,7 +235,9 @@
|
|||
560D40E30164CA9D05C6AC3B /* MyColours.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MyColours.h; path = ../../Source/MyColours.h; sourceTree = SOURCE_ROOT; };
|
||||
571BC08FE42BABE3BAF364C8 /* Info-AUv3_AppExtension.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-AUv3_AppExtension.plist"; sourceTree = SOURCE_ROOT; };
|
||||
596723D094319DA06FDDCDC6 /* StateChangeSubscriber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StateChangeSubscriber.h; path = ../../Source/StateChangeSubscriber.h; sourceTree = "<group>"; };
|
||||
596725F7ACCE2D50FCEC1981 /* ExposesComponents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExposesComponents.h; path = ../../Source/ExposesComponents.h; sourceTree = "<group>"; };
|
||||
59672C6315E5D06A21B4A2F2 /* SharesParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SharesParams.h; path = ../../Source/SharesParams.h; sourceTree = "<group>"; };
|
||||
59672DE3D2595F1C3D7189CB /* FilePickerFragment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FilePickerFragment.h; path = ../../Source/FilePickerFragment.h; sourceTree = "<group>"; };
|
||||
5B3CBC48DAB08EDF53CEE609 /* include_juce_audio_plugin_client_VST3.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = include_juce_audio_plugin_client_VST3.cpp; path = ../../JuceLibraryCode/include_juce_audio_plugin_client_VST3.cpp; sourceTree = SOURCE_ROOT; };
|
||||
5BC90F629770BCF4193FABDD /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
|
||||
63942F8053F1E4E72C1BE98C /* FilePicker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = FilePicker.cpp; path = ../../Source/FilePicker.cpp; sourceTree = SOURCE_ROOT; };
|
||||
|
@ -557,6 +559,8 @@
|
|||
B3E8D1BE528BBA1B6004672E /* PluginEditor.h */,
|
||||
596723D094319DA06FDDCDC6 /* StateChangeSubscriber.h */,
|
||||
59672C6315E5D06A21B4A2F2 /* SharesParams.h */,
|
||||
596725F7ACCE2D50FCEC1981 /* ExposesComponents.h */,
|
||||
59672DE3D2595F1C3D7189CB /* FilePickerFragment.h */,
|
||||
);
|
||||
name = Source;
|
||||
sourceTree = "<group>";
|
||||
|
|
16
Source/ExposesComponents.h
Normal file
16
Source/ExposesComponents.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// Created by Alex Birch on 11/04/2018.
|
||||
// Copyright (c) 2018 Birchlabs. All rights reserved.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#import "FilePickerFragment.h"
|
||||
|
||||
class ExposesComponents {
|
||||
public:
|
||||
virtual ~ExposesComponents() {}
|
||||
|
||||
virtual FilePickerFragment& getFilePicker() = 0;
|
||||
|
||||
};
|
|
@ -18,14 +18,12 @@ FilePicker::FilePicker(
|
|||
String(),
|
||||
"Choose a Soundfont file to load into the synthesizer"
|
||||
),
|
||||
fluidSynthModel(fluidSynthModel) {
|
||||
fluidSynthModel(fluidSynthModel),
|
||||
currentPath() {
|
||||
// faster (rounded edges introduce transparency)
|
||||
setOpaque (true);
|
||||
|
||||
const String& currentSoundFontAbsPath = fluidSynthModel->getCurrentSoundFontAbsPath();
|
||||
if (currentSoundFontAbsPath.isNotEmpty()) {
|
||||
fileChooser.setCurrentFile(File(currentSoundFontAbsPath), true, dontSendNotification);
|
||||
}
|
||||
setDisplayedFilePath(fluidSynthModel->getCurrentSoundFontAbsPath());
|
||||
|
||||
addAndMakeVisible (fileChooser);
|
||||
fileChooser.addListener (this);
|
||||
|
@ -48,5 +46,24 @@ void FilePicker::paint(Graphics& g)
|
|||
}
|
||||
|
||||
void FilePicker::filenameComponentChanged (FilenameComponent*) {
|
||||
currentPath = fileChooser.getCurrentFile().getFullPathName();
|
||||
fluidSynthModel->onFileNameChanged(fileChooser.getCurrentFile().getFullPathName());
|
||||
}
|
||||
|
||||
void FilePicker::setDisplayedFilePath(const String& path) {
|
||||
if (!shouldChangeDisplayedFilePath(path)) {
|
||||
return;
|
||||
}
|
||||
currentPath = path;
|
||||
fileChooser.setCurrentFile(File(path), true, dontSendNotification);
|
||||
}
|
||||
|
||||
bool FilePicker::shouldChangeDisplayedFilePath(const String &path) {
|
||||
if (path.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (path == currentPath) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
|
@ -6,8 +6,10 @@
|
|||
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
#include "FluidSynthModel.h"
|
||||
#import "FilePickerFragment.h"
|
||||
|
||||
class FilePicker: public Component,
|
||||
public FilePickerFragment,
|
||||
private FilenameComponentListener
|
||||
{
|
||||
public:
|
||||
|
@ -18,12 +20,18 @@ public:
|
|||
|
||||
void resized() override;
|
||||
void paint (Graphics& g) override;
|
||||
|
||||
virtual void setDisplayedFilePath(const String&) override;
|
||||
private:
|
||||
FilenameComponent fileChooser;
|
||||
|
||||
FluidSynthModel* fluidSynthModel;
|
||||
|
||||
String currentPath;
|
||||
|
||||
void filenameComponentChanged (FilenameComponent*) override;
|
||||
|
||||
bool shouldChangeDisplayedFilePath(const String &path);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FilePicker)
|
||||
};
|
14
Source/FilePickerFragment.h
Normal file
14
Source/FilePickerFragment.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Created by Alex Birch on 11/04/2018.
|
||||
// Copyright (c) 2018 Birchlabs. All rights reserved.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
|
||||
class FilePickerFragment {
|
||||
public:
|
||||
virtual ~FilePickerFragment() {}
|
||||
|
||||
virtual void setDisplayedFilePath(const String&) = 0;
|
||||
};
|
|
@ -135,6 +135,6 @@ bool JuicySFAudioProcessorEditor::keyStateChanged (bool isKeyDown) {
|
|||
// return false;
|
||||
}
|
||||
|
||||
const FilePicker& JuicySFAudioProcessorEditor::getFilePicker() {
|
||||
|
||||
FilePickerFragment& JuicySFAudioProcessorEditor::getFilePicker() {
|
||||
return filePicker;
|
||||
}
|
|
@ -14,13 +14,16 @@
|
|||
#include "PluginProcessor.h"
|
||||
#include "TablesComponent.h"
|
||||
#include "SurjectiveMidiKeyboardComponent.h"
|
||||
#include "FilePickerFragment.h"
|
||||
#include "ExposesComponents.h"
|
||||
#include "FilePicker.h"
|
||||
#include "StateChangeSubscriber.h"
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
*/
|
||||
class JuicySFAudioProcessorEditor : public AudioProcessorEditor/*,
|
||||
class JuicySFAudioProcessorEditor : public AudioProcessorEditor,
|
||||
public ExposesComponents/*,
|
||||
public StateChangeSubscriber*/
|
||||
{
|
||||
public:
|
||||
|
@ -37,7 +40,7 @@ public:
|
|||
// void getStateInformation (XmlElement& xml) override;
|
||||
// void setStateInformation (XmlElement* xmlState) override;
|
||||
|
||||
const FilePicker& getFilePicker();
|
||||
virtual FilePickerFragment& getFilePicker() override;
|
||||
|
||||
private:
|
||||
// This reference is provided as a quick way for your editor to
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "PluginEditor.h"
|
||||
#include "SoundfontSynthVoice.h"
|
||||
#include "SoundfontSynthSound.h"
|
||||
#include "ExposesComponents.h"
|
||||
|
||||
AudioProcessor* JUCE_CALLTYPE createPluginFilter();
|
||||
|
||||
|
@ -241,6 +242,10 @@ void JuicySFAudioProcessor::setStateInformation (const void* data, int sizeInByt
|
|||
AudioProcessorEditor* editor = getActiveEditor();
|
||||
if (editor != nullptr) {
|
||||
editor->setSize(lastUIWidth, lastUIHeight);
|
||||
|
||||
jassert(dynamic_cast<ExposesComponents*> (editor) != nullptr);
|
||||
ExposesComponents* exposesComponents = dynamic_cast<ExposesComponents*> (editor);
|
||||
exposesComponents->getFilePicker().setDisplayedFilePath(soundFontPath);
|
||||
}
|
||||
|
||||
// const String& currentSoundFontAbsPath = fluidSynthModel->getCurrentSoundFontAbsPath();
|
||||
|
|
Loading…
Reference in New Issue
Block a user