Package _Framework :: Module CompoundComponent
[hide private]
[frames] | no frames]

Source Code for Module _Framework.CompoundComponent

 1  #Embedded file name: /Users/versonator/Hudson/live/Projects/AppLive/Resources/MIDI Remote Scripts/_Framework/CompoundComponent.py 
 2  from ControlSurfaceComponent import ControlSurfaceComponent 
 3   
4 -class CompoundComponent(ControlSurfaceComponent):
5 """ Base class for classes encompasing other components to form complex components """ 6
7 - def __init__(self, *a, **k):
8 super(CompoundComponent, self).__init__(*a, **k) 9 self._sub_components = []
10
11 - def update_all(self):
12 self.update() 13 for component in self._sub_components: 14 component.update_all()
15
16 - def register_component(self, component):
17 raise component != None or AssertionError 18 raise component not in self._sub_components or AssertionError 19 component._set_enabled_recursive(self.is_enabled()) 20 self._sub_components.append(component) 21 return component
22
23 - def register_components(self, *a):
24 return map(self.register_component, a)
25
26 - def has_component(self, component):
27 return component in self._sub_components
28
29 - def set_enabled(self, enable):
30 """ 31 When disabling a compound component, childs are disabled. When 32 enabled, childs are restored to whatever state they were 33 explicitly set to. 34 """ 35 super(CompoundComponent, self).set_enabled(enable) 36 for component in self._sub_components: 37 component._set_enabled_recursive(self.is_enabled())
38
39 - def _set_enabled_recursive(self, enable):
40 super(CompoundComponent, self)._set_enabled_recursive(enable) 41 for component in self._sub_components: 42 component._set_enabled_recursive(self.is_enabled())
43
44 - def set_allow_update(self, allow_updates):
45 allow = bool(allow_updates) 46 if self._allow_updates != allow: 47 for component in self._sub_components: 48 component.set_allow_update(allow) 49 50 super(CompoundComponent, self).set_allow_update(allow)
51