Old 11-04-2018, 08:03 PM   #321
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default

Try calling the listbox's init method as well. It will need to redraw some stuff internally as the size changes.
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 11-04-2018, 08:13 PM   #322
ausbaxter
Human being with feelings
 
Join Date: Apr 2016
Posts: 37
Default

You sir are a gentleman and a scholar! Works like a charm!
ausbaxter is offline   Reply With Quote
Old 11-05-2018, 04:00 PM   #323
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default

God... I feel really dumb.

I'm working on porting Radial Menu to the current GUI version so I can actually update it, and ran into a crash that also happens in GUI Builder.

I knew that it was because the script was running out of graphics buffers internally, but it confused me because there's always been code to specifically free them up as elements are deleted.

...or at least, it would have been doing that if that code was being run. One little typo, not even enough to cause problems on its own, was allowing the GUI to happily skip right over that logic.

TL;DR Small update, should fix issues with scripts crashing if they create/delete too many elements. The GUI will now also explicitly tell you (in the crash report) if it fails because there weren't any more buffers.
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 11-05-2018, 05:20 PM   #324
ausbaxter
Human being with feelings
 
Join Date: Apr 2016
Posts: 37
Default

Hey Lokasenna,

I found a bug when closing out a "Window" class. When closing a window it calls

Code:
function GUI.Window:showlayers()
    
    -- Set the layer visibility back to where it was
    for i = 1, GUI.z_max do
        GUI.elms_hide[i] = self.elms_hide[i]
    end
    
    -- Hide the window and its child layers
    GUI.elms_hide[self.z] = true
    for k, v in pairs(self.z_set) do
        GUI.elms_hide[v] = true
    end
    
end
Here was the behavior I saw:



Redrawing the previously hidden layers worked after I reset the hidden elements table:

Code:
    for i = 1, GUI.z_max do
        GUI.elms_hide = {}
        GUI.elms_hide[i] = self.elms_hide[i]
    end
Probably should submit a pull request on your github sorry!
ausbaxter is offline   Reply With Quote
Old 11-05-2018, 08:47 PM   #325
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default

It's always behaved correctly on my end. Mind PMing the script you're working with so I can have a look?
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 11-06-2018, 06:31 PM   #326
MusoBob
Human being with feelings
 
Join Date: Sep 2014
Posts: 409
Default

I haven't look at the new features of the current GUI Library, but I was thinking of adding a chord sheet layout GUI
that would represent the timeline measures/regions with like 4 measures with bar numbers
and region color and name(chord name) then a new line so on....
when you edit the sheet it will apply it to the regions.
I have it set to ignore regions with "@" as a prefix in the region name to allow for usage of other regions beside chords.
Does it seem it would be possible ??



Last edited by MusoBob; 11-07-2018 at 02:44 PM.
MusoBob is offline   Reply With Quote
Old 11-08-2018, 01:53 AM   #327
MusoBob
Human being with feelings
 
Join Date: Sep 2014
Posts: 409
Default

I was trying to work out how to do this after playing around with the GUI Builder.
Was trying the textbox but maybe it's better to have any font you like for the chords and color section then when you click them (function btn_click) it will move the cursor to that region then Markers: Edit region near cursor, then get the regions reaper.EnumProjectMarkers3 and update the GUI by GUI.elms.bar1-beat1_chord:ondelete() or loop it through all the current region chords/bars.
Just not sure if you can get scrollbars on the GUI ?? I know with AutoHotKey the feature wasn't added yet.

It will have to follow the time signature and maybe set it to 1/4 or 1/8 so you could have 4 chords per bar or 8 chords per bar @ 4/4 or maybe just represent what the grid is set to ??
Maybe if the chord name is more than so many characters it will use a smaller font size ??
MusoBob is offline   Reply With Quote
Old 11-08-2018, 05:46 AM   #328
MusoBob
Human being with feelings
 
Join Date: Sep 2014
Posts: 409
Default

Not sure how to get the GUI measures display to sync ??


MusoBob is offline   Reply With Quote
Old 11-08-2018, 06:03 AM   #329
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 1,939
Default

they seem to be in sync in your gif or this not real example? : ) reminds me band in a box : ) coincidence?
deeb is offline   Reply With Quote
Old 11-08-2018, 07:07 AM   #330
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default

- A chord sheet is certainly doable, although I think the easiest approach would be to use a frame the size of the whole window and just change its draw method to do all of that for you. Maybe some blitting as well to reduce the amount of redrawing it has to do.

- Scrollbars aren't currently available. I tried for a bit but couldn't get the handles to place themselves correctly, which was weird because the code was just lifted directly from the Slider class.

- As deeb said, that .gif looks like they're in sync.
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 11-08-2018, 12:30 PM   #331
MusoBob
Human being with feelings
 
Join Date: Sep 2014
Posts: 409
Default

Yea that's ReWire syncing

So you would have to have scroll buttons that move the whole display

up 4 bars or down 4 bars at a time to edit the chords in the GUI, same way it would play/sync ??


MusoBob is offline   Reply With Quote
Old 11-08-2018, 02:09 PM   #332
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default

Pretty much. An alternative solution might be to make the window a grid of Frame elements, and then when the "view" needs to change you just update the content, colors, etc of each frame. (Might need to init them, I forget)
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 11-08-2018, 02:52 PM   #333
MusoBob
Human being with feelings
 
Join Date: Sep 2014
Posts: 409
Default

If you could please make a little demo gui of what you mean that might get me started.
Thanks.
MusoBob is offline   Reply With Quote
Old 11-10-2018, 12:31 AM   #334
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 1,939
Default

I think he means: make example 16 labels + button up + button down and update their labels values acording to what is happening (sync or up or down)

16 is a fixed number, so you could refine even more and do something like check the space available and create the number of labels that this space permits. And work from there.

Last edited by deeb; 11-10-2018 at 12:36 AM.
deeb is offline   Reply With Quote
Old 11-10-2018, 03:33 AM   #335
MusoBob
Human being with feelings
 
Join Date: Sep 2014
Posts: 409
Default

I made this in the GUI Builder (a save session in GUI Builder would be good) it's just frames, just not sure how to correspond it to the region list, it needs to be able to show a chord on each beat if needed, and the frames only have one text: text = "",
There is Get Inputs I could use to edit the region names but I think the normal region edit is best.
I can still enter chords from the other main GUI and the Circle of Fifths radial menu.
Color sections can be added/change with the main GUI also.










Last edited by MusoBob; 11-10-2018 at 03:40 AM.
MusoBob is offline   Reply With Quote
Old 11-10-2018, 05:56 AM   #336
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 1,939
Default

i am not sure about your question:


There was an example always running in loop and in that way you can check for changes on markers, or whatever you need, .. the example is: first selected track, you will have to get the markers information you need inside the main function

also, .. the input you will use is just one so probably:
1 - you have to create the elements you need as an array or give them names so that you know what is what(i guess not with GUI builder - never used tho)

Code:
 
something like this (i don't remember the syntax) , .. 
for i=1,16 do
  GUI.New("my_frm_list_"[i], 	"Frame", 	...
end
or

Code:
 
for i=1,16 do
  GUI.New("my_frm_list_"..i, 	"Frame", 	...
end
probably first is better so you can take advantage of array functions

2- onclick one of the element display the input box and put's this value on the right position of the array having in mind the up and down state ofcourse.

Hope it helps

Code:
--[[
	Lokasenna_GUI 2.0 preview

	- Using the Main loop to monitor and interact with things in Reaper
	- Using z layers and related functions to move elements around
	- Changing elements' methods for your own purposes

]]--

local dm, _ = debug_mode
local function Msg(str)
	reaper.ShowConsoleMsg(tostring(str).."\n")
end

local info = debug.getinfo(1,'S');
script_path = info.source:match[[^@?(.*[\/])[^\/]-$]]


-- I hate working with 'requires', so I've opted to do it this way.
-- This also works much more easily with my Script Compiler.
local function req(file)
	
	if missing_lib then return function () end end
	
	local ret, err = loadfile(script_path .. file)
	if not ret then
		reaper.ShowMessageBox("Couldn't load "..file.."\n\nError: "..tostring(err), "Library error", 0)
		missing_lib = true		
		return function () end

	else 
		return ret
	end	

end


-- The Core library must be loaded prior to any classes, or the classes will throw up errors
-- when they look for functions that aren't there.
req("Core.lua")()

-- For better cross-platform behavior.
local sep = GUI.file_sep

req("Classes"..sep.."Class - Label.lua")()
--req("Classes"..sep.."Class - Knob.lua")()
--req("Classes"..sep.."Class - Tabs.lua")()
req("Classes"..sep.."Class - Slider.lua")()
--req("Classes"..sep.."Class - Button.lua")()
--req("Classes"..sep.."Class - Menubox.lua")()
--req("Classes"..sep.."Class - Checklist.lua")()
--req("Classes"..sep.."Class - Radio.lua")()
--req("Classes"..sep.."Class - Textbox.lua")()
req("Classes"..sep.."Class - Frame.lua")()

-- If any of the requested libraries weren't found, abort the script.
if missing_lib then return 0 end



GUI.name = "Example - Main, Z, and Methods"
GUI.x, GUI.y, GUI.w, GUI.h = 0, 0, 300, 128
GUI.anchor, GUI.corner = "mouse", "C"


-- Pre-declaring this so every function has access to it
local tr



--[[	

	New elements are created by:
	
	GUI.New(name, class, params)
	
	and can then have their parameters accessed via:
	
	GUI.elms.name.param
	
	ex:
	
	GUI.New("my_new_label", "Label", 1, 32, 32, "This is my label")
	GUI.elms.my_new_label.color = "magenta"
	GUI.elms.my_new_label.font = 1
	
	
		Classes and parameters
	
	Button		name, 	z, 	x, 	y, 	w, 	h, caption, func[, ...]
	Checklist	name, 	z, 	x, 	y, 	w, 	h, caption, opts[, dir, pad]
	Frame		name, 	z, 	x, 	y, 	w, 	h[, shadow, fill, color, round]
	Knob		name, 	z, 	x, 	y, 	w, 	caption, min, max, steps, default[, vals]	
	Label		name, 	z, 	x, 	y,		caption[, shadow, font, color, bg]
	Menubox		name, 	z, 	x, 	y, 	w, 	h, caption, opts
	Radio		name, 	z, 	x, 	y, 	w, 	h, caption, opts[, dir, pad]
	Slider		name, 	z, 	x, 	y, 	w, 	caption, min, max, steps, handles[, dir]
	Tabs		name, 	z, 	x, 	y, 		tab_w, tab_h, opts[, pad]
	Textbox		name, 	z, 	x, 	y, 	w, 	h[, caption, pad]

	
]]--

GUI.New("lbl_track", "Label",	1,	96, 8, "No track selected!", true, 2, "red")
GUI.New("frm_track", "Frame",	2,	0, 0, 300, 128, false, true, "faded", 0)
GUI.New("sldr_pan", "Slider",	3,	88, 64, 128, "First selected track's Pan:", -100, 100, 200, 100, "h")

-- Layer 5 will never be shown or updated
-- (See the Main function below)
GUI.elms_hide[5] = true



local function update_pan()
	
	reaper.SetMediaTrackInfo_Value( tr, "D_PAN", GUI.Val("sldr_pan")/100 )
	
end


-- Class methods can be overwritten, either at the class level or
-- for individual elements.

-- You can also easily add your own code to methods:

-- Needs to be global, since GUI already exists
function GUI.elms.sldr_pan:onmousedown()
	
	-- Run the slider's normal method
	
	-- Note that we have to call the method as a function here; we
	-- can't use the : syntax because sldr_pan's 'self' needs to be
	-- passed on as a value. If we used a :, it would pass GUI.Slider
	GUI.Slider.onmousedown(self)
	update_pan()
	
end
function GUI.elms.sldr_pan:ondrag()
	GUI.Slider.ondrag(self)
	update_pan()
end
function GUI.elms.sldr_pan:onwheel()
	GUI.Slider.onwheel(self)
	update_pan()
end
function GUI.elms.sldr_pan:ondoubleclick()
	GUI.Slider.ondoubleclick(self)
	update_pan()
end



-- This will be run on every update loop of the GUI script; anything you would put
-- inside a reaper.defer() loop should go here. (The function name doesn't matter)
local function Main()
	
	-- Check the track state and toggle our warning label as needed
	tr = reaper.GetSelectedTrack( 0, 0 )
	
	if tr then
		
		-- Save a bit of CPU by only doing this if we need to
		if GUI.elms.lbl_track.z == 1 then
			
			-- These both accomplish the same thing...
			
			-- lbl_track is moved to a different layer, which we've permanently
			-- hidden above. Use this if you have several elements on a single 
			-- layer and only want to hide one of them. e.g. adjusting which
			-- options are available depending on other things the user does.
			GUI.elms.lbl_track.z = 5
			
			-- frm_track's entire layer is hidden. This is what the Tabs element
			-- uses.
			GUI.elms_hide[GUI.elms.frm_track.z] = true
			
			
			-- Layers can also be frozen; they'll be drawn, but won't receive
			-- any user input. Use this for i.e. having a slider display an
			-- RMS value, since the user can't do anything with it.
			
			-- Completely unnecessary here, because frm_track is on top and will
			-- "steal" any user input.
			
			GUI.elms_freeze[GUI.elms.sldr_pan.z] = false
			
			
			-- Force a redraw of every layer
			GUI.redraw_z[0] = true
			
		end
		
		-- See if the track's Pan value has been changed and update the slider
		local pan = reaper.GetMediaTrackInfo_Value( tr, "D_PAN" )
		if math.abs( pan - (GUI.Val("sldr_pan") / 100) ) > 0.00 then
			
			-- Converting the returned value (-1 to 1) to Slider steps (0 to 200)
			pan = (math.floor(100*pan) - GUI.elms.sldr_pan.min )
			
			-- Pan knobs can actually be at 0% L or R; correcting for that.
			if pan < 100 then pan = pan + 1 end
			
			GUI.Val("sldr_pan", pan )
			
		end		
		
	else
	
		if GUI.elms.lbl_track.z == 5 then
			
			GUI.elms.lbl_track.z = 1
			GUI.elms_hide[GUI.elms.frm_track.z] = false
			GUI.elms_freeze[GUI.elms.sldr_pan.z] = true
		
			GUI.redraw_z[0] = true
			
		end
	
	end
	
	
end

GUI.Init()

-- Tell the GUI library to run Main on each update loop
-- Individual elements are updated first, then GUI.func is run, then the GUI is redrawn
GUI.func = Main

-- How often (in seconds) to run GUI.func. 0 = every loop.
GUI.freq = 0

GUI.Main()

Last edited by deeb; 11-10-2018 at 06:08 AM.
deeb is offline   Reply With Quote
Old 11-12-2018, 12:34 AM   #337
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 68
Default

THIS is the present from GOD! I like it sooooo much!!

A question: I tried to made a button and then let it run an action. But it only run it one time. Then I kept on clicking on it, it did nothing
dsyrock is online now   Reply With Quote
Old 11-12-2018, 01:59 AM   #338
MusoBob
Human being with feelings
 
Join Date: Sep 2014
Posts: 409
Default

For button actions I use:


Code:
-- Button Colors  = {r, g, b, transparency}
GUI.colors["my_pink"] = {255, 124, 192, 255}
GUI.colors["my_purple"] = {119, 17, 174, 255}


function btn_click_sect_help()
    commandID1 = reaper.NamedCommandLookup("_RSbe31a3de2526d47fa8357af06379275cceb291c2")
    reaper.Main_OnCommand(commandID1, 0) -- Script: ReaTrak sections help.lua
    end

GUI.New("sect_help_btn",      "Button",           3, 225+x1, 32+y1, 40, 17, "HELP", btn_click_sect_help)
GUI.elms.sect_help_btn.col_txt = "white" --Or you can use "my_pink" "my_purple"
GUI.elms.sect_help_btn.col_fill = "green"
GUI.elms.sect_help_btn.font = {"Arial", 12, "bi"} --"bi" bold italic
....

Last edited by MusoBob; 11-12-2018 at 02:25 AM.
MusoBob is offline   Reply With Quote
Old 11-12-2018, 02:16 AM   #339
MusoBob
Human being with feelings
 
Join Date: Sep 2014
Posts: 409
Default

@deeb thanks for that I see how that works, should be able to use it, appreciate any input/ideas.

I thought with the Chord Region Sheet GUI I just need it to represent the measures and time signature
with editable buttons for each beat of the time signature within the measure cell, frame or whatever,
then I should be able to use part of
"Script: X-Raym_Create text items on first selected track from regions.lua"
to draw in the names in the GUI at their start position.
bpi = reaper.GetProjectTimeSignature()
cursor_pos = reaper.GetCursorPosition()
MusoBob is offline   Reply With Quote
Old 11-12-2018, 07:18 AM   #340
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default

Quote:
Originally Posted by dsyrock View Post
THIS is the present from GOD! I like it sooooo much!!

A question: I tried to made a button and then let it run an action. But it only run it one time. Then I kept on clicking on it, it did nothing
Strange. Make sure that when you assign the function to the button you're *not* adding ()s.

Good - gives the button the name of a function to run:
Code:
GUI.elms.my_btn.func = my_function
Bad - Runs the function immediately and gives the button whatever value it returned:
Code:
GUI.elms.my_btn.func = my_function()
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 11-12-2018, 08:27 PM   #341
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 68
Default

Quote:
Originally Posted by Lokasenna View Post
Strange. Make sure that when you assign the function to the button you're *not* adding ()s.

Good - gives the button the name of a function to run:
Code:
GUI.elms.my_btn.func = my_function
Bad - Runs the function immediately and gives the button whatever value it returned:
Code:
GUI.elms.my_btn.func = my_function()
Thanks, that's exactly what I had done, the() thing.

And there is a new question, about the Knob. How to combine a knob with a function? I checked your document and read the Knob-Output parts, but still confusing about it
dsyrock is online now   Reply With Quote
Old 11-12-2018, 09:13 PM   #342
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default

The knob (and slider, I think?)'s output property lets you format the values it displays.

Setting it to a number:
Code:
GUI.elms.my_knob.output = 5
will always show 5.

Setting it to a function will show whatever is returned by calling my_function(value). For instance, to make the knob show "dB" next to every number you would use:
Code:
local function append_db(value)
  return value .. "dB"
end

GUI.elms.my_knob.output = append_db
(One of the example scripts in the Dev. Tools package does this... I think)

Setting it to a table will show whatever value it finds in the table, using the value as a key. This is good if you want to convert the numeric value to some sort of "mode":
Code:
local knob_strings = {
  [0] = "Please don't hurt me",
  [1] = "Hey, not too rough",
  [2] = "Hurt me plenty",
  [3] = "Ultra-violence",
  [4] = "Nightmare"
}

GUI.elms.my_knob.output = knob_string
It will always pass the value through tostring afterward, so buggy output shouldn't crash the script (yay!) but you might see a bunch of nil if something goes wrong (boo!).

https://github.com/jalovatt/Lokasenn...wiki/2.00-Knob
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 11-12-2018, 10:06 PM   #343
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 68
Default

Quote:
Originally Posted by Lokasenna View Post
Setting it to a function will show whatever is returned by calling my_function(value). For instance, to make the knob show "dB" next to every number you would use:
Code:
local function append_db(value)
  return value .. "dB"
end

GUI.elms.my_knob.output = append_db

OK, it seems that the knob can not run a function directly, it can only send some value out. So is the slider?

If I want a knob to adjust item's volume, I need to define a function that get the value from knob using GUI.Val("myknob"), then give it to item via SetMediaItemSelected, and then run the function in defer mode. I tried before and it worked. But I do not know if there any better way to code it. Please let me know, THANKS!


UPDATE: I just realized that I can use "onmousedown" and "onmousedrag" to do that, thats amazing! Thanks again!!

Last edited by dsyrock; 11-13-2018 at 09:44 AM.
dsyrock is online now   Reply With Quote
Old 11-12-2018, 10:38 PM   #344
MusoBob
Human being with feelings
 
Join Date: Sep 2014
Posts: 409
Default

Can you please give some examples of the Additional Parameters for Textbox
https://github.com/jalovatt/Lokasenn...i/2.00-Textbox
bg---Color to be drawn underneath the label. Defaults to "wnd_bg"
shadow---Boolean. Draw a shadow beneath the label?
color---Text color
font_a---Label font
font_b---Text font
cap_pos---Position of the text box's label. "left", "right", "top", "bottom"
focus---Boolean. Whether the textbox is "in focus" or not, allowing users to type.
This setting is automatically updated, so you shouldn't need to change it yourself in most cases.

I need to be able to change font color bg color font, size, type etc..
and to set a default name (current region name of the value from reaper.EnumProjectMarkers3(0, i))






EDIT: Found it from the GUI Builder !

Code:
GUI.New("Textbox1", "Textbox", {
    z = 11,
    x = 288,
    y = 96,
    w = 96,
    h = 20,
    caption = "Textbox1",
    cap_pos = "left",
    font_a = 3,
    font_b = "monospace",
    color = "txt",
    bg = "wnd_bg",
    shadow = true,
    pad = 4,
    undo_limit = 20
})
Now I need to change the black textbox bg not the Caption bg. Wasn't there an alpha level on some other elements to make it transparent ?




...

Last edited by MusoBob; 11-13-2018 at 01:25 AM.
MusoBob is offline   Reply With Quote
Old 11-13-2018, 03:59 AM   #345
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 68
Default

Well there comes a new question about slider

If I change the slider's max value in a function

Code:
GUI.elms.myslider.max=value
Actually it was changed successfully. But I don't know how to "refresh" or "update" the slider. Seems I only changed the value but couldn't change the graphic. Any idea of this?


UPDATE: Seems like I need the redraw method, but I tried
Code:
function GUI.elms.myslider:redraw()

  GUI.Slider.redraw(self)

  self.max=newvalue
end

GUI.elms.myslider:redraw()
But nothing happened

Last edited by dsyrock; 11-13-2018 at 02:41 PM.
dsyrock is online now   Reply With Quote
Old 11-13-2018, 05:09 PM   #346
MusoBob
Human being with feelings
 
Join Date: Sep 2014
Posts: 409
Default

deeb's post above has a sample slider that updates
https://forum.cockos.com/showpost.ph...&postcount=336
MusoBob is offline   Reply With Quote
Old 11-13-2018, 05:14 PM   #347
MusoBob
Human being with feelings
 
Join Date: Sep 2014
Posts: 409
Default

How do you set a default value for a textbox ? so if I move the text box with a up/down scroll button with x=x+50 or x=x-50 i still get the same name in the textbox.
MusoBob is offline   Reply With Quote
Old 11-13-2018, 08:37 PM   #348
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default

Changing a slider's min/max/increment will need it to do some recalculating internally. I think calling GUI.elms.my_slider:init() should do it, not sure though.
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 11-13-2018, 08:38 PM   #349
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default

Quote:
Originally Posted by MusoBob View Post
How do you set a default value for a textbox ? so if I move the text box with a up/down scroll button with x=x+50 or x=x-50 i still get the same name in the textbox.
Not sure what you mean. Moving an element doesn't affect its value.
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 11-13-2018, 09:57 PM   #350
MusoBob
Human being with feelings
 
Join Date: Sep 2014
Posts: 409
Default

I will have a textbox for each beat @ 4/4 that will be 16 per row,
I just got to find some way to scroll them up/down with the buttons and
scroll up 1 row after it plays the 16 on each row.
That's just one cell/textbox at the moment.


Code:
local function scroll_up() --scroll up one row

    y1=y1+50
    GUI.New("my_text1", "Textbox", {
        z = 1,
        x = x1,
        y = y1,
        w = 57,
        h = 35,
        caption = "",
        cap_pos = "left",
        font_a = 3,
        font_b = {"Chords", 28},
        color = "white",
        bg = "wnd_bg",
        shadow = true,
        pad = 4,
        undo_limit = 20
        
    })
    
end
MusoBob is offline   Reply With Quote
Old 11-13-2018, 10:36 PM   #351
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 1,939
Default

Just an alert musobob, input boxes don't allow copy pasting and other things (afaik)... Reaper input boxes allow. I just thought I should say that. On the other hand might be not so "beautiful". anyway
deeb is offline   Reply With Quote
Old 11-14-2018, 06:23 AM   #352
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 68
Default

Quote:
Originally Posted by Lokasenna View Post
Changing a slider's min/max/increment will need it to do some recalculating internally. I think calling GUI.elms.my_slider:init() should do it, not sure though.
I found a solution. I can't just change the max value, instead, I have to recreate a new slider, with a new max value. It seems stupid, but worked.

But I don't know why, after I recreating it, I had to declare the function
Code:
GUI.elms.myslider:onmousedown()
and
Code:
 GUI.elms.myslider:ondrag()
Cause the orginal ones didn't work after I recreated the slider
dsyrock is online now   Reply With Quote
Old 11-14-2018, 06:54 AM   #353
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default

Quote:
Originally Posted by MusoBob View Post
I will have a textbox for each beat @ 4/4 that will be 16 per row,
I just got to find some way to scroll them up/down with the buttons and
scroll up 1 row after it plays the 16 on each row.
You might find it easier to just have multiple rows and move the values up to the next row.

Quote:
Originally Posted by deeb View Post
Just an alert musobob, input boxes don't allow copy pasting and other things (afaik)... Reaper input boxes allow. I just thought I should say that. On the other hand might be not so "beautiful". anyway
They've had copy/paste since around June.
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 11-14-2018, 06:56 AM   #354
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default

Quote:
Originally Posted by dsyrock View Post
I found a solution. I can't just change the max value, instead, I have to recreate a new slider, with a new max value. It seems stupid, but worked.
That works too. In some cases it ends up being much easier.

Quote:
But I don't know why, after I recreating it, I had to declare the function
Code:
GUI.elms.myslider:onmousedown()
and
Code:
 GUI.elms.myslider:ondrag()
Cause the orginal ones didn't work after I recreated the slider
That's very strange, not sure why it would be happening - does your script have custom functions for those or anything?
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 11-14-2018, 01:05 PM   #355
MusoBob
Human being with feelings
 
Join Date: Sep 2014
Posts: 409
Default

Quote:
Originally Posted by Lokasenna View Post
You might find it easier to just have multiple rows and move the values up to the next row.
Yes I think I will look at moving the values, It would save having a lot of textboxes, and there would be a limit I'd imagine.


I can't see how to get a value in a textbox without typing or pasting.
The textboxes in GetUserInputs can preset values:

local defaults = {"Def 1", "Def 2", "Def 3", "Def 4", "Def 5", "Def 6"}


The only way I found so far is edit Class - Textbox.lua

Code:
txt_default = ""

GUI.Textbox = GUI.Element:new()
function GUI.Textbox:new(name, z, x, y, w, h, caption, pad)

    local txt = (not x and type(z) == "table") and z or {}

    txt.name = name
    txt.type = "Textbox"

    txt.z = txt.z or z

    txt.x = txt.x or x
    txt.y = txt.y or y
    txt.w = txt.w or w
    txt.h = txt.h or h

    txt.retval = txt.retval or txt_default
and in the GUI script:
Code:
local function scroll_up()

     y1=y1+50

     txt_default = GUI.Val("my_text1") or ""
     GUI.New("my_text1", "Textbox", {
        z = 1,
        x = 10,
        y = y1,
        w = 100,
        h = 35,
        caption = "",
        cap_pos = "left",
        font_a = 3,
        font_b = {"Chords", 28}, 
        color = "white",
        bg = "wnd_bg",
        shadow = true,
        pad = 4,
        undo_limit = 20,
       
        
    })
    
     txt_default = GUI.Val("my_text2") or ""
     GUI.New("my_text2", "Textbox", {
        z = 1,
        x = 120,
        y = y1,
        w = 100,
        h = 35,
        caption = "",
        cap_pos = "left",
        font_a = 3,
        font_b = {"Chords", 28}, 
        color = "white",
        bg = "wnd_bg",
        shadow = true,
        pad = 4,
        undo_limit = 20,
       
        
    })
     
   
    
end

local function scroll_down()

     y1=y1-50

     txt_default = GUI.Val("my_text1") or ""
     GUI.New("my_text1", "Textbox", {
            z = 1,
            x = 10,
            y = y1,
            w = 100,
            h = 35,
            caption = "",
            cap_pos = "left",
            font_a = 3,
            font_b = {"Chords", 28},
            color = "white",
            bg = "wnd_bg",
            shadow = true,
            pad = 4,
            undo_limit = 20
            
        })
        
     txt_default = GUI.Val("my_text2") or ""
     GUI.New("my_text2", "Textbox", {
            z = 1,
            x = 120,
            y = y1,
            w = 100,
            h = 35,
            caption = "",
            cap_pos = "left",
            font_a = 3,
            font_b = {"Chords", 28},
            color = "white",
            bg = "wnd_bg",
            shadow = true,
            pad = 4,
            undo_limit = 20
            
        })    
        
    
end
MusoBob is offline   Reply With Quote
Old 11-14-2018, 01:25 PM   #356
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 68
Default

Quote:
Originally Posted by Lokasenna View Post
That's very strange, not sure why it would be happening - does your script have custom functions for those or anything?
Here is the simple version of my code

Code:
function functionB()

 some codes

end

function functionA()

  some codes

    GUI.New("mylider", "Slider", {     --recreate the slider
        z = 11,
        x = 1096.0,
        y = 5.0,
        w = 106,
        min=0,
        max=newvalue,                  -- new value of max
        defaults=0,    
        caption = "myslider",
        font = 3,
        col_txt = "txt",
        --col_fill = "elm_frame",
        show_values=false
       
    })    

    function GUI.elms.myslider:onmousedown()      --have to declare it again

     GUI.Slider.onmousedown(self)
   
      funntionB()
      
    end
    
    function GUI.elms.myslider:ondrag()           --have to declare it again

      GUI.Slider.ondrag(self)

      functionB()

    end

  reaper.defer(functionA)

end

----------------------
--                  --
--    Load Files    --
--                  --
---------------------- 
local lib_path = reaper.GetExtState("Lokasenna_GUI", "lib_path_v2")
if not lib_path or lib_path == "" then
    reaper.MB("Couldn't load the Lokasenna_GUI library. Please run 'Set Lokasenna_GUI v2 library path.lua' in the Lokasenna_GUI folder.", "Whoops!", 0)
    return
end
loadfile(lib_path .. "Core.lua")()

GUI.req("Classes/Class - Slider.lua")()

if missing_lib then return 0 end  


--------------------------------
--                            --
--         GUI Elements       --
--                            --
--------------------------------

GUI.name = "ToolBar"
GUI.x, GUI.y, GUI.w, GUI.h = 0, 0, 1920, 480
GUI.anchor, GUI.corner = "screen", "C"

GUI.New("myslider", "Slider", {
    z = 11,
    x = 1096.0,
    y = 5.0,
    w = 106,
    min=0,
    max=60,                  --just an initial value
    defaults=0,    
    caption = "myslider",
    font = 3,
    col_txt = "txt",
    --col_fill = "elm_frame",
    show_values=false,
        
})

    function GUI.elms.myslider:onmousedown()      --declare it for the first time

     GUI.Slider.onmousedown(self)
   
      funntionB()
      
    end
    
    function GUI.elms.myslider:ondrag()           --declare it for the first time

      GUI.Slider.ondrag(self)

      functionB()

    end 

GUI.Init()

GUI.Main()

functionB()
Is the anything I'm misunderstanding?
dsyrock is online now   Reply With Quote
Old 11-14-2018, 03:49 PM   #357
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default

Ah. Yes, in that case you need to redeclare it - when you create a new slider, it only has the default slider methods.

If all of the sliders in your script make use of your extended method, you could extendGUI.Slidernmousedown instead to have all of them pick it up. You might have to declare that before creating them, I'm not sure.
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 11-14-2018, 03:52 PM   #358
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default

Quote:
Originally Posted by MusoBob View Post
I can't see how to get a value in a textbox without typing or pasting.
Code:
local value_from_1 = GUI.Val("textbox1")

GUI.Val("textbox2", value_from_1)
However, you would ideally be storing all of the values in a table somewhere and then just having your code go through each textbox, decide what row/column from the table it's "looking at", and grab the value from that.
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 11-15-2018, 12:09 AM   #359
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 68
Default

Quote:
Originally Posted by Lokasenna View Post
Ah. Yes, in that case you need to redeclare it - when you create a new slider, it only has the default slider methods.

If all of the sliders in your script make use of your extended method, you could extendGUI.Slidernmousedown instead to have all of them pick it up. You might have to declare that before creating them, I'm not sure.
Emmm... A new strange thing happened.I redeclared the function GUI.elms.myslidernmousedown(), it worked. But at the same time I redeclared the function GUI.elms.mysliderndrag() too, but I couldn't drag the slider anymore. Before I recreating the slider, both of them worked perfectly
dsyrock is online now   Reply With Quote
Old 11-15-2018, 06:51 AM   #360
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default

Did you remember to include a call to the original methods inside both of yours? If you forget that, then the element literally doesn't know anymore what it's supposed to be doing.
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna 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 08:13 PM.


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