mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-16 21:22:33 +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
|
end
|
||||||
|
|
||||||
def width(text = @text)
|
def width(text = @text)
|
||||||
textobject.text_width(text)
|
textobject.text_width(text) + @border_size + @shadow_size
|
||||||
end
|
end
|
||||||
|
|
||||||
def markup_width(text = @text)
|
def markup_width(text = @text)
|
||||||
textobject.markup_width(text)
|
textobject.markup_width(text) + @border_size + @shadow_size
|
||||||
end
|
end
|
||||||
|
|
||||||
def height(text = @text)
|
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
|
end
|
||||||
|
|
||||||
def draw(method = :draw_markup)
|
def draw(method = :draw_markup)
|
||||||
|
|||||||
@@ -22,6 +22,12 @@ module CyberarmEngine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def recalculate
|
def recalculate
|
||||||
|
unless @enabled
|
||||||
|
@text.color = @style.disabled[:color]
|
||||||
|
else
|
||||||
|
@text.color = @style.color
|
||||||
|
end
|
||||||
|
|
||||||
@width = 0
|
@width = 0
|
||||||
@height = 0
|
@height = 0
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,10 @@ module CyberarmEngine
|
|||||||
text_align: :left,
|
text_align: :left,
|
||||||
font: "Arial",
|
font: "Arial",
|
||||||
margin: 0,
|
margin: 0,
|
||||||
padding: 2
|
padding: 2,
|
||||||
|
disabled: {
|
||||||
|
color: Gosu::Color.rgb(175, 175, 175),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
Banner: { # < TextBlock
|
Banner: { # < TextBlock
|
||||||
|
|||||||
Reference in New Issue
Block a user