X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=helpers%2Fkey.py;h=9099f00925b28e0764aa4eb6f6afa1743a595993;hb=1094ab1ac48313b0c1caec15bc4fb6c584efa047;hp=bf46eebc73237520770daeb01dc225448a4685e4;hpb=e4917bcc6c5355a82f05880a389d0a1fd868561d;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git diff --git a/helpers/key.py b/helpers/key.py index bf46eeb..9099f00 100644 --- a/helpers/key.py +++ b/helpers/key.py @@ -30,7 +30,8 @@ class Key(ButtonBehavior, Widget): { 'trigger': 'fail', 'source': 'configuring', - 'dest': 'failed' + 'dest': 'failed', + 'after': 'key_loaded_callback' }, { 'trigger': 'success', @@ -42,6 +43,7 @@ class Key(ButtonBehavior, Widget): 'trigger': 'no_config', 'source': 'configuring', 'dest': 'loaded_no_config', + 'after': 'key_loaded_callback' }, { 'trigger': 'load', @@ -51,22 +53,26 @@ class Key(ButtonBehavior, Widget): { 'trigger': 'fail', 'source': 'loading', - 'dest': 'failed' + 'dest': 'failed', + 'after': 'key_loaded_callback' }, { 'trigger': 'success', 'source': 'loading', - 'dest': 'loaded' + 'dest': 'loaded', + 'after': 'key_loaded_callback' }, { 'trigger': 'no_actions', 'source': 'loading', 'dest': 'loaded_no_actions', + 'after': 'key_loaded_callback' }, { 'trigger': 'reload', - 'source': 'loaded', - 'dest': 'configuring' + 'source': ['loaded','failed'], + 'dest': 'configuring', + 'after': 'key_loaded_callback' }, { 'trigger': 'run', @@ -90,6 +96,18 @@ class Key(ButtonBehavior, Widget): description = ListProperty([]) state = StringProperty("") + def get_alias_line_color(self): + if self.is_loaded_running(): + return [0, 0, 0, 1] + else: + return [120/255, 120/255, 120/255, 1] + + def set_alias_line_color(self): + pass + + line_color = AliasProperty(get_alias_line_color, set_alias_line_color, + bind=['state']) + def get_alias_color(self): if self.is_loaded_inactive(): return [1, 1, 1, 1] @@ -150,7 +168,7 @@ class Key(ButtonBehavior, Widget): else: self.no_actions() - def on_enter_loaded_running(self): + def on_enter_loaded_running(self, modifiers): self.parent.parent.ids['KeyList'].append(self.key_sym) debug_print("running actions for {}".format(self.key_sym)) start_time = time.time() @@ -171,6 +189,9 @@ class Key(ButtonBehavior, Widget): self.current_action.interrupt() # Callbacks + def key_loaded_callback(self): + self.parent.key_loaded_callback() + def callback_action_ready(self, action, success): if not success: self.fail() @@ -181,6 +202,7 @@ class Key(ButtonBehavior, Widget): def set_description(self, description): if description[0] is not None: self.description_title = str(description[0]) + self.description = [] for desc in description[1 :]: if desc is None: self.description.append("")