Old 11-09-2019, 10:12 AM   #601
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 402
Default

Quote:
Originally Posted by Lokasenna View Post
The previous versions were all double quotes as well. As for why:
- IMO doubles make slightly more sense since single quotes/apostrophes are more likely to appear in a UI's text.
I think this is the best argument... sold.

Looks like there may be enough image support here for me to port my IControl class over to V3 without having to edit the base classes (which I did before). I'll submit it for your inspection when I get something working.
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 11-09-2019, 11:45 PM   #602
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 402
Default

I'm trying to figure out what the (...) syntax does in LUA. I'm searching on google, and it doesn't seem to be 'searchable'! Google turns nothing up for it.

Do you know where I might be able to read up on it?
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 11-10-2019, 12:24 AM   #603
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,813
Default

They're called vararg functions: https://www.lua.org/manual/5.3/manual.html#3.4.11. The vararg expression ... (three dots) stores all extra parameters that were given to the function (it's not a table, more like functions with multiple return values).

Last edited by cfillion; 11-10-2019 at 12:46 AM.
cfillion is offline   Reply With Quote
Old 11-10-2019, 10:18 PM   #604
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 402
Default

Quote:
Originally Posted by cfillion View Post
They're called vararg functions: https://www.lua.org/manual/5.3/manual.html#3.4.11. The vararg expression ... (three dots) stores all extra parameters that were given to the function (it's not a table, more like functions with multiple return values).
Thanks! A lot of good information there about how arguments work.

I'm going to have to get my head around passing functions around. It's all new to me and makes my head spin a bit....

As an example, in 'working with images' I find:

Code:
if self:containsPoint(state.mouse.x, state.mouse.y) then

		self.func(table.unpack(self.params))
self.params here refers to func's self, is that right? Am I right in thinking that func as an argument to the control should be the function we want it to execute when the button is pressed?

I'm trying to imagine what syntax I would use to have the func parameter call an action that required the value of self.state as an argument... I've figured other ways to do that without func, (basically overriding the control's mouse methods with direct calls) but it seems like I'm missing the point. There is an easier way, correct?

Okay, searched in Knob.lua, and it looks like the func argument is not being used in this way there, so maybe I was mistaken. Is what I'm talking about above possible? or desirable?
__________________
eric moon
Very Stable Genius
https://gogolab.com/

Last edited by woodslanding; 11-10-2019 at 10:55 PM.
woodslanding is offline   Reply With Quote
Old 11-11-2019, 07:35 AM   #605
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,348
Default

Quote:
Originally Posted by woodslanding View Post
Thanks! A lot of good information there about how arguments work.

I'm going to have to get my head around passing functions around. It's all new to me and makes my head spin a bit....

As an example, in 'working with images' I find:

Code:
if self:containsPoint(state.mouse.x, state.mouse.y) then

		self.func(table.unpack(self.params))
self.params here refers to func's self, is that right? Am I right in thinking that func as an argument to the control should be the function we want it to execute when the button is pressed?
self is just an argument; in this case self is the IButton. If you're used to something like Javascript's this, self isn't passed around the same way.

Quote:
I'm trying to imagine what syntax I would use to have the func parameter call an action that required the value of self.state as an argument... I've figured other ways to do that without func, (basically overriding the control's mouse methods with direct calls) but it seems like I'm missing the point. There is an easier way, correct?
I've just pushed an update for you. . User functions for Button, Menubar, and the IButton example in the image script all receive self as their first argument. i.e. when creating them you would use:
Code:
func = function(self, a, b, c) Msg(self.name, a, b, c) end,
params = {"a", "b", "c"}
Lokasenna is online now   Reply With Quote
Old 11-11-2019, 10:31 AM   #606
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 402
Default

oh, sweet, thanks!
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 11-13-2019, 10:36 AM   #607
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 233
Default

Is it possible to set the inc paramter of the Slider class to something smaller than 1? I´d like to keep the range at 1 top at the beginning and inc something like 0,01, cause then i wouldnt need to do any math, should the user change the range of the fader.
reapero is offline   Reply With Quote
Old 11-13-2019, 10:38 AM   #608
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,348
Default

Quote:
Originally Posted by reapero View Post
Is it possible to set the inc paramter of the Slider class to something smaller than 1? I´d like to keep the range at 1 top at the beginning and inc something like 0,01, cause then i wouldnt need to do any math, should the user change the range of the fader.
Yup. One of the sliders in the General Demonstration example has increments of 0.25:
Code:
GUI.New("my_sldr", 	"Slider",		4, 128, 256, 128, "Slider", 0, 10, 20, 0.25, "v")
Lokasenna is online now   Reply With Quote
Old Yesterday, 02:00 AM   #609
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 233
Default

So how come this doesnt work? I kept the formatting that your GUI builder puked:

Code:
GUI.New("Offset", "Slider", {
    z = 11,
    x = 64.0,
    y = 340,
    w = 96,
    caption = "Offset",
    min = offset_min,
    max = offset_max,
    defaults = {0,0},
    inc = 0.1,
    dir = "h",
    font_a = 2,
    font_b = 4,
    col_txt = "txt",
    col_fill = "elm_fill",
    bg = "wnd_bg",
    show_handles = true,
    show_values = true,
    cap_x = 0,
    cap_y = 0
    
})
Offset_min is 0 and offset_max is 1. The slider goes straight from 0 to 1, no steps allowed.

Last edited by reapero; Yesterday at 03:37 AM.
reapero is offline   Reply With Quote
Old Yesterday, 07:17 AM   #610
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,348
Default

My bad; it wasn't picking up the inc parameter for elements created as a table. Pushing a fix up now.
Lokasenna is online now   Reply With Quote
Old Yesterday, 01:05 PM   #611
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 233
Default

Thanks Loka. Working nicely now!
reapero 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 04:19 PM.


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