]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blob - music_sampler/music_sampler.kv
Precompute font size in kv file
[perso/Immae/Projets/Python/MusicSampler.git] / music_sampler / music_sampler.kv
1 #:import math math
2
3 <Key>:
4 pad_col_sep: 0 if not self.pad_cols else self.parent.pad_x
5 pad_cols: False
6
7 y: (self.parent.top-self.parent.y) - (self.row) * self.parent.key_size - (self.row - 1) * self.parent.key_sep
8 x: (self.col - 1) * self.parent.key_size + int(self.col - 1) * self.parent.key_sep + self.pad_col_sep
9 size_hint: None, None
10 enabled: True
11 line_width: 2
12 row: 1
13 col: 0
14 key_code: 0
15 key_sym: ""
16 key_width: 1
17 key_height: 1
18 width: self.key_width * (self.parent.key_size + self.parent.key_sep) - self.parent.key_sep
19 height: self.key_height * (self.parent.key_size + self.parent.key_sep) - self.parent.key_sep
20 normal_font_size: self.parent.font_size
21 smaller_font_size: math.ceil(2 * math.sqrt(self.parent.key_size / 2))
22 canvas.before:
23 Color:
24 rgba: self.color
25 RoundedRectangle:
26 pos: self.x, self.y
27 size: self.size
28 canvas:
29 Color:
30 rgba: self.line_color
31 Line:
32 rounded_rectangle: self.x + self.line_width, self.y + self.line_width, self.width - 2 * self.line_width, self.height - 2 * self.line_width, 10
33 width: self.line_width
34 Color:
35 rgba: self.line_cross_color
36 Line:
37 points: self.x + self.line_width + 3, self.y + self.line_width + 3, self.x + self.width - 2 * self.line_width - 3, self.y + self.height - 2 * self.line_width - 3
38 width: self.line_width
39 Line:
40 points: self.x + self.line_width + 3, self.y + self.height - 2 * self.line_width - 3, self.x + self.width - 2 * self.line_width - 3, self.y + self.line_width + 3
41 width: self.line_width
42 Label:
43 id: key_label
44 font_name: "Ubuntu"
45 bold: True
46 font_size: self.parent.normal_font_size or 10
47 color: 0, 0, 0, 1
48 text: self.parent.key_sym
49 text_size: self.parent.width,self.font_size
50 shorten: True
51 shorten_from: "right"
52 split_str: ""
53 center_x: self.parent.x + self.texture_size[0] /2 + 5
54 center_y: self.parent.y + self.parent.height - self.texture_size[1] /2 - 5
55 Label:
56 id: key_description_title
57 font_name: "Ubuntu"
58 font_size: self.parent.smaller_font_size or 8
59 color: 0, 0, 0, 1
60 text: self.parent.description_title
61 text_size: self.parent.width - 2*self.parent.line_width, self.font_size
62 halign: "right"
63 valign: "middle"
64 center_x: self.parent.x + self.texture_size[0] /2
65 center_y: self.parent.y + self.parent.height - self.texture_size[1] /2 - 5
66 Label:
67 id: key_description
68 font_name: "Ubuntu"
69 font_size: self.parent.smaller_font_size or 8
70 color: 0, 0, 0, 1
71 text: "\n".join(self.parent.description)
72 text_size: 2 * self.parent.width,self.parent.height - key_label.font_size
73 halign: "left"
74 valign: "middle"
75 pos: self.parent.x + 2 * self.parent.line_width + 2, self.parent.y
76 size_hint: None, None
77 size: 2 * self.parent.width - 2 * self.parent.line_width, self.parent.height - key_label.font_size
78
79 <Screen>:
80 canvas:
81 Color:
82 rgba: 229/255, 228/255, 226/255, 1
83 Rectangle:
84 pos: 0, 0
85 size: self.width, self.height
86
87 key_size: int( (3 * self.width - 16) / 56)
88 key_sep: int( self.key_size / 24)
89 key_pad_sep: int( self.key_size / 7) + 1
90
91 border: (self.width - self.key_size * 18 - self.key_sep * 16 - self.key_pad_sep)/ 2
92
93 mapping_height: self.key_size * 6 + self.key_sep * 5
94 mapping_width: self.key_size * 18 + self.key_sep * 16 + self.key_pad_sep
95 mapping_x: self.border
96 mapping_y: self.top - self.mapping_height - self.border
97
98 key_list_width: 4 * (mock_ubuntu_regular.width or 0)
99 key_list_height: self.height - self.mapping_height - 3 * self.border
100 key_list_x: (self.action_list_width or 0) + 2 * self.border
101 key_list_y: self.border
102
103 action_list_height: self.height - self.mapping_height - 3 * self.border
104 action_list_width: 3 * self.width / 4 - self.key_list_width - self.border
105 action_list_x: self.border
106 action_list_y: self.border
107
108 play_list_height: self.action_list_height
109 play_list_width: self.width - self.key_list_width - self.action_list_width - 4* self.border
110 play_list_y: self.border
111 play_list_x: self.action_list_width + self.key_list_width + 3 * self.border
112
113 font_size: math.ceil(2 * math.sqrt(self.key_size or 10))
114 max_height: 1.3 * self.font_size
115
116 Label:
117 id: mock_ubuntu_regular
118 font_name: "Ubuntu"
119 font_size: self.parent.font_size
120 color: 0, 0, 0, 0
121 text: "A"
122 text_size: None, None
123 size_hint: None, None
124 size: self.texture_size
125
126 Mapping:
127 id: Mapping
128 pos: self.parent.mapping_x, self.parent.mapping_y
129 size: self.parent.mapping_width, self.parent.mapping_height
130
131 key_size: self.parent.key_size
132 key_sep: self.parent.key_sep
133 key_pad_sep: self.parent.key_pad_sep
134 pad_x: self.key_size * 15 + 14 * self.key_sep + self.key_pad_sep
135 ActionList:
136 id: ActionList
137 pos: self.parent.action_list_x, self.parent.action_list_y
138 size: self.parent.action_list_width, self.parent.action_list_height
139 KeyList:
140 id: KeyList
141 pos: self.parent.key_list_x, self.parent.key_list_y
142 size: self.parent.key_list_width, self.parent.key_list_height
143 PlayList:
144 id: PlayList
145 pos: self.parent.play_list_x, self.parent.play_list_y
146 size: self.parent.play_list_width, self.parent.play_list_height
147
148 <KeyList>:
149 font_size: self.parent.font_size or 10
150 size_hint: None, None
151 canvas:
152 Color:
153 rgba: 250./255, 250./255, 250./255, 1
154 Rectangle:
155 pos: 0, 0
156 size: self.width, self.height
157 Label:
158 id: key_list_first
159 font_name: "Ubuntu"
160 bold: True
161 font_size: self.parent.font_size
162 color: 0, 0, 0, 1
163 text: self.parent.first_key
164 text_size: None, None
165 valign: "top"
166 halign: "center"
167 size_hint: None, None
168 size: self.parent.width, self.texture_size[1]
169 pos: 0, self.parent.height - self.height
170 Label:
171 id: key_list_second
172 font_name: "Ubuntu"
173 font_size: self.parent.font_size
174 color: 0, 0, 0, 1
175 text: self.parent.second_key
176 text_size: None, None
177 valign: "top"
178 halign: "center"
179 size_hint: None, None
180 size: self.parent.width, self.texture_size[1]
181 pos: 0, self.parent.height - key_list_first.height - self.height
182 Label:
183 id: key_list_third
184 font_name: "Ubuntu"
185 font_size: self.parent.font_size
186 color: 0, 0, 0, 0.75
187 text: self.parent.third_key
188 text_size: None, None
189 valign: "top"
190 halign: "center"
191 size_hint: None, None
192 size: self.parent.width, self.texture_size[1]
193 pos: 0, self.parent.height - key_list_first.height - key_list_second.height - self.height
194 Label:
195 id: key_list_rest
196 font_name: "Ubuntu"
197 font_size: self.parent.font_size
198 color: 0, 0, 0, 0.5
199 text: "\n".join(self.parent.keylist[3:])
200 text_size: None, None
201 valign: "top"
202 halign: "center"
203 size_hint: None, None
204 size: self.parent.width, self.texture_size[1]
205 pos: 0, self.parent.height - key_list_first.height - key_list_second.height - key_list_third.height - self.height
206
207 <ActionList>:
208 size_hint: None, None
209 labels_height: self.parent.max_height or 1
210 font_size: self.parent.font_size or 10
211 canvas:
212 Color:
213 rgba: 250./255, 250./255, 250./255, 1
214 Rectangle:
215 pos: 0, 0
216 size: self.width, self.height
217 Label:
218 id: action_list_title
219 font_name: "Ubuntu"
220 bold: True
221 font_size: self.parent.font_size
222 color: 0, 0, 0, 1
223 text: self.parent.action_title
224 text_size: None, self.parent.height
225 halign: "left"
226 valign: "top"
227 size_hint: None, None
228 size: self.texture_size[0], self.parent.height
229 ActionListIcons:
230 font_size: self.parent.font_size
231 labels_height: self.parent.labels_height
232 orientation: 'lr-tb'
233 size_hint: 0.02, 0.9
234 pos_hint: { 'x': 0, 'top': 0.9 }
235 ActionListDescriptions:
236 font_size: self.parent.font_size
237 labels_height: self.parent.labels_height
238 orientation: 'lr-tb'
239 size_hint: 0.98, 0.9
240 pos_hint: { 'x': 0.02, 'top': 0.9 }
241
242 <ActionListIcon>:
243 font_size: self.parent and self.parent.font_size or 10
244 height: self.parent and self.parent.labels_height or 0
245 font_name: "Symbola"
246 color: 0, 0, 0, 1
247 text_size: None, None
248 halign: "left"
249 size_hint: None, None
250 width: self.texture_size[0]
251
252 <ActionListDescription>:
253 font_size: self.parent and self.parent.font_size or 10
254 height: self.parent and self.parent.labels_height or 0
255 font_name: "Ubuntu"
256 color: 0, 0, 0, 1
257 text_size: self.width, None
258 shorten: True
259 shorten_from: "right"
260 split_str: ""
261 halign: "left"
262 size_hint: 1, None
263
264 <PlayList>:
265 size_hint: None, None
266 labels_height: self.parent.max_height or 1
267 font_size: self.parent.font_size or 10
268 canvas:
269 Color:
270 rgba: 250./255, 250./255, 250./255, 1
271 Rectangle:
272 pos: 0, 0
273 size: self.width, self.height
274 PlayListIcons:
275 font_size: self.parent.font_size
276 labels_height: self.parent.labels_height
277 orientation: 'lr-tb'
278 size_hint: 0.05, 1
279 pos_hints: { 'x': 0, 'top': 0 }
280 PlayListNames:
281 font_size: self.parent.font_size
282 labels_height: self.parent.labels_height
283 orientation: 'lr-tb'
284 pos_hint: { 'x': 0.05, 'bottom': 0 }
285 size_hint: 0.65, 1
286 PlayListTimes:
287 font_size: self.parent.font_size
288 labels_height: self.parent.labels_height
289 orientation: 'lr-tb'
290 pos_hint: { 'x': 0.7, 'bottom': 0 }
291 size_hint: 0.30, 1
292
293 <PlayListIcon>:
294 font_size: self.parent and self.parent.font_size or 10
295 height: self.parent and self.parent.labels_height or 0
296 font_name: "Symbola"
297 color: 0, 0, 0, 1
298 text_size: None, None
299 halign: "left"
300 size_hint: None, None
301 width: self.texture_size[0]
302
303 <PlayListName>:
304 font_size: self.parent and self.parent.font_size or 10
305 height: self.parent and self.parent.labels_height or 0
306 font_name: "Ubuntu"
307 color: 0, 0, 0, 1
308 text_size: self.width, None
309 shorten: True
310 shorten_from: "right"
311 split_str: ""
312 halign: "left"
313 size_hint: 1, None
314
315 <PlayListTime>:
316 font_size: self.parent and self.parent.font_size or 10
317 height: self.parent and self.parent.labels_height or 0
318 canvas.before:
319 Color:
320 rgba: 250./255, 250./255, 250./255, 1
321 Rectangle:
322 pos: self.pos
323 size: self.width, self.height
324 font_name: "Ubuntu"
325 color: 0, 0, 0, 1
326 text_size: None, None
327 halign: "left"
328 size_hint: None, None
329 width: self.texture_size[0]
330
331 <Mapping>:
332 size_hint: None, None
333 key_size: 48
334 font_size: self.parent.font_size
335 key_sep: 2
336 key_pad_sep: 7
337 pad_x: 755
338 canvas:
339 Color:
340 rgba: 250./255, 250./255, 250./255, 1
341 Rectangle:
342 pos: 0, 0
343 size: self.width, self.height
344 Color:
345 rgba: self.ready_color
346 Ellipse:
347 pos: self.width - self.key_size / 2, self.height - self.key_size /2
348 size: self.key_size / 3, self.key_size / 3
349 Label:
350 font_name: "Ubuntu"
351 font_size: self.parent.font_size or 10
352 color: 0, 0, 0, 1
353 text: "volume: {}%".format(self.parent.master_volume)
354 valign: "top"
355 size_hint: None, None
356 size: self.texture_size[0], self.texture_size[1]
357 x: self.parent.width - self.width - 2 * self.parent.key_size / 3
358 center_y: self.parent.height - self.height
359 Key:
360 id: Key_27
361 key_code: 27
362 key_sym: "ESC"
363 row: 1
364 col: 1
365 Key:
366 id: Key_282
367 key_code: 282
368 key_sym: "F1"
369 row: 1
370 col: 3
371 Key:
372 id: Key_283
373 key_code: 283
374 key_sym: "F2"
375 row: 1
376 col: 4
377 Key:
378 id: Key_284
379 key_code: 284
380 key_sym: "F3"
381 row: 1
382 col: 5
383 Key:
384 id: Key_285
385 key_code: 285
386 key_sym: "F4"
387 row: 1
388 col: 6
389
390 Key:
391 id: Key_286
392 key_code: 286
393 key_sym: "F5"
394 row: 1
395 col: 7.5
396 Key:
397 id: Key_287
398 key_code: 287
399 key_sym: "F6"
400 row: 1
401 col: 8.5
402 Key:
403 id: Key_288
404 key_code: 288
405 key_sym: "F7"
406 row: 1
407 col: 9.5
408 Key:
409 id: Key_289
410 key_code: 289
411 key_sym: "F8"
412 row: 1
413 col: 10.5
414
415 Key:
416 id: Key_290
417 key_code: 290
418 key_sym: "F9"
419 row: 1
420 col: 12
421 Key:
422 id: Key_291
423 key_code: 291
424 key_sym: "F10"
425 row: 1
426 col: 13
427 Key:
428 id: Key_292
429 key_code: 292
430 key_sym: "F11"
431 row: 1
432 col: 14
433 Key:
434 id: Key_293
435 key_code: 293
436 key_sym: "F12"
437 row: 1
438 col: 15
439
440 Key:
441 id: Key_178
442 key_code: 178
443 key_sym: "ยฒ"
444 row: 2
445 col: 1
446 Key:
447 id: Key_38
448 key_code: 38
449 key_sym: "&"
450 row: 2
451 col: 2
452 Key:
453 id: Key_233
454 key_code: 233
455 key_sym: "รฉ"
456 row: 2
457 col: 3
458 Key:
459 id: Key_34
460 key_code: 34
461 key_sym: '"'
462 row: 2
463 col: 4
464 Key:
465 id: Key_39
466 key_code: 39
467 key_sym: "'"
468 row: 2
469 col: 5
470 Key:
471 id: Key_40
472 key_code: 40
473 key_sym: "("
474 row: 2
475 col: 6
476 Key:
477 id: Key_45
478 key_code: 45
479 key_sym: "-"
480 row: 2
481 col: 7
482 Key:
483 id: Key_232
484 key_code: 232
485 key_sym: "รจ"
486 row: 2
487 col: 8
488 Key:
489 id: Key_95
490 key_code: 95
491 key_sym: "_"
492 row: 2
493 col: 9
494 Key:
495 id: Key_231
496 key_code: 231
497 key_sym: "รง"
498 row: 2
499 col: 10
500 Key:
501 id: Key_224
502 key_code: 224
503 key_sym: "ร "
504 row: 2
505 col: 11
506 Key:
507 id: Key_41
508 key_code: 41
509 key_sym: ")"
510 row: 2
511 col: 12
512 Key:
513 id: Key_61
514 key_code: 61
515 key_sym: "="
516 row: 2
517 col: 13
518 Key:
519 id: Key_8
520 key_code: 8
521 key_sym: "<-"
522 row: 2
523 col: 14
524 key_width: 2
525 Key:
526 id: Key_9
527 key_code: 9
528 key_sym: "tab"
529 row: 3
530 col: 1
531 key_width: 1.48
532 Key:
533 id: Key_97
534 key_code: 97
535 key_sym: "a"
536 row: 3
537 col: 2.5
538 Key:
539 id: Key_122
540 key_code: 122
541 key_sym: "z"
542 row: 3
543 col: 3.5
544 Key:
545 id: Key_101
546 key_code: 101
547 key_sym: "e"
548 row: 3
549 col: 4.5
550 Key:
551 id: Key_114
552 key_code: 114
553 key_sym: "r"
554 row: 3
555 col: 5.5
556 Key:
557 id: Key_116
558 key_code: 116
559 key_sym: "t"
560 row: 3
561 col: 6.5
562 Key:
563 id: Key_121
564 key_code: 121
565 key_sym: "y"
566 row: 3
567 col: 7.5
568 Key:
569 id: Key_117
570 key_code: 117
571 key_sym: "u"
572 row: 3
573 col: 8.5
574 Key:
575 id: Key_105
576 key_code: 105
577 key_sym: "i"
578 row: 3
579 col: 9.5
580 Key:
581 id: Key_111
582 key_code: 111
583 key_sym: "o"
584 row: 3
585 col: 10.5
586 Key:
587 id: Key_112
588 key_code: 112
589 key_sym: "p"
590 row: 3
591 col: 11.5
592 Key:
593 id: Key_94
594 key_code: 94
595 key_sym: "^"
596 row: 3
597 col: 12.5
598 Key:
599 id: Key_36
600 key_code: 36
601 key_sym: "$"
602 row: 3
603 col: 13.5
604 Key:
605 id: Key_13
606 key_code: 13
607 key_sym: "Enter"
608 row: 4
609 col: 14.8
610 key_width: 1.23
611 key_height: 2
612 Key:
613 id: Key_301
614 key_code: 301
615 key_sym: "CAPS"
616 row: 4
617 col: 1
618 key_width: 1.75
619 line_width: 1
620 enabled: False
621
622 Key:
623 id: Key_113
624 key_code: 113
625 key_sym: "q"
626 row: 4
627 col: 2.8
628 Key:
629 id: Key_115
630 key_code: 115
631 key_sym: "s"
632 row: 4
633 col: 3.8
634 Key:
635 id: Key_100
636 key_code: 100
637 key_sym: "d"
638 row: 4
639 col: 4.8
640 Key:
641 id: Key_102
642 key_code: 102
643 key_sym: "f"
644 row: 4
645 col: 5.8
646 Key:
647 id: Key_103
648 key_code: 103
649 key_sym: "g"
650 row: 4
651 col: 6.8
652 Key:
653 id: Key_104
654 key_code: 104
655 key_sym: "h"
656 row: 4
657 col: 7.8
658 Key:
659 id: Key_106
660 key_code: 106
661 key_sym: "j"
662 row: 4
663 col: 8.8
664 Key:
665 id: Key_107
666 key_code: 107
667 key_sym: "k"
668 row: 4
669 col: 9.8
670 Key:
671 id: Key_108
672 key_code: 108
673 key_sym: "l"
674 row: 4
675 col: 10.8
676 Key:
677 id: Key_109
678 key_code: 109
679 key_sym: "m"
680 row: 4
681 col: 11.8
682 Key:
683 id: Key_249
684 key_code: 249
685 key_sym: "รน"
686 row: 4
687 col: 12.8
688 Key:
689 id: Key_42
690 key_code: 42
691 key_sym: "*"
692 row: 4
693 col: 13.8
694 Key:
695 id: Key_304
696 key_code: 304
697 key_sym: "LShift"
698 row: 5
699 col: 1
700 key_width: 1.3
701 line_width: 1
702 enabled: False
703 Key:
704 id: Key_60
705 key_code: 60
706 key_sym: "<"
707 row: 5
708 col: 2.3
709 Key:
710 id: Key_119
711 key_code: 119
712 key_sym: "w"
713 row: 5
714 col: 3.3
715 Key:
716 id: Key_120
717 key_code: 120
718 key_sym: "x"
719 row: 5
720 col: 4.3
721 Key:
722 id: Key_99
723 key_code: 99
724 key_sym: "c"
725 row: 5
726 col: 5.3
727 Key:
728 id: Key_118
729 key_code: 118
730 key_sym: "v"
731 row: 5
732 col: 6.3
733 Key:
734 id: Key_98
735 key_code: 98
736 key_sym: "b"
737 row: 5
738 col: 7.3
739 Key:
740 id: Key_110
741 key_code: 110
742 key_sym: "n"
743 row: 5
744 col: 8.3
745 Key:
746 id: Key_44
747 key_code: 44
748 key_sym: ","
749 row: 5
750 col: 9.3
751 Key:
752 id: Key_59
753 key_code: 59
754 key_sym: ";"
755 row: 5
756 col: 10.3
757 Key:
758 id: Key_58
759 key_code: 58
760 key_sym: ":"
761 row: 5
762 col: 11.3
763 Key:
764 id: Key_33
765 key_code: 33
766 key_sym: "!"
767 row: 5
768 col: 12.3
769 Key:
770 id: Key_303
771 key_code: 303
772 key_sym: "RShift"
773 row: 5
774 col: 13.3
775 key_width: 2.7
776 line_width: 1
777 enabled: False
778 Key:
779 id: Key_306
780 key_code: 306
781 key_sym: "LCtrl"
782 row: 6
783 col: 1
784 key_width: 1.3
785 line_width: 1
786 enabled: False
787 Key:
788 id: Key_311
789 key_code: 311
790 key_sym: "LSuper"
791 row: 6
792 col: 3.3
793 line_width: 1
794 enabled: False
795 Key:
796 id: Key_308
797 key_code: 308
798 key_sym: "LAlt"
799 row: 6
800 col: 4.3
801 line_width: 1
802 enabled: False
803 Key:
804 id: Key_32
805 key_code: 32
806 key_sym: "Espace"
807 row: 6
808 col: 5.3
809 key_width: 5
810 Key:
811 id: Key_313
812 key_code: 313
813 key_sym: "AltGr"
814 row: 6
815 col: 10.3
816 line_width: 1
817 enabled: False
818 Key:
819 id: Key_314
820 key_code: 314
821 key_sym: "Compose"
822 row: 6
823 col: 11.3
824 line_width: 1
825 enabled: False
826 Key:
827 id: Key_305
828 key_code: 305
829 key_sym: "RCtrl"
830 row: 6
831 col: 12.3
832 key_width: 1.3
833 line_width: 1
834 enabled: False
835
836
837 Key:
838 id: Key_277
839 key_code: 277
840 key_sym: "ins"
841 row: 2
842 col: 1
843 pad_cols: True
844 Key:
845 id: Key_278
846 key_code: 278
847 key_sym: "home"
848 row: 2
849 col: 2
850 pad_cols: True
851 Key:
852 id: Key_280
853 key_code: 280
854 key_sym: "pg_u"
855 row: 2
856 col: 3
857 pad_cols: True
858 Key:
859 id: Key_127
860 key_code: 127
861 key_sym: "del"
862 row: 3
863 col: 1
864 pad_cols: True
865 Key:
866 id: Key_279
867 key_code: 279
868 key_sym: "end"
869 row: 3
870 col: 2
871 pad_cols: True
872 Key:
873 id: Key_281
874 key_code: 281
875 key_sym: "pg_d"
876 row: 3
877 col: 3
878 pad_cols: True
879 Key:
880 id: Key_273
881 key_code: 273
882 key_sym: "up"
883 row: 5
884 col: 2
885 pad_cols: True
886 Key:
887 id: Key_274
888 key_code: 274
889 key_sym: "down"
890 row: 6
891 col: 2
892 pad_cols: True
893 Key:
894 id: Key_276
895 key_code: 276
896 key_sym: "left"
897 row: 6
898 col: 1
899 pad_cols: True
900 Key:
901 id: Key_275
902 key_code: 275
903 key_sym: "right"
904 row: 6
905 col: 3
906 pad_cols: True