Better prepared for usage

- added modified debugDraw to element class
- made window element properly inherit from element class
- fixed path detection on initialization
- added better logging and more logging to initialization
- fixed stupid bug with pop.debugDraw
This commit is contained in:
Paul Liverman III 2016-10-30 22:19:24 -07:00
parent fda0a340c9
commit bb2cbba024
12 changed files with 141 additions and 36 deletions

View File

@ -71,6 +71,10 @@
<td class="summary">Constructor expects nothing, or a data table describing it.</td> <td class="summary">Constructor expects nothing, or a data table describing it.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#element.debugDraw">element.debugDraw (self)</a></td>
<td class="summary">Slightly modified from pop.debugDraw</td>
</tr>
<tr>
<td class="name" nowrap><a href="#element.setSize">element.setSize (w, h)</a></td> <td class="name" nowrap><a href="#element.setSize">element.setSize (w, h)</a></td>
<td class="summary">Sets an element's width/height.</td> <td class="summary">Sets an element's width/height.</td>
</tr> </tr>
@ -133,6 +137,32 @@
</dd>
<dt>
<a name = "element.debugDraw"></a>
<strong>element.debugDraw (self)</strong>
</dt>
<dd>
Slightly modified from pop.debugDraw
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
</li>
</ul>
<h3>See also:</h3>
<ul>
<a href="../modules/pop.html#debugDraw">pop.debugDraw</a>
</ul>
</dd> </dd>
<dt> <dt>
<a name = "element.setSize"></a> <a name = "element.setSize"></a>
@ -313,7 +343,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2016-09-07 21:37:53 </i> <i style="float:right;">Last updated 2016-10-30 22:18:17 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -79,7 +79,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2016-09-07 21:37:53 </i> <i style="float:right;">Last updated 2016-10-30 22:18:17 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -490,7 +490,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2016-09-07 21:37:53 </i> <i style="float:right;">Last updated 2016-10-30 22:18:17 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -71,7 +71,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2016-09-07 21:37:53 </i> <i style="float:right;">Last updated 2016-10-30 22:18:17 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -665,7 +665,7 @@ table.insert element.parent, element.parent\removeChild(element),
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2016-09-07 21:37:53 </i> <i style="float:right;">Last updated 2016-10-30 22:18:17 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -125,7 +125,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2016-09-07 21:37:53 </i> <i style="float:right;">Last updated 2016-10-30 22:18:17 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -1,7 +1,18 @@
local graphics
graphics = love.graphics
local element local element
do do
local _class_0 local _class_0
local _base_0 = { local _base_0 = {
debugDraw = function(self)
graphics.setLineWidth(1)
graphics.setColor(0, 20, 0, 100)
graphics.rectangle("fill", self.data.x, self.data.y, self.data.w, self.data.h)
graphics.setColor(150, 255, 150, 150)
graphics.rectangle("line", self.data.x, self.data.y, self.data.w, self.data.h)
graphics.setColor(200, 255, 200, 255)
return graphics.print("e", self.data.x, self.data.y)
end,
setSize = function(self, w, h) setSize = function(self, w, h)
if w then if w then
self.data.w = w self.data.w = w
@ -63,6 +74,7 @@ do
if self.data.draw == nil then if self.data.draw == nil then
self.data.draw = true self.data.draw = true
end end
self.child = { }
end, end,
__base = _base_0, __base = _base_0,
__name = "element" __name = "element"

View File

@ -3,6 +3,8 @@
--- @copyright Paul Liverman III (2016) --- @copyright Paul Liverman III (2016)
--- @license The MIT License (MIT) --- @license The MIT License (MIT)
import graphics from love
class element class element
--- Constructor expects nothing, or a data table describing it. --- Constructor expects nothing, or a data table describing it.
--- @tparam ?Element|false parent The parent element. --- @tparam ?Element|false parent The parent element.
@ -12,7 +14,7 @@ class element
if type @data != "table" if type @data != "table"
@data = {} @data = {}
@data.parent = false unless @data.parent --included for correctness @data.parent = false unless @data.parent
@data.child = {} unless @data.child @data.child = {} unless @data.child
@data.x = 0 unless @data.x @data.x = 0 unless @data.x
@data.y = 0 unless @data.y @data.y = 0 unless @data.y
@ -21,6 +23,19 @@ class element
@data.update = false if @data.update == nil @data.update = false if @data.update == nil
@data.draw = true if @data.draw == nil @data.draw = true if @data.draw == nil
@child = {}
--- Slightly modified from pop.debugDraw
--- @see pop.debugDraw
debugDraw: =>
graphics.setLineWidth 1
graphics.setColor 0, 20, 0, 100
graphics.rectangle "fill", @data.x, @data.y, @data.w, @data.h
graphics.setColor 150, 255, 150, 150
graphics.rectangle "line", @data.x, @data.y, @data.w, @data.h
graphics.setColor 200, 255, 200, 255
graphics.print "e", @data.x, @data.y
--- Sets an element's width/height. --- Sets an element's width/height.
--- @tparam integer w[opt] Width. --- @tparam integer w[opt] Width.
--- @tparam integer h[opt] Height. --- @tparam integer h[opt] Height.

View File

@ -1,21 +1,36 @@
local element = require(tostring((...):sub(1, -7)) .. "/element")
local window local window
do do
local _class_0 local _class_0
local _parent_0 = element
local _base_0 = { local _base_0 = {
setSize = function(self) end setSize = function(self) end
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
setmetatable(_base_0, _parent_0.__base)
_class_0 = setmetatable({ _class_0 = setmetatable({
__init = function(self, parent, data) __init = function(self, parent, data)
if data == nil then if data == nil then
data = { } data = { }
end end
self.parent, self.data = parent, data self.parent, self.data = parent, data
return _class_0.__parent.__init(self, self.parent, self.data)
end, end,
__base = _base_0, __base = _base_0,
__name = "window" __name = "window",
__parent = _parent_0
}, { }, {
__index = _base_0, __index = function(cls, name)
local val = rawget(_base_0, name)
if val == nil then
local parent = rawget(cls, "__parent")
if parent then
return parent[name]
end
else
return val
end
end,
__call = function(cls, ...) __call = function(cls, ...)
local _self_0 = setmetatable({}, _base_0) local _self_0 = setmetatable({}, _base_0)
cls.__init(_self_0, ...) cls.__init(_self_0, ...)
@ -23,6 +38,9 @@ do
end end
}) })
_base_0.__class = _class_0 _base_0.__class = _class_0
if _parent_0.__inherited then
_parent_0.__inherited(_parent_0, _class_0)
end
window = _class_0 window = _class_0
return _class_0 return _class_0
end end

View File

@ -3,9 +3,13 @@
--- @copyright Paul Liverman III (2016) --- @copyright Paul Liverman III (2016)
--- @license The MIT License (MIT) --- @license The MIT License (MIT)
class window element = require "#{(...)\sub 1, -7}/element"
class window extends element
--- Constructor expects nothing, or a data table describing it. --- Constructor expects nothing, or a data table describing it.
new: (@parent, @data={}) => new: (@parent, @data={}) =>
super @parent, @data
--- @todo if data, do stuff about it --- @todo if data, do stuff about it
setSize: => setSize: =>

View File

@ -5,16 +5,21 @@ local pop = {
_LICENSE = 'The MIT License (MIT)', _LICENSE = 'The MIT License (MIT)',
_AUTHOR = 'Paul Liverman III' _AUTHOR = 'Paul Liverman III'
} }
local log
log = function(...)
return print("[Pop.Box]", ...)
end
if not (love.getVersion) then if not (love.getVersion) then
error("Pop.Box only supports LOVE versions >= 0.9.1") error("Pop.Box only supports LOVE versions >= 0.9.1")
end end
local path = ... local path = (...):gsub("%.", "/")
if (...):sub(-4) == "init" then if (...):sub(-4) == "init" then
path = (...):sub(1, -5) path = (...):sub(1, -5)
if not (path) then if not (path) then
path = "." path = "."
end end
end end
log("Require path detected: \"" .. tostring(path) .. "\"")
local filesystem, graphics local filesystem, graphics
do do
local _obj_0 = love local _obj_0 = love
@ -29,21 +34,25 @@ pop.skins = { }
pop.extensions = { } pop.extensions = { }
pop.screen = false pop.screen = false
pop.focused = false pop.focused = false
pop.log = log
pop.load = function() pop.load = function()
log("Loading elements from \"" .. tostring(path) .. "/elements\"")
local elements = filesystem.getDirectoryItems(tostring(path) .. "/elements") local elements = filesystem.getDirectoryItems(tostring(path) .. "/elements")
for i = 1, #elements do for i = 1, #elements do
local _continue_0 = false local _continue_0 = false
repeat repeat
if not (elements[i]:sub(-4) == ".lua") then if not (elements[i]:sub(-4) == ".lua") then
log("Ignored non-Lua file \"" .. tostring(path) .. "/elements/" .. tostring(elements[i]) .. "\"")
_continue_0 = true _continue_0 = true
break break
end end
local name = elements[i]:sub(1, -5) local name = elements[i]:sub(1, -5)
log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(path) .. "/elements/" .. tostring(name) .. "\"")
pop.elements[name] = require(tostring(path) .. "/elements/" .. tostring(name)) pop.elements[name] = require(tostring(path) .. "/elements/" .. tostring(name))
if pop.elements[name].load then if pop.elements[name].load then
pop.elements[name].load(pop) pop.elements[name].load(pop)
end end
print("element loaded: \"" .. tostring(name) .. "\"") log("Element loaded: \"" .. tostring(name) .. "\"")
if not (pop[name]) then if not (pop[name]) then
if pop.elements[name].wrap then if pop.elements[name].wrap then
pop[name] = pop.elements[name].wrap(pop) pop[name] = pop.elements[name].wrap(pop)
@ -52,7 +61,7 @@ pop.load = function()
return pop.create(name, ...) return pop.create(name, ...)
end end
end end
print("wrapper created: \"pop." .. tostring(name) .. "()\"") log("Wrapper created: \"pop." .. tostring(name) .. "()\"")
end end
_continue_0 = true _continue_0 = true
until true until true
@ -65,15 +74,17 @@ pop.load = function()
local _continue_0 = false local _continue_0 = false
repeat repeat
if not (skins[i]:sub(-4) == ".lua") then if not (skins[i]:sub(-4) == ".lua") then
log("Ignored non-Lua file \"" .. tostring(path) .. "/skins/" .. tostring(skins[i]) .. "\"")
_continue_0 = true _continue_0 = true
break break
end end
local name = skins[i]:sub(1, -5) local name = skins[i]:sub(1, -5)
log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(path) .. "/skins/" .. tostring(name) .. "\"")
pop.skins[name] = require(tostring(path) .. "/skins/" .. tostring(name)) pop.skins[name] = require(tostring(path) .. "/skins/" .. tostring(name))
if pop.skins[name].load then if pop.skins[name].load then
pop.skins[name].load(pop) pop.skins[name].load(pop)
end end
print("skin loaded: \"" .. tostring(name) .. "\"") log("Skin loaded: \"" .. tostring(name) .. "\"")
_continue_0 = true _continue_0 = true
until true until true
if not _continue_0 then if not _continue_0 then
@ -85,15 +96,17 @@ pop.load = function()
local _continue_0 = false local _continue_0 = false
repeat repeat
if not (extensions[i]:sub(-4) == ".lua") then if not (extensions[i]:sub(-4) == ".lua") then
log("Ignored non-Lua file \"" .. tostring(path) .. "/extensions/" .. tostring(extensions[i]) .. "\"")
_continue_0 = true _continue_0 = true
break break
end end
local name = extensions[i]:sub(1, -5) local name = extensions[i]:sub(1, -5)
log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(path) .. "/extensions/" .. tostring(name) .. "\"")
pop.extensions[name] = require(tostring(path) .. "/extensions/" .. tostring(name)) pop.extensions[name] = require(tostring(path) .. "/extensions/" .. tostring(name))
if pop.extensions[name].load then if pop.extensions[name].load then
pop.extensions[name].load(pop) pop.extensions[name].load(pop)
end end
print("extension loaded: \"" .. tostring(name) .. "\"") log("Extension loaded: \"" .. tostring(name) .. "\"")
_continue_0 = true _continue_0 = true
until true until true
if not _continue_0 then if not _continue_0 then
@ -101,7 +114,7 @@ pop.load = function()
end end
end end
pop.screen = pop.create("element", false):setSize(graphics.getWidth(), graphics.getHeight()) pop.screen = pop.create("element", false):setSize(graphics.getWidth(), graphics.getHeight())
return print("created \"pop.screen\"") return log("Created \"pop.screen\"")
end end
pop.create = function(element, parent, ...) pop.create = function(element, parent, ...)
if parent == nil then if parent == nil then
@ -160,7 +173,7 @@ pop.mousemoved = function(x, y, dx, dy)
end end
pop.mousepressed = function(x, y, button, element) pop.mousepressed = function(x, y, button, element)
if not (element) then if not (element) then
print("mousepressed", x, y, button) log("mousepressed", x, y, button)
element = pop.screen element = pop.screen
end end
local handled = false local handled = false
@ -210,13 +223,13 @@ pop.mousereleased = function(x, y, button, element)
end end
end end
else else
print("mousereleased", x, y, button) log("mousereleased", x, y, button)
pop.mousereleased(x, y, button, pop.screen) pop.mousereleased(x, y, button, pop.screen)
end end
return clickedHandled, mousereleasedHandled return clickedHandled, mousereleasedHandled
end end
pop.keypressed = function(key) pop.keypressed = function(key)
print("keypressed", key) log("keypressed", key)
local element = pop.focused local element = pop.focused
if element and element.keypressed and element.data.draw then if element and element.keypressed and element.data.draw then
return element.keypressed(key) return element.keypressed(key)
@ -224,7 +237,7 @@ pop.keypressed = function(key)
return false return false
end end
pop.keyreleased = function(key) pop.keyreleased = function(key)
print("keyreleased", key) log("keyreleased", key)
local element = pop.focused local element = pop.focused
if element and element.keyreleased then if element and element.keyreleased then
return element.keyreleased(key) return element.keyreleased(key)
@ -232,7 +245,7 @@ pop.keyreleased = function(key)
return false return false
end end
pop.textinput = function(text) pop.textinput = function(text)
print("textinput", text) log("textinput", text)
local element = pop.focused local element = pop.focused
if element and element.textinput and element.data.draw then if element and element.textinput and element.data.draw then
return element.textinput(text) return element.textinput(text)
@ -247,7 +260,7 @@ pop.debugDraw = function(element)
element:debugDraw() element:debugDraw()
else else
graphics.setLineWidth(1) graphics.setLineWidth(1)
graphics.setLineColor(0, 0, 0, 100) graphics.setColor(0, 0, 0, 100)
graphics.rectangle("fill", element.data.x, element.data.y, element.data.w, element.data.h) graphics.rectangle("fill", element.data.x, element.data.y, element.data.w, element.data.h)
graphics.setColor(150, 150, 150, 150) graphics.setColor(150, 150, 150, 150)
graphics.rectangle("line", element.data.x, element.data.y, element.data.w, element.data.h) graphics.rectangle("line", element.data.x, element.data.y, element.data.w, element.data.h)
@ -275,7 +288,7 @@ pop.printElementTree = function(element, depth)
end end
cls = cls .. " (" .. tostring(bg) .. ")" cls = cls .. " (" .. tostring(bg) .. ")"
end end
print(string.rep("-", depth) .. " " .. tostring(cls)) log(string.rep("-", depth) .. " " .. tostring(cls))
for i = 1, #element.child do for i = 1, #element.child do
pop.printElementTree(element.child[i], depth + 1) pop.printElementTree(element.child[i], depth + 1)
end end

View File

@ -12,16 +12,21 @@ pop = {
_AUTHOR: 'Paul Liverman III' _AUTHOR: 'Paul Liverman III'
} }
log = (...) ->
print "[Pop.Box]", ...
unless love.getVersion unless love.getVersion
error "Pop.Box only supports LOVE versions >= 0.9.1" error "Pop.Box only supports LOVE versions >= 0.9.1"
path = ... path = (...)\gsub "%.", "/"
if (...)\sub(-4) == "init" if (...)\sub(-4) == "init"
path = (...)\sub 1, -5 path = (...)\sub 1, -5
unless path unless path
path = "." path = "."
log "Require path detected: \"#{path}\""
import filesystem, graphics from love import filesystem, graphics from love
import insert from table import insert from table
import inheritsFromElement from require "#{path}/util" import inheritsFromElement from require "#{path}/util"
@ -42,6 +47,7 @@ pop.skins = {}
pop.extensions = {} pop.extensions = {}
pop.screen = false pop.screen = false
pop.focused = false pop.focused = false
pop.log = log
@ -56,21 +62,24 @@ pop.focused = false
pop.load = -> pop.load = ->
--@todo @ see Skins --@todo @ see Skins
--@todo @ see Extensions --@todo @ see Extensions
log "Loading elements from \"#{path}/elements\""
elements = filesystem.getDirectoryItems "#{path}/elements" elements = filesystem.getDirectoryItems "#{path}/elements"
for i = 1, #elements for i = 1, #elements
-- ignore non-Lua files -- ignore non-Lua files
unless elements[i]\sub(-4) == ".lua" unless elements[i]\sub(-4) == ".lua"
log "Ignored non-Lua file \"#{path}/elements/#{elements[i]}\""
continue continue
-- require into pop.elements table by filename -- require into pop.elements table by filename
name = elements[i]\sub 1, -5 name = elements[i]\sub 1, -5
log "Requiring \"#{name}\" from \"#{path}/elements/#{name}\""
pop.elements[name] = require "#{path}/elements/#{name}" pop.elements[name] = require "#{path}/elements/#{name}"
-- call the element's load function if it exists -- call the element's load function if it exists
if pop.elements[name].load if pop.elements[name].load
pop.elements[name].load pop pop.elements[name].load pop
print "element loaded: \"#{name}\"" log "Element loaded: \"#{name}\""
-- create "pop.element()" function wrapper if possible -- create "pop.element()" function wrapper if possible
unless pop[name] unless pop[name]
@ -80,46 +89,50 @@ pop.load = ->
pop[name] = (...) -> pop[name] = (...) ->
return pop.create(name, ...) return pop.create(name, ...)
print "wrapper created: \"pop.#{name}()\"" log "Wrapper created: \"pop.#{name}()\""
skins = filesystem.getDirectoryItems "#{path}/skins" skins = filesystem.getDirectoryItems "#{path}/skins"
for i = 1, #skins for i = 1, #skins
-- ignore non-Lua files -- ignore non-Lua files
unless skins[i]\sub(-4) == ".lua" unless skins[i]\sub(-4) == ".lua"
log "Ignored non-Lua file \"#{path}/skins/#{skins[i]}\""
continue continue
-- require into pop.skins table by filename -- require into pop.skins table by filename
name = skins[i]\sub 1, -5 name = skins[i]\sub 1, -5
log "Requiring \"#{name}\" from \"#{path}/skins/#{name}\""
pop.skins[name] = require "#{path}/skins/#{name}" pop.skins[name] = require "#{path}/skins/#{name}"
-- call the skin's load function if it exists -- call the skin's load function if it exists
if pop.skins[name].load if pop.skins[name].load
pop.skins[name].load pop pop.skins[name].load pop
print "skin loaded: \"#{name}\"" log "Skin loaded: \"#{name}\""
extensions = filesystem.getDirectoryItems "#{path}/extensions" extensions = filesystem.getDirectoryItems "#{path}/extensions"
for i = 1, #extensions for i = 1, #extensions
-- ignore non-Lua files -- ignore non-Lua files
unless extensions[i]\sub(-4) == ".lua" unless extensions[i]\sub(-4) == ".lua"
log "Ignored non-Lua file \"#{path}/extensions/#{extensions[i]}\""
continue continue
-- require into pop.extensions by filename -- require into pop.extensions by filename
name = extensions[i]\sub 1, -5 name = extensions[i]\sub 1, -5
log "Requiring \"#{name}\" from \"#{path}/extensions/#{name}\""
pop.extensions[name] = require "#{path}/extensions/#{name}" pop.extensions[name] = require "#{path}/extensions/#{name}"
-- call the extension's load function if it exists -- call the extension's load function if it exists
if pop.extensions[name].load if pop.extensions[name].load
pop.extensions[name].load pop pop.extensions[name].load pop
print "extension loaded: \"#{name}\"" log "Extension loaded: \"#{name}\""
-- Initialize pop.screen (top element, GUI area) -- Initialize pop.screen (top element, GUI area)
pop.screen = pop.create("element", false)\setSize(graphics.getWidth!, graphics.getHeight!) pop.screen = pop.create("element", false)\setSize(graphics.getWidth!, graphics.getHeight!)
print "created \"pop.screen\"" log "Created \"pop.screen\""
@ -227,7 +240,7 @@ pop.mousemoved = (x, y, dx, dy) ->
pop.mousepressed = (x, y, button, element) -> pop.mousepressed = (x, y, button, element) ->
-- start at the screen, print that we received an event -- start at the screen, print that we received an event
unless element unless element
print "mousepressed", x, y, button log "mousepressed", x, y, button
element = pop.screen element = pop.screen
-- have we handled the event? -- have we handled the event?
@ -298,7 +311,7 @@ pop.mousereleased = (x, y, button, element) ->
-- else, default to pop.screen to begin! (and print that we received an event) -- else, default to pop.screen to begin! (and print that we received an event)
else else
print "mousereleased", x, y, button log "mousereleased", x, y, button
pop.mousereleased x, y, button, pop.screen pop.mousereleased x, y, button, pop.screen
return clickedHandled, mousereleasedHandled return clickedHandled, mousereleasedHandled
@ -311,7 +324,7 @@ pop.mousereleased = (x, y, button, element) ->
--- @treturn boolean Was the event handled? --- @treturn boolean Was the event handled?
pop.keypressed = (key) -> pop.keypressed = (key) ->
print "keypressed", key log "keypressed", key
-- keypressed events must be on visible elements -- keypressed events must be on visible elements
element = pop.focused element = pop.focused
@ -328,7 +341,7 @@ pop.keypressed = (key) ->
--- @treturn boolean Was the event handled? --- @treturn boolean Was the event handled?
pop.keyreleased = (key) -> pop.keyreleased = (key) ->
print "keyreleased", key log "keyreleased", key
-- keyreleased events are always called -- keyreleased events are always called
element = pop.focused element = pop.focused
@ -345,7 +358,7 @@ pop.keyreleased = (key) ->
--- @treturn boolean Was the text input handled? --- @treturn boolean Was the text input handled?
pop.textinput = (text) -> pop.textinput = (text) ->
print "textinput", text log "textinput", text
-- textinput events must be on visible elements -- textinput events must be on visible elements
element = pop.focused element = pop.focused
@ -368,7 +381,7 @@ pop.debugDraw = (element=pop.screen) ->
element\debugDraw! element\debugDraw!
else else
graphics.setLineWidth 1 graphics.setLineWidth 1
graphics.setLineColor 0, 0, 0, 100 graphics.setColor 0, 0, 0, 100
graphics.rectangle "fill", element.data.x, element.data.y, element.data.w, element.data.h graphics.rectangle "fill", element.data.x, element.data.y, element.data.w, element.data.h
graphics.setColor 150, 150, 150, 150 graphics.setColor 150, 150, 150, 150
graphics.rectangle "line", element.data.x, element.data.y, element.data.w, element.data.h graphics.rectangle "line", element.data.x, element.data.y, element.data.w, element.data.h
@ -400,7 +413,7 @@ pop.printElementTree = (element=pop.screen, depth=0) ->
cls = cls .. " (#{bg})" cls = cls .. " (#{bg})"
print string.rep("-", depth) .. " #{cls}" log string.rep("-", depth) .. " #{cls}"
for i = 1, #element.child for i = 1, #element.child
pop.printElementTree element.child[i], depth + 1 pop.printElementTree element.child[i], depth + 1