diff --git a/README.md b/README.md
index db3a943..0e63e33 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,10 @@ to make it easy to experiment with GUIs during development.
Supports LÖVE versions 0.9.1 and higher.
+
+
+**Note**: Currently rewriting and redesigning Pop.Box. The following info is out of date until I finish:
+
## Features
- Quickly set up and align GUI elements.
diff --git a/build.bat b/build.bat
deleted file mode 100644
index a5a160b..0000000
--- a/build.bat
+++ /dev/null
@@ -1,6 +0,0 @@
-@ECHO OFF
-REM Assumes you have Windows binaries in the project's root directory!
-cd src
-"%cd%\..\moonc.exe" -t ../lib .
-cd ..
-xcopy /S /Y "%cd%\lib\pop\*" "%cd%\demo\pop\*"
diff --git a/build.sh b/build.sh
deleted file mode 100755
index d9ec838..0000000
--- a/build.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-cd src
-moonc -t ../lib .
-cd ..
-cp -rf ./lib/pop/* ./demo/pop/
diff --git a/config.ld b/config.ld
new file mode 100644
index 0000000..7232154
--- /dev/null
+++ b/config.ld
@@ -0,0 +1,11 @@
+file = {
+ "init.moon",
+ "util.moon",
+}
+
+project = "Pop.Box()"
+description = "GUI library for LOVE, designed for ease of use"
+title = "Documentation"
+--package = "pop" --has to be same name as source directory
+format = "markdown"
+dir = "docs"
diff --git a/demo.bat b/demo.bat
deleted file mode 100644
index cdcf57e..0000000
--- a/demo.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@ECHO OFF
-REM "%cd%\build.bat"
-"C:\Program Files\Love\LOVE.exe" "%cd%\demo"
diff --git a/demo.sh b/demo.sh
deleted file mode 100755
index 95885c3..0000000
--- a/demo.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-./build.sh
-love demo
diff --git a/demo/conf.lua b/demo/conf.lua
deleted file mode 100644
index 1d5727b..0000000
--- a/demo/conf.lua
+++ /dev/null
@@ -1,7 +0,0 @@
-function love.conf(t)
- t.title = "Pop.Box demo/tests"
- t.console = true
-
- t.window.width = 960
- t.window.height = 540
-end
diff --git a/demo/debug-lib/inspect.lua b/demo/debug-lib/inspect.lua
deleted file mode 100644
index 4b654b2..0000000
--- a/demo/debug-lib/inspect.lua
+++ /dev/null
@@ -1,344 +0,0 @@
-local inspect ={
- _VERSION = 'inspect.lua 3.0.3',
- _URL = 'http://github.com/kikito/inspect.lua',
- _DESCRIPTION = 'human-readable representations of tables',
- _LICENSE = [[
- MIT LICENSE
-
- Copyright (c) 2013 Enrique García Cota
-
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- ]]
-}
-
-inspect.KEY = setmetatable({}, {__tostring = function() return 'inspect.KEY' end})
-inspect.METATABLE = setmetatable({}, {__tostring = function() return 'inspect.METATABLE' end})
-
--- Apostrophizes the string if it has quotes, but not aphostrophes
--- Otherwise, it returns a regular quoted string
-local function smartQuote(str)
- if str:match('"') and not str:match("'") then
- return "'" .. str .. "'"
- end
- return '"' .. str:gsub('"', '\\"') .. '"'
-end
-
-local controlCharsTranslation = {
- ["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n",
- ["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v"
-}
-
-local function escape(str)
- local result = str:gsub("\\", "\\\\"):gsub("(%c)", controlCharsTranslation)
- return result
-end
-
-local function isIdentifier(str)
- return type(str) == 'string' and str:match( "^[_%a][_%a%d]*$" )
-end
-
-local function isSequenceKey(k, sequenceLength)
- return type(k) == 'number'
- and 1 <= k
- and k <= sequenceLength
- and math.floor(k) == k
-end
-
-local defaultTypeOrders = {
- ['number'] = 1, ['boolean'] = 2, ['string'] = 3, ['table'] = 4,
- ['function'] = 5, ['userdata'] = 6, ['thread'] = 7
-}
-
-local function sortKeys(a, b)
- local ta, tb = type(a), type(b)
-
- -- strings and numbers are sorted numerically/alphabetically
- if ta == tb and (ta == 'string' or ta == 'number') then return a < b end
-
- local dta, dtb = defaultTypeOrders[ta], defaultTypeOrders[tb]
- -- Two default types are compared according to the defaultTypeOrders table
- if dta and dtb then return defaultTypeOrders[ta] < defaultTypeOrders[tb]
- elseif dta then return true -- default types before custom ones
- elseif dtb then return false -- custom types after default ones
- end
-
- -- custom types are sorted out alphabetically
- return ta < tb
-end
-
--- For implementation reasons, the behavior of rawlen & # is "undefined" when
--- tables aren't pure sequences. So we implement our own # operator.
-local function getSequenceLength(t)
- local len = 1
- local v = rawget(t,len)
- while v ~= nil do
- len = len + 1
- v = rawget(t,len)
- end
- return len - 1
-end
-
-local function getNonSequentialKeys(t)
- local keys = {}
- local sequenceLength = getSequenceLength(t)
- for k,_ in pairs(t) do
- if not isSequenceKey(k, sequenceLength) then table.insert(keys, k) end
- end
- table.sort(keys, sortKeys)
- return keys, sequenceLength
-end
-
-local function getToStringResultSafely(t, mt)
- local __tostring = type(mt) == 'table' and rawget(mt, '__tostring')
- local str, ok
- if type(__tostring) == 'function' then
- ok, str = pcall(__tostring, t)
- str = ok and str or 'error: ' .. tostring(str)
- end
- if type(str) == 'string' and #str > 0 then return str end
-end
-
-local maxIdsMetaTable = {
- __index = function(self, typeName)
- rawset(self, typeName, 0)
- return 0
- end
-}
-
-local idsMetaTable = {
- __index = function (self, typeName)
- local col = {}
- rawset(self, typeName, col)
- return col
- end
-}
-
-local function countTableAppearances(t, tableAppearances)
- tableAppearances = tableAppearances or {}
-
- if type(t) == 'table' then
- if not tableAppearances[t] then
- tableAppearances[t] = 1
- for k,v in pairs(t) do
- countTableAppearances(k, tableAppearances)
- countTableAppearances(v, tableAppearances)
- end
- countTableAppearances(getmetatable(t), tableAppearances)
- else
- tableAppearances[t] = tableAppearances[t] + 1
- end
- end
-
- return tableAppearances
-end
-
-local copySequence = function(s)
- local copy, len = {}, #s
- for i=1, len do copy[i] = s[i] end
- return copy, len
-end
-
-local function makePath(path, ...)
- local keys = {...}
- local newPath, len = copySequence(path)
- for i=1, #keys do
- newPath[len + i] = keys[i]
- end
- return newPath
-end
-
-local function processRecursive(process, item, path, visited)
-
- if item == nil then return nil end
- if visited[item] then return visited[item] end
-
- local processed = process(item, path)
- if type(processed) == 'table' then
- local processedCopy = {}
- visited[item] = processedCopy
- local processedKey
-
- for k,v in pairs(processed) do
- processedKey = processRecursive(process, k, makePath(path, k, inspect.KEY), visited)
- if processedKey ~= nil then
- processedCopy[processedKey] = processRecursive(process, v, makePath(path, processedKey), visited)
- end
- end
-
- local mt = processRecursive(process, getmetatable(processed), makePath(path, inspect.METATABLE), visited)
- setmetatable(processedCopy, mt)
- processed = processedCopy
- end
- return processed
-end
-
-
-
--------------------------------------------------------------------
-
-local Inspector = {}
-local Inspector_mt = {__index = Inspector}
-
-function Inspector:puts(...)
- local args = {...}
- local buffer = self.buffer
- local len = #buffer
- for i=1, #args do
- len = len + 1
- buffer[len] = tostring(args[i])
- end
-end
-
-function Inspector:down(f)
- self.level = self.level + 1
- f()
- self.level = self.level - 1
-end
-
-function Inspector:tabify()
- self:puts(self.newline, string.rep(self.indent, self.level))
-end
-
-function Inspector:alreadyVisited(v)
- return self.ids[type(v)][v] ~= nil
-end
-
-function Inspector:getId(v)
- local tv = type(v)
- local id = self.ids[tv][v]
- if not id then
- id = self.maxIds[tv] + 1
- self.maxIds[tv] = id
- self.ids[tv][v] = id
- end
- return id
-end
-
-function Inspector:putKey(k)
- if isIdentifier(k) then return self:puts(k) end
- self:puts("[")
- self:putValue(k)
- self:puts("]")
-end
-
-function Inspector:putTable(t)
- if t == inspect.KEY or t == inspect.METATABLE then
- self:puts(tostring(t))
- elseif self:alreadyVisited(t) then
- self:puts('
')
- elseif self.level >= self.depth then
- self:puts('{...}')
- else
- if self.tableAppearances[t] > 1 then self:puts('<', self:getId(t), '>') end
-
- local nonSequentialKeys, sequenceLength = getNonSequentialKeys(t)
- local mt = getmetatable(t)
- local toStringResult = getToStringResultSafely(t, mt)
-
- self:puts('{')
- self:down(function()
- if toStringResult then
- self:puts(' -- ', escape(toStringResult))
- if sequenceLength >= 1 then self:tabify() end
- end
-
- local count = 0
- for i=1, sequenceLength do
- if count > 0 then self:puts(',') end
- self:puts(' ')
- self:putValue(t[i])
- count = count + 1
- end
-
- for _,k in ipairs(nonSequentialKeys) do
- if count > 0 then self:puts(',') end
- self:tabify()
- self:putKey(k)
- self:puts(' = ')
- self:putValue(t[k])
- count = count + 1
- end
-
- if mt then
- if count > 0 then self:puts(',') end
- self:tabify()
- self:puts(' = ')
- self:putValue(mt)
- end
- end)
-
- if #nonSequentialKeys > 0 or mt then -- result is multi-lined. Justify closing }
- self:tabify()
- elseif sequenceLength > 0 then -- array tables have one extra space before closing }
- self:puts(' ')
- end
-
- self:puts('}')
- end
-end
-
-function Inspector:putValue(v)
- local tv = type(v)
-
- if tv == 'string' then
- self:puts(smartQuote(escape(v)))
- elseif tv == 'number' or tv == 'boolean' or tv == 'nil' then
- self:puts(tostring(v))
- elseif tv == 'table' then
- self:putTable(v)
- else
- self:puts('<',tv,' ',self:getId(v),'>')
- end
-end
-
--------------------------------------------------------------------
-
-function inspect.inspect(root, options)
- options = options or {}
-
- local depth = options.depth or math.huge
- local newline = options.newline or '\n'
- local indent = options.indent or ' '
- local process = options.process
-
- if process then
- root = processRecursive(process, root, {}, {})
- end
-
- local inspector = setmetatable({
- depth = depth,
- buffer = {},
- level = 0,
- ids = setmetatable({}, idsMetaTable),
- maxIds = setmetatable({}, maxIdsMetaTable),
- newline = newline,
- indent = indent,
- tableAppearances = countTableAppearances(root)
- }, Inspector_mt)
-
- inspector:putValue(root)
-
- return table.concat(inspector.buffer)
-end
-
-setmetatable(inspect, { __call = function(_, ...) return inspect.inspect(...) end })
-
-return inspect
-
diff --git a/demo/main-simple.lua b/demo/main-simple.lua
deleted file mode 100644
index 8461be4..0000000
--- a/demo/main-simple.lua
+++ /dev/null
@@ -1,78 +0,0 @@
-local lg = love.graphics
-local pop, inspect
-
-local debugDraw = false
-
-function love.load()
- pop = require "pop"
-
- w2 = pop.window(nil, "Window")
- w2:move(100, 100)
- w2:setWidth(500)
- w2:move(-50, 80)
- w2:setHeight(500)
- w2:move(0, -175)
- w2.title:align("center")
- w2:position(0, 0)
- w2:size(200, 120):position(90, 70)
- w2:setClose(false)
- local t2 = pop.text("Click here to toggle close\nbutton on this window."):setMargin(10):setColor(0,0,0)
- t2.clicked = function()
- w2:setClose(not w2:hasClose())
- return true
- end
- w2:addChild(t2)
-end
-
-function love.update(dt)
- pop.update(dt)
-end
-
-function love.draw()
- pop.draw()
-
- if debugDraw then
- pop.debugDraw()
- end
-end
-
-function love.mousemoved(x, y, dx, dy)
- pop.mousemoved(x, y, dx, dy)
-end
-
-function love.mousepressed(x, y, button)
- pop.mousepressed(x, y, button)
-end
-
-function love.mousereleased(x, y, button)
- pop.mousereleased(x, y, button)
-end
-
-function love.keypressed(key)
- local handled = pop.keypressed(key)
-
- if (key == "d") and (not handled) then
- debugDraw = not debugDraw
- end
-
- if (key == "w") and (not handled) then
- local w = pop.window()
- w.title:align("center")
- end
-
- if (key == "p") and (not handled) then
- pop.printElementStack()
- end
-
- if (key == "escape") and (not handled) then
- love.event.quit()
- end
-end
-
-function love.keyreleased(key)
- pop.keyreleased(key)
-end
-
-function love.textinput(text)
- pop.textinput(text)
-end
diff --git a/demo/main.lua b/demo/main.lua
deleted file mode 100644
index e4247d1..0000000
--- a/demo/main.lua
+++ /dev/null
@@ -1,143 +0,0 @@
-local lg = love.graphics
-local pop, inspect
-
-local debugDraw = false
-local videoFile = lg.newVideo("test.ogv") -- so we can loop playback
-
-function love.load()
- print(love.getVersion())
-
- inspect = require "debug-lib/inspect"
- pop = require "pop"
- ---[[
- local c = pop.box():align("center", "center"):setSize(300, 300)
- pop.box(c, {255, 0, 0, 255}):setSize(100, 50)
- pop.box(c, {0, 255, 0, 255}):align("center"):setSize(100, 100)
- pop.box(c, {0, 0, 255, 255}):align("right"):setSize(50, 100)
- pop.box(c, {100, 100, 100, 255}):align("center", "center"):setSize(500, 100)
- pop.box(c):align("center"):setSize(50, 500):move(0, -100)
- pop.box(c, {255, 255, 0, 255}):align(false, "bottom"):setSize(100, 100)
- pop.box(c, {255, 150, 0, 255}):align("center", "bottom"):setSize(100, 50)
- pop.box(c, {0, 255, 255}):align("right", "bottom"):setSize(50, 100):move(-50)
- pop.text(nil, "Here's some test text\n(with newlines)\nin the top left corner!")
- pop.text(nil, "Here's some test text in the bottom right corner!"):align("right", "bottom")
- pop.skin(pop.text("Here's easier-to-code test text in the center!"):align("center", "center", true)) -- 'true' means align to pixel!
- w = pop.box(nil, {255, 255, 255, 255}):align(false, "bottom"):setSize(150, 150)
- b = pop.box(w, {0, 0, 0, 255}):margin(5):setSize(100, 100)
- --]]
-
- --c:move(100)
- pop.box({255, 0, 0, 255}):position(50, 500) -- testing streamlined_get_set extension & optional parents
- --b:margin(2) -- testing streamlined_get_set extension
- b:fill() -- testing fill!
-
- w2 = pop.window(nil, "Window")
- w2:move(100, 100)
- w2:setWidth(500)
- w2:move(-50, 80)
- w2:setHeight(500)
- w2:move(0, -175)
- w2.title:align("center")
- w2:position(0, 0)
- w2:size(200, 120):position(90, 70)
- w2:setClose(false)
- local t2 = pop.text("Click here to toggle close\nbutton on this window."):setMargin(10):setColor(0,0,0)
- t2.clicked = function()
- w2:setClose(not w2:hasClose())
- return true
- end
- w2:addChild(t2)
-
- local test = lg.newImage("test.png")
- G = pop.element():align("right"):move(-2, 2)
- a = pop.box(G, test):align("right")
- b = pop.box(G, test):align("right"):move(-25):setWidth(40)
- c = pop.box(G, test):align("right"):move(0, 25):setHeight(40)
-
- print(a.horizontal, a.vertical)
- print(b.horizontal, b.vertical)
- print(c.horizontal, c.vertical)
-
- local window = pop.window():align("center", "center"):setTitle("Welcome! This title is far too big!")
-
- pop.window():setClose(false):setClose(true)
-
- local video = pop.box():align("right", "bottom"):setBackground(videoFile):setSize(320/2, 240/2):move(-20, -20)
- videoFile:play()
-
- --TODO make debugDraw better
-
- --[[
- local all = pop.box()
- for k,v in pairs(all) do
- print(k, v)
- end
- print(all.__class.__name)
- --]]
-end
-
-function love.update(dt)
- pop.update(dt)
-
- if not videoFile:isPlaying() then
- videoFile:rewind()
- videoFile:play() -- sometimes rewinding at the end of play fails to start a loop
- end
-end
-
-function love.draw()
- pop.draw()
-
- if debugDraw then
- pop.debugDraw()
- end
-end
-
-function love.mousemoved(x, y, dx, dy)
- pop.mousemoved(x, y, dx, dy)
-end
-
-function love.mousepressed(x, y, button)
- pop.mousepressed(x, y, button)
-end
-
-function love.mousereleased(x, y, button)
- pop.mousereleased(x, y, button)
-end
-
-function love.keypressed(key)
- local handled = pop.keypressed(key)
-
- if (key == "d") and (not handled) then
- debugDraw = not debugDraw
- end
-
- if (key == "w") and (not handled) then
- local w = pop.window()
- w.title:align("center")
- end
-
- if (key == "e") and (not handled) then
- print("EVENTS:")
- for k,v in pairs(pop.events) do
- print(k, v)
- end
- print("END")
- end
-
- if (key == "p") and (not handled) then
- pop.printElementTree()
- end
-
- if (key == "escape") and (not handled) then
- love.event.quit()
- end
-end
-
-function love.keyreleased(key)
- pop.keyreleased(key)
-end
-
-function love.textinput(text)
- pop.textinput(text)
-end
diff --git a/demo/pop/elements/box.lua b/demo/pop/elements/box.lua
deleted file mode 100644
index 2128ddf..0000000
--- a/demo/pop/elements/box.lua
+++ /dev/null
@@ -1,110 +0,0 @@
-local graphics
-graphics = love.graphics
-local sub, len
-do
- local _obj_0 = string
- sub, len = _obj_0.sub, _obj_0.len
-end
-local path = sub(..., 1, len(...) - len("/box"))
-local element = require(tostring(path) .. "/element")
-local box
-do
- local _class_0
- local _parent_0 = element
- local _base_0 = {
- draw = function(self)
- if self.background then
- if type(self.background) == "table" then
- graphics.setColor(self.background)
- graphics.rectangle("fill", self.x, self.y, self.w, self.h)
- else
- local w, h = self.background:getDimensions()
- w = self.w / w
- h = self.h / h
- graphics.setColor(255, 255, 255, 255)
- graphics.draw(self.background, self.x, self.y, 0, w, h)
- end
- end
- return self
- end,
- debugDraw = function(self)
- graphics.setLineWidth(0.5)
- graphics.setColor(0, 0, 0, 100)
- graphics.rectangle("fill", self.x, self.y, self.w, self.h)
- graphics.setColor(0, 0, 200, 200)
- graphics.rectangle("line", self.x, self.y, self.w, self.h)
- graphics.setColor(200, 200, 255, 255)
- graphics.print("b", self.x, self.y)
- return self
- end,
- setBackground = function(self, background)
- self.background = background
- return self
- end,
- getBackground = function(self)
- return self.background
- end,
- setColor = function(self, r, g, b, a)
- if a == nil then
- a = 255
- end
- if type(r) == "table" then
- self.background = r
- else
- self.background = {
- r,
- g,
- b,
- a
- }
- end
- return self
- end,
- getColor = function(self)
- if type(self.background) == "table" then
- return unpack(self.background)
- else
- return error("Box \"" .. tostring(self) .. "\" doesn't have a color.")
- end
- end
- }
- _base_0.__index = _base_0
- setmetatable(_base_0, _parent_0.__base)
- _class_0 = setmetatable({
- __init = function(self, parent, background)
- if background == nil then
- background = false
- end
- _class_0.__parent.__init(self, parent)
- self.w = 20
- self.h = 20
- self.background = background
- end,
- __base = _base_0,
- __name = "box",
- __parent = _parent_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, ...)
- local _self_0 = setmetatable({}, _base_0)
- cls.__init(_self_0, ...)
- return _self_0
- end
- })
- _base_0.__class = _class_0
- if _parent_0.__inherited then
- _parent_0.__inherited(_parent_0, _class_0)
- end
- box = _class_0
- return _class_0
-end
diff --git a/demo/pop/elements/element.lua b/demo/pop/elements/element.lua
deleted file mode 100644
index 0532455..0000000
--- a/demo/pop/elements/element.lua
+++ /dev/null
@@ -1,296 +0,0 @@
-local graphics
-graphics = love.graphics
-local floor
-floor = math.floor
-local insert, remove
-do
- local _obj_0 = table
- insert, remove = _obj_0.insert, _obj_0.remove
-end
-local tonumber = tonumber
-local element
-do
- local _class_0
- local _base_0 = {
- debugDraw = function(self)
- graphics.setLineWidth(0.5)
- graphics.setColor(0, 0, 0, 100)
- graphics.rectangle("fill", self.x, self.y, self.w, self.h)
- graphics.setColor(0, 200, 0, 200)
- graphics.rectangle("line", self.x, self.y, self.w, self.h)
- graphics.setColor(200, 255, 200, 255)
- graphics.print("e", self.x, self.y)
- return self
- end,
- addChild = function(self, child)
- if child.parent then
- child.parent:removeChild(child)
- end
- insert(self.child, child)
- child.parent = self
- child:align()
- return self
- end,
- removeChild = function(self, child)
- if tonumber(child) == child then
- self.child[child].parent = false
- return remove(self.child, child)
- else
- for k, v in ipairs(self.child) do
- if v == child then
- return remove(self.child, k)
- end
- end
- return "Element \"" .. tostring(child) .. "\" is not a child of element \"" .. tostring(self) .. "\". Cannot remove it."
- end
- end,
- getChildren = function(self)
- return self.child
- end,
- move = function(self, x, y)
- if x then
- self.x = self.x + x
- end
- if y then
- self.y = self.y + y
- end
- for i = 1, #self.child do
- if not (self.child[i].excludeMovement) then
- self.child[i]:move(x, y)
- end
- end
- return self
- end,
- setPosition = function(self, x, y)
- local oldX = self.x
- local oldY = self.y
- if x then
- local _exp_0 = self.horizontal
- if "left" == _exp_0 then
- self.x = x
- elseif "center" == _exp_0 then
- self.x = x - self.w / 2
- elseif "right" == _exp_0 then
- self.x = x - self.w
- end
- else
- x = oldX
- end
- if y then
- local _exp_0 = self.vertical
- if "top" == _exp_0 then
- self.y = y
- elseif "center" == _exp_0 then
- self.y = y - self.h / 2
- elseif "bottom" == _exp_0 then
- self.y = y - self.h
- end
- else
- y = oldY
- end
- for i = 1, #self.child do
- self.child[i]:move(x - oldX, y - oldY)
- end
- return self
- end,
- getPosition = function(self)
- local resultX = self.x
- local resultY = self.y
- local _exp_0 = self.horizontal
- if "center" == _exp_0 then
- resultX = resultX + (self.w / 2)
- elseif "right" == _exp_0 then
- resultY = resultY + self.w
- end
- local _exp_1 = self.vertical
- if "center" == _exp_1 then
- resultY = resultY + (self.h / 2)
- elseif "bottom" == _exp_1 then
- resultY = resultY + self.h
- end
- return resultX, resultY
- end,
- setSize = function(self, w, h)
- if w then
- local _exp_0 = self.horizontal
- if "center" == _exp_0 then
- self.x = self.x - ((w - self.w) / 2)
- elseif "right" == _exp_0 then
- self.x = self.x - (w - self.w)
- end
- self.w = w
- end
- if h then
- local _exp_0 = self.vertical
- if "center" == _exp_0 then
- self.y = self.y - ((h - self.h) / 2)
- elseif "bottom" == _exp_0 then
- self.y = self.y - (h - self.h)
- end
- self.h = h
- end
- return self
- end,
- getSize = function(self)
- return self.w, self.h
- end,
- setWidth = function(self, w)
- local _exp_0 = self.horizontal
- if "center" == _exp_0 then
- self.x = self.x - ((w - self.w) / 2)
- elseif "right" == _exp_0 then
- self.x = self.x - (w - self.w)
- end
- self.w = w
- return self
- end,
- getWidth = function(self)
- return self.w
- end,
- setHeight = function(self, h)
- local _exp_0 = self.vertical
- if "center" == _exp_0 then
- self.y = self.y - ((h - self.h) / 2)
- elseif "bottom" == _exp_0 then
- self.y = self.y - (h - self.h)
- end
- self.h = h
- return self
- end,
- getHeight = function(self)
- return self.h
- end,
- adjustSize = function(self, w, h)
- local W, H = self:getSize()
- if w then
- W = W + w
- end
- if h then
- H = H + h
- end
- self:setSize(W, H)
- return self
- end,
- align = function(self, horizontal, vertical, toPixel)
- if toPixel == nil then
- toPixel = true
- end
- self:setAlignment(horizontal, vertical)
- self.x = self.parent.x
- self.y = self.parent.y
- local _exp_0 = self.horizontal
- if "left" == _exp_0 then
- self.x = self.x + self.spacing
- elseif "center" == _exp_0 then
- self.x = self.x + ((self.parent.w - self.w) / 2)
- elseif "right" == _exp_0 then
- self.x = self.x + (self.parent.w - self.w - self.spacing)
- end
- local _exp_1 = self.vertical
- if "top" == _exp_1 then
- self.y = self.y + self.spacing
- elseif "center" == _exp_1 then
- self.y = self.y + ((self.parent.h - self.h) / 2)
- elseif "bottom" == _exp_1 then
- self.y = self.y + (self.parent.h - self.h - self.spacing)
- end
- if toPixel then
- self.x = floor(self.x)
- self.y = floor(self.y)
- end
- return self
- end,
- alignTo = function(self, element, horizontal, vertical, toPixel)
- if toPixel == nil then
- toPixel = true
- end
- local parent = self.parent
- self.parent = element
- self:align(horizontal, vertical, toPixel)
- self.parent = parent
- return self
- end,
- setAlignment = function(self, horizontal, vertical)
- if horizontal then
- self.horizontal = horizontal
- end
- if vertical then
- self.vertical = vertical
- end
- return self
- end,
- getAlignment = function(self)
- return self.horizontal, self.vertical
- end,
- setMargin = function(self, spacing)
- self.spacing = spacing
- self:align()
- return self
- end,
- getMargin = function(self)
- return self.spacing
- end,
- fill = function(self)
- self.x = self.parent.x + self.spacing
- self.y = self.parent.y + self.spacing
- self.w = self.parent.w - self.spacing * 2
- self.h = self.parent.h - self.spacing * 2
- end,
- delete = function(self)
- for k, v in ipairs(self.child) do
- v:delete()
- end
- self.parent:removeChild(self)
- self = nil
- return nil
- end,
- getVisibility = function(self)
- return (not self.excludeDraw)
- end,
- setVisibility = function(self, isVisible)
- self.excludeDraw = (not isVisible)
- return self
- end,
- getStatic = function(self)
- return self.excludeMovement
- end,
- setStatic = function(self, isStatic)
- self.excludeMovement = isStatic
- return self
- end
- }
- _base_0.__index = _base_0
- _class_0 = setmetatable({
- __init = function(self, parent)
- self.parent = parent
- self.child = { }
- self.w = 0
- self.h = 0
- self.spacing = 0
- if parent then
- self.x = parent.x
- self.y = parent.y
- else
- self.x = 0
- self.y = 0
- end
- self.horizontal = "left"
- self.vertical = "top"
- self.excludeDraw = false
- self.excludeUpdate = false
- self.excludeMovement = false
- 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
diff --git a/demo/pop/elements/img/close.png b/demo/pop/elements/img/close.png
deleted file mode 100644
index a14891b..0000000
Binary files a/demo/pop/elements/img/close.png and /dev/null differ
diff --git a/demo/pop/elements/text.lua b/demo/pop/elements/text.lua
deleted file mode 100644
index a81af09..0000000
--- a/demo/pop/elements/text.lua
+++ /dev/null
@@ -1,154 +0,0 @@
-local graphics
-graphics = love.graphics
-local sub, len
-do
- local _obj_0 = string
- sub, len = _obj_0.sub, _obj_0.len
-end
-local path = sub(..., 1, len(...) - len("/box"))
-local element = require(tostring(path) .. "/element")
-local text
-do
- local _class_0
- local _parent_0 = element
- local _base_0 = {
- draw = function(self)
- graphics.setColor(self.color)
- graphics.setFont(self.font)
- graphics.print(self.txt, self.x, self.y)
- return self
- end,
- debugDraw = function(self)
- graphics.setLineWidth(0.5)
- graphics.setColor(0, 0, 0, 100)
- graphics.rectangle("fill", self.x, self.y, self.w, self.h)
- graphics.setColor(200, 0, 0, 200)
- graphics.rectangle("line", self.x, self.y, self.w, self.h)
- graphics.setColor(255, 200, 200, 255)
- graphics.print("t", self.x, self.y)
- return self
- end,
- setSize = function(self)
- local w = self.font:getWidth(self.txt)
- local h = self.font:getHeight() * (select(2, self.txt:gsub("\n", "\n")) + 1)
- local _exp_0 = self.horizontal
- if "center" == _exp_0 then
- self.x = self.x - ((w - self.w) / 2)
- elseif "right" == _exp_0 then
- self.x = self.x - (w - self.w - self.spacing)
- end
- local _exp_1 = self.vertical
- if "center" == _exp_1 then
- self.y = self.y - ((h - self.h) / 2)
- elseif "bottom" == _exp_1 then
- self.y = self.y - (h - self.h - self.spacing)
- end
- self.w = w
- self.h = h
- return self
- end,
- setWidth = function(self)
- self:setSize()
- return self
- end,
- setHeight = function(self)
- self:setSize()
- return self
- end,
- setText = function(self, text)
- if text == nil then
- text = ""
- end
- self.txt = text
- self:setSize()
- return self
- end,
- getText = function(self)
- return self.txt
- end,
- setFont = function(self, font)
- self.font = font
- self:setSize()
- return self
- end,
- getFont = function(self)
- return self.font
- end,
- setColor = function(self, r, g, b, a)
- if a == nil then
- a = 255
- end
- if type(r) == "table" then
- self.color = r
- else
- self.color = {
- r,
- g,
- b,
- a
- }
- end
- return self
- end,
- getColor = function(self)
- return unpack(self.color)
- end
- }
- _base_0.__index = _base_0
- setmetatable(_base_0, _parent_0.__base)
- _class_0 = setmetatable({
- __init = function(self, parent, text, color)
- if text == nil then
- text = ""
- end
- if color == nil then
- color = {
- 255,
- 255,
- 255,
- 255
- }
- end
- _class_0.__parent.__init(self, parent)
- self.font = graphics.newFont(14)
- self:setText(text)
- self.color = color
- end,
- __base = _base_0,
- __name = "text",
- __parent = _parent_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, ...)
- local _self_0 = setmetatable({}, _base_0)
- cls.__init(_self_0, ...)
- return _self_0
- end
- })
- _base_0.__class = _class_0
- local self = _class_0
- self.wrap = function(pop)
- return function(parent, ...)
- if type(parent) == "string" then
- return pop.create("text", nil, parent, ...)
- else
- return pop.create("text", parent, ...)
- end
- end
- end
- if _parent_0.__inherited then
- _parent_0.__inherited(_parent_0, _class_0)
- end
- text = _class_0
- return _class_0
-end
diff --git a/demo/pop/elements/window.lua b/demo/pop/elements/window.lua
deleted file mode 100644
index cd4cb31..0000000
--- a/demo/pop/elements/window.lua
+++ /dev/null
@@ -1,353 +0,0 @@
-local graphics, mouse
-do
- local _obj_0 = love
- graphics, mouse = _obj_0.graphics, _obj_0.mouse
-end
-local insert, remove
-do
- local _obj_0 = table
- insert, remove = _obj_0.insert, _obj_0.remove
-end
-local sub, len
-do
- local _obj_0 = string
- sub, len = _obj_0.sub, _obj_0.len
-end
-local path = sub(..., 1, len(...) - len("/window"))
-local element = require(tostring(path) .. "/element")
-local box = require(tostring(path) .. "/box")
-local text = require(tostring(path) .. "/text")
-local closeImage = graphics.newImage(tostring(path) .. "/img/close.png")
-local left = 1
-local mousemoved_event = true
-do
- local major, minor, revision = love.getVersion()
- if (major == 0) and (minor == 10) and ((revision == 0) or (revision == 1)) then
- left = 1
- elseif (major == 0) and (minor == 9) then
- left = "l"
- if revision == 1 then
- mousemoved_event = false
- end
- else
- print("elements/window: unrecognized LOVE version: " .. tostring(major) .. "." .. tostring(minor) .. "." .. tostring(revision))
- print(" assuming LOVE version > 0.10.1 (there may be bugs)")
- end
-end
-local pop_ref = false
-local window
-do
- local _class_0
- local _parent_0 = element
- local _base_0 = {
- load = function(pop)
- pop_ref = pop
- end,
- debugDraw = function(self)
- graphics.setLineWidth(0.5)
- graphics.setColor(0, 0, 0, 100)
- graphics.rectangle("fill", self.x, self.y, self.w, self.h)
- graphics.setColor(200, 0, 200, 200)
- graphics.rectangle("line", self.x, self.y, self.w, self.h)
- graphics.setColor(255, 200, 255, 255)
- graphics.print("w", self.x, self.y)
- return self
- end,
- addChild = function(self, child)
- self.area:addChild(child)
- return self
- end,
- removeChild = function(self, child)
- local result = self.area:removeChild(child)
- if result == self.area then
- return self
- elseif type(result) == "string" then
- for k, v in ipairs(self.child) do
- if v == child then
- remove(self.child, k)
- return self
- end
- end
- return "Element \"" .. tostring(child) .. "\" is not a child of window \"" .. tostring(self) .. "\". Cannot remove it."
- else
- return result
- end
- end,
- getChildren = function(self)
- return self.area.child
- end,
- align = function(self, horizontal, vertical, toPixel)
- _class_0.__parent.__base.align(self, horizontal, vertical, toPixel)
- for i = 1, #self.child do
- self.child[i]:align()
- end
- self.area:move(nil, self.head:getHeight())
- return self
- end,
- setSize = function(self, w, h)
- local x = 0
- local y = 0
- if w then
- local _exp_0 = self.horizontal
- if "center" == _exp_0 then
- x = x - ((w - self.w) / 2)
- elseif "right" == _exp_0 then
- x = x - (w - self.w)
- end
- if self.close then
- self.head:setWidth(w - self.head:getHeight())
- else
- self.head:setWidth(w)
- end
- self.area:setWidth(w)
- self.w = w
- self.x = self.x + x
- self.title:align()
- if self.close then
- self.close:align()
- end
- end
- if h then
- h = h - self.head:getHeight()
- local _exp_0 = self.vertical
- if "center" == _exp_0 then
- y = y - ((h - self.h) / 2)
- elseif "right" == _exp_0 then
- y = y - (h - self.h)
- end
- self.area:setHeight(h)
- self.h = h + self.head:getHeight()
- self.y = self.y + y
- end
- self.head:move(x, y)
- self.area:move(x, y)
- return self
- end,
- setWidth = function(self, w)
- local x = 0
- local _exp_0 = self.horizontal
- if "center" == _exp_0 then
- x = x - ((w - self.w) / 2)
- elseif "right" == _exp_0 then
- x = x - (w - self.w)
- end
- if self.close then
- self.head:setWidth(w - self.head:getHeight())
- else
- self.head:setWidth(w)
- end
- self.area:setWidth(w)
- self.w = w
- self.x = self.x + x
- self.title:align()
- if self.close then
- self.close:align()
- end
- self.head:move(x)
- self.area:move(x)
- return self
- end,
- setHeight = function(self, h)
- local y = 0
- h = h - self.head:getHeight()
- local _exp_0 = self.vertical
- if "center" == _exp_0 then
- y = y - ((h - self.h) / 2)
- elseif "right" == _exp_0 then
- y = y - (h - self.h)
- end
- self.area:setHeight(h)
- self.h = h + self.head:getHeight()
- self.y = self.y + y
- self.head:move(nil, y)
- self.title:move(nil, y)
- self.area:move(nil, y)
- return self
- end,
- setTitle = function(self, title)
- self.title:setText(title)
- if self.titleOverflow == "trunicate" then
- while self.title:getWidth() > self.head:getWidth() do
- title = title:sub(1, -3)
- self.title:setText(title .. "…")
- end
- elseif self.titleOverflow == "resize" then
- if self.title:getWidth() > self.head:getWidth() then
- self:setWidth(self.title:getWidth())
- end
- end
- return self
- end,
- getTitle = function(self)
- return self.title:getText()
- end,
- setTitleOverflow = function(self, method)
- self.titleOverflow = method
- return self
- end,
- getTitleOverflow = function(self)
- return self.titleOverflow
- end,
- setClose = function(self, enabled)
- if enabled then
- self.close = box(self, closeImage)
- self.close.clicked = function()
- self:delete()
- return true
- end
- local height = self.head:getHeight()
- self.close:align("right"):setSize(height, height)
- self.head:setWidth(self.w - height)
- self.title:align()
- insert(self.child, self.close)
- else
- self.close:delete()
- self.head:setWidth(self.w)
- self.title:align()
- self.close = false
- end
- return self
- end,
- hasClose = function(self)
- if self.close then
- return true
- else
- return false
- end
- end,
- delete = function(self)
- _class_0.__parent.__base.delete(self)
- self.head = nil
- self.title = nil
- self.area = nil
- self.close = nil
- end
- }
- _base_0.__index = _base_0
- setmetatable(_base_0, _parent_0.__base)
- _class_0 = setmetatable({
- __init = function(self, parent, title, tBackground, tColor, wBackground)
- if title == nil then
- title = "window"
- end
- if tBackground == nil then
- tBackground = {
- 25,
- 180,
- 230,
- 255
- }
- end
- if tColor == nil then
- tColor = {
- 255,
- 255,
- 255,
- 255
- }
- end
- if wBackground == nil then
- wBackground = {
- 200,
- 200,
- 210,
- 255
- }
- end
- _class_0.__parent.__init(self, parent)
- self.head = box(self, tBackground)
- self.title = text(self.head, title, tColor)
- self.area = box(self, wBackground)
- self.close = box(self, closeImage)
- local height = self.title:getHeight()
- self.head:setSize(self.w - height, height)
- self.area:move(nil, height)
- self.close:align("right"):setSize(height, height)
- self:setSize(100, 80)
- self.child = {
- self.head,
- self.title,
- self.area,
- self.close
- }
- self.titleOverflow = "trunicate"
- self.area.mousepressed = function()
- return true
- end
- self.area.clicked = function()
- return true
- end
- self.close.clicked = function()
- self:delete()
- return true
- end
- self.head.selected = false
- if mousemoved_event then
- self.head.mousemoved = function(self, x, y, dx, dy)
- if self.selected then
- self.parent:move(dx, dy)
- return true
- end
- return false
- end
- self.head.mousepressed = function(self, x, y, button)
- if button == left then
- self.selected = true
- return true
- end
- return false
- end
- else
- self.head.mx = 0
- self.head.my = 0
- self.head.update = function(self)
- local x, y = mouse.getPosition()
- return self:setPosition(x - mx, y - my)
- end
- self.head.mousepressed = function(self, x, y, button)
- if button == left then
- self.selected = true
- self.mx = x
- self.my = y
- return true
- end
- return false
- end
- end
- self.head.mousereleased = function(self, x, y, button)
- if button == left then
- self.selected = false
- pop_ref.focused = false
- return true
- end
- return false
- end
- end,
- __base = _base_0,
- __name = "window",
- __parent = _parent_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, ...)
- local _self_0 = setmetatable({}, _base_0)
- cls.__init(_self_0, ...)
- return _self_0
- end
- })
- _base_0.__class = _class_0
- if _parent_0.__inherited then
- _parent_0.__inherited(_parent_0, _class_0)
- end
- window = _class_0
- return _class_0
-end
diff --git a/demo/pop/extensions/streamlined_get_set.lua b/demo/pop/extensions/streamlined_get_set.lua
deleted file mode 100644
index c958a9b..0000000
--- a/demo/pop/extensions/streamlined_get_set.lua
+++ /dev/null
@@ -1,102 +0,0 @@
-local graphics
-graphics = love.graphics
-local sub, len
-do
- local _obj_0 = string
- sub, len = _obj_0.sub, _obj_0.len
-end
-local path = sub(..., 1, len(...) - len("/extensions/streamlined_get_set"))
-local element = require(tostring(path) .. "/elements/element")
-local box = require(tostring(path) .. "/elements/box")
-local text = require(tostring(path) .. "/elements/text")
-element.__base.position = function(self, x, y)
- if x or y then
- return self:setPosition(x, y)
- else
- return self:getPosition()
- end
-end
-element.__base.size = function(self, w, h)
- if w or h then
- return self:setSize(w, h)
- else
- return self:getSize()
- end
-end
-element.__base.width = function(self, w)
- if w then
- return self:setWidth(w)
- else
- return self:getWidth()
- end
-end
-element.__base.height = function(self, h)
- if h then
- return self:setHeight(h)
- else
- return self:getHeight()
- end
-end
-element.__base.alignment = function(self, horizontal, vertical)
- if horizontal or vertical then
- return self:setAlignment(horizontal, vertical)
- else
- return self:getAlignment()
- end
-end
-element.__base.margin = function(self, m)
- if m then
- return self:setMargin(m)
- else
- return self:getMargin()
- end
-end
-element.__base.resize = element.__base.adjustSize
-element.__base.visibility = function(self, v)
- if v ~= nil then
- return self:setVisibility(v)
- else
- return self:getVisibility()
- end
-end
-element.__base.show = function(self)
- return self:setVisibility(true)
-end
-element.__base.hide = function(self)
- return self:setVisibility(false)
-end
-element.__base.static = function(self, s)
- if s ~= nil then
- return self:setStatic(s)
- else
- return self:getStatic()
- end
-end
-box.__base.color = function(self, r, g, b, a)
- if r or g or b or a then
- return self:setColor(r, g, b, a)
- else
- return self:getColor()
- end
-end
-text.__base.text = function(self, text)
- if text then
- return self:setText(text)
- else
- return self:getText()
- end
-end
-text.__base.font = function(self, font)
- if font then
- return self:setFont(font)
- else
- return self:getFont()
- end
-end
-text.__base.color = function(self, r, g, b, a)
- if r or g or b or a then
- return self:setColor(r, g, b, a)
- else
- return self:getColor()
- end
-end
diff --git a/demo/pop/init.lua b/demo/pop/init.lua
deleted file mode 100644
index 27eb383..0000000
--- a/demo/pop/init.lua
+++ /dev/null
@@ -1,291 +0,0 @@
-local pop = {
- _VERSION = 'Pop.Box v0.0.0',
- _DESCRIPTION = 'GUI library for LOVE, designed for ease of use',
- _URL = 'http://github.com/Guard13007/Pop.Box',
- _LICENSE = 'The MIT License (MIT)',
- _AUTHOR = 'Paul Liverman III'
-}
-if not (love.getVersion) then
- error("Pop.Box only supports LOVE versions >= 0.9.1")
-end
-local filesystem, graphics
-do
- local _obj_0 = love
- filesystem, graphics = _obj_0.filesystem, _obj_0.graphics
-end
-local insert
-insert = table.insert
-local inheritsFromElement
-inheritsFromElement = require(tostring(...) .. "/util").inheritsFromElement
-local path = ...
-pop.elements = { }
-pop.skins = { }
-pop.screen = false
-pop.focused = false
-pop.load = function()
- local elements = filesystem.getDirectoryItems(tostring(path) .. "/elements")
- for i = 1, #elements do
- local _continue_0 = false
- repeat
- if not (elements[i]:sub(-4) == ".lua") then
- _continue_0 = true
- break
- end
- local name = elements[i]:sub(1, -5)
- pop.elements[name] = require(tostring(path) .. "/elements/" .. tostring(name))
- if pop.elements[name].load then
- pop.elements[name].load(pop)
- end
- print("element loaded: \"" .. tostring(name) .. "\"")
- if not (pop[name]) then
- if pop.elements[name].wrap then
- pop[name] = pop.elements[name].wrap(pop)
- else
- pop[name] = function(...)
- return pop.create(name, ...)
- end
- end
- print("wrapper created: \"pop." .. tostring(name) .. "()\"")
- end
- _continue_0 = true
- until true
- if not _continue_0 then
- break
- end
- end
- local skins = filesystem.getDirectoryItems(tostring(path) .. "/skins")
- for i = 1, #skins do
- local _continue_0 = false
- repeat
- if not (skins[i]:sub(-4) == ".lua") then
- _continue_0 = true
- break
- end
- local name = skins[i]:sub(1, -5)
- pop.skins[name] = require(tostring(path) .. "/skins/" .. tostring(name))
- print("skin loaded: \"" .. tostring(name) .. "\"")
- _continue_0 = true
- until true
- if not _continue_0 then
- break
- end
- end
- local extensions = filesystem.getDirectoryItems(tostring(path) .. "/extensions")
- for i = 1, #extensions do
- local _continue_0 = false
- repeat
- if not (extensions[i]:sub(-4) == ".lua") then
- _continue_0 = true
- break
- end
- local name = extensions[i]:sub(1, -5)
- require(tostring(path) .. "/extensions/" .. tostring(name))
- print("extension loaded: \"" .. tostring(name) .. "\"")
- _continue_0 = true
- until true
- if not _continue_0 then
- break
- end
- end
- pop.screen = pop.create("element", false):setSize(graphics.getWidth(), graphics.getHeight())
- return print("created \"pop.screen\"")
-end
-pop.create = function(element, parent, ...)
- if parent == nil then
- parent = pop.screen
- end
- if inheritsFromElement(parent) then
- element = pop.elements[element](parent, ...)
- insert(parent.child, element)
- elseif parent == false then
- element = pop.elements[element](false, ...)
- else
- element = pop.elements[element](pop.screen, parent, ...)
- insert(pop.screen.child, element)
- end
- return element
-end
-pop.update = function(dt, element)
- if element == nil then
- element = pop.screen
- end
- if not (element.excludeUpdate) then
- if element.update then
- element:update(dt)
- end
- for i = 1, #element.child do
- pop.update(dt, element.child[i])
- end
- end
-end
-pop.draw = function(element)
- if element == nil then
- element = pop.screen
- end
- if not (element.excludeDraw) then
- if element.draw then
- element:draw()
- end
- for i = 1, #element.child do
- pop.draw(element.child[i])
- end
- end
-end
-pop.mousemoved = function(x, y, dx, dy)
- if pop.focused and pop.focused.mousemoved then
- return pop.focused:mousemoved(x, y, dx, dy)
- end
- return false
-end
-pop.mousepressed = function(x, y, button, element)
- if not (element) then
- print("mousepressed", x, y, button)
- element = pop.screen
- end
- local handled = false
- if (x >= element.x) and (x <= element.x + element.w) and (y >= element.y) and (y <= element.y + element.h) then
- for i = #element.child, 1, -1 do
- do
- handled = pop.mousepressed(x, y, button, element.child[i])
- if handled then
- return handled
- end
- end
- end
- if not (handled) then
- if element.mousepressed and (not element.excludeDraw) then
- do
- handled = element:mousepressed(x - element.x, y - element.y, button)
- if handled then
- pop.focused = element
- end
- end
- end
- end
- end
- return handled
-end
-pop.mousereleased = function(x, y, button, element)
- local clickedHandled = false
- local mousereleasedHandled = false
- if element then
- if (x >= element.x) and (x <= element.x + element.w) and (y >= element.y) and (y <= element.y + element.h) then
- for i = #element.child, 1, -1 do
- clickedHandled, mousereleasedHandled = pop.mousereleased(x, y, button, element.child[i])
- if clickedHandled or mousereleasedHandled then
- return clickedHandled, mousereleasedHandled
- end
- end
- if not (clickedHandled or mousereleasedHandled) then
- if element.clicked and (not element.excludeDraw) then
- clickedHandled = element:clicked(x - element.x, y - element.y, button)
- end
- if element.mousereleased then
- mousereleasedHandled = element:mousereleased(x - element.x, y - element.y, button)
- end
- if clickedHandled then
- pop.focused = element
- end
- end
- end
- else
- print("mousereleased", x, y, button)
- pop.mousereleased(x, y, button, pop.screen)
- end
- return clickedHandled, mousereleasedHandled
-end
-pop.keypressed = function(key)
- print("keypressed", key)
- local element = pop.focused
- if element and element.keypressed and (not element.excludeDraw) then
- return element.keypressed(key)
- end
- return false
-end
-pop.keyreleased = function(key)
- print("keyreleased", key)
- local element = pop.focused
- if element and element.keyreleased then
- return element.keyreleased(key)
- end
- return false
-end
-pop.textinput = function(text)
- print("textinput", text)
- local element = pop.focused
- if element and element.textinput and (not element.excludeDraw) then
- return element.textinput(text)
- end
- return false
-end
-pop.skin = function(element, skin, depth)
- if element == nil then
- element = pop.screen
- end
- if skin == nil then
- skin = pop.skins.default
- end
- if element.background and skin.background then
- element.background = skin.background
- end
- if element.color and skin.color then
- element.color = skin.color
- end
- if element.font and skin.font then
- element.font = skin.font
- end
- if not (depth or (depth == 0)) then
- if depth == tonumber(depth) then
- for i = 1, #element.child do
- pop.skin(element.child[i], skin, depth - 1)
- end
- else
- for i = 1, #element.child do
- pop.skin(element.child[i], skin, false)
- end
- end
- end
-end
-pop.debugDraw = function(element)
- if element == nil then
- element = pop.screen
- end
- if element.debugDraw then
- element:debugDraw()
- else
- graphics.setLineWidth(1)
- graphics.setLineColor(0, 0, 0, 100)
- graphics.rectangle("fill", element.x, element.y, element.w, element.h)
- graphics.setColor(150, 150, 150, 150)
- graphics.rectangle("line", element.x, element.y, element.w, element.h)
- graphics.setColor(200, 200, 200, 255)
- graphics.print(".", element.x, element.y)
- end
- for i = 1, #element.child do
- pop.debugDraw(element.child[i])
- end
-end
-pop.printElementTree = function(element, depth)
- if element == nil then
- element = pop.screen
- end
- if depth == nil then
- depth = 0
- end
- local cls = element.__class.__name
- if cls == "text" then
- cls = cls .. " (\"" .. tostring(element:getText():gsub("\n", "\\n")) .. "\")"
- elseif cls == "box" then
- local bg = element:getBackground()
- if type(bg) == "table" then
- bg = tostring(bg[1]) .. ", " .. tostring(bg[2]) .. ", " .. tostring(bg[3]) .. ", " .. tostring(bg[4])
- end
- cls = cls .. " (" .. tostring(bg) .. ")"
- end
- print(string.rep("-", depth) .. " " .. tostring(cls))
- for i = 1, #element.child do
- pop.printElementStack(element.child[i], depth + 1)
- end
-end
-pop.load()
-return pop
diff --git a/demo/pop/skins/default.lua b/demo/pop/skins/default.lua
deleted file mode 100644
index 299adb2..0000000
--- a/demo/pop/skins/default.lua
+++ /dev/null
@@ -1,17 +0,0 @@
-local graphics
-graphics = love.graphics
-return {
- background = {
- 0,
- 0,
- 0,
- 220
- },
- color = {
- 255,
- 255,
- 255,
- 250
- },
- font = graphics.newFont(14)
-}
diff --git a/demo/pop/util.lua b/demo/pop/util.lua
deleted file mode 100644
index 0804d8b..0000000
--- a/demo/pop/util.lua
+++ /dev/null
@@ -1,19 +0,0 @@
-local inheritsFromElement
-inheritsFromElement = function(object)
- if object and object.__class then
- local cls = object.__class
- if cls.__name == "element" then
- return true
- end
- while cls.__parent do
- cls = cls.__parent
- if cls.__name == "element" then
- return true
- end
- end
- end
- return false
-end
-return {
- inheritsFromElement = inheritsFromElement
-}
diff --git a/demo/test.ogv b/demo/test.ogv
deleted file mode 100644
index 1dcdf39..0000000
Binary files a/demo/test.ogv and /dev/null differ
diff --git a/demo/test.png b/demo/test.png
deleted file mode 100644
index bf19d3b..0000000
Binary files a/demo/test.png and /dev/null differ
diff --git a/docs/Drawables.md b/docs/Drawables.md
deleted file mode 100644
index 3db65da..0000000
--- a/docs/Drawables.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# Supported Drawables
-
-Pop.Box supports three [Drawables][1]: Canvas, Image, and Video.
-
-**Note**: Video and Canvas support are untested.
-
-Additionally, in the place of a Drawable, you can use `false` to not render
-anything, or a table of color values. The color values should be in the format
-LÖVE uses (`{red, green, blue, alpha}`, see [love.graphics.setColor][2]).
-
-(The alpha value is optional, but not using an alpha is likely to mess up your
- rendering if an alpha is used *anywhere else*.)
-
-[1]: https://love2d.org/wiki/Drawable
-[2]: https://love2d.org/wiki/love.graphics.setColor
diff --git a/docs/Elements.md b/docs/Elements.md
deleted file mode 100644
index 20be594..0000000
--- a/docs/Elements.md
+++ /dev/null
@@ -1,31 +0,0 @@
-# Elements
-
-Elements are the core of Pop.Box.
-
-Once `pop` has been required, you can create elements and interact with them.
-Most elements can be created like this: `local box = pop.box(...)`
-
-However, if an element's name clashes with a function name used in Pop.Box, you
-will have to use `pop.create(type, ...)` where `type` is a string naming the
-element type. (No standard elements do this.)
-
-When creating an element, the first argument is its parent element. If the first
-argument is not an element, it will be treated as the second argument. If it is
-`false`, then an element with no parent will be created.
-
-When no parent is specified, an element's parent is `pop.screen`, which is the
-top-level element of Pop.Box. (This behavior can be modified by custom elements,
-so check their documentation.)
-
-## Available Elements
-
-- [Element][1] (The base of all elements, and useful for alignment.)
-- [Box][2] (A box, can be colored, or display a [supported Drawable][3].)
-- [Text][4] (Plain text, no special features. Useful for basic labels and such.)
-- [Window][5] (A movable window. Has a title and area for other elements.)
-
-[1]: ./elements/element.md
-[2]: ./elements/box.md
-[3]: ./Drawables.md
-[4]: ./elements/text.md
-[5]: ./elements/window.md
diff --git a/docs/Excludes.md b/docs/Excludes.md
deleted file mode 100644
index d31e27d..0000000
--- a/docs/Excludes.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# Excludes
-
-Any element can have a few boolean values set to exclude it from normal
-operations for movement, rendering, and updating. Simply set the appropriate
-value to a true value.
-
-Note that any element using one of these excludes its children as well.
-
-- `excludeMovement` Excludes movement caused by a parent being moved.
-- `excludeUpdate` Excludes an element from being updated (by `pop.update()`).
-- `excludeDraw` Excludes being rendered (by `pop.draw()`).
-
-**Note**: `excludeDraw` also excludes an element from accepting the following
-events:
-
-- `mousepressed`
-- `clicked`
-- `keypressed`
-- `textinput`
-
-The reason for this is that it wouldn't make sense for an invisible element to
-be capturing input. However, some events are passed through in case an element
-becomes invisible while processing input.
diff --git a/docs/Extensions.md b/docs/Extensions.md
deleted file mode 100644
index 778c7b4..0000000
--- a/docs/Extensions.md
+++ /dev/null
@@ -1,14 +0,0 @@
-# Extensions
-
-Extensions are simply a way for custom code to be run after loading elements and
-skins. Simply place a `.lua` file in the `extensions` directory, and it will be
-required.
-
-## Standard Extensions
-
-There is only one standard extension, which modifies element classes to add a
-more convenient getter/setter method to most get/set methods. For example,
-instead of `element:getSize()`, just call `element:size()`. Instead of
-`element:setSize(w, h)`, call `element:size(w, h)`.
-
-This is mostly for a demo of what can be possible, but also might be useful.
diff --git a/docs/Pop.md b/docs/Pop.md
deleted file mode 100644
index 79d1b69..0000000
--- a/docs/Pop.md
+++ /dev/null
@@ -1,54 +0,0 @@
-# Pop Module
-
-This is the main module that allows you to access everything else in Pop.Box.
-Simply require it (`local pop = require "pop"`) and define LÖVE callbacks for:
-
-- `pop.update(dt)`
-- `pop.draw()`
-- `pop.mousemoved(x, y, dx, dy)` (when using LÖVE 0.10.0 or later)
-- `pop.mousepressed(x, y, button)`
-- `pop.mousereleased(x, y, button)`
-- `pop.keypressed(key)`
-- `pop.keyreleased(key)`
-- `pop.textinput(text)`
-
-Every callback returns `true`/`false` for whether or not the event was handled.
-For example, using the `mousepressed` event handler:
-
-```lua
-function love.mousepressed(x, y, button)
- local handled = pop.mousepressed(x, y, button)
- if not handled then
- -- do something useful
- end
-end
-```
-
-## Creating Elements
-
-Once `pop` has been required, you can create [Elements][1] and interact with
-them. Most elements can be created like this: `local box = pop.box(...)`
-
-For more information, see the [Elements documentation][1].
-
-## Skinning Elements
-
-See the [Skins][2] documentation.
-
-## Custom Elements/Skins/Extensions
-
-Any `.lua` file placed in the `elements`, `skins`, and `extensions` directories
-within the module will be loaded and available as appropriate. See the
-documentation on each for how to make them:
-
-- [Elements][1]
-- [Skins][2]
-- [Extensions][3]
-
-Also of use, there is a separate set of docs about how Pop.Box works under the
-surface: [Pop Module (dev)][4]
-
-[1]: ./Elements.md
-[2]: ./Skins.md
-[3]: ./Extensions.md
-[4]: ./dev/Pop.md
diff --git a/docs/Skins.md b/docs/Skins.md
deleted file mode 100644
index 9b3bae4..0000000
--- a/docs/Skins.md
+++ /dev/null
@@ -1,37 +0,0 @@
-# Skins
-
-**Note**: This system is mostly an after-thought right now, and will probably
-be replaced with something else entirely.
-
-Skins are simple tables containing information to style a variety of elements.
-Use `pop.skin()` to apply a skin to an element and its children. Skins are
-loaded from the `skins` directory.
-
-**Note**: Skins are only applied on elements as-is. You can't change elements
-added in the future by setting a skin, or change a skin to modify elements that
-have had it applied. In the future, I might change this. (This skinning system
-is basically a placeholder.)
-
-Usage: `pop.skin(element, skin, depth)`
-
-- `element` is the element to start with.
-- `skin` is the skin (a table).
-- `depth` is how many levels of children of the element should be skinned.
- Defaults to skinning as many levels of children as there are.
-
-Alternately, you can think of depth as a boolean for "don't recurse". By
-setting it to `true`, you can stop skinning children. `false` (and default
-behavior) will skin all levels of children.
-
-## What's inside a skin
-
-- `color` - A table of RGBA values (see [love.graphics.setColor][2]), used as a
- foreground color (currently for `text` elements only).
-- `background` - A [supported Drawable][4], used for backgrounds (currently
- used on `box` elements only).
-- `font` - A [Font][5].
-
-[2]: https://love2d.org/wiki/love.graphics.setColor
-[3]: ./Pop.md
-[4]: ./Drawables.md
-[5]: https://love2d.org/wiki/Font
diff --git a/docs/dev/Pop.md b/docs/dev/Pop.md
deleted file mode 100644
index 63e6666..0000000
--- a/docs/dev/Pop.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# Pop Module (dev)
-
-(This document focuses on the structure and code of Pop.Box, not how to use it.
- See the [regular documentation][1] for that.)
-
-TODO: Write me.
-
-## Notes
-
-- `pop.mousereleased()` Handling a click maybe should *not* check bounds.
- Handling a mouse release should maybe *not* check for `excludeDraw`. If an
- element was already selected and then went invisible, I'm probably breaking
- things worse by doing this. This has been changed.
-
-[1]: ../Pop.md
diff --git a/docs/dev/elements/window.md b/docs/dev/elements/window.md
deleted file mode 100644
index 354df90..0000000
--- a/docs/dev/elements/window.md
+++ /dev/null
@@ -1,4 +0,0 @@
-- `addChild()` Adds children to `@window` instead of itself. This may cause
- issues with expectation vs result. A user expects when using `addChild()` that
- an element will be a direct child of `window`, not that it will end up in a
- sub-element.
diff --git a/docs/elements/box.md b/docs/elements/box.md
deleted file mode 100644
index e2ec304..0000000
--- a/docs/elements/box.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# box
-
-The box element is a rectangle that has a [supported Drawable][1] as its
-background.
-
-## Methods
-
-- `setBackground(background)` Using a supported Drawable (see above), set the
- background.
-- `getBackground()` Returns the background in use.
-- `setColor(red, green, blue, alpha)` Sets the background to the specified
- color. `alpha` is optional and defaults to `255`. Alternately, pass a table of
- color values (ex: `{red, green, blue, alpha}`).
-- `getColor()` Returns red, green, blue, and alpha color values of background.
- Errors if the background is not a color.
-
-[1]: ../Drawables.md
diff --git a/docs/elements/element.md b/docs/elements/element.md
deleted file mode 100644
index e6e67a6..0000000
--- a/docs/elements/element.md
+++ /dev/null
@@ -1,62 +0,0 @@
-# element
-
-This is the base of all elements, and useful for alignment purposes. It is also
-the element type used for `pop.screen` (the top-level element of Pop.Box). All
-methods here are available on all other elements (any differences are noted on
-their documentation pages).
-
-## Alignment
-
-All elements have a `horizontal` and `vertical` alignment property. These modify
-how elements are aligned and how positions are handled. For example, an element
-aligned to the top-right will return the position of the top-right corner when
-calling `getPosition()`.
-
-- `horizontal` can be `left`, `center`, or `right`. Defaults to `left`.
-- `vertical` can be `top`, `center`, or `bottom`. Defaults to `top`.
-
-## Methods
-
-Every method that does not return a value returns the element itself, so that
-you can chain method calls (ex: `box:setSize(100, 50):align("right")`).
-
-- `addChild(child)` Adds a child element.
-- `removeChild(child)` Removes child element by reference or index. If `child`
- is a number, it will return the child at that index (after removing it).
-- `getChildren()` Returns a numerically indexed table of child elements.
-- `move(x, y)` Moves the element (and its children) by specified values.
- Parameters optional. (Children can exclude being moved with their parent. See
- [Excludes][1].)
-- `setPosition(x, y)` Sets position of the element (and its children) based on
- the alignment of the element. Parameters optional. (Children can exclude being
- moved with their parent. See [Excludes][1].)
-- `getPosition()` Returns x/y position of the element based on its alignment.
-- `setSize(w, h)` Sets the width/height of the element, element keeps "in-place"
- based on its alignment. (For example, a right-aligned element will grow to the
- left.) Parameters optional.
-- `getSize()` Returns the width/height of the element.
-- `setWidth(w)` Sets the width of the element. Element stays "in-place" based on
- its alignment.
-- `getWidth()` Returns the width of the element.
-- `setHeight(h)` Sets the height of the element. Element stays "in-place" based
- on its alignment.
-- `getHeight()` Returns the height of the element.
-- `adjustSize(w, h)` Grows the element by a relative width/height. Element stays
- "in-place" based on its alignment.
-- `align(horizontal, vertical, toPixel)` Aligns the element based on its margin
- and parent. `toPixel` is a boolean for pixel-perfect alignment, defaulting to
- `true`. See above section about alignment for valid values of `horizontal` and
- `vertical`. A parent element is required for this method.
-- `alignTo(element, horizontal, vertical, toPixel)` Works just like `align()`,
- except that alignment is based on a specific element instead of the parent.
- Does not require a parent element.
-- `setAlignment(horizontal, vertical)` Sets alignment values on the element
- *without* moving the element.
-- `getAlignment()` Returns the `horizontal` and `vertical` alignment of the
- element.
-- `setMargin(m)` Sets a margin to be used when aligning the element.
-- `getMargin()` Returns the current margin value.
-- `fill()` Resizes and aligns the element to fill its parent's area, with the
- element's margin taken into account on all sides.
-
-[1]: ../Excludes.md
diff --git a/docs/elements/text.md b/docs/elements/text.md
deleted file mode 100644
index fd68c2b..0000000
--- a/docs/elements/text.md
+++ /dev/null
@@ -1,22 +0,0 @@
-# text
-
-The text element is plain text in one color. Nothing special.
-
-(**Note**: Other, more advanced text elements are planned, with support for
- things like line-wrapping and custom coloring and formatting of text.)
-
-## Methods
-
-- `setSize()` Unlike other elements, a size cannot be set. If this is called, it
- will fix the size of the text if it somehow was modified incorrectly.
-- `setWidth()` Width cannot be set. If called, will fix the size of the text.
-- `setHeight()` Height cannot be set. If called, will fix the size of the text.
-- `setText(text)` Sets the text of the element. Will resize element to fit text.
- Newlines are supported. Defaults to an empty string.
-- `getText()` Returns the text of the element.
-- `setFont()` Sets the font to be used on this element. Will resize to fit the
- text and font.
-- `setColor(red, green, blue, alpha)` Sets color of text. `alpha` is optional
- and defaults to `255`. Alternately, pass a table of color values (ex: `{red,
- green, blue, alpha}`).
-- `getColor()` Returns red, green, blue, and alpha values of color.
diff --git a/docs/elements/window.md b/docs/elements/window.md
deleted file mode 100644
index dc443bd..0000000
--- a/docs/elements/window.md
+++ /dev/null
@@ -1,4 +0,0 @@
-# window
-
-Documentation has not been written yet, as this element is still under heavy
-development.
diff --git a/docs/index.html b/docs/index.html
new file mode 100644
index 0000000..fa5a30e
--- /dev/null
+++ b/docs/index.html
@@ -0,0 +1,65 @@
+
+
+
+
+ Documentation
+
+
+
+
+
Implement a way for an element to attach itself to love.mousemoved() events?
+
+
+
+
+
+
+
+
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.
+
+
+
+
+
+
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.)
+
+ 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?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2016-06-20 22:28:27
+