Module pop

The Pop.Box GUI itself.

Info:

  • Copyright: Paul Liverman III (2015-2016)
  • Release: v0.0.0
  • License: The MIT License (MIT)

Functions

load () Loads elements, skins, extensions, and initializes pop.screen.
create (element, parent) Creates an element.
update (dt, element) Event handler for love.update().
draw (element) Event handler for love.draw().
mousemoved (x, y, dx, dy) Event handler for love.mousemoved().
mousepressed (x, y, button, element) Event handler for love.mousepressed().
mousereleased (x, y, button, element) Event handler for love.mousereleased().
keypressed (key) Event handler for love.keypressed().
keyreleased (key) Event handler for love.keyreleased().
textinput (text) Event handler for love.textinput().
skin (element, skin, depth) Applies skins to elements.
debugDraw (element) Draws simple rectangle outlines to debug placement of elements.
printElementTree (element) Prints a basic structure of GUI elements with minimal info.

Tables

pop

Issues

pop-todo1 Find out what happens if someone requires the init.lua / init.moon file instead of the directory, add an error message for this.
load-todo2 Determine if extensions should have a reference saved (and the possibility of a load function?) require into pop.extensions by filename
mousemoved-todo3 Implement a way for an element to attach itself to love.mousemoved() events?
mousereleased-todo4 Figure out how to bring a focused element to the front of view (aka the first element in its parent's children). (If I do it right here, the for loop above may break! I need to test/figure this out.) NOTE this might cause an error in the above for loop! basically, move focused element to front of its parent's child element.parent\focusChild element table.insert element.parent, element.parent\removeChild(element),


Functions

load ()
Loads elements, skins, extensions, and initializes pop.screen. IMPORTANT: Intended to only be called once, and is automatically called when you require Pop.Box.

See also:

create (element, parent)
Creates an element.

Parameters:

  • element A string naming the element class to use.
  • parent Optional The parent element. If false, an element is created with no parent. If nil, defaults to pop.screen. (Note: An element with no parent will not be handled by Pop.Box's event handlers unless you handle it explicitly.)

See also:

update (dt, element)
Event handler for love.update().

Parameters:

  • dt The amount of time passed since the last call to update, in seconds.
  • element Optional The element to update. Defaults to pop.screen (and loops through all its children).
draw (element)
Event handler for love.draw().

Parameters:

  • element Optional The element to draw. Defaults to pop.screen (and loops through all its children).
mousemoved (x, y, dx, dy)
Event handler for love.mousemoved(). (*LÖVE >= 0.10.0*)

Parameters:

  • x The x coordinate of the mouse.
  • y The y coordinate of the mouse.
  • dx The distance on the x axis the mouse was moved.
  • dy The distance on the y axis the mouse was moved.

Returns:

    true / false: Was the event handled?
mousepressed (x, y, button, element)
Event handler for love.mousepressed().

Parameters:

  • x The x coordinate of the mouse press.
  • y The y coordinate of the mouse press.
  • button The mouse button pressed.
  • element Optional The element to check for event handling. Defaults to pop.screen (and loops through all its children).

Returns:

    true / false: Was the event handled?
mousereleased (x, y, button, element)
Event handler for love.mousereleased().

Parameters:

  • x The x coordinate of the mouse release.
  • y The y coordinate of the mouse release.
  • button The mouse button released.
  • element Optional The element to check for event handling. Defaults to pop.screen (and loops through all its children).

Returns:

  1. true / false: Was a click handled?
  2. true / false: Was a mouse release handled?
keypressed (key)
Event handler for love.keypressed().

Parameters:

  • key The key that was pressed.

Returns:

    true / false: Was the event handled?
keyreleased (key)
Event handler for love.keyreleased().

Parameters:

  • key The key that was released.

Returns:

    true / false: Was the event handled?
textinput (text)
Event handler for love.textinput().

Parameters:

  • text The text that was typed.

Returns:

    true / false: Was the text input handled?
skin (element, skin, depth)
Applies skins to elements. (*NOTE^: This function will be rewritten and change at some point...)

Parameters:

  • element The element to skin. Defaults to pop.screen (and loops through all its children).
  • skin The skin to use, can be a string or an actual skin object, defaults to a default skin that is part of Pop.Box.
  • depth Can be an integer for how many levels to go skinning. Alternately, if true, will skin all children.
debugDraw (element)
Draws simple rectangle outlines to debug placement of elements.

Parameters:

  • element The element to draw. Defaults to pop.screen (and loops through all its children).
printElementTree (element)
Prints a basic structure of GUI elements with minimal info.

Parameters:

  • element The element to start at. Defaults to pop.screen (and loops through all its children).

Tables

pop

Fields:

  • elements All GUI classes are stored here.
  • skins All skins are stored here.
  • screen The top level GUI element. Represents the game screen. Initialized in pop.load()
  • focused The currently focused GUI element (or false if none is focused).

See also:

Issues

pop-todo1
Find out what happens if someone requires the init.lua / init.moon file instead of the directory, add an error message for this.
load-todo2
Determine if extensions should have a reference saved (and the possibility of a load function?) require into pop.extensions by filename
mousemoved-todo3
Implement a way for an element to attach itself to love.mousemoved() events?
mousereleased-todo4
Figure out how to bring a focused element to the front of view (aka the first element in its parent's children). (If I do it right here, the for loop above may break! I need to test/figure this out.) NOTE this might cause an error in the above for loop! basically, move focused element to front of its parent's child element.parent\focusChild element table.insert element.parent, element.parent\removeChild(element),
generated by LDoc 1.4.3 Last updated 2016-06-21 12:31:16