Colour Swatch window
for context sensitive colouring of tracks or items
I recommend getting this script with the ReaPack extension. That version is stable, and will update automatically when you sync, should anyone update it.
Current version: v1.61 (2016-06-15)
+ spk77: fixed colour swatch reset
1.60 (2016.06.11)
- fixed Reset function
- larger window with more colour choices, hopefully covering most needs
Don't forget you can change the default preset to suit your needs. There is some help text included.
Written by Airon, SPK77, Heda, Evil Dragon and all the folks who contributed ideas, criticism and bug reports.
Will remember the state it was left in the next time the window is opened again.
Can be reset to defaults by clicking on the text in the upper middle "Reset"
Detects the selection focus and indicates this in the top row with a TRACK or ITEM text highlighted in red
CONFIG options(edit script to change these):
one_off_colour_change - if set to true, will close the colour swatch window after the first colour change
move_window_to_mouse - if set to true, will reposition the window where the mouse is after opening the window and RESET
SHIFT + Right-Click + drag = Upper Saturation
CTRL + Right-Click + drag = Lower Saturation
ALT + Right-Click + drag = Upper Luminosity
Right-Click + drag = Lower Luminosity
Colour Gradient for selected tracks or items
CLICK on first colour, then CTRL(Cmd on OSX)+CLICK on second colour
Great toolbar icon by Hopi:
To install, copy it in to your data/toolbar_icons directory in the Reaper resource directory. Click on Options/Show Reaper resource path... to get to that.
How to install
Place in script directory.
First time users need to locate this via Options / Show Reaper resource path in Explorer/ Finder.
Then open the Action List window (Actions / Show Action list...) and hit the Load button next to Reascript:, and select the script file. Then you can activate it either from the action list window with the Run button, or bind it to any key, toolbar button, midi note or midi message.
This is really pretty. I'm getting different colors (than presented) though
Might have to do with OSX or an option? SWS Auto-color shouldn't influence it right now.
Nice one Airon -this will be very useful for setting up/managing projects prior to a mix, or even organising as you go -another step closer to a clunk-free workflow -I like!
This is really pretty. I'm getting different colors (than presented) though
Might have to do with OSX or an option? SWS Auto-color shouldn't influence it right now.
... screenshot?
__________________ DarkStar ... interesting, if true. . . . Inspired by ...
Seventh, that's a good idea. I'll ask around to see how that can be done.
Right now I'm working on a simple preset system, so your favorite swatches can be saved. Not sure how extensive that system can be though. I'll resort to loading presets only for starters, and then tackle saving data to an external file or the RPP.
Since people want to name things, that should be interesting to do as well with some kind of text box.
Note:
You can configure how many swatches vertically and horizontally you want, as well as the starter values for the generated colours.
For example, this gives you a bit of a Protools-like colour picker, at least in size :
Code:
saturation = 0.7 ; luminance_max = 0.85; luminance_min = 0.58
sw_max_x = 23 -- how many swatches horizontally
sw_max_y = 3 -- how many swatches vertically
sw_w = 16 -- swatch width
sw_h = 12 -- swatch height
sw_border = 2 -- empty around the swatches
Change those variables at the start of the script and rerun it. Presto.
Btw, this is running a different font, and a background colour I just implemented. Will update it whole thing later today.
It's still coloring the track, if I first click on an item and then run the script. Could it figure out what I've selected last and use that as the target?
Quote:
Originally Posted by airon
Since people want to name things, that should be interesting to do as well with some kind of text box.
Maybe the box can always display the name of the target track/item, which you can then double-click to rename.
Maybe this script will evolve into a comprehensive track/item appearance customization tookit. ^_^
__________________
Grey, flat and minimal theme for Reaper: Symbiosis
It's still coloring the track, if I first click on an item and then run the script. Could it figure out what I've selected last and use that as the target?
Start the script first. On my end it doesn't colour anything if you start the script after selecting anything.
I'll take a look at this.
Meanwhile, I'm working on a value readout and preset system. The readout is done and I've placed the first visual hooks for the actual help pop up and preset system that'll eventually follow, but only the readout has functionality.
Oh yeah, I've added saturation boundaries too.
Code:
R-drag for saturation upper boundary
ALT+R-drag for saturation lower boundary
SHIFT+R-drag for luminosity upper boundary
CTRL+R-drag for luminosity lower boundary
...parts of Reaper's UI not updating to the new color until I manually force a redraw. That's for the track manager swatches as well as the swatches in the MIDI editor's track list and the MIDI Piano Roll (if it is set to track color mode, obviously). I tried adding UpdateTimeline and Update Arrange to no success. Is this a LUA issue we should report?
In my own Python and EEL color scripts I don't do anything special to force an UI update, just the SetTrackColor function, basically like you do in this one.
(slightly edited for clearness)
Please try:
- Open Reaper's track manager view
- Select a track and use the colour swatch script to change a track's color
=> does the color swatch in track manager update for you? Mine doesn't, until I force a redraw (eg by selecting another track).
Similarly, the MIDI editor's track list doesn't update here, as well as event color in Piano roll view.
I don't have this issue using my EEL and Python scripts which essentially use the same function to change the track color, so this might be a LUA issue - if it is, it should be reported in the pre-release bug report thread (preferably by someone who actually does LUA, so not me).
Minor inconvenience encountered while looking at this:
If you clicked an item, so that the script switched to "Item" coloring, clicking on a track in the track manager list doesn't switch the script back to "Track". Selecting tracks via actions doesn't cause the script to switch back to "Track" either. The only way it seems to work is actually clicking on a TCP or MCP. Maybe it would be easier and more save to have a set of buttons on the script's GUI to do the switching.
Right now I'm working on a simple preset system, so your favorite swatches can be saved.
That would be awesome.
Quote:
Originally Posted by airon
Since people want to name things, that should be interesting to do as well with some kind of text box.
Yes, I would name my colours according to what they represent. (drums, bass, clean GTR, distorted GTRs, FX)
This would help my assistants when they're setting up projects for me to mix.
@gofer
Confirmed. (haven't tested with EEL or Python)
Very nice Airon!
Here's a little optimization thing:
Code:
function runloop()
if gfx.mouse_cap&1 == 1 then
if not mouse.down then
-- The Reaper action is here
OnMouseDown()
end
elseif mouse.down then
OnMouseUp()
end
local c=gfx.getchar()
-- capture mouse x-pos movements
mouse.moving = mouse.mx ~= gfx.mouse_x -- true, if mouse x position changed
mouse.mx = gfx.mouse_x
-- detect selection context
---[[ -- which does not work yet
--if reaper.GetCursorContext2() == 0 then
if reaper.GetCursorContext() == 0 then
item_apply = 0 ; track_apply = 1
elseif reaper.GetCursorContext() == 1 then
item_apply = 1 ; track_apply = 0
--else
-- item_apply = 0 ; track_apply = 1 -- fall back on track colouring.
end
selection_context = (-1) * item_apply + track_apply
if last_selection_context ~= selection_context then
--something's changed, let's redraw
draw_indicate_controls()
end
last_selection_context = selection_context
--]]
-- Mouse + modifiers to change the three parameters
-- saturnation, maximum luminosity and minimum luminosity
if (gfx.mouse_cap&2 == 2) and mouse.moving then -- right-mouse button clicked down
.
.
.
I have a small suggestion if possible. I would add an option to set track/item back to the default color(a reset to no color), otherwise its perfect and fast to use.
mouse.moving = mouse.mx ~= gfx.mouse_x -- true, if mouse x position changed
I'm not at my studio atm, and will continue the script development on monday.
Quote:
Originally Posted by spk77
@gofer
Confirmed. (haven't tested with EEL or Python)
Very nice Airon!
Here's a little optimization thing:
Code:
function runloop()
if gfx.mouse_cap&1 == 1 then
if not mouse.down then
-- The Reaper action is here
OnMouseDown()
end
elseif mouse.down then
OnMouseUp()
end
local c=gfx.getchar()
-- capture mouse x-pos movements
mouse.moving = mouse.mx ~= gfx.mouse_x -- true, if mouse x position changed
mouse.mx = gfx.mouse_x
-- detect selection context
---[[ -- which does not work yet
--if reaper.GetCursorContext2() == 0 then
if reaper.GetCursorContext() == 0 then
item_apply = 0 ; track_apply = 1
elseif reaper.GetCursorContext() == 1 then
item_apply = 1 ; track_apply = 0
--else
-- item_apply = 0 ; track_apply = 1 -- fall back on track colouring.
end
selection_context = (-1) * item_apply + track_apply
if last_selection_context ~= selection_context then
--something's changed, let's redraw
draw_indicate_controls()
end
last_selection_context = selection_context
--]]
-- Mouse + modifiers to change the three parameters
-- saturnation, maximum luminosity and minimum luminosity
if (gfx.mouse_cap&2 == 2) and mouse.moving then -- right-mouse button clicked down
.
.
.
I sent the PT color set to airon, so he can add it to his presets of his advanced Color Swatch tool. I'll get together with him when he gets back to wrap up this simple version before releasing it.
Shane
__________________
"Music should be performed by the musician not by the engineer."
It would be nice to have an option to color both selected track and item instead of using focus as a reference
yes. I agree.
- Both track + items selected: color track + items
- Only track selected: color track
- Only items selected: color item
- Only items selected + key combination (CTRL for example) color takes.
I think REAPER by default selects the track when you select an item. That makes it difficult to separate the track selection / item selection if you don't change the setting.
That searching tool, it would be more interesting to me if it was open source. Meanwhile, the windows search box is good enough.
now.. to not be completely off topic... Adding those sliders to the colour watch tool, is a good idea. More intuitive than using the mouse. Although using the mouse is cool. But with sliders we could set precise amounts of saturation etc.
I'm trying to use a system that parses the data as a Lua program, as detailed in the Programming For Lua book. So you're storing presets exactly like they're kept in the script, plus they're human readable and editable.
I'm getting the pieces together one scrap at a time, at least in the last week or two, so it has been slow.
I hope to keep a preset file that contains the user presets and the last used settings. If it works great, I figure it'll be usable for everyones scripts.
After that, I want to put in sliders :P. Others have done that neat stuff, so I'll copy that from there.
I don't know if this is a lot to ask, but anyway.. I would love to see two more things:
- Take colouring in addition to Track and Item
- the HEX number of a chosen colour so that we could easily use it in SWS auto colour/icon
P.S. And as if this was not already enough :P... it would be nice to have the ability to "pick" a colour of an existing item/track and be able to apply it to another track/item.
Please try:
- Open Reaper's track manager view
- Select a track and use the colour swatch script to change a track's color
=> does the color swatch in track manager update for you? Mine doesn't, until I force a redraw (eg by selecting another track).
Similarly, the MIDI editor's track list doesn't update here, as well as event color in Piano roll view.
I don't have this issue using my EEL and Python scripts which essentially use the same function to change the track color, so this might be a LUA issue - if it is, it should be reported in the pre-release bug report thread (preferably by someone who actually does LUA, so not me).
Still (not) happening in pre19b/x64, but here's some additional info:
The culprit seems to be that it's a deferred script. This little test LUA script:
Code:
tr = reaper.GetSelectedTrack(0, 0)
color = 18894459
reaper.SetTrackColor (tr, color)
does update correctly everywhere, but not if run from the IDE edit window.
I wrote the same thing in py and eel as well, with the same result. No update from the IDE, but correct when run from the action window/shortcut/toolbar button. My existing python/eel color scripts behave the same. So it doesn't seem to be LUA-related at all.
Would be nice if somebody took the effort to verify whether it's indeed a defer issue and report this properly in the pre release forum.