From fc2d109b2ce67c01ca752572a2a83e6a0c4680bb Mon Sep 17 00:00:00 2001 From: Fox Date: Mon, 25 Jan 2016 19:02:17 -0800 Subject: [PATCH] more testing, thinner debug lines --- main.lua | 2 ++ pop/elements/box.lua | 2 +- pop/elements/element.lua | 2 +- pop/elements/text.lua | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/main.lua b/main.lua index f8507dc..4d5c0ac 100644 --- a/main.lua +++ b/main.lua @@ -10,6 +10,8 @@ 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) --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) end function love.update(dt) diff --git a/pop/elements/box.lua b/pop/elements/box.lua index 3dad73e..1b3ba13 100644 --- a/pop/elements/box.lua +++ b/pop/elements/box.lua @@ -31,7 +31,7 @@ function box:draw() --NOTE these ifs are probably wrong end function box:debugDraw() - lg.setLineWidth(1) + lg.setLineWidth(0.5) lg.setColor(0, 0, 0, 100) lg.rectangle("fill", self.x, self.y, self.w, self.h) lg.setColor(0, 0, 200, 200) diff --git a/pop/elements/element.lua b/pop/elements/element.lua index 42d5fa4..e6edde3 100644 --- a/pop/elements/element.lua +++ b/pop/elements/element.lua @@ -19,7 +19,7 @@ function element:initialize(pop, parent) end function element:debugDraw() - lg.setLineWidth(1) + lg.setLineWidth(0.5) lg.setColor(0, 0, 0, 100) lg.rectangle("fill", self.x, self.y, self.w, self.h) lg.setColor(0, 200, 0, 200) diff --git a/pop/elements/text.lua b/pop/elements/text.lua index f9f3385..17f210c 100644 --- a/pop/elements/text.lua +++ b/pop/elements/text.lua @@ -23,7 +23,7 @@ function text:draw() end function text:debugDraw() - lg.setLineWidth(1) + lg.setLineWidth(0.5) lg.setColor(0, 0, 0, 100) lg.rectangle("fill", self.x, self.y, self.w, self.h) lg.setColor(200, 0, 0, 200) @@ -34,7 +34,7 @@ end function text:setSize() local w = self.font:getWidth(self.text) - local h = self.font:getHeight() + local h = self.font:getHeight() * (select(2, self.text:gsub("\n", "\n")) + 1) if self.horizontal == "center" then self.x = self.x - (w - self.w)/2