-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackgroundComponent.py
43 lines (35 loc) · 1.7 KB
/
BackgroundComponent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Embedded file name: /Users/versonator/Jenkins/live/output/mac_64_static/Release/python-bundle/MIDI Remote Scripts/Launchpad_Pro/BackgroundComponent.py
# Compiled at: 2018-04-23 20:27:04
from __future__ import absolute_import, print_function, unicode_literals
from _Framework.SubjectSlot import SubjectSlotError
from _Framework.BackgroundComponent import BackgroundComponent as BackgroundComponentBase
class BackgroundComponent(BackgroundComponentBase):
def _clear_control(self, name, control):
if control:
super(BackgroundComponent, self)._clear_control(name, control)
else:
slot = self._control_slots.get(name, None)
if slot:
del self._control_slots[name]
self.disconnect_disconnectable(slot)
if name in self._control_map:
del self._control_map[name]
return
class ModifierBackgroundComponent(BackgroundComponentBase):
def __init__(self, *a, **k):
super(ModifierBackgroundComponent, self).__init__(*a, **k)
def _clear_control(self, name, control):
super(ModifierBackgroundComponent, self)._clear_control(name, control)
if control:
try:
self._control_slots[name] = self.register_slot(control, lambda *a, **k: self._on_value_listener(control, *a, **k), 'value')
except SubjectSlotError:
pass
def _reset_control(self, control):
if len(control.resource.owners) > 1:
control.set_light(control.is_pressed())
else:
control.reset()
def _on_value_listener(self, sender, value, *a, **k):
if len(sender.resource.owners) > 1:
sender.set_light(sender.is_pressed())