]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blame_incremental - music_sampler/app.py
Add Unfocused overlay when focus is lost
[perso/Immae/Projets/Python/MusicSampler.git] / music_sampler / app.py
... / ...
CommitLineData
1from .helpers import parse_args, register_fonts, path
2
3parse_args()
4
5import kivy
6kivy.require("1.9.1")
7from kivy.app import App
8from kivy.uix.floatlayout import FloatLayout
9from kivy.uix.relativelayout import RelativeLayout
10from kivy.uix.label import Label
11from kivy.properties import ListProperty, StringProperty
12from kivy.core.window import Window
13from kivy.lang import Builder
14
15register_fonts()
16
17
18from .helpers import Config
19from .key import Key
20from .mapping import Mapping
21
22from .app_blocks.actionlist import *
23from .app_blocks.playlist import *
24
25class 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
42class UnfocusedOverlay(Label):
43 pass
44
45class 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
59class MusicSamplerApp(App):
60 def build(self):
61 Window.size = (913, 563)
62
63 return Screen()
64
65def main():
66 Builder.load_file(path() + "/music_sampler.kv")
67 MusicSamplerApp().run()