Module vn.gui

gui.lua User-interface related classes and functions

Functions

alignAnchorX (outer, inner, anchor) Returns the correct X offset for a component with width inner given the width outer of its desired container.
alignAnchorY (outer, inner, anchor) Returns the correct Y offset for a component with height inner given the height outer of its desired container.
createFlowLayout (overrides) Creates a new FlowLayout object.
createGridLayout (overrides) Creates a new GridLayout object.
createLayoutComponent (x, y, w, h) Creates an implementation of ILayoutComponent for use in ILayout objects like the FlowLayout and GridLayout.
createPanel (w, h) Creates a new panel
createViewport (w, h) Creates a new viewport
doLayout (layout, x, y, w, h, overrides, components) Creates a layout object and uses it to layout the given components.
toLayoutComponent (c) Creates a layout component from the given userdata or table.
transferBounds (lc, c) Sets the bounds of c to lc.


Functions

alignAnchorX (outer, inner, anchor)
Returns the correct X offset for a component with width inner given the width outer of its desired container.

Parameters:

  • outer: Width of the container
  • inner: Width of the component inside the container
  • anchor: Alignment of the component within the container. These correspond to numpad directions (4=left, 5=center, 6=right).

Return value:

    The correct X offset for the inner component
alignAnchorY (outer, inner, anchor)
Returns the correct Y offset for a component with height inner given the height outer of its desired container.

Parameters:

  • outer: Height of the container
  • inner: Height of the component inside the container
  • anchor: Alignment of the component within the container. These correspond to numpad directions (8=top, 5=center, 2=bottom).

Return value:

    The correct Y offset for the inner component
createFlowLayout (overrides)
Creates a new FlowLayout object.

Parameters:

  • overrides: An optional table containing default values for the new layout's properties.
createGridLayout (overrides)
Creates a new GridLayout object.

Parameters:

  • overrides: An optional table containing default values for the new layout's properties.
createLayoutComponent (x, y, w, h)
Creates an implementation of ILayoutComponent for use in ILayout objects like the FlowLayout and GridLayout.

Parameters:

  • x: The top-left x coordinate for the component.
  • y: The top-left y coordinate for the component.
  • w: The width of the component.
  • h: The height of the component.
createPanel (w, h)
Creates a new panel

Parameters:

  • w: Optional initial width for the panel.
  • h: Optional initial height for the panel.

Return value:

    The newly created panel.
createViewport (w, h)
Creates a new viewport

Parameters:

  • w: Optional initial width for the viewport.
  • h: Optional initial height for the viewport.

Return value:

    The newly created viewport.
doLayout (layout, x, y, w, h, overrides, components)
Creates a layout object and uses it to layout the given components. This function can layout any object which implements getBounds/setBounds functions, not just drawables.

Parameters:

  • layout: The layout object, or a table containing a new function that can be used to create a new layout object like FlowLayout and GridLayout.
  • x: The top-left x coordinate of the layout bounds.
  • y: The top-left y coordinate of the layout bounds.
  • w: The width of the layout bounds.
  • h: The height of the layout bounds.
  • overrides: An optional table containing property overrides for the layout.
  • components: The things to layout, must implement getBounds/setBounds functions.
toLayoutComponent (c)
Creates a layout component from the given userdata or table. The initial bounds for the component are the values returned from a call c:getBounds().

Parameters:

  • c: The Lua userdata or table to initialize the layout component with.
transferBounds (lc, c)
Sets the bounds of c to lc.

Parameters:

  • lc: The object containing the source bounds.
  • c: The destination object to update the bounds of.

Valid XHTML 1.0!