[feature request] Preset Browser broadcasters
-
@d-healey that should be doable - I could make an API that attaches random properties to the event JSON object then you can query it in the mouse event callback.
-
@Christoph-Hart could we also get scriptable callbacks for all the preset buttons please pretty please? So we can use their functionality outside of the preset browser.
-
@DanH nah thats super difficult to setup
-
@DanH You should be able to achieve the same effect with broadcasters once Christoph implements it.
-
@d-healey Alright, it's pushed. The system is fairly easy to use so you should be able to extend it yourself instead of nagging me :)
Just subclass any component you want to attach more properties to from
hise::ComponentWithAdditionalMouseProperties
, then define avoid attachAdditionalMouseProperties(const MouseEvent& e, var& obj);
method where you can add more stuff to the
obj
JSON (you can query the component that's been clicked on withe.eventComponent
). -
@d-healey even if I’m not clicking inside the preset browser?
-
@Christoph-Hart Thank you!
even if I’m not clicking inside the preset browser?
No but then how would that work for a control callback?
-
@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.