|
04-26-2017, 01:45 AM
|
#1
|
Human being with feelings
Join Date: Apr 2014
Posts: 42
|
IFileSelectorControl: window doesn't come up if I set file
For the purpose of having a default file opened at startup, I pass a path to IFileSelectorControl::SetLastSelectedFileFromPlug( path) in the plugin constructor. The file (a WAVE file) is located in the path of the plugin, so it is retrieved by appending the name of the file to GetGUI()->PluginPath(ref). However, when doing this, the windows file browser doesn't come up anymore when the button associated with the IFileSelectorControl is clicked. SetLastSelectedFileFromPlug seem to only set the mFile member of the control, so I am very unsure as to what might be causing this behaviour. Any thoughts?
|
|
|
04-26-2017, 02:06 PM
|
#2
|
Human being with feelings
Join Date: Mar 2017
Location: Littleton, CO USA
Posts: 22
|
Can you post your code please?
|
|
|
04-26-2017, 03:18 PM
|
#3
|
Human being with feelings
Join Date: Apr 2014
Posts: 42
|
I'm not sure how to format code here but here it comes:
in the plugin's constructor i set mFile (in IFileSelector) through the provided method:
WDL_String path;
GetGUI()->PluginPath(&path);
path.Append("/arp (1).wav");
mFileDialog->SetLastSelectedFileFromPlug(path.Get());
in OnParamChange:
(...)
mFileDialog->GetLastSelectedFileForPlug(&a_path);
mExciter.loadAudioFromFile(&a_path); (irrelevant)
I don't get any errors, and the method after GetLastSelectedFileForPlug is called even though the windows file browser doesn't come up. Note that the file browser does come up if I don't set mFile beforehand as in the first block of code. Maybe I'm just using the control in a way it isn't supposed to be used?
EDIT: spelling
|
|
|
04-26-2017, 07:14 PM
|
#4
|
Human being with feelings
Join Date: Mar 2017
Location: Littleton, CO USA
Posts: 22
|
Am I correct in that you want the plugin to open a file dialog at start that has a specific .wav file selected? If so is the dialog instantiated so that the end user can select a different .wav file that the default if they choose?
|
|
|
04-27-2017, 01:48 AM
|
#5
|
Human being with feelings
Join Date: Apr 2014
Posts: 42
|
Hmm, no, I would like to just load a default wave file (this might be tied to a preset system in the future, but as of now I just want to make it work with simple methods to test the important part of the plugin, the DSP ).
I can see why you'd think so as I'm relying on the EParam associated with IFileSelectorControl to show up in OnParamChange's switch statement, to actually load the file. This is just (what I thought would be) a convenient shortcut. I suspect this "shortcut" thing isn't working so well.
So, to recap, at startup I just want to load a wave file, without the dialog popping up. But after that, the user can click on a load button and choose whatever supported audio file they want. Problem is, the dialog doesn't pop up when clicking this load button if, and only if, I've called IFileSelectorControl::SetLastSelectedFileFromPlug( ) beforehand (in my case, in the plugins constructor).
|
|
|
04-27-2017, 11:14 AM
|
#6
|
Human being with feelings
Join Date: Mar 2017
Location: Littleton, CO USA
Posts: 22
|
If it were me I would load the file using standard file code and only use the IFileSelectorControl when needed. I have experienced a ton of issues with IFileSelectorControl when doing cross-platform with OSX, so I don't use it. I use this instead and have had good luck with it: https://sourceforge.net/projects/tinyfiledialogs/
|
|
|
04-27-2017, 11:56 AM
|
#7
|
Human being with feelings
Join Date: Apr 2014
Posts: 42
|
Quote:
Originally Posted by michaelwayneharwood
If it were me I would load the file using standard file code and only use the IFileSelectorControl when needed. I have experienced a ton of issues with IFileSelectorControl when doing cross-platform with OSX, so I don't use it. I use this instead and have had good luck with it: https://sourceforge.net/projects/tinyfiledialogs/
|
Thanks for the tip! I'm always a little skeptical bringing in outside code in an existing library, but that seems simple and self contained enough so I might give it a try. Hadn't thought about portability issues either. What's your experience using tiny file dialogs in wdl-ol? Any quirks I should be aware of?
It might be intresting for posterity to consider this thread still open, even if I go with tiny file dialogs since my original problem isn't really solved. So if someone has other thoughts, feel welcome to chime in.
|
|
|
04-27-2017, 12:38 PM
|
#8
|
Human being with feelings
Join Date: Mar 2017
Location: Littleton, CO USA
Posts: 22
|
I was hesitant as well, but it works very well.
What I did what to include the header file, and use the functions as provided. Here's a few code snippets from a plugin I am working on. I am using an IInvisibleSwitchControl as my "button", though you could do it in any number of ways...
Code:
#include "tinyfiledialogs.h"
...
in void TestFileDialog::OnParamChange(int paramIdx):
char const * sclfilename;
char const * lFilterPatterns[2] = { "*.scl", "*." };
sclfilename = tinyfd_openFileDialog("Open SCL File", "", 2, lFilterPatterns, "SCALA Scale Files", 0);
Let me know if this is not clear and I will code up a quick example and attach a .zip to this thread.
|
|
|
04-28-2017, 02:20 AM
|
#9
|
Human being with feelings
Join Date: Apr 2014
Posts: 42
|
I've now implemented a file selector with tiny file dialogs and it works like a charm. Thank you again for the great tip! I might use this in many other projects.
|
|
|
04-28-2017, 09:33 AM
|
#10
|
Human being with feelings
Join Date: Mar 2017
Location: Littleton, CO USA
Posts: 22
|
You are very welcome! I am glad my small contribution helped!
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 10:18 PM.
|