]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/commitdiff
Add other_only flag to stop_all_actions
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 27 Jul 2016 00:17:39 +0000 (02:17 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 27 Jul 2016 00:17:39 +0000 (02:17 +0200)
helpers/action.py
helpers/actions/stop_all_actions.py
helpers/key.py
helpers/mapping.py

index 6ac47b199015c61b9015e3e347c26d37a9549300..4b5a71d3806275b5bf16198be985fda052f7b61f 100644 (file)
@@ -80,10 +80,11 @@ class Action:
             error_print("Unknown action {}".format(self.action))
             self.fail()
 
-    def on_enter_loaded_running(self):
+    def on_enter_loaded_running(self, key_start_time):
         debug_print(self.description())
         if hasattr(actions, self.action):
-            getattr(actions, self.action).run(self, **self.arguments)
+            getattr(actions, self.action).run(self,
+                    key_start_time=key_start_time, **self.arguments)
 
     def poll_loaded(self):
         self.key.callback_action_ready(self,
index f3fc5fbe58937f9ca95368e3fdaf241858e65c2a..4ea875a7ca3d6aa9c7d17c43cbdce0a32ee94ffa 100644 (file)
@@ -1,5 +1,14 @@
-def run(action, **kwargs):
-    action.mapping.stop_all_running()
+def run(action, key_start_time=0, other_only=False, **kwargs):
+    if other_only:
+        action.mapping.stop_all_running(
+                except_key=action.key,
+                key_start_time=key_start_time)
+    else:
+        action.mapping.stop_all_running()
 
-def description(action, **kwargs):
-    return "stopping all actions"
+def description(action, other_only=False, **kwargs):
+    message = "stopping all actions"
+    if other_only:
+        message += " except this key"
+
+    return message
index 2f941532256ff89d97b688fe0a70582c6e813e35..b5c1af95a3901a0a1e095506f4538f52399775c9 100644 (file)
@@ -191,7 +191,7 @@ class Key(ButtonBehavior, Widget):
         for self.current_action in self.actions:
             if self.parent.keep_running(self, start_time):
                 self.list_actions()
-                self.current_action.run()
+                self.current_action.run(start_time)
         self.list_actions(last_action_finished=True)
 
         self.parent.finished_running(self, start_time)
index dbc1a811e405de4273f53259c711f09e1d83269d..bb20e679b1e4a9eb8312e0404a913411b178e93c 100644 (file)
@@ -169,11 +169,13 @@ class Mapping(RelativeLayout):
             self.ready_color = [1, 165/255, 0, 1]
 
     ## Some global actions
-    def stop_all_running(self):
+    def stop_all_running(self, except_key=None, key_start_time=0):
         running = self.running
-        self.running = []
+        self.running = [r for r in running\
+                if r[0] == except_key and r[1] == key_start_time]
         for (key, start_time) in running:
-            key.interrupt()
+            if (key, start_time) != (except_key, key_start_time):
+                key.interrupt()
 
     # Master volume methods
     @property