aboutsummaryrefslogtreecommitdiff
path: root/music_sampler
diff options
context:
space:
mode:
Diffstat (limited to 'music_sampler')
-rw-r--r--music_sampler/app.py18
-rw-r--r--music_sampler/helpers.py5
-rw-r--r--music_sampler/music_sampler.kv16
3 files changed, 38 insertions, 1 deletions
diff --git a/music_sampler/app.py b/music_sampler/app.py
index 08a8891..ac1944a 100644
--- a/music_sampler/app.py
+++ b/music_sampler/app.py
@@ -7,6 +7,7 @@ kivy.require("1.9.1")
7from kivy.app import App 7from kivy.app import App
8from kivy.uix.floatlayout import FloatLayout 8from kivy.uix.floatlayout import FloatLayout
9from kivy.uix.relativelayout import RelativeLayout 9from kivy.uix.relativelayout import RelativeLayout
10from kivy.uix.label import Label
10from kivy.properties import ListProperty, StringProperty 11from kivy.properties import ListProperty, StringProperty
11from kivy.core.window import Window 12from kivy.core.window import Window
12from kivy.lang import Builder 13from kivy.lang import Builder
@@ -14,6 +15,7 @@ from kivy.lang import Builder
14register_fonts() 15register_fonts()
15 16
16 17
18from .helpers import Config
17from .key import Key 19from .key import Key
18from .mapping import Mapping 20from .mapping import Mapping
19 21
@@ -37,9 +39,23 @@ class KeyList(RelativeLayout):
37 if len(self.keylist) > 2: 39 if len(self.keylist) > 2:
38 self.third_key = self.keylist[2] 40 self.third_key = self.keylist[2]
39 41
40class Screen(FloatLayout): 42class UnfocusedOverlay(Label):
41 pass 43 pass
42 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
43class MusicSamplerApp(App): 59class MusicSamplerApp(App):
44 def build(self): 60 def build(self):
45 Window.size = (913, 563) 61 Window.size = (913, 563)
diff --git a/music_sampler/helpers.py b/music_sampler/helpers.py
index 6acaba4..2249746 100644
--- a/music_sampler/helpers.py
+++ b/music_sampler/helpers.py
@@ -123,6 +123,10 @@ def parse_args():
123 action=ListDevicesAction, 123 action=ListDevicesAction,
124 help="List available sound devices" 124 help="List available sound devices"
125 ) 125 )
126 parser.add_argument("--no-focus-warning",
127 action='store_true',
128 help="Don't show warning when focus is lost"
129 )
126 parser.add_argument('--', 130 parser.add_argument('--',
127 dest="args", 131 dest="args",
128 help="Kivy arguments. All arguments after this are interpreted\ 132 help="Kivy arguments. All arguments after this are interpreted\
@@ -138,6 +142,7 @@ def parse_args():
138 Config.channels = args.channels 142 Config.channels = args.channels
139 Config.sample_width = args.sample_width 143 Config.sample_width = args.sample_width
140 Config.builtin_mixing = args.builtin_mixing 144 Config.builtin_mixing = args.builtin_mixing
145 Config.no_focus_warning = args.no_focus_warning
141 if args.music_path.endswith("/"): 146 if args.music_path.endswith("/"):
142 Config.music_path = args.music_path 147 Config.music_path = args.music_path
143 else: 148 else:
diff --git a/music_sampler/music_sampler.kv b/music_sampler/music_sampler.kv
index 7abab0d..ae5dbd7 100644
--- a/music_sampler/music_sampler.kv
+++ b/music_sampler/music_sampler.kv
@@ -76,6 +76,22 @@
76 size_hint: None, None 76 size_hint: None, None
77 size: 2 * self.parent.width - 2 * self.parent.line_width, self.parent.height - key_label.font_size 77 size: 2 * self.parent.width - 2 * self.parent.line_width, self.parent.height - key_label.font_size
78 78
79<UnfocusedOverlay>:
80 canvas.before:
81 Color:
82 rgba: 1, 0, 0, 0.9
83 Rectangle:
84 pos: 0, 0
85 size: self.width, self.height
86 size_hint: 1, 1
87 color: 1, 1, 1, 1
88 valign: "middle"
89 halign: "center"
90 font_name: "Ubuntu"
91 font_size: self.parent and 2 * self.parent.key_size or 42
92 text_size: self.size
93 text: "Focus lost!"
94
79<Screen>: 95<Screen>:
80 canvas: 96 canvas:
81 Color: 97 Color: