close #27 @window -> @area in window elements

This commit is contained in:
Paul Liverman III 2016-04-20 14:12:53 -07:00
parent 441e0647b8
commit fec58c231d

View File

@ -37,28 +37,28 @@ class window extends element
-- NOTE @title having @head as its parent might break things horribly -- NOTE @title having @head as its parent might break things horribly
@head = box @, tBackground -- title box at top @head = box @, tBackground -- title box at top
@title = text @head, title, tColor -- text at top @title = text @head, title, tColor -- text at top
@window = box @, wBackground -- main window area @area = box @, wBackground -- main window area
@close = box @, closeImage -- close button @close = box @, closeImage -- close button
-- correct placement / sizes of elements -- correct placement / sizes of elements
height = @title\getHeight! height = @title\getHeight!
@head\setSize @w - height, height @head\setSize @w - height, height
@window\move nil, height @area\move nil, height
@close\align("right")\setSize height, height @close\align("right")\setSize height, height
@setSize 100, 80 @setSize 100, 80
-- our child elements are still child elements -- our child elements are still child elements
--TODO change title to be a child of head ? --TODO change title to be a child of head ?
@child = { @child = {
@head, @title, @window, @close @head, @title, @area, @close
} }
@titleOverflow = "trunicate" -- defaults to trunicating title to fit in window @titleOverflow = "trunicate" -- defaults to trunicating title to fit in window
-- window area steals mouse events to keep them from propagating under it -- window area steals mouse events to keep them from propagating under it
@window.mousepressed = -> @area.mousepressed = ->
return true return true
@window.clicked = -> @area.clicked = ->
return true return true
@close.clicked = -> @close.clicked = ->
@ -116,14 +116,14 @@ class window extends element
return @ return @
addChild: (child) => addChild: (child) =>
@window\addChild child @area\addChild child
return @ return @
-- pass through to window, but return us if window returns itself -- pass through to window, but return us if window returns itself
removeChild: (child) => removeChild: (child) =>
result = @window\removeChild child result = @area\removeChild child
if result == @window if result == @area
return @ return @
elseif type(result) == "string" elseif type(result) == "string"
for k,v in ipairs @child for k,v in ipairs @child
@ -135,7 +135,7 @@ class window extends element
return result return result
getChildren: => getChildren: =>
return @window.child return @area.child
align: (horizontal, vertical, toPixel) => align: (horizontal, vertical, toPixel) =>
super horizontal, vertical, toPixel super horizontal, vertical, toPixel
@ -143,7 +143,7 @@ class window extends element
for i = 1, #@child for i = 1, #@child
@child[i]\align! @child[i]\align!
@window\move nil, @head\getHeight! @area\move nil, @head\getHeight!
return @ return @
@ -163,7 +163,7 @@ class window extends element
else else
@head\setWidth w @head\setWidth w
@window\setWidth w @area\setWidth w
@w = w @w = w
@x += x @x += x
@ -180,13 +180,13 @@ class window extends element
when "right" when "right"
y -= h - @h y -= h - @h
@window\setHeight h @area\setHeight h
@h = h + @head\getHeight! @h = h + @head\getHeight!
@y += y @y += y
@head\move x, y @head\move x, y
--@title\move x, y --@title\move x, y
@window\move x, y @area\move x, y
return @ return @
@ -204,7 +204,7 @@ class window extends element
else else
@head\setWidth w @head\setWidth w
@window\setWidth w @area\setWidth w
@w = w @w = w
@x += x @x += x
@ -215,7 +215,7 @@ class window extends element
@head\move x @head\move x
--@title\move x --@title\move x
@window\move x @area\move x
return @ return @
@ -229,13 +229,13 @@ class window extends element
when "right" when "right"
y -= h - @h y -= h - @h
@window\setHeight h @area\setHeight h
@h = h + @head\getHeight! @h = h + @head\getHeight!
@y += y @y += y
@head\move nil, y @head\move nil, y
@title\move nil, y @title\move nil, y
@window\move nil, y @area\move nil, y
return @ return @