mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
another fix attempt, failed
This commit is contained in:
parent
79130fe3d6
commit
a5e3714af8
@ -1,4 +1,4 @@
|
||||
local pop = require("pop")()
|
||||
local pop = require "pop"
|
||||
|
||||
local lg = love.graphics
|
||||
|
||||
@ -7,35 +7,35 @@ local testsRun = false
|
||||
local debugDrawEnabled = false
|
||||
|
||||
function love.load()
|
||||
pop:text(nil, "Press \"s\" to show objects for visual testing/demo.\nPress \"t\" to run tests.\nPress \"d\" to toggle debug draw."):move(2, 2)
|
||||
pop.text(nil, "Press \"s\" to show objects for visual testing/demo.\nPress \"t\" to run tests.\nPress \"d\" to toggle debug draw."):move(2, 2)
|
||||
--TODO correct the fact that the size is wrong here! (height doesn't take into account \n)
|
||||
--NOTE width? Is width calculated correctly when \n's exist? TEST THIS (also test tabs)
|
||||
pop:text(nil, "This is a test\ncollection of strings to see how width is determined.\nLooks like it takes width of widest line!"):move(30, 120)
|
||||
pop:element():align("right", "bottom"):setSize(25, 25):move(-5, -5)
|
||||
pop.text(nil, "This is a test\ncollection of strings to see how width is determined.\nLooks like it takes width of widest line!"):move(30, 120)
|
||||
pop.element():align("right", "bottom"):setSize(25, 25):move(-5, -5)
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
pop:update(dt)
|
||||
pop.update(dt)
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
pop:draw()
|
||||
pop.draw()
|
||||
|
||||
if debugDrawEnabled then
|
||||
pop:debugDraw()
|
||||
pop.debugDraw()
|
||||
end
|
||||
end
|
||||
|
||||
function love.textinput(text)
|
||||
--pop:textinput(text)
|
||||
pop.textinput(text)
|
||||
end
|
||||
|
||||
function love.mousepressed(button, x, y)
|
||||
--pop:mousepressed(button, x, y)
|
||||
pop.mousepressed(button, x, y)
|
||||
end
|
||||
|
||||
function love.mousereleased(button, x, y)
|
||||
--pop:mousereleased(button, x, y)
|
||||
pop.mousereleased(button, x, y)
|
||||
end
|
||||
|
||||
function love.keypressed(key)
|
||||
@ -44,19 +44,19 @@ function love.keypressed(key)
|
||||
else
|
||||
if (key == "s") and (not visualTestsShown) then
|
||||
-- old visual tests
|
||||
local align = pop:box():align("center", "center"):setSize(200, 200)
|
||||
pop:box(align):align("left", "top"):setSize(75, 10):setColor(255, 0, 255, 255)
|
||||
pop:box(align):align("center", "top"):setColor(100, 100, 100)
|
||||
pop:box(align, {0, 255, 0, 255}):setSize(20, 5):align("right", "top")
|
||||
pop:box(align):align("left", "center"):setColor(0, 0, 255)
|
||||
pop:box(align):align("center", "center"):setSize(90, 90):setColor(255, 255, 255)
|
||||
pop:box(align):align("right", "center"):setColor(255, 0, 0)
|
||||
pop:box(align):align("left", "bottom"):setColor(0, 255, 0):setSize(nil, 40)
|
||||
pop:box(align):align("center", "bottom"):setColor(255, 255, 0)
|
||||
pop:box(align):align("right", "bottom"):setColor(0, 255, 255):setSize(40, 40)
|
||||
--pop:box(nil, {255, 0, 0, 255}):align("left", "top"):setSize(50, 50) --TODO adjust z-height of elements
|
||||
pop:text(nil, "Hello World!"):align("center"):setText("Hey, I've been modified!")--:move(0, 18)
|
||||
pop:text(nil, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-=_+[]{}\\|:;\"',./<>?`~"):align("center", "bottom")
|
||||
local align = pop.box():align("center", "center"):setSize(200, 200)
|
||||
pop.box(align):align("left", "top"):setSize(75, 10):setColor(255, 0, 255, 255)
|
||||
pop.box(align):align("center", "top"):setColor(100, 100, 100)
|
||||
pop.box(align, {0, 255, 0, 255}):setSize(20, 5):align("right", "top")
|
||||
pop.box(align):align("left", "center"):setColor(0, 0, 255)
|
||||
pop.box(align):align("center", "center"):setSize(90, 90):setColor(255, 255, 255)
|
||||
pop.box(align):align("right", "center"):setColor(255, 0, 0)
|
||||
pop.box(align):align("left", "bottom"):setColor(0, 255, 0):setSize(nil, 40)
|
||||
pop.box(align):align("center", "bottom"):setColor(255, 255, 0)
|
||||
pop.box(align):align("right", "bottom"):setColor(0, 255, 255):setSize(40, 40)
|
||||
--pop.box(nil, {255, 0, 0, 255}):align("left", "top"):setSize(50, 50) --TODO adjust z-height of elements
|
||||
pop.text(nil, "Hello World!"):align("center"):setText("Hey, I've been modified!")--:move(0, 18)
|
||||
pop.text(nil, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-=_+[]{}\\|:;\"',./<>?`~"):align("center", "bottom")
|
||||
|
||||
visualTestsShown = true
|
||||
elseif (key == "t") and (not testsRun) then
|
||||
@ -65,10 +65,10 @@ function love.keypressed(key)
|
||||
debugDrawEnabled = not debugDrawEnabled
|
||||
end
|
||||
|
||||
--pop:keypressed(key)
|
||||
pop.keypressed(key)
|
||||
end
|
||||
end
|
||||
|
||||
function love.keyreleased(key)
|
||||
--pop:keyreleased(key)
|
||||
pop.keyreleased(key)
|
||||
end
|
||||
|
@ -6,59 +6,76 @@ end
|
||||
local insert
|
||||
insert = table.insert
|
||||
local path = ...
|
||||
local Pop
|
||||
do
|
||||
local _class_0
|
||||
local _base_0 = {
|
||||
create = function(self, elementType, parent, ...)
|
||||
if parent == nil then
|
||||
parent = self.window
|
||||
local pop = { }
|
||||
pop.elements = { }
|
||||
pop.window = {
|
||||
child = { }
|
||||
}
|
||||
pop.load = function()
|
||||
local elements = filesystem.getDirectoryItems(tostring(path) .. "/elements")
|
||||
for i = 1, #elements do
|
||||
local name = elements[i]:sub(1, -5)
|
||||
pop.elements[name] = require(tostring(path) .. "/elements/" .. tostring(name))
|
||||
print("loaded element: " .. tostring(name))
|
||||
if not pop[name] then
|
||||
pop[name] = function(...)
|
||||
return pop.create(name, ...)
|
||||
end
|
||||
local newElement = self.elements[elementType](parent, ...)
|
||||
print("wrapper created: " .. tostring(name) .. "()")
|
||||
end
|
||||
end
|
||||
pop.window = pop.create("element"):setSize(graphics.getWidth(), graphics.getHeight())
|
||||
return print("created window")
|
||||
end
|
||||
pop.create = function(elementType, parent, ...)
|
||||
if parent == nil then
|
||||
parent = pop.window
|
||||
end
|
||||
local newElement = pop.elements[elementType](parent, ...)
|
||||
insert(parent.child, newElement)
|
||||
return newElement
|
||||
end,
|
||||
update = function(self, dt, element)
|
||||
end
|
||||
pop.update = function(dt, element)
|
||||
if element == nil then
|
||||
element = self.window
|
||||
element = pop.window
|
||||
end
|
||||
if not element.excludeUpdating then
|
||||
if element.update then
|
||||
element:update(dt)
|
||||
end
|
||||
for i = 1, #element.child do
|
||||
self:update(dt, element.child[i])
|
||||
pop.update(dt, element.child[i])
|
||||
end
|
||||
end
|
||||
end,
|
||||
draw = function(self, element)
|
||||
end
|
||||
pop.draw = function(element)
|
||||
if element == nil then
|
||||
element = self.window
|
||||
element = pop.window
|
||||
end
|
||||
if not element.excludeRendering then
|
||||
if element.draw then
|
||||
local _
|
||||
do
|
||||
local _base_1 = element
|
||||
local _fn_0 = _base_1.draw
|
||||
local _base_0 = element
|
||||
local _fn_0 = _base_0.draw
|
||||
_ = function(...)
|
||||
return _fn_0(_base_1, ...)
|
||||
return _fn_0(_base_0, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
for i = 1, #element.child do
|
||||
self:draw(element.child[i])
|
||||
pop.draw(element.child)
|
||||
end
|
||||
end
|
||||
end,
|
||||
mousepressed = function(self, button, x, y, element)
|
||||
end
|
||||
pop.mousepressed = function(button, x, y, element)
|
||||
if element == nil then
|
||||
element = self.window
|
||||
element = pop.window
|
||||
end
|
||||
if (x >= element.x) and (x <= (element.x + element.w)) then
|
||||
if (y >= element.y) and (y <= (element.y + element.h)) then
|
||||
for i = 1, #element.child do
|
||||
if self:mousepressed(button, x, y, element.child[i]) then
|
||||
if pop.mousepressed(button, x, y, element.child[i]) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -69,36 +86,22 @@ do
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
mousereleased = function(self, button, x, y, element)
|
||||
end
|
||||
pop.mousereleased = function(button, x, y, element)
|
||||
if element == nil then
|
||||
element = self.window
|
||||
end
|
||||
if (x >= element.x) and (x <= (element.x + element.w)) then
|
||||
if (y >= element.y) and (y <= (element.y + element.h)) then
|
||||
for i = 1, #element.child do
|
||||
if self:mousereleased(button, x, y, element.child[i]) then
|
||||
return true
|
||||
element = pop.window
|
||||
end
|
||||
end
|
||||
if element.mousereleased then
|
||||
return element:mousereleased(button, x - element.x, y - element.y)
|
||||
else
|
||||
return false
|
||||
pop.keypressed = function(key)
|
||||
return print("pop.keypressed() is unimplemented.")
|
||||
end
|
||||
pop.keyreleased = function(key)
|
||||
return print("pop.keyreleased() is unimplemented.")
|
||||
end
|
||||
pop.textinput = function(text)
|
||||
return print("pop.textinput() is unimplemented.")
|
||||
end
|
||||
end,
|
||||
keypressed = function(self, key)
|
||||
return error("Unimplemented.")
|
||||
end,
|
||||
keyreleased = function(self, key)
|
||||
return error("Unimplemented.")
|
||||
end,
|
||||
textinput = function(self, text)
|
||||
return error("Unimplemented.")
|
||||
end,
|
||||
skin = function(self, element, skin, apply_to_children)
|
||||
pop.skin = function(element, skin, apply_to_children)
|
||||
if apply_to_children == nil then
|
||||
apply_to_children = true
|
||||
end
|
||||
@ -114,13 +117,13 @@ do
|
||||
end
|
||||
if apply_to_children then
|
||||
for i = 1, #element.child do
|
||||
self:skin(element.child[i], skin)
|
||||
pop.skin(element.child[i], skin)
|
||||
end
|
||||
end
|
||||
end,
|
||||
debugDraw = function(self, element)
|
||||
end
|
||||
pop.debugDraw = function(element)
|
||||
if element == nil then
|
||||
element = self.window
|
||||
element = pop.window
|
||||
end
|
||||
if element.debugDraw then
|
||||
element:debugDraw()
|
||||
@ -134,43 +137,8 @@ do
|
||||
graphics.print(".", element.x, element.y)
|
||||
end
|
||||
for i = 1, #element.child do
|
||||
self:debugDraw(element.child[i])
|
||||
pop.debugDraw(element.child[i])
|
||||
end
|
||||
end
|
||||
}
|
||||
_base_0.__index = _base_0
|
||||
_class_0 = setmetatable({
|
||||
__init = function(self)
|
||||
self.elements = { }
|
||||
self.window = {
|
||||
child = { }
|
||||
}
|
||||
local elements = filesystem.getDirectoryItems(tostring(path) .. "/elements")
|
||||
for i = 1, #elements do
|
||||
local name = elements[i]:sub(1, -5)
|
||||
self.elements[name] = require(tostring(path) .. "/elements/" .. tostring(name))
|
||||
print("loaded element: " .. tostring(name))
|
||||
if not self[name] then
|
||||
self[name] = function(self, ...)
|
||||
return self:create(name, ...)
|
||||
end
|
||||
print("wrapper created: " .. tostring(name) .. "()")
|
||||
end
|
||||
end
|
||||
self.window = self:create("element", self.window):setSize(graphics.getWidth(), graphics.getHeight())
|
||||
return print("created window")
|
||||
end,
|
||||
__base = _base_0,
|
||||
__name = "Pop"
|
||||
}, {
|
||||
__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
|
||||
Pop = _class_0
|
||||
return _class_0
|
||||
end
|
||||
pop.load()
|
||||
return pop
|
||||
|
146
lib/pop/init.lua
146
lib/pop/init.lua
@ -6,59 +6,76 @@ end
|
||||
local insert
|
||||
insert = table.insert
|
||||
local path = ...
|
||||
local Pop
|
||||
do
|
||||
local _class_0
|
||||
local _base_0 = {
|
||||
create = function(self, elementType, parent, ...)
|
||||
if parent == nil then
|
||||
parent = self.window
|
||||
local pop = { }
|
||||
pop.elements = { }
|
||||
pop.window = {
|
||||
child = { }
|
||||
}
|
||||
pop.load = function()
|
||||
local elements = filesystem.getDirectoryItems(tostring(path) .. "/elements")
|
||||
for i = 1, #elements do
|
||||
local name = elements[i]:sub(1, -5)
|
||||
pop.elements[name] = require(tostring(path) .. "/elements/" .. tostring(name))
|
||||
print("loaded element: " .. tostring(name))
|
||||
if not pop[name] then
|
||||
pop[name] = function(...)
|
||||
return pop.create(name, ...)
|
||||
end
|
||||
local newElement = self.elements[elementType](parent, ...)
|
||||
print("wrapper created: " .. tostring(name) .. "()")
|
||||
end
|
||||
end
|
||||
pop.window = pop.create("element"):setSize(graphics.getWidth(), graphics.getHeight())
|
||||
return print("created window")
|
||||
end
|
||||
pop.create = function(elementType, parent, ...)
|
||||
if parent == nil then
|
||||
parent = pop.window
|
||||
end
|
||||
local newElement = pop.elements[elementType](parent, ...)
|
||||
insert(parent.child, newElement)
|
||||
return newElement
|
||||
end,
|
||||
update = function(self, dt, element)
|
||||
end
|
||||
pop.update = function(dt, element)
|
||||
if element == nil then
|
||||
element = self.window
|
||||
element = pop.window
|
||||
end
|
||||
if not element.excludeUpdating then
|
||||
if element.update then
|
||||
element:update(dt)
|
||||
end
|
||||
for i = 1, #element.child do
|
||||
self:update(dt, element.child[i])
|
||||
pop.update(dt, element.child[i])
|
||||
end
|
||||
end
|
||||
end,
|
||||
draw = function(self, element)
|
||||
end
|
||||
pop.draw = function(element)
|
||||
if element == nil then
|
||||
element = self.window
|
||||
element = pop.window
|
||||
end
|
||||
if not element.excludeRendering then
|
||||
if element.draw then
|
||||
local _
|
||||
do
|
||||
local _base_1 = element
|
||||
local _fn_0 = _base_1.draw
|
||||
local _base_0 = element
|
||||
local _fn_0 = _base_0.draw
|
||||
_ = function(...)
|
||||
return _fn_0(_base_1, ...)
|
||||
return _fn_0(_base_0, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
for i = 1, #element.child do
|
||||
self:draw(element.child[i])
|
||||
pop.draw(element.child)
|
||||
end
|
||||
end
|
||||
end,
|
||||
mousepressed = function(self, button, x, y, element)
|
||||
end
|
||||
pop.mousepressed = function(button, x, y, element)
|
||||
if element == nil then
|
||||
element = self.window
|
||||
element = pop.window
|
||||
end
|
||||
if (x >= element.x) and (x <= (element.x + element.w)) then
|
||||
if (y >= element.y) and (y <= (element.y + element.h)) then
|
||||
for i = 1, #element.child do
|
||||
if self:mousepressed(button, x, y, element.child[i]) then
|
||||
if pop.mousepressed(button, x, y, element.child[i]) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -69,36 +86,22 @@ do
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
mousereleased = function(self, button, x, y, element)
|
||||
end
|
||||
pop.mousereleased = function(button, x, y, element)
|
||||
if element == nil then
|
||||
element = self.window
|
||||
end
|
||||
if (x >= element.x) and (x <= (element.x + element.w)) then
|
||||
if (y >= element.y) and (y <= (element.y + element.h)) then
|
||||
for i = 1, #element.child do
|
||||
if self:mousereleased(button, x, y, element.child[i]) then
|
||||
return true
|
||||
element = pop.window
|
||||
end
|
||||
end
|
||||
if element.mousereleased then
|
||||
return element:mousereleased(button, x - element.x, y - element.y)
|
||||
else
|
||||
return false
|
||||
pop.keypressed = function(key)
|
||||
return print("pop.keypressed() is unimplemented.")
|
||||
end
|
||||
pop.keyreleased = function(key)
|
||||
return print("pop.keyreleased() is unimplemented.")
|
||||
end
|
||||
pop.textinput = function(text)
|
||||
return print("pop.textinput() is unimplemented.")
|
||||
end
|
||||
end,
|
||||
keypressed = function(self, key)
|
||||
return error("Unimplemented.")
|
||||
end,
|
||||
keyreleased = function(self, key)
|
||||
return error("Unimplemented.")
|
||||
end,
|
||||
textinput = function(self, text)
|
||||
return error("Unimplemented.")
|
||||
end,
|
||||
skin = function(self, element, skin, apply_to_children)
|
||||
pop.skin = function(element, skin, apply_to_children)
|
||||
if apply_to_children == nil then
|
||||
apply_to_children = true
|
||||
end
|
||||
@ -114,13 +117,13 @@ do
|
||||
end
|
||||
if apply_to_children then
|
||||
for i = 1, #element.child do
|
||||
self:skin(element.child[i], skin)
|
||||
pop.skin(element.child[i], skin)
|
||||
end
|
||||
end
|
||||
end,
|
||||
debugDraw = function(self, element)
|
||||
end
|
||||
pop.debugDraw = function(element)
|
||||
if element == nil then
|
||||
element = self.window
|
||||
element = pop.window
|
||||
end
|
||||
if element.debugDraw then
|
||||
element:debugDraw()
|
||||
@ -134,43 +137,8 @@ do
|
||||
graphics.print(".", element.x, element.y)
|
||||
end
|
||||
for i = 1, #element.child do
|
||||
self:debugDraw(element.child[i])
|
||||
pop.debugDraw(element.child[i])
|
||||
end
|
||||
end
|
||||
}
|
||||
_base_0.__index = _base_0
|
||||
_class_0 = setmetatable({
|
||||
__init = function(self)
|
||||
self.elements = { }
|
||||
self.window = {
|
||||
child = { }
|
||||
}
|
||||
local elements = filesystem.getDirectoryItems(tostring(path) .. "/elements")
|
||||
for i = 1, #elements do
|
||||
local name = elements[i]:sub(1, -5)
|
||||
self.elements[name] = require(tostring(path) .. "/elements/" .. tostring(name))
|
||||
print("loaded element: " .. tostring(name))
|
||||
if not self[name] then
|
||||
self[name] = function(self, ...)
|
||||
return self:create(name, ...)
|
||||
end
|
||||
print("wrapper created: " .. tostring(name) .. "()")
|
||||
end
|
||||
end
|
||||
self.window = self:create("element", self.window):setSize(graphics.getWidth(), graphics.getHeight())
|
||||
return print("created window")
|
||||
end,
|
||||
__base = _base_0,
|
||||
__name = "Pop"
|
||||
}, {
|
||||
__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
|
||||
Pop = _class_0
|
||||
return _class_0
|
||||
end
|
||||
pop.load()
|
||||
return pop
|
||||
|
@ -3,56 +3,57 @@ import insert from table
|
||||
|
||||
path = ...
|
||||
|
||||
class Pop
|
||||
new: =>
|
||||
@elements = {}
|
||||
@window = {child: {}}
|
||||
--@focused = @window --TODO redo better
|
||||
pop = {}
|
||||
|
||||
pop.elements = {}
|
||||
pop.window = {child: {}} --placeholder to allow window creation without specialized code
|
||||
--pop.focused = false
|
||||
|
||||
pop.load = ->
|
||||
elements = filesystem.getDirectoryItems "#{path}/elements"
|
||||
for i = 1, #elements
|
||||
name = elements[i]\sub 1, -5
|
||||
@elements[name] = require "#{path}/elements/#{name}"
|
||||
pop.elements[name] = require "#{path}/elements/#{name}"
|
||||
print "loaded element: #{name}"
|
||||
|
||||
if not @[name]
|
||||
@[name] = (...) => return @create(name, ...)
|
||||
if not pop[name]
|
||||
pop[name] = (...) -> return pop.create(name, ...)
|
||||
print "wrapper created: #{name}()"
|
||||
|
||||
@window = @create("element", @window)\setSize(graphics.getWidth!, graphics.getHeight!)
|
||||
pop.window = pop.create("element")\setSize(graphics.getWidth!, graphics.getHeight!)
|
||||
--pop.window.parent = pop.window --may be dangerous? infinite loop looking for the window?
|
||||
--pop.window.parent = false --may be dangerous? attempting to index a boolean?
|
||||
print "created window"
|
||||
--@window.parent = @window
|
||||
--@window.parent = false
|
||||
|
||||
create: (elementType, parent=@window, ...) =>
|
||||
newElement = @elements[elementType](parent, ...)
|
||||
pop.create = (elementType, parent=pop.window, ...) ->
|
||||
newElement = pop.elements[elementType](parent, ...)
|
||||
insert parent.child, newElement
|
||||
return newElement
|
||||
|
||||
update: (dt, element=@window) =>
|
||||
pop.update = (dt, element=pop.window) ->
|
||||
if not element.excludeUpdating
|
||||
if element.update
|
||||
element\update dt
|
||||
|
||||
for i = 1, #element.child
|
||||
@update dt, element.child[i]
|
||||
pop.update dt, element.child[i]
|
||||
|
||||
draw: (element=@window) =>
|
||||
pop.draw = (element=pop.window) ->
|
||||
if not element.excludeRendering
|
||||
if element.draw
|
||||
element\draw
|
||||
|
||||
for i = 1, #element.child
|
||||
@draw element.child[i]
|
||||
pop.draw element.child
|
||||
|
||||
mousepressed: (button, x, y, element=@window) =>
|
||||
-- if within bounds of element, check its children
|
||||
-- if not handled by child, check if it can handle it
|
||||
-- abort loop with success if handled
|
||||
pop.mousepressed = (button, x, y, element=pop.window) ->
|
||||
-- if within bounds, check children
|
||||
-- if not handled, check if we can handle it
|
||||
-- abort with success if handled
|
||||
if (x >= element.x) and (x <= (element.x + element.w))
|
||||
if (y >= element.y) and (y <= (element.y + element.h))
|
||||
for i = 1, #element.child
|
||||
if @mousepressed button, x, y, element.child[i]
|
||||
if pop.mousepressed button, x, y, element.child[i]
|
||||
return true
|
||||
|
||||
if element.mousepressed
|
||||
@ -60,31 +61,20 @@ class Pop
|
||||
else
|
||||
return false
|
||||
|
||||
--TODO rewrite for multiple return values, mousereleased is the first val, click is the second!
|
||||
mousereleased: (button, x, y, element=@window) =>
|
||||
-- same as mousepressed, except an additional click is fired
|
||||
-- (TODO fix, so you have to start and end the click on the same element)
|
||||
if (x >= element.x) and (x <= (element.x + element.w))
|
||||
if (y >= element.y) and (y <= (element.y + element.h))
|
||||
for i = 1, #element.child
|
||||
if @mousereleased button, x, y, element.child[i]
|
||||
return true
|
||||
--TODO multiple return values, mousereleased first, click second
|
||||
pop.mousereleased = (button, x, y, element=pop.window) ->
|
||||
-- same as mousepressed, except a click can be fired as well
|
||||
|
||||
if element.mousereleased
|
||||
return element\mousereleased button, x - element.x, y - element.y
|
||||
else
|
||||
return false
|
||||
pop.keypressed = (key) ->
|
||||
print "pop.keypressed() is unimplemented."
|
||||
|
||||
keypressed: (key) =>
|
||||
error "Unimplemented."
|
||||
pop.keyreleased = (key) ->
|
||||
print "pop.keyreleased() is unimplemented."
|
||||
|
||||
keyreleased: (key) =>
|
||||
error "Unimplemented."
|
||||
pop.textinput = (text) ->
|
||||
print "pop.textinput() is unimplemented."
|
||||
|
||||
textinput: (text) =>
|
||||
error "Unimplemented."
|
||||
|
||||
skin: (element, skin, apply_to_children=true) =>
|
||||
pop.skin = (element, skin, apply_to_children=true) ->
|
||||
element.margin = skin.margin
|
||||
|
||||
if element.background
|
||||
@ -96,9 +86,9 @@ class Pop
|
||||
|
||||
if apply_to_children
|
||||
for i = 1, #element.child
|
||||
@skin element.child[i], skin
|
||||
pop.skin element.child[i], skin
|
||||
|
||||
debugDraw: (element=@window) =>
|
||||
pop.debugDraw = (element=pop.window) ->
|
||||
if element.debugDraw
|
||||
element\debugDraw!
|
||||
else
|
||||
@ -111,4 +101,8 @@ class Pop
|
||||
graphics.print ".", element.x, element.y
|
||||
|
||||
for i = 1, #element.child
|
||||
@debugDraw element.child[i]
|
||||
pop.debugDraw element.child[i]
|
||||
|
||||
pop.load!
|
||||
|
||||
return pop
|
||||
|
Loading…
Reference in New Issue
Block a user