]>
Commit | Line | Data |
---|---|---|
4b2d79ca IB |
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]) | |
189bf90c | 31 | |
189bf90c | 32 | |
4b2d79ca IB |
33 | class ActionList(RelativeLayout): |
34 | action_title = StringProperty("") | |
35 | action_list = ListProperty([]) | |
189bf90c | 36 | |
4b2d79ca IB |
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 = [] | |
189bf90c | 40 | |
4b2d79ca | 41 | action_descriptions = [action.description() for action in key.actions] |
e7f8dab4 | 42 | |
4b2d79ca IB |
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 = " " | |
be27763f | 50 | |
4b2d79ca | 51 | self.action_list.append([icon, description]) |
189bf90c | 52 | |
4b2d79ca IB |
53 | class Screen(FloatLayout): |
54 | pass | |
189bf90c | 55 | |
4b2d79ca IB |
56 | class MusicSamplerApp(App): |
57 | def build(self): | |
58 | Window.size = (913, 563) | |
9de92b6d | 59 | |
4b2d79ca | 60 | return Screen() |
9de92b6d | 61 | |
4b2d79ca IB |
62 | if __name__ == '__main__': |
63 | MusicSamplerApp().run() |