-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnavigator.ts
More file actions
115 lines (102 loc) · 3.33 KB
/
navigator.ts
File metadata and controls
115 lines (102 loc) · 3.33 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
namespace microcode {
import RowNavigator = user_interface_base.RowNavigator
import PickerNavigator = user_interface_base.PickerNavigator
import Picker = user_interface_base.Picker
import Button = user_interface_base.Button
// this adds accessibility for rule
export class RuleRowNavigator extends RowNavigator {
private rules: RuleDefn[]
constructor() {
super()
this.rules = []
}
getRowCount() {
return this.buttonGroups.length
}
/* overrides */
public clear() {
super.clear()
this.rules = []
}
public addRule(rule: RuleDefn) {
this.rules.push(rule)
}
public atRuleStart() {
return this.row >= 1 && this.col == 0
}
protected reportAria(ret: Button) {
if (!reportAria) return
if (!ret) {
return
}
let accessibilityMessage: accessibility.AccessibilityMessage
if (this.row > 0 && this.col == 0) {
const ruleDef = this.rules[this.row - 1]
const whens = ruleDef.sensors
.concat(ruleDef.filters)
.map(s => tidToString(s))
const dos: string[] = ruleDef.actuators
.concat(ruleDef.modifiers.map(t => getTid(t)))
.map(s => tidToString(s))
accessibilityMessage = <accessibility.RuleAccessibilityMessage>{
type: "rule",
whens,
dos,
}
} else {
accessibilityMessage = <accessibility.TileAccessibilityMessage>{
type: "tile",
value: (ret ? ret.ariaId : "") || "",
force: true,
}
}
accessibility.setLiveContent(accessibilityMessage)
}
}
// accessibility for melody
export class MelodyNavigator extends PickerNavigator {
constructor(picker: Picker) {
super(picker)
this.row = 2
this.col = 2
}
protected reportAria() {
if (!reportAria) return
super.reportAria()
if (this.row == -1) return
const on = true // TODO btn.getIcon() === "note_on"
const index = this.hasDelete ? this.row - 1 : this.row
accessibility.setLiveContent(<
accessibility.NoteAccessibilityMessage
>{
type: "note",
on,
index,
force: true,
})
}
}
// accessibility for LEDs
export class LEDNavigator extends PickerNavigator {
constructor(picker: Picker) {
super(picker)
this.row = 2
this.col = 2
}
protected reportAria() {
if (!reportAria) return
super.reportAria()
if (this.row == -1) return
const on = true // TODO: btn.getIcon() == "solid_red"
accessibility.setLiveContent(<
accessibility.LEDAccessibilityMessage
>{
type: "led",
on,
x: this.col,
y: this.row,
force: true,
})
}
}
}