mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-10-18 08:14:17 +00:00
parent
028bc423a0
commit
2ba0839ed8
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
lua51.dll
|
||||
moon*.exe
|
||||
moonscript.dll
|
||||
spec/*.lua
|
||||
|
@ -1,11 +1,11 @@
|
||||
file = {
|
||||
"init.moon",
|
||||
"main.moon",
|
||||
--"main.moon",
|
||||
"util.moon",
|
||||
}
|
||||
|
||||
project = "Pop.Box()"
|
||||
description = "GUI library for [LOVE](https://love2d.org/), designed for ease of use"
|
||||
description = "GUI library for [LÖVE](https://love2d.org/), designed for ease of use"
|
||||
title = "Documentation"
|
||||
--package = "pop" --has to be same name as source directory
|
||||
format = "markdown"
|
||||
|
@ -32,7 +32,6 @@
|
||||
<h2>Modules</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
<li><a href="modules/pop.html">pop</a></li>
|
||||
<li><a href="modules/main.html">main</a></li>
|
||||
<li><a href="modules/util.html">util</a></li>
|
||||
</ul>
|
||||
|
||||
@ -41,7 +40,7 @@
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h2>GUI library for <a href="https://love2d.org/">LOVE</a>, designed for ease of use</h2>
|
||||
<h2>GUI library for <a href="https://love2d.org/">LÖVE</a>, designed for ease of use</h2>
|
||||
|
||||
<h2>Modules</h2>
|
||||
<table class="module_list">
|
||||
@ -49,10 +48,6 @@
|
||||
<td class="name" nowrap><a href="modules/pop.html">pop</a></td>
|
||||
<td class="summary">The Pop.Box GUI itself.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/main.html">main</a></td>
|
||||
<td class="summary">A demo program for Pop.Box.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/util.html">util</a></td>
|
||||
<td class="summary">Utility functions, intended for internal use only.</td>
|
||||
@ -63,7 +58,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
|
||||
<i style="float:right;">Last updated 2016-08-02 16:30:36 </i>
|
||||
<i style="float:right;">Last updated 2016-08-20 21:29:17 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -30,10 +30,6 @@
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
@ -59,47 +55,18 @@
|
||||
</ul>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#pop">pop ()</a></td>
|
||||
<td class="summary">
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "pop"></a>
|
||||
<strong>pop ()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
|
||||
<i style="float:right;">Last updated 2016-08-02 16:30:36 </i>
|
||||
<i style="float:right;">Last updated 2016-08-20 19:46:37 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -34,14 +34,12 @@
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
<li><a href="#Tables">Tables</a></li>
|
||||
<li><a href="#Issues">Issues</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
<li><strong>pop</strong></li>
|
||||
<li><a href="../modules/main.html">main</a></li>
|
||||
<li><a href="../modules/util.html">util</a></li>
|
||||
</ul>
|
||||
|
||||
@ -69,7 +67,7 @@
|
||||
<td class="summary">Loads elements, skins, extensions, and initializes <code>pop.screen</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#create">create (element, parent)</a></td>
|
||||
<td class="name" nowrap><a href="#create">create (element, parent, ...)</a></td>
|
||||
<td class="summary">Creates an element.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -126,27 +124,6 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Issues">Issues</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#load-todo1">load-todo1</a></td>
|
||||
<td class="summary">Determine if extensions should have a reference saved (and the possibility of a load function?)
|
||||
require into pop.extensions by filename</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#mousemoved-todo2">mousemoved-todo2</a></td>
|
||||
<td class="summary">Implement a way for an element to attach itself to <code>love.mousemoved()</code> events?</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#mousereleased-todo3">mousereleased-todo3</a></td>
|
||||
<td class="summary"> 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),</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
@ -160,7 +137,9 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
<strong>load ()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Loads elements, skins, extensions, and initializes <code>pop.screen</code>. <strong>IMPORTANT</strong>: Intended to only be called once, and is automatically called when you require Pop.Box.
|
||||
Loads elements, skins, extensions, and initializes <code>pop.screen</code>. </p>
|
||||
|
||||
<p> <strong>IMPORTANT</strong>: Intended to only be called once, and is automatically called when you require Pop.Box.
|
||||
|
||||
|
||||
|
||||
@ -175,7 +154,7 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "create"></a>
|
||||
<strong>create (element, parent)</strong>
|
||||
<strong>create (element, parent, ...)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Creates an element.
|
||||
@ -187,8 +166,12 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
A string naming the element class to use.
|
||||
</li>
|
||||
<li><span class="parameter">parent</span>
|
||||
<em>Optional</em> The parent element. If <code>false</code>, an element is created with no parent. If <code>nil</code>, defaults to <code>pop.screen</code>.
|
||||
(<strong>Note</strong>: An element with no parent will not be handled by Pop.Box's event handlers unless you handle it explicitly.)
|
||||
[opt] The parent element. If <code>false</code>, an element is created with no parent. If <code>nil</code>, defaults to <code>pop.screen</code>.
|
||||
</li>
|
||||
<li><span class="parameter">...</span>
|
||||
[opt] Any number of parameters can be passed to the constructor for the element.</p>
|
||||
|
||||
<p> (<strong>Note</strong>: An element with no parent will not be handled by Pop.Box's event handlers unless you handle it explicitly.)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -215,7 +198,7 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
The amount of time passed since the last call to update, in seconds.
|
||||
</li>
|
||||
<li><span class="parameter">element</span>
|
||||
<em>Optional</em> The element to update. Defaults to <code>pop.screen</code> (and loops through all its children).
|
||||
[opt] The element to update (will update all its children as well). Defaults to <code>pop.screen</code>.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -235,7 +218,7 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">element</span>
|
||||
<em>Optional</em> The element to draw. Defaults to <code>pop.screen</code> (and loops through all its children).
|
||||
[opt] The element to draw (will draw all its children as well). Defaults to <code>pop.screen</code>.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -298,7 +281,7 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
The mouse button pressed.
|
||||
</li>
|
||||
<li><span class="parameter">element</span>
|
||||
<em>Optional</em> The element to check for event handling. Defaults to <code>pop.screen</code> (and loops through all its children).
|
||||
[opt] The element to check for event handling (will check its children as well). Defaults to <code>pop.screen</code>.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -332,7 +315,7 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
The mouse button released.
|
||||
</li>
|
||||
<li><span class="parameter">element</span>
|
||||
<em>Optional</em> The element to check for event handling. Defaults to <code>pop.screen</code> (and loops through all its children).
|
||||
[opt] The element to check for event handling (will check its children as well). Defaults to <code>pop.screen</code>.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -428,19 +411,19 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
<strong>skin (element, skin, depth)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Applies skins to elements. (<em>*NOTE^</em>: This function will be rewritten and change at some point...)
|
||||
Applies skins to elements. (<strong>NOTE</strong>: This function will be rewritten and change at some point...)
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">element</span>
|
||||
The element to skin. Defaults to <code>pop.screen</code> (and loops through all its children).
|
||||
The element to skin (will also be applied to children). Defaults to <code>pop.screen</code>.
|
||||
</li>
|
||||
<li><span class="parameter">skin</span>
|
||||
The skin to use, can be a string or an actual skin object, defaults to a default skin that is part of Pop.Box.
|
||||
The skin to use, can be a string or an actual skin object, defaults to the default skin included with Pop.Box.
|
||||
</li>
|
||||
<li><span class="parameter">depth</span>
|
||||
Can be an integer for how many levels to go skinning. Alternately, if <code>true</code>, will skin all children.
|
||||
[opt] An integer for how many child levels to skin, OR, if <code>true</code>, will skin all children.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -460,7 +443,7 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">element</span>
|
||||
The element to draw. Defaults to <code>pop.screen</code> (and loops through all its children).
|
||||
The element to draw (will draw its children as well). Defaults to <code>pop.screen</code>.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -480,7 +463,7 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">element</span>
|
||||
The element to start at. Defaults to <code>pop.screen</code> (and loops through all its children).
|
||||
The element to start at. Defaults to <code>pop.screen</code>.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -511,11 +494,14 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
<li><span class="parameter">skins</span>
|
||||
All skins are stored here.
|
||||
</li>
|
||||
<li><span class="parameter">extensions</span>
|
||||
All extensions are loaded here.
|
||||
</li>
|
||||
<li><span class="parameter">screen</span>
|
||||
The top level GUI element. Represents the game screen. Initialized in <code>pop.load()</code>
|
||||
</li>
|
||||
<li><span class="parameter">focused</span>
|
||||
The currently focused GUI element (or false if none is focused).
|
||||
The currently focused GUI element (or <code>false</code> if none is focused).
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -527,58 +513,6 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
</ul>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Issues"></a>Issues</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "load-todo1"></a>
|
||||
<strong>load-todo1</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Determine if extensions should have a reference saved (and the possibility of a load function?)
|
||||
require into pop.extensions by filename
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "mousemoved-todo2"></a>
|
||||
<strong>mousemoved-todo2</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Implement a way for an element to attach itself to <code>love.mousemoved()</code> events?
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "mousereleased-todo3"></a>
|
||||
<strong>mousereleased-todo3</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
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),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
@ -587,7 +521,7 @@ table.insert element.parent, element.parent\removeChild(element),
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
|
||||
<i style="float:right;">Last updated 2016-08-02 16:30:36 </i>
|
||||
<i style="float:right;">Last updated 2016-08-20 21:29:17 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -39,7 +39,6 @@
|
||||
<h2>Modules</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
<li><a href="../modules/pop.html">pop</a></li>
|
||||
<li><a href="../modules/main.html">main</a></li>
|
||||
<li><strong>util</strong></li>
|
||||
</ul>
|
||||
|
||||
@ -55,7 +54,7 @@
|
||||
<h3>Info:</h3>
|
||||
<ul>
|
||||
<li><strong>Copyright</strong>: Paul Liverman III (2015-2016)</li>
|
||||
<li><strong>Release</strong>: v0.0.0</li>
|
||||
<li><strong>Release</strong>: 0.0.0</li>
|
||||
<li><strong>License</strong>: The MIT License (MIT)</li>
|
||||
</ul>
|
||||
|
||||
@ -113,7 +112,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
|
||||
<i style="float:right;">Last updated 2016-08-02 16:30:36 </i>
|
||||
<i style="float:right;">Last updated 2016-08-20 21:29:17 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
23
elements/element.lua
Normal file
23
elements/element.lua
Normal file
@ -0,0 +1,23 @@
|
||||
local element
|
||||
do
|
||||
local _class_0
|
||||
local _base_0 = {
|
||||
setSize = function(self) end
|
||||
}
|
||||
_base_0.__index = _base_0
|
||||
_class_0 = setmetatable({
|
||||
__init = function(self) end,
|
||||
__base = _base_0,
|
||||
__name = "element"
|
||||
}, {
|
||||
__index = _base_0,
|
||||
__call = function(cls, ...)
|
||||
local _self_0 = setmetatable({}, _base_0)
|
||||
cls.__init(_self_0, ...)
|
||||
return _self_0
|
||||
end
|
||||
})
|
||||
_base_0.__class = _class_0
|
||||
element = _class_0
|
||||
return _class_0
|
||||
end
|
12
elements/element.moon
Normal file
12
elements/element.moon
Normal file
@ -0,0 +1,12 @@
|
||||
--- A generic element every element must inherit from.
|
||||
--- @module pop
|
||||
--- @copyright Paul Liverman III (2016)
|
||||
--- @license The MIT License (MIT)
|
||||
--- @release 0.0.0
|
||||
|
||||
class element
|
||||
new: =>
|
||||
--do stuff
|
||||
|
||||
setSize: =>
|
||||
--do more stuff!
|
17
init.lua
17
init.lua
@ -8,10 +8,13 @@ local pop = {
|
||||
if not (love.getVersion) then
|
||||
error("Pop.Box only supports LOVE versions >= 0.9.1")
|
||||
end
|
||||
if (...):sub(-4) == "init" then
|
||||
error("Pop.Box must be required by its containing folder")
|
||||
end
|
||||
local path = ...
|
||||
if (...):sub(-4) == "init" then
|
||||
path = (...):sub(1, -5)
|
||||
if not (path) then
|
||||
path = "."
|
||||
end
|
||||
end
|
||||
local filesystem, graphics
|
||||
do
|
||||
local _obj_0 = love
|
||||
@ -23,6 +26,7 @@ local inheritsFromElement
|
||||
inheritsFromElement = require(tostring(path) .. "/util").inheritsFromElement
|
||||
pop.elements = { }
|
||||
pop.skins = { }
|
||||
pop.extensions = { }
|
||||
pop.screen = false
|
||||
pop.focused = false
|
||||
pop.load = function()
|
||||
@ -85,7 +89,10 @@ pop.load = function()
|
||||
break
|
||||
end
|
||||
local name = extensions[i]:sub(1, -5)
|
||||
require(tostring(path) .. "/extensions/" .. tostring(name))
|
||||
pop.extensions[name] = require(tostring(path) .. "/extensions/" .. tostring(name))
|
||||
if pop.extensions[name].load then
|
||||
pop.extensions[name].load(pop)
|
||||
end
|
||||
print("extension loaded: \"" .. tostring(name) .. "\"")
|
||||
_continue_0 = true
|
||||
until true
|
||||
@ -249,7 +256,7 @@ pop.skin = function(element, skin, depth)
|
||||
end
|
||||
else
|
||||
for i = 1, #element.child do
|
||||
pop.skin(element.child[i], skin, false)
|
||||
pop.skin(element.child[i], skin, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
71
init.moon
71
init.moon
@ -15,11 +15,13 @@ pop = {
|
||||
unless love.getVersion
|
||||
error "Pop.Box only supports LOVE versions >= 0.9.1"
|
||||
|
||||
if (...)\sub(-4) == "init"
|
||||
error "Pop.Box must be required by its containing folder"
|
||||
|
||||
path = ...
|
||||
|
||||
if (...)\sub(-4) == "init"
|
||||
path = (...)\sub 1, -5
|
||||
unless path
|
||||
path = "."
|
||||
|
||||
import filesystem, graphics from love
|
||||
import insert from table
|
||||
import inheritsFromElement from require "#{path}/util"
|
||||
@ -27,25 +29,29 @@ import inheritsFromElement from require "#{path}/util"
|
||||
--- @table pop
|
||||
--- @field elements All GUI classes are stored here.
|
||||
--- @field skins All skins are stored here.
|
||||
--- @field extensions All extensions are loaded here.
|
||||
--- @field screen The top level GUI element. Represents the game screen. Initialized in `pop.load()`
|
||||
--- @see pop.load
|
||||
--- @field focused The currently focused GUI element (or false if none is focused).
|
||||
--- @field focused The currently focused GUI element (or `false` if none is focused).
|
||||
|
||||
pop.elements = {}
|
||||
pop.skins = {}
|
||||
pop.extensions = {}
|
||||
pop.screen = false
|
||||
pop.focused = false
|
||||
|
||||
|
||||
|
||||
--- Loads elements, skins, extensions, and initializes `pop.screen`. **IMPORTANT**: Intended to only be called once, and is automatically called when you require Pop.Box.
|
||||
--- Loads elements, skins, extensions, and initializes `pop.screen`.
|
||||
---
|
||||
--- **IMPORTANT**: Intended to only be called once, and is automatically called when you require Pop.Box.
|
||||
--- @function load
|
||||
--- @see pop
|
||||
--- @todo @see Elements
|
||||
--- @todo @see Skins
|
||||
--- @todo @see Extensions
|
||||
|
||||
pop.load = ->
|
||||
--@todo @ see Elements
|
||||
--@todo @ see Skins
|
||||
--@todo @ see Extensions
|
||||
elements = filesystem.getDirectoryItems "#{path}/elements"
|
||||
for i = 1, #elements
|
||||
-- ignore non-Lua files
|
||||
@ -96,10 +102,13 @@ pop.load = ->
|
||||
unless extensions[i]\sub(-4) == ".lua"
|
||||
continue
|
||||
|
||||
--- @todo Determine if extensions should have a reference saved (and the possibility of a load function?)
|
||||
-- require into pop.extensions by filename
|
||||
name = extensions[i]\sub 1, -5
|
||||
require "#{path}/extensions/#{name}"
|
||||
pop.extensions[name] = require "#{path}/extensions/#{name}"
|
||||
|
||||
-- call the extension's load function if it exists
|
||||
if pop.extensions[name].load
|
||||
pop.extensions[name].load pop
|
||||
|
||||
print "extension loaded: \"#{name}\""
|
||||
|
||||
@ -113,12 +122,14 @@ pop.load = ->
|
||||
--- Creates an element.
|
||||
--- @function create
|
||||
--- @param element A string naming the element class to use.
|
||||
--- @param parent *Optional* The parent element. If `false`, an element is created with no parent. If `nil`, defaults to `pop.screen`.
|
||||
--- @param parent[opt] The parent element. If `false`, an element is created with no parent. If `nil`, defaults to `pop.screen`.
|
||||
--- @param ...[opt] Any number of parameters can be passed to the constructor for the element.
|
||||
---
|
||||
--- (**Note**: An element with no parent will not be handled by Pop.Box's event handlers unless you handle it explicitly.)
|
||||
--- @see pop
|
||||
--- @todo @see Elements
|
||||
|
||||
pop.create = (element, parent=pop.screen, ...) ->
|
||||
--@todo @ see Elements
|
||||
-- if valid parent element, use it
|
||||
if inheritsFromElement parent
|
||||
element = pop.elements[element](parent, ...)
|
||||
@ -140,10 +151,10 @@ pop.create = (element, parent=pop.screen, ...) ->
|
||||
--- Event handler for `love.update()`.
|
||||
--- @function update
|
||||
--- @param dt The amount of time passed since the last call to update, in seconds.
|
||||
--- @param element *Optional* The element to update. Defaults to `pop.screen` (and loops through all its children).
|
||||
--- @todo Define Elements and @see that documentation from here. Generic documentation, not specifically element!
|
||||
--- @param element[opt] The element to update (will update all its children as well). Defaults to `pop.screen`.
|
||||
|
||||
pop.update = (dt, element=pop.screen) ->
|
||||
--@todo Define Elements and @ see that documentation from here. Generic documentation, not specifically element!
|
||||
-- data.update boolean controls an element and its children being updated
|
||||
if element.data.update
|
||||
if element.update
|
||||
@ -155,10 +166,10 @@ pop.update = (dt, element=pop.screen) ->
|
||||
|
||||
--- Event handler for `love.draw()`.
|
||||
--- @function draw
|
||||
--- @param element *Optional* The element to draw. Defaults to `pop.screen` (and loops through all its children).
|
||||
--- @todo @see Elements
|
||||
--- @param element[opt] The element to draw (will draw all its children as well). Defaults to `pop.screen`.
|
||||
|
||||
pop.draw = (element=pop.screen) ->
|
||||
--@todo @ see Elements
|
||||
-- data.draw boolean controls an element and its children being drawn
|
||||
if element.data.draw
|
||||
if element.draw
|
||||
@ -176,8 +187,8 @@ pop.draw = (element=pop.screen) ->
|
||||
--- @param dy The distance on the y axis the mouse was moved.
|
||||
--- @return `true` / `false`: Was the event handled?
|
||||
|
||||
--- @todo Implement a way for an element to attach itself to `love.mousemoved()` events?
|
||||
pop.mousemoved = (x, y, dx, dy) ->
|
||||
--@todo Implement a way for an element to attach itself to `love.mousemoved()` events?
|
||||
if pop.focused and pop.focused.mousemoved
|
||||
return pop.focused\mousemoved x, y, dx, dy
|
||||
|
||||
@ -190,7 +201,7 @@ pop.mousemoved = (x, y, dx, dy) ->
|
||||
--- @param x The x coordinate of the mouse press.
|
||||
--- @param y The y coordinate of the mouse press.
|
||||
--- @param button The mouse button pressed.
|
||||
--- @param element *Optional* The element to check for event handling. Defaults to `pop.screen` (and loops through all its children).
|
||||
--- @param element[opt] The element to check for event handling (will check its children as well). Defaults to `pop.screen`.
|
||||
--- @return `true` / `false`: Was the event handled?
|
||||
|
||||
pop.mousepressed = (x, y, button, element) ->
|
||||
@ -226,7 +237,7 @@ pop.mousepressed = (x, y, button, element) ->
|
||||
--- @param x The x coordinate of the mouse release.
|
||||
--- @param y The y coordinate of the mouse release.
|
||||
--- @param button The mouse button released.
|
||||
--- @param element *Optional* The element to check for event handling. Defaults to `pop.screen` (and loops through all its children).
|
||||
--- @param element[opt] The element to check for event handling (will check its children as well). Defaults to `pop.screen`.
|
||||
--- @return `true` / `false`: Was a click handled?
|
||||
--- @return `true` / `false`: Was a mouse release handled?
|
||||
|
||||
@ -255,7 +266,7 @@ pop.mousereleased = (x, y, button, element) ->
|
||||
-- if we clicked, we're focused!
|
||||
if clickedHandled
|
||||
pop.focused = element
|
||||
--- @todo Figure out how to bring a focused element to the front of view (aka the first element in its parent's children).
|
||||
--@todo 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
|
||||
@ -322,12 +333,11 @@ pop.textinput = (text) ->
|
||||
|
||||
|
||||
|
||||
--- Applies skins to elements. (**NOTE^*: This function will be rewritten and change at some point...)
|
||||
--- Applies skins to elements. (**NOTE**: This function will be rewritten and change at some point...)
|
||||
--- @function skin
|
||||
--- @param element The element to skin. Defaults to `pop.screen` (and loops through all its children).
|
||||
--- @param 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.
|
||||
--- @param depth Can be an integer for how many levels to go skinning. Alternately, if `true`, will skin all children.
|
||||
--- @todo Rewrite the skin function taking advantage of data block / whatever else is needed.
|
||||
--- @param element The element to skin (will also be applied to children). Defaults to `pop.screen`.
|
||||
--- @param skin The skin to use, can be a string or an actual skin object, defaults to the default skin included with Pop.Box.
|
||||
--- @param depth[opt] An integer for how many child levels to skin, OR, if `true`, will skin all children.
|
||||
|
||||
--TODO rewrite skin system to not rely on knowing internals of elements,
|
||||
-- instead call functions like setColor and setBackground
|
||||
@ -335,6 +345,7 @@ pop.textinput = (text) ->
|
||||
-- depth can be an integer for how many levels to go down when skinning
|
||||
-- defaults to pop.screen and the default skin
|
||||
pop.skin = (element=pop.screen, skin=pop.skins.default, depth) ->
|
||||
--@todo Rewrite the skin function taking advantage of data block / whatever else is needed.
|
||||
if element.background and skin.background
|
||||
element.background = skin.background
|
||||
if element.color and skin.color
|
||||
@ -348,16 +359,16 @@ pop.skin = (element=pop.screen, skin=pop.skins.default, depth) ->
|
||||
pop.skin element.child[i], skin, depth - 1
|
||||
else
|
||||
for i = 1, #element.child
|
||||
pop.skin element.child[i], skin, false
|
||||
pop.skin element.child[i], skin, true
|
||||
|
||||
|
||||
|
||||
--- Draws simple rectangle outlines to debug placement of elements.
|
||||
--- @function debugDraw
|
||||
--- @param element The element to draw. Defaults to `pop.screen` (and loops through all its children).
|
||||
--- @todo Make this better in the future when different element types have been created and whatnot.
|
||||
--- @param element The element to draw (will draw its children as well). Defaults to `pop.screen`.
|
||||
|
||||
pop.debugDraw = (element=pop.screen) ->
|
||||
--@todo Make this better in the future when different element types have been created and whatnot.
|
||||
if element.debugDraw
|
||||
element\debugDraw!
|
||||
else
|
||||
@ -376,10 +387,10 @@ pop.debugDraw = (element=pop.screen) ->
|
||||
|
||||
--- Prints a basic structure of GUI elements with minimal info.
|
||||
--- @function printElementTree
|
||||
--- @param element The element to start at. Defaults to `pop.screen` (and loops through all its children).
|
||||
--- @todo Correct this once elements are reimplemented if it needs correction.
|
||||
--- @param element The element to start at. Defaults to `pop.screen`.
|
||||
|
||||
pop.printElementTree = (element=pop.screen, depth=0) ->
|
||||
--@todo Correct this once elements are reimplemented if it needs correction.
|
||||
cls = element.__class.__name
|
||||
|
||||
if cls == "text"
|
||||
|
2
main.lua
2
main.lua
@ -1,2 +1,2 @@
|
||||
local pop = require("init")
|
||||
local pop = require("")
|
||||
return print(pop, pop.elements)
|
||||
|
@ -2,8 +2,7 @@
|
||||
--- @copyright Paul Liverman III (2016)
|
||||
--- @license The MIT License (MIT)
|
||||
|
||||
pop = require ""
|
||||
--- @todo write this!
|
||||
|
||||
pop = require "init"
|
||||
|
||||
print(pop, pop.elements)
|
||||
print(pop, pop.elements) --NOTE TEMPORARY
|
||||
|
22
spec/love.moon
Normal file
22
spec/love.moon
Normal file
@ -0,0 +1,22 @@
|
||||
lfs = require "lfs"
|
||||
|
||||
return {
|
||||
getVersion: ->
|
||||
0, 10, 1, "Super Toast"
|
||||
filesystem:
|
||||
getDirectoryItems: (path) ->
|
||||
ok, results = pcall ->
|
||||
results = {}
|
||||
for file in lfs.dir lfs.currentdir! .. "/" .. path
|
||||
table.insert results, file
|
||||
return results
|
||||
if ok
|
||||
return results
|
||||
else
|
||||
return {}
|
||||
graphics:
|
||||
getWidth: ->
|
||||
return 1280
|
||||
getHeight: ->
|
||||
return 720
|
||||
}
|
75
spec/pop_spec.moon
Normal file
75
spec/pop_spec.moon
Normal file
@ -0,0 +1,75 @@
|
||||
lfs = require "lfs"
|
||||
|
||||
expose "fake LOVE 0.10.1", ->
|
||||
|
||||
_G.love = require "spec/love"
|
||||
|
||||
describe "Pop.Box", ->
|
||||
|
||||
--it "errors when require'd wrong", ->
|
||||
-- assert.error -> require "init"
|
||||
|
||||
it "can be required by 'init'", ->
|
||||
assert.has_no.errors -> require "init"
|
||||
|
||||
pending "errors if you use LOVE < 0.9.1", ->
|
||||
|
||||
describe "pop.load", ->
|
||||
|
||||
pending "loads all elements", ->
|
||||
-- check they are in elements[name]
|
||||
-- check specifics if able have used their load functions
|
||||
-- if able, check that custom wraps have been called
|
||||
|
||||
pending "loads all skins", ->
|
||||
-- see checks for loading all elements
|
||||
|
||||
pending "loads all extensions", ->
|
||||
-- see checks for loading all elements
|
||||
|
||||
pending "creates an element the size of the game window", ->
|
||||
-- use our shim's width/height, check the size of the element, check that it actually is an element class object, make sure it is stored in pop.screen
|
||||
|
||||
pending "check inherit checker", ->
|
||||
|
||||
describe "pop.create", ->
|
||||
-- these need to check parent/child relations and data relations
|
||||
pending "creates elements with pop.screen by default", ->
|
||||
pending "creates elements with no parent when you pass false", ->
|
||||
pending "creates elements with specified parent when passed an element", ->
|
||||
|
||||
describe "pop.update", ->
|
||||
pending "only updates when data.update is truthy", ->
|
||||
pending "updates all children", ->
|
||||
|
||||
describe "pop.draw", ->
|
||||
pending "draws elements only when data.draw is truthy", ->
|
||||
pending "draws all children", ->
|
||||
|
||||
describe "pop.mousemoved", ->
|
||||
pending "handles mousemoved events on a focused element", ->
|
||||
--idk exactly how to make a unit test for this...
|
||||
|
||||
describe "pop.mousepressed", ->
|
||||
pending "idk", ->
|
||||
|
||||
describe "pop.mousereleased", ->
|
||||
|
||||
describe "click handling", ->
|
||||
|
||||
describe "mouserelease handling", ->
|
||||
|
||||
describe "pop.keypressed", ->
|
||||
pending "idk", ->
|
||||
|
||||
describe "pop.keyreleased", ->
|
||||
pending "idk", ->
|
||||
|
||||
describe "pop.textinput", ->
|
||||
pending "idk", ->
|
||||
|
||||
describe "pop.debugDraw", ->
|
||||
pending "idk", ->
|
||||
|
||||
describe "pop.printElementTree", ->
|
||||
pending "idk", ->
|
@ -2,7 +2,7 @@
|
||||
--- @module util
|
||||
--- @copyright Paul Liverman III (2015-2016)
|
||||
--- @license The MIT License (MIT)
|
||||
--- @release v0.0.0
|
||||
--- @release 0.0.0
|
||||
|
||||
--- @function inheritsFromElement
|
||||
--- @param object A table (MoonScript object expected) to be checked for inheritence from the "element" element.
|
||||
|
Loading…
Reference in New Issue
Block a user