From 40c415b88158892511fbf4cb171b8a6858ed31e5 Mon Sep 17 00:00:00 2001 From: Ben Talagan Babut Date: Sun, 29 Oct 2023 10:21:52 +0100 Subject: [PATCH] Release Track Color Layouts v1.0 (#1277) --- .../talagan_Track color layouts.lua | 62 ++++++++ .../talagan_Track color layouts lib.lua | 139 ++++++++++++++++++ .../toolbar_talagan_track_color_layout_1.png | Bin 0 -> 534 bytes .../toolbar_talagan_track_color_layout_2.png | Bin 0 -> 644 bytes .../toolbar_talagan_track_color_layout_3.png | Bin 0 -> 656 bytes .../toolbar_talagan_track_color_layout_4.png | Bin 0 -> 615 bytes 6 files changed, 201 insertions(+) create mode 100644 Tracks Properties/talagan_Track color layouts.lua create mode 100644 Tracks Properties/talagan_Track color layouts/talagan_Track color layouts lib.lua create mode 100644 Tracks Properties/talagan_Track color layouts/toolbar_talagan_track_color_layout_1.png create mode 100644 Tracks Properties/talagan_Track color layouts/toolbar_talagan_track_color_layout_2.png create mode 100644 Tracks Properties/talagan_Track color layouts/toolbar_talagan_track_color_layout_3.png create mode 100644 Tracks Properties/talagan_Track color layouts/toolbar_talagan_track_color_layout_4.png diff --git a/Tracks Properties/talagan_Track color layouts.lua b/Tracks Properties/talagan_Track color layouts.lua new file mode 100644 index 000000000..a232bf750 --- /dev/null +++ b/Tracks Properties/talagan_Track color layouts.lua @@ -0,0 +1,62 @@ +--[[ +@description Track color layouts +@version 1.0.0 +@author Ben 'Talagan' Babut +@donation https://www.paypal.com/donate/?business=3YEZMY9D6U8NC&no_recurring=1¤cy_code=EUR +@license MIT +@changelog + Initial Version +@metapackage +@provides + [nomain] talagan_Track color layouts/talagan_Track color layouts lib.lua + [main=main,midi_editor] . > talagan_Track color layout 1.lua + [main=main,midi_editor] . > talagan_Track color layout 2.lua + [main=main,midi_editor] . > talagan_Track color layout 3.lua + [main=main,midi_editor] . > talagan_Track color layout 4.lua + [data] talagan_Track color layouts/toolbar_talagan_track_color_layout_1.png > toolbar_icons/toolbar_talagan_track_color_layout_1.png + [data] talagan_Track color layouts/toolbar_talagan_track_color_layout_2.png > toolbar_icons/toolbar_talagan_track_color_layout_2.png + [data] talagan_Track color layouts/toolbar_talagan_track_color_layout_3.png > toolbar_icons/toolbar_talagan_track_color_layout_3.png + [data] talagan_Track color layouts/toolbar_talagan_track_color_layout_4.png > toolbar_icons/toolbar_talagan_track_color_layout_4.png +@screenshot + Standard use case https://i.imgur.com/KlOdiwy.gif + The tool in action https://i.imgur.com/LD8x61n.gif +@about + # Purpose + + REAPER is by default limited to one color per track. What if we were able to define multiple colors for each track, each color tied to a configuration (or layout), and switch between those layouts in an instant to recolorize the whole project set of tracks ? + + For example you could have one track color layout for composing, one for mixing, etc. Depending on the workflow, you could quickly switch from a color scheme to another. + + This is what this small extension tries to achieve. + + # How to use + + Simply call the action "talagan_Track Color Layout N" to switch to Layout number N. That's all ! Now, the current Track Color Layout is N, and all track color modifications will be done in the current layout. Then call "talagan_Track Color Layout M" to switch to Layout number M. And so on. + + The default, active layout is Layout 1 (for new projects or projects that have not used layouts yet). + + # Saving features + + All color pieces of information are stored directly on each track. Saving your project will thus also save your color layouts. They are also saved inside track templates too ! + + # More layouts + + The install is limited to 4 layouts, but you can duplicate the script and change the number at the end to use another layout. You can virtually have as many layouts as you desire. + + # Known bugs / limitations + + When importing a track template, the new tracks will have the color they had at export time, and the corresponding layout at that time may not match the current project layout (ex : they were saved while being on layout 1, and your current project is currently using layout 2, so they will thus appear with the colors of layout 1 whereas they should appear with the colors of layout 2). There's a security in the script that prevents those new tracks colors from being squashed due to this incoherency and lose their layout configs. To resynchronize these new tracks with the rest of the project, just switch the layout once after import. + +--]] + +--[[ + + This file is a generic action for the Track Color Layout library. + You can duplicate it and change the number at the end of its file name + to modify the Track Color Layout to switch to. + +]]-- + +package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .."?.lua;".. package.path +require "talagan_Track color layouts/talagan_Track color layouts lib" +switchToTrackColorLayout(extractTrackLayoutNumFromActionName()) diff --git a/Tracks Properties/talagan_Track color layouts/talagan_Track color layouts lib.lua b/Tracks Properties/talagan_Track color layouts/talagan_Track color layouts lib.lua new file mode 100644 index 000000000..e2c372011 --- /dev/null +++ b/Tracks Properties/talagan_Track color layouts/talagan_Track color layouts lib.lua @@ -0,0 +1,139 @@ +--[[ +@noindex +@author Talagan +@license MIT +@about + This is the lib file for the Track Color Layout feature. + See the companion action file for details. +--]] + +_DEBUG=false +function DBG(txt) + if _DEBUG then + reaper.ShowConsoleMsg(txt); + end +end + +function getProjectCurrentLayoutNum() + local mtrack = reaper.GetMasterTrack(); + local succ, str = reaper.GetSetMediaTrackInfo_String(mtrack, + "P_EXT:talagan_track_color_layout_current", + '', + false + ); + + if not succ or str == nil or str == '' then + str = "1" + end + + return tonumber(str); +end + +function getTrackCurrentLayoutNum(track) + local succ, str = reaper.GetSetMediaTrackInfo_String(track, + "P_EXT:talagan_track_color_layout_current", + '', + false + ); + + -- If there's no info of the current track's layer + -- It's probably a new track that has not yet been committed. + -- Use the project's current layout then. + + if not succ or str == nil or str == '' then + return getProjectCurrentLayoutNum(); + end + + return tonumber(str); +end + +function setCurrentLayoutNum(layout) + local mtrack = reaper.GetMasterTrack(); + local succ, str = reaper.GetSetMediaTrackInfo_String(mtrack, + "P_EXT:talagan_track_color_layout_current", + tostring(layout), + true + ); + + local tc = reaper.GetNumTracks(); + local ti = 0; + for ti = 0, tc - 1, 1 do + local track = reaper.GetTrack(0, ti); + + -- Also commit on tracks individually, for later sanity checks + local succ, str = reaper.GetSetMediaTrackInfo_String(track, + "P_EXT:talagan_track_color_layout_current", + tostring(layout), + true + ); + end +end + +function commitCurrentLayout() + + local tc = reaper.GetNumTracks(); + local layout = getProjectCurrentLayoutNum(); + + local ti = 0; + for ti = 0, tc - 1, 1 do + local track = reaper.GetTrack(0, ti); + + local trackLayout = getTrackCurrentLayoutNum(track); + + if trackLayout == layout then + -- Get current col + local col = reaper.GetMediaTrackInfo_Value(track, "I_CUSTOMCOLOR"); + + -- Commit into the track's layer slot + local succ, str = reaper.GetSetMediaTrackInfo_String(track, + "P_EXT:talagan_track_color_layout_" .. layout, + tostring(col), + true + ); + else + -- There's an incoherency ! The track was not in sync with the project. + -- It probably means that it's an imported template, we want to avoid breaking things + end + + end + +end + +function restoreLayout(layout) + local tc = reaper.GetNumTracks(); + + local ti = 0; + for ti = 0, tc - 1, 1 do + local track = reaper.GetTrack(0, ti); + + -- Commit into the track's layer slot + local succ, str = reaper.GetSetMediaTrackInfo_String(track, + "P_EXT:talagan_track_color_layout_" .. layout, + '', + false + ); + + local col = 0; + if succ then + col = tonumber(str); + end + + -- Set current col + reaper.SetMediaTrackInfo_Value(track, "I_CUSTOMCOLOR", col); + + end + + setCurrentLayoutNum(layout); +end + +function switchToTrackColorLayout(layout) + commitCurrentLayout(); + restoreLayout(layout); +end + +function extractTrackLayoutNumFromActionName() + local _, sfname = reaper.get_action_context() + + -- Get the param inside parenthesis + return sfname.match(sfname,"([0-9]+).lua$") +end diff --git a/Tracks Properties/talagan_Track color layouts/toolbar_talagan_track_color_layout_1.png b/Tracks Properties/talagan_Track color layouts/toolbar_talagan_track_color_layout_1.png new file mode 100644 index 0000000000000000000000000000000000000000..0136c500610ba2edd2d648c4a0699e8f43dd6996 GIT binary patch literal 534 zcmV+x0_pvUP)$wo|gaafLBmKOF{)L2^F*?+G;h<9d8SLL!K>d5Ig6sBu|8T52hAvdDm{Q zgnD-d$9{Qh1`XH`$BNmbEv}oe8;%vc4{dj7T!^>cLsLVCBnx7cf5?x0^N5RFEW%jEz7x~>EC zja%$BFL%(9Fu}rd5{6-L%Nn8Cy^danT@fLloSyQkuMSD5pe508(57hunomSuT190Qbu?iCfcbSFLPoSQC6!0Bdes;$3CoI}$vhEczPD6Y0ZWym z0N@e;Kr4p`+~!pkEs44n&AVVP3emePb`ibH@)M%|>yU#QIwYZjmV^pg5-Mm(sGueB Y1=f808@amJNB{r;07*qoM6N<$f=4~r*Z=?k literal 0 HcmV?d00001 diff --git a/Tracks Properties/talagan_Track color layouts/toolbar_talagan_track_color_layout_2.png b/Tracks Properties/talagan_Track color layouts/toolbar_talagan_track_color_layout_2.png new file mode 100644 index 0000000000000000000000000000000000000000..474a1a0dcbb63886d65d65927ea4ad1c5ac15f87 GIT binary patch literal 644 zcmV-~0(HY3pQv&*q{wzgEqvn#SR|4dco5b^2Xs4s+IGO z+;ctkj_n<8$vZOn#8Yp!Z^r`fqCrFJ;WXpG_<7Myv>Hw`qz~<4|4vW5jUJkvItZ#O)j6wCeO z6$RZJhF~C%QtGdE`Q;wxSKuu%e|K_Fm!jSC&@s`YX$Pl>M*640h@;gbmsdHfTfG epbcSzHpFijONw6k^QcDv00008 literal 0 HcmV?d00001 diff --git a/Tracks Properties/talagan_Track color layouts/toolbar_talagan_track_color_layout_3.png b/Tracks Properties/talagan_Track color layouts/toolbar_talagan_track_color_layout_3.png new file mode 100644 index 0000000000000000000000000000000000000000..811e0cebde4f56f86aad28629cc80eb0c2e4d411 GIT binary patch literal 656 zcmV;B0&o3^P)n%zn&TQc4V+C-lEhASjriHDQ9*gb7*`YgXHN;>KlP?~wP-T(G2#V*Cc{A)g%6*Ubno~vy0YIfvf$)H8 zsX%#^=V*Y3dC7~?0zwFKxg2vN{lCPY+o=`|Z(C0tM~+(TOl-!sZL--cWAhDg>+O^Z zj8{46J5xWHpG#4zN{YoI0I^uC;{)z?uhP`v)M0uy&dkg$gb=u{i*4IH>8pW=LPg0P zD6dk`g9DJ-`-^X?ES*;RTi)Ky~?r@%ly}& q2QzhO!UU}e6SO8w(3&toYvLzU5}pG@xrDj^00004{K#R!ASzoSsNmV*nCp|dICwo1#Jlzv?W~7me{i1;NZQRMt>p4&tDT!-goio zs8R2oW9K4yFTZ(V)O)L^|1a;lK|}O#+Hv~s4W*rk8csV@58Ca0M~rw|9W=LeSfXV| zukhe-m)x=c8`-@fOWP%3P7vl`F`eOgnB(P--2@c)+1NwoQwQ5Vc9Q+j!Qw>UhB_o} zUf0o<&<^@b@SE2opQ)XlMS9aF=M+n?cF;3p4XzJ)NGbXC_?2#%#CWxW9=|Wyl{rJH zRMPplHvh9%Iq0|VC3DZZsZ=U>o~JENnpZjKN7IsOwTkci_`cs97n4u4Cy@ki+ta(% z)atOr0L5Yvp!pgE0r`Umpm%e=(sA%Ab#zxJWK%N;ArL}PE|&qw=kthxqbjA8h=W&o z>9{hK;^9<^tHWEV*Xzx3dGfewsYH3TPw#g2q?!LZfe?c9i9@<&65~}`qu0`VDM#Z% zfq()uHc~16UiTN=5^X#B)Iv?LuzFj zOH@qXWm$`G&vn?rEghC{L0iHFZ3!2&C0x*!_yZQ>OmN$##XbN4002ovPDHLkV1fzb BAIAUy literal 0 HcmV?d00001