Skip to content

Gspot Types

trubblegum edited this page Mar 31, 2012 · 8 revisions

The following object types are used within Gspot.

Table of Contents

Gspot.element

element = {
  elementtype = string,
  label = string or nil,
  pos = Gspot.pos(pos),
  style = Gspot.style,
  parent = element reference or nil,
  children = {},
  Gspot = Gspot,
}
Gspot:element(type, label, pos, parent) returns a table which inherits from Gspot[type] (and thereby also Gspot.util), and contains a reference to the Gspot instance which created it.

When the element constructor calls Gspot:pos(pos), it will set element.shape = 'circle' if circ.

The element constructors call Gspot:add(element), which inserts the element into Gspot's element heirarchy.

See Element Functions.

Gspot.pos

pos = -pos
pos = pos + number or Gspot:pos({x = number, y = number})
pos = pos - number or Gspot:pos({x = number, y = number})
pos = pos * number or Gspot:pos({x = number, y = number})
pos = pos / number or Gspot:pos({x = number, y = number})
pos = pos ^ number or Gspot:pos({x = number, y = number})
Gspot:pos(nil or {} or {number, number, number, number}, or {number, number, number}) returns a table which inherits from Gspot.pos_mt.

Gspot:pos() also accepts a table with an incomplete set of named ordinals (x, y, w, h, r), or a table containing a pos index to be copied, and returns a fully-formed pos type in either case, with missing x, y values initialized to 0 and missing w, hGspot.style.unit.

If a table is supplied as argument, and t.r is specified, or exactly three ordered values are present, it is assumed that a circle is desired, w, h will be set to r * 2, and Gspot:pos() returns true as a second value.

Operators return a new Gspot.pos.

element:getpos() returns the element's absolute position

element.style

element.color = {
  unit = number,
  font = love.font,
  fg = color,
  bg = color,
  default = color,
  hilite = color,
  focus = color,
}
element.style inherits from element.parent.style or Gspot.style

Gspot.scollvalues

scroll.values = {
  min = number,
  max = number,
  current = number,
  step = number
}
Not strictly a datatype, Gspot:scrollvalues({number, number, number, number}) returns a set of values formatted for use by a scrollbar.