-
-
Notifications
You must be signed in to change notification settings - Fork 354
/
GTSpotterHeaderBrick.class.st
203 lines (147 loc) · 5.04 KB
/
GTSpotterHeaderBrick.class.st
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
Class {
#name : #GTSpotterHeaderBrick,
#superclass : #GLMBrick,
#instVars : [
'searchField',
'closeButton',
'spotterModel',
'settingsButton',
'helpButton'
],
#category : #'GT-Spotter-UI-Widgets'
}
{ #category : #accessing }
GTSpotterHeaderBrick >> closeButton [
^ closeButton
]
{ #category : #accessing }
GTSpotterHeaderBrick >> closeButton: aBrick [
closeButton ifNotNil: [self removeBrick: closeButton].
closeButton := aBrick.
self themer spotterThemer closeButtonWidgetStyleFor: closeButton.
self themer spotterThemer closeButtonStyleFor: closeButton.
closeButton
hintTitle: 'Close Spotter';
hintText: '<escape>';
action: [ self spotterModel exitDueTo: #actionButton ].
self addBrickBack: closeButton
]
{ #category : #accessing }
GTSpotterHeaderBrick >> helpButton [
^ helpButton
]
{ #category : #accessing }
GTSpotterHeaderBrick >> helpButton: aBrick [
| tree item |
helpButton ifNotNil: [self removeBrick: helpButton].
helpButton := aBrick.
self themer spotterThemer helpButtonWidgetStyleFor: helpButton.
self themer spotterThemer helpButtonStyleFor: helpButton.
helpButton
hintTitle: 'Spotter help';
action: [
self spotterModel exitDueTo: #actionButton.
tree := HelpBrowser open instVarNamed: #treeMorph.
item := tree allItems detect: [:each |
each complexContents item key = GTSpotterHelp key].
tree selection: item ].
self addBrickBack: helpButton
]
{ #category : #initialization }
GTSpotterHeaderBrick >> initialize [
super initialize.
self searchField: self newSearchField.
self class environment at: #GTEventRecorderSettings ifPresent: [
self settingsButton: self newSettingsButton ].
self helpButton: self newHelpButton.
self closeButton: self newCloseButton.
]
{ #category : #'instance creation' }
GTSpotterHeaderBrick >> newCloseButton [
^ GLMHintableActionButtonBrick new
]
{ #category : #'instance creation' }
GTSpotterHeaderBrick >> newHelpButton [
^ GLMHintableActionButtonBrick new
]
{ #category : #'instance creation' }
GTSpotterHeaderBrick >> newSearchField [
^ GLMRubTextFieldBrick new
]
{ #category : #'instance creation' }
GTSpotterHeaderBrick >> newSettingsButton [
^ GLMHintableActionButtonBrick new
]
{ #category : #'instance creation' }
GTSpotterHeaderBrick >> newStepsBand [
^ GLMBrick new
]
{ #category : #'event handling' }
GTSpotterHeaderBrick >> onCurrentStepChanged [
self searchField rubric updateTextWith: self spotterModel currentStep context text.
self searchField rubric selectFrom: self searchField rubric text size + 1 to: self searchField rubric text size
]
{ #category : #'event handling' }
GTSpotterHeaderBrick >> onHideHints [
self themer spotterThemer hintHideStyleFor: self settingsButton.
self themer spotterThemer hintHideStyleFor: self closeButton.
self themer spotterThemer hintHideStyleFor: self helpButton.
]
{ #category : #'event handling' }
GTSpotterHeaderBrick >> onRevealHints [
self themer spotterThemer hintRevealStyleFor: self settingsButton.
self themer spotterThemer hintRevealStyleFor: self closeButton.
self themer spotterThemer hintRevealStyleFor: self helpButton
]
{ #category : #'brick-properties-events' }
GTSpotterHeaderBrick >> onThemerChanged [
super onThemerChanged.
self themer spotterThemer headerWidgetStyleFor: self.
self themer spotterThemer closeButtonWidgetStyleFor: self closeButton.
self themer spotterThemer searchFieldWidgetStyleFor: self searchField.
self class environment at: #GTEventRecorderSettings ifPresent: [self themer spotterThemer settingsButtonWidgetStyleFor: self settingsButton]
]
{ #category : #accessing }
GTSpotterHeaderBrick >> openSettingsBrowser [
GLMPrivacyAgreementBrick openSettingsBrowser.
self spotterModel exitDueTo: #openSettingsBrowser.
]
{ #category : #accessing }
GTSpotterHeaderBrick >> searchField [
^ searchField
]
{ #category : #accessing }
GTSpotterHeaderBrick >> searchField: aBrick [
searchField := aBrick.
self themer spotterThemer searchFieldStyleFor: searchField.
searchField morph takeKeyboardFocus.
self addBrickBack: searchField
]
{ #category : #accessing }
GTSpotterHeaderBrick >> settingsButton [
^ settingsButton
]
{ #category : #accessing }
GTSpotterHeaderBrick >> settingsButton: aBrick [
settingsButton ifNotNil: [self removeBrick: settingsButton].
settingsButton := aBrick.
self themer spotterThemer settingsButtonWidgetStyleFor: settingsButton.
self themer spotterThemer settingsButtonStyleFor: settingsButton.
settingsButton
hintTitle: 'Settings';
hintText: 'Shows the settings UI';
action: [ self openSettingsBrowser ].
self addBrickBack: settingsButton
]
{ #category : #accessing }
GTSpotterHeaderBrick >> spotterModel [
^ spotterModel
]
{ #category : #accessing }
GTSpotterHeaderBrick >> spotterModel: aModel [
spotterModel := aModel.
self searchField morph on: spotterModel.
spotterModel announcer when: GTSpotterCurrentStepChanged send: #onCurrentStepChanged to: self.
self spotterModel announcer when: GTSpotterRevealHints send: #onRevealHints to: self.
self spotterModel announcer when: GTSpotterHideHints send: #onHideHints to: self.
]