-
Notifications
You must be signed in to change notification settings - Fork 0
/
whim.layouts.csx
86 lines (80 loc) · 2.94 KB
/
whim.layouts.csx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using Whim;
using Whim.SliceLayout;
public static class CustomLayouts
{
// Grid layout, inspired by LeftWM's GridHorizontal
public static ILayoutEngine CreateGridLayout(
IContext context,
ISliceLayoutPlugin plugin,
LayoutEngineIdentity identity,
string name = "Grid"
) => new SliceLayoutEngine(context, plugin, identity, CreateGridArea()) { Name = name };
internal static ParentArea CreateGridArea()
{
ParentArea parentArea = new (
isRow: true,
(0.25, new SliceArea(order: 1, maxChildren: 2)),
(0.5,
new ParentArea(
isRow: false,
(0.5, new SliceArea(order: 0, maxChildren: 1)),
(0.5, new SliceArea(order: 3, maxChildren: 1))
)
),
(0.25,
new ParentArea(
isRow: false,
(0.667, new SliceArea(order: 2, maxChildren: 2)),
(0.333, new OverflowArea())
)
)
);
return parentArea;
}
// Same as PrimaryStack, but with more config options
public static ILayoutEngine CreatePrimaryStackLayout(
IContext context,
ISliceLayoutPlugin plugin,
LayoutEngineIdentity identity,
double masterWidth = 0.5,
bool reverse = false,
string name = "Primary stack"
) => new SliceLayoutEngine(context, plugin, identity, CreatePrimaryStackArea(masterWidth, reverse)) { Name = name };
internal static ParentArea CreatePrimaryStackArea(double masterWidth, bool reverse)
{
int masterIdx = reverse ? 1 : 0;
(double, IArea)[] areas = new (double, IArea)[2];
areas[masterIdx] = (masterWidth, new SliceArea(order: 0, maxChildren: 1));
areas[1 - masterIdx] = (1 - masterWidth, new OverflowArea());
ParentArea parentArea = new(isRow: true, areas);
return parentArea;
}
// Same as SecondaryPrimaryLayout but with (slightly) more config options
public static ILayoutEngine CreateSecondaryPrimaryLayout(
IContext context,
ISliceLayoutPlugin plugin,
LayoutEngineIdentity identity,
uint primaryColumnCapacity = 1,
uint secondaryColumnCapacity = 2,
string name = "Secondary primary"
) =>
new SliceLayoutEngine(
context,
plugin,
identity,
CreateSecondaryPrimaryArea(primaryColumnCapacity, secondaryColumnCapacity)
)
{
Name = name
};
internal static ParentArea CreateSecondaryPrimaryArea(uint primaryColumnCapacity, uint secondaryColumnCapacity)
{
return new ParentArea(
isRow: true,
(0.25, new SliceArea(order: 1, maxChildren: secondaryColumnCapacity)),
(0.5, new SliceArea(order: 0, maxChildren: primaryColumnCapacity)),
(0.25, new OverflowArea())
);
}
}