]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blobdiff - musicsampler.kv
Factorise font mocks
[perso/Immae/Projets/Python/MusicSampler.git] / musicsampler.kv
index 3c1964bfe3eec5911fca08e3735a8ee5a25bffb4..4a44069c03bf1154f023470ad59f2cafbaf3e63d 100644 (file)
@@ -1,4 +1,5 @@
 #:import math math
+#:import h helpers
 
 <Key>:
   pad_col_sep: 0 if not self.pad_cols else self.parent.pad_x
@@ -32,7 +33,7 @@
       width: self.line_width
   Label:
     id: key_label
-    font_name: "fonts/Ubuntu-B.ttf"
+    font_name: h.path() + "fonts/Ubuntu-B.ttf"
     font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size))
     color: 0, 0, 0, 1
     text: self.parent.key_sym
@@ -44,7 +45,7 @@
     center_y: self.parent.y + self.parent.height - self.texture_size[1] /2 - 5
   Label:
     id: key_description_title
-    font_name: "fonts/Ubuntu-Regular.ttf"
+    font_name: h.path() + "fonts/Ubuntu-Regular.ttf"
     font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size / 2))
     color: 0, 0, 0, 1
     text: self.parent.description_title
@@ -55,7 +56,7 @@
     center_y: self.parent.y + self.parent.height - self.texture_size[1] /2 - 5
   Label:
     id: key_description
-    font_name: "fonts/Ubuntu-Regular.ttf"
+    font_name: h.path() + "fonts/Ubuntu-Regular.ttf"
     font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size / 2))
     color: 0, 0, 0, 1
     text: "\n".join(self.parent.description)
     size: 2 * self.parent.width - 2 * self.parent.line_width, self.parent.height - key_label.font_size
 
 <Screen>:
+  canvas:
+    Color:
+      rgba: 229/255, 228/255, 226/255, 1
+    Rectangle:
+      pos: 0, 0
+      size: self.width, self.height
+
   key_size: int( (3 * self.width - 16) / 56)
   key_sep: int( self.key_size / 24)
   key_pad_sep: int( self.key_size / 7) + 1
   play_list_y: self.border
   play_list_x: self.action_list_width + 2 * self.border
 
+  min_height: min(mock_symbola.height, mock_ubuntu_regular.height, mock_ubuntu_bold.height)
+  symbola_line_height: self.min_height / max(mock_symbola.height,1)
+  ubuntu_regular_line_height: self.min_height / max(mock_ubuntu_regular.height,1)
+  ubuntu_bold_line_height: self.min_height / max(mock_ubuntu_bold.height,1)
+  Label:
+    id: mock_symbola
+    font_name: h.path() + "fonts/Symbola.ttf"
+    font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10))
+    color: 0, 0, 0, 0
+    text: "A"
+    text_size: None, None
+    size_hint: None, None
+    size: self.texture_size
+  Label:
+    id: mock_ubuntu_regular
+    font_name: h.path() + "fonts/Ubuntu-Regular.ttf"
+    font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10))
+    color: 0, 0, 0, 0
+    text: "A"
+    text_size: None, None
+    size_hint: None, None
+    size: self.texture_size
+  Label:
+    id: mock_ubuntu_bold
+    font_name: h.path() + "fonts/Ubuntu-B.ttf"
+    font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10))
+    color: 0, 0, 0, 0
+    text: "A"
+    text_size: None, None
+    size_hint: None, None
+    size: self.texture_size
+
   Mapping:
     id: Mapping
     pos: self.parent.mapping_x, self.parent.mapping_y
     Rectangle:
       pos:  0, 0
       size: self.width, self.height
+
   Label:
     id: action_list_title
-    font_name: "fonts/Ubuntu-B.ttf"
+    font_name: h.path() + "fonts/Ubuntu-B.ttf"
     font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10))
     color: 0, 0, 0, 1
     text: self.parent.action_title
     size: self.texture_size[0], self.parent.height
   Label:
     id: action_list_icons
-    font_name: "fonts/Symbola.ttf"
+    font_name: h.path() + "fonts/Symbola.ttf"
     font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10))
-    line_height: 1.2 # FIXME: Donner la bonne taille de label
+    line_height: self.parent.parent.symbola_line_height or 1
     color: 0, 0, 0, 1
     text: "\n".join(map(lambda x: x[0], self.parent.action_list))
     text_size: None, self.parent.height
     size: self.texture_size[0], self.parent.height - 3 * self.line_height * self.font_size
   Label:
     id: action_list_names
-    font_name: "fonts/Ubuntu-Regular.ttf"
+    font_name: h.path() + "fonts/Ubuntu-Regular.ttf"
     font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10))
+    line_height: self.parent.parent.ubuntu_regular_line_height or 1
     color: 0, 0, 0, 1
     text: "\n".join(map(lambda x: x[1], self.parent.action_list))
     text_size: None, self.parent.height
     Rectangle:
       pos:  0, 0
       size: self.width, self.height
+
   Label:
     id: playlist_icons
-    font_name: "fonts/Symbola.ttf"
+    font_name: h.path() + "fonts/Symbola.ttf"
     font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10))
-    line_height: 1.2 # FIXME: Donner la bonne taille de label
+    line_height: self.parent.parent.symbola_line_height or 1
     color: 0, 0, 0, 1
     text: "\n".join(map(lambda x: x[0], self.parent.playlist))
     text_size: None, self.parent.height
     size: self.texture_size[0], self.parent.height
   Label:
     id: playlist_names
-    font_name: "fonts/Ubuntu-Regular.ttf" # FIXME: Mettre en gras quand c'est en cours
+    font_name: h.path() + "fonts/Ubuntu-Regular.ttf" # FIXME: Mettre en gras quand c'est en cours
+    line_height: self.parent.parent.ubuntu_regular_line_height or 1
     font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10))
     color: 0, 0, 0, 1
     text: "\n".join(map(lambda x: x[1], self.parent.playlist))