View Single Post
Old 10-22-2019, 05:19 PM   #544
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,230
Default

made some minor adjustments to get this to work but still some issues. using 'buttons_per_row0' returned an error:
Quote:
toolbartest-01_GUI.lua:78: attempt to perform arithmetic on a nil value (global 'buttons_per_row0')
changing to just 'buttons_per_row' does not return an error.
Code:
local button_width = 62
local button_height = 32
local buttons_per_row = 4

for k, v in ipairs(toolbar_buttons) do
  GUI.New(
    "btn_"..k, 
    "Button", 
    1, 
    (k - 1) * (button_width + 5), -- x
    math.floor((k - 1) / buttons_per_row) *  button_height, -- y
    button_width, -- w
    button_height, -- h
    v.label, 
    function() reaper.Main_OnCommand(v.command, 0) end
  )
end
the problem with the code above is that, while it does jump to a new row as defined in 'local buttons_per_row = 4', it does not reset the x position. it just goes on from the end of the preceding button rather than starting a new row at 0. been trying to figure out a way to flag that but haven't figured out yet.

if i can get this working, i'll give a go at the newer method. this seems so close, though, that i want to try to get it to work.

thanks,
babag
babag is offline   Reply With Quote