8
8
package com.osfans.trime.ime.bar
9
9
10
10
import com.osfans.trime.ime.bar.QuickBarStateMachine.BooleanKey.CandidateEmpty
11
+ import com.osfans.trime.ime.bar.QuickBarStateMachine.BooleanKey.SuggestionEmpty
11
12
import com.osfans.trime.ime.bar.QuickBarStateMachine.State.Always
12
13
import com.osfans.trime.ime.bar.QuickBarStateMachine.State.Candidate
14
+ import com.osfans.trime.ime.bar.QuickBarStateMachine.State.Suggestion
13
15
import com.osfans.trime.ime.bar.QuickBarStateMachine.State.Tab
14
16
import com.osfans.trime.util.BuildTransitionEvent
15
17
import com.osfans.trime.util.EventStateMachine
@@ -20,10 +22,12 @@ object QuickBarStateMachine {
20
22
Always ,
21
23
Candidate ,
22
24
Tab ,
25
+ Suggestion ,
23
26
}
24
27
25
28
enum class BooleanKey : EventStateMachine .BooleanStateKey {
26
29
CandidateEmpty ,
30
+ SuggestionEmpty ,
27
31
}
28
32
29
33
enum class TransitionEvent (
@@ -32,16 +36,23 @@ object QuickBarStateMachine {
32
36
CandidatesUpdated ({
33
37
from(Always ) transitTo Candidate on (CandidateEmpty to false )
34
38
from(Candidate ) transitTo Always on (CandidateEmpty to true )
39
+ from(Suggestion ) transitTo Candidate on (CandidateEmpty to false )
35
40
}),
36
41
BarBoardWindowAttached ({
37
42
from(Always ) transitTo Tab
38
43
from(Candidate ) transitTo Tab
44
+ from(Suggestion ) transitTo Tab
39
45
}),
40
46
WindowDetached ({
41
47
// candidate state has higher priority so here it goes first
42
48
from(Tab ) transitTo Candidate on (CandidateEmpty to false )
49
+ from(Tab ) transitTo Suggestion on (SuggestionEmpty to false )
43
50
from(Tab ) transitTo Always
44
51
}),
52
+ SuggestionUpdated ({
53
+ from(Always ) transitTo Suggestion on (SuggestionEmpty to false )
54
+ from(Suggestion ) transitTo Always on (SuggestionEmpty to true )
55
+ }),
45
56
}
46
57
47
58
fun new (block : (State ) -> Unit ) =
@@ -50,6 +61,7 @@ object QuickBarStateMachine {
50
61
externalBooleanStates =
51
62
mutableMapOf (
52
63
CandidateEmpty to true ,
64
+ SuggestionEmpty to true ,
53
65
),
54
66
).apply {
55
67
onNewStateListener = block
0 commit comments