Simpler and safer GUI2 text positioning formulas

This commit is contained in:
Charles Dang 2016-07-28 23:01:35 +11:00
parent 95ab7971f8
commit 1cfad2404f

View file

@ -21,7 +21,7 @@
# If the text is too wide it returns the left side.
# Rounding happens to the left side.
#define GUI__TEXT_HORIZONTALLY_CENTRED
"(if(text_width < width, (width - text_width ) / 2, 0))"
"(max((width - text_width) / 2, 0))"
#enddef
# Centers the text vertically.
@ -29,7 +29,7 @@
# If the text is too high it returns the top side.
# Rounding happens to the bottom side.
#define GUI__TEXT_VERTICALLY_CENTRED
"(if(text_height < height, (height - text_height - 2) / 2, 0))"
"(max((height - text_height - 2) / 2, 0))"
#enddef
#define GUI__CENTERED_TEXT FONT_SIZE FONT_STYLE FONT_COLOR