1
1
import { logger } from "@/utils/shell" ;
2
2
import GLib from "@gi-types/glib2" ;
3
- import { TileGroup } from "@/components/layout/tileGroup " ;
4
- import { LAYOUT_HORIZONTAL_TYPE , Layout } from "./Layout " ;
3
+ import { Layout } from "./Layout " ;
4
+ import { Tile } from "./Tile " ;
5
5
6
6
const debug = logger ( 'LayoutsUtils' ) ;
7
7
@@ -14,28 +14,22 @@ export class LayoutsUtils {
14
14
return GLib . build_filenamev ( [ this . configPath , 'layouts.json' ] ) ;
15
15
}
16
16
17
- public static LoadLayouts ( ) : TileGroup [ ] {
17
+ public static LoadLayouts ( ) : Layout [ ] {
18
18
const availableLayouts = [
19
- new TileGroup ( { } ) ,
20
- new TileGroup ( {
21
- tiles : [
22
- new TileGroup ( { perc : 0.22 } ) ,
23
- new TileGroup ( { perc : 0.56 } ) ,
24
- new TileGroup ( { perc : 0.22 } ) ,
25
- ] ,
26
- } ) ,
27
- new TileGroup ( {
28
- tiles : [
29
- new TileGroup ( { perc : 0.33 } ) ,
30
- new TileGroup ( { perc : 0.67 } ) ,
31
- ] ,
32
- } ) ,
33
- new TileGroup ( {
34
- tiles : [
35
- new TileGroup ( { perc : 0.67 } ) ,
36
- new TileGroup ( { perc : 0.33 } ) ,
37
- ] ,
38
- } )
19
+ new Layout ( [ ] ) ,
20
+ new Layout ( [
21
+ new Tile ( { x :0 , y :0 , height : 1 , width : 0.22 } ) ,
22
+ new Tile ( { x :0.22 , y :0 , height : 1 , width : 0.56 } ) ,
23
+ new Tile ( { x :0.78 , y :0 , height : 1 , width : 0.22 } ) ,
24
+ ] ) ,
25
+ new Layout ( [
26
+ new Tile ( { x :0 , y :0 , height : 1 , width : 0.33 } ) ,
27
+ new Tile ( { x :0.33 , y :0 , height : 1 , width : 0.67 } ) ,
28
+ ] ) ,
29
+ new Layout ( [
30
+ new Tile ( { x :0.33 , y :0 , height : 1 , width : 0.67 } ) ,
31
+ new Tile ( { x :0 , y :0 , height : 1 , width : 0.33 } ) ,
32
+ ] ) ,
39
33
] ;
40
34
const filePath = this . layoutsPath ;
41
35
if ( GLib . file_test ( filePath , GLib . FileTest . EXISTS ) ) {
@@ -45,8 +39,7 @@ export class LayoutsUtils {
45
39
const decoder = new TextDecoder ( 'utf-8' ) ;
46
40
let contentsString = decoder . decode ( contents ) ;
47
41
const parsed = JSON . parse ( contentsString ) ;
48
- const layouts = parsed . definitions as Layout [ ] ;
49
- availableLayouts [ 0 ] = this . _layoutToTileGroup ( layouts [ 0 ] ) ;
42
+ return parsed . definitions as Layout [ ] ;
50
43
}
51
44
} catch ( exception ) {
52
45
debug ( `exception loading layouts: ${ JSON . stringify ( exception ) } ` ) ;
@@ -56,27 +49,13 @@ export class LayoutsUtils {
56
49
return availableLayouts ;
57
50
}
58
51
59
- private static _layoutToTileGroup ( layout : Layout ) : TileGroup {
60
- return new TileGroup ( {
61
- perc : layout . length / 100 ,
62
- horizontal : layout . type === LAYOUT_HORIZONTAL_TYPE ,
63
- tiles : layout . items ? layout . items . map ( LayoutsUtils . _layoutToTileGroup ) :[ ] ,
64
- } ) ;
65
- }
66
-
67
- private static _getDefaultLayout ( ) : TileGroup {
68
- return new TileGroup ( {
69
- tiles : [
70
- new TileGroup ( { perc : 0.22 , horizontal : false , tiles : [
71
- new TileGroup ( { perc : 0.5 } ) ,
72
- new TileGroup ( { perc : 0.5 } )
73
- ] } ) ,
74
- new TileGroup ( { perc : 0.56 } ) ,
75
- new TileGroup ( { perc : 0.22 , horizontal : false , tiles : [
76
- new TileGroup ( { perc : 0.5 } ) ,
77
- new TileGroup ( { perc : 0.5 } )
78
- ] } ) ,
79
- ] ,
80
- } ) ;
52
+ private static _getDefaultLayout ( ) : Layout {
53
+ return new Layout ( [
54
+ new Tile ( { x :0 , y :0 , height : 0.5 , width : 0.22 } ) , // top-left
55
+ new Tile ( { x :0 , y :0.5 , height : 0.5 , width : 0.22 } ) , // bottom-left
56
+ new Tile ( { x :0.22 , y :0 , height : 1 , width : 0.56 } ) , // center
57
+ new Tile ( { x :0.78 , y :0 , height : 0.5 , width : 0.22 } ) , // top-right
58
+ new Tile ( { x :0.78 , y :0.5 , height : 0.5 , width : 0.22 } ) , // bottom-right
59
+ ] ) ;
81
60
}
82
61
}
0 commit comments