COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 04-26-2017, 01:45 AM   #1
Antonio the carver
Human being with feelings
 
Join Date: Apr 2014
Posts: 42
Default 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?
Antonio the carver is offline   Reply With Quote
Old 04-26-2017, 02:06 PM   #2
michaelwayneharwood
Human being with feelings
 
Join Date: Mar 2017
Location: Littleton, CO USA
Posts: 22
Default

Can you post your code please?
michaelwayneharwood is offline   Reply With Quote
Old 04-26-2017, 03:18 PM   #3
Antonio the carver
Human being with feelings
 
Join Date: Apr 2014
Posts: 42
Default

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
Antonio the carver is offline   Reply With Quote
Old 04-26-2017, 07:14 PM   #4
michaelwayneharwood
Human being with feelings
 
Join Date: Mar 2017
Location: Littleton, CO USA
Posts: 22
Default

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?
michaelwayneharwood is offline   Reply With Quote
Old 04-27-2017, 01:48 AM   #5
Antonio the carver
Human being with feelings
 
Join Date: Apr 2014
Posts: 42
Default

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).
Antonio the carver is offline   Reply With Quote
Old 04-27-2017, 11:14 AM   #6
michaelwayneharwood
Human being with feelings
 
Join Date: Mar 2017
Location: Littleton, CO USA
Posts: 22
Default

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/
michaelwayneharwood is offline   Reply With Quote
Old 04-27-2017, 11:56 AM   #7
Antonio the carver
Human being with feelings
 
Join Date: Apr 2014
Posts: 42
Default

Quote:
Originally Posted by michaelwayneharwood View Post
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.
Antonio the carver is offline   Reply With Quote
Old 04-27-2017, 12:38 PM   #8
michaelwayneharwood
Human being with feelings
 
Join Date: Mar 2017
Location: Littleton, CO USA
Posts: 22
Default

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.
michaelwayneharwood is offline   Reply With Quote
Old 04-28-2017, 02:20 AM   #9
Antonio the carver
Human being with feelings
 
Join Date: Apr 2014
Posts: 42
Default

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.
Antonio the carver is offline   Reply With Quote
Old 04-28-2017, 09:33 AM   #10
michaelwayneharwood
Human being with feelings
 
Join Date: Mar 2017
Location: Littleton, CO USA
Posts: 22
Default

You are very welcome! I am glad my small contribution helped!
michaelwayneharwood is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:18 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.