]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/commitdiff
Factorise font mocks
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 26 Jun 2016 15:42:09 +0000 (17:42 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 26 Jun 2016 15:42:09 +0000 (17:42 +0200)
musicsampler.kv

index 137b7bd811a5461a1714821cfac549f0fef9550a..4a44069c03bf1154f023470ad59f2cafbaf3e63d 100644 (file)
   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
     size: self.parent.play_list_width, self.parent.play_list_height
 
 <ActionList>:
-  min_height: min(action_list_mock_symbola.height, action_list_mock_ubuntu_regular.height, action_list_mock_ubuntu_bold.height)
   size_hint: None, None
   canvas:
     Color:
     Rectangle:
       pos:  0, 0
       size: self.width, self.height
-  # FIXME: déplacer ça dans Screen?
-  Label:
-    id: action_list_mock_symbola
-    font_name: h.path() + "fonts/Symbola.ttf"
-    font_size: math.ceil(2 * math.sqrt(self.parent.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: action_list_mock_ubuntu_regular
-    font_name: h.path() + "fonts/Ubuntu-Regular.ttf"
-    font_size: math.ceil(2 * math.sqrt(self.parent.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: action_list_mock_ubuntu_bold
-    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, 0
-    text: "A"
-    text_size: None, None
-    size_hint: None, None
-    size: self.texture_size
-
 
   Label:
     id: action_list_title
     id: action_list_icons
     font_name: h.path() + "fonts/Symbola.ttf"
     font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10))
-    line_height: self.parent.min_height / max(action_list_mock_symbola.height,1)
+    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
     id: action_list_names
     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.min_height / max(action_list_mock_ubuntu_regular.height,1)
+    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
     size: self.texture_size[0], self.parent.height - 3 * self.line_height * self.font_size
   
 <PlayList>:
-  min_height: min(playlist_mock_symbola.height, playlist_mock_ubuntu_regular.height, playlist_mock_ubuntu_bold.height)
   size_hint: None, None
   canvas:
     Color:
     Rectangle:
       pos:  0, 0
       size: self.width, self.height
-  Label:
-    id: playlist_mock_symbola
-    font_name: h.path() + "fonts/Symbola.ttf"
-    font_size: math.ceil(2 * math.sqrt(self.parent.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: playlist_mock_ubuntu_regular
-    font_name: h.path() + "fonts/Ubuntu-Regular.ttf"
-    font_size: math.ceil(2 * math.sqrt(self.parent.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: playlist_mock_ubuntu_bold
-    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, 0
-    text: "A"
-    text_size: None, None
-    size_hint: None, None
-    size: self.texture_size
-
 
   Label:
     id: playlist_icons
     font_name: h.path() + "fonts/Symbola.ttf"
     font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10))
-    line_height: self.parent.min_height / max(playlist_mock_symbola.height,1)
+    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
   Label:
     id: playlist_names
     font_name: h.path() + "fonts/Ubuntu-Regular.ttf" # FIXME: Mettre en gras quand c'est en cours
-    line_height: self.parent.min_height / max(playlist_mock_ubuntu_regular.height,1)
+    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))