small changes

This commit is contained in:
Paul Liverman III 2017-04-09 02:02:14 -07:00
parent 978562774a
commit 7121cc1773
10 changed files with 144 additions and 13 deletions

View File

@ -72,6 +72,10 @@
<td class="name" nowrap><a href="#element.debugDraw-todo7">element.debugDraw-todo7</a></td>
<td class="summary">doc me</td>
</tr>
<tr>
<td class="name" nowrap><a href="#element.debugDraw-todo7-todo8">element.debugDraw-todo7-todo8</a></td>
<td class="summary">document this</td>
</tr>
</table>
<h2><a href="#Methods">Methods</a></h2>
<table class="function_list">
@ -111,6 +115,10 @@
<td class="name" nowrap><a href="#element.move">element.move (self, x, y)</a></td>
<td class="summary">Moves an element by specified x/y.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#element.delete">element.delete (self)</a></td>
<td class="summary">Deletes references to this element and then deletes it.</td>
</tr>
</table>
<br/>
@ -133,6 +141,20 @@
</dd>
<dt>
<a name = "element.debugDraw-todo7-todo8"></a>
<strong>element.debugDraw-todo7-todo8</strong>
</dt>
<dd>
document this
</dd>
</dl>
<h2 class="section-header "><a name="Methods"></a>Methods</h2>
@ -404,6 +426,28 @@
</dd>
<dt>
<a name = "element.delete"></a>
<strong>element.delete (self)</strong>
</dt>
<dd>
Deletes references to this element and then deletes it.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
</li>
</ul>
</dd>
</dl>
@ -412,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-08 17:10:29 </i>
<i style="float:right;">Last updated 2017-04-09 02:01:53 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -68,7 +68,7 @@
<h2><a href="#Issues">Issues</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#window.new-todo8">window.new-todo8</a></td>
<td class="name" nowrap><a href="#window.new-todo9">window.new-todo9</a></td>
<td class="summary">if data, do stuff about it</td>
</tr>
</table>
@ -88,8 +88,8 @@
<dl class="function">
<dt>
<a name = "window.new-todo8"></a>
<strong>window.new-todo8</strong>
<a name = "window.new-todo9"></a>
<strong>window.new-todo9</strong>
</dt>
<dd>
if data, do stuff about it
@ -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-08 17:10:29 </i>
<i style="float:right;">Last updated 2017-04-09 02:01:53 </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-08 17:10:29 </i>
<i style="float:right;">Last updated 2017-04-09 02:01:53 </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-08 17:10:29 </i>
<i style="float:right;">Last updated 2017-04-09 02:01:53 </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-08 17:10:29 </i>
<i style="float:right;">Last updated 2017-04-09 02:01:53 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -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-08 17:10:29 </i>
<i style="float:right;">Last updated 2017-04-09 02:01:53 </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-08 17:10:29 </i>
<i style="float:right;">Last updated 2017-04-09 02:01:53 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -49,6 +49,34 @@ do
end
return self
end,
setPosition = function(self, x, y, toPixel)
if toPixel == nil then
toPixel = true
end
if x then
self.data.x = x
end
if y then
self.data.y = y
end
local _exp_0 = self.data.horizontal
if "center" == _exp_0 then
self.data.x = self.data.x - (self.data.w / 2)
elseif "right" == _exp_0 then
self.data.x = self.data.x - self.data.w
end
local _exp_1 = self.data.vertical
if "center" == _exp_1 then
self.data.y = self.data.y - (self.data.h / 2)
elseif "bottom" == _exp_1 then
self.data.y = self.data.y - self.data.h
end
if toPixel then
self.data.x = floor(self.data.x)
self.data.y = floor(self.data.y)
end
return self
end,
setSize = function(self, w, h)
if w then
self.data.w = w
@ -86,6 +114,20 @@ do
self.data.x = self.data.x + x
self.data.y = self.data.y + y
return self
end,
delete = function(self)
for i = 1, #self.parent.child do
if self.parent.child[i] == self then
table.remove(self.parent.child, i)
break
end
end
for i = 1, #self.parent.data.child do
if self.parent.data.child[i] == self.data then
table.remove(self.parent.data.child, i)
break
end
end
end
}
_base_0.__index = _base_0
@ -117,7 +159,7 @@ do
self.data.h = 0
end
if self.data.update == nil then
self.data.update = false
self.data.update = true
end
if self.data.draw == nil then
self.data.draw = true

View File

@ -21,7 +21,7 @@ class element
@data.y = 0 unless @data.y
@data.w = 0 unless @data.w
@data.h = 0 unless @data.h
@data.update = false if @data.update == nil
@data.update = true if @data.update == nil
@data.draw = true if @data.draw == nil
@data.type = "element" unless @data.type
@data.align = true if (@data.align == nil) and @parent
@ -73,6 +73,31 @@ class element
return @
--- @todo document this
setPosition: (x, y, toPixel=true) =>
if x
@data.x = x
if y
@data.y = y
switch @data.horizontal
when "center"
@data.x -= @data.w / 2
when "right"
@data.x -= @data.w
switch @data.vertical
when "center"
@data.y -= @data.h / 2
when "bottom"
@data.y -= @data.h
if toPixel
@data.x = floor @data.x
@data.y = floor @data.y
return @
--- Sets an element's width/height. Fixes alignment if needed.
--- @tparam integer w[opt] Width.
--- @tparam integer h[opt] Height.
@ -123,3 +148,23 @@ class element
@data.x += x
@data.y += y
return @
--- Deletes references to this element and then deletes it.
delete: =>
--for i=1, #@child
-- @child[i]\delete!
--@data.child -- for each child, delete its parent ref!
for i=1, #@parent.child
if @parent.child[i] == @
table.remove @parent.child, i
break
for i=1, #@parent.data.child
if @parent.data.child[i] == @data
table.remove @parent.data.child, i
break
--@parent = nil
--@data.parent = nil -- really should be for all @data -> nil, and for all @ -> nil
--@ = nil

View File

@ -434,7 +434,7 @@ pop.import = (data, parent=pop.screen) ->
data = loads(data)
element = pop.create(data.type, parent, data)
else
element = pop.elements[data.type](parent, data)
element = pop.elements[data.type](parent, data) --why is it not the same as the other way?
insert parent.child, element
for i = 1, #data.child