]>
Commit | Line | Data |
---|---|---|
d8046b94 IB |
1 | import kivy |
2 | kivy.require("1.9.1") | |
4b2d79ca IB |
3 | from kivy.app import App |
4 | from kivy.uix.floatlayout import FloatLayout | |
5 | from kivy.uix.relativelayout import RelativeLayout | |
6 | from kivy.properties import ListProperty, StringProperty | |
7 | from kivy.clock import Clock | |
8 | from kivy.core.window import Window | |
bb69f62e | 9 | from kivy.lang import Builder |
4b2d79ca IB |
10 | from helpers.key import Key |
11 | from helpers.mapping import Mapping | |
e4846541 | 12 | import helpers |
bb69f62e | 13 | |
65ec4d2a IB |
14 | class KeyList(RelativeLayout): |
15 | keylist = ListProperty([]) | |
16 | first_key = StringProperty("") | |
17 | second_key = StringProperty("") | |
18 | third_key = StringProperty("") | |
19 | ||
20 | def append(self, value): | |
21 | self.keylist = [value] + self.keylist | |
22 | ||
23 | def on_keylist(self, instance, new_key_list): | |
24 | if len(self.keylist) > 0: | |
25 | self.first_key = self.keylist[0] | |
26 | if len(self.keylist) > 1: | |
27 | self.second_key = self.keylist[1] | |
28 | if len(self.keylist) > 2: | |
29 | self.third_key = self.keylist[2] | |
30 | ||
4b2d79ca IB |
31 | class PlayList(RelativeLayout): |
32 | playlist = ListProperty([]) | |
33 | ||
34 | def __init__(self, **kwargs): | |
35 | super(PlayList, self).__init__(**kwargs) | |
36 | Clock.schedule_interval(self.update_playlist, 0.5) | |
37 | ||
38 | def update_playlist(self, dt): | |
39 | if self.parent is None or 'Mapping' not in self.parent.ids: | |
40 | return True | |
41 | ||
42 | open_files = self.parent.ids['Mapping'].open_files | |
43 | self.playlist = [] | |
44 | for music_file in open_files.values(): | |
45 | if not music_file.is_playing(): | |
46 | continue | |
47 | if music_file.is_paused(): | |
48 | self.playlist.append(["⏸", music_file.name, False]) | |
49 | else: | |
50 | self.playlist.append(["⏵", music_file.name, True]) | |
189bf90c | 51 | |
189bf90c | 52 | |
4b2d79ca IB |
53 | class ActionList(RelativeLayout): |
54 | action_title = StringProperty("") | |
55 | action_list = ListProperty([]) | |
189bf90c | 56 | |
4b2d79ca IB |
57 | def update_list(self, key, action_number = 0): |
58 | self.action_title = "actions linked to key {}:".format(key.key_sym) | |
59 | self.action_list = [] | |
189bf90c | 60 | |
4b2d79ca | 61 | action_descriptions = [action.description() for action in key.actions] |
e7f8dab4 | 62 | |
4b2d79ca IB |
63 | for index, description in enumerate(action_descriptions): |
64 | if index < int(action_number): | |
65 | icon = "✓" | |
66 | elif index + 0.5 == action_number: | |
67 | icon = "✅" | |
68 | else: | |
69 | icon = " " | |
be27763f | 70 | |
4b2d79ca | 71 | self.action_list.append([icon, description]) |
189bf90c | 72 | |
4b2d79ca IB |
73 | class Screen(FloatLayout): |
74 | pass | |
189bf90c | 75 | |
4b2d79ca IB |
76 | class MusicSamplerApp(App): |
77 | def build(self): | |
78 | Window.size = (913, 563) | |
9de92b6d | 79 | |
4b2d79ca | 80 | return Screen() |
9de92b6d | 81 | |
4b2d79ca | 82 | if __name__ == '__main__': |
e4846541 | 83 | Builder.load_file(helpers.path() + "/music_sampler.kv") |
4b2d79ca | 84 | MusicSamplerApp().run() |