Made Text account for shadow and border effects in width/height methods, made TextBlock support disabled state styling

This commit is contained in:
2021-06-03 01:00:13 +00:00
parent 1b080f9fb9
commit a92d1ad746
3 changed files with 17 additions and 4 deletions

View File

@@ -128,15 +128,19 @@ module CyberarmEngine
end
def width(text = @text)
textobject.text_width(text)
textobject.text_width(text) + @border_size + @shadow_size
end
def markup_width(text = @text)
textobject.markup_width(text)
textobject.markup_width(text) + @border_size + @shadow_size
end
def height(text = @text)
text.lines.count > 0 ? text.lines.count * textobject.height : @textobject.height
if text.lines.count > 0
text.lines.count * textobject.height + @border_size + @shadow_size
else
@textobject.height + @border_size + @shadow_size
end
end
def draw(method = :draw_markup)

View File

@@ -22,6 +22,12 @@ module CyberarmEngine
end
def recalculate
unless @enabled
@text.color = @style.disabled[:color]
else
@text.color = @style.color
end
@width = 0
@height = 0

View File

@@ -119,7 +119,10 @@ module CyberarmEngine
text_align: :left,
font: "Arial",
margin: 0,
padding: 2
padding: 2,
disabled: {
color: Gosu::Color.rgb(175, 175, 175),
}
},
Banner: { # < TextBlock