@@ -6023,14 +6023,24 @@ test "text input sizing" {
60236023 try eq (88 , l .shrink_height (display , 115 ));
60246024 }
60256025
6026- const label = try create_label (allocator , display , .{
6026+ var panel = try display .add_panel (allocator , .{
6027+ .rect = .{ .width = 500 , .height = 200 },
6028+ .minimum = .{ .width = 5 , .height = 8 },
6029+ .type = .{ .panel = .{ .spacing = 0 , .direction = .top_to_bottom } },
6030+ .layout = .{ .x = .shrinks , .y = .shrinks },
6031+ });
6032+ try eq (5 , panel .shrink_width (display , 500 ));
6033+ try eq (8 , panel .shrink_height (display , 500 ));
6034+
6035+ var label = try panel .add (allocator , display , .{
60276036 .name = "hello" ,
60286037 .rect = .{ .width = 500 , .height = 60 },
60296038 .minimum = .{ .width = 300 , .height = 100 },
60306039 .maximum = .{ .width = 401 , .height = 201 },
60316040 .type = .{ .label = .{ .text = "Hello world" } },
60326041 .layout = .{ .x = .fixed , .y = .fixed },
60336042 });
6043+
60346044 label .pad = .{ .top = 0 , .bottom = 0 , .left = 0 , .right = 0 };
60356045 try eq (500 , label .shrink_width (display , 500 ));
60366046 try eq (100 , label .shrink_height (display , 500 ));
@@ -6044,20 +6054,11 @@ test "text input sizing" {
60446054 label .layout .x = .grows ;
60456055 try eq (91 , @round (label .shrink_width (display , 500 )));
60466056
6047- var panel = try display .add_panel (allocator , .{
6048- .rect = .{ .width = 500 , .height = 200 },
6049- .minimum = .{ .width = 5 , .height = 8 },
6050- .type = .{ .panel = .{ .spacing = 0 , .direction = .top_to_bottom } },
6051- .layout = .{ .x = .shrinks , .y = .shrinks },
6052- });
6053- try eq (5 , panel .shrink_width (display , 500 ));
6054- try eq (8 , panel .shrink_height (display , 500 ));
6055-
60566057 panel .layout .x = .shrinks ;
60576058 panel .layout .y = .shrinks ;
60586059 label .layout .x = .grows ;
60596060 label .layout .y = .shrinks ;
6060- _ = try panel . add ( allocator , display , label .* );
6061+
60616062 label .pad .top = 0 ;
60626063 label .pad .bottom = 0 ;
60636064 display .relayout ();
@@ -6069,6 +6070,7 @@ test "text input sizing" {
60696070 label .maximum .width ,
60706071 label .maximum .height ,
60716072 });
6073+
60726074 // Two words wrapped, so the with is the width of the longest word.
60736075 try eq (401 , @round (label .rect .width )); // Label has 401 as maximum
60746076 try eq (500 , @trunc (panel .rect .width ));
0 commit comments