mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-15 20:52:35 +00:00
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:
@@ -47,8 +47,8 @@ module CyberarmEngine
|
|||||||
when :left
|
when :left
|
||||||
@text.x = @style.border_thickness_left + @style.padding_left + @x
|
@text.x = @style.border_thickness_left + @style.padding_left + @x
|
||||||
when :center
|
when :center
|
||||||
@text.x = if @text.width <= outer_width
|
@text.x = if @text.width <= width
|
||||||
@x + outer_width / 2 - @text.width / 2
|
@x + width / 2 - @text.width / 2
|
||||||
else # Act as left aligned
|
else # Act as left aligned
|
||||||
@style.border_thickness_left + @style.padding_left + @x
|
@style.border_thickness_left + @style.padding_left + @x
|
||||||
end
|
end
|
||||||
@@ -61,7 +61,7 @@ module CyberarmEngine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def handle_text_wrapping(max_width)
|
def handle_text_wrapping(max_width)
|
||||||
max_width ||= @parent&.width
|
max_width ||= @parent&.content_width
|
||||||
max_width ||= @x - (window.width + noncontent_width)
|
max_width ||= @x - (window.width + noncontent_width)
|
||||||
wrap_behavior = style.text_wrap
|
wrap_behavior = style.text_wrap
|
||||||
copy = @raw_text.to_s.dup
|
copy = @raw_text.to_s.dup
|
||||||
|
|||||||
Reference in New Issue
Block a user