-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathlayout.go
63 lines (54 loc) · 973 Bytes
/
layout.go
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
package main
const (
MASTER_MAX_PROPORTION = 0.9
MASTER_MIN_PROPORTION = 0.1
)
type Layout interface {
Do()
Undo()
Add(c Client)
Remove(c Client)
MakeMaster(c Client)
IncMaster()
DecreaseMaster()
NextClient()
PreviousClient()
IncrementMaster()
DecrementMaster()
sto() *Store
}
type VertHorz struct {
*Store
Proportion float64
WorkspaceNum uint
}
func (l *VertHorz) Undo() {
for _, c := range append(l.masters, l.slaves...) {
c.Restore()
}
}
func (l *VertHorz) NextClient() {
c := l.Next()
c.Activate()
}
func (l *VertHorz) PreviousClient() {
c := l.Previous()
c.Activate()
}
func (l *VertHorz) IncrementMaster() {
value := l.Proportion + Config.Proportion
if value >= MASTER_MAX_PROPORTION {
return
}
l.Proportion = value
}
func (l *VertHorz) DecrementMaster() {
value := l.Proportion - Config.Proportion
if value <= MASTER_MIN_PROPORTION {
return
}
l.Proportion = value
}
func (l *VertHorz) sto() *Store {
return l.Store
}