aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--music_sampler/app.py18
-rw-r--r--music_sampler/app_blocks/__init__.py1
-rw-r--r--music_sampler/app_blocks/actionlist.py84
-rw-r--r--music_sampler/music_sampler.kv65
4 files changed, 120 insertions, 48 deletions
diff --git a/music_sampler/app.py b/music_sampler/app.py
index 510cb44..cce3969 100644
--- a/music_sampler/app.py
+++ b/music_sampler/app.py
@@ -16,6 +16,7 @@ from .mapping import Mapping
16 16
17register_fonts() 17register_fonts()
18 18
19from .app_blocks.actionlist import *
19from .app_blocks.playlist import * 20from .app_blocks.playlist import *
20 21
21class KeyList(RelativeLayout): 22class KeyList(RelativeLayout):
@@ -35,23 +36,6 @@ class KeyList(RelativeLayout):
35 if len(self.keylist) > 2: 36 if len(self.keylist) > 2:
36 self.third_key = self.keylist[2] 37 self.third_key = self.keylist[2]
37 38
38class ActionList(RelativeLayout):
39 action_title = StringProperty("")
40 action_list = ListProperty([])
41
42 def update_list(self, key, action_descriptions):
43 self.action_title = "actions linked to key {}:".format(key.key_sym)
44 self.action_list = []
45
46 for [action, status] in action_descriptions:
47 if status == "done":
48 icon = "✓"
49 elif status == "current":
50 icon = "✅"
51 else:
52 icon = " "
53 self.action_list.append([icon, action])
54
55class Screen(FloatLayout): 39class Screen(FloatLayout):
56 pass 40 pass
57 41
diff --git a/music_sampler/app_blocks/__init__.py b/music_sampler/app_blocks/__init__.py
index c412eb1..82c3ec7 100644
--- a/music_sampler/app_blocks/__init__.py
+++ b/music_sampler/app_blocks/__init__.py
@@ -1 +1,2 @@
1from . import actionlist
1from . import playlist 2from . import playlist
diff --git a/music_sampler/app_blocks/actionlist.py b/music_sampler/app_blocks/actionlist.py
new file mode 100644
index 0000000..70fe3f4
--- /dev/null
+++ b/music_sampler/app_blocks/actionlist.py
@@ -0,0 +1,84 @@
1from kivy.uix.label import Label
2from kivy.uix.stacklayout import StackLayout
3from kivy.uix.relativelayout import RelativeLayout
4from kivy.properties import ListProperty, StringProperty
5
6import math
7
8__all__ = ["ActionList",
9 "ActionListIcons", "ActionListIcon",
10 "ActionListDescriptions", "ActionListDescription"]
11
12class ActionList(RelativeLayout):
13 action_title = StringProperty("")
14 action_list = ListProperty([])
15
16 def update_list(self, key, action_descriptions):
17 self.action_title = "actions linked to key {}:".format(key.key_sym)
18 action_list = []
19
20 for [action, status] in action_descriptions:
21 if status == "done":
22 icon = "✓"
23 elif status == "current":
24 icon = "✅"
25 else:
26 icon = " "
27 action_list.append([icon, action])
28 self.action_list = action_list
29
30class ActionListIcons(StackLayout):
31 def __init__(self, **kwargs):
32 super(ActionListIcons, self).__init__(**kwargs)
33 self.icons = []
34
35 def on_parent(self, instance, parent):
36 parent.bind(action_list=self.update_actionlist_icons)
37
38 def update_actionlist_icons(self, instance, actionlist):
39 for icon in self.icons:
40 self.remove_widget(icon)
41 self.icons = []
42 for icon, description in actionlist:
43 icon_label = ActionListIcon(text=icon)
44 self.add_widget(icon_label)
45 self.icons.append(icon_label)
46
47class ActionListIcon(Label):
48 def __init__(self, text='', **kwargs):
49 super(ActionListIcon, self).__init__(**kwargs)
50 self.text = text
51
52 def on_parent(self, instance, parent):
53 if parent is not None:
54 self.font_size = math.ceil(2 * math.sqrt(parent.parent.parent.key_size))
55 self.height = parent.parent.labels_height
56
57class ActionListDescriptions(StackLayout):
58 def __init__(self, **kwargs):
59 super(ActionListDescriptions, self).__init__(**kwargs)
60 self.descriptions = []
61
62 def on_parent(self, instance, parent):
63 parent.bind(action_list=self.update_actionlist_descriptions)
64
65 def update_actionlist_descriptions(self, instance, actionlist):
66 for description in self.descriptions:
67 self.remove_widget(description)
68 self.descriptions = []
69 for icon, description in actionlist:
70 description_label = ActionListDescription(text=description)
71 self.add_widget(description_label)
72 self.descriptions.append(description_label)
73
74class ActionListDescription(Label):
75 def __init__(self, text='', **kwargs):
76 super(ActionListDescription, self).__init__(**kwargs)
77 self.text = text
78
79 def on_parent(self, instance, parent):
80 if parent is not None:
81 self.font_size = math.ceil(2 * math.sqrt(parent.parent.parent.key_size))
82 self.height = parent.parent.labels_height
83
84
diff --git a/music_sampler/music_sampler.kv b/music_sampler/music_sampler.kv
index 8e94da8..afb99e4 100644
--- a/music_sampler/music_sampler.kv
+++ b/music_sampler/music_sampler.kv
@@ -226,13 +226,13 @@
226 226
227<ActionList>: 227<ActionList>:
228 size_hint: None, None 228 size_hint: None, None
229 labels_height: self.parent.max_height or 1
229 canvas: 230 canvas:
230 Color: 231 Color:
231 rgba: 250./255, 250./255, 250./255, 1 232 rgba: 250./255, 250./255, 250./255, 1
232 Rectangle: 233 Rectangle:
233 pos: 0, 0 234 pos: 0, 0
234 size: self.width, self.height 235 size: self.width, self.height
235
236 Label: 236 Label:
237 id: action_list_title 237 id: action_list_title
238 font_name: "Ubuntu" 238 font_name: "Ubuntu"
@@ -245,32 +245,33 @@
245 valign: "top" 245 valign: "top"
246 size_hint: None, None 246 size_hint: None, None
247 size: self.texture_size[0], self.parent.height 247 size: self.texture_size[0], self.parent.height
248 Label: 248 ActionListIcons:
249 id: action_list_icons 249 orientation: 'lr-tb'
250 font_name: "Symbola" 250 size_hint: 0.02, 0.9
251 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) 251 pos_hint: { 'x': 0, 'top': 0.9 }
252 line_height: self.parent.parent.symbola_line_height or 1 252 ActionListDescriptions:
253 color: 0, 0, 0, 1 253 orientation: 'lr-tb'
254 text: "\n".join(map(lambda x: x[0], self.parent.action_list)) 254 size_hint: 0.98, 0.9
255 text_size: None, self.parent.height 255 pos_hint: { 'x': 0.02, 'top': 0.9 }
256 halign: "left" 256
257 valign: "top" 257<ActionListIcon>:
258 size_hint: None, None 258 font_name: "Symbola"
259 size: self.texture_size[0], self.parent.height - 3 * self.line_height * self.font_size 259 color: 0, 0, 0, 1
260 Label: 260 text_size: None, None
261 id: action_list_names 261 halign: "left"
262 font_name: "Ubuntu" 262 size_hint: None, None
263 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) 263 width: self.texture_size[0]
264 line_height: self.parent.parent.ubuntu_regular_line_height or 1 264
265 color: 0, 0, 0, 1 265<ActionListDescription>:
266 text: "\n".join(map(lambda x: x[1], self.parent.action_list)) 266 font_name: "Ubuntu"
267 text_size: None, self.parent.height 267 color: 0, 0, 0, 1
268 halign: "left" 268 text_size: self.width, None
269 valign: "top" 269 shorten: True
270 size_hint: None, None 270 shorten_from: "right"
271 pos: 15, self.y 271 split_str: ""
272 size: self.texture_size[0], self.parent.height - 3 * self.line_height * self.font_size 272 halign: "left"
273 273 size_hint: 1, None
274
274<PlayList>: 275<PlayList>:
275 size_hint: None, None 276 size_hint: None, None
276 labels_height: self.parent.max_height or 1 277 labels_height: self.parent.max_height or 1
@@ -298,16 +299,18 @@
298 color: 0, 0, 0, 1 299 color: 0, 0, 0, 1
299 text_size: None, None 300 text_size: None, None
300 halign: "left" 301 halign: "left"
301 size_hint: 1, None 302 size_hint: None, None
302 width: self.texture_size[0] 303 width: self.texture_size[0]
303 304
304<PlayListName>: 305<PlayListName>:
305 font_name: "Ubuntu" 306 font_name: "Ubuntu"
306 color: 0, 0, 0, 1 307 color: 0, 0, 0, 1
307 text_size: None, None 308 text_size: self.width, None
309 shorten: True
310 shorten_from: "right"
311 split_str: ""
308 halign: "left" 312 halign: "left"
309 size_hint: None, None 313 size_hint: 1, None
310 width: self.texture_size[0]
311 314
312<PlayListTime>: 315<PlayListTime>:
313 canvas.before: 316 canvas.before: