more improvements/changes!

This commit is contained in:
Paul Liverman III 2017-04-10 20:32:31 -07:00
parent d589e1440b
commit e895e83ec4
11 changed files with 62 additions and 48 deletions

View File

@ -456,7 +456,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2017-04-09 18:24:55 </i>
<i style="float:right;">Last updated 2017-04-10 20:32:12 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -144,7 +144,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2017-04-09 18:24:55 </i>
<i style="float:right;">Last updated 2017-04-10 20:32:12 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -84,7 +84,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2017-04-09 18:24:55 </i>
<i style="float:right;">Last updated 2017-04-10 20:32:12 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -491,7 +491,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2017-04-09 18:24:55 </i>
<i style="float:right;">Last updated 2017-04-10 20:32:12 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -105,7 +105,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2017-04-09 18:24:55 </i>
<i style="float:right;">Last updated 2017-04-10 20:32:12 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -159,7 +159,7 @@ table.insert element.parent, element.parent\removeChild(element),</td>
</tr>
<tr>
<td class="name" nowrap><a href="#printElementTree-todo6">printElementTree-todo6</a></td>
<td class="summary">Correct this once elements are reimplemented if it needs correction.</td>
<td class="summary">Write debugInfo things for elements.</td>
</tr>
</table>
@ -707,7 +707,7 @@ table.insert element.parent, element.parent\removeChild(element),
<strong>printElementTree-todo6</strong>
</dt>
<dd>
Correct this once elements are reimplemented if it needs correction.
Write debugInfo things for elements.
@ -723,7 +723,7 @@ table.insert element.parent, element.parent\removeChild(element),
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2017-04-09 18:24:55 </i>
<i style="float:right;">Last updated 2017-04-10 20:32:12 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -126,7 +126,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2017-04-09 18:24:55 </i>
<i style="float:right;">Last updated 2017-04-10 20:32:12 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -53,6 +53,7 @@ do
if toPixel == nil then
toPixel = true
end
local dx, dy = self.data.x, self.data.y
if x then
self.data.x = x
end
@ -75,6 +76,13 @@ do
self.data.x = floor(self.data.x)
self.data.y = floor(self.data.y)
end
dx = self.data.x - dx
dy = self.data.y - dy
local _list_0 = self.child
for _index_0 = 1, #_list_0 do
local child = _list_0[_index_0]
child:move(dx, dy)
end
return self
end,
setSize = function(self, w, h)
@ -111,6 +119,11 @@ do
if y == nil then
y = 0
end
local _list_0 = self.child
for _index_0 = 1, #_list_0 do
local child = _list_0[_index_0]
child:move(x, y)
end
self.data.x = self.data.x + x
self.data.y = self.data.y + y
return self

View File

@ -75,9 +75,13 @@ class element
--- @todo document this
setPosition: (x, y, toPixel=true) =>
dx, dy = @data.x, @data.y
if x
--dx = x - @data.x
@data.x = x
if y
--dy = y - @data.y
@data.y = y
switch @data.horizontal
@ -96,6 +100,12 @@ class element
@data.x = floor @data.x
@data.y = floor @data.y
-- new minus old is difference that children need to be moved
dx = @data.x - dx
dy = @data.y - dy
for child in *@child
child\move dx, dy
return @
--- Sets an element's width/height. Fixes alignment if needed.
@ -145,6 +155,9 @@ class element
--- Moves an element by specified x/y.
--- @treturn element self
move: (x=0, y=0) =>
for child in *@child
child\move x, y
@data.x += x
@data.y += y
return @

View File

@ -256,7 +256,7 @@ pop.mousereleased = function(x, y, button, element)
local clickedHandled = false
local mousereleasedHandled = false
if element then
if (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) then
if element.data.draw and (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) then
for i = #element.child, 1, -1 do
clickedHandled, mousereleasedHandled = pop.mousereleased(x, y, button, element.child[i])
if clickedHandled or mousereleasedHandled then
@ -331,16 +331,16 @@ pop.debugDraw = function(element)
if element == nil then
element = pop.screen
end
if element.debugDraw then
element:debugDraw()
else
graphics.setLineWidth(1)
graphics.setColor(0, 0, 0, 100)
graphics.rectangle("fill", element.data.x, element.data.y, element.data.w, element.data.h)
graphics.setColor(150, 150, 150, 150)
graphics.rectangle("line", element.data.x, element.data.y, element.data.w, element.data.h)
graphics.setColor(200, 200, 200, 255)
graphics.print(".", element.data.x, element.data.y)
if element.debugInfo then
graphics.print(tostring(element.__class.__name:sub(1, 1)) .. " (" .. tostring(element:debugInfo()) .. ")", element.data.x, element.data.y)
else
graphics.print(tostring(element.__class.__name:sub(1, 1)), element.data.x, element.data.y)
end
for i = 1, #element.child do
pop.debugDraw(element.child[i])
@ -354,14 +354,8 @@ pop.printElementTree = function(element, depth)
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) .. ")"
if element.debugInfo then
cls = tostring(cls) .. " (" .. tostring(element:debugInfo()) .. ")"
end
if depth > 0 then
log(string.rep("-", depth) .. " " .. tostring(cls))

View File

@ -341,7 +341,7 @@ pop.mousereleased = (x, y, button, element) ->
-- if we have an element, and are within its bounds
if element
if (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h)
if element.data.draw and (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h)
-- check its children in reverse for handling a clicked or mousereleased event
for i = #element.child, 1, -1
clickedHandled, mousereleasedHandled = pop.mousereleased x, y, button, element.child[i]
@ -456,17 +456,18 @@ pop.export = (element=pop.screen) ->
--- @see Element
pop.debugDraw = (element=pop.screen) ->
--@todo Make this better in the future when different element types have been created and whatnot.
if element.debugDraw
element\debugDraw!
else
--@todo Remove element.debugDraw functions.
graphics.setLineWidth 1
graphics.setColor 0, 0, 0, 100
graphics.rectangle "fill", element.data.x, element.data.y, element.data.w, element.data.h
graphics.setColor 150, 150, 150, 150
graphics.rectangle "line", element.data.x, element.data.y, element.data.w, element.data.h
graphics.setColor 200, 200, 200, 255
graphics.print ".", element.data.x, element.data.y
if element.debugInfo
graphics.print "#{element.__class.__name\sub 1, 1} (#{element\debugInfo!})", element.data.x, element.data.y
else
graphics.print "#{element.__class.__name\sub 1, 1}", element.data.x, element.data.y
for i = 1, #element.child
pop.debugDraw element.child[i]
@ -480,18 +481,11 @@ pop.debugDraw = (element=pop.screen) ->
--- @see Element
pop.printElementTree = (element=pop.screen, depth=0) ->
--- @todo Correct this once elements are reimplemented if it needs correction.
--- @todo Write debugInfo things for elements.
cls = element.__class.__name
if cls == "text"
cls = cls .. " (\"#{element\getText!\gsub "\n", "\\n"}\")"
elseif cls == "box"
bg = element\getBackground!
if type(bg) == "table"
bg = "#{bg[1]}, #{bg[2]}, #{bg[3]}, #{bg[4]}"
cls = cls .. " (#{bg})"
if element.debugInfo
cls = "#{cls} (#{element\debugInfo!})"
if depth > 0
log string.rep("-", depth) .. " #{cls}"