def _get_step_start_time(self, x, y):
     """ returns step starttime in beats, based on step coordinates """
     raise in_range(x, 0, self._width) or AssertionError
     raise in_range(y, 0, self._height) or AssertionError
     page_time = self._page_index * self._get_step_count() * self._triplet_factor
     step_time = x + y * self._width * self._triplet_factor
     return (page_time + step_time) * self._get_step_length()
Example #2
0
 def update(self):
     super(BaseClipSlotComponent, self).update()
     self._has_fired_slot = False
     button = self._launch_button_value.subject
     delete_button = self._delete_button_value.subject
     if self._allow_updates:
         value_to_send = self._feedback_value()
         if self.is_enabled() and button != None:
             delete_value_to_send = self._deletable_value(value_to_send)
             if value_to_send in (None, -1):
                 button.turn_off()
             elif in_range(value_to_send, 0, 128):
                 button.send_value(value_to_send)
             else:
                 button.set_light(value_to_send)
         if self.is_enabled() and delete_button != None:
             delete_value_to_send = self._deletable_value(value_to_send)
             if value_to_send in (None, -1):
                 delete_button.turn_off()
             elif in_range(value_to_send, 0, 128):
                 delete_button.send_value(delete_value_to_send)
             else:
                 delete_button.set_light(delete_value_to_send)
     else:
         self._update_requests += 1
 def _get_step_start_time(self, x, y):
     """ returns step starttime in beats, based on step coordinates """
     raise in_range(x, 0, STEP_SEQ_WIDTH) or AssertionError
     raise in_range(y, 0, STEP_SEQ_HEIGHT) or AssertionError
     page_time = self._page_index * STEP_SEQ_SIZE * self._triplet_factor
     step_time = x + y * STEP_SEQ_WIDTH * self._triplet_factor
     return (page_time + step_time) * self._get_step_length()
 def _get_step_start_time(self, x, y):
     """ returns step starttime in beats, based on step coordinates """
     raise in_range(x, 0, self._width) or AssertionError
     raise in_range(y, 0, self._height) or AssertionError
     page_time = self._page_index * self._get_step_count() * self._triplet_factor
     step_time = x + y * self._width * self._triplet_factor
     return (page_time + step_time) * self._get_step_length()
 def update(self):
     super(BaseClipSlotComponent, self).update()
     self._has_fired_slot = False
     button = self._launch_button_value.subject
     delete_button = self._delete_button_value.subject
     if self._allow_updates:
         value_to_send = self._feedback_value()
         if self.is_enabled() and button != None:
             delete_value_to_send = self._deletable_value(value_to_send)
             if value_to_send in (None, -1):
                 button.turn_off()
             elif in_range(value_to_send, 0, 128):
                 button.send_value(value_to_send)
             else:
                 button.set_light(value_to_send)
         if self.is_enabled() and delete_button != None:
             delete_value_to_send = self._deletable_value(value_to_send)
             if value_to_send in (None, -1):
                 delete_button.turn_off()
             elif in_range(value_to_send, 0, 128):
                 delete_button.send_value(delete_value_to_send)
             else:
                 delete_button.set_light(delete_value_to_send)
     else:
         self._update_requests += 1
Example #6
0
 def _get_step_start_time(self, x, y):
     """ returns step starttime in beats, based on step coordinates """
     raise in_range(x, 0, STEP_SEQ_WIDTH) or AssertionError
     raise in_range(y, 0, STEP_SEQ_HEIGHT) or AssertionError
     page_time = self._page_index * STEP_SEQ_SIZE * self._triplet_factor
     step_time = x + y * STEP_SEQ_WIDTH * self._triplet_factor
     return (page_time + step_time) * self._get_step_length()
 def send_value(self, column, row, value, force=False):
     if self.__grabbed:
         assert in_range(value, 0, 128)
         assert in_range(column, 0, self.width())
         assert in_range(row, 0, self.height())
         if len(self._buttons[row]) > column:
             button = self._buttons[row][column]
             if button:
                 button.send_color(value)
Example #8
0
 def send_value(self, column, row, value, force=False):
     if self._IndexButtonMatrix__grabbed:
         if not in_range(value, 0, 128):
             raise AssertionError
         else:
             assert in_range(column, 0, self.width())
             assert in_range(row, 0, self.height())
             if len(self._buttons[row]) > column:
                 button = self._buttons[row][column]
                 if button:
                     button.send_color(value)
Example #9
0
 def send_value(self, column, row, value, force=False):
     if self.grabbed:
         if not in_range(value, 0, 128):
             raise AssertionError
         elif not in_range(column, 0, self.width()):
             raise AssertionError
         else:
             assert in_range(row, 0, self.height())
             if len(self._buttons[row]) > column:
                 button = self._buttons[row][column]
                 if button:
                     if value == 0:
                         button.send_color_direct(0)
                     else:
                         button.send_color_direct(value)
 def preselect(self):
     old_selected_child_index = self.selected_child
     if old_selected_child_index == None:
         devices = map(second, self.children)
         instrument = index_if(
             lambda d: isinstance(d, Live.Device.Device) and d.type == DeviceType.instrument, devices
         )
         if in_range(instrument, 0, len(devices)):
             if (
                 devices[instrument].can_have_drum_pads
                 and devices[instrument].drum_pads
                 and instrument + 1 < len(devices)
             ):
                 self.selected_child = instrument + 1
             else:
                 self.selected_child = instrument
     super(ChainNode, self).preselect()
     new_selected_child_index = self.selected_child
     track = self._get_track()
     if new_selected_child_index == old_selected_child_index:
         if new_selected_child_index != None:
             _, selected_object = self.children[new_selected_child_index]
             isinstance(
                 selected_object, Live.Device.Device
             ) and track and track.view.selected_device != selected_object and self._get_song().view.select_device(
                 selected_object
             )
     self._device_bank_registry.set_device_bank(track.view.selected_device, None)
 def preselect(self):
     old_selected_child_index = self.selected_child
     if old_selected_child_index == None:
         devices = map(second, self.children)
         instrument = index_if(
             lambda d: isinstance(d, Live.Device.Device) and d.type ==
             DeviceType.instrument, devices)
         if in_range(instrument, 0, len(devices)):
             if devices[instrument].can_have_drum_pads and devices[
                     instrument].drum_pads and instrument + 1 < len(
                         devices):
                 self.selected_child = instrument + 1
             else:
                 self.selected_child = instrument
     super(ChainNode, self).preselect()
     new_selected_child_index = self.selected_child
     track = self._get_track()
     if new_selected_child_index == old_selected_child_index:
         if new_selected_child_index != None:
             _, selected_object = self.children[new_selected_child_index]
             isinstance(
                 selected_object, Live.Device.Device
             ) and track and track.view.selected_device != selected_object and self._get_song(
             ).view.select_device(selected_object)
     self._device_bank_registry.set_device_bank(track.view.selected_device,
                                                None)
     return
def can_nav_list(list_to_nav, current_selection, increment):
    """ Returns whether or not it's possible to navigate the given list from the given
    selection by the given increment. """
    try:
        return in_range(list(list_to_nav).index(current_selection) + increment, 0, len(list_to_nav))
    except ValueError:
        return False
 def _on_stop_track_value(self, value, button):
     if self.is_enabled():
         if value is not 0 or not button.is_momentary():
             tracks = self.tracks_to_use()
             track_index = list(self._stop_track_clip_buttons).index(button) + self.track_offset()
             if in_range(track_index, 0, len(tracks)) and tracks[track_index] in self.song().tracks:
                 tracks[track_index].stop_all_clips()
 def _set_selected_option(self, selected_option):
     raise in_range(selected_option, 0, len(
         self.option_names)) or selected_option is None or AssertionError
     self._selected_option = selected_option
     self._update_select_buttons()
     self._update_data_sources()
     return
 def set_selected_child(self, child):
     if not (in_range(child, 0, len(self._children)) or child == None):
         raise AssertionError
     _, obj = child >= 0 and child < len(self._children) and self._children[child]
     self._set_selected_child_in_model(obj)
     self._selected_child = child
     else:
Example #16
0
 def _update_stop_clips_led(self, index):
     tracks_to_use = self.tracks_to_use()
     track_index = index + self.track_offset()
     if self.is_enabled(
     ) and self._stop_track_clip_buttons is not None and index < len(
             self._stop_track_clip_buttons):
         button = self._stop_track_clip_buttons[index]
         if button is not None:
             value_to_send = None
             if track_index < len(tracks_to_use) and tracks_to_use[
                     track_index].clip_slots:
                 track = tracks_to_use[track_index]
                 if track.fired_slot_index == -2:
                     value_to_send = self._stop_clip_triggered_value
                 elif track.playing_slot_index >= 0:
                     value_to_send = self._stop_clip_value
                 else:
                     value_to_send = self._stopped_clip_value
             if value_to_send is None:
                 button.turn_off()
             elif in_range(value_to_send, 0, 128):
                 button.send_value(value_to_send)
             else:
                 button.set_light(value_to_send)
     return
Example #17
0
 def _update_stop_scene_leds(self, index):
     scenes = self.song().scenes
     scene_index = index + self.scene_offset()
     if self.is_enabled(
     ) and self._stop_scene_clip_buttons is not None and index < len(
             self._stop_scene_clip_buttons):
         button = self._stop_scene_clip_buttons[index]
         if button is not None:
             value_to_send = None
             if scene_index < len(
                     scenes) and scenes[scene_index].clip_slots:
                 tracks = self.tracks_to_use()
                 if find_if(
                         lambda x: x.playing_slot_index == scene_index and x
                         .fired_slot_index != -2, tracks):
                     value_to_send = self._stop_clip_value
                 elif find_if(
                         lambda x: x.fired_slot_index == -2 and x.
                         playing_slot_index == scene_index, tracks):
                     value_to_send = self._stop_clip_triggered_value
                 else:
                     value_to_send = b'Session.StoppedClip'
             if value_to_send is None:
                 button.turn_off()
             elif in_range(value_to_send, 0, 128):
                 button.send_value(value_to_send)
             else:
                 button.set_light(value_to_send)
     return
Example #18
0
 def _on_stop_scene_value(self, value, button):
     if self.is_enabled():
         if value is not 0 or not button.is_momentary():
             scene_index = list(self._stop_scene_clip_buttons).index(button) + self.scene_offset()
             for track in self.tracks_to_use():
                 if in_range(scene_index, 0, len(track.clip_slots)) and (track.playing_slot_index == scene_index or track.fired_slot_index == scene_index):
                     track.stop_all_clips()
def to_bytes(number, size):
    """
    turns the given value into tuple of 4bit bytes,
    ordered from most significant to least significant byte
    """
    raise in_range(number, 0, 1 << size * 4) or AssertionError
    return tuple([ number >> offset & 15 for offset in xrange((size - 1) * 4, -1, -4) ])
Example #20
0
 def next_item(self):
     item = None
     if self._scrollable_list != None:
         all_items = self._scrollable_list.items
         next_index = self._scrollable_list.selected_item_index + 1
         item = all_items[next_index] if in_range(next_index, 0, len(all_items)) else None
     return item
 def _on_stop_scene_value(self, value, button):
     if self.is_enabled():
         if value is not 0 or not button.is_momentary():
             scene_index = list(self._stop_scene_clip_buttons).index(button) + self.scene_offset()
             for track in self.tracks_to_use():
                 if in_range(scene_index, 0, len(track.clip_slots)) and (track.playing_slot_index == scene_index or track.fired_slot_index == scene_index):
                     track.stop_all_clips()
Example #22
0
 def next_item(self):
     item = None
     if self._scrollable_list != None:
         all_items = self._scrollable_list.items
         next_index = self._scrollable_list.selected_item_index + 1
         item = all_items[next_index] if in_range(next_index, 0, len(all_items)) else None
     return item
Example #23
0
 def selected_object(self):
     selected = None
     if self._current_node:
         children = self._current_node.children
         option = self._device_list.selected_option
         if children and in_range(option, 0, len(children)):
             _, selected = children[option]
     return selected
Example #24
0
 def selected_object(self):
     selected = None
     if self._current_node:
         children = self._current_node.children
         option = self._device_list.selected_option
         if children and in_range(option, 0, len(children)):
             _, selected = children[option]
     return selected
 def _set_mode(self, mode):
     raise in_range(mode, 0, self.MODE_COUNT) or AssertionError
     self._mode = mode
     self._send_midi(Sysex.START + (99,
      0,
      1,
      mode,
      247))
 def _set_selected_option(self, selected_option):
     if not (selected_option != self._selected_option and
             (selected_option == None
              or in_range(selected_option, 0, self._option_names))):
         raise AssertionError
         self._selected_option = selected_option
         self.notify_change_option(selected_option)
         self.update()
 def set_selected_child(self, child):
     if not (in_range(child, 0, len(self._children)) or child == None):
         raise AssertionError
         _, obj = child >= 0 and child < len(self._children) and self._children[child]
         self._set_selected_child_in_model(obj)
         self._selected_child = child
     else:
         self._selected_child = None
         self._set_selected_child_in_model(None)
Example #28
0
 def _update_select_buttons(self):
     if self.is_enabled() and self._select_buttons:
         for index, button in enumerate(self._select_buttons):
             if button:
                 if index == self._selected_option:
                     button.set_light(self.selected_color)
                 elif in_range(index, 0, len(self.option_names)):
                     button.set_light(self.unselected_color)
                 else:
                     button.set_light('DefaultButton.Disabled')
 def select_item_index_with_border(self, index, border_size):
     """
     Selects an item with an index. Moves the view if the selection would exceed the
     border of the current view.
     """
     if index >= 0 and index < len(self._items):
         if not in_range(index, self._offset + border_size, self._offset + self._num_visible_items - border_size):
             offset = index - (self._num_visible_items - 2 * border_size) if self.selected_item_index < index else index - border_size
             self._offset = clamp(offset, 0, len(self._items))
         self._normalize_offset(index)
         self._do_set_selected_item_index(index)
Example #30
0
 def select_item_index_with_border(self, index, border_size):
     """
     Selects an item with an index. Moves the view if the selection would exceed the
     border of the current view.
     """
     if self.fixed_offset is not None:
         self.select_item_index_with_offset(index, self.fixed_offset)
     elif index >= 0 and index < len(self._items):
         if not in_range(index, self._offset + border_size, self._offset + self._num_visible_items - border_size):
             offset = index - (self._num_visible_items - 2 * border_size) if self.selected_item_index < index else index - border_size
             self._offset = clamp(offset, 0, len(self._items))
         self._normalize_offset(index)
         self._do_set_selected_item_index(index)
Example #31
0
 def _on_state_button_value(self, index, value):
     min_button_index = int(bool(self._offset_index))
     max_button_index = len(self._state_button_slots) - int(self._maximal_offset() > self._offset_index)
     if self.is_enabled() and value:
         if in_range(index, min_button_index, max_button_index):
             index += max(0, self._offset_index - 1)
             if index < len(self._option_states):
                 new_state = not self.option_state(index)
                 self.set_option_state(index, new_state)
             else:
                 self.notify_press_option(None)
         else:
             self.notify_press_option(None)
Example #32
0
 def _on_selection_clicked_in_controller(self, index):
     if self._delete_button and self._delete_button.is_pressed():
         if self._current_node:
             self._current_node.delete_child(index)
         return True
     elif consts.PROTO_FAST_DEVICE_NAVIGATION:
         if self._device_list.selected_option == index:
             self._set_current_node(self._make_enter_node())
             return True
         elif not in_range(index, 0, len(self._device_list.option_names)):
             self._set_current_node(self._make_exit_node())
             return True
     return index == None
 def _on_state_button_value(self, index, value):
     min_button_index = int(bool(self._offset_index))
     max_button_index = len(self._state_button_slots) - int(self._maximal_offset() > self._offset_index)
     if self.is_enabled() and value:
         if in_range(index, min_button_index, max_button_index):
             index += max(0, self._offset_index - 1)
             if index < len(self._option_states):
                 new_state = not self.option_state(index)
                 self.set_option_state(index, new_state)
             else:
                 self.notify_press_option(None)
         else:
             self.notify_press_option(None)
Example #34
0
 def _on_selection_clicked_in_controller(self, index):
     if self._is_deleting:
         if self._current_node:
             self._current_node.delete_child(index)
         return True
     elif consts.PROTO_FAST_DEVICE_NAVIGATION:
         if self._device_list.selected_option == index:
             self._set_current_node(self._make_enter_node())
             return True
         elif not in_range(index, 0, len(self._device_list.option_names)):
             self._set_current_node(self._make_exit_node())
             return True
     return index == None
    def update_selection(self):
        last_seleced_list_index = None
        if self._browser.hotswap_target != None:
            list_index = 0
            while list_index < self._num_contents:
                content_list, _ = self._contents[list_index]
                items = content_list.items
                index = index_if(lambda x: x.content.is_selected, items)
                if in_range(index, 0, len(items)):
                    content_list.select_item_index_with_offset(index, 2)
                    last_seleced_list_index = list_index
                list_index += 1

        if last_seleced_list_index != None:
            self.notify_selection_updated(last_seleced_list_index)
    def update_selection(self):
        last_seleced_list_index = None
        if self._browser.hotswap_target != None:
            list_index = 0
            while list_index < self._num_contents:
                content_list, _ = self._contents[list_index]
                items = content_list.items
                index = index_if(lambda x: x.content.is_selected, items)
                if in_range(index, 0, len(items)):
                    content_list.select_item_index_with_offset(index, 2)
                    last_seleced_list_index = list_index
                list_index += 1

        if last_seleced_list_index != None:
            self.notify_selection_updated(last_seleced_list_index)
    def update_selection(self):
        target = self._browser.hotswap_target
        if self._browser.hotswap_target != None:
            if isinstance(target, Live.DrumPad.DrumPad) and (not target.chains or not target.chains[0].devices):
                for content_list in self.content_lists:
                    content_list.select_item_index_with_offset(0, 0)

            else:
                list_index = 0
                while list_index < self._num_contents:
                    content_list, _ = self._contents[list_index]
                    items = content_list.items
                    index = index_if(lambda x: x.content.is_selected, items)
                    if in_range(index, 0, len(items)):
                        content_list.select_item_index_with_offset(index, 2)
                    list_index += 1
    def assign_items(self, items):
        old_selection = unicode(self.selected_item)
        for item in self._items:
            item._scrollable_list = None

        self._items = tuple([ self.item_type(index=index, content=item, scrollable_list=self) for index, item in enumerate(items) ])
        if self._items:
            new_selection = index_if(lambda item: unicode(item) == old_selection, self._items)
            self._selected_item_index = new_selection if in_range(new_selection, 0, len(self._items)) else 0
            self._normalize_offset(self._selected_item_index)
        else:
            self._offset = 0
            self._selected_item_index = -1
        self._last_activated_item_index = None
        self.notify_selected_item()
        self.request_notify_item_activated()
 def _update_stop_clips_led(self, index):
     if self.is_enabled() and self._stop_track_clip_buttons != None:
         button = self._stop_track_clip_buttons[index]
         tracks = self.tracks_to_use()
         track_index = index + self.track_offset()
         if in_range(track_index, 0, len(tracks)):
             track = tracks[track_index]
             is_player_track = track in self.song().tracks
             if is_player_track and track.fired_slot_index == -2:
                 button.send_value(self._stop_track_clip_value)
             elif is_player_track and track.playing_slot_index >= 0:
                 button.send_value(AMBER_HALF)
             else:
                 button.turn_off()
         else:
             button.send_value(LED_OFF)
Example #40
0
    def update_selection(self):
        target = self._browser.hotswap_target
        if self._browser.hotswap_target != None:
            if isinstance(target, Live.DrumPad.DrumPad) and (not target.chains or not target.chains[0].devices):
                for content_list in self.content_lists:
                    content_list.select_item_index_with_offset(0, 0)

            else:
                list_index = 0
                while list_index < self._num_contents:
                    content_list, _ = self._contents[list_index]
                    items = content_list.items
                    index = index_if(lambda x: x.content.is_selected, items)
                    if in_range(index, 0, len(items)):
                        content_list.select_item_index_with_offset(index, 2)
                    list_index += 1
 def _update_stop_clips_led(self, index):
     if self.is_enabled() and self._stop_track_clip_buttons != None:
         button = self._stop_track_clip_buttons[index]
         tracks = self.tracks_to_use()
         track_index = index + self.track_offset()
         if in_range(track_index, 0, len(tracks)):
             track = tracks[track_index]
             is_player_track = track in self.song().tracks
             if is_player_track and track.fired_slot_index == -2:
                 button.send_value(self._stop_track_clip_value)
             elif is_player_track and track.playing_slot_index >= 0:
                 button.send_value(AMBER_HALF)
             else:
                 button.turn_off()
         else:
             button.send_value(LED_OFF)
Example #42
0
    def assign_items(self, items):
        old_selection = unicode(self.selected_item)
        for item in self._items:
            item._scrollable_list = None

        self._items = tuple([ self.item_type(index=index, content=item, scrollable_list=self) for index, item in enumerate(items) ])
        if self._items:
            new_selection = index_if(lambda item: unicode(item) == old_selection, self._items)
            self._selected_item_index = new_selection if in_range(new_selection, 0, len(self._items)) else 0
            self._normalize_offset(self._selected_item_index)
        else:
            self._offset = 0
            self._selected_item_index = -1
        self._last_activated_item_index = None
        self.notify_selected_item()
        self.request_notify_item_activated()
Example #43
0
 def update(self):
     super(ClipSlotComponent, self).update()
     self._has_fired_slot = False
     button = self._launch_button_value.subject
     if self._allow_updates:
         if self.is_enabled() and button != None:
             value_to_send = self._feedback_value()
             if value_to_send in (None, -1) or value_to_send["value"] in (None, -1):
                 button.turn_off()
             elif in_range(value_to_send["value"], 0, 128):
                 button.force_next_send()
                 button.send_value(value_to_send["value"], channel=value_to_send["channel"])
             else:
                 button.force_next_send()
                 button.set_light(value_to_send["value"])
     else:
         self._update_requests += 1
 def update(self):
     super(ClipSlotComponent, self).update()
     self._has_fired_slot = False
     button = self._launch_button_value.subject
     if self._allow_updates:
         if self.is_enabled() and button != None:
             value_to_send = self._feedback_value()
             if value_to_send in (None, -1) or value_to_send["value"] in (None, -1):
                 button.turn_off()
             elif in_range(value_to_send["value"], 0, 128):
                 button.force_next_send()
                 button.send_value(value_to_send["value"], channel=value_to_send["channel"])
             else:
                 button.force_next_send()
                 button.set_light(value_to_send["value"])
     else:
         self._update_requests += 1
 def _update_stop_clips_led(self, index):
     tracks_to_use = self.tracks_to_use()
     track_index = index + self.track_offset()
     if self.is_enabled() and self._stop_track_clip_buttons is not None and index < len(self._stop_track_clip_buttons):
         button = self._stop_track_clip_buttons[index]
         if button is not None:
             value_to_send = None
             if track_index < len(tracks_to_use) and tracks_to_use[track_index].clip_slots:
                 track = tracks_to_use[track_index]
                 if track.fired_slot_index == -2:
                     value_to_send = self._stop_clip_triggered_value
                 elif track.playing_slot_index >= 0:
                     value_to_send = self._stop_clip_value
                 else:
                     value_to_send = self._stopped_clip_value
             if value_to_send is None:
                 button.turn_off()
             elif in_range(value_to_send, 0, 128):
                 button.send_value(value_to_send)
             else:
                 button.set_light(value_to_send)
 def _update_stop_scene_leds(self, index):
     scenes = self.song().scenes
     scene_index = index + self.scene_offset()
     if self.is_enabled() and self._stop_scene_clip_buttons is not None and index < len(self._stop_scene_clip_buttons):
         button = self._stop_scene_clip_buttons[index]
         if button is not None:
             value_to_send = None
             if scene_index < len(scenes) and scenes[scene_index].clip_slots:
                 tracks = self.tracks_to_use()
                 if find_if(lambda x: x.playing_slot_index == scene_index and x.fired_slot_index != -2, tracks):
                     value_to_send = self._stop_clip_value
                 elif find_if(lambda x: x.fired_slot_index == -2 and x.playing_slot_index == scene_index, tracks):
                     value_to_send = self._stop_clip_triggered_value
                 else:
                     value_to_send = 'Session.StoppedClip'
             if value_to_send is None:
                 button.turn_off()
             elif in_range(value_to_send, 0, 128):
                 button.send_value(value_to_send)
             else:
                 button.set_light(value_to_send)
 def _set_mode(self, mode):
     if not in_range(mode, 0, TouchStripModes.COUNT):
         raise IndexError('Invalid Touch Strip Mode %d' % mode)
     self.behaviour = SimpleBehaviour(mode=mode)
Example #48
0
def has_next_item(seq, item, delta):
    try:
        return in_range(list(seq).index(item) + delta, 0, len(seq))
    except ValueError:
        return False
Example #49
0
 def selected_item(self):
     return self._items[self.selected_item_index] if in_range(
         self._selected_item_index, 0, len(self._items)) else None
 def turn_on_index(self, index, on_state=STATE_FULL, off_state=STATE_OFF):
     raise in_range(index, 0, self.STATE_COUNT) or AssertionError
     states = [off_state] * self.STATE_COUNT
     states[index] = on_state
     self.send_state(states)
 def turn_on_index(self, index, on_state = STATE_FULL, off_state = STATE_OFF):
     raise in_range(index, 0, self.STATE_COUNT) or AssertionError
     states = [off_state] * self.STATE_COUNT
     states[index] = on_state
     self.send_state(states)
 def _on_select_value(self, value, sender):
     if value:
         index = list(self._select_buttons).index(sender)
         if in_range(index, 0, len(self.option_names)):
             self.selected_option = index
             self.notify_selected_option(self.selected_option)
 def _set_selected_option(self, selected_option):
     raise in_range(selected_option, 0, len(self.option_names)) or selected_option is None or AssertionError
     self._selected_option = selected_option
     self._update_select_buttons()
     self._update_data_sources()
 def includes_time(self, time):
     return in_range(time - self.start + self.offset, 0, self.length)
 def _looped_time(self, time, extra_time = 0.0):
     if in_range(time, self.clip_end - self.offset, self.clip_end):
         time = time - self.clip_end + self.clip_start
     return time + extra_time
Example #56
0
 def selected_item(self):
     return self._items[self.selected_item_index] if in_range(self._selected_item_index, 0, len(self._items)) else None
 def includes_time(self, time):
     return in_range(self._looped_time(time) + self.offset - self.start, 0, self.length) and in_range(time, self.clip_start, self.clip_end)
 def includes_time(self, time):
     return in_range(time - self.start + self.offset, 0, self.length)