Old 05-06-2018, 08:52 PM   #121
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

In Theory Helper the function update_buttons takes care of it - line 6163 in the current version.

The rough idea is this:
Code:
for each element in GUI.elms do
    if the name contains "btn_chords" or "lbl_chords" then
        GUI.elms[that element name] = nil
    end
end

for each scale degree do

    create a label for that column

    for each entry in the table of legal chords (updated on every scale change) do

        create a button for it

    end

end
All of the buttons run the same function, but with their scale degree and name as arguments so the function can look up the correct chord to play/add.
__________________
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 05-09-2018, 09:12 PM   #122
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

I couldn't work out that bit, so I just added some buttons in a function, so each time you click a button it will update the 14 chord buttons to match the key and scale.
Works good but once any of the buttons are clicked 13 times all up I get a crash.
I know on your Theory Helper the whole GUI seems to refresh when the chords are changed ?


https://www.dropbox.com/s/2d59cuejmu...hords.gif?dl=0
https://www.dropbox.com/s/2d59cuejmu...hords.gif?dl=1

Code:
Stack traceback:
    Core.lua:31: in function <...\AppData\Roaming\REAPER\Scripts\ActBut\Core.lua:25>
        [C]: in metamethod '__newindex'
    Class - Button.lua:84: in method 'init'
    Core.lua:531: in field 'New'
    ActBut gui.lua:1199: in function 'chord_buttons'
    ActBut gui.lua:1064: in field 'func'
    Class - Button.lua:159: in method 'onmouseup'
    Core.lua:627: in field 'Update'
    Core.lua:308: in field 'Main_Update_Elms'
    Core.lua:198: in function <...\AppData\Roaming\REAPER\Scripts\ActBut\Core.lua:194>
        [C]: in function 'xpcall'
    Core.lua:189: in function <...\AppData\Roaming\REAPER\Scripts\ActBut\Core.lua:187>
MusoBob is offline   Reply With Quote
Old 05-10-2018, 04:18 AM   #123
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Class - Button.lua:84: in method 'init'
Core.lua:531: in field 'New'
You're still hitting the buffer limit, most likely because the old buttons aren't being properly deleted before you add the new ones so the buffers are never being freed up.

(I just checked Theory Helper, and it's still running a much older version of the library that didn't use buffers at all - everything gets redrawn all the time - so it's not an issue there)

Are you just creating new buttons with the same name as the old ones? If so, try calling ondelete for each of them first:

Code:
for i = 1, #button_list do
    local name = "button_" .. i
    GUI.elms[name]:ondelete()
    GUI.New(name, "Button", etc...)
end
All of the stock elements call GUI.FreeBuffer automatically when they're deleted by the GUI logic, which just sets their buffer numbers as being available again. The "correct" way to delete elements, if you don't need to recreate them right away as above, is to just set their z to -1. On each GUI update it specifically looks for that and gets rid of them - I'll try update the documentation to include that.

Alternatively, you could leave the buttons there and just reassign them manually:

Code:
button_1.caption = "New Chord Name"
button_1.func = new_chord_function
Quote:
Originally Posted by MusoBob View Post
I couldn't work out that bit, so I just added some buttons in a function
You can add the function's arguments as extra arguments to the button.

Code:
local function button_was_clicked(button_num)
    GUI.Msg("button " .. tostring(button_num) .. " was clicked.")
end

local ref_x, off_x = 32, 48
for i = 1, 14 do
    GUI.New("my_button", "Button", 1, ref_x + (i - 1) * off_x, 32, 40, 20, i, button_click, i)
end
...I think. Typing from memory, can't test it now.

Quote:
I know on your Theory Helper the whole GUI seems to refresh when the chords are changed ?
That's just to resize the window so it fits the longest column of buttons.
__________________
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 05-10-2018, 12:21 PM   #124
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Code:
GUI.elms[name]:ondelete()
That's what I was looking for ! thanks.

Rather than how I got it now, having a button above for each radio choice (that calls the update chord buttons function)
how do I get it to call that function on each radio mouse click ?
Code:
GUI.New("key_choice",     "Radio",          4, 92, 125, 0, 0, "Select Key", "C,C♯,Db,D,D♯,Eb,E,F,F♯,Gb,G,G♯,Ab,A,A♯,Bb,B", "h", 15)
So just clicking the Key Choice radio or the Scale Choice radio will call the update chord buttons function.
MusoBob is offline   Reply With Quote
Old 05-10-2018, 12:33 PM   #125
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

You can add code to existing methods:

Code:
function GUI.elms.key_choice:onmouseup()
    -- Run the original method
    GUI.Radio.onmouseup(self)

    -- And then your function
    update_chord_buttons()
end
__________________
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 05-10-2018, 01:37 PM   #126
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

PERFECT ! thanks again !
MusoBob is offline   Reply With Quote
Old 05-10-2018, 08:25 PM   #127
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Small update.

Knob and Slider were being really inconsistent with their return values. I rewrote some things to fix it, but unfortunately it necessitated changing their available parameters. Any scripts using Knob or Slider will break from this.

Working on a documentation update now.
__________________
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 05-11-2018, 05:40 PM   #128
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Can I have the same Radio element on 2 tabs ?

If I set the Radio z to 2 I only get it on tab 3 and if I set it to 6 I get nothing.

[1] = {3},
[2] = {2,4},
[3] = {2,5},

[1] = {3},
[2] = {6,4},
[3] = {6,5},
MusoBob is offline   Reply With Quote
Old 05-11-2018, 07:04 PM   #129
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

That's the idea, yeah. Turns out there was a bug there, which should be fixed as of just now.

As for why you weren't seeing anything on layer 6... is there anything on 4 or 5 in front of the radio buttons? They would cover it up even if it were showing.
__________________
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 05-11-2018, 09:48 PM   #130
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

2 is working now and 6 ! the radio is at the bottom of each tab.
I do beta testing for other apps, it should not be fixed that quick !
MusoBob is offline   Reply With Quote
Old 05-12-2018, 04:58 AM   #131
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by MusoBob View Post
2 is working now and 6 ! the radio is at the bottom of each tab.
I do beta testing for other apps, it should not be fixed that quick !
It took longer to edit one of the demonstration scripts to check that the bug was fixed than it did to actually fix it.
__________________
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 05-15-2018, 10:46 AM   #132
atonalist
Human being with feelings
 
Join Date: May 2018
Location: Stony Brook, New York
Posts: 3
Default Strange Behaviour: Likely My Own Stupidity

First off, thanks so much Lokasenna for all the work you've put into this library. It is extraordinarily helpful and just what I needed for a small project at my workplace.

I've done some Reaper scripting before, but it has all been in EEL, so maybe the issue that I'm having is from being a novice programmer and brand new to Lua, but here's what's happening:

I have created as a test a very simple GUI with a single button that should start recording and print a message to the console. This is just a test.

When I run this script, the function I've assigned to the button fires when the script is run, but not when the button is pressed. This happens with any GUI script I've written that has buttons in it.

I'm sure I've done something very silly here, but I can't for the life of me figure out what it is.

I've been through the GitWiki as well as the tutorials here, but to no avail.

Any help would be much appreciated, and sorry for such a silly question. Script attached.

Nick Nelson
Attached Files
File Type: lua StrippedDownButtonScript.lua (1.5 KB, 232 views)
atonalist is offline   Reply With Quote
Old 05-15-2018, 11:47 AM   #133
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

There's no such thing as a silly question. Well, until after it leaves your mouth, but if you knew it was silly beforehand you wouldn't need to ask.

Here's the culprit:
Quote:
GUI.New("GoButton", "Button", 1, 64, 20, 40, 40, "Go", rec_press())
Lua treats variables, tables, and functions all the same - they're just a name that refers to something. As such, you can do things like this all day long:

Code:
local reaper = reaper
local ShowConsoleMsg = reaper.ShowConsoleMsg
local Msg = ShowConsoleMsg
local M = Msg
Alright, this is getting silly
Until you actually do something with them, they're just names. Adding () tells Lua that a) this is a function and b) you want to execute it, as in:

Code:
local sin = math.sin
vs
local sin = math.sin()
The latter will throw an error because math.sin() expects a number.

GUI.New just wants a reference to your function - by including the parentheses, you're running the function and putting the function's return value (nil, in this case) there instead. When you go to click the button, it looks for self.func, finds nil, shrugs its shoulders, and goes out for a coffee.

TL;DR Remove the function's ()s:
Code:
GUI.New("GoButton", "Button", 1, 64, 20, 40, 40, "Go", rec_press)
(Updated the wiki and class comments to clarify this)
__________________
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

Last edited by Lokasenna; 05-15-2018 at 11:54 AM.
Lokasenna is offline   Reply With Quote
Old 05-15-2018, 12:11 PM   #134
atonalist
Human being with feelings
 
Join Date: May 2018
Location: Stony Brook, New York
Posts: 3
Default Thanks!

Thanks so much for this!!

All my previous programming experience is in LISP, so I have a... relationship... with parenthesis.

~NRN~
atonalist is offline   Reply With Quote
Old 05-15-2018, 12:34 PM   #135
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by atonalist View Post
Thanks so much for this!!

All my previous programming experience is in LISP, so I have a... relationship... with parenthesis.

~NRN~
I almost failed my first-year computer science classes because they used Scheme and it made my brain want to throttle itself.
__________________
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 05-25-2018, 02:32 PM   #136
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default Mac Win Font Size

I found the text going outside of the GUI buttons in Mac so I just decrease it a bit from *0.8 to *0.7 in Core.lua

-- Different OSes use different font sizes, for some reason
-- This should give a roughly equal size on Mac
if string.find(reaper.GetOS(), "OSX") then
size = math.floor(size * 0.7)
MusoBob is offline   Reply With Quote
Old 05-25-2018, 04:44 PM   #137
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Good to know. I've noticed the text looking a bit big in a few people's screenshots, so I might change that in the next update.
__________________
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 05-31-2018, 09:52 AM   #138
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,812
Default

hei Loka! Hope you are good! I have some doubts and ideas i would like to discuss!

1) I feel the need of passthrue commands to the Lua Gui. Is there something immediate on the library? This is something i really have to dig.

2) Also what text editor you use for scripting lua?

I use sublime text! i never done it, but i was thinking to try config it in a way that it could recognise the "require" function on this script to autocomplete function names and variables while developing (you know IDE nice autocompletes, but between different files which is something that does not happen in sublime text by default).


3 ) the require function you use is the way i am using to make my own stuff.
It's just a pity it as to be copy/pasted the function before require something.

Do you think there is something Cockos could do in this matter? i think it would be nice if we could standarise a reaper require that would allow to simply do

reaper.require "my reaper lua lib" on the beggining of an empty script

What do you think? maybe this should be discussed on another thread.

4 ) I am having some concerns about fonts sizes,example:
GUI.New("lbl, "Label", 1, 1, 1, "Cool from you!!", true, 3, "red")

the font size is 4 is the smaller font size i can get and is too big.
2 is bigger
1 even bigger
5 - i get attempt to get length of a nil value

can't we have smaller fonts?

Many thanks
deeb is offline   Reply With Quote
Old 05-31-2018, 10:13 AM   #139
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by deeb View Post
1) I feel the need of passthrue commands to the Lua Gui. Is there something immediate on the library? This is something i really have to dig.
Sorry, I don't understand what you're asking here.

Quote:
2) Also what text editor you use for scripting lua?
Notepad++ here. I tried Sublime Text and it seemed nice, but I'm not in a position to spend money on a text editor. NP++ does almost everything I want.

If you're talking about having autocomplete for the GUI commands... that would be neat, but it would be a lot of effort for something I can't use.

Quote:
Do you think there is something Cockos could do in this matter? i think it would be nice if we could standarise a reaper require that would allow to simply do

reaper.require "my reaper lua lib" on the beggining of an empty script
Lua's require(___) function still works, you just have to know how it works - it doesn't look in the script's path by default. I find it awkward, thus why I wrote req, but I'm actually considering going back to require to make a couple of things easier.

The links here might help: https://forum.cockos.com/showthread.php?t=190342

Quote:
the font size is 4 is the smaller font size i can get and is too big.
2 is bigger
1 even bigger
5 - i get attempt to get length of a nil value
Those aren't fonts, they're font presets. Have a look in Core.lua at GUI.fonts. You can add more presets, or overwrite them in your script - if you do, though, anything that uses font 4 will use your new font 4, etc.

Same with the color presets - GUI.colors. You could retheme everything pretty easily with that.
__________________
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 05-31-2018, 10:27 AM   #140
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,812
Default

Quote:
Originally Posted by Lokasenna View Post
Sorry, I don't understand what you're asking here.
I mean! normal passthrue like for midi editor: when clicking/ focusing in the GUI, and if i press example: space the transport play does not start! this might get complext i know ...


Quote:
Originally Posted by Lokasenna View Post
Sorry, I don't understand what you're asking here.



Notepad++ here. I tried Sublime Text and it seemed nice, but I'm not in a position to spend money on a text editor. NP++ does almost everything I want.

If you're talking about having autocomplete for the GUI commands... that would be neat, but it would be a lot of effort for something I can't use.
yes i mean that! notepad as no autocomplete? i am using version 2 of sublime-- i thought buying was optional.

Quote:
Originally Posted by Lokasenna View Post
Lua's require(___) function still works, you just have to know how it works - it doesn't look in the script's path by default. I find it awkward, thus why I wrote req, but I'm actually considering going back to require to make a couple of things easier.

The links here might help: https://forum.cockos.com/showthread.php?t=190342
I didn't like them too when i fest tried! but i had no experience. Problems everywhere when requiring and confusion. So I will read! thank you

Quote:
Originally Posted by Lokasenna View Post
Those aren't fonts, they're font presets. Have a look in Core.lua at GUI.fonts. You can add more presets, or overwrite them in your script - if you do, though, anything that uses font 4 will use your new font 4, etc.

Same with the color presets - GUI.colors. You could retheme everything pretty easily with that.
Will look! Many thanks!
deeb is offline   Reply With Quote
Old 05-31-2018, 10:53 AM   #141
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by deeb View Post
I mean! normal passthrue like for midi editor: when clicking/ focusing in the GUI, and if i press example: space the transport play does not start! this might get complext i know ...
There's no way for a script to pass commands through - it would have to literally check every key and then parse the action list to see what it did.

Quote:
yes i mean that! notepad as no autocomplete? i am using version 2 of sublime-- i thought buying was optional.
I tried Sublime 3 and then uninstalled when it asked me to pay after half an hour. Notepad++ has autocomplete, but it's really complicated to set up. There isn't even a good one for the Reaper API.
__________________
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 05-31-2018, 10:59 AM   #142
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,812
Default

Quote:
Originally Posted by Lokasenna View Post
There's no way for a script to pass commands through - it would have to literally check every key and then parse the action list to see what it did.
how about , to just pass everything?
and if needed elements like texteditor or textbox to write values, to use reaper MsgBoxes Inputs.



Quote:
Originally Posted by Lokasenna View Post
Notepad++ has autocomplete, but it's really complicated to set up. There isn't even a good one for the Reaper API.
maybe this should be a good feature for the community.. I am not asking ... just opening the idea.. like an Adopted Lua (or more?) Reaper editor .. just saying
deeb is offline   Reply With Quote
Old 05-31-2018, 02:06 PM   #143
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by deeb View Post
how about , to just pass everything?
and if needed elements like texteditor or textbox to write values, to use reaper MsgBoxes Inputs.
Nope. No way to pass through at all. If you really wanted you could have each key trigger an AutoHotKey .exe to send a press of that key to the Reaper window.

Quote:
maybe this should be a good feature for the community.. I am not asking ... just opening the idea.. like an Adopted Lua (or more?) Reaper editor .. just saying
Too many people prefer different editors. There are some syntax highlighting and/or autocomplete files for the different Reascript languages, for a few editors, but as far as I know none of them are up to date.

https://forum.cockos.com/showthread.php?t=141221
https://forum.cockos.com/showthread.php?t=132924
https://www.extremraym.com/en/tools-reaper-scripters/
https://forum.cockos.com/showthread.php?t=142641
__________________
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 05-31-2018, 03:54 PM   #144
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,812
Default

Quote:
Originally Posted by Lokasenna View Post
Nope. No way to pass through at all.
well lbx and mpl interactive tool bar per example work this way. So Its by this side design, maybe we are talking different things ?

thanks
deeb is offline   Reply With Quote
Old 05-31-2018, 04:03 PM   #145
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,874
Default

@lokasenna
Don't forget Atom Editor (which is my favorite):
https://forum.cockos.com/showthread.php?t=173434


It is the easies one to set up.


It shouldn't be too hard to create a script to update this code snippet from my online doc, and he best whould be to share that as an official package.



though I don't felt the need so far for it.
X-Raym is offline   Reply With Quote
Old 05-31-2018, 07:01 PM   #146
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by deeb View Post
well lbx and mpl interactive tool bar per example work this way. So Its by this side design, maybe we are talking different things ?
If there's a script window open and in focus, it will eat all keyboard input. I think because those scripts are things you dock, leave open, and go to do other stuff, they're not typically in focus and therefore don't eat the input.

Quote:
Originally Posted by X-Raym View Post
@lokasenna
Don't forget Atom Editor
Indeed, yes.

I actually tried Atom again the other day because I was getting fed up with one or two things NP++ wouldn't do, spent a good four hours getting it set up and finding packages, and then ended up going back to NP++ because it was just so slow to do anything. And a bunch of the packages I tried to install were buggy and hadn't been updated in a couple of years.

Same with the Github desktop client - some really basic bugs that they don't seem interested in fixing.
__________________
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 05-31-2018, 07:36 PM   #147
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,812
Default

Quote:
Originally Posted by Lokasenna View Post
If there's a script window open and in focus, it will eat all keyboard input. I think because those scripts are things you dock, leave open, and go to do other stuff, they're not typically in focus and therefore don't eat the input.
excuse me! so scripts done with this lib wont be able to be docked?
deeb is offline   Reply With Quote
Old 05-31-2018, 07:40 PM   #148
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

At the moment it has no docking functionality, simply because I don't know how the docking stuff works. I'm pretty sure your scripts could manage the docking without breaking the library though.
__________________
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 05-31-2018, 07:50 PM   #149
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,812
Default

Quote:
Originally Posted by Lokasenna View Post
At the moment it has no docking functionality, simply because I don't know how the docking stuff works. I'm pretty sure your scripts could manage the docking without breaking the library though.
alright! thank you! ill post here when i know about it! good night!
deeb is offline   Reply With Quote
Old 06-02-2018, 07:23 AM   #150
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Update!

I still have to go through the list and make sure everything is documented - there are a TON of tiny changes, so I'll post those later, but highlights include:

- Window class, for popping up dialog boxes, settings windows, etc.



- Improved crash reporting.
- Automatic checking for Reaper's "restricted permissions" mode, and more informative error messages if a crash occurs because of it.
- Some new GUI functions.
__________________
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 06-02-2018, 11:36 AM   #151
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Changes

Note: I've removed all parameter documentation from the class files so that I only have to update one file (the Wiki) when there are changes. I'm working on a way to have documentation automatically copied into the class files when I upload it, so we'll see.

Core
  • New: Detect Reaper's "restricted permissions" mode and display an appropriate error message if scripts crash because they tried to access a restricted function.
  • New: Added GUI.error_message = "my error message" for including extra details in the crash reporter's printout.
  • New: Added GUI.mouse.off_x and .off_y, .r_off_x/y, .m_off_x/y to remember where the mouse was originally clicked in an element when dragging.
  • New: Added GUI.escape_bypass, boolean. Flag to keep Esc from closing the script window.
  • New: Added GUI.center(elm1, elm2). Returns x,y coordinates that would center elm1 within elm2. If elm2 isn't specified, will center elm1 in the script window.
  • New: GUI.table_find (return the first key matching a value)
  • New: GUI.table_invert (return a table with the keys and values swapped - some searches are easier this way).
  • New: OSX will use a slightly smaller size for all fonts.
  • Fix: GUI.quit wasn't working properly.
  • Fix: Replaced a call to os.time with reaper.time_precise so scripts will work in "restricted permission" mode.
  • Fix: GUI.table_compare was never actually returning True.
  • Fix: GUI.New wasn't properly giving error messages for invalid classes.

Button
  • New: Button captions should now support \n for multiline captions.

Frame
  • Fix: Shadows being drawn strangely.
  • Fix: Weird indenting behavior.

Knob
  • Updated GUI.triangle calls to reflect 'fill' now being a boolean argument.

Listbox
  • New: Listbox.cap_bg for the caption background, .bg is now the list background.

Menubar
  • New: Menus with a blank title ("") will act as a spacer.
  • Fix: Shadows being drawn strangely.
  • Fix: Changed how self.w is calculated and tracked.

Menubox
  • New: :val now returns two values: item number, item text.
  • Updated GUI.triangle calls to reflect 'fill' now being a boolean argument.

Options
  • New: Checklist:val will now return and accept a boolean value if # is only 1.
  • Fix: Checklist:val() wasn't always returning the full list.
  • Fix: Don't adjust options to make room for the caption if there isn't one.
  • Added a few error checks.

Tabs
  • New: .pad now defaults to 8.
  • New: 'opts' will now accept a table of tab names directly.
  • Fix: Reworked how self.w is calculated and tracked, for better consistency.
  • Fix: Won't throw an error if started with no z_sets; just lets the tabs do nothing.

Textbox
  • Fix: Make sure the box's highlight goes away if focus is lost programmatically.
  • Major tidying of selection, clipboard, and Ctrl+___ code.

TextEditor
  • New: TextEditor.cap_bg for the caption background, .bg is now the editor background.
  • Fix: ondrag was routing through onmousedown for no actual reason.
  • Fix: Issues with text window vs. scrollbar positioning.
  • Fix: Dragging on scrollbars would switch to moving the caret if you moved the mouse into the text area.
  • Blank scrollbars are now always shown.
  • Major tidying of selection, clipboard, and Ctrl+___ code.

Window
  • Initial release. Somewhat basic, but it appears to work.
__________________
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 06-04-2018, 04:42 AM   #152
RobU
Human being with feelings
 
RobU's Avatar
 
Join Date: Sep 2009
Posts: 863
Default

Quote:
Originally Posted by Lokasenna View Post
Lua's require(___) function still works, you just have to know how it works - it doesn't look in the script's path by default. I find it awkward, thus why I wrote req, but I'm actually considering going back to require to make a couple of things easier.
I like your 'req' function.

I've been working on a complete bottom-up rewrite of Eugen's GUI for my MIDI Ex Machina script (it's still alive, v2 might be out later this year, maybe... and TBH it probably would have been easier to port the new classes to your GUI )... Anyways, I borrowed your idea of splitting out the class libraries and loading them with your 'req' function. The only difference here is that the classes are 'req'd into a library-loader file. A script then only has to 'require' the library-loader to get everything.

It would be great if Reaper would let us include external Lua libs, like LFS - it would make a few niggly issues a lot easier, but for now, 'req' works pretty good.


As for Editors - I really wanted to like Atom, but I got so used to the (Lua) function/table browser in NPP that I went back to it, auto-complete be damned. However, the default dark theme in Atom was so nice I cloned it for NPP - https://github.com/RobU23/NotepadPlusPlus
__________________
Return of the Dub Cadet - https://open.spotify.com/album/2t98A...lQ&dl_branch=1
RobU is offline   Reply With Quote
Old 06-04-2018, 05:08 AM   #153
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by RobU View Post
I like your 'req' function.
It works well for what I do. One important thing that only requires does, though - you can require("lib.lua") a million times and it will only load the file once, whereas loadfile("lib.lua") will read, recompile, etc every single time. Not important if you're only loading everything once, of course.

Quote:
and TBH it probably would have been easier to port the new classes to your GUI
Happy to help if you change your mind.

Quote:
The only difference here is that the classes are 'req'd into a library-loader file. A script then only has to 'require' the library-loader to get everything.
I should probably include that as an option. I only did it this way so a script can include just the classes it needs instead of the whole massive thing.

Quote:
As for Editors - I really wanted to like Atom, but I got so used to the (Lua) function/table browser in NPP that I went back to it, auto-complete be damned. However, the default dark theme in Atom was so nice I cloned it for NPP - https://github.com/RobU23/NotepadPlusPlus
I keep trying to work with NPP's function browser but it won't stay in alphabetical order and keeps collapsing on its own. Good ol' Ctrl+F here.

Heavily-modified Monokai (I think) and DejaVu Sans Mono here: https://www.dropbox.com/s/r4t35om5qp...nshot.png?dl=0
__________________
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 06-04-2018, 06:57 AM   #154
Frank B
Human being with feelings
 
Frank B's Avatar
 
Join Date: Nov 2015
Posts: 137
Default create send script

How can I change this so there is no "prompt" and simply tell it the "track number"or "track name" within the script?

--[[
Description: Create send from selected tracks
Version: 1.00
Author: Lokasenna
Donation: https://paypal.me/Lokasenna
Changelog:
Initial release
Links:
Lokasenna's Website http://forum.cockos.com/member.php?u=10417
About:
Prompts for a track number, then creates sends to that track
from every selected track.
--]]

-- Licensed under the GNU GPL v3

local function Main()

local num_tracks = reaper.CountSelectedTracks(0)

if num_tracks == 0 then return end

-- Prompt for destination track + offer chance to edit sel.
-- retval, retvals_csv reaper.GetUserInputs( title, num_inputs, captions_csv, retvals_csv )
local ret, dest_num = reaper.GetUserInputs("Create sends to...", 1, "Destination track #:", "")

if not ret or not tonumber(dest_num) then return end

local dest = reaper.GetTrack(0, tonumber(dest_num) - 1)

reaper.Undo_BeginBlock()

-- For each selected track
local sel = {}
for i = 0, num_tracks - 1 do

local sel = reaper.GetSelectedTrack(0, i)

-- Create a default send
--reaper.CreateTrackSend( tr, desttrInOptional )
reaper.CreateTrackSend(sel, dest)

end

reaper.Undo_EndBlock("Create send from selected tracks", -1)

end
Frank B is offline   Reply With Quote
Old 06-04-2018, 10:28 AM   #155
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Replace this:
Code:
-- Prompt for destination track + offer chance to edit sel.
-- retval, retvals_csv reaper.GetUserInputs( title, num_inputs, captions_csv, retvals_csv )
local ret, dest_num = reaper.GetUserInputs("Create sends to...", 1, "Destination track #:", "")

if not ret or not tonumber(dest_num) then return end
with just this:

Code:
local dest_num = your_track_number
Doing it by track name is a slightly more involved - I'll post it in a bit.
__________________
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 06-04-2018, 10:28 AM   #156
RobU
Human being with feelings
 
RobU's Avatar
 
Join Date: Sep 2009
Posts: 863
Default

Quote:
Originally Posted by Lokasenna View Post
Happy to help if you change your mind.
I'll bear that in mind - I'd have to make some modifications to use blit instead of redrawing every frame. There's a smallish CPU penalty doing it that way for sure, but it does make for tasty real-time scaling.

I also have a custom theme thing going on, which I'd need to port to GUI.core, although using 'req' I could just add the code on the fly at runtime, like an extension.. I'll seriously think about it because I'm quite a bit aways from being finished - it didn't seem that big a job when I started

Quote:
I should probably include that as an option. I only did it this way so a script can include just the classes it needs instead of the whole massive thing.
You still can, it's just done in the loader file instead.

Quote:
I keep trying to work with NPP's function browser but it won't stay in alphabetical order and keeps collapsing on its own. Good ol' Ctrl+F here.

Heavily-modified Monokai (I think) and DejaVu Sans Mono here: https://www.dropbox.com/s/r4t35om5qp...nshot.png?dl=0
That looks quite tasty. I tried for a long time to find the right code to make the function browser work properly - if you follow my earlier link, you will find the file for the Lua function list too, it might work for you. Unless you're on a Mac, maybe ?

I did move to the 64 bit version some time ago, all works well here. I was a bit miffed at first that TextFX was unavailable, but then discovered that NPP does line sorting natively which was all I really ever used it for.
__________________
Return of the Dub Cadet - https://open.spotify.com/album/2t98A...lQ&dl_branch=1
RobU is offline   Reply With Quote
Old 06-04-2018, 10:59 AM   #157
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by Frank B View Post
How can I change this so there is no "prompt" and simply tell it the "track number"or "track name" within the script?
(Updated the original script to accept names as well)

Hard-coding the track name - replace all of this:
Code:
-- Prompt for destination track + offer chance to edit sel.
-- retval, retvals_csv reaper.GetUserInputs( title, num_inputs, captions_csv, retvals_csv )
local ret, dest_num = reaper.GetUserInputs("Create sends to...", 1, "Destination track #:", "")

if not ret or not tonumber(dest_num) then return end

local dest = reaper.GetTrack(0, tonumber(dest_num) - 1)
with all of this:
Code:
local dest
local track_name = "my track name"
for i = 0, reaper.GetNumTracks() - 1 do
            
    local track = reaper.GetTrack(0, i)
    local ret, name = reaper.GetTrackName(track, "")
    if ret and name == tostring(track_name) then
        dest = track
    end    
end

if not dest then return end
__________________
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 06-04-2018, 11:03 AM   #158
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by RobU View Post
if you follow my earlier link, you will find the file for the Lua function list too, it might work for you. Unless you're on a Mac, maybe ?
It detects all the functions correctly, although I use so many different formats for them that it looks pretty weird. The issue I have is that the list itself will randomly collapse, or choose to sort itself to match the code rather than A to Z. I can't make it stay open and alphabetical, so I never end up using it.
__________________
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 06-04-2018, 11:10 AM   #159
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by RobU View Post
I'll bear that in mind - I'd have to make some modifications to use blit instead of redrawing every frame.
Blitting and scaling aren't incompatible. Your classes would just have to check if the window size has changed (if GUI.resized) on each update and then resize their buffer and redraw themselves if it has.
__________________
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 06-04-2018, 12:03 PM   #160
RobU
Human being with feelings
 
RobU's Avatar
 
Join Date: Sep 2009
Posts: 863
Default

Quote:
Originally Posted by Lokasenna View Post
Blitting and scaling aren't incompatible. Your classes would just have to check if the window size has changed (if GUI.resized) on each update and then resize their buffer and redraw themselves if it has.

I'll have a play around with something simple and see how I get on. If I get stuck I'll give you a shout thanks for the info.


R
__________________
Return of the Dub Cadet - https://open.spotify.com/album/2t98A...lQ&dl_branch=1
RobU 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 02:43 AM.


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