Old 03-17-2020, 11:39 AM   #681
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,230
Default

Total newbie beginner question (please speak slowly ).

Using the awesome GUI builder, I created a simple knob and button to learn how to get values from the GUI.



All I want to do is have the script give me the knob value when I hit the Get Val button.

Can someone give me a simple example of how I would be able to this? I've scanned (admittedly not deeply) the documentation. And something is clearly not registering with me. For example, there is the GUI.init() function and the GUI.main() function, but there is no actual function listed in the code. Sorry for being so clueless. I think if someone just gave me the few lines of code to get the knob value when the button is pushed... that would really help me.

Here's the code the GUI builder gave me:

Code:
-- Script generated by Lokasenna's GUI Builder


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 install 'Lokasenna's GUI library v2 for Lua', available on ReaPack, then run the 'Set Lokasenna_GUI v2 library path.lua' script in your Action List.", "Whoops!", 0)
    return
end
loadfile(lib_path .. "Core.lua")()




GUI.req("Classes/Class - Button.lua")()
GUI.req("Classes/Class - Knob.lua")()
-- If any of the requested libraries weren't found, abort the script.
if missing_lib then return 0 end



GUI.name = "AK Test GUI"
GUI.x, GUI.y, GUI.w, GUI.h = 0, 0, 640, 480
GUI.anchor, GUI.corner = "mouse", "C"



GUI.New("Knob1", "Knob", {
    z = 11,
    x = 80,
    y = 80,
    w = 40,
    caption = "Knob1",
    min = 0,
    max = 10,
    default = 5,
    inc = 1,
    vals = true,
    font_a = 3,
    font_b = 4,
    col_txt = "txt",
    col_head = "elm_fill",
    col_body = "elm_frame",
    cap_x = 0,
    cap_y = 0
})

GUI.New("Get_val", "Button", {
    z = 11,
    x = 64,
    y = 192,
    w = 48,
    h = 24,
    caption = "Get Val",
    font = 3,
    col_txt = "txt",
    col_fill = "elm_frame"
})


GUI.Init()
GUI.Main()
__________________
Cheers,
Andrew K
v6.03+dev0114 - January 14 2020 • Mac 10.12.+ • i7 Quad 2.9GHz • 24GB
Thonex is offline   Reply With Quote
Old 03-17-2020, 11:59 AM   #682
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 4,718
Default

Here's an updated example:
Code:
-- Script generated by Lokasenna's GUI Builder
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 install 'Lokasenna's GUI library v2 for Lua', available on ReaPack, then run the 'Set Lokasenna_GUI v2 library path.lua' script in your Action List.", "Whoops!", 0)
    return
end
loadfile(lib_path .. "Core.lua")()

GUI.req("Classes/Class - Label.lua")()
GUI.req("Classes/Class - Button.lua")()
GUI.req("Classes/Class - Knob.lua")()
-- If any of the requested libraries weren't found, abort the script.
if missing_lib then return 0 end

GUI.name = "AK Test GUI"
GUI.x, GUI.y, GUI.w, GUI.h = 0, 0, 640, 480
GUI.anchor, GUI.corner = "mouse", "C"

local function GetValue()
  local knobValue = GUI.Val("Knob1")
  GUI.Val("Label1", knobValue)
end


GUI.New("Knob1", "Knob", {
    z = 11,
    x = 80,
    y = 80,
    w = 40,
    caption = "Knob1",
    min = 0,
    max = 10,
    default = 5,
    inc = 1,
    vals = true,
    font_a = 3,
    font_b = 4,
    col_txt = "txt",
    col_head = "elm_fill",
    col_body = "elm_frame",
    cap_x = 0,
    cap_y = 0,
})

GUI.New("Label1", "Label", {
    z = 11,
    x = 150,
    y = 192,
    caption = "Label1",
    font = 2,
    color = "txt",
    bg = "wnd_bg",
    shadow = false
})


GUI.New("Get_val", "Button", {
    z = 11,
    x = 64,
    y = 192,
    w = 48,
    h = 24,
    caption = "Get Val",
    font = 3,
    col_txt = "txt",
    col_fill = "elm_frame",
    func = GetValue
})

GUI.Init()
GUI.Main()
The func parameter lets you define which function is called on a button press.
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 03-17-2020, 12:17 PM   #683
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,230
Default

@solger,

Thanks a million!!

So, any GUI element that I want to run a function on when touched is simply a matter of adding the line func = my_function and then (of course) writing:

function my_function ()
do something...
end


That's it? Does it have to be a "local" function?

Thanks!!
__________________
Cheers,
Andrew K
v6.03+dev0114 - January 14 2020 • Mac 10.12.+ • i7 Quad 2.9GHz • 24GB
Thonex is offline   Reply With Quote
Old 03-17-2020, 12:27 PM   #684
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 4,718
Default

Quote:
Originally Posted by Thonex View Post
@solger,

Thanks a million!!

So, any GUI element that I want to run a function on when touched is simply a matter of adding the line func = my_function and then (of course) writing:

function my_function ()
do something...
end

That's it?
Well, it basically depends on the element what behaviors are available.

In case of a Button it's func (left click) and r_func (right click) in V2: https://github.com/jalovatt/Lokasenn...ki/2.00-Button
Or func and rightFunc in V3: https://jalovatt.github.io/scythe/#/gui/elements/Button


Quote:
Does it have to be a "local" function?
It's mainly a question about code efficiency and optimization. Some info links as example:

This tutorial should also be helpful in general: https://www.admiralbumblebee.com/mus...-Tutorial.html
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 03-17-2020, 12:37 PM   #685
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,230
Default

Quote:
Originally Posted by solger View Post
Well, it basically depends on the element what behaviors are available.

In case of a Button it's func (left click) and r_func (right click) in V2: https://github.com/jalovatt/Lokasenn...ki/2.00-Button
Or func and rightFunc in V3: https://jalovatt.github.io/scythe/#/gui/elements/Button



It's mainly a question about code efficiency and optimization. Some info links as example:

This tutorial should also be helpful in general: https://www.admiralbumblebee.com/mus...-Tutorial.html
Thanks solger!!

OK... I think I know enough now to hurt myself

Quote:
This tutorial should also be helpful in general: https://www.admiralbumblebee.com/mus...-Tutorial.html
Brilliant... I think this is exactly what I needed.

Cheers!
__________________
Cheers,
Andrew K
v6.03+dev0114 - January 14 2020 • Mac 10.12.+ • i7 Quad 2.9GHz • 24GB
Thonex is offline   Reply With Quote
Old 03-17-2020, 01:21 PM   #686
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,230
Default

OK... last question for the day!

Is it possible to get a knob value in realtime within the GUI element code block?

If I add to the slider GUI code the following at the last line:

Code:
func = get_slider_val
and then use this function

Code:
function get_slider_val ()
    slider = GUI.Val ("Slider1")
  GUI.Val("Label1", slider)
end
Nothing happens.

If I use this code outside the slider GUI code block:

Code:
GUI.freq = .5
GUI.func = get_slider_val
then that works, however it may be overkill CPU wise.

... nothing else seems to work. Of course I can read the slider value from outside of the GUI.New("Slider1", "Slider"... code block, but unlike the button, I can't get instant feedback on the slider. Same with the knob.

So, my only solution for realtime polling of a slider of knob is GUI.func?
__________________
Cheers,
Andrew K
v6.03+dev0114 - January 14 2020 • Mac 10.12.+ • i7 Quad 2.9GHz • 24GB

Last edited by Thonex; 03-17-2020 at 01:48 PM.
Thonex is offline   Reply With Quote
Old 03-18-2020, 07:58 AM   #687
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 4,718
Default

Quote:
Originally Posted by Thonex View Post
Is it possible to get a knob value in realtime within the GUI element code block? ...

... So, my only solution for realtime polling of a slider of knob is GUI.func?
You can also try using a reaper.defer function for this. See the code examples in this thread: https://forum.cockos.com/showthread.php?t=168270
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 03-18-2020, 01:31 PM   #688
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,230
Default

Quote:
Originally Posted by solger View Post
You can also try using a reaper.defer function for this. See the code examples in this thread: https://forum.cockos.com/showthread.php?t=168270
Thanks solger.

Yeah... ok. I was hoping to stay away from defer functions. I hate using cycles when I don't have to

Is there any consensus whether GUI.func or defer is more CPU efficient? I believe defer by default is about every 30ms. IIRC, defer and GUI.func both have freq (or some kind of timing) control.
__________________
Cheers,
Andrew K
v6.03+dev0114 - January 14 2020 • Mac 10.12.+ • i7 Quad 2.9GHz • 24GB
Thonex is offline   Reply With Quote
Old 03-18-2020, 02:01 PM   #689
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 4,718
Default

Quote:
Originally Posted by Thonex View Post
Is there any consensus whether GUI.func or defer is more CPU efficient? I believe defer by default is about every 30ms. IIRC, defer and GUI.func both have freq (or some kind of timing) control.
I'd say it probably depends on the use-case (like when and where need certain things to be updated in the GUI, running in the background, etc.)

This thread has some interesting info which might be helpful (like, for instance, post #16): https://forum.cockos.com/showthread.php?t=213212
__________________
ReaLauncher

Last edited by solger; 03-18-2020 at 02:11 PM.
solger is offline   Reply With Quote
Old 03-18-2020, 02:16 PM   #690
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,230
Default

Quote:
Originally Posted by solger View Post
I'd say it probably depends on the use-case (like when and where need certain things to be updated in the GUI, running in the background, etc.)

This thread has some interesting info which might be helpful (like, for instance, post #16): https://forum.cockos.com/showthread.php?t=213212
Ahaa.... I thought that maybe the GUI.func was wrapped in a defer loop.

You've been very helpful solger!

Thanks.
__________________
Cheers,
Andrew K
v6.03+dev0114 - January 14 2020 • Mac 10.12.+ • i7 Quad 2.9GHz • 24GB
Thonex is offline   Reply With Quote
Old 03-20-2020, 08:17 PM   #691
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Hey folks,

I'm really sorry to do this, but I don't think I can keep going with this project.

Between my day job and my family there just isn't enough time left over for all of the things I'd like to get done. Hell, I haven't even had time to use Reaper for anything other than working on the GUI in a little over a year, and I don't see that changing anytime soon.

Additionally, I don't think I'll be frequenting the forum. As I said, I don't even have time to do audio stuff and if I sign in I'll just stress myself out with all of the things I wish I could do for the GUI, Radial Menu, Theory Helper, and my other scripts, AND the long list of cool ideas I haven't even gotten to.

This might change one day, of course. I signed off for a year, I think, quite a while back and yet here we are.

Cheers.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 03-21-2020, 12:14 AM   #692
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,230
Default

Quote:
Originally Posted by Lokasenna View Post
Hey folks,

I'm really sorry to do this, but I don't think I can keep going with this project.

Between my day job and my family there just isn't enough time left over for all of the things I'd like to get done. Hell, I haven't even had time to use Reaper for anything other than working on the GUI in a little over a year, and I don't see that changing anytime soon.

Additionally, I don't think I'll be frequenting the forum. As I said, I don't even have time to do audio stuff and if I sign in I'll just stress myself out with all of the things I wish I could do for the GUI, Radial Menu, Theory Helper, and my other scripts, AND the long list of cool ideas I haven't even gotten to.

This might change one day, of course. I signed off for a year, I think, quite a while back and yet here we are.

Cheers.
I'm sure I'm not speaking for myself when I say we'll all miss you when you're not around... and will all be eternally grateful for your amazing contributions!

Take care of yourself first. Get rid of any stress... it's not worth it. We'll always be here when/if you're ready to come back... and thanks again for all you've done!

Cheers,

Andrew K
__________________
Cheers,
Andrew K
v6.03+dev0114 - January 14 2020 • Mac 10.12.+ • i7 Quad 2.9GHz • 24GB
Thonex is offline   Reply With Quote
Old 03-21-2020, 01:58 AM   #693
tompad
Human being with feelings
 
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 479
Default

Quote:
Originally Posted by Thonex View Post
I'm sure I'm not speaking for myself when I say we'll all miss you when you're not around... and will all be eternally grateful for your amazing contributions!

Take care of yourself first. Get rid of any stress... it's not worth it. We'll always be here when/if you're ready to come back... and thanks again for all you've done!
@Lokasenna

+1

Take care and thanks for all the wonderful things you done and all the help you have given.

Regards
Thomas
__________________
ToDoList Obliques MusicMath Donation Some of mine and my friends music projects on Spotify
tompad is offline   Reply With Quote
Old 03-21-2020, 02:31 AM   #694
azimuth
Human being with feelings
 
azimuth's Avatar
 
Join Date: Apr 2014
Location: The place that's round on the ends and high in the middle
Posts: 206
Default

Lokasenna,

Hopefully you'll see this just so you'll know how much your amazing contributions have been appreciated by users like myself. Health and happiness and congratulations on your wise decision to focus upon the really important things in life.

A sincere thank you from me (and I'm sure countless others) to you.
azimuth is offline   Reply With Quote
Old 03-21-2020, 04:06 AM   #695
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 4,718
Default

+1 here, as well.

Take care and thanks for all your work and time, so far!
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 04-07-2020, 03:20 PM   #696
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 3,813
Default

Quote:
Originally Posted by Lokasenna View Post
Hey folks,

I'm really sorry to do this, but I don't think I can keep going with this project.

Between my day job and my family there just isn't enough time left over for all of the things I'd like to get done. Hell, I haven't even had time to use Reaper for anything other than working on the GUI in a little over a year, and I don't see that changing anytime soon.

Additionally, I don't think I'll be frequenting the forum. As I said, I don't even have time to do audio stuff and if I sign in I'll just stress myself out with all of the things I wish I could do for the GUI, Radial Menu, Theory Helper, and my other scripts, AND the long list of cool ideas I haven't even gotten to.

This might change one day, of course. I signed off for a year, I think, quite a while back and yet here we are.

Cheers.
Man, that’s so sad to read. Thank you for all your work and for getting me into refactoring. Hope to see you anyway, from time to time!
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is online now   Reply With Quote
Old 04-11-2020, 02:57 PM   #697
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,230
Default

Does anyone know what to "Get" a MenuBox's current value?

I've tried to message out the optarray and retval of a menubox with a button function and I keep getting nil.

I saw this in the documentation, but no example of how to use it:


Menubox:val([newval])
Get or set the selected item


Any ideas?
__________________
Cheers,
Andrew K
v6.03+dev0114 - January 14 2020 • Mac 10.12.+ • i7 Quad 2.9GHz • 24GB
Thonex is offline   Reply With Quote
Old 04-11-2020, 03:11 PM   #698
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,230
Default

Quote:
Originally Posted by Thonex View Post
Does anyone know what to "Get" a MenuBox's current value?

I've tried to message out the optarray and retval of a menubox with a button function and I keep getting nil.

I saw this in the documentation, but no example of how to use it:


Menubox:val([newval])
Get or set the selected item


Any ideas?

Ugh... never mind... I forgot to use the GUI.Val("Menubox1") command.
__________________
Cheers,
Andrew K
v6.03+dev0114 - January 14 2020 • Mac 10.12.+ • i7 Quad 2.9GHz • 24GB
Thonex is offline   Reply With Quote
Old 04-22-2020, 05:24 PM   #699
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: Apr 2020
Location: Leipzig
Posts: 839
Default

Does somebody have an email address of lokasenna and could pm it to me?
Wanted to ask him, if I could overtake development of guilib v3 aka Scythe as part of the Ultraschall-Api. Wouldn't do it without his permission.
__________________
Use you/she/her, when contacting me, please. Thanks :) Not mentoring via PMs, sorry.
Ultraschall-API - 1200 ReaScript functions for Reaper - Reaper Internals - Developerdocs4Reaper - Donate, if you wish
Meo-Ada Mespotine is online now   Reply With Quote
Old 04-22-2020, 08:34 PM   #700
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 502
Default

I wonder if you could contact him through gitHub.

I know he was soliciting help, and the lack of that may have impacted his decision to let it go....

It's hard to imagine him having a problem with you forking it. But do as you see best. I'm hoping to use it more, so I'd like to see it developed.
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 04-23-2020, 12:35 AM   #701
Harald_v
Human being with feelings
 
Join Date: Feb 2020
Posts: 9
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Does somebody have an email address of lokasenna and could pm it to me?
Wanted to ask him, if I could overtake development of guilib v3 aka Scythe as part of the Ultraschall-Api. Wouldn't do it without his permission.
It is nice to ask before forking it.
Nevertheless, if the git repo is forkable and you don't have an answer soon, I think you should do it.
Everybody will be happy to see someone pursuing his great job!
Harald_v is offline   Reply With Quote
Old 04-23-2020, 08:17 AM   #702
tompad
Human being with feelings
 
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 479
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Does somebody have an email address of lokasenna and could pm it to me?
Wanted to ask him, if I could overtake development of guilib v3 aka Scythe as part of the Ultraschall-Api. Wouldn't do it without his permission.
Dont have email to Lokasenna, just wanna say it would be wonderful if you could keep it alive if Lokasenna dont return!

Regards
Thomas
__________________
ToDoList Obliques MusicMath Donation Some of mine and my friends music projects on Spotify
tompad is offline   Reply With Quote
Old 04-23-2020, 08:32 AM   #703
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 2,909
Default

+1 big thank you ! Wish you all the best and hope you keep doing music or play your instrument ! When you have more time then spend time on making even more
Who cares about code! Jking /kind off
__________________
i had to come back !
deeb is offline   Reply With Quote
Old 04-28-2020, 04:41 AM   #704
Jan Flikweert
Human being with feelings
 
Join Date: Apr 2020
Posts: 62
Default

Hi all,

How to toggle the col_fill propertie after clicking a button from the lokasenna GUI library?

PHP Code:
elms["button_"..k] = {
 
type "Button",
 
= (#toolbar_buttons - k) + 1,
 
= ((1) % buttons_per_row) * (button_width button_h_spacer),
 
math.floor((1) / buttons_per_row) *  (button_height button_v_spacer),
 
button_width,
 
button_height,
 
col_txt "black",
 
col_fill "red",
 
font=4,
 
func toggle_bypass,
 
caption v.label,
 
params = {v.track,v.slot,v.col_fill},
 
tooltip ""

Kind regards,

Jan Flikweert

Last edited by Jan Flikweert; 04-28-2020 at 04:47 AM.
Jan Flikweert is offline   Reply With Quote
Old 04-28-2020, 06:09 AM   #705
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 4,718
Default

Quote:
Originally Posted by Jan Flikweert View Post
How to toggle the col_fill propertie after clicking a button from the lokasenna GUI library?
Have a look at the different code examples in this thread (post #2, #17, #18): https://forum.cockos.com/showthread.php?t=234642
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 04-28-2020, 06:48 AM   #706
Jan Flikweert
Human being with feelings
 
Join Date: Apr 2020
Posts: 62
Default

Hi,

Thanks for your reply.

This did it:

PHP Code:
function GUI.Button:onmouseup()
  
self.state 0
  
-- If the mouse was released on the buttonrun func
  
if GUI.IsInside(selfGUI.mouse.xGUI.mouse.ythen
    self
.func(table.unpack(self.params))
    
self.col_fill self.col_fill == "elm_frame" and "green" or "elm_frame" -- ADDED THIS
  end
  self
:redraw()
  
self:init() -- ADDED THIS
end 
Quote:
Originally Posted by solger View Post
Have a look at the different code examples in this thread (post #2, #17, #18): https://forum.cockos.com/showthread.php?t=234642
Kind regards,


Jan Flikweert

Last edited by Jan Flikweert; 04-28-2020 at 07:07 AM.
Jan Flikweert is offline   Reply With Quote
Old 05-14-2020, 03:40 AM   #707
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 3,813
Default

I‘m using the Loka GUI to open a settings dialog for a defer script. The dialog is opened with the key „o“ and triggers:

Code:
GUI.Init()
GUI.Main()
The window opens correctly on the first press. But when I close it and re-open it, it crashes (have to get the actual error log). Any ideas what could cause this?
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is online now   Reply With Quote
Old 05-19-2020, 11:58 AM   #708
jkooks
Human being with feelings
 
Join Date: May 2020
Posts: 55
Default

Hey everyone,

Out of curiosity, does anyone know if there is a script hook I can utilize for when a tab changes state? I know I can get the state at any point using GUI.Val, but I was hoping there might be something that already does this in the background so I can flip a bool every time the tab changes, affecting the way that my main script works.
jkooks is online now   Reply With Quote
Old 05-24-2020, 04:20 PM   #709
cohler
Human being with feelings
 
Join Date: Dec 2018
Posts: 244
Default Scaling a GUI window by dragging corner

Is there an easy way in Lokasenna GUI to automatically scale all the contents in a GUI window when the corner is dragged?

Ideally this would be proportional scaling in both x and y directions...
__________________
Source-Destination 4-Point Editing for REAPER!
Available NOW for PC & Mac • FREE Trial License included
info@cohlerclassical.comhttps://cohlerclassical.com
cohler is offline   Reply With Quote
Old 05-25-2020, 01:30 AM   #710
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 1,583
Default

https://forum.cockos.com/showthread....14#post2215614
I use +x1 and +y1 then I can reposition all the buttons by changing the x,y value
you could maybe add to the size & height & font the same way ?
Code:
GUI.New("count_in_btn",      "Button",           3, 16+x1, 65+y1, 70, 20,
I did the font scaling in another GUI:

__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
MusoBob is offline   Reply With Quote
Old 06-04-2020, 10:40 PM   #711
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 2,909
Default

In version 3, does anyone knows how to override the font colors and font sizes without changing directly core.lua?
__________________
i had to come back !
deeb is offline   Reply With Quote
Old 06-06-2020, 10:57 PM   #712
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 2,909
Default

in V3 - scythe, Does anyone have a recommendation of good practice for overriding:
function Window:handleWindowEvents()

?

I would like to have my own logic in this function, without compromising the future updates.

Thank you!
__________________
i had to come back !
deeb is offline   Reply With Quote
Old 06-07-2020, 11:40 PM   #713
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 2,909
Default

Also,
in V3 - scythe, Does anyone have a recommendation of good practice for overriding event methods from GUI Elements?

In V1 and V2 this used to work:
Code:
GUI.MyListbox = GUI.Listbox
GUI.MyListbox.on_mouseup= GUI.MyListbox.onmouseup
function GUI.MyFolders:onmouseup() 
    self:on_mouseup()
    do_something()
end
in V3 i am trying using:
Code:
GUI.elementClasses.MyListbox =GUI.elementClasses.Listbox
GUI.elementClasses.MyListbox.on_mouseup= GUI.elementClasses.MyListbox.onMouseUp
function GUI.elementClasses.MyListbox:onMouseUp(state) 
    self:on_mouseup(state)
   
end

but this seems to mess up with the original ListBox and It works if we override only one Listbox, so that when creating example: "MySecondListBox" with the same method, then in the GUI doing click on MyListbox or MySecondListBox GUI, gives error:

Code:
Error: MyElements.lua:19: stack overflow

Stack traceback:
	MyElements.lua:19: in function 'gui.elements.Listbox.on_mouseup'
It's calling the "Listbox.on_mouseup" instead of the "MyListbox.on_mouseup"
__________________
i had to come back !

Last edited by deeb; 06-08-2020 at 12:32 AM.
deeb is offline   Reply With Quote
Old 06-08-2020, 10:11 AM   #714
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: Apr 2020
Location: Leipzig
Posts: 839
Default

A total noob-question: When using v3(but probably with v2 as well), what is the purpose of GUI.createLayer?

Means, what is a layer in the sense of Lokasenna's Gui-Lib, the benefits and importances?
Is it like a z-buffer, so I can put together numerous gui-elements into one layer and turn it on and off, when working with tabs? Or does one gui-element need its own layer?
__________________
Use you/she/her, when contacting me, please. Thanks :) Not mentoring via PMs, sorry.
Ultraschall-API - 1200 ReaScript functions for Reaper - Reaper Internals - Developerdocs4Reaper - Donate, if you wish
Meo-Ada Mespotine is online now   Reply With Quote
Old 06-08-2020, 11:24 AM   #715
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 4,718
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
A total noob-question: When using v3(but probably with v2 as well), what is the purpose of GUI.createLayer?

Means, what is a layer in the sense of Lokasenna's Gui-Lib, the benefits and importances?
Is it like a z-buffer, so I can put together numerous gui-elements into one layer and turn it on and off, when working with tabs?
Yeah, that's basically it.

Each element has a specific layer (z-value) assigned. A tab, for instance, can have multiple layers assigned (to control which elements are shown on a specific tab).

In case you haven't already seen it, some details and short examples can be found in the GUI Wiki pages:
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 06-08-2020, 06:46 PM   #716
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: Apr 2020
Location: Leipzig
Posts: 839
Default

Thanks.

Another question: When I use this script and doubleclick one of the buttons, they stay "clicked". Is this intentional behavior as I doubleclicked at it or rather a bug?
I use Scythe in this example.

Code:
loadfile(libPath .. "scythe.lua")()

local Table = require("public.table")
GUI = require("gui.core")

local window = GUI.createWindow({
  name = "My Script",
  w = 296,
  h = 248,
})

local layer = GUI.createLayer({ name = "My Layer" })

local button = GUI.createElement({
  name = "Boo1",
  type = "button",
  x = 16,
  y = 16,
  caption = "Hi!"
})

local button2 = GUI.createElement({
  name = "Boo2",
  type = "button",
  x = 46,
  y = 46,
  caption = "Hi!"
})

PUH=0

button.func = function() 
  PUH=PUH+1
  
end

layer:addElements(button)
layer:addElements(button2)
window:addLayers(layer)
__________________
Use you/she/her, when contacting me, please. Thanks :) Not mentoring via PMs, sorry.
Ultraschall-API - 1200 ReaScript functions for Reaper - Reaper Internals - Developerdocs4Reaper - Donate, if you wish
Meo-Ada Mespotine is online now   Reply With Quote
Old 06-08-2020, 08:09 PM   #717
jkooks
Human being with feelings
 
Join Date: May 2020
Posts: 55
Default

Has anyone ever adjusted the code for list-boxes so they return an entire list of bools when the list-box is set to multi? Right now it'll only return a partial list of what is selected rather than an entire indexed table of the table that I passed to it.

The idea is that it'll act like the return value for checklists where it gives you the bool for every indexed item in the list.
jkooks is online now   Reply With Quote
Old 06-16-2020, 11:05 AM   #718
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 4,718
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Thanks.

Another question: When I use this script and doubleclick one of the buttons, they stay "clicked". Is this intentional behavior as I doubleclicked at it or rather a bug?
I use Scythe in this example.
Unfortunately I haven't had time yet to take a deeper look at the differences in Scythe. So not sure if this behavior is intended.

I only had a quick look at the draw and click functions in the Button.lua files in V2 and V3 and at first glance both look very similar (so it doesn't look like there are any major changes there).
As example, the code for the double click function is the same in both versions (self.state = 0). And the same state is also set in the OnMouseUp function (triggered when releasing the mouse button).
Code:
function Button:onDoubleClick()
  self.state = 0
end
The V3 wiki also only lists a left & right click function (and no double click function). So my first guess would be that this might perhaps be a bug.
__________________
ReaLauncher

Last edited by solger; 06-16-2020 at 11:36 AM.
solger is offline   Reply With Quote
Old 06-16-2020, 11:25 AM   #719
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 4,718
Default

Quote:
Originally Posted by jkooks View Post
Has anyone ever adjusted the code for list-boxes so they return an entire list of bools when the list-box is set to multi? ...
I guess it's possible by making a custom function in your script for creating and returning a 'full' selection table.

The 'partial' selection table is either passed as parameter to the custom function:
  1. Get Listbox value (outside of custom function)
  2. Pass values as parameter to custom function
  3. Custom function creates and returns a 'full' selection table

Or everything is done inside the custom function:
  1. Call custom function
  2. Get Listbox values (inside the custom function)
  3. Create and return a 'full' selection table

By the way: are you using v2 or v3 (Scythe) of the GUI library?

Quote:
Originally Posted by jkooks View Post
... Right now it'll only return a partial list of what is selected rather than an entire indexed table of the table that I passed to it.

The idea is that it'll act like the return value for checklists where it gives you the bool for every indexed item in the list.
What's the use-case for which you require the 'full' listbox selection table?
__________________
ReaLauncher

Last edited by solger; 06-16-2020 at 10:08 PM.
solger is offline   Reply With Quote
Old 06-16-2020, 12:28 PM   #720
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: Apr 2020
Location: Leipzig
Posts: 839
Default

Quote:
Originally Posted by solger View Post
Unfortunately I haven't had time yet to take a deeper look at the differences in Scythe. So not sure if this behavior is intended.

I only had a quick look at the draw and click functions in the Button.lua files in V2 and V3 and at first glance both look very similar (so it doesn't look like there are any major changes there).
As example, the code for the double click function is the same in both versions (self.state = 0). And the same state is also set in the OnMouseUp function (triggered when releasing the mouse button).
Code:
function Button:onDoubleClick()
  self.state = 0
end
The V3 wiki also only lists a left & right click function (and no double click function). So my first guess would be that this might perhaps be a bug.
Ok, so I probably need to debug this first. Otherwise clicked elements will not behave exactly as they do in all other dialogs of Reaper.
Double click would also be nice to have in general, so people can add their own classes who benefit from double-click.
__________________
Use you/she/her, when contacting me, please. Thanks :) Not mentoring via PMs, sorry.
Ultraschall-API - 1200 ReaScript functions for Reaper - Reaper Internals - Developerdocs4Reaper - Donate, if you wish
Meo-Ada Mespotine is online now   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 10:11 AM.


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