X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=music_sampler%2Fkey.py;h=ce2f45bafd8bf9ca9cbdf47c48070eb99615e4cb;hb=7df12958bed6544b36bc946cdbb185ff2011733c;hp=534a3db565671128ac066d191f862c412c79783d;hpb=ba21932596c3b6d1a2ce1e1a22b6417e1c509865;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git diff --git a/music_sampler/key.py b/music_sampler/key.py index 534a3db..ce2f45b 100644 --- a/music_sampler/key.py +++ b/music_sampler/key.py @@ -149,19 +149,19 @@ class KeyMachine(Widget): self.key.parent.parent.ids['KeyList'].append(self.key.key_sym) debug_print("running actions for {}".format(self.key.key_sym)) start_time = time.time() - self.key.parent.start_running(self, start_time) + self.key.parent.start_running(self.key, start_time) for self.key.current_action in self.key.actions: - if self.key.parent.keep_running(self, start_time): + if self.key.parent.keep_running(self.key, start_time): self.key.list_actions() self.key.current_action.run(start_time) self.key.list_actions(last_action_finished=True) - self.key.parent.finished_running(self, start_time) + self.key.parent.finished_running(self.key, start_time) def on_enter_loaded_protecting_repeat(self, modifiers): - if 'repeat_delay' in self.key.config['properties']: + if self.key.repeat_delay > 0: self.key.protecting_repeat_timer = threading.Timer( - self.key.config['properties']['repeat_delay'], + self.key.repeat_delay, self.key.repeat_protection_finished) self.key.protecting_repeat_timer.start() else: @@ -287,6 +287,15 @@ class Key(ButtonBehavior, Widget): def unset_color(self): self.custom_color = [0, 1, 0] + # Helpers + @property + def repeat_delay(self): + if hasattr(self, 'config') and\ + 'repeat_delay' in self.config['properties']: + return self.config['properties']['repeat_delay'] + else: + return 0 + # Actions handling def add_action(self, action_name, **arguments): self.actions.append(Action(action_name, self, **arguments))