-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#45 - Prepare to remove BanksController, EffectController, Pedalboard…
…Controller, ParamController
- Loading branch information
1 parent
24dfa19
commit 248e612
Showing
16 changed files
with
401 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Copyright 2017 SrMouraSilva | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from pluginsmanager.observer.updates_observer import UpdatesObserver | ||
|
||
|
||
class ComponentsObserver(UpdatesObserver): | ||
|
||
def __init__(self, manager): | ||
super(ComponentsObserver, self).__init__() | ||
self.observers = [] | ||
self._manager = manager | ||
|
||
def register(self, observer): | ||
self.observers.append(observer) | ||
observer.manager = self.manager | ||
|
||
def unregister(self, observer): | ||
observer.manager = None | ||
self.observers.remove(observer) | ||
|
||
@property | ||
def scope(self): | ||
return self._manager.observer_manager.scope | ||
|
||
def on_bank_updated(self, bank, update_type, index, origin, **kwargs): | ||
for observer in self.observers: | ||
if observer != self.scope: | ||
observer.on_bank_updated(bank, update_type, index=index, origin=origin, **kwargs) | ||
|
||
def on_pedalboard_updated(self, pedalboard, update_type, index, origin, **kwargs): | ||
for observer in self.observers: | ||
if observer != self.scope: | ||
observer.on_pedalboard_updated(pedalboard, update_type, index=index, origin=origin, **kwargs) | ||
|
||
def on_effect_updated(self, effect, update_type, index, origin, **kwargs): | ||
for observer in self.observers: | ||
if observer != self.scope: | ||
observer.on_effect_updated(effect, update_type, index=index, origin=origin, **kwargs) | ||
|
||
def on_effect_status_toggled(self, effect, **kwargs): | ||
for observer in self.observers: | ||
if observer != self.scope: | ||
observer.on_effect_status_toggled(effect, **kwargs) | ||
|
||
def on_param_value_changed(self, param, **kwargs): | ||
for observer in self.observers: | ||
if observer != self.scope: | ||
observer.on_param_value_changed(param, **kwargs) | ||
|
||
def on_connection_updated(self, connection, update_type, pedalboard, **kwargs): | ||
for observer in self.observers: | ||
if observer != self.scope: | ||
observer.on_connection_updated(connection, update_type, pedalboard=pedalboard, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright 2017 SrMouraSilva | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from application.component.application_observer import ApplicationObserver | ||
from pluginsmanager.observer.update_type import UpdateType | ||
|
||
|
||
class CurrentPedalboardObserver(ApplicationObserver): | ||
""" | ||
This viewer allows change the current pedalboard | ||
if it is updated or removed or if your bank is updated or removed. | ||
""" | ||
|
||
def __init__(self, current_controller): | ||
""" | ||
:param CurrentController current_controller: | ||
""" | ||
super(CurrentPedalboardObserver, self).__init__() | ||
self._current_controller = current_controller | ||
|
||
def on_bank_updated(self, bank, update_type, index, origin, **kwargs): | ||
if update_type == UpdateType.UPDATED: | ||
old_bank = kwargs['old'] | ||
if old_bank == self._current_controller.bank: | ||
self._current_controller.set_bank(bank, try_preserve_index=True) | ||
|
||
elif update_type == UpdateType.DELETED: | ||
if bank == self._current_controller.bank: | ||
next_bank_index = self._current_controller.next_bank_index(index-1) | ||
new_current_bank = origin.banks[next_bank_index] | ||
|
||
self._current_controller.set_bank(new_current_bank) | ||
|
||
def on_pedalboard_updated(self, pedalboard, update_type, index, origin, **kwargs): | ||
if update_type == UpdateType.UPDATED: | ||
old_pedalboard = kwargs['old'] | ||
|
||
if pedalboard == self._current_controller.pedalboard \ | ||
or old_pedalboard == self._current_controller.pedalboard: | ||
self._current_controller.set_pedalboard(pedalboard, notify=False, force=True) | ||
|
||
def on_effect_status_toggled(self, effect, **kwargs): | ||
pass | ||
|
||
def on_connection_updated(self, connection, update_type, pedalboard, **kwargs): | ||
pass | ||
|
||
def on_param_value_changed(self, param, **kwargs): | ||
pass | ||
|
||
def on_effect_updated(self, effect, update_type, index, origin, **kwargs): | ||
pass | ||
|
||
def on_current_pedalboard_changed(self, pedalboard, token=None): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.