mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
attempted to add margin capability
This commit is contained in:
parent
a100f0f50c
commit
6cb3c23d09
@ -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 @
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,7 +1,8 @@
|
||||
import graphics from love
|
||||
|
||||
return {
|
||||
skin = {
|
||||
color: {255, 255, 255, 255}
|
||||
background: false
|
||||
font: graphics.newFont(13)
|
||||
margin: 2
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user