From 2b5cde684bfe8e4aeffb688ff60d957349ba0d53 Mon Sep 17 00:00:00 2001 From: San Jacobs Date: Fri, 3 Oct 2025 10:07:05 +0200 Subject: If something has text, let it be sized to the text by default --- src/tafl/tafl.odin | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/tafl/tafl.odin b/src/tafl/tafl.odin index 83fc670..50c68c5 100644 --- a/src/tafl/tafl.odin +++ b/src/tafl/tafl.odin @@ -102,6 +102,12 @@ tafl_open :: proc( parent = &tafl_elements[tafl_stack[tafl_stack_depth-1]] } + if text != "" { + measurement := rl.MeasureTextEx(DEFAULT_FONT, strings.clone_to_cstring(text, allocator=context.temp_allocator), f32(FONT_SIZE), 0) + width = max(width, int(measurement.x)) + height = max(height, int(measurement.y)) + } + if width == -1 { width = parent.inner.width } @@ -109,11 +115,6 @@ tafl_open :: proc( height = parent.inner.height } - if text != "" { - measurement := rl.MeasureTextEx(DEFAULT_FONT, strings.clone_to_cstring(text, allocator=context.temp_allocator), f32(FONT_SIZE), 0) - width = max(width, int(measurement.x)) - height = max(height, int(measurement.y)) - } x, y : int if parent != nil { -- cgit v1.2.1