Gspot-Types
Pedro Gimeno edited this page 5 years ago

The following object types are used within Gspot.

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

element.pos, circ = {
  x = number,
  y = number,
  w = number,
  h = number,
  r = number,
}

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, h to Gspot.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.style = {
  unit = number,
  font = love.font,
  fg = color,
  bg = color,
  labelfg = color,
  default = color,
  hilite = color,
  focus = color,
  hs = number or 'auto', -- handle size, only used in scrollbars
}

element.style inherits from element.parent.style or Gspot.style

Gspot.scrollvalues

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.