@@ -597,9 +597,13 @@ fn compute_layout_info(
597597 crate :: layout:: Layout :: GridLayout ( layout) => {
598598 let ( padding, spacing) = generate_layout_padding_and_spacing ( & layout. geometry , o, ctx) ;
599599 let cells = grid_layout_cell_data ( layout, o, ctx) ;
600+ let orientation_literal = llr_Expression:: EnumerationValue ( EnumerationValue {
601+ value : o as _ ,
602+ enumeration : crate :: typeregister:: BUILTIN . with ( |b| b. enums . Orientation . clone ( ) ) ,
603+ } ) ;
600604 llr_Expression:: ExtraBuiltinFunctionCall {
601605 function : "grid_layout_info" . into ( ) ,
602- arguments : vec ! [ cells, spacing, padding] ,
606+ arguments : vec ! [ cells, spacing, padding, orientation_literal ] ,
603607 return_ty : crate :: typeregister:: layout_info_type ( ) . into ( ) ,
604608 }
605609 }
@@ -643,6 +647,10 @@ fn solve_layout(
643647 let ( padding, spacing) = generate_layout_padding_and_spacing ( & layout. geometry , o, ctx) ;
644648 let cells = grid_layout_cell_data ( layout, o, ctx) ;
645649 let size = layout_geometry_size ( & layout. geometry . rect , o, ctx) ;
650+ let orientation_expr = llr_Expression:: EnumerationValue ( EnumerationValue {
651+ value : o as _ ,
652+ enumeration : crate :: typeregister:: BUILTIN . with ( |b| b. enums . Orientation . clone ( ) ) ,
653+ } ) ;
646654 if let ( Some ( button_roles) , Orientation :: Horizontal ) = ( & layout. dialog_button_roles , o)
647655 {
648656 let cells_ty = cells. ty ( ctx) ;
@@ -669,37 +677,43 @@ fn solve_layout(
669677 } ,
670678 llr_Expression:: ExtraBuiltinFunctionCall {
671679 function: "solve_grid_layout" . into( ) ,
672- arguments: vec![ make_struct(
673- "GridLayoutData" ,
674- [
675- ( "size" , Type :: Float32 , size) ,
676- ( "spacing" , Type :: Float32 , spacing) ,
677- ( "padding" , padding. ty( ctx) , padding) ,
678- (
679- "cells" ,
680- cells_ty. clone( ) ,
681- llr_Expression:: ReadLocalVariable {
682- name: "cells" . into( ) ,
683- ty: cells_ty,
684- } ,
685- ) ,
686- ] ,
687- ) ] ,
680+ arguments: vec![
681+ make_struct(
682+ "GridLayoutData" ,
683+ [
684+ ( "size" , Type :: Float32 , size) ,
685+ ( "spacing" , Type :: Float32 , spacing) ,
686+ ( "padding" , padding. ty( ctx) , padding) ,
687+ (
688+ "cells" ,
689+ cells_ty. clone( ) ,
690+ llr_Expression:: ReadLocalVariable {
691+ name: "cells" . into( ) ,
692+ ty: cells_ty,
693+ } ,
694+ ) ,
695+ ] ,
696+ ) ,
697+ orientation_expr,
698+ ] ,
688699 return_ty: Type :: LayoutCache ,
689700 } ,
690701 ] )
691702 } else {
692703 llr_Expression:: ExtraBuiltinFunctionCall {
693704 function : "solve_grid_layout" . into ( ) ,
694- arguments : vec ! [ make_struct(
695- "GridLayoutData" ,
696- [
697- ( "size" , Type :: Float32 , size) ,
698- ( "spacing" , Type :: Float32 , spacing) ,
699- ( "padding" , padding. ty( ctx) , padding) ,
700- ( "cells" , cells. ty( ctx) , cells) ,
701- ] ,
702- ) ] ,
705+ arguments : vec ! [
706+ make_struct(
707+ "GridLayoutData" ,
708+ [
709+ ( "size" , Type :: Float32 , size) ,
710+ ( "spacing" , Type :: Float32 , spacing) ,
711+ ( "padding" , padding. ty( ctx) , padding) ,
712+ ( "cells" , cells. ty( ctx) , cells) ,
713+ ] ,
714+ ) ,
715+ orientation_expr,
716+ ] ,
703717 return_ty : Type :: LayoutCache ,
704718 }
705719 }
@@ -846,15 +860,33 @@ fn grid_layout_cell_data(
846860 . elems
847861 . iter ( )
848862 . map ( |c| {
849- let ( col_or_row , span) = c. col_or_row_and_span ( orientation) ;
863+ let span = c. span ( orientation) ;
850864 let layout_info =
851865 get_layout_info ( & c. item . element , ctx, & c. item . constraints , orientation) ;
852866
867+ let mut lower_expr_or_auto = |expr : & Option < crate :: expression_tree:: Expression > | {
868+ expr. as_ref ( ) . map_or_else (
869+ || llr_Expression:: NumberLiteral ( u16:: MAX . into ( ) ) , // MAX means "auto", see to_layout_data()
870+ |e| lower_expression ( e, ctx) ,
871+ )
872+ } ;
873+ let row_expr = lower_expr_or_auto ( & c. row_expr ) ;
874+ let col_expr = lower_expr_or_auto ( & c. col_expr ) ;
875+
853876 make_struct (
854877 "GridLayoutCellData" ,
855878 [
856879 ( "constraint" , crate :: typeregister:: layout_info_type ( ) . into ( ) , layout_info) ,
857- ( "col_or_row" , Type :: Int32 , llr_Expression:: NumberLiteral ( col_or_row as _ ) ) ,
880+ ( "new_row" , Type :: Bool , llr_Expression:: BoolLiteral ( c. new_row ) ) ,
881+ (
882+ "col_or_row" ,
883+ Type :: Int32 ,
884+ match orientation {
885+ Orientation :: Horizontal => col_expr,
886+ Orientation :: Vertical => row_expr. clone ( ) ,
887+ } ,
888+ ) ,
889+ ( "row" , Type :: Int32 , row_expr) ,
858890 ( "span" , Type :: Int32 , llr_Expression:: NumberLiteral ( span as _ ) ) ,
859891 ] ,
860892 )
@@ -867,6 +899,7 @@ fn grid_layout_cell_data(
867899pub ( super ) fn grid_layout_cell_data_ty ( ) -> Type {
868900 Type :: Struct ( Rc :: new ( Struct {
869901 fields : IntoIterator :: into_iter ( [
902+ ( SmolStr :: new_static ( "new_row" ) , Type :: Bool ) ,
870903 ( SmolStr :: new_static ( "col_or_row" ) , Type :: Int32 ) ,
871904 ( SmolStr :: new_static ( "span" ) , Type :: Int32 ) ,
872905 ( SmolStr :: new_static ( "constraint" ) , crate :: typeregister:: layout_info_type ( ) . into ( ) ) ,
0 commit comments