Fixed centered text with unequal margins/paddings/border thicknesses being offset, fixed text wrapping using parents #width (which includes padding and margins) instead of the correct #content_width (which is only the parents content width; which the text is part of)

This commit is contained in:
2021-11-17 17:23:48 -06:00
parent a915a25699
commit c1b25d2045

View File

@@ -47,8 +47,8 @@ module CyberarmEngine
when :left
@text.x = @style.border_thickness_left + @style.padding_left + @x
when :center
@text.x = if @text.width <= outer_width
@x + outer_width / 2 - @text.width / 2
@text.x = if @text.width <= width
@x + width / 2 - @text.width / 2
else # Act as left aligned
@style.border_thickness_left + @style.padding_left + @x
end
@@ -61,7 +61,7 @@ module CyberarmEngine
end
def handle_text_wrapping(max_width)
max_width ||= @parent&.width
max_width ||= @parent&.content_width
max_width ||= @x - (window.width + noncontent_width)
wrap_behavior = style.text_wrap
copy = @raw_text.to_s.dup