Old 09-07-2020, 03:16 AM   #1
White Tie
Pixel Pusher
 
White Tie's Avatar
 
Join Date: Mar 2007
Location: Blighty
Posts: 4,983
Default Adjusting themes using scripting

In v5.78pre1 the following lines appeared in the changelog:

v5.78pre1 - March 10 2018
# API: add ThemeLayout_SetParameter(), ThemeLayout_GetParameter(), ThemeLayout_RefreshAll() for use with define_parameter lines
# WALTER: support define_parameter scalar_name 'description' default_value min_value max_value

These are the tools used to make adjustments to a theme's WALTER using scripting, and are what I used to make the Default 6 theme and its 'theme adjuster' script. That theme and its script are complex, so here are a basic script and theme to illustrate the full power of these tools without any distracting complications.

basic_adjusted_theme.ReaperThemeZip
basic_theme_adjuster.lua



THEMERS As you can see, this is a very simple theme, little more than the 'blank file' theme I recommend for anyone learning theming. The WALTER is profoundly simple, but just as you've been making complicated themes using nothing more than Reaper's small set of predefined scalar variables like "w>10", this is the same thing but you get to create the scalar variables and alter them using a script. This could easily be retrofitted into your existing themes, or you could design new themes from scratch to really take advantage it. But what if you don't have time to, or don't want to learn scripting?

SCRIPTERS As you can see, this is a very simple script. I'm sure its also very badly written because, hey, beginner programmer here There are only three things in there that have anything to do with themeing (reaper.ThemeLayout_GetParameter(), reaper.ThemeLayout_SetParameter(), reaper.ThemeLayout_RefreshAll() ) and I have little doubt that you could do all manner of scripting that could use these to great effect. But what if you don't have time to, or don't want to learn theming?

THEMERS & SCRIPTERS This theme is crap. This script is very crap. But I hope its very crapness will whet your appetite for all the possibilities that could come from you using these simple tools to do your half of this combination with all of your skills and imagination.

A script and theme could be made where every theme element can be repositioned freely. Someone could make a generic theme adjuster script that simply read in parameters and made them editable, like this one does but in a non-crap way. The possibilities offered by this are truly exciting and transformational, but will never be realised if they are forever limited by my dodgy scripting skills

To that end, if any of you have any interest in forging dialog and cooperation between the theme forum and the script forum, I would encourage you to do so here. The results might be awesome.

This thread's sister thread on the Reascript forum
__________________
The House of White Tie
White Tie is offline   Reply With Quote
Old 09-07-2020, 03:44 AM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,629
Default

I'll add my own demotheme to the mix as well:
https://forum.cockos.com/showthread.php?t=229063
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 09-07-2020, 03:48 AM   #3
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,629
Default

Quote:
Originally Posted by White Tie View Post
In
A script and theme could be made where every theme element can be repositioned freely.
This is exactly the idea for a theme editor I have in my mind.
You can even have 65000+ parameters in your theme but the thing really slows down Reaper then.
But yeah, this is the approach.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 09-07-2020, 04:03 AM   #4
White Tie
Pixel Pusher
 
White Tie's Avatar
 
Join Date: Mar 2007
Location: Blighty
Posts: 4,983
Default

Its not a silver bullet, because what you'll end up with is a static theme that doesn't respond to changes width/height/other variables. But lots of themers make static themes and lots of users love them, so it would definitely be of great value and a step in the right direction.

I have some ideas for how the two might work together to be less static, in my head it quickly turns into complicated macro workarounds for inherent limitations in the way WALTER works, but the possibilities are there.

One approach to mitigate it might be to do all the resizing logic on the fly in the script, and have it drive the theme. The performance consequences of that scared me away
__________________
The House of White Tie
White Tie is offline   Reply With Quote
Old 09-07-2020, 09:12 PM   #5
+NRG
Human being with feelings
 
+NRG's Avatar
 
Join Date: Aug 2014
Location: NY
Posts: 791
Default

Wow, this seems like a great idea to me! I’ll be watching to see what develops...

I don’t mind a static theme as long everything is where I want it / looking how I want it / with a few layouts for specific needs...

Having said that... I think the V6 default theme is a masterpiece! I really didn’t have trouble editing Sir Walter to get what I wanted and the flexibility is astounding to me.

I’ve been sick for 10 years (CIDP) with no end in sight and REAPER has been a bright light for me.

I feel pretty spoiled, actually!

So, thank you for your efforts B)
__________________
“Where words fail, music speaks”
+NRG is offline   Reply With Quote
Old 09-08-2020, 06:38 PM   #6
Win Conway
Human being with feelings
 
Join Date: Dec 2010
Posts: 3,826
Default

Could I use this to create actions to set colors based on layouts after changing layouts, example....

I use Layouts to change my track colors, so for instance in color 1 layout i change the label color, the meter/dials and some buttons colors via use of a color 1 folder with colored images.
What i need is some way to use the different color parts of a layout without actually changing the layout as it were, because if i have created layouts on my MCP for normal/compact/slidecar/sidecar etc, i want to be able to switch between those without the color being changed back to default if i have set the color (via layout) or indeed be able to change the color without having to create colored versions of all the different layouts normal/compact/slidecar/sidecar etc.




For the record my layout code is super simple, and because i ddnt use clear MCP or anything, I assumed that it would just change the coloring of the already set layout.

Code:
    Layout "Color 1" "color_1"
   set mcp.label.color [218 112 112 255 0 0 0 0]
	EndLayout ;
	Layout "Color 2" "color_2"
   set mcp.label.color [236 128 55 255 0 0 0 0]
	EndLayout ;
	Layout "Color 3" "color_3"
   set mcp.label.color [226 222 63 255 0 0 0 0]
	EndLayout ;
	Layout "Color 4" "color_4"
   set mcp.label.color [129 120 228 255 0 0 0 0]
	EndLayout ;
	Layout "Color 5" "color_5"
   set mcp.label.color [107 216 61 255 0 0 0 0]
	EndLayout ;
	Layout "Color 6" "color_6"
   set mcp.label.color [187 69 211 255 0 0 0 0]
	EndLayout ;
	Layout "Color Default"
   set mcp.label.color [200 200 200 255 0 0 0 0]
	EndLayout ;
__________________
Stop posting huge images, smaller images or thumbnail, it's not rocket science!

Last edited by Win Conway; 09-08-2020 at 06:48 PM.
Win Conway is offline   Reply With Quote
Old 09-08-2020, 06:58 PM   #7
Win Conway
Human being with feelings
 
Join Date: Dec 2010
Posts: 3,826
Default

My question seems worded badly.

1 Set an MCP color using a layout.
2 Have an action that changes all the MCP sizes and controls locations via this scripting.
3 Still be able to change MCP colors using a different layout afterwards and the scripts sizes and locations all stay the same.
__________________
Stop posting huge images, smaller images or thumbnail, it's not rocket science!
Win Conway is offline   Reply With Quote
Old 09-08-2020, 07:55 PM   #8
Win Conway
Human being with feelings
 
Join Date: Dec 2010
Posts: 3,826
Default

Ok I am trying some tests but lua is way beyond me, im trying this in the rtconfig
Code:
 define_parameter ext_x 'extmix x' 1 100 1000
   define_parameter ext_y 'extmix y' 1 100 1000

  ;MCP Default....................
   clear mcp.*
   set mcp.size [140 335]
   
  ;[FX]
   set mcp.extmixer.mode [1]
   set mcp.extmixer.position [ext_x ext_y 108 236 0 0 0 1]
and this in the create new action editor.
Code:
reaper.ThemeLayout_SetParameter (ext_y, 100, true)
I'm getting this fault..
Code:
MCPtest.lua:1: bad argument #1 to 'ThemeLayout_SetParameter' (number expected, got nil)
__________________
Stop posting huge images, smaller images or thumbnail, it's not rocket science!
Win Conway is offline   Reply With Quote
Old 09-08-2020, 11:26 PM   #9
mikostep
Human being with feelings
 
mikostep's Avatar
 
Join Date: Nov 2019
Posts: 92
Default

Quote:
Originally Posted by Win Conway View Post
Could I use this to create actions to set colors based on layouts after changing layouts, example....

I use Layouts to change my track colors, so for instance in color 1 layout i change the label color, the meter/dials and some buttons colors via use of a color 1 folder with colored images.
What i need is some way to use the different color parts of a layout without actually changing the layout as it were, because if i have created layouts on my MCP for normal/compact/slidecar/sidecar etc, i want to be able to switch between those without the color being changed back to default if i have set the color (via layout) or indeed be able to change the color without having to create colored versions of all the different layouts normal/compact/slidecar/sidecar etc.




For the record my layout code is super simple, and because i ddnt use clear MCP or anything, I assumed that it would just change the coloring of the already set layout.

Code:
    Layout "Color 1" "color_1"
   set mcp.label.color [218 112 112 255 0 0 0 0]
	EndLayout ;
	Layout "Color 2" "color_2"
   set mcp.label.color [236 128 55 255 0 0 0 0]
	EndLayout ;
	Layout "Color 3" "color_3"
   set mcp.label.color [226 222 63 255 0 0 0 0]
	EndLayout ;
	Layout "Color 4" "color_4"
   set mcp.label.color [129 120 228 255 0 0 0 0]
	EndLayout ;
	Layout "Color 5" "color_5"
   set mcp.label.color [107 216 61 255 0 0 0 0]
	EndLayout ;
	Layout "Color 6" "color_6"
   set mcp.label.color [187 69 211 255 0 0 0 0]
	EndLayout ;
	Layout "Color Default"
   set mcp.label.color [200 200 200 255 0 0 0 0]
	EndLayout ;
Great idea. I`ll have to try it.
What theme is that? Nice!
mikostep is offline   Reply With Quote
Old 09-08-2020, 11:44 PM   #10
White Tie
Pixel Pusher
 
White Tie's Avatar
 
Join Date: Mar 2007
Location: Blighty
Posts: 4,983
Default

Its unrelated to the newer stuff we're discussing here (scripts directly interacting with WALTER) but yes, scripts can do all kinds of fancy things like reaper.ThemeLayout_SetLayout (change layouts) and reaper.SetTrackColor (change track custom colours).
__________________
The House of White Tie
White Tie is offline   Reply With Quote
Old 09-09-2020, 09:44 AM   #11
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,629
Default

Quote:
Originally Posted by Win Conway View Post
Ok I am trying some tests but lua is way beyond me, im trying this in the rtconfig
Code:
 define_parameter ext_x 'extmix x' 1 100 1000
   define_parameter ext_y 'extmix y' 1 100 1000

  ;MCP Default....................
   clear mcp.*
   set mcp.size [140 335]
   
  ;[FX]
   set mcp.extmixer.mode [1]
   set mcp.extmixer.position [ext_x ext_y 108 236 0 0 0 1]
and this in the create new action editor.
Code:
reaper.ThemeLayout_SetParameter (ext_y, 100, true)
I'm getting this fault..
Code:
MCPtest.lua:1: bad argument #1 to 'ThemeLayout_SetParameter' (number expected, got nil)
Now I get it: your code must be

Code:
reaper.ThemeLayout_SetParameter(1, 100, true)
as ext_x is the first parameter defined in your rtconfig, so it must be 1 in this function.
If you had two and would like to change this second, the first parameter in the function would be 2, etc.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...

Last edited by White Tie; 09-09-2020 at 10:34 AM.
Meo-Ada Mespotine is offline   Reply With Quote
Old 09-09-2020, 02:45 PM   #12
Win Conway
Human being with feelings
 
Join Date: Dec 2010
Posts: 3,826
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Now I get it: your code must be

Code:
reaper.ThemeLayout_SetParameter(1, 100, true)
as ext_x is the first parameter defined in your rtconfig, so it must be 1 in this function.
If you had two and would like to change this second, the first parameter in the function would be 2, etc.
You mean 0 right ?
The first parameter is 0, the second is 1 so on and so on.
__________________
Stop posting huge images, smaller images or thumbnail, it's not rocket science!
Win Conway is offline   Reply With Quote
Old 10-06-2020, 04:31 AM   #13
MisterLevy
Human being with feelings
 
Join Date: Sep 2020
Posts: 20
Default

People interested in this thread may be interested in my Theme Adjuster

https://forum.cockos.com/showthread.php?t=243159




__
MisterLevy is offline   Reply With Quote
Old 04-06-2021, 08:43 PM   #14
OakleyRdStudios
Human being with feelings
 
Join Date: Jun 2017
Posts: 226
Default

How do I open the theme adjuster?
OakleyRdStudios is offline   Reply With Quote
Old 04-07-2021, 05:09 PM   #15
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,629
Default

Quote:
Originally Posted by OakleyRdStudios View Post
How do I open the theme adjuster?
Which one? The official one or the one from MisterLevy?
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 04-07-2021, 11:44 PM   #16
OakleyRdStudios
Human being with feelings
 
Join Date: Jun 2017
Posts: 226
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Which one? The official one or the one from MisterLevy?

I mean the one that comes with 'basic_adjusted_theme.ReaperThemeZip'.
I put 'basic_theme_adjuster.lua into the same Reaper resource folder, alongside the other .lua scripts. The option to use it is greyed out on the Options>Themes sub menu.

It doesn't matter now. I simply was curious to see how this thing worked. I'm now fairly engrossed in building myself a basic, static theme/ learning curve thing. That, and tiling my bathroom floor.
OakleyRdStudios is offline   Reply With Quote
Old 04-08-2021, 05:46 AM   #17
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 13,333
Default

Quote:
Originally Posted by OakleyRdStudios View Post
I mean the one that comes with 'basic_adjusted_theme.ReaperThemeZip'.
I put 'basic_theme_adjuster.lua into the same Reaper resource folder, alongside the other .lua scripts. The option to use it is greyed out on the Options>Themes sub menu.
You have to name script [Theme]_theme_adjuster.lua. In this case it should be called "basic_adjusted_theme_theme_adjuster.lua". Actually WT wrote this somewhere, but I can't find it. Remember about adding images folder if you need to "basic_adjusted_theme_theme_adjuster_images".
vitalker 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 02:18 PM.


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