-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiwriteit.kv
439 lines (428 loc) · 13.4 KB
/
iwriteit.kv
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
#
# iWriteIt - You Like?
#
# Copyright (C) 2014 Suriyan Laohaprapanon
#
# For comments, suggestions or other messages, contact me at:
#
# This file is part of iWriteIt.
#
# iWriteIt is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iWriteIt is distributed in the hope that it will be fun,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iWriteIt. If not, see <http://www.gnu.org/licenses/>.
#
#:kivy 1.4
#:import os os
<DigitBox>:
size_hint: 0.5, 0.8
text: ""
canvas.before:
Color:
rgba: (1, 1, 1, 0.1)
Rectangle:
pos: self.pos
size: self.size
Label:
text: root.text
font_name: "fonts/RaiNgan.ttf"
font_size: 180
size: root.size
pos: root.pos
<AppSettings>:
orientation: 'vertical'
padding: 10
app: app
GridLayout:
cols: 2
Label:
text: 'Music'
font_name: "fonts/RaiNgan.ttf"
font_size: 32
Switch:
id: _music
active: True
Label:
text: "Voice"
font_name: "fonts/RaiNgan.ttf"
font_size: 32
Switch:
id: _voice
active: True
Label:
text: "Max digits"
font_name: "fonts/RaiNgan.ttf"
font_size: 32
Spinner:
id: _maxdigits
text: "2"
values: "2", "3"
font_name: "fonts/RaiNgan.ttf"
font_size: 32
opacity: 1.0
Label:
text: "Operation"
font_name: "fonts/RaiNgan.ttf"
font_size: 32
Spinner:
id: _operation
text: "Plus"
values: "Plus", "Minus", "Mix"
font_name: "fonts/RaiNgan.ttf"
font_size: 32
opacity: 1.0
Widget:
height: 10
Button:
font_name: "fonts/RaiNgan.ttf"
font_size: 40
size_hint: 1, 0.1
pos_hint: {'bottom': 0.9}
text: "Apply"
opacity: 1.0
on_release: root.write_settings()
<WriteBoard>:
digit1: _digit1
digit2: _digit2
digit3: _digit3
digit4: _digit4
result_area: _result_area
surface: _gesture
menu: _menu
FloatLayout:
GridLayout:
id: _menu
cols: 1
size_hint: 0.2, None
pos: 40, root.height - self.height - 40
Button:
text: "Back"
on_release: app.root.manager.current = 'start'
font_name: "fonts/RaiNgan.ttf"
font_size: 32
Button:
text: "Clear"
font_name: "fonts/RaiNgan.ttf"
font_size: 32
on_release: app.root.board.clear(True)
Button:
text: "?"
font_name: "fonts/RaiNgan.ttf"
font_size: 32
on_release: app.root.manager.current = 'mygesture'
GestureSurface:
id: _gesture
draw_timeout: 3
temporal_window: 1
bbox_margin: 10
line_width: 3
draw_bbox: True
use_random_color: True
BoxLayout:
cols: 1
orientation: 'vertical'
padding: 40
spacing: 10
GridLayout:
cols: 4
Label:
id: a4
text: "1"
bold: True
font_name: "fonts/RaiNgan.ttf"
font_size: 180
Label:
id: a3
text: "2"
bold: True
font_name: "fonts/RaiNgan.ttf"
font_size: 180
Label:
id: a2
text: "3"
bold: True
font_name: "fonts/RaiNgan.ttf"
font_size: 180
Label:
id: a1
text: "4"
bold: True
font_name: "fonts/RaiNgan.ttf"
font_size: 180
Label:
id: _operator
text: "+"
size_hint: 0.1, 0.1
font_name: "fonts/RaiNgan.ttf"
font_size: 120
pos_hint: {'right': 0.90}
GridLayout:
cols: 4
Label:
id: b4
text: "5"
bold: True
font_name: "fonts/RaiNgan.ttf"
font_size: 180
Label:
id: b3
text: "6"
bold: True
font_name: "fonts/RaiNgan.ttf"
font_size: 180
Label:
id: b2
text: "7"
bold: True
underline: True
font_name: "fonts/RaiNgan.ttf"
font_size: 180
Label:
id: b1
text: "8"
bold: True
underline: True
font_name: "fonts/RaiNgan.ttf"
font_size: 180
GridLayout:
id: _result_area
cols: 4
DigitBox:
id: _digit4
DigitBox:
id: _digit3
DigitBox:
id: _digit2
DigitBox:
id: _digit1
<MyGestureSavePopup>:
title: 'Specify your gesture name'
auto_dismiss: True
size_hint: None, None
size: 400, 400
GridLayout:
cols: 1
spacing: 10
padding: 10
rows_minimum: {0: 100}
TextInput:
id: filename
multiline: False
size_hint: 1, None
height: 20
Button:
id: save_btn
text: 'Save'
size_hint: 1, None
height: 45
Button:
id: cancel_btn
text: 'Cancel'
size_hint: 1, None
height: 45
on_press: root.dismiss()
<MyGestureLoadPopup>:
title: "Select your gesture name"
auto_dismiss: True
size_hint: None, None
size: 450, 420
FileChooserIconView:
id: filechooser
size_hint: None, None
size: 400, 350
filters: ['*.kg']
rootpath: os.getcwd() + '/gestures'
<MyGestureWidget>
surface: _surface
GridLayout:
cols: 1
Label:
size_hint: 0.1, None
text: 'Please trace the following number(s)\nto update your writing style.'
font_name: "fonts/RaiNgan.ttf"
font_size: 32
halign: 'center'
GestureSurface:
id: _surface
draw_timeout: 3
temporal_window: 1
bbox_margin: 10
line_width: 3
draw_bbox: True
use_random_color: True
GridLayout:
pos_hint: {'top': 1, 'right': 1}
cols: 5
padding: 10
DigitBox:
id: _mydigit0
text: "0"
font_name: "fonts/RaiNgan.ttf"
font_size: 80
DigitBox:
id: _mydigit1
text: "1"
font_name: "fonts/RaiNgan.ttf"
font_size: 80
DigitBox:
id: _mydigit2
text: "2"
font_name: "fonts/RaiNgan.ttf"
font_size: 80
DigitBox:
id: _mydigit3
text: "3"
font_name: "fonts/RaiNgan.ttf"
font_size: 80
DigitBox:
id: _mydigit4
text: "4"
font_name: "fonts/RaiNgan.ttf"
font_size: 80
DigitBox:
id: _mydigit5
text: "5"
font_name: "fonts/RaiNgan.ttf"
font_size: 80
DigitBox:
id: _mydigit6
text: "6"
font_name: "fonts/RaiNgan.ttf"
font_size: 80
DigitBox:
id: _mydigit7
text: "7"
font_name: "fonts/RaiNgan.ttf"
font_size: 80
DigitBox:
id: _mydigit8
text: "8"
font_name: "fonts/RaiNgan.ttf"
font_size: 80
DigitBox:
id: _mydigit9
text: "9"
font_name: "fonts/RaiNgan.ttf"
font_size: 80
# Background description:
<Background>:
source: self.source
allow_stretch: True
keep_ratio: False
size: self.size
<RootWidget>:
#This is the root widget's kv definition
id: _root
manager: manager
board: _board
settings: _settings
my_gesture: _my_gesture
ScreenManager:
id: manager
Screen:
name: 'start'
Background:
id: background
source: 'graphics/background.jpg'
GridLayout:
cols: 1
padding: 30
Label:
text: "[b]==> iWriteIt <==[/b]\n\njust write your answer\n\nare you like it?"
font_name: "fonts/RaiNgan.ttf"
font_size: 60
halign: 'center'
markup: True
GridLayout:
rows: 1
size_hint: 0.8, 0.2
pos_hint: {'bottom': 0.8}
spacing: 50
Button:
text: "Start"
font_name: "fonts/RaiNgan.ttf"
font_size: 40
on_release: app.start()
Button:
text: "Settings"
on_release: app.settings()
font_name: "fonts/RaiNgan.ttf"
font_size: 40
Label:
size_hint: 1, 0.1
text: "Copyright (c) 2014 Suriyan Laohaprapanon"
font_size: 10
halign: 'center'
markup: True
Screen:
name: 'writing'
on_enter: root.board.on_enter()
Background:
id: background
source: 'graphics/background.jpg'
WriteBoard:
id: _board
root: _root
Screen:
name: 'settings'
Background:
id: background
source: 'graphics/background.jpg'
GridLayout:
cols: 1
padding: 30
AppSettings:
id: _settings
Button:
font_name: "fonts/RaiNgan.ttf"
font_size: 40
size_hint: 0.5, 0.1
pos_hint: {'bottom': 0.9}
text: "Back"
on_release: app.root.manager.current = 'start'
Screen:
name: 'mygesture'
on_enter: root.my_gesture.on_enter()
on_pre_leave: root.my_gesture.on_pre_leave()
Background:
id: background
source: 'graphics/background.jpg'
GridLayout:
cols: 1
padding: 20
MyGestureWidget:
id: _my_gesture
root: _root
GridLayout:
rows: 1
size_hint: 0.5, 0.1
pos_hint: {'bottom': 0.9}
Button:
font_name: "fonts/RaiNgan.ttf"
font_size: 40
text: "Back"
on_release: app.root.manager.current = 'writing'
Button:
font_name: "fonts/RaiNgan.ttf"
font_size: 40
text: "Clear"
on_release: root.my_gesture.clear()
Button:
font_name: "fonts/RaiNgan.ttf"
font_size: 40
text: "Load"
on_release: root.my_gesture.load()
Button:
font_name: "fonts/RaiNgan.ttf"
font_size: 40
text: "Save"
on_release: root.my_gesture.save()