Old 08-13-2018, 01:36 PM   #281
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

Quote:
Originally Posted by cfillion View Post
Ah right, for some reason gfx.getfont() always returns an empty string on Linux (bug?)
I can't imagine it's intentional.
Lokasenna is online now   Reply With Quote
Old 08-13-2018, 01:41 PM   #282
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

What I'm gathering from this is that I should probably throw Linux on a USB drive just for scripting.
Lokasenna is online now   Reply With Quote
Old 08-13-2018, 02:52 PM   #283
White Tie
Pixel Pusher
 
White Tie's Avatar
 
Join Date: Mar 2007
Location: Blighty
Posts: 2,563
Default

As of v5.94pre6, Reaper for Linux bundles the liberation fonts.
__________________
The House of White Tie
White Tie is offline   Reply With Quote
Old 08-14-2018, 04:13 AM   #284
tompad
Human being with feelings
 
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 373
Default

I am maybe out and bicycling now but I looked in Reaper.ini and found this:

Code:
t_font_fallback=// Cantarell FreeSans DejaVuSans NotoSans LiberationSans Oxygen Arial Verdana
ft_font_fallback_fixedwidth=// FreeMono DejaVuSansMono NotoMono OxygenMono LiberationMono Courier
Is this something I can change to make it work?
__________________
ToDoList Obliques MusicMath Donation Mark4celeste Frid i ditt hjärta Eve & the Fisherman on Spotify
tompad is offline   Reply With Quote
Old 08-14-2018, 09:13 AM   #285
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 3,757
Default

@Lokasenna

I just did a quick check on Linux and changing these lines in your Core.lua seem to help:

Code:
Linux = {
            sans = "Arial",
            mono = "DejaVuSansMono"   <-- without the spaces
Or in case of using the Liberation fonts White Tie mentioned:
Code:
Linux = {
            sans = "LiberationSans",
            mono = "LiberationMono"
        }

Quote:
Originally Posted by Lokasenna
What I'm gathering from this is that I should probably throw Linux on a USB drive just for scripting.
In case you don't already know it, another option is to make a Linux install on a virtual machine using something like VirtualBox.
That's what I'm currently using here to test the Linux version
__________________
ReaLauncher

Last edited by solger; 08-14-2018 at 09:19 AM.
solger is offline   Reply With Quote
Old 08-14-2018, 11:44 AM   #286
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

Alright, I'm dual-booting with Ubuntu Studio now. Just have to sort out some crap with my trackball and my laptop's function keys and then I can investigate.
Lokasenna is online now   Reply With Quote
Old 08-14-2018, 12:42 PM   #287
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

Fix confirmed, updating.
Lokasenna is online now   Reply With Quote
Old 08-14-2018, 01:22 PM   #288
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 3,757
Default

Quote:
Originally Posted by Lokasenna View Post
Fix confirmed, updating.
Nice!
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 08-14-2018, 10:08 PM   #289
tompad
Human being with feelings
 
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 373
Default

Quote:
Originally Posted by Lokasenna View Post
Fix confirmed, updating.
Yeah, nice!
__________________
ToDoList Obliques MusicMath Donation Mark4celeste Frid i ditt hjärta Eve & the Fisherman on Spotify
tompad is offline   Reply With Quote
Old 08-18-2018, 12:43 PM   #290
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,775
Default

v5.95pre7 supports font families and gfx.getfont's second return value on Linux!

sans-serif/serif/monospace/cursive now resolves to the user's preferred font of that type.

(It doesn't always match what was given to gfx.setfont. The system's FontConfig will select the closest substitute font in most cases if the requested one isn't installed. gfx.getfont returns which font is actually being used.)

Last edited by cfillion; 08-18-2018 at 02:42 PM.
cfillion is online now   Reply With Quote
Old 08-18-2018, 02:30 PM   #291
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

Quote:
Originally Posted by cfillion View Post
v5.95pre7 supports font families and gfx.getfont's second return value on Linux!

(It doesn't always match what was given to gfx.setfont. The system's FontConfig will select the closest substitute font in most cases if the requested one isn't installed. gfx.getfont returns which font is actually being used.)
Awesome. AFAIK pretty much any Linux distro should have DejaVu on hand, so I won't worry too much unless I hear about people having trouble.
Lokasenna is online now   Reply With Quote
Old 08-22-2018, 07:54 AM   #292
tompad
Human being with feelings
 
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 373
Default Selecting item in listbox

Hi again! ;-)

Have I misunderstod the following:

GUI.Val("listbox_tasks",3) - should select the third item in list??

I am creating a new item in listbox and want the created item
to be selected when returning to the listbox.
__________________
ToDoList Obliques MusicMath Donation Mark4celeste Frid i ditt hjärta Eve & the Fisherman on Spotify
tompad is offline   Reply With Quote
Old 08-22-2018, 08:16 AM   #293
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

It wants to see a table of booleans:
Code:
GUI.Val("listbox_tasks", {[3] = true})
Pushing an update to have it take a single number as well.

Last edited by Lokasenna; 08-22-2018 at 08:35 AM.
Lokasenna is online now   Reply With Quote
Old 08-22-2018, 09:14 AM   #294
tompad
Human being with feelings
 
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 373
Default

Quote:
Originally Posted by Lokasenna View Post
It wants to see a table of booleans:
Code:
GUI.Val("listbox_tasks", {[3] = true})
Pushing an update to have it take a single number as well.
Ahaaa! Ok now I understand what is written in the documentation.
Needed to see an example in code....Thanks again!
__________________
ToDoList Obliques MusicMath Donation Mark4celeste Frid i ditt hjärta Eve & the Fisherman on Spotify
tompad is offline   Reply With Quote
Old 08-22-2018, 02:01 PM   #295
tompad
Human being with feelings
 
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 373
Default Word wrap in texteditor

Ok, I am very close to release my first real reascript (not built with actions).
I read in documentation that word wrap is not implemented in TextEditor. :-(
Is there another way to get multiline text from users input?
__________________
ToDoList Obliques MusicMath Donation Mark4celeste Frid i ditt hjärta Eve & the Fisherman on Spotify
tompad is offline   Reply With Quote
Old 08-22-2018, 02:36 PM   #296
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

You could convert the user's input to fit in the window, adding "\n" characters any time the string gets wider than the TextBox (self.wnd_w is the number of characters it fits, I think?). If you need to save/export/copy the text elsewhere, though, you'd need some way of tracking where those extra lines were so you could remove them.

I'd love to have word wrap, I just haven't found an algorithm for tracking where the real line breaks are versus the wrapped ones, etc.
Lokasenna is online now   Reply With Quote
Old 08-27-2018, 07:19 AM   #297
tompad
Human being with feelings
 
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 373
Default

Quote:
Originally Posted by Lokasenna View Post
You could convert the user's input to fit in the window, adding "\n" characters any time the string gets wider than the TextBox (self.wnd_w is the number of characters it fits, I think?). If you need to save/export/copy the text elsewhere, though, you'd need some way of tracking where those extra lines were so you could remove them.

I'd love to have word wrap, I just haven't found an algorithm for tracking where the real line breaks are versus the wrapped ones, etc.
I take a look on it. :-)
__________________
ToDoList Obliques MusicMath Donation Mark4celeste Frid i ditt hjärta Eve & the Fisherman on Spotify
tompad is offline   Reply With Quote
Old 08-27-2018, 07:27 AM   #298
tompad
Human being with feelings
 
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 373
Default

Hola!

I moved my reascript I've been working on on Linux
to my main DAW on windows10 and got some things not
happening. The messageBox dont show up and the else
is running (inspite of some empty text fields).
Script run well on Linux.

Code:
function GUI.elms.btn_save_new:onmouseup()

  GUI.Button.onmouseup(self)
Msg("ShowMessageBox")
  if (GUI.Val("txtbox_caption_tasks") == "") or (GUI.Val("txt_editor_tasks") == "") then

    reaper.ShowMessageBox("Fill in the blanks - you must have text in Tasks and Details", "Fill in the blanks", 0)

  else

    table.insert(items, { prio[1], GUI.Val("txtbox_caption_tasks"), GUI.Val("txt_editor_tasks")})

    sortItems()

    GUI.Val("frm_details", items[GUI.Val("lst_tasks")][3])

    saveToFile()

    emptyTxtFields()

    shiftNewWindow()
  end

end
Are there any modifications I need to do if I want to run script
on windows?
__________________
ToDoList Obliques MusicMath Donation Mark4celeste Frid i ditt hjärta Eve & the Fisherman on Spotify
tompad is offline   Reply With Quote
Old 08-27-2018, 07:31 AM   #299
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

The only differences are if you access file paths or some of the io. and os. commands. The GUI shouldn't care.

Hard to say what the issue is without having the whole script to test though.
Lokasenna is online now   Reply With Quote
Old 08-27-2018, 11:28 AM   #300
tompad
Human being with feelings
 
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 373
Default

Quote:
Originally Posted by Lokasenna View Post
The only differences are if you access file paths or some of the io. and os. commands. The GUI shouldn't care.

Hard to say what the issue is without having the whole script to test though.
Can I PM it to you?
__________________
ToDoList Obliques MusicMath Donation Mark4celeste Frid i ditt hjärta Eve & the Fisherman on Spotify
tompad is offline   Reply With Quote
Old 08-27-2018, 12:07 PM   #301
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

Yup, anytime.
Lokasenna is online now   Reply With Quote
Old 09-06-2018, 07:44 PM   #302
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 391
Default Question about toggle buttons

What is the recommended way to create a toggle button? There doesn't seem to be a built-in option for it.

I guess you could use a single check box?

Alternatively, I could see modifying the mouseDn and mouseUp methods.... but I'd wonder about saving state.

Indeed that makes me wonder. I'd be using toggle buttons to control a lot of switchable on-off parameters of various vsts and jsfxs, and I'm wondering how best to synchronize these states, so when f.i. loading a new preset to a vst, the settings of gui controls would update. I haven't noticed an example of setting the state of a control externally.....

Edit: thinking about this, I guess it's just a matter of calling the GUI:Val function? And state is actually saved by Reaper itself, and you can request a parameter value when the gui opens....
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 09-06-2018, 08:16 PM   #303
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

A single checkbox, yeah. caption = "" and frame = false are probably your friends in that case.

As far as synchronizing the values, as long as you know what you're trying to sync with you can have a function that polls the current VST to see if the parameters have changed, and then if they have repopulate your script's values.

Code:
local function pollVST()
  -- Do whatever you want here
end

GUI.func = pollVST
GUI.freq = 0 -- Interval to call pollVST, 0 = every loop

GUI.Init()
GUI.Main()
Going the other way is much easier - you can append your own code to the elements' event methods to have changes in the script automatically sent over to the VST.

Code:
function GUI.elms.my_checklist:onmouseup()

  -- Make sure the original code is called, note the . and "self" here

  GUI.Checklist.onmouseup(self)

  updateMyVSTState()

end
Be aware of which methods each class uses though, since some use onmousedown, some also have onwheel, etc.
Lokasenna is online now   Reply With Quote
Old 09-06-2018, 08:17 PM   #304
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

You can use Reaper's ExtStates for saving data between script instances, or you can write to a text file yourself as long as the script isn't running in Restricted Permissions mode (it disables all os and io functions).
Lokasenna is online now   Reply With Quote
Old 09-06-2018, 08:37 PM   #305
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 391
Default

okay, I can certainly do that. But it seems like if everything in my script is referencing the state of reaper or the settings of the parameters of some plugin or other, I should be able to restore state of all the elements in the gui by querying Reaper, and those values should be storable and recallable by SWS snapshots..... correct?
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 09-06-2018, 09:14 PM   #306
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

I would think so, yeah.
Lokasenna is online now   Reply With Quote
Old 09-19-2018, 03:45 PM   #307
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 1,029
Default GUI Builder Import/Paste Code

With the GUI Builder if you could import or paste a section of code would help.
This way I could rearrange existing buttons or other elements easily.
MusoBob is offline   Reply With Quote
Old 09-20-2018, 05:52 PM   #308
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 1,029
Default

Have a look at AHK, SmartGUI you can import scripts into that and

AutoGUI you can clone other GUI's.
MusoBob is offline   Reply With Quote
Old 09-26-2018, 02:35 PM   #309
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

Better import/export options are on my list, along with being able to read/write the GUI code for an existing script.

Unfortunately, some organizational choices I made for GUI Builder have created a few bugs that are really painful to fix and work around, so the smart thing to do would be a complete rewrite.

Unfortunately unfortunately, I'm prepping for a course and don't have much time to spare. Hoping to fix a couple of instant-crash bugs I've found, if nothing else.
Lokasenna is online now   Reply With Quote
Old 10-03-2018, 05:21 AM   #310
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 1,029
Default

I'm trying to get the button Toggle state color to show, the initial button text color and color fill works, the text and text color will change for the New button but not the color fill. It seems to use the default color fill dark gray.
It's very late here so might just be a brain freeze.



Code:
function btn_click_show_chords_in_items()
    reaper.Main_OnCommand(40691, 0) -- View: Toggle show media cues in items
      
    update_show_chords_in_items()
    end
     






function update_show_chords_in_items() 
       
--Delete old buttons before updating  

   if reaper.GetToggleCommandState(40691) == 1 then onstate = "red"
   else
     onstate = "gray"
   end
GUI.elms.show_chords_in_items_btn:ondelete()
 
GUI.New("show_chords_in_items_btn",      "Button",           3, 275+x1, 180+y1, 135, 20, "New Chords in Items "..onstate, btn_click_show_chords_in_items)
GUI.elms.show_chords_in_items_btn.col_txt = "yellow"
GUI.elms.show_chords_in_items_btn.col_fill = onstate    
    

end



   if reaper.GetToggleCommandState(40691) == 1 then onstate = "red"
   else
     onstate = "gray"
   end
     
GUI.New("show_chords_in_items_btn",      "Button",           3, 275+x1, 180+y1, 135, 20, "Initial Chords in Items", btn_click_show_chords_in_items)
GUI.elms.show_chords_in_items_btn.col_txt = "yellow"
GUI.elms.show_chords_in_items_btn.col_fill = onstate
MusoBob is offline   Reply With Quote
Old 10-03-2018, 05:45 AM   #311
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

Try adding:
Code:
GUI.elms.show_chords_in_items_btn:init()
afterward. The button itself is drawn to a buffer when it's created, so changing the color will need that buffer to be redrawn.
Lokasenna is online now   Reply With Quote
Old 10-03-2018, 10:55 AM   #312
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 1,029
Default

Love it ! perfect !
MusoBob is offline   Reply With Quote
Old 10-17-2018, 10:28 AM   #313
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,498
Default

Is there a way to automatically incorporate the GUI code into my script, without having to require it externally? The main reason is, I would like to make the Radio to update in realtime, so changes are instant, and to be able to color the background of each text line a different color.
Is it possible?


Thanks!
amagalma is offline   Reply With Quote
Old 10-17-2018, 01:45 PM   #314
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

You could copy/paste all the necessary modules into it, but then you'd never see any updates/fixes I put up.

If you just require them as normal you can rewrite or extend any of the GUI or element functions that want - I do it all the time. There are also a number of empty methods ready to go for your own code, such as onupdate.
Lokasenna is online now   Reply With Quote
Old 10-18-2018, 05:59 PM   #315
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,498
Default

Thanks!


How can I "rewrite or extend any of the GUI or element functions that want"? I mean, is it possible to change them in my script? Or change the external libraries? Because in this case, my changes will get overwritten in the next update. Could I use onupdate somehow to make the Radio update in realtime?
amagalma is offline   Reply With Quote
Old 10-18-2018, 06:35 PM   #316
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

No need to worry about breaking the user's install or having your code disappear - Lua is happy to let you rewrite things at runtime, so whatever your script does with the GUI stays in your script.

Well, unless you were rude enough to actually open the files and write to them...

You can overwrite any or all of the GUI functions in your script by just declaring that function again. All of the methods listed in the project documentation are already present, but most of them are empty. Using onupdate, for example, is as simple as just writing your own code for it:

Code:
-- Radio class has already been loaded

function GUI.Radio.onupdate()
  -- Any code here will be called on every 
  -- GUI loop as long as the element isn't 
  -- on a frozen or hidden Z layer
end
Just have a look in the class file first to see if it's making use of a particular method. Off the top of my head I don't think any of them use onupdate, but let's pretend that Radio does - you probably don't want to break whatever it's doing, so it's important to grab the original method first and include a call to it:

Code:
local RadioUpdate = GUI.Radio.onupdate

function GUI.Radio:onupdate()
  -- your code here

  RadioUpdate(self)

  -- or your code here
end
This is particularly important to remember if you're messing with things like onmouseup that pretty much every class uses.

You can also do this at the level of individual elements if you, for example, only want one particular Radio element to do something special:

Code:
function GUI.elms.my_radio:onmouseup()

  -- Note the . and self here
  GUI.Radio.onmouseup(self)

  doMyStuff()

end
Depending on what you're doing, sometimes it might be easier to add your code to the element directly so it can easily access of the element's properties using self:

Code:
function GUI.elms.my_radio:doMyStuff()

  Msg(self.name .. " has the value: " .. self:val() )

end

function GUI.elms.my_radio:onmouseup()

  self:doMyStuff()

end
Lokasenna is online now   Reply With Quote
Old 10-18-2018, 06:38 PM   #317
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,254
Default

Just a reminder, though - it's always good to make sure that Radio NEEDS to update before actually doing it, so you aren't hogging the CPU.
Lokasenna is online now   Reply With Quote
Old 10-18-2018, 08:03 PM   #318
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,498
Default

Thank you so much for the tutorial!!
amagalma is offline   Reply With Quote
Old 10-27-2018, 07:47 PM   #319
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 1,029
Default

Where would we be without your awesome GUIs ???
Thanks !!!!!!

https://forum.cockos.com/showthread....52#post2050752


MusoBob is offline   Reply With Quote
Old 11-04-2018, 05:14 PM   #320
ausbaxter
Human being with feelings
 
Join Date: Apr 2016
Posts: 39
Default

Hey guys, hoping someone can help me with this. I'm doing some simple scaling on a listbox element. Looks like the bg rect is not receiving the width or height updates. Text and scrollbar update as they should. Figured i'd ask if anyone had this problem or know a solution before diving into the class!



Here's the scaling code i'm running:

Code:
function OnResize()
    GUI.elms.Listbox1.w = gfx.w - 20
    GUI.elms.Listbox1.h = gfx.h - 20
    GUI.elms.Listbox1:redraw() --same behavior without this line
    GUI.elms.Listbox1:wnd_recalc()
end
...
...
GUI.onresize = OnResize
Hoping Lokasenna or someone else can save me <3
ausbaxter 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 12:42 PM.


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