@@ -11,7 +11,7 @@ pub const HOST_SCREEN_HEIGHT: usize = 544;
1111pub const GUEST_SCREEN_WIDTH : usize = 256 ;
1212pub const GUEST_SCREEN_HEIGHT : usize = 192 ;
1313
14- pub fn get_screen_layouts ( ) -> Vec < [ [ f32 ; 9 ] ; 4 ] > {
14+ pub fn get_screen_layouts ( ) -> Vec < ( & ' static str , [ [ f32 ; 9 ] ; 4 ] ) > {
1515 let mut layouts = Vec :: new ( ) ;
1616
1717 {
@@ -24,7 +24,7 @@ pub fn get_screen_layouts() -> Vec<[[f32; 9]; 4]> {
2424 * Matrix3 :: new_scaling ( width_scale) ;
2525 let b_trans = Matrix3 :: new_translation ( & Vector2 :: new ( guest_width, 0.0 ) ) ;
2626
27- layouts. push ( [ mtx, b_trans * mtx] ) ;
27+ layouts. push ( ( "Side by side" , [ mtx, b_trans * mtx] ) ) ;
2828 }
2929
3030 {
@@ -37,30 +37,30 @@ pub fn get_screen_layouts() -> Vec<[[f32; 9]; 4]> {
3737 * Matrix3 :: new_scaling ( full_height_scale) ;
3838 let b_trans = Matrix3 :: new_translation ( & Vector2 :: new ( guest_height, 0.0 ) ) ;
3939
40- layouts. push ( [ mtx, b_trans * mtx] ) ;
40+ layouts. push ( ( "Rotate" , [ mtx, b_trans * mtx] ) ) ;
4141 }
4242
4343 {
4444 let full_height_scale = HOST_SCREEN_HEIGHT as f32 / GUEST_SCREEN_HEIGHT as f32 ;
4545 let guest_top_width = GUEST_SCREEN_WIDTH as f32 * full_height_scale;
4646 let width_remaining_space = HOST_SCREEN_WIDTH as f32 - guest_top_width;
47- let guest_bottom_scale = width_remaining_space / GUEST_SCREEN_WIDTH as f32 ;
48- let guest_bottom_height = GUEST_SCREEN_HEIGHT as f32 * guest_bottom_scale;
49- let height_remaining_space = HOST_SCREEN_HEIGHT as f32 - guest_bottom_height;
50- let top_mtx = Matrix3 :: new_translation ( & Vector2 :: new ( guest_top_width / 2.0 , HOST_SCREEN_HEIGHT as f32 / 2.0 ) ) * Matrix3 :: new_scaling ( full_height_scale) ;
51- let bottom_mtx =
52- Matrix3 :: new_translation ( & Vector2 :: new ( width_remaining_space / 2.0 + guest_top_width, guest_bottom_height / 2.0 + height_remaining_space / 2.0 ) ) * Matrix3 :: new_scaling ( guest_bottom_scale) ;
47+ let top_mtx = Matrix3 :: new_translation ( & Vector2 :: new ( guest_top_width / 2.0 + width_remaining_space / 2.0 , HOST_SCREEN_HEIGHT as f32 / 2.0 ) ) * Matrix3 :: new_scaling ( full_height_scale) ;
5348
54- layouts. push ( [ top_mtx, bottom_mtx ] ) ;
49+ layouts. push ( ( "Single" , [ top_mtx, Matrix3 :: new_translation ( & Vector2 :: new ( - ( HOST_SCREEN_WIDTH as f32 ) , - ( HOST_SCREEN_HEIGHT as f32 ) ) ) ] ) ) ;
5550 }
5651
5752 {
5853 let full_height_scale = HOST_SCREEN_HEIGHT as f32 / GUEST_SCREEN_HEIGHT as f32 ;
5954 let guest_top_width = GUEST_SCREEN_WIDTH as f32 * full_height_scale;
6055 let width_remaining_space = HOST_SCREEN_WIDTH as f32 - guest_top_width;
61- let top_mtx = Matrix3 :: new_translation ( & Vector2 :: new ( guest_top_width / 2.0 + width_remaining_space / 2.0 , HOST_SCREEN_HEIGHT as f32 / 2.0 ) ) * Matrix3 :: new_scaling ( full_height_scale) ;
56+ let guest_bottom_scale = width_remaining_space / GUEST_SCREEN_WIDTH as f32 ;
57+ let guest_bottom_height = GUEST_SCREEN_HEIGHT as f32 * guest_bottom_scale;
58+ let height_remaining_space = HOST_SCREEN_HEIGHT as f32 - guest_bottom_height;
59+ let top_mtx = Matrix3 :: new_translation ( & Vector2 :: new ( guest_top_width / 2.0 , HOST_SCREEN_HEIGHT as f32 / 2.0 ) ) * Matrix3 :: new_scaling ( full_height_scale) ;
60+ let bottom_mtx =
61+ Matrix3 :: new_translation ( & Vector2 :: new ( width_remaining_space / 2.0 + guest_top_width, guest_bottom_height / 2.0 + height_remaining_space / 2.0 ) ) * Matrix3 :: new_scaling ( guest_bottom_scale) ;
6262
63- layouts. push ( [ top_mtx, Matrix3 :: new_translation ( & Vector2 :: new ( - ( HOST_SCREEN_WIDTH as f32 ) , - ( HOST_SCREEN_HEIGHT as f32 ) ) ) ] ) ;
63+ layouts. push ( ( "Focus" , [ top_mtx, bottom_mtx ] ) ) ;
6464 }
6565
6666 {
@@ -71,14 +71,17 @@ pub fn get_screen_layouts() -> Vec<[[f32; 9]; 4]> {
7171 let bottom_mtx = Matrix3 :: new_translation ( & Vector2 :: new ( ( HOST_SCREEN_WIDTH - GUEST_SCREEN_WIDTH ) as f32 , ( HOST_SCREEN_HEIGHT - GUEST_SCREEN_HEIGHT ) as f32 ) )
7272 * Matrix3 :: new_translation ( & Vector2 :: new ( GUEST_SCREEN_WIDTH as f32 / 2.0 , GUEST_SCREEN_HEIGHT as f32 / 2.0 ) ) ;
7373
74- layouts. push ( [ top_mtx, bottom_mtx] ) ;
74+ layouts. push ( ( "Focus Overlap" , [ top_mtx, bottom_mtx] ) ) ;
7575 }
7676
7777 layouts
7878 . iter ( )
79- . map ( |mtxs| {
79+ . map ( |( name , mtxs) | {
8080 let flatten = |mtx : & Matrix3 < f32 > | [ mtx[ 0 ] , mtx[ 1 ] , mtx[ 2 ] , mtx[ 3 ] , mtx[ 4 ] , mtx[ 5 ] , mtx[ 6 ] , mtx[ 7 ] , mtx[ 8 ] ] ;
81- [ flatten ( & mtxs[ 0 ] ) , flatten ( & mtxs[ 1 ] ) , flatten ( & mtxs[ 0 ] . try_inverse ( ) . unwrap ( ) ) , flatten ( & mtxs[ 1 ] . try_inverse ( ) . unwrap ( ) ) ]
81+ (
82+ * name,
83+ [ flatten ( & mtxs[ 0 ] ) , flatten ( & mtxs[ 1 ] ) , flatten ( & mtxs[ 0 ] . try_inverse ( ) . unwrap ( ) ) , flatten ( & mtxs[ 1 ] . try_inverse ( ) . unwrap ( ) ) ] ,
84+ )
8285 } )
8386 . collect ( )
8487}
@@ -87,14 +90,17 @@ pub fn main() {
8790 let out_path = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
8891 let screen_layouts_file = out_path. join ( "screen_layouts.rs" ) ;
8992 let layouts = get_screen_layouts ( ) ;
90- let mut code = format ! ( "pub const SCREEN_LAYOUTS: [[[f32; 9]; 4]; {}] = [\n " , layouts. len( ) ) ;
91- for layout in layouts {
92- code += "\t [\n " ;
93- code += & format ! ( "\t \t {:?},\n " , layout[ 0 ] ) ;
94- code += & format ! ( "\t \t {:?},\n " , layout[ 1 ] ) ;
95- code += & format ! ( "\t \t {:?},\n " , layout[ 2 ] ) ;
96- code += & format ! ( "\t \t {:?},\n " , layout[ 3 ] ) ;
97- code += "\t ],\n " ;
93+ let mut code = format ! ( "pub const SCREEN_LAYOUTS: [(&'static str, [[f32; 9]; 4]); {}] = [\n " , layouts. len( ) ) ;
94+ for ( name, mtxs) in layouts {
95+ code += "\t (\n " ;
96+ code += & format ! ( "\t \t \" {name}\" ,\n " ) ;
97+ code += "\t \t [\n " ;
98+ code += & format ! ( "\t \t \t {:?},\n " , mtxs[ 0 ] ) ;
99+ code += & format ! ( "\t \t \t {:?},\n " , mtxs[ 1 ] ) ;
100+ code += & format ! ( "\t \t \t {:?},\n " , mtxs[ 2 ] ) ;
101+ code += & format ! ( "\t \t \t {:?},\n " , mtxs[ 3 ] ) ;
102+ code += "\t \t ],\n " ;
103+ code += "\t ),\n " ;
98104 }
99105 code += "];\n " ;
100106 File :: create ( screen_layouts_file) . unwrap ( ) . write_all ( code. as_bytes ( ) ) . unwrap ( ) ;
0 commit comments