mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-15 12:42:34 +00:00
Made Text account for shadow and border effects in width/height methods, made TextBlock support disabled state styling
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user