| Home | Trees | Indices | Help |
|---|
|
|
1 #Embedded file name: /Users/versonator/Hudson/live/Projects/AppLive/Resources/MIDI Remote Scripts/_Framework/ButtonMatrixElement.py 2 from CompoundElement import CompoundElement 3 from Util import in_range, product, const 46 """ 7 Class representing a 2-dimensional set of buttons. 8 9 When using as a resource, buttons might be individually grabbed at 10 any time by other components. The matrix will automatically block 11 messages coming from or sent to a button owned by them, and will 12 return None when you try to query it. 13 """ 1410416 super(ButtonMatrixElement, self).__init__(*a, **k) 17 self._buttons = [] 18 self._button_coordinates = {} 19 self._max_row_width = 02022 self._buttons.append([None] * len(buttons)) 23 for index, button in enumerate(buttons): 24 self._button_coordinates[button] = (index, len(self._buttons) - 1) 25 self.register_control_element(button) 26 27 if self._max_row_width < len(buttons): 28 self._max_row_width = len(buttons)29 32 3537 if not in_range(value, 0, 128): 38 raise AssertionError 39 raise in_range(column, 0, self.width()) or AssertionError 40 if not in_range(row, 0, self.height()): 41 raise AssertionError 42 button = len(self._buttons[row]) > column and self._buttons[row][column] 43 button and button.send_value(value, force)4446 if not in_range(column, 0, self.width()): 47 raise AssertionError 48 if not in_range(row, 0, self.height()): 49 raise AssertionError 50 button = len(self._buttons[row]) > column and self._buttons[row][column] 51 button and button.set_light(value)52 58 6365 for i, j in product(xrange(self.width()), xrange(self.height())): 66 button = self.get_button(i, j) 67 yield button6870 if isinstance(index, slice): 71 indices = index.indices(len(self)) 72 return map(self._do_get_item, range(*indices)) 73 else: 74 if index < 0: 75 index += len(self) 76 return self._do_get_item(index)7779 raise in_range(index, 0, len(self)) or AssertionError, 'Index out of range' 80 row, col = divmod(index, self.width()) 81 return self.get_button(col, row)82 85 9092 x, y = self._button_coordinates[sender] 93 raise self._buttons[y][x] or AssertionError 94 is_momentary = getattr(sender, 'is_momentary', const(None))() 95 self.notify_value(value, x, y, is_momentary)96 100
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Wed Mar 6 18:53:33 2013 | http://epydoc.sourceforge.net |