@@ -27,25 +27,39 @@ impl Default for LayoutMode {
2727 }
2828}
2929
30+ #[ derive( Copy , Clone , PartialEq , Eq , Serialize , Deserialize , Debug ) ]
31+ #[ cfg_attr( feature = "inspector" , derive( Inspectable ) ) ]
32+ pub enum GridAlignMode {
33+ Center ,
34+ ForceCenter ,
35+ Top ,
36+ ForceTop ,
37+ }
38+ impl Default for GridAlignMode {
39+ fn default ( ) -> Self {
40+ Self :: Center
41+ }
42+ }
43+
3044#[ derive( Clone , Serialize , Deserialize , Debug ) ]
3145#[ cfg_attr( feature = "inspector" , derive( Inspectable ) ) ]
3246pub struct LayoutSettings {
3347 pub mode : LayoutMode ,
48+ pub grid_align_mode : GridAlignMode ,
3449 pub focus_bar_ease_ms : u64 ,
3550 pub focusing_bar_ordinal : usize ,
3651 pub video_recording_mode : bool ,
37- pub grid_force_centered : bool ,
3852 pub override_focus_offset_y : Option < f32 > ,
3953}
4054
4155impl Default for LayoutSettings {
4256 fn default ( ) -> Self {
4357 Self {
4458 mode : LayoutMode :: default ( ) ,
59+ grid_align_mode : GridAlignMode :: default ( ) ,
4560 focus_bar_ease_ms : 250 ,
4661 focusing_bar_ordinal : usize:: MAX ,
4762 video_recording_mode : false ,
48- grid_force_centered : false ,
4963 override_focus_offset_y : None ,
5064 }
5165 }
@@ -154,7 +168,7 @@ impl LayoutSettings {
154168 let mut y = pos_data. bar_layout . offset . y ;
155169 let grid_size = layout. size ;
156170 let content_size = grid_data. content_size ;
157- if self . video_recording_mode {
171+ if self . video_recording_mode || self . grid_align_mode == GridAlignMode :: ForceTop {
158172 y += self . override_focus_offset_y . unwrap_or ( 0.0 ) ;
159173 } else {
160174 if grid_size. height > content_size. height {
@@ -166,9 +180,12 @@ impl LayoutSettings {
166180 y = grid_data.calc_cell_offset(row - 1, col).y;
167181 }
168182 */
169- y += ( grid_size. height - grid_data. margin . height * 2.0 - pos_data. bar_layout . size . height ) / 2.0 + self . override_focus_offset_y . unwrap_or ( 0.0 ) ;
170-
171- if !self . grid_force_centered {
183+ if self . grid_align_mode == GridAlignMode :: Center
184+ || self . grid_align_mode == GridAlignMode :: ForceCenter {
185+ y += ( grid_size. height - grid_data. margin . height * 2.0 - pos_data. bar_layout . size . height ) / 2.0 + self . override_focus_offset_y . unwrap_or ( 0.0 ) ;
186+ }
187+ if self . grid_align_mode != GridAlignMode :: ForceCenter
188+ && self . grid_align_mode != GridAlignMode :: ForceTop {
172189 let min_y = grid_size. height - content_size. height - theme. sizes . layout . page_margin * 2.0 ;
173190 if y < min_y {
174191 y = min_y;
0 commit comments