1
2 import Live
3 from Dependency import dependency, depends
4 from SubjectSlot import SlotManager, Subject
5 from Util import lazy_attribute
6 import Task
9 """
10 Base class for all classes encapsulating functions in Live
11 """
12 name = ''
13 canonical_parent = None
14 is_private = False
15 _show_msg_callback = dependency(show_message=None)
16 _has_task_group = False
17 _layer = None
18
19 @depends(register_component=None, song=None)
20 - def __init__(self, name = '', register_component = None, song = None, *a, **k):
31
37
50
53
55 raise NotImplementedError, self.__class__
56
59
63
67
74
76 allow = bool(allow_updates)
77 if self._allow_updates != allow:
78 self._allow_updates = allow
79 if self._allow_updates and self._update_requests > 0:
80 self._update_requests = 0
81 self.update()
82
84 return Live.Application.get_application()
85
88
89 @lazy_attribute
90 @depends(parent_task_group=None)
91 - def _tasks(self, parent_task_group = None):
97
100
102 if self._layer != new_layer:
103 self._layer and self._layer.release(self)
104 self._layer = new_layer
105 if new_layer and self.is_enabled():
106 grabbed = new_layer.grab(self)
107 if not grabbed:
108 raise AssertionError, 'Only one component can use a layer at atime'
109
110 layer = property(_get_layer, _set_layer)
111
113 """
114 Returns whether the component is enabled.
115 If 'explicit' is True the parent state is ignored.
116 """
117 return self._is_enabled if not explicit else self._explicit_is_enabled
118
120 """
121 Called by the control surface if tracks are added/removed,
122 to be overridden
123 """
124 pass
125
127 """
128 Called by the control surface if scenes are added/removed, to
129 be overridden
130 """
131 pass
132
134 """
135 Called by the control surface when a track is selected, to be
136 overridden
137 """
138 pass
139
141 """
142 Called by the control surface when a scene is selected, to be
143 overridden
144 """
145 pass
146
147 @depends(parent_task_group=None)
149 """
150 DEPRECATED. Use tasks instead
151 """
152 raise callable(callback) or AssertionError
153 raise parent_task_group.find(callback) is None or AssertionError
154
155 def wrapper(delta):
156 callback()
157 return Task.RUNNING
158
159 parent_task_group.add(Task.FuncTask(wrapper, callback))
160
161 @depends(parent_task_group=None)
163 """
164 DEPRECATED. Use tasks instead
165 """
166 raise callable(callback) or AssertionError
167 task = parent_task_group.find(callback)
168 raise task is not None or AssertionError
169 parent_task_group.remove(task)
170