[feature request] Preset Browser broadcasters
-
@Christoph-Hart This commit is segfaulting when I open my project. Getting some preset handler errors
JUCE Assertion failure in PresetHandler.cpp:2820 JUCE Assertion failure in PresetHandler.cpp:2891 JUCE Assertion failure in PresetHandler.cpp:2690 JUCE Assertion failure in PresetHandler.cpp:2820 JUCE Assertion failure in PresetHandler.cpp:2891 JUCE Assertion failure in PresetHandler.cpp:2690
If I make a new project with a preset browser it works but seeing these errors on exit.
*** Leaked objects detected: 1 instance(s) of class SafeChangeBroadcaster JUCE Assertion failure in juce_LeakedObjectDetector.h:92 *** Leaked objects detected: 1 instance(s) of class AsyncBroadcaster JUCE Assertion failure in juce_LeakedObjectDetector.h:92 *** Leaked objects detected: 1 instance(s) of class DynamicObject JUCE Assertion failure in juce_LeakedObjectDetector.h:92 *** Leaked objects detected: 1 instance(s) of class AudioBuffer JUCE Assertion failure in juce_LeakedObjectDetector.h:92 *** Leaked objects detected: 1 instance(s) of class AsyncUpdater JUCE Assertion failure in juce_LeakedObjectDetector.h:92
Edit: Seems the segfault is unrelated to those preset handler assertions. I think it's caused by the hydra tabs fix. When I remove my
editorData.json
file HISE loads up no problem. -
@d-healey crossed wires I think - I just want the brower's functionality (so save, new, import etc) to be available outside of the browser window, so we can have the equivalent buttons wherever we like on the ui.
-
@DanH There should be enough API calls to create, save and import user presets using the file API.
-
@Christoph-Hart I think I was getting the segfault because my ScriptEditors were missing the new
ScriptFile
tag. I've added this into the XML and HISE is opening now. -
A little example for anyone who wants to use this.
fltPresetBrowser
is the id of my preset browser floating tile.// Broadcaster const bc = Engine.createBroadcaster({"id": "PresetBrowser", "args": [component, obj]}); bc.attachToComponentMouseEvents(["fltPresetBrowser"], "Clicks Only", ""); bc.addListener("mouseAction", "Mouse action for preset browser", function(component, obj) { Console.print(trace(obj)); });
-
I've added a couple of properties:
int selectedRow = lb->getSelectedRow(); String file = column->getFileForIndex(rowNumber).getFileName();
For file I had to add the
getFileForIndex()
function inpresetBrowserComponents.h
.This works, but what I'd really like is for the file to actually be the file object instead of a filename/path. But when I try that I get an error:
error: cannot convert ‘juce::File’ to ‘const juce::var&’ 955 | dyn->setProperty("file", file); | ^~~~ | | | juce::File
Any idea how I can handle the conversion?
-
@d-healey the preset browser can't create scripting file objects (also the JSON object should only contain Strings or primitive values), but if you use
File::getFullPathName()
you can create a file object withFileSystem.fromAbsolutePath()
in your script function. -
@Christoph-Hart Ah that's a good idea, thanks for the explanation.
-
@Christoph-Hart
bool selected = lb->isRowSelected(rowNumber);
is always returning true, even for the expansion column, any suggestion? -
@d-healey well after you clicked on it, it‘s selected, no?
-
@Christoph-Hart Not for the expansions column, you can click again to deselect
-
@d-healey didn't we discuss having a 'Factory' folder in the Expansions column so users could navigate back to the 'Factory' presets rather than clicking the expansion name again?
-
@DanH Yeah that's another way to do it. But in my case I don't want any factory presets.
-
Actually I'm not sure if the juce::ListBox class can have a "deselect" action, so you would need to hack around in there.
-
@Christoph-Hart I think I'll just track the selected index in my script and if the index is the same as the last index I know it's been deselected :)
-
Am I being silly or is the favourite button stateAha! It triggers on mouse up not mouse down :)obj.buttonState
inverted?