]>
Commit | Line | Data |
---|---|---|
1 | from kivy.app import App | |
2 | from kivy.uix.floatlayout import FloatLayout | |
3 | from kivy.uix.relativelayout import RelativeLayout | |
4 | from kivy.properties import ListProperty, StringProperty | |
5 | from kivy.clock import Clock | |
6 | from kivy.core.window import Window | |
7 | ||
8 | from helpers.key import Key | |
9 | from helpers.mapping import Mapping | |
10 | ||
11 | class PlayList(RelativeLayout): | |
12 | playlist = ListProperty([]) | |
13 | ||
14 | def __init__(self, **kwargs): | |
15 | super(PlayList, self).__init__(**kwargs) | |
16 | Clock.schedule_interval(self.update_playlist, 0.5) | |
17 | ||
18 | def update_playlist(self, dt): | |
19 | if self.parent is None or 'Mapping' not in self.parent.ids: | |
20 | return True | |
21 | ||
22 | open_files = self.parent.ids['Mapping'].open_files | |
23 | self.playlist = [] | |
24 | for music_file in open_files.values(): | |
25 | if not music_file.is_playing(): | |
26 | continue | |
27 | if music_file.is_paused(): | |
28 | self.playlist.append(["⏸", music_file.name, False]) | |
29 | else: | |
30 | self.playlist.append(["⏵", music_file.name, True]) | |
31 | ||
32 | ||
33 | class ActionList(RelativeLayout): | |
34 | action_title = StringProperty("") | |
35 | action_list = ListProperty([]) | |
36 | ||
37 | def update_list(self, key, action_number = 0): | |
38 | self.action_title = "actions linked to key {}:".format(key.key_sym) | |
39 | self.action_list = [] | |
40 | ||
41 | action_descriptions = [action.description() for action in key.actions] | |
42 | ||
43 | for index, description in enumerate(action_descriptions): | |
44 | if index < int(action_number): | |
45 | icon = "✓" | |
46 | elif index + 0.5 == action_number: | |
47 | icon = "✅" | |
48 | else: | |
49 | icon = " " | |
50 | ||
51 | self.action_list.append([icon, description]) | |
52 | ||
53 | class Screen(FloatLayout): | |
54 | pass | |
55 | ||
56 | class MusicSamplerApp(App): | |
57 | def build(self): | |
58 | Window.size = (913, 563) | |
59 | ||
60 | return Screen() | |
61 | ||
62 | if __name__ == '__main__': | |
63 | MusicSamplerApp().run() |