attempted to add margin capability

This commit is contained in:
Fox 2016-02-23 08:11:09 -08:00
parent a100f0f50c
commit 6cb3c23d09
4 changed files with 13 additions and 5 deletions

View File

@ -12,6 +12,7 @@ class element
@horizontal = "left"
@vertical = "top"
@margin = 0
debugDraw: =>
graphics.setLineWidth 0.5
@ -120,16 +121,20 @@ class element
@y = @parent.y
switch @horizontal
when "left"
@x += @margin
when "center"
@x += (@parent.w - @w)/2
when "right"
@x += @parent.w - @w
@x += @parent.w - @w - @margin
switch @vertical
when "top"
@y += @margin
when "center"
@y += (@parent.h - @h)/2
when "bottom"
@y += @parent.h - @h
@y += @parent.h - @h - @margin
return @

View File

@ -38,13 +38,13 @@ class text extends element
when "center"
@x -= (w - @w)/2
when "right"
@x -= w - @w
@x -= w - @w - @margin
switch @vertical
when "center"
@y -= (h - @h)/2
when "right"
@y -= h - @h
@y -= h - @h - @margin
@w = w
@h = h

View File

@ -59,6 +59,8 @@ class Pop
error "Unimplemented."
skin: (element, skin, apply_to_children=false) =>
element.margin = skin.margin
if element.background
element.background = skin.background
if element.color

View File

@ -1,7 +1,8 @@
import graphics from love
return {
skin = {
color: {255, 255, 255, 255}
background: false
font: graphics.newFont(13)
margin: 2
}