diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-07-27 02:17:39 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-07-27 02:17:39 +0200 |
commit | 62a8b07a2264101fd6d9c201267966e3c5de0cd4 (patch) | |
tree | b11e6bc4e48e4051ee80427c391f9e4522382726 | |
parent | 6c42e32d98aa2e04d446f31b8e667a280acf4b54 (diff) | |
download | MusicSampler-62a8b07a2264101fd6d9c201267966e3c5de0cd4.tar.gz MusicSampler-62a8b07a2264101fd6d9c201267966e3c5de0cd4.tar.zst MusicSampler-62a8b07a2264101fd6d9c201267966e3c5de0cd4.zip |
Add other_only flag to stop_all_actions
-rw-r--r-- | helpers/action.py | 5 | ||||
-rw-r--r-- | helpers/actions/stop_all_actions.py | 17 | ||||
-rw-r--r-- | helpers/key.py | 2 | ||||
-rw-r--r-- | helpers/mapping.py | 8 |
4 files changed, 22 insertions, 10 deletions
diff --git a/helpers/action.py b/helpers/action.py index 6ac47b1..4b5a71d 100644 --- a/helpers/action.py +++ b/helpers/action.py | |||
@@ -80,10 +80,11 @@ class Action: | |||
80 | error_print("Unknown action {}".format(self.action)) | 80 | error_print("Unknown action {}".format(self.action)) |
81 | self.fail() | 81 | self.fail() |
82 | 82 | ||
83 | def on_enter_loaded_running(self): | 83 | def on_enter_loaded_running(self, key_start_time): |
84 | debug_print(self.description()) | 84 | debug_print(self.description()) |
85 | if hasattr(actions, self.action): | 85 | if hasattr(actions, self.action): |
86 | getattr(actions, self.action).run(self, **self.arguments) | 86 | getattr(actions, self.action).run(self, |
87 | key_start_time=key_start_time, **self.arguments) | ||
87 | 88 | ||
88 | def poll_loaded(self): | 89 | def poll_loaded(self): |
89 | self.key.callback_action_ready(self, | 90 | self.key.callback_action_ready(self, |
diff --git a/helpers/actions/stop_all_actions.py b/helpers/actions/stop_all_actions.py index f3fc5fb..4ea875a 100644 --- a/helpers/actions/stop_all_actions.py +++ b/helpers/actions/stop_all_actions.py | |||
@@ -1,5 +1,14 @@ | |||
1 | def run(action, **kwargs): | 1 | def run(action, key_start_time=0, other_only=False, **kwargs): |
2 | action.mapping.stop_all_running() | 2 | if other_only: |
3 | action.mapping.stop_all_running( | ||
4 | except_key=action.key, | ||
5 | key_start_time=key_start_time) | ||
6 | else: | ||
7 | action.mapping.stop_all_running() | ||
3 | 8 | ||
4 | def description(action, **kwargs): | 9 | def description(action, other_only=False, **kwargs): |
5 | return "stopping all actions" | 10 | message = "stopping all actions" |
11 | if other_only: | ||
12 | message += " except this key" | ||
13 | |||
14 | return message | ||
diff --git a/helpers/key.py b/helpers/key.py index 2f94153..b5c1af9 100644 --- a/helpers/key.py +++ b/helpers/key.py | |||
@@ -191,7 +191,7 @@ class Key(ButtonBehavior, Widget): | |||
191 | for self.current_action in self.actions: | 191 | for self.current_action in self.actions: |
192 | if self.parent.keep_running(self, start_time): | 192 | if self.parent.keep_running(self, start_time): |
193 | self.list_actions() | 193 | self.list_actions() |
194 | self.current_action.run() | 194 | self.current_action.run(start_time) |
195 | self.list_actions(last_action_finished=True) | 195 | self.list_actions(last_action_finished=True) |
196 | 196 | ||
197 | self.parent.finished_running(self, start_time) | 197 | self.parent.finished_running(self, start_time) |
diff --git a/helpers/mapping.py b/helpers/mapping.py index dbc1a81..bb20e67 100644 --- a/helpers/mapping.py +++ b/helpers/mapping.py | |||
@@ -169,11 +169,13 @@ class Mapping(RelativeLayout): | |||
169 | self.ready_color = [1, 165/255, 0, 1] | 169 | self.ready_color = [1, 165/255, 0, 1] |
170 | 170 | ||
171 | ## Some global actions | 171 | ## Some global actions |
172 | def stop_all_running(self): | 172 | def stop_all_running(self, except_key=None, key_start_time=0): |
173 | running = self.running | 173 | running = self.running |
174 | self.running = [] | 174 | self.running = [r for r in running\ |
175 | if r[0] == except_key and r[1] == key_start_time] | ||
175 | for (key, start_time) in running: | 176 | for (key, start_time) in running: |
176 | key.interrupt() | 177 | if (key, start_time) != (except_key, key_start_time): |
178 | key.interrupt() | ||
177 | 179 | ||
178 | # Master volume methods | 180 | # Master volume methods |
179 | @property | 181 | @property |