Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 05-07-2016, 05:42 AM   #1
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default LUA:TrackList ALPHA - Cubase/PT TrackVersions/Playlist for REAPER

Update 07.09.2016 : Latest version on git hub
TRACK LISTS (Cubase TrackVersions / ProTools Playlist)!
Github link : https://raw.githubusercontent.com/Go...istVersion.lua

Features:
- Storing with projects
- Auto naming
- Deleting track deletes all version of that track
- Right Click menu (rename/delete version/save modification)
- Folder Versions (all child versions follow folder version selection)
- Multiple track selection Versions
- Items Only (not including track state, FX , automation,volume etc) ,full chunk version may be implemented but there could be problems with large chunks from FX
- One Empty version per tracks (shows only if there are saved versions)
- Multiselection save

the TRACK LISTS (Cubase TrackVersions / ProTools Playlist)!


latest version:
https://raw.githubusercontent.com/Go...istVersion.lua

installation:
1. copy all text from the link
2. open actions in reaper and click new reascript
3. call it "playlist.lua" or anything but dont forget ".lua"
4. paste the text and ctrl+s

Last edited by Sexan; 09-07-2016 at 03:57 AM.
Sexan is online now   Reply With Quote
Old 05-07-2016, 06:46 AM   #2
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,239
Default

You can use the gui creator from eugen2777 and study the code it generates. It is very good.
Making tutorials is difficult. It is much easier to code. there are many ways to do it depending on the complexity required
heda is offline   Reply With Quote
Old 05-07-2016, 07:30 AM   #3
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

Ok, checked it out,cool,looking forward for next update (this will be life saver),ok a question if its not very hard,how can I dynamically there add buttons? (I know script needs to be modified aditional function that will be called when this needs to happen)
So if I have:
Code:
for i = 0 , 5 do
add_button()
end
for example I want to add track names in a list

maybe this will be a FR for it

Last edited by Sexan; 05-07-2016 at 07:37 AM.
Sexan is online now   Reply With Quote
Old 05-07-2016, 09:47 AM   #4
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,239
Default

each button is an "object" so yes you can dynamically add or remove as many buttons as needed


for i = 0 , reaper.CountTracks(0)-1 do
Button:new(... parameters for each button...)
end


the example in FR: A way to mark audio files during recording
is a good example http://forum.cockos.com/showthread.php?t=175925
heda is offline   Reply With Quote
Old 05-07-2016, 09:53 AM   #5
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

thank you very much!
Sexan is online now   Reply With Quote
Old 05-07-2016, 10:21 AM   #6
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Here's an example (using eugen2777's GUI code):

(Draw buttons from track selection)



Code:
local Button_TB = {} -- All created buttons are held in this table. 

local Element = {}
function Element:new(x,y,w,h, r,g,b,a, lbl,fnt,fnt_sz, norm_val)
    local elm = {}
    elm.def_xywh = {x,y,w,h,fnt_sz} -- its default coord,used for Zoom etc
    elm.x, elm.y, elm.w, elm.h = x, y, w, h
    elm.r, elm.g, elm.b, elm.a = r, g, b, a
    elm.lbl, elm.fnt, elm.fnt_sz  = lbl, fnt, fnt_sz
    elm.norm_val = norm_val
    ------
    setmetatable(elm, self)
    self.__index = self 
    return elm
end
--------------------------------------------------------------
--- Function for Child Classes(args = Child,Parent Class) ----
--------------------------------------------------------------
function extended(Child, Parent)
  setmetatable(Child,{__index = Parent}) 
end
--------------------------------------------------------------
---   Element Class Methods(Main Methods)   ------------------
--------------------------------------------------------------
function Element:update_xywh()
  if not Z_w or not Z_h then return end -- return if zoom not defined
  if Z_w>0.5 and Z_w<3 then  
   self.x, self.w = math.ceil(self.def_xywh[1]* Z_w) , math.ceil(self.def_xywh[3]* Z_w) --upd x,w
  end
  if Z_h>0.5 and Z_h<3 then
   self.y, self.h = math.ceil(self.def_xywh[2]* Z_h) , math.ceil(self.def_xywh[4]* Z_h) --upd y,h
  end
  if Z_w>0.5 or Z_h>0.5  then --fix it!--
     self.fnt_sz = math.max(9,self.def_xywh[5]* (Z_w+Z_h)/2)
     self.fnt_sz = math.min(22,self.fnt_sz)
  end       
end
--------
function Element:pointIN(p_x, p_y)
  return p_x >= self.x and p_x <= self.x + self.w and p_y >= self.y and p_y <= self.y + self.h
end
--------
function Element:mouseIN()
  return gfx.mouse_cap&1==0 and self:pointIN(gfx.mouse_x,gfx.mouse_y)
end
--------
function Element:mouseDown()
  return gfx.mouse_cap&1==1 and self:pointIN(mouse_ox,mouse_oy)
end
--------
function Element:mouseClick()
  return gfx.mouse_cap&1==0 and last_mouse_cap&1==1 and
  self:pointIN(gfx.mouse_x,gfx.mouse_y) and self:pointIN(mouse_ox,mouse_oy)         
end
--------
function Element:draw_frame()
  local x,y,w,h  = self.x,self.y,self.w,self.h
  gfx.rect(x, y, w, h, 0)--frame1
  gfx.roundrect(x, y, w-1, h-1, 3, true)--frame2         
end
--------------------------------------------------------------------------------
---   Create Element Child Classes(Button,Slider,Knob)   -----------------------
--------------------------------------------------------------------------------
local Button ={}; local Knob ={}; local Slider ={}; 
  extended(Button, Element)
  extended(Knob,   Element)
  extended(Slider, Element)
---Create Slider Child Classes(V_Slider,H_Slider)----
local H_Slider ={}; local V_Slider ={};
  extended(H_Slider, Slider)
  extended(V_Slider, Slider)

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
---   Button Class Methods   ---------------------------------------------------
--------------------------------------------------------------------------------
function Button:draw_lbl()
    local x,y,w,h  = self.x,self.y,self.w,self.h
    local fnt,fnt_sz = self.fnt, self.fnt_sz
    --Draw btn lbl(text)--
      gfx.set(0.7, 1, 0, 1)--set label color
      gfx.setfont(1, fnt, fnt_sz);--set label fnt
        local lbl_w, lbl_h = gfx.measurestr(self.lbl)
        gfx.x = x+(w-lbl_w)/2; gfx.y = y+(h-lbl_h)/2
        gfx.drawstr(self.lbl)
end
---------------------
function Button:draw()
    self:update_xywh()--Update xywh(if wind changed)
    local x,y,w,h  = self.x,self.y,self.w,self.h
    local r,g,b,a  = self.r,self.g,self.b,self.a
    ---Get L_mouse state--
          --in element--
          if self:mouseIN() then a=a+0.1 end
          --in elm L_down--
          if self:mouseDown() then a=a+0.2 end
          --in elm L_up(released and was previously pressed)--
          if self:mouseClick() and self.onClick ~= nil then self.onClick() end
    --Draw btn(body,frame)--
    gfx.set(r,g,b,a)--set btn color
    gfx.rect(x,y,w,h,true)--body
    self:draw_frame()
    ------------------------
    self:draw_lbl()
end


                          
----------------------------------------------------------------------------------------------------
---   Main DRAW function   -------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
function DRAW()
    for key,btn  in pairs(Button_TB) do btn:draw()  end 
end

--------------------------------------------------------------------------------
--   INIT   --------------------------------------------------------------------
--------------------------------------------------------------------------------
function Init()
    --Some gfx Wnd Default Values--------------
    local R,G,B = 20,20,20        --0..255 form
    Wnd_bgd = R + G*256 + B*65536 --red+green*256+blue*65536  
    Wnd_Title,Wnd_W,Wnd_H,Wnd_Dock,Wnd_X,Wnd_Y = "Title", 330,250, 0,100,320
    --Init window------------------------------
    gfx.clear = Wnd_bgd         
    gfx.init( Wnd_Title, Wnd_W,Wnd_H, Wnd_Dock, Wnd_X,Wnd_Y )
    --Mouse--------------
    last_mouse_cap = 0
    last_x, last_y = 0, 0
end
----------------------------------------
--   Mainloop   ------------------------
----------------------------------------
function mainloop()
    --Z_w,Z_h = gfx.w/Wnd_W, gfx.h/Wnd_H
    if gfx.mouse_cap&1==1 and last_mouse_cap&1==0 then 
       mouse_ox, mouse_oy = gfx.mouse_x, gfx.mouse_y 
    end
    
    ----------------------------------------------------------------------------------
    --  Create buttons from selected tracks --
    --  Button_TB: see DRAW() function. Each created button is held in this table.
    Button_TB = {}                -- "Clear" the Button_TB first
    local btn_w = 50              -- width for new buttons
    local btn_h = 50              -- height for new buttons
    local current_draw_pos_x = 10 -- see end of loop below
    local current_draw_pos_y = 10 -- see end of loop below
    local btn_pad_x = 10          -- x space between buttons
    local btn_pad_y = 10          -- y space between buttons
    for i=1, reaper.CountSelectedTracks(0) do     -- loop through selected tracks
      -- get track and its name
      local tr = reaper.GetSelectedTrack(0, i-1)
      local retval, tr_name = reaper.GetSetMediaTrackInfo_String(tr, "P_NAME", "", false)
      -- Create a new button and insert it at the end of "Button_TB"
      Button_TB[#Button_TB+1] =
                            -- Desc: Element:new(x,y,w,h, r,g,b,a, lbl,fnt,fnt_sz, norm_val) 
                            Button:new( 
                                        current_draw_pos_x, --  x
                                        current_draw_pos_y, --  y 
                                        btn_w,              --  w
                                        btn_h,              --  h
                                        0.2,                --  r
                                        0.2,                --  g
                                        1.0,                --  b
                                        0.5,                --  a
                                        tr_name,            --  lbl (button name)
                                        "Arial",            --  label font
                                        15,                 --  label font size
                                        0                   --  norm_val
                                      )
      -- update draw pos to start of next button
      current_draw_pos_x = current_draw_pos_x + btn_w + btn_pad_x
      -- if button doesn't fit to current row, update draw pos to start of next column
      if current_draw_pos_x + btn_w + btn_pad_x > gfx.w then
        current_draw_pos_x = 10
        current_draw_pos_y = current_draw_pos_y + btn_h + btn_pad_y
      end
    end
    ----------------------------------------------------------------------------------
    
    Ctrl  = gfx.mouse_cap&4==4
    Shift = gfx.mouse_cap&8==8
    -----------------------
    --DRAW,MAIN functions--
    DRAW()--Main()
    -----------------------
    -----------------------
    last_mouse_cap = gfx.mouse_cap
    last_x, last_y = gfx.mouse_x, gfx.mouse_y
    char = gfx.getchar() 
    if char~=-1 then reaper.defer(mainloop) end --defer
    -----------  
    gfx.update()
    -----------
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
------
Init()
mainloop()

Last edited by spk77; 05-07-2016 at 10:51 AM.
spk77 is offline   Reply With Quote
Old 05-07-2016, 10:40 AM   #7
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

Cool! I've managed to do something similar :

but my coding skills are awful,this is the ugly code behind it
Code:
Button_TB = {}
xpos = 10
ypos = 10

    
    for i = 1 ,reaper.CountTracks(0) do    
        btn = Button:new(xpos,ypos,60,30, 0.2,0.2,1.0,0.5, "TEST","Arial",15, 0 )
        xpos = xpos + 70    
        Button_TB[i] = btn
        
        if xpos >= Wnd_W then
           xpos = 10
           ypos = ypos + 40
           if ypos >= Wnd_H then break end
        end    
    end
will study your code now
Sexan is online now   Reply With Quote
Old 05-07-2016, 10:47 AM   #8
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Sexan View Post
Cool! I've managed to do something similar :

but my coding skills are awful,this is the ugly code behind it
Not ugly at all! It's more or less the same code as in my example
spk77 is offline   Reply With Quote
Old 05-07-2016, 10:58 AM   #9
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

just one more question,why is this not working (your code) when I define it as an function and then call that function in main_loop?
Sexan is online now   Reply With Quote
Old 05-07-2016, 11:12 AM   #10
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Sexan View Post
just one more question,why is this not working (your code) when I define it as an function and then call that function in main_loop?
Maybe because there are local variables...did you include all the blue code in your function?
spk77 is offline   Reply With Quote
Old 05-07-2016, 11:16 AM   #11
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

my bad,I was defining the function on top of the script,put it above main loop and its fine
Sexan is online now   Reply With Quote
Old 05-07-2016, 12:28 PM   #12
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

starting to like this script very very much,awesome tool,cant way for it to get finished:

Last edited by Sexan; 05-07-2016 at 12:33 PM.
Sexan is online now   Reply With Quote
Old 05-07-2016, 03:01 PM   #13
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

figured out how click works on button!
Sexan is online now   Reply With Quote
Old 05-07-2016, 05:18 PM   #14
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

Ok next question,i have a very simple function that adds buttons based on how many tracks are there.how can i now select that track when i click on the button?buttons have track names and i want to select that track when i click on its button.thank you for helping
Sexan is online now   Reply With Quote
Old 05-08-2016, 12:33 AM   #15
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 271
Default

If you have some global function (for example, my_func), you can specify when you create buttons btn.onClick = my_func
__________________
ReaScripts
eugen2777 is offline   Reply With Quote
Old 05-08-2016, 01:03 AM   #16
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by eugen2777 View Post
If you have some global function (for example, my_func), you can specify when you create buttons btn.onClick = my_func
Thanks for this GUI code - it's very tidy!


@Sexan
Here's an example (it can be implemented in many ways)



Code:
local Button_TB = {} -- All created buttons are held in this table. 

local Element = {}
function Element:new(x,y,w,h, r,g,b,a, lbl,fnt,fnt_sz, norm_val)
    local elm = {}
    elm.def_xywh = {x,y,w,h,fnt_sz} -- its default coord,used for Zoom etc
    elm.x, elm.y, elm.w, elm.h = x, y, w, h
    elm.r, elm.g, elm.b, elm.a = r, g, b, a
    elm.lbl, elm.fnt, elm.fnt_sz  = lbl, fnt, fnt_sz
    elm.norm_val = norm_val
    ------
    setmetatable(elm, self)
    self.__index = self 
    return elm
end
--------------------------------------------------------------
--- Function for Child Classes(args = Child,Parent Class) ----
--------------------------------------------------------------
function extended(Child, Parent)
  setmetatable(Child,{__index = Parent}) 
end
--------------------------------------------------------------
---   Element Class Methods(Main Methods)   ------------------
--------------------------------------------------------------
function Element:update_xywh()
  if not Z_w or not Z_h then return end -- return if zoom not defined
  if Z_w>0.5 and Z_w<3 then  
   self.x, self.w = math.ceil(self.def_xywh[1]* Z_w) , math.ceil(self.def_xywh[3]* Z_w) --upd x,w
  end
  if Z_h>0.5 and Z_h<3 then
   self.y, self.h = math.ceil(self.def_xywh[2]* Z_h) , math.ceil(self.def_xywh[4]* Z_h) --upd y,h
  end
  if Z_w>0.5 or Z_h>0.5  then --fix it!--
     self.fnt_sz = math.max(9,self.def_xywh[5]* (Z_w+Z_h)/2)
     self.fnt_sz = math.min(22,self.fnt_sz)
  end       
end
--------
function Element:pointIN(p_x, p_y)
  return p_x >= self.x and p_x <= self.x + self.w and p_y >= self.y and p_y <= self.y + self.h
end
--------
function Element:mouseIN()
  return gfx.mouse_cap&1==0 and self:pointIN(gfx.mouse_x,gfx.mouse_y)
end
--------
function Element:mouseDown()
  return gfx.mouse_cap&1==1 and self:pointIN(mouse_ox,mouse_oy)
end
--------
function Element:mouseClick()
  return gfx.mouse_cap&1==0 and last_mouse_cap&1==1 and
  self:pointIN(gfx.mouse_x,gfx.mouse_y) and self:pointIN(mouse_ox,mouse_oy)         
end
--------
function Element:draw_frame()
  local x,y,w,h  = self.x,self.y,self.w,self.h
  gfx.rect(x, y, w, h, 0)--frame1
  gfx.roundrect(x, y, w-1, h-1, 3, true)--frame2         
end
--------------------------------------------------------------------------------
---   Create Element Child Classes(Button,Slider,Knob)   -----------------------
--------------------------------------------------------------------------------
local Button ={}; local Knob ={}; local Slider ={}; 
  extended(Button, Element)
  extended(Knob,   Element)
  extended(Slider, Element)
---Create Slider Child Classes(V_Slider,H_Slider)----
local H_Slider ={}; local V_Slider ={};
  extended(H_Slider, Slider)
  extended(V_Slider, Slider)

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
---   Button Class Methods   ---------------------------------------------------
--------------------------------------------------------------------------------
function Button:draw_lbl()
    local x,y,w,h  = self.x,self.y,self.w,self.h
    local fnt,fnt_sz = self.fnt, self.fnt_sz
    --Draw btn lbl(text)--
      gfx.set(0.7, 1, 0, 1)--set label color
      gfx.setfont(1, fnt, fnt_sz);--set label fnt
        local lbl_w, lbl_h = gfx.measurestr(self.lbl)
        gfx.x = x+(w-lbl_w)/2; gfx.y = y+(h-lbl_h)/2
        gfx.drawstr(self.lbl)
end
---------------------
function Button:draw()
    self:update_xywh()--Update xywh(if wind changed)
    local x,y,w,h  = self.x,self.y,self.w,self.h
    if self.norm_val == 1 then self.a = self.a+0.3 end
    local r,g,b,a  = self.r,self.g,self.b,self.a
    ---Get L_mouse state--
          --in element--
          if self:mouseIN() then a=a+0.1 end
          --in elm L_down--
          if self:mouseDown() then a=a+0.2 end
          --in elm L_up(released and was previously pressed)--
          if self:mouseClick() and self.onClick ~= nil then self.onClick() end
    --Draw btn(body,frame)--
    gfx.set(r,g,b,a)--set btn color
    gfx.rect(x,y,w,h,true)--body
    self:draw_frame()
    ------------------------
    self:draw_lbl()
end


                          
----------------------------------------------------------------------------------------------------
---   Main DRAW function   -------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
function DRAW()
    for key,btn  in pairs(Button_TB) do btn:draw()  end 
end

--------------------------------------------------------------------------------
--   INIT   --------------------------------------------------------------------
--------------------------------------------------------------------------------
function Init()
    --Some gfx Wnd Default Values--------------
    local R,G,B = 20,20,20        --0..255 form
    Wnd_bgd = R + G*256 + B*65536 --red+green*256+blue*65536  
    Wnd_Title,Wnd_W,Wnd_H,Wnd_Dock,Wnd_X,Wnd_Y = "Title", 330,250, 0,100,320
    --Init window------------------------------
    gfx.clear = Wnd_bgd         
    gfx.init( Wnd_Title, Wnd_W,Wnd_H, Wnd_Dock, Wnd_X,Wnd_Y )
    --Mouse--------------
    last_mouse_cap = 0
    last_x, last_y = 0, 0
end
----------------------------------------
--   Mainloop   ------------------------
----------------------------------------
function mainloop()
    --Z_w,Z_h = gfx.w/Wnd_W, gfx.h/Wnd_H
    if gfx.mouse_cap&1==1 and last_mouse_cap&1==0 then 
       mouse_ox, mouse_oy = gfx.mouse_x, gfx.mouse_y 
    end
    
    ----------------------------------------------------------------------------------
    --  Create buttons from tracks --
    --  Button_TB: see DRAW() function. Each created button is held in this table.
    Button_TB = {}                -- "Clear" the Button_TB first
    local btn_w = 100              -- width for new buttons
    local btn_h = 20              -- height for new buttons
    local current_draw_pos_x = 10 -- see end of loop below
    local current_draw_pos_y = 10 -- see end of loop below
    local btn_pad_x = 10          -- x space between buttons
    local btn_pad_y = 10          -- y space between buttons
    for i=1, reaper.CountTracks(0) do     -- loop through selected tracks
      -- get track and its name
      local tr = reaper.GetTrack(0, i-1)
      local retval, tr_name = reaper.GetSetMediaTrackInfo_String(tr, "P_NAME", "", false)
      
      -- Create a new button
      -- Desc: Element:new(x,y,w,h, r,g,b,a, lbl,fnt,fnt_sz, norm_val) 
      local btn = Button:new(   
                              current_draw_pos_x, --  x
                              current_draw_pos_y, --  y 
                              btn_w,              --  w
                              btn_h,              --  h
                              0.2,                --  r
                              0.2,                --  g
                              1.0,                --  b
                              0.5,                --  a
                              tr_name,            --  lbl (button name)
                              "Arial",            --  label font
                              15,                 --  label font size
                              0                   --  norm_val
                            )
                            
      btn.tr = tr  --store track id to current button table
      -- Override "norm_val". Set value from track's selected state
      if reaper.IsTrackSelected(tr) then
        btn.norm_val = 1
      else
        btn.norm_val = 0
      end
      btn.onClick = function()
                      local state = btn.norm_val == 1 -- is "state" true or false?
                      reaper.SetTrackSelected(btn.tr, not state) -- toggle "track selected" state
                    end
                                         
      
      
      
      -- update draw pos to start of next button
      current_draw_pos_x = current_draw_pos_x + btn_w + btn_pad_x
      -- if button doesn't fit to current row, update draw pos to start of next column
      if current_draw_pos_x + btn_w + btn_pad_x > gfx.w then
        current_draw_pos_x = 10
        current_draw_pos_y = current_draw_pos_y + btn_h + btn_pad_y
      end
      

      Button_TB[#Button_TB+1] = btn -- insert the created button at the end of "Button_TB"
    end
    ----------------------------------------------------------------------------------
    
    Ctrl  = gfx.mouse_cap&4==4
    Shift = gfx.mouse_cap&8==8
    -----------------------
    --DRAW,MAIN functions--
    DRAW()--Main()
    -----------------------
    -----------------------
    last_mouse_cap = gfx.mouse_cap
    last_x, last_y = gfx.mouse_x, gfx.mouse_y
    char = gfx.getchar() 
    if char~=-1 then reaper.defer(mainloop) end --defer
    -----------  
    gfx.update()
    -----------
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
------
Init()
mainloop()

Last edited by spk77; 05-08-2016 at 01:09 AM.
spk77 is offline   Reply With Quote
Old 05-08-2016, 05:07 AM   #17
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

Edit......

Last edited by Sexan; 05-09-2016 at 10:31 AM.
Sexan is online now   Reply With Quote
Old 05-08-2016, 12:50 PM   #18
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Maybe this helps (note: very raw, no error handling etc.)

Store/restore track selections:
https://stash.reaper.fm/27525/Add%20b...ode%29%202.lua


spk77 is offline   Reply With Quote
Old 05-08-2016, 01:27 PM   #19
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

let me dig into the code!
Sexan is online now   Reply With Quote
Old 05-09-2016, 04:21 AM   #20
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

edit:
Last update and progress post #21

Last edited by Sexan; 05-09-2016 at 10:31 AM.
Sexan is online now   Reply With Quote
Old 05-09-2016, 07:58 AM   #21
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

hm....I've partially done it but some (haha "some" ) hiccups are there :
https://stash.reaper.fm/27536/spkMODtest.lua

it remembers it on wrong position
edit:my bad, fixed it , now its looking good .... almost,now its overriding button names (because I'm deleting the table too soon)

Last edited by Sexan; 05-09-2016 at 02:40 PM.
Sexan is online now   Reply With Quote
Old 05-09-2016, 02:49 PM   #22
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

so here it is,the pre alpha of alpha (if someone can give a hand here it would be awesome),btw I'm ultra proud with it haha
the TRACK LISTS!


script:
https://stash.reaper.fm/27542/TrackListsAlpha.lua

I've commented everything I've done

Current problems :
1. When other track is saved it overrides the first ones chunk,need better way of storing in projexstate
2. GUI - when selecting new track then returning to previous one with buttons,new buttons draw on top of current buttons

Currently on one track its works well,but when second track is being added with buttons,it overrides the track chunks of previous track (poorly coded)
I would appreciate if someone could step in,I will be donating for help.

If I continue alone it will be extremely painful and slow (because I do the code with trial and error,brute force it until it works haha)

WARNING ! DO NOT USE IN REAL PROJECTS!

Last edited by Sexan; 05-10-2016 at 02:24 AM.
Sexan is online now   Reply With Quote
Old 05-10-2016, 03:17 AM   #23
stereolost
Human being with feelings
 
stereolost's Avatar
 
Join Date: Mar 2015
Location: Moscow, Russia
Posts: 206
Default

Thank you so much for starting this long awaited thing!
stereolost is offline   Reply With Quote
Old 05-10-2016, 04:30 AM   #24
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

Update :
Problem 1. Fixed (projextstate not needed for buttons,don't know why I've put it in the first place )

https://stash.reaper.fm/27545/TrackListsAlpha2.lua


Working on all tracks now

Now I need to solve GUI problem (new added buttons draw over buttons on track change)

Last edited by Sexan; 05-10-2016 at 05:53 AM.
Sexan is online now   Reply With Quote
Old 05-10-2016, 07:42 AM   #25
musicbynumbers
Human being with feelings
 
musicbynumbers's Avatar
 
Join Date: Jun 2009
Location: South, UK
Posts: 14,214
Default

Wow, don't know how I missed this one so far! Looks right up my street!

Subscribed and will try it when I get a breather.

Nice work!
__________________
subproject FRs click here
note: don't search for my pseudonym on the web. The "musicbynumbers" you find is not me or the name I use for my own music.
musicbynumbers is offline   Reply With Quote
Old 05-11-2016, 06:34 AM   #26
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

Edit: My silly coding error

Last edited by Sexan; 05-11-2016 at 10:24 AM.
Sexan is online now   Reply With Quote
Old 05-11-2016, 08:46 AM   #27
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 271
Default

Sexan, how to reproduce the error?
My English leaves much to be desired. If you explain in Russian ( or pictures for fools) , I can help to fix it .
__________________
ReaScripts
eugen2777 is offline   Reply With Quote
Old 05-11-2016, 10:19 AM   #28
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

Hi,fixed the error,was in if loop that I've excluded.Now it works fine
https://stash.reaper.fm/27561/TrackListsAlpha3.lua

Now I'm working on rewriting the Button drawing so for new window it starts from point 0 and for existing buttons it draws from the last button (how I've done it in first version is very cruel and bad and very simple,if new window x-y=0,but that would override tracks that has buttons).This is a little hard for me .If anyone can help here I would appreciate
How it currently works :

Last edited by Sexan; 05-11-2016 at 10:32 AM.
Sexan is online now   Reply With Quote
Old 05-11-2016, 10:36 AM   #29
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 271
Default

Quote:
This is a little hard for me
You can do it yourself. I'm sure. Help is not needed
__________________
ReaScripts
eugen2777 is offline   Reply With Quote
Old 05-11-2016, 10:39 AM   #30
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

The biggest challenge will be how to store button table to reaper.SetProjExtState,I've did a little research and its not that simple since reaper.SetProjExtState can't store tables.(I've already tried something but no success)
Sexan is online now   Reply With Quote
Old 05-11-2016, 11:09 AM   #31
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

Almost there
https://stash.reaper.fm/27564/TrackListsAlpha3.lua

Code:
for k,v in pairs(Button_TB) do ----iterate table
         if sel_track == v.tr then  --- if current track is in the table
            v.x = current_draw_pos_x
            v.y = current_draw_pos_y + ((btn_h + btn_pad_y)*counter)
                   if v.y + btn_h + btn_pad_y >= gfx.h-10 then                      
                      v.y = 30
                      v.x = current_draw_pos_x + btn_w + btn_pad_x  
                    end           
            current_track[#current_track+1] = Button_TB[k] --- add that track to new temp table
            counter = counter + 1 -- increase button counter                       
         end
     end
Stuck when in next row......
Sexan is online now   Reply With Quote
Old 05-11-2016, 11:59 AM   #32
musicbynumbers
Human being with feelings
 
musicbynumbers's Avatar
 
Join Date: Jun 2009
Location: South, UK
Posts: 14,214
Default

All good stuff!


I haven't got round to testing yet but are there any things to be aware of yet that you know of?

and this script has been done 2 times before (that I'm aware of) so I just wondered what made you redo it and if you've managed to solve any issues the others had?

It's a feature I've wanted forever to be honest and I can't wait to try this version soon!
__________________
subproject FRs click here
note: don't search for my pseudonym on the web. The "musicbynumbers" you find is not me or the name I use for my own music.
musicbynumbers is offline   Reply With Quote
Old 05-11-2016, 12:07 PM   #33
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

The first initial version was very badly written,lots of unnecessary code,for example : the way which the window will show only buttons for selected track (that was really "oh my god" of the code)
That part is rewritten and now is much better.

The GUI part also needs to be rewritten (it was done really really simple in the first version (if other track is selected,reset the x-y,but that caused buttons to draw over buttons).Btw this is the last part of GUI that needs to be changed.

There are no current issues except that (I've tried lots and lots of storing and recalling and all fine,did not encounter any bug regarding that)

Other than that the script works really REALLY well! But for now it does not store with the project.
That part is really REALLY complicated (one of the script gurus will have to do it) because projextstate cant store tables,so some other approach is needed.This will need major testing when done,since here is when potential problems start

Since I am a noob and while writing the code I'm learning and lots of googleing research,so It will be pretty slow progress (I still hope some guru will help (donations incoming))

But without briliant Eugen2777 gui template script,I would not even touch this (tried many times in the past) so thank you very much!

Quote:
Originally Posted by musicbynumbers View Post
and this script has been done 2 times before (that I'm aware of) so I just wondered what made you redo it and if you've managed to solve any issues the others had?
There is no LUA version as I am aware of it ??
But other ones are eel and not "all in one" script but many shortcuts needed in order to make it work.I wanted to do the "all in one" script and in LUA so I can modify it when I want or add features (I dont understand eel at all its like alien language to me).I do not know any issues others had (did not used any of it except one version I've just tried one time and that version was not not finished).

Last edited by Sexan; 05-11-2016 at 12:25 PM.
Sexan is online now   Reply With Quote
Old 05-11-2016, 04:02 PM   #34
musicbynumbers
Human being with feelings
 
musicbynumbers's Avatar
 
Join Date: Jun 2009
Location: South, UK
Posts: 14,214
Default

Thanks for explaining that, appreciated and understood now!

It is a very cool script indeed! checking it out soon!
__________________
subproject FRs click here
note: don't search for my pseudonym on the web. The "musicbynumbers" you find is not me or the name I use for my own music.
musicbynumbers is offline   Reply With Quote
Old 05-11-2016, 04:40 PM   #35
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

Finally!!!!!! I can go to sleep now!
https://stash.reaper.fm/27568/TrackListAlpha4.lua
Sexan is online now   Reply With Quote
Old 05-11-2016, 04:48 PM   #36
snooks
Banned
 
Join Date: Sep 2015
Posts: 1,650
Default

Quote:
Originally Posted by Sexan View Post
Other than that the script works really REALLY well! But for now it does not store with the project.
That part is really REALLY complicated (one of the script gurus will have to do it) because projextstate cant store tables,so some other approach is needed.This will need major testing when done,since here is when potential problems start.
I use pickle.lua with my gui library to convert tables to strings for storing/retrieving from ext states...

https://github.com/Lazzle/ReaMIDI/bl...res/pickle.lua

So (this is edited from the el gui.lua script and isn't tested but should work)...
Code:
--do whatever to get pickle.lua included/required/loaded, maybe this
dofile(reaper.GetResourcePath().."/Scripts/pickle.lua")

function storeStateTable(state_name,key,table)
  reaper.SetProjExtState(0,state_name,tostring(key),pickle(table),true)
end

function recallStateTable(state_name,key)
  local ok,found,cnt=true,false,0
  local k,state
  while not found and ok do
    ok,k,state=reaper.EnumProjExtState(0,state_name,cnt)
    if tostring(k)==tostring(key) then 
      found=true ok=false
    end 
    cnt=cnt+1 
  end
  if found then
    return unpickle(state)
  else
    return nil
  end
end
snooks is offline   Reply With Quote
Old 05-11-2016, 04:56 PM   #37
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

Thank you very much!!!! Will test it in morning
Sexan is online now   Reply With Quote
Old 05-12-2016, 01:01 AM   #38
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

eugen2777 please when you got some time , can you check why my script won't auto update size when enabled?
https://stash.reaper.fm/27571/TrackListApha5.lua
Its because I'm updating button positions on the fly,but can something be done
or modified to make it work?


and how can I implement now if button is ALT clicked to remove it?

Last edited by Sexan; 05-12-2016 at 01:29 AM.
Sexan is online now   Reply With Quote
Old 05-12-2016, 01:11 AM   #39
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,591
Default

edit.....

Last edited by Sexan; 05-25-2016 at 05:11 AM.
Sexan is online now   Reply With Quote
Old 05-12-2016, 02:09 AM   #40
snooks
Banned
 
Join Date: Sep 2015
Posts: 1,650
Default

Yes, your buttons are storing MediaTrack objects, which is "userdata" in Lualand so you need to either store them as a GUID and convert them to MediaTrack objects when needed or just convert when storing/recalling.
Code:
guid=reaper.GetTrackGUID(tr)

tr=reaper.BR_GetMediaTrackByGUID(0,guid)
snooks 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 07:07 AM.


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