aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-29 01:20:19 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-29 01:20:19 +0200
commit3c0cb1f738f39c1e5800bd42d16189e72e365ec2 (patch)
tree86b7b5531bcca5607b35715d8c02b76d016296ae
parent4d1dfc89066e8dbccf7e5049686895de6fcb32d2 (diff)
downloadMusicSampler-3c0cb1f738f39c1e5800bd42d16189e72e365ec2.tar.gz
MusicSampler-3c0cb1f738f39c1e5800bd42d16189e72e365ec2.tar.zst
MusicSampler-3c0cb1f738f39c1e5800bd42d16189e72e365ec2.zip
Precompute font size in kv file
-rw-r--r--music_sampler/music_sampler.kv30
1 files changed, 17 insertions, 13 deletions
diff --git a/music_sampler/music_sampler.kv b/music_sampler/music_sampler.kv
index ffc2797..7abab0d 100644
--- a/music_sampler/music_sampler.kv
+++ b/music_sampler/music_sampler.kv
@@ -1,5 +1,4 @@
1#:import math math 1#:import math math
2#:import h music_sampler
3 2
4<Key>: 3<Key>:
5 pad_col_sep: 0 if not self.pad_cols else self.parent.pad_x 4 pad_col_sep: 0 if not self.pad_cols else self.parent.pad_x
@@ -18,6 +17,8 @@
18 key_height: 1 17 key_height: 1
19 width: self.key_width * (self.parent.key_size + self.parent.key_sep) - self.parent.key_sep 18 width: self.key_width * (self.parent.key_size + self.parent.key_sep) - self.parent.key_sep
20 height: self.key_height * (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))
21 canvas.before: 22 canvas.before:
22 Color: 23 Color:
23 rgba: self.color 24 rgba: self.color
@@ -42,7 +43,7 @@
42 id: key_label 43 id: key_label
43 font_name: "Ubuntu" 44 font_name: "Ubuntu"
44 bold: True 45 bold: True
45 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size)) 46 font_size: self.parent.normal_font_size or 10
46 color: 0, 0, 0, 1 47 color: 0, 0, 0, 1
47 text: self.parent.key_sym 48 text: self.parent.key_sym
48 text_size: self.parent.width,self.font_size 49 text_size: self.parent.width,self.font_size
@@ -54,7 +55,7 @@
54 Label: 55 Label:
55 id: key_description_title 56 id: key_description_title
56 font_name: "Ubuntu" 57 font_name: "Ubuntu"
57 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size / 2)) 58 font_size: self.parent.smaller_font_size or 8
58 color: 0, 0, 0, 1 59 color: 0, 0, 0, 1
59 text: self.parent.description_title 60 text: self.parent.description_title
60 text_size: self.parent.width - 2*self.parent.line_width, self.font_size 61 text_size: self.parent.width - 2*self.parent.line_width, self.font_size
@@ -65,7 +66,7 @@
65 Label: 66 Label:
66 id: key_description 67 id: key_description
67 font_name: "Ubuntu" 68 font_name: "Ubuntu"
68 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size / 2)) 69 font_size: self.parent.smaller_font_size or 8
69 color: 0, 0, 0, 1 70 color: 0, 0, 0, 1
70 text: "\n".join(self.parent.description) 71 text: "\n".join(self.parent.description)
71 text_size: 2 * self.parent.width,self.parent.height - key_label.font_size 72 text_size: 2 * self.parent.width,self.parent.height - key_label.font_size
@@ -109,12 +110,13 @@
109 play_list_y: self.border 110 play_list_y: self.border
110 play_list_x: self.action_list_width + self.key_list_width + 3 * self.border 111 play_list_x: self.action_list_width + self.key_list_width + 3 * self.border
111 112
112 max_height: 1.3 * math.ceil(2 * math.sqrt(self.key_size or 10)) 113 font_size: math.ceil(2 * math.sqrt(self.key_size or 10))
114 max_height: 1.3 * self.font_size
113 115
114 Label: 116 Label:
115 id: mock_ubuntu_regular 117 id: mock_ubuntu_regular
116 font_name: "Ubuntu" 118 font_name: "Ubuntu"
117 font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10)) 119 font_size: self.parent.font_size
118 color: 0, 0, 0, 0 120 color: 0, 0, 0, 0
119 text: "A" 121 text: "A"
120 text_size: None, None 122 text_size: None, None
@@ -144,6 +146,7 @@
144 size: self.parent.play_list_width, self.parent.play_list_height 146 size: self.parent.play_list_width, self.parent.play_list_height
145 147
146<KeyList>: 148<KeyList>:
149 font_size: self.parent.font_size or 10
147 size_hint: None, None 150 size_hint: None, None
148 canvas: 151 canvas:
149 Color: 152 Color:
@@ -155,7 +158,7 @@
155 id: key_list_first 158 id: key_list_first
156 font_name: "Ubuntu" 159 font_name: "Ubuntu"
157 bold: True 160 bold: True
158 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) 161 font_size: self.parent.font_size
159 color: 0, 0, 0, 1 162 color: 0, 0, 0, 1
160 text: self.parent.first_key 163 text: self.parent.first_key
161 text_size: None, None 164 text_size: None, None
@@ -167,7 +170,7 @@
167 Label: 170 Label:
168 id: key_list_second 171 id: key_list_second
169 font_name: "Ubuntu" 172 font_name: "Ubuntu"
170 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) 173 font_size: self.parent.font_size
171 color: 0, 0, 0, 1 174 color: 0, 0, 0, 1
172 text: self.parent.second_key 175 text: self.parent.second_key
173 text_size: None, None 176 text_size: None, None
@@ -179,7 +182,7 @@
179 Label: 182 Label:
180 id: key_list_third 183 id: key_list_third
181 font_name: "Ubuntu" 184 font_name: "Ubuntu"
182 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) 185 font_size: self.parent.font_size
183 color: 0, 0, 0, 0.75 186 color: 0, 0, 0, 0.75
184 text: self.parent.third_key 187 text: self.parent.third_key
185 text_size: None, None 188 text_size: None, None
@@ -191,7 +194,7 @@
191 Label: 194 Label:
192 id: key_list_rest 195 id: key_list_rest
193 font_name: "Ubuntu" 196 font_name: "Ubuntu"
194 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) 197 font_size: self.parent.font_size
195 color: 0, 0, 0, 0.5 198 color: 0, 0, 0, 0.5
196 text: "\n".join(self.parent.keylist[3:]) 199 text: "\n".join(self.parent.keylist[3:])
197 text_size: None, None 200 text_size: None, None
@@ -204,7 +207,7 @@
204<ActionList>: 207<ActionList>:
205 size_hint: None, None 208 size_hint: None, None
206 labels_height: self.parent.max_height or 1 209 labels_height: self.parent.max_height or 1
207 font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10)) 210 font_size: self.parent.font_size or 10
208 canvas: 211 canvas:
209 Color: 212 Color:
210 rgba: 250./255, 250./255, 250./255, 1 213 rgba: 250./255, 250./255, 250./255, 1
@@ -261,7 +264,7 @@
261<PlayList>: 264<PlayList>:
262 size_hint: None, None 265 size_hint: None, None
263 labels_height: self.parent.max_height or 1 266 labels_height: self.parent.max_height or 1
264 font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10)) 267 font_size: self.parent.font_size or 10
265 canvas: 268 canvas:
266 Color: 269 Color:
267 rgba: 250./255, 250./255, 250./255, 1 270 rgba: 250./255, 250./255, 250./255, 1
@@ -328,6 +331,7 @@
328<Mapping>: 331<Mapping>:
329 size_hint: None, None 332 size_hint: None, None
330 key_size: 48 333 key_size: 48
334 font_size: self.parent.font_size
331 key_sep: 2 335 key_sep: 2
332 key_pad_sep: 7 336 key_pad_sep: 7
333 pad_x: 755 337 pad_x: 755
@@ -344,7 +348,7 @@
344 size: self.key_size / 3, self.key_size / 3 348 size: self.key_size / 3, self.key_size / 3
345 Label: 349 Label:
346 font_name: "Ubuntu" 350 font_name: "Ubuntu"
347 font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10)) 351 font_size: self.parent.font_size or 10
348 color: 0, 0, 0, 1 352 color: 0, 0, 0, 1
349 text: "volume: {}%".format(self.parent.master_volume) 353 text: "volume: {}%".format(self.parent.master_volume)
350 valign: "top" 354 valign: "top"