@@ -88,8 +88,12 @@ pub struct Child {
8888}
8989
9090impl Child {
91+ pub fn layout_origin ( & self , children_offset : Vec2 ) -> Point {
92+ self . params . position_local + children_offset
93+ }
94+
9195 pub fn layout_bounding_rect ( & self , children_offset : Vec2 ) -> Rect {
92- Rect :: from_origin_size ( self . params . position_local + children_offset, self . calculated_size )
96+ Rect :: from_origin_size ( self . layout_origin ( children_offset) , self . calculated_size )
9397 }
9498
9599 pub fn get_channels ( & self , direction : ChannelDirection ) -> & Vec < WidgetPod < dyn Widget > > {
@@ -570,27 +574,25 @@ impl Widget for FloatingPanes {
570574 ctx. place_child ( & mut child. content , position) ;
571575
572576 let channel_bc =
573- BoxConstraints :: new ( Size :: ZERO , Size :: new ( child. calculated_size . width , f64:: INFINITY ) ) ;
577+ BoxConstraints :: new ( Size :: ZERO , Size :: new ( child. calculated_size . width / 2.0 , f64:: INFINITY ) ) ;
574578
575- {
576- let mut channel_position = position ;
579+ let mut layout_channels = | channels : & mut [ _ ] , offset : Vec2 | {
580+ let mut channel_position = child . calculated_size . height ;
577581
578- for channel_in in & mut child . channels_in {
579- let channel_size = ctx. run_layout ( channel_in , & channel_bc) ;
580- ctx. place_child ( channel_in , channel_position) ;
581- channel_position. y += channel_size. height ;
582+ for channel in channels {
583+ let channel_size = ctx. run_layout ( channel , & channel_bc) ;
584+ ctx. place_child ( channel , position + offset + Vec2 :: new ( 0.0 , channel_position) ) ;
585+ channel_position += channel_size. height ;
582586 }
583- }
584587
585- {
586- let mut channel_position = position ;
588+ channel_position
589+ } ;
587590
588- for channel_out in & mut child. channels_out {
589- let channel_size = ctx. run_layout ( channel_out, & channel_bc) ;
590- ctx. place_child ( channel_out, channel_position) ;
591- channel_position. y += channel_size. height ;
592- }
593- }
591+ child. calculated_size . height = std:: cmp:: max_by (
592+ layout_channels ( & mut child. channels_in , Vec2 :: ZERO ) ,
593+ layout_channels ( & mut child. channels_out , Vec2 :: new ( child. calculated_size . width / 2.0 , 0.0 ) ) ,
594+ |lhs, rhs| lhs. total_cmp ( rhs) ,
595+ ) ;
594596 }
595597
596598 bc. max ( )
@@ -610,7 +612,7 @@ impl Widget for FloatingPanes {
610612 stroke ( scene, & border_rect, border_color. color , border_width. width ) ;
611613
612614 // Clip children drawn outside the layout area.
613- // scene.push_clip_layer(Affine::IDENTITY, &bg_rect);
615+ scene. push_clip_layer ( Affine :: IDENTITY , & bg_rect) ;
614616
615617 for child in & self . children {
616618 let child_bg_rect = child. layout_bounding_rect ( self . children_offset ) ;
0 commit comments