def on_selected_scene_changed(self):
     super(SessionComponent, self).on_selected_scene_changed()
     all_scenes = self.song().scenes
     selected_scene = self.song().view.selected_scene
     new_offset = index_if(lambda a: a == selected_scene, all_scenes)
     if new_offset < len(all_scenes):
         self.set_offsets(self.track_offset(), new_offset)
 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
Example #4
0
 def _first_scale_note_offset(self):
     if not self._scales.is_diatonic:
         return self._scales.notes[0]
     elif self._scales.notes[0] == 0:
         return 0
     else:
         return len(self._scales.notes) - index_if(lambda n: n >= 12, self._scales.notes)
 def on_selected_scene_changed(self):
     super(SessionComponent, self).on_selected_scene_changed()
     all_scenes = self.song().scenes
     selected_scene = self.song().view.selected_scene
     new_offset = index_if(lambda a: a == selected_scene, all_scenes)
     if new_offset < len(all_scenes):
         self.set_offsets(self.track_offset(), new_offset)
 def _selected_track_clip_is_above_playing_clip(self):
     song_view = self.song().view
     track = song_view.selected_track
     playing_slot_index = track.playing_slot_index
     selected_index = index_if(
         lambda slot: slot == song_view.highlighted_clip_slot,
         track.clip_slots)
     return playing_slot_index <= selected_index
 def get_filter_type(self):
     selected = self.get_selection_for_insert()
     chain = selected.canonical_parent if selected else self._selection.selected_track
     chain_len = len(chain.devices)
     index = index_if(lambda device: device == selected, chain.devices)
     is_drum_pad = isinstance(chain.canonical_parent, Live.DrumPad.DrumPad)
     midi_support = chain.has_midi_input
     if not is_drum_pad:
         supports_instrument = chain.has_midi_input and (chain.has_audio_output or isinstance(chain, Live.Track.Track))
         left = self.insert_left and (chain.devices[index - 1] if index > 0 else None)
         return filter_type_between(left, selected, midi_support, is_drum_pad, supports_instrument)
     else:
         right = chain.devices[index + 1] if index < chain_len - 1 else None
         return filter_type_between(selected, right, midi_support, is_drum_pad, supports_instrument)
 def get_filter_type(self):
     selected = self.get_selection_for_insert()
     chain = selected.canonical_parent if selected else self._selection.selected_track
     chain_len = len(chain.devices)
     index = index_if(lambda device: device == selected, chain.devices)
     is_drum_pad = isinstance(chain.canonical_parent, Live.DrumPad.DrumPad)
     midi_support = chain.has_midi_input
     if not is_drum_pad:
         supports_instrument = chain.has_midi_input and (chain.has_audio_output or isinstance(chain, Live.Track.Track))
         left = self.insert_left and (chain.devices[index - 1] if index > 0 else None)
         return filter_type_between(left, selected, midi_support, is_drum_pad, supports_instrument)
     else:
         right = chain.devices[index + 1] if index < chain_len - 1 else None
         return filter_type_between(selected, right, midi_support, is_drum_pad, supports_instrument)
    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)
Example #11
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 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_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
Example #14
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 #15
0
 def on_mixer_track_nav(self, value):
     move = -1 if value > 64 else +1
     # get tracks-info
     tracks = self.song().tracks
     return_tracks = self.song().return_tracks
     master_track = self.song().master_track
     all_tracks = list(chain(tracks, return_tracks))
     all_tracks.append(master_track)
     num_tracks = len(tracks)
     num_return_tracks = len(return_tracks)
     num_master_track = 1
     num_all_tracks = num_tracks + num_return_tracks + num_master_track
     # update selected-track
     index = index_if(lambda t: t == self.song().view.selected_track,
                      all_tracks)
     index += move
     index = min(max(index, 0), num_all_tracks - 1)
     self.song().view.selected_track = all_tracks[index]
 def _selected_track_clip_is_above_playing_clip(self):
     song_view = self.song().view
     track = song_view.selected_track
     playing_slot_index = track.playing_slot_index
     selected_index = index_if(lambda slot: slot == song_view.highlighted_clip_slot, track.clip_slots)
     return playing_slot_index <= selected_index
 def _find_last_clip(self):
     """ Finds the last clip of the session and returns the scene index """
     scenes = self.song().scenes
     return len(scenes) - index_if(self._has_clip, reversed(scenes)) - 1
 def _find_last_clip(self):
     """ Finds the last clip of the session and returns the scene index """
     scenes = self.song().scenes
     return len(scenes) - index_if(self._has_clip, reversed(scenes)) - 1
 def _remove_client(self, client):
     idx = index_if(lambda (c, _): c == client, self._clients)
     if idx != len(self._clients):
         del self._clients[idx]
         return True
 def _add_client(self, client, priority):
     idx = index_if(lambda (_, p): p > priority, self._clients)
     self._clients.insert(idx, (client, priority))