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 and new_selected_child_index != None: _, selected_object = self.children[new_selected_child_index] if isinstance( selected_object, Live.Device.Device ) and track and track.view.selected_device != selected_object: select_and_appoint_device(self._get_song(), selected_object) self._device_bank_registry.set_device_bank(track.view.selected_device, 0)
def _set_selected_child_in_model(self, selected): song = self._get_song() if selected and isinstance(selected, Live.DrumPad.DrumPad): if selected.chains and selected.chains[0].devices: select_and_appoint_device(song, selected.chains[0].devices[0]) selected.canonical_parent.view.selected_drum_pad = selected elif selected and isinstance(selected, Live.Device.Device): select_and_appoint_device(song, selected) self._device_bank_registry.set_device_bank(selected, 0)
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 and new_selected_child_index != None: _, selected_object = self.children[new_selected_child_index] if isinstance(selected_object, Live.Device.Device) and track and track.view.selected_device != selected_object: select_and_appoint_device(self._get_song(), selected_object) self._device_bank_registry.set_device_bank(track.view.selected_device, 0)