wip shit probably broken

This commit is contained in:
Fox 2016-03-31 16:19:52 -07:00
parent 40ab56437d
commit 59842a2a3d
4 changed files with 50 additions and 3 deletions

View File

@ -5,6 +5,7 @@ local debugDraw = false
function love.load()
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)
@ -19,6 +20,7 @@ function love.load()
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}):setMargin(5):setSize(100, 100)
--]]
--c:move(100)
@ -39,9 +41,13 @@ function love.load()
local test = lg.newImage("test.png")
G = pop.element():align("right"):move(-2, 2)
pop.box(G, test):align("right")
pop.box(G, test):align("right"):move(-25):setWidth(40)
pop.box(G, test):align("right"):move(0, 25):setHeight(40)
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)
--TODO make rounding to nearest pixel DEFAULT BEHAVIOR
--TODO make debugDraw better

34
dummy/main.lua Normal file
View File

@ -0,0 +1,34 @@
local lg = love.graphics
local pop, parts
-- pretend parts has been defined
function love.load()
pop = require "lib.pop"
local width4 = lg.getWidth()/4
local height2 = lg.getHeight()/2
local PartList = pop.scrollbox():setSize(width4, height2)--:setSizeControl(true) --defaults to true
local PartInfo = pop.scrollbox():setSize(width4, height2):move(nil, height2)
local CraftInfo = pop.box():setSize(width4, height2):move(lg.getWidth()*3/4)
local columns = math.floor(PartList:getWidth()/128)
local rows = math.floor(#parts/columns)
local grid = pop.grid(PartList, columns, rows)
for i = 1, #parts do
-- pretend that parts.gui is a box designed to fix in here properly
grid:add(parts[i].gui) -- pretend by default, adding something to a grid like this adds it to first available spot
-- also, grids auto-resize their children
end
PartList:add(grid) -- BULLSHIT ?!
end
-- parts.gui is something like this:
gui = pop.box(newImage()) -- assumes a box can take 'userdata' as first arg and know it is an image
gui.clicked = function(x, y, button)
-- don't care about x/y
if button == "l" then --left
selected = gui.partReference -- or something
elseif button == "r" then --right
displayPartInfo() -- something happens to display it in the proper spot
end
end

View File

@ -37,6 +37,12 @@ class element
return @
addChild: (child) =>
@child[#@child+1] = child
child.parent = @
return @
move: (x, y) =>
if x
@x = @x + x

View File

@ -53,6 +53,7 @@ pop.load = ->
-- creates an element with specified parent (parent can be false)
pop.create = (element, parent=pop.screen, ...) ->
-- 1: if parent is object, use it, 2: if parent is false, use it (use false), 3: if parent is nil, use pop.screen as parent
element = pop.elements[element](parent, ...)
if parent