]>
Commit | Line | Data |
---|---|---|
1 | from .helpers import parse_args, register_fonts, path | |
2 | ||
3 | parse_args() | |
4 | ||
5 | import kivy | |
6 | kivy.require("1.9.1") | |
7 | from kivy.app import App | |
8 | from kivy.uix.floatlayout import FloatLayout | |
9 | from kivy.uix.relativelayout import RelativeLayout | |
10 | from kivy.uix.label import Label | |
11 | from kivy.properties import ListProperty, StringProperty | |
12 | from kivy.core.window import Window | |
13 | from kivy.lang import Builder | |
14 | ||
15 | register_fonts() | |
16 | ||
17 | ||
18 | from .helpers import Config | |
19 | from .key import Key | |
20 | from .mapping import Mapping | |
21 | ||
22 | from .app_blocks.actionlist import * | |
23 | from .app_blocks.playlist import * | |
24 | ||
25 | class KeyList(RelativeLayout): | |
26 | keylist = ListProperty([]) | |
27 | first_key = StringProperty("") | |
28 | second_key = StringProperty("") | |
29 | third_key = StringProperty("") | |
30 | ||
31 | def append(self, value): | |
32 | self.keylist.insert(0, value) | |
33 | ||
34 | def on_keylist(self, instance, new_key_list): | |
35 | if len(self.keylist) > 0: | |
36 | self.first_key = self.keylist[0] | |
37 | if len(self.keylist) > 1: | |
38 | self.second_key = self.keylist[1] | |
39 | if len(self.keylist) > 2: | |
40 | self.third_key = self.keylist[2] | |
41 | ||
42 | class UnfocusedOverlay(Label): | |
43 | pass | |
44 | ||
45 | class Screen(FloatLayout): | |
46 | def __init__(self, **kwargs): | |
47 | super(Screen, self).__init__(**kwargs) | |
48 | self.unfocused_widget = UnfocusedOverlay() | |
49 | Window.bind(focus=self.focus_changed) | |
50 | ||
51 | def focus_changed(self, instance, focus): | |
52 | if Config.no_focus_warning: | |
53 | return | |
54 | if not focus: | |
55 | self.add_widget(self.unfocused_widget) | |
56 | else: | |
57 | self.remove_widget(self.unfocused_widget) | |
58 | ||
59 | class MusicSamplerApp(App): | |
60 | def build(self): | |
61 | Window.size = (913, 563) | |
62 | ||
63 | return Screen() | |
64 | ||
65 | def main(): | |
66 | Builder.load_file(path() + "/music_sampler.kv") | |
67 | MusicSamplerApp().run() |