@@ -71,9 +71,17 @@ impl Region {
71
71
}
72
72
73
73
pub fn sanity_check ( & self ) {
74
- debug_assert ! ( !self . min_rect. any_nan( ) ) ;
75
- debug_assert ! ( !self . max_rect. any_nan( ) ) ;
76
- debug_assert ! ( !self . cursor. any_nan( ) ) ;
74
+ debug_assert ! (
75
+ !self . min_rect. any_nan( ) ,
76
+ "min rect has Nan: {:?}" ,
77
+ self . min_rect
78
+ ) ;
79
+ debug_assert ! (
80
+ !self . max_rect. any_nan( ) ,
81
+ "max rect has Nan: {:?}" ,
82
+ self . max_rect
83
+ ) ;
84
+ debug_assert ! ( !self . cursor. any_nan( ) , "cursor has Nan: {:?}" , self . cursor) ;
77
85
}
78
86
}
79
87
@@ -394,8 +402,8 @@ impl Layout {
394
402
/// ## Doing layout
395
403
impl Layout {
396
404
pub fn align_size_within_rect ( & self , size : Vec2 , outer : Rect ) -> Rect {
397
- debug_assert ! ( size. x >= 0.0 && size. y >= 0.0 ) ;
398
- debug_assert ! ( !outer. is_negative( ) ) ;
405
+ debug_assert ! ( size. x >= 0.0 && size. y >= 0.0 , "Negative size: {size:?}" ) ;
406
+ debug_assert ! ( !outer. is_negative( ) , "Negative outer: {outer:?}" ) ;
399
407
self . align2 ( ) . align_size_within_rect ( size, outer) . round_ui ( )
400
408
}
401
409
@@ -421,7 +429,7 @@ impl Layout {
421
429
}
422
430
423
431
pub ( crate ) fn region_from_max_rect ( & self , max_rect : Rect ) -> Region {
424
- debug_assert ! ( !max_rect. any_nan( ) ) ;
432
+ debug_assert ! ( !max_rect. any_nan( ) , "max_rect is not NaN: {max_rect:?}" ) ;
425
433
let mut region = Region {
426
434
min_rect : Rect :: NOTHING , // temporary
427
435
max_rect,
@@ -454,8 +462,8 @@ impl Layout {
454
462
/// Given the cursor in the region, how much space is available
455
463
/// for the next widget?
456
464
fn available_from_cursor_max_rect ( & self , cursor : Rect , max_rect : Rect ) -> Rect {
457
- debug_assert ! ( !cursor. any_nan( ) ) ;
458
- debug_assert ! ( !max_rect. any_nan( ) ) ;
465
+ debug_assert ! ( !cursor. any_nan( ) , "cursor is NaN: {cursor:?}" ) ;
466
+ debug_assert ! ( !max_rect. any_nan( ) , "max_rect is NaN: {max_rect:?}" ) ;
459
467
460
468
// NOTE: in normal top-down layout the cursor has moved below the current max_rect,
461
469
// but the available shouldn't be negative.
@@ -509,7 +517,7 @@ impl Layout {
509
517
avail. max . y = y;
510
518
}
511
519
512
- debug_assert ! ( !avail. any_nan( ) ) ;
520
+ debug_assert ! ( !avail. any_nan( ) , "avail is NaN: {avail:?}" ) ;
513
521
514
522
avail
515
523
}
@@ -520,7 +528,10 @@ impl Layout {
520
528
/// Use `justify_and_align` to get the inner `widget_rect`.
521
529
pub ( crate ) fn next_frame ( & self , region : & Region , child_size : Vec2 , spacing : Vec2 ) -> Rect {
522
530
region. sanity_check ( ) ;
523
- debug_assert ! ( child_size. x >= 0.0 && child_size. y >= 0.0 ) ;
531
+ debug_assert ! (
532
+ child_size. x >= 0.0 && child_size. y >= 0.0 ,
533
+ "Negative size: {child_size:?}"
534
+ ) ;
524
535
525
536
if self . main_wrap {
526
537
let available_size = self . available_rect_before_wrap ( region) . size ( ) ;
@@ -600,7 +611,10 @@ impl Layout {
600
611
601
612
fn next_frame_ignore_wrap ( & self , region : & Region , child_size : Vec2 ) -> Rect {
602
613
region. sanity_check ( ) ;
603
- debug_assert ! ( child_size. x >= 0.0 && child_size. y >= 0.0 ) ;
614
+ debug_assert ! (
615
+ child_size. x >= 0.0 && child_size. y >= 0.0 ,
616
+ "Negative size: {child_size:?}"
617
+ ) ;
604
618
605
619
let available_rect = self . available_rect_before_wrap ( region) ;
606
620
@@ -633,16 +647,19 @@ impl Layout {
633
647
frame_rect = frame_rect. translate ( Vec2 :: Y * ( region. cursor . top ( ) - frame_rect. top ( ) ) ) ;
634
648
}
635
649
636
- debug_assert ! ( !frame_rect. any_nan( ) ) ;
637
- debug_assert ! ( !frame_rect. is_negative( ) ) ;
650
+ debug_assert ! ( !frame_rect. any_nan( ) , "frame_rect is NaN: {frame_rect:?}" ) ;
651
+ debug_assert ! ( !frame_rect. is_negative( ) , "frame_rect is negative" ) ;
638
652
639
653
frame_rect. round_ui ( )
640
654
}
641
655
642
656
/// Apply justify (fill width/height) and/or alignment after calling `next_space`.
643
657
pub ( crate ) fn justify_and_align ( & self , frame : Rect , mut child_size : Vec2 ) -> Rect {
644
- debug_assert ! ( child_size. x >= 0.0 && child_size. y >= 0.0 ) ;
645
- debug_assert ! ( !frame. is_negative( ) ) ;
658
+ debug_assert ! (
659
+ child_size. x >= 0.0 && child_size. y >= 0.0 ,
660
+ "Negative size: {child_size:?}"
661
+ ) ;
662
+ debug_assert ! ( !frame. is_negative( ) , "frame is negative" ) ;
646
663
647
664
if self . horizontal_justify ( ) {
648
665
child_size. x = child_size. x . at_least ( frame. width ( ) ) ; // fill full width
@@ -660,8 +677,8 @@ impl Layout {
660
677
) -> Rect {
661
678
let frame = self . next_frame_ignore_wrap ( region, size) ;
662
679
let rect = self . align_size_within_rect ( size, frame) ;
663
- debug_assert ! ( !rect. any_nan( ) ) ;
664
- debug_assert ! ( !rect. is_negative( ) ) ;
680
+ debug_assert ! ( !rect. any_nan( ) , "rect is NaN: {rect:?}" ) ;
681
+ debug_assert ! ( !rect. is_negative( ) , "rect is negative: {rect:?}" ) ;
665
682
rect
666
683
}
667
684
@@ -704,7 +721,7 @@ impl Layout {
704
721
widget_rect : Rect ,
705
722
item_spacing : Vec2 ,
706
723
) {
707
- debug_assert ! ( !cursor. any_nan( ) ) ;
724
+ debug_assert ! ( !cursor. any_nan( ) , "cursor is NaN: {cursor:?}" ) ;
708
725
if self . main_wrap {
709
726
if cursor. intersects ( frame_rect. shrink ( 1.0 ) ) {
710
727
// make row/column larger if necessary
0 commit comments