@@ -948,7 +948,7 @@ pub const Element = struct {
948948 if (self .layout .y == .shrinks or self .layout .y == .grows ) {
949949 // Generate the image textures for each word and the locations they
950950 // should be rendered.
951- draw_text_elements (self , display , .{ .x = 0 , .y = 0 }, null , false );
951+ draw_label (self , display , .{ .x = 0 , .y = 0 }, null , false );
952952 }
953953 }
954954 },
@@ -976,8 +976,8 @@ pub const Element = struct {
976976 if (self .layout .y == .shrinks or self .layout .y == .grows ) {
977977 // Simulate a draw of this element to see how many
978978 // lines it would take.
979- // TODO: dont need draw_text_elements ?
980- draw_text_elements (self , display , .{ .x = 0 , .y = 0 }, null , false );
979+ // TODO: dont need draw_label ?
980+ draw_label (self , display , .{ .x = 0 , .y = 0 }, null , false );
981981 }
982982 }
983983 },
@@ -1339,9 +1339,7 @@ pub const Element = struct {
13391339 .text_input = > draw_text_input (element , display , parent_scroll_offset , parent_clip ),
13401340 .sprite = > draw_sprite (element , display , parent_scroll_offset , parent_clip , scroll_offset ),
13411341 .rectangle = > draw_rectangle_element (element , display , parent_scroll_offset , parent_clip , scroll_offset ),
1342- .label = > if (element .type .label .text .len > 0 ) {
1343- draw_text_elements (element , display , scroll_offset , parent_clip , true );
1344- },
1342+ .label = > draw_label (element , display , scroll_offset , parent_clip , true ),
13451343 .progress_bar = > draw_progress_bar (element , display , parent_scroll_offset , parent_clip ),
13461344 .expander = > {},
13471345 }
@@ -1683,7 +1681,7 @@ pub const Element = struct {
16831681 inline fn draw_checkbox (element : * Element , display : * Display , _ : Vector , _ : ? Clip , scroll_offset : Vector ) void {
16841682 const checkbox = display .checkbox ();
16851683 // Output checkbox text.
1686- draw_text_elements (element , display , scroll_offset , null , true );
1684+ draw_label (element , display , scroll_offset , null , true );
16871685 var dest : Rect = .{
16881686 .x = element .rect .x + element .rect .width - checkbox .width - element .pad .left ,
16891687 .y = element .rect .y + (element .rect .height / 2 ) - (checkbox .height / 2 ),
@@ -2224,7 +2222,7 @@ inline fn text_size(display: *Display, texture: *sdl.SDL_Texture, size: TextSize
22242222///
22252223/// If the text is centred or right aligned, then each line must be pushed along
22262224/// by a certain offset amount.
2227- inline fn draw_text_elements (
2225+ inline fn draw_label (
22282226 element : * Element ,
22292227 display : * Display ,
22302228 scroll_offset : Vector ,
@@ -2233,6 +2231,9 @@ inline fn draw_text_elements(
22332231) void {
22342232 std .debug .assert (element .type == .label or element .type == .checkbox );
22352233
2234+ if (element .type == .label and element .type .label .text .len == 0 ) return ;
2235+ if (element .type == .checkbox and element .type .checkbox .text .len == 0 ) return ;
2236+
22362237 var x : f32 = element .rect .x + element .pad .left ;
22372238 var y : f32 = element .rect .y + element .pad .top ;
22382239 const x_start : f32 = @floor (x );
@@ -2370,7 +2371,7 @@ pub const MinMax = struct {
23702371};
23712372
23722373/// Calculate the width of this element by examining each of the child
2373- /// elements. This is a cut down version of draw_text_elements but
2374+ /// elements. This is a cut down version of draw_label but
23742375/// without the overhead of things like text justifications.
23752376inline fn text_elements_size (
23762377 element : * Element ,
0 commit comments