@@ -474,6 +474,7 @@ pub const Element = struct {
474474 button : struct {
475475 font : * Font = undefined ,
476476 font_name : ? []const u8 = null ,
477+ text_size : TextSize = .normal ,
477478 text : []const u8 = "" ,
478479 translated : []const u8 = "" ,
479480 text_texture : ? * sdl.SDL_Texture = null ,
@@ -1272,7 +1273,7 @@ pub const Element = struct {
12721273 }
12731274
12741275 if (self .type .button .text_texture ) | t | {
1275- const size = TextSize . normal .pixel_size (display , t );
1276+ const size = self . type . button . text_size .pixel_size (display , t );
12761277 width += size .width ;
12771278 }
12781279 return @max (self .minimum .width , width );
@@ -1596,7 +1597,7 @@ pub const Element = struct {
15961597
15971598 if (element .type .text_input .text .items .len > 0 ) {
15981599 if (element .type .text_input .texture ) | texture | {
1599- const size = .normal .pixel_size (display , texture );
1600+ const size = TextSize .normal .pixel_size (display , texture );
16001601 // Draw the text
16011602 var dest : Rect = .{
16021603 .x = @round (x ),
@@ -1620,7 +1621,7 @@ pub const Element = struct {
16201621 }
16211622 } else {
16221623 if (element .type .text_input .placeholder_texture ) | texture | {
1623- const size = .normal .pixel_size (display , texture );
1624+ const size = TextSize .normal .pixel_size (display , texture );
16241625 // Draw the placeholder text
16251626 var dest : Rect = .{
16261627 .x = @round (x ),
@@ -1886,7 +1887,7 @@ pub const Element = struct {
18861887 // The inner content can contain a button and/or text texture.
18871888 var content_width = element .type .button .icon_size .width ;
18881889 if (element .type .button .text_texture ) | texture | {
1889- const size = .normal .pixel_size (display , texture );
1890+ const size = element . type . button . text_size .pixel_size (display , texture );
18901891
18911892 // Do we need space between text and icon?
18921893 if (content_width > 0 )
@@ -1942,7 +1943,7 @@ pub const Element = struct {
19421943 }
19431944 }
19441945 if (element .type .button .text_texture ) | texture | {
1945- const size = .normal .pixel_size (display , texture );
1946+ const size = element . type . button . text_size .pixel_size (display , texture );
19461947 var dest : Rect = .{
19471948 .x = element .rect .x + element .type .button .icon_size .width + element .pad .left + content_offset ,
19481949 .y = element .rect .y + (element .rect .height / 2.0 ) - (size .height / 2 ),
@@ -2011,7 +2012,7 @@ pub const Element = struct {
20112012 if (display .generate_text_texture (self .type .text_input .text .items , self .type .text_input .font )) | texture | {
20122013 self .type .text_input .texture = texture ;
20132014 // For now, the cursor position is simply the end of the text.
2014- self .type .text_input .cursor_pixels = .normal .pixel_size (display , texture ).width ;
2015+ self .type .text_input .cursor_pixels = TextSize .normal .pixel_size (display , texture ).width ;
20152016 }
20162017 } else {
20172018 self .type .text_input .cursor_pixels = 0 ;
@@ -5468,6 +5469,7 @@ pub fn setup_button(
54685469 element .type .button .background_pressed = null ;
54695470 element .type .button .background_hover = null ;
54705471 element .type .button .background_disabled = null ;
5472+ element .type .button .text_size = .normal ;
54715473 element .type .button .font = select_font (display .fonts .items , element .type .button .font_name );
54725474
54735475 if (element .focus == .unspecified )
0 commit comments