Class: GuiHelpers

LuxModule: gui

GuiHelpers contain a few functions to aid application development. Can be accessed via GH as well.

Methods:

Method overview:


addcheckbox (Container frame,int x,y,w,h, string title, table parameters)
returns: (int newy, Checkbox)

adds Checkbox to frame.
Parameters table contains:

  1. initvalue: boolean
  2. callback: function, callback(state).

addcolorbutton (Container frame,int x,y,w,h, string title, table parameters)
returns: (int newy, fn setcolor, Button)

creates a color button which on execution pops up a colormenu dialog. returns a function, which can be used to change preview button color, and new y value which is y + h.
Function: setcolor(table colorRGBA, [boolean noevent]. Returned button contains .lbl
Parameters table contains:

  1. initvalue: table, color HSVA
  2. initrgba: table, color RGBA
  3. callback: function, callback(obj,r,g,b,a)
  4. [obj]: upvalue for function callback
  5. [alphaname]: string, Alphaname if alpha slider should be available
  6. [nomodal]: boolean, no darkening modal dialog
  7. [noalpha]: boolean, no alpha in the preview button color
  8. [titleicon]: Icon, instead of button label.
  9. [ok]: string, okay text
  10. [cancel]: string, cancel text

addslider (Container frame,int x,y,w,h, string title, table parameters)
returns: (int newy, Slider)

creates a slider with leading description label (slider.lbl) and following value label (slider.lblval). New y value which is y + h.
slidervalue = sliderpos * scale + offset
Parameters table contains:

  1. initvalue: float, 0-1 position along slider
  2. callback: function, (outvalue, sliderpos) : callback (slidervalue,numericinput,sliderpos). When allowinput is true and callback is called with "nil,numericinput,nil" it must return sliderpos as well. Otherwise only outvalue is taken and (slidervalue, nil, sliderpos) are passed.
  3. [scale]: float
  4. [offset]: float
  5. [increment]: float, Slider increment
  6. [intmode]: boolean, Slider IntegerMode

  7. [labelw]: int, name label widht, defaults to GH.sldLabelwidth
  8. [valw]: int, value label width, defaults to GH.sldLabelval
  9. [formatstr]: string, argument to string.format for value label
  10. [allowinput]: boolean, allows manual popup dialog input, when clicking on value label

createcolormenu (int x,y,w,h, string title, table colorHSVA, fn onchange, [upvalue], [string alphaname])
returns: (Container)
creates a container with a graphical color menu. Initilized with the table value.
Function: onchange(upvalue,r,g,b,alpha)
filedialog (string title,oktext,canceltext,[initpath],[fn onsave], [oncancel], [table strings extensions], [string startname], [fn addedframe], [table warnonoverwrite])
returns: (GroupFrame)
creates and file dialog as popup menu.
Functions: onsave(fileframe,filepath,filetext), oncancel(fileframe). Both must return true if dialog should be destroyed.
addedframe(fileframe) allows to add custom frame to the modal dialog which must be returned by the function.

warnonoverwrite will cause yes/no popup and can contain
  1. width: int
  2. height: int
  3. title: string
  4. descr: string
  5. yes: string
  6. no: string
frameminmax (Container frame, fnminbounds, fnmaxbounds, [fninput], [boolean spaceable])
returns: (Button btn)

creates a button "Hide"/"Show" which sets bounds based on the returns of fnmaxbounds and fnminbounds, which use fninput as input. All functions return x,y,w,h. If fninput is not specified current window dimensions are taken. When minimized all children are removed. Once minimized btn.oldcomponents will be set and hold all temporarily removed Components. When spaceable is set, focus and space bar will not cause the button to act.

getIconUVs (texture,x,y,[iconwidth],[iconheight],[gridwidth],[gridheight])
returns: (float u,v,uscale,vscale)

returns u,v position and scalings for an icon inside a texture (top =0,0) for setting texture matrices. Takes rectangle textures into account. Grid and icon dimensions default to 24.

makeLayoutFunc (Rectangle hostref, Rectangle ref, table params)
returns: (fnlayouter)

returns a function that computes new rectangles according to rescaling / repositioning behavior. x,y,w,h returned by fnlayouter (nx,ny,nw,nh). On call of makeLayoutFunc the current Rectangles and their relative positions to refbounds are stored.
The params table contains:

  1. bottom: boolean for anchor.y
  2. right: boolean for anchor.x
  3. relscale: {boolean w,h}, required
  4. relpos: {boolean x,y}, required

When relscale is true for a dimension the size is changed according to the ratio of original refsize and newsize. When relpos is true, the position of top left corner of the component changes relatively to scaling, when false it will keep its original distance to the anchor point. Anchor point is made from reference dimension of hostframes and is created from "right" and "bottom".

modaldialog ([titlename], [int x,y,w,h], [int fw,fh], [boolean nomodal])
returns: (TitleFrame)
creates a modal titleframe on top of everything, and normally darkens the background (unless nomodal is true). All arguments are optional. x,y,w,h default to 0,0 and window size. fw/fh are the dimensions of the TitleFrame created. Returns the empty titleframe, mostly used for pop-up menus.
popupYesNo (int w,h, string title, question, function fnyes, [fnno], [string yes], [no], [int buttonwidth])
returns: (GroupFrame)
creates a modal popup with description label string, and two buttons for "yes" and "no".
scrollfield (int x,y,w,h)
returns: (GroupFrame)
creates and returns groupframe, which gets a vertically scroll slider if content is out of bounds. ".area" of returned frame should be used to add components to. ".area" also contains the function "scrollto(itemY,itemHeight)" with which you can set the scroll pos (if slider exists, otherwise ignored).
sldLabelval
[int] - default width for value label for addlsider
sldLabelwidth
[int] - width of description label for addslider