|
|
|
08-03-2018, 03:12 PM
|
#241
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Updated the library to use different fonts per OS - no more gross Arial for Mac users, and no Courier in the Textboxes for anybody anymore.
Downside: Any scripts made with GUI Builder that have a Textbox will probably break. It's a simple fix - in each Textbox's GUI.New, make sure font_b is set to monospace, or not at all.
Cheers.
This update also fixes some longstanding issues with the Textbox's caret position on Mac that I wasn't aware of.
|
|
|
08-04-2018, 08:08 AM
|
#242
|
Human being with feelings
Join Date: Apr 2017
Location: St. Petersburg, FL
Posts: 880
|
Quote:
Originally Posted by Lokasenna
Updated the library to use different fonts per OS - no more gross Arial for Mac users, and no Courier in the Textboxes for anybody anymore.
Downside: Any scripts made with GUI Builder that have a Textbox will probably break. It's a simple fix - in each Textbox's GUI.New, make sure font_b is set to monospace, or not at all.
Cheers.
This update also fixes some longstanding issues with the Textbox's caret position on Mac that I wasn't aware of.
|
And list boxes are fixed too!
|
|
|
08-05-2018, 02:13 AM
|
#243
|
Human being with feelings
Join Date: Mar 2013
Posts: 5,857
|
Quote:
Originally Posted by Lokasenna
Updated the library to use different fonts per OS - no more gross Arial for Mac users, and no Courier in the Textboxes for anybody anymore ...
|
The listbox selection highlight issue on macOS (mentioned in post #201: https://forum.cockos.com/showpost.ph...&postcount=201) seems to be fixed too with this update.
Thanks!
|
|
|
08-05-2018, 04:04 AM
|
#244
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
|
Woop! That's awesome, that one was a real annoying bug
|
|
|
08-05-2018, 07:32 AM
|
#245
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
|
@Solger:
does ReaLaunch need an update in order to fix that list bug or should it work out of the box?
|
|
|
08-05-2018, 08:03 AM
|
#246
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Other scripts will see the fix right away. The current version of ReaLauncher overwrites the code that was bugged, so it'll need an update, but he has one pending on the repo.
|
|
|
08-05-2018, 09:26 AM
|
#247
|
Human being with feelings
Join Date: Mar 2013
Posts: 5,857
|
Quote:
Originally Posted by _Stevie_
@Solger:
does ReaLaunch need an update in order to fix that list bug or should it work out of the box?
|
Yeah, as Lokasenna already mentioned above, the next update is already on the way (and is currently in the pull request)
|
|
|
08-05-2018, 01:21 PM
|
#248
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
|
Looking forward to it, you guys rock!
|
|
|
08-06-2018, 03:51 AM
|
#249
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
Moved from another thread
Hi!
I have this senario:
When I left click in a listbox the item get selected and in a frame
some text is shown. When I right click in my listbox I get a dropdown-
menu BUT the item in listbox dont get selected.
How can I select an item in listbox when I right click?
AND is it possible to change color on selected item?
Answer from:
Quote:
Originally Posted by Lokasenna
- Wrong thread. :P
- You could have the right-click method call the left-click method at the end, I think. Haven't tried.
Code:
function GUI.elms.my_listbox:onr_mouseup() -- or whatever the method is called, I forget
... do stuff...
self:onmouseup()
end
|
I have tried calling the function "GUI.elms.lst_tks nmouseup()"
inside of the onmouser_down but no change - no item under the
mouse is selected.
Last edited by tompad; 08-06-2018 at 03:59 AM.
|
|
|
08-06-2018, 04:14 AM
|
#250
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
This is my code:
Code:
function GUI.elms.lst_tks:onmouser_down()
--Calling onmouseup
GUI.elms.lst_tks:onmouseup() --
-- Getting coordinates of mouse for dropdown
gfx.x = gfx.mouse_x
gfx.y = gfx.mouse_y
-- Show dropdown
menu = gfx.showmenu("New|Edit|Done|Delete")
--Checking what is selected
if menu == 1
then funNew()
elseif menu == 2
then funEdit()
elseif menu == 3
then funDone()
elseif menu == 4
then funDelete()
end
-- Needs to be added - dont ask me why
GUI.Listbox.onmouser_down(self)
end
I am using a call to onmouseup() because when earlier
using onmousedown() nothing happened.
|
|
|
08-06-2018, 05:18 AM
|
#251
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
Hmmmm, it seems like the item IS selected but its not coloured,
its the previous item that keeps its colour. How can I make the
latest selected item coloured?
|
|
|
08-06-2018, 05:42 AM
|
#252
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
1. That's strange - it should be redrawing automatically. Try adding self:redraw() at the end.
2. It can just be self.onmouseup(). When you call a function with :, Lua secretly gives it the name to the left of the : as a parameter called self to work with.
3. You don't need to a call to GUI.Listbox.mouser_down in this case - that function doesn't exist. It is important to check though, and if it did that would be the correct thing to do. It's necessary when you want to add to an existing function - you run your own code, and then you tell it "do what you normally do".
4. onmouseup is the right one to call because onmousedown only affects the scrollbar. You can see which methods are used, and what they do, by looking in the class files.
If it's still giving you trouble, PM with me the script and I can have a look.
|
|
|
08-06-2018, 03:29 PM
|
#253
|
Human being with feelings
Join Date: Aug 2009
Location: Sweden
Posts: 70
|
This is awesome work and really useful!
Quote:
Originally Posted by Lokasenna
This update also fixes some longstanding issues with the Textbox's caret position on Mac that I wasn't aware of.
|
Both the caret position and selection is off in the Texteditor as well on OSX:
It works fine using the same fix as in Listbox:
Code:
function GUI.TextEditor:wnd_recalc()
GUI.font(self.font_b)
self.char_w, self.char_h = gfx.measurestr("i")
--self.char_h = gfx.texth
self.wnd_h = math.floor((self.h - 2*self.pad) / self.char_h)
--self.char_w = gfx.measurestr("_")
self.wnd_w = math.floor(self.w / self.char_w)
end
|
|
|
08-06-2018, 03:59 PM
|
#254
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
What the hell... I thought I fixed that at the same time.
Thanks, updating.
|
|
|
08-07-2018, 02:03 AM
|
#255
|
Human being with feelings
Join Date: Aug 2009
Location: Sweden
Posts: 70
|
Quote:
Originally Posted by Lokasenna
What the hell... I thought I fixed that at the same time.
Thanks, updating.
|
Now it's working! Thanks!
|
|
|
08-08-2018, 03:08 AM
|
#256
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
Quote:
Originally Posted by Lokasenna
1. That's strange - it should be redrawing automatically. Try adding self:redraw() at the end.
|
No change. However I discovered that the second time I click with
right mouse the item is selected.
Quote:
2. It can just be self.onmouseup(). When you call a function with :, Lua secretly gives it the name to the left of the : as a parameter called self to work with.
|
Ok, learned something new again! :-)
Edit: Ooooops, got crash:
Code:
Error: Class - Listbox.lua:159: attempt to index a nil value (local 'self')
Stack traceback:
Core.lua:72: in metamethod '__index'
Class - Listbox.lua:159: in field 'onmouseup'
DLT_ToDoList.lua:398: in field 'onmouseup'
DLT_ToDoList.lua:439: in method 'onmouser_down'
Core.lua:905: in field 'Update'
Core.lua:419: in field 'Main_Update_Elms'
Core.lua:286: in function <...am Scripts/Development/Lokasenna_GUI v2/Library/Core.lua:282>
[C]: in function 'xpcall'
Core.lua:282: in function <...am Scripts/Development/Lokasenna_GUI v2/Library/Core.lua:281>
Lokasenna_GUI: v2.15.5
Reaper: 5.93/linux64
Platform: Other
Quote:
3. You don't need to a call to GUI.Listbox.mouser_down in this case - that function doesn't exist. It is important to check though, and if it did that would be the correct thing to do. It's necessary when you want to add to an existing function - you run your own code, and then you tell it "do what you normally do".
|
I checked the class file for Listbox, and you are right, it doesn't exist.
BUT this makes me VERY confused - how can I show the dropdown with right
click in Listbox if onmouser_down doesn't exist!? It shows up just like I
expected, and the selection in dropdown is working fine.
Quote:
4. onmouseup is the right one to call because onmousedown only affects the scrollbar. You can see which methods are used, and what they do, by looking in the class files.
If it's still giving you trouble, PM with me the script and I can have a look.
|
I will look at this a bit more and if I cant solve it I PM you.
Im very grateful for your help!
|
|
|
08-09-2018, 01:25 AM
|
#257
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
Lokasenna - thanks for the help!
After I PM:ed you I remembered another question. Maybe its
better to take it here because other people maybe can benefit
on the answer.
What is the best practice if I need 2 windows in my script?
Is it to make one main window and load another separate window
(or using tabs in main window)
or
Is it to have one window and make use of z-index to show and
hide the different parts I want to use.
|
|
|
08-09-2018, 03:13 AM
|
#258
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
What is wrong with this? Suddenly my buttons dont run the functions
I told them to do. Not even msg!
Code:
GUI.New("btn_edit", "Button", {
z = 11,
x = 80,
y = 256,
w = 60,
h = 24,
caption = "Edit",
font = 3,
col_txt = "txt",
col_fill = "elm_frame",
func = fun_edit
})
function fun_edit ()
msg("Edit")
-- body...
local selected = GUI.Val("lst_tasks")
msg(selected)
shiftWindow()
str1 = items[selected][1]
GUI.Val("txtbox_caption_tasks", str1)
str2 = items[selected][2]
GUI.Val("txt_editor_tasks", str2)
end
|
|
|
08-09-2018, 05:13 AM
|
#259
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Quote:
Originally Posted by tompad
What is the best practice if I need 2 windows in my script?
Is it to make one main window and load another separate window
(or using tabs in main window)
or
Is it to have one window and make use of z-index to show and
hide the different parts I want to use.
|
Do you mean two script windows ( gfx.init) or two Window elements?
The first can't be done - scripts are limited to one window at a time, so you'd have to gfx.quit the first window, open a new one, and then do the same to re-open your original window after.
The second doesn't require anything special. Just make sure that the z-layers you define for the first window don't overlap with the z-layers for the second window, so they both have their own space to do stuff in.
|
|
|
08-09-2018, 05:14 AM
|
#260
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Quote:
Originally Posted by tompad
What is wrong with this? Suddenly my buttons dont run the functions
I told them to do. Not even msg!
|
That's weird. I don't see anything there that would break it - can you send me the entire script?
|
|
|
08-09-2018, 04:47 PM
|
#261
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
Quote:
Originally Posted by Lokasenna
Do you mean two script windows (gfx.init) or two Window elements?
|
I think I mean two window elements - like a dialog window but with more elements on than button Yes/No.
Like a window with a dialog window for preferences.
Quote:
The second doesn't require anything special. Just make sure that the z-layers you define for the first window don't overlap with the z-layers for the second window, so they both have their own space to do stuff in.
|
So I cant have say 2 buttons on the same coordinates (x,y) but in different z-layers?
My scenario is some buttons, listbox, frames etc in z-layer 11 and some
similar elements hidden in layer 5 and when I shift the z-layer - the
elements that have z-layer 11 get 5 and vice versa.
|
|
|
08-09-2018, 05:48 PM
|
#262
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Sorry, I misunderstood.
You can have as many Window elements in your script as you want - my GUI Builder has two at the moment, and will certainly pick up one or two more at some point.
I don't think it would break anything to have them share the OK and Cancel buttons, however:
1. You'd have to remember to move them to the appropriate z-layers all the time.
2. You'd have to change what function they're calling so the appropriate Window's :close is being run.
IMO it's way easier to have a separate pair of buttons for each window.
|
|
|
08-10-2018, 03:41 AM
|
#263
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
Quote:
Originally Posted by Lokasenna
That's weird. I don't see anything there that would break it - can you send me the entire script?
|
I solved it by removing the "func = fun_edit" in the element and made a "function GUI.elms.btn_edit nmouseup()" instead.
|
|
|
08-10-2018, 04:36 AM
|
#264
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
Quote:
Originally Posted by Lokasenna
Sorry, I misunderstood.
You can have as many Window elements in your script as you want - my GUI Builder has two at the moment, and will certainly pick up one or two more at some point.
I don't think it would break anything to have them share the OK and Cancel buttons, however:
1. You'd have to remember to move them to the appropriate z-layers all the time.
2. You'd have to change what function they're calling so the appropriate Window's :close is being run.
IMO it's way easier to have a separate pair of buttons for each window.
|
Ok, I go with the z-layering method this time then, but using window class
looked interesting.
|
|
|
08-10-2018, 04:48 AM
|
#265
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
Spagetti in head and code
Hi again :-)
It's interesting to code in Reascript/lua - but I must admit it
gets bigger and bigger, so many different way to do different things!
I need to narrow down what I want to do - so I am breaking it down to small parts.
Right now I wanted to make an item in a listbox selected when I start the script
and show some text that is connected to the item in a separate frame.
What I come up with is this, but I am unsure if this is the best way to do it?
Many of my earlier coding suffered of what I call "spagetti-code"
and I guess this is just another spagetti-version:
Code:
function GUI.elms.lst_tasks:init ()
-- Make the first item selected
self.retval = {[1] = true}
GUI.Listbox.init(self)
-- Put the connected text in frame
str = items[1][2]
GUI.Val("frm_details", str)
end
GUI.Init()
GUI.elms.lst_tasks:init ()
GUI.Main()
Is this the optimal way to do it or can it be done in a better way? Hit me!
Last edited by tompad; 08-10-2018 at 04:56 AM.
|
|
|
08-10-2018, 12:58 PM
|
#266
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
- Some elements end up calling their init methods more than once, for instance if they have to re-do some internal calculations. In that case your code would be resetting the listbox to 1 = true unintentionally. I'd suggest doing that in a separate function.
- I recommend using GUI.Val() as a general rule, again because some of the elements do internal calculations that you're bypassing if you set retval directly. In this case it's not an issue, but if you were doing the same thing after Main has started you'd have to manually call self:redraw().
- To save yourself some time and typing, you could make a function for setting the frame's text.
Code:
function set_frm_details()
GUI.Val("frm_details", items[1][2]
end
function set_initial_state()
-- If you don't specify any keys, Lua will just start the
-- table at 1 for you
GUI.Val("lst_tasks", {true})
end
set_initial_state()
set_frm_details()
GUI.Init()
GUI.Main()
Spaghetti code is something everyone does, especially when learning - it can take a lot of practice to stop doing it. If you're interested, I highly recommend these books:
Refactoring - Martin Fowler - Even if you just read the example where he tidies up a video store's software.
Clean Code - Robert C. Martin
Or just Google "refactoring" and "clean code", find some sites that actually show examples rather than telling you "don't do this", watch a video or two, etc.
|
|
|
08-11-2018, 04:00 AM
|
#267
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
Quote:
Originally Posted by Lokasenna
- To save yourself some time and typing, you could make a function for setting the frame's text.
Code:
function set_frm_details()
GUI.Val("frm_details", items[1][2]
end
function set_initial_state()
-- If you don't specify any keys, Lua will just start the
-- table at 1 for you
GUI.Val("lst_tasks", {true})
end
set_initial_state()
set_frm_details()
GUI.Init()
GUI.Main()
|
Works like a charm!! Thanks
Quote:
Spaghetti code is something everyone does, especially when learning - it can take a lot of practice to stop doing it. If you're interested, I highly recommend these books:
Refactoring - Martin Fowler - Even if you just read the example where he tidies up a video store's software.
Clean Code - Robert C. Martin
Or just Google "refactoring" and "clean code", find some sites that actually show examples rather than telling you "don't do this", watch a video or two, etc.
|
Will order books, starting with Refactoring.
Just Googled and have already put away some bad smell :-)
Thanks for the recommendation!
|
|
|
08-11-2018, 11:31 AM
|
#268
|
Human being with feelings
Join Date: Mar 2013
Posts: 5,857
|
Hey Lokasenna,
I'm currently adapting the ReaLauncher code for Linux support and it seems like that Linux needs the same font scaling as OSX.
So it would be great if you could add this in a future update (see the bold part added to your code below). Thanks.
Quote:
Originally Posted by Core.lua
GUI.font = function (fnt)
local font, size, str = table.unpack( type(fnt) == "table"
and fnt
or GUI.fonts[fnt])
-- Different OSes use different font sizes, for some reason
-- This should give a roughly equal size on Mac
if string.find(reaper.GetOS(), "OSX") or string.find(reaper.GetAppVersion(), "Linux") then
size = math.floor(size * 0.7)
end
-- Cheers to Justin and Schwa for this
local flags = 0
if str then
for i = 1, str:len() do
flags = flags * 256 + string.byte(str, i)
end
end
gfx.setfont(1, font, size, flags)
end
|
Checking for a "Linux" version via reaper.GetAppVersion() seems to be the better (more readable code) option since reaper.GetOS() returns just "Other".
Quote:
reaper.GetAppVersion(): 5.941/linux64
reaper.GetOS(): Other
|
|
|
|
08-11-2018, 11:45 AM
|
#269
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
I can probably just check if not Windows, but sure. Updating.
|
|
|
08-11-2018, 11:45 AM
|
#270
|
Human being with feelings
Join Date: Mar 2013
Posts: 5,857
|
Quote:
Originally Posted by Lokasenna
I can probably just check if not Windows, but sure. Updating.
|
Yeah, whatever works best Thanks.
|
|
|
08-12-2018, 02:14 AM
|
#271
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
Curser placement
Hi again! :-)
I'm not sure if this have been discussed earlier, but I'm running
Reaper on linux and the cursor placement in Textbox and Texteditor
is strange. The cursor is visible in middle of text but if I backspace
it removes the last letters in end of text. A bug?
|
|
|
08-12-2018, 06:12 AM
|
#272
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Are you running the newest version of the GUI? There were some font issues common to Mac and Linux that (AFAIK) were fixed recently.
Does your Linux have DejaVu Sans Mono? It looks for that because (according to the internet) 90%+ of Linux installations have it, but if you don't then you'll end up with Arial or Courier or something.
|
|
|
08-12-2018, 09:55 PM
|
#273
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
Quote:
Originally Posted by Lokasenna
Are you running the newest version of the GUI? There were some font issues common to Mac and Linux that (AFAIK) were fixed recently.
|
I am running 2.15.7.
Quote:
Does your Linux have DejaVu Sans Mono? It looks for that because (according to the internet) 90%+ of Linux installations have it, but if you don't then you'll end up with Arial or Courier or something.
|
I checked the system and DejaVu Sans Mono is installed.
Edit:
Can it be something with using GUI from an earlier version of Guibuilder?
Last edited by tompad; 08-13-2018 at 03:32 AM.
|
|
|
08-13-2018, 04:31 AM
|
#274
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Maybe. Have a look in the script and see what the textbox's font_b is set to - it should be "monospace", but older ones might be "textbox".
|
|
|
08-13-2018, 11:01 AM
|
#275
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
Quote:
Originally Posted by Lokasenna
Maybe. Have a look in the script and see what the textbox's font_b is set to - it should be "monospace", but older ones might be "textbox".
|
Font_b is set to monospace. :-(
|
|
|
08-13-2018, 11:54 AM
|
#276
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
This may or may not help - it lets you specify a font, tries to draw some text with it, and shows rectangles for the reported character sizes. Save it, run it, click the window, enter "DejaVu Sans Mono", and see what happens.
https://www.dropbox.com/s/f7sxxqzy4f...uring.lua?dl=0
|
|
|
08-13-2018, 12:35 PM
|
#277
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
Quote:
Originally Posted by Lokasenna
This may or may not help - it lets you specify a font, tries to draw some text with it, and shows rectangles for the reported character sizes. Save it, run it, click the window, enter "DejaVu Sans Mono", and see what happens.
https://www.dropbox.com/s/f7sxxqzy4f...uring.lua?dl=0
|
It tells me "DejaVu Sans Mono is not a valid font face " in red.
|
|
|
08-13-2018, 12:57 PM
|
#278
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
Quote:
Originally Posted by tompad
It tells me "DejaVu Sans Mono is not a valid font face " in red.
|
Try without the spaces: DejaVuSansMono.
|
|
|
08-13-2018, 01:09 PM
|
#279
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 813
|
Quote:
Originally Posted by cfillion
Try without the spaces: DejaVuSansMono.
|
Same answer....
|
|
|
08-13-2018, 01:29 PM
|
#280
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
Quote:
Originally Posted by tompad
Same answer....
|
Ah right, for some reason gfx.getfont() always returns an empty string on Linux (bug?). Try bypassing the check with "if false then" instead of "if retfont ~= font then".
libSwell on Linux finds fonts from their filename instead of the family name (DejaVu Sans Mono is usually installed as DejaVuSansMono.ttf without spaces). (It also appears to only scan inside /usr/share/fonts so I don't think it supports user fonts or exotic installs, but I digress...)
Last edited by cfillion; 08-13-2018 at 02:10 PM.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 02:32 AM.
|