View Single Post
Old 07-06-2019, 10:47 AM   #1
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default WalterTheme&API: Custom Buttons, Textfields, Sliders, etc.

Time and again, I run into the wish of having the ability to add my own custom-buttons/sliders/etc to my theme.
For instance, I have a set of vst-plugins, that I would love to load by clicking a button on a track or add other nice and important stuff to the Transport-panel.
Especially with the new scripting-possibilities using the theme-layout-functions and the massive changes for Reaper v6, this would be another killer customize feature.

How I think it could be done.

Theme
You can add, let's say, up to 32 custom-elements to a Theme-element.
In the rt-config, a button and a caption could be added to a track like:
Code:
 tcp.custom1 "button" x y w h
 tcp.custom2 "caption=This is a button" x y w h
 tcp.custom2 "slider=minval,maxval,default,stepsize" x y w h
So it's
themelement.customxxx "type of element like button, slider, etc" x y width height

themeelement is the usual themeelements Walter supports like mcp, tcp, trans, etc

This could be themed as all other theme-elements(buttons, captions), but with the difference, that they're not "linked" to a feature/an action by default.

Set and Action to this theme-element
Now, how can we trigger scripts/actions. For that I would suggest to treat them like shortcuts.
So I go into the ActionList-window, select an action, select AddShortcut and when the dialog opens which asks for the shortcut, you click on the custom-element(in our case, the clickable button).
So everytime the button gets clicked, it will run the associated action with it.

Scripting/coding the action behind the theme-element
Now, how to program the scripts behind that.
I would suggest a new function "get_action_context2", which returns:
custom_theme_elementname - like tcp.custom1
object_id - the track/obejct number, in which one clicked the button/etc.
min_value - the minimum value for this element
max_value - the maximum value for this element
current value - 0,1 for buttons, min_value to max_value for buttons

With that, this could be codeable in a quite extensive way and would help us tons.


This is my current idea, how this could be done, but I'm open for better ones that could do things even easier for devs, scripters, themers and users.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...

Last edited by Meo-Ada Mespotine; 03-31-2020 at 03:31 PM.
Meo-Ada Mespotine is offline   Reply With Quote