Insert instead of replace
-
@MikeB You might use external .js files for that (globally or locally), so you can share them easily. Though if you don't think about GUI only but also modules this might be trickier to implement...
-
@ustk I already do that - always, but as you said, only the content of the .js file can be transferred, not the elements used in the file.
However, if I could insert a snippet into my project in its own namespace* "Snippet", for example, it would save a lot of time.
*Of course, any similarities in the names of variables or elements would have to be ensured by encapsulating the code used.
-
@MikeB You can create factory scripts to add ui components and modules. I do this to build reusable project templates so I don't have to keep rebuilding the same UI elements over and over for different projects.
-
-
@ustk No it's painful for me too :p but it's a one time job.
All of my instruments that I'm working on have basically the same interface. So I built it once using the usual tools (interface designer, etc.). Then I spent a day writing a script that would do exactly the same thing.
Now when I start a new project I run the script and my interface is built. Then I remove the script because it's no longer needed in the project.
Here's the script (or an old version of it) - https://github.com/davidhealey/LibreWaveBoilerplate/blob/master/UIFactory.js
-
@d-healey said in Insert instead of replace:
Then I remove the script because it's no longer needed in the project.
I imagine that's why you seem to be relying a lot on
getComponent()
, clever -
@d-healey Thanks Dave - but unfortunately I can't get your script to work!
No error is reported - it just does nothing.
A video?
-
@MikeB You don't want to use my script, that is just an example (unless your project has the same UI as mine).
I'm creating a UI using scripting instead of using the interface designer (but once the UI is created I remove the extra script and do further work in the UI designer).
There is nothing special here, these are the same functions you'll be using in your secondary (non-main interface) scripts to build those UIs.
-
@d-healey No - I don't want to use your UI. I just wanted to understand the function.
I understand the principle of how it works.
Do you have a current snippet? -
@MikeB I don't have a snippet that would make it any clearer. Add the script via include, then call the createShell function.
-
In most cases, I directly use the below method to create UI controls. Every UI property can be set inside the JSON data.
This way, no need to repeat the process again and just copying / pasting the code will create the UI control quickly.
After creating the UI controls, you can also delete the code and go on with the interface designer too
addPanel
,addKnob
,addButton
,addComboBox
,addFloatingTile
...etc.// Create Panel ------------------------------------ const var Panel1 = Content.addPanel("Panel1", 10, 10); Content.setPropertiesFromJSON("Panel1", { "width": 230, "height": 220, "borderRadius": 0.0, "borderSize": 2.0, "bgColour": 0, "itemColour": 0, "itemColour2": 0, "textColour": 0x550095FE, }); // Create Knob ------------------------------------ const var TheKnob1 = Content.addKnob("TheKnob1", 30, 40); Content.setPropertiesFromJSON("TheKnob1", { "text": "The Knob1", "tooltip": "This is the tooltip", "isPluginParameter": true, "pluginParameterName": "The Knob One", "isMetaParameter": true, "useUndoManager": true, "width": 161.0, "height": 45.0, "parentComponent": "Panel1", "min": -1.0, "middlePosition": 0.0, "stepSize": "0.1" }); // Create Button ------------------------------------ const var Button1 = Content.addButton("Button1", 50, 120); Content.setPropertiesFromJSON("Button1", { "parentComponent": "Panel1", "isPluginParameter": true, "isMetaParameter": true, "tooltip": "The Button 1 tooltip", "useUndoManager": true, "pluginParameterName": "The Button One", "isMomentary": false, "textColour": 0xFFFF3F3F, "bgColour": 0x55F83F3F });
HiseSnippet 1299.3ocsW0raaaDDdorYPjZRfCPaOVPnSJ.1NRxVoosnPt9GU3lZagH6fbKXM4JqElbWBxkIV0H.8knGxs9lzGf9DTfdtm6wdptyvk+JKoHKfxDCH9Myr6ry7MyrrefzlEFJCHFUOcrOiX7.yAiEpQ6MhxEjC2mX7HyingJVfkFZ2w9zvPlCwvXkuGALptJI94u6tK0kJrY4PDxqjba1Ox83pbz967BtqaOpC6TtWAs2dmCskh8jtxHveVwrIwmZeI8B1wTTsJlDi6cfCWICFnnJVHnytRmwCFIemPq+q3g7ycY3KsHCfERCS1aD20oe5YMjPLVse9IeE8I+SMOh6vyvyi.qEKvJ2hhw.iJyykZcGbIiBtzpZW5wlCrC39pbIn+7IlGJfDxPJDpK5JZcIU9cSy8jfFB0ldzKY8BfWxrnQ6NMW2p81Mex2TCdd5Ss1KfAttUepf4ZswB7TCxRgJq2RCzF0x5asR2PpiSLVi5ZQ0W2pUS7OX6R0IjgGHeVfhyBAuy6GFbxwEL35ZVvS82wcTip+0Vs2p45ZjQL9EiTHT6TnykANrfWRc3QgfflaVVv.9OwP8yguPyuPcSf3Jl2b.aW.UwtRkq5Uc5zr4W0o2AqW685nYw34KDxysZcWCnmNhgFNQ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- thank you
-
I just remembered Christoph wrote about this ages ago in this post (lots of other good stuff in there too) - https://forum.hise.audio/topic/79/scripting-best-practices
-
@orange Hmmm.... Exactly.