diff --git a/demo/main.lua b/demo/main.lua index e857148..521b2a3 100644 --- a/demo/main.lua +++ b/demo/main.lua @@ -57,7 +57,9 @@ function love.load() print(b.horizontal, b.vertical) print(c.horizontal, c.vertical) - --TODO make rounding to nearest pixel DEFAULT BEHAVIOR + local window = pop.window():align("center", "center"):setTitle("Welcome!") + --window:addChild(pop.text("Welcome to Pop.Box()!")) + --TODO make debugDraw better end diff --git a/demo/pop/elements/element.lua b/demo/pop/elements/element.lua index 8af555a..e0d5301 100644 --- a/demo/pop/elements/element.lua +++ b/demo/pop/elements/element.lua @@ -21,6 +21,9 @@ do child.parent = self return self end, + getChildren = function(self) + return self.child + end, move = function(self, x, y) if x then self.x = self.x + x diff --git a/demo/pop/elements/window.lua b/demo/pop/elements/window.lua index f791a16..57ea9df 100644 --- a/demo/pop/elements/window.lua +++ b/demo/pop/elements/window.lua @@ -44,6 +44,14 @@ do graphics.print("w", self.x, self.y) return self end, + addChild = function(self, child) + self.window.child[#self.window.child + 1] = child + child.parent = self.window + return self + end, + getChildren = function(self) + return self.window.child + end, setSize = function(self, w, h) local x = 0 local y = 0 @@ -109,6 +117,10 @@ do self.title:move(nil, y) self.window:move(nil, y) return self + end, + setTitle = function(self, title) + self.title:setText(title) + return self end } _base_0.__index = _base_0 diff --git a/lib/pop/elements/element.lua b/lib/pop/elements/element.lua index 8af555a..e0d5301 100644 --- a/lib/pop/elements/element.lua +++ b/lib/pop/elements/element.lua @@ -21,6 +21,9 @@ do child.parent = self return self end, + getChildren = function(self) + return self.child + end, move = function(self, x, y) if x then self.x = self.x + x diff --git a/lib/pop/elements/window.lua b/lib/pop/elements/window.lua index f791a16..57ea9df 100644 --- a/lib/pop/elements/window.lua +++ b/lib/pop/elements/window.lua @@ -44,6 +44,14 @@ do graphics.print("w", self.x, self.y) return self end, + addChild = function(self, child) + self.window.child[#self.window.child + 1] = child + child.parent = self.window + return self + end, + getChildren = function(self) + return self.window.child + end, setSize = function(self, w, h) local x = 0 local y = 0 @@ -109,6 +117,10 @@ do self.title:move(nil, y) self.window:move(nil, y) return self + end, + setTitle = function(self, title) + self.title:setText(title) + return self end } _base_0.__index = _base_0 diff --git a/src/pop/elements/window.moon b/src/pop/elements/window.moon index 2447ec0..4eb7787 100644 --- a/src/pop/elements/window.moon +++ b/src/pop/elements/window.moon @@ -207,3 +207,7 @@ class window extends element @window\move nil, y return @ + + setTitle: (title) => + @title\setText title + return @