Exemplo n.º 1
0
    def __init__(self, scrollable_list=None, data_sources=tuple(), *a, **k):
        super(ListComponent, self).__init__(*a, **k)
        self._data_sources = data_sources
        self._activation_task = Task.Task()
        self._action_on_scroll_task = Task.Task()
        self._scrollable_list = None
        self._scroller = self.register_component(ScrollComponent())
        self._pager = self.register_component(ScrollComponent())
        self.last_action_item = lambda: self._last_action_item
        self.item_formatter = DefaultItemFormatter()
        for c in (self._scroller, self._pager):
            for button in (c.scroll_up_button, c.scroll_down_button):
                button.color = 'List.ScrollerOn'
                button.pressed_color = None
                button.disabled_color = 'List.ScrollerOff'

        if scrollable_list == None:
            self.scrollable_list = ActionList(
                num_visible_items=len(data_sources))
        else:
            self.scrollable_list = scrollable_list
        self._scrollable_list.num_visible_items = len(data_sources)
        self._delay_activation = BooleanContext()
        self._selected_index_float = 0.0
        self._in_encoder_selection = BooleanContext(False)
        self._execute_action_task = self._tasks.add(
            Task.sequence(Task.delay(1), Task.run(self._execute_action)))
        self._execute_action_task.kill()
Exemplo n.º 2
0
    def __init__(self,
                 num_tracks=0,
                 num_scenes=0,
                 auto_name=False,
                 enable_skinning=False,
                 *a,
                 **k):
        super(CustomSessionComponent, self).__init__(*a, **k)
        assert num_tracks >= 0
        assert num_scenes >= 0
        self._track_offset = -1
        self._scene_offset = -1
        self._num_tracks = num_tracks
        self._num_scenes = num_scenes
        self._vertical_banking, self._horizontal_banking, self._vertical_paginator, self._horizontal_paginator = self.register_components(
            ScrollComponent(), ScrollComponent(), ScrollComponent(),
            ScrollComponent())
        self._vertical_banking.can_scroll_up = self._can_bank_up
        self._vertical_banking.can_scroll_down = self._can_bank_down
        self._vertical_banking.scroll_up = self._bank_up
        self._vertical_banking.scroll_down = self._bank_down
        self._horizontal_banking.can_scroll_up = self._can_bank_left
        self._horizontal_banking.can_scroll_down = self._can_bank_right
        self._horizontal_banking.scroll_up = self._bank_left
        self._horizontal_banking.scroll_down = self._bank_right
        self._vertical_paginator.can_scroll_up = self._can_scroll_page_up
        self._vertical_paginator.can_scroll_down = self._can_scroll_page_down
        self._vertical_paginator.scroll_up = self._scroll_page_up
        self._vertical_paginator.scroll_down = self._scroll_page_down
        self._horizontal_paginator.can_scroll_up = self._can_scroll_page_left
        self._horizontal_paginator.can_scroll_down = self._can_scroll_page_right
        self._horizontal_paginator.scroll_up = self._scroll_page_left
        self._horizontal_paginator.scroll_down = self._scroll_page_right

        self._delete_button = None
        self._delete_button_slot = None
        self._delete_pressed = False

        self._page_left_button = None
        self._page_right_button = None
        self._stop_all_button = None
        self._next_scene_button = None
        self._prev_scene_button = None
        self._stop_track_clip_buttons = None
        self._stop_clip_triggered_value = 127
        self._stop_clip_value = None
        self._highlighting_callback = None
        self._show_highlight = num_tracks > 0 and num_scenes > 0
        self._mixer = None
        self._track_slots = self.register_slot_manager()
        self._selected_scene = self.register_component(self._create_scene())
        self._scenes = self.register_components(
            *[self._create_scene() for _ in xrange(num_scenes)])
        if self._session_component_ends_initialisation:
            self._end_initialisation()
        if auto_name:
            self._auto_name()
        if enable_skinning:
            self._enable_skinning()
        return
 def __init__(self, name='Standard_Navigation_Control', **k):
     super(StandardNavComponent, self).__init__(name=name)
     self._horizontal_nav = self.register_component(ScrollComponent(scrollable=HorizontalNav(self.application()), **k))
     self._vertical_nav = self.register_component(ScrollComponent(scrollable=VerticalNav(self.application()), **k))
     self.application().view.add_is_view_visible_listener('Session', self._on_main_view_changed)
     skin_scroll_component(self._horizontal_nav, color='Navigation.StandardEnabled')
     skin_scroll_component(self._vertical_nav, color='Navigation.StandardEnabled')
Exemplo n.º 4
0
 def __init__(self, slideable=None, *a, **k):
     super(SlideComponent, self).__init__(*a, **k)
     slideable = slideable or self
     self._slideable = slideable
     self._position_scroll, self._page_scroll = self.register_components(
         ScrollComponent(), ScrollComponent())
     self._position_scroll.scrollable = self
     self._page_scroll.can_scroll_up = self.can_scroll_page_up
     self._page_scroll.can_scroll_down = self.can_scroll_page_down
     self._page_scroll.scroll_down = self.scroll_page_down
     self._page_scroll.scroll_up = self.scroll_page_up
     self._on_position_changed.subject = slideable
Exemplo n.º 5
0
    def __init__(self, *a, **k):
        super(SessionComponent, self).__init__(*a, **k)

        self._clip_horisontal_buttons = ScrollComponent()
        self._clip_horisontal_buttons.can_scroll_up = self.can_clip_left
        self._clip_horisontal_buttons.can_scroll_down = self.can_clip_right
        self._clip_horisontal_buttons.scroll_up = self.clip_left
        self._clip_horisontal_buttons.scroll_down = self.clip_right

        self._scene_vertical_buttons = ScrollComponent()
        self._scene_vertical_buttons.can_scroll_up = self.can_scene_up
        self._scene_vertical_buttons.can_scroll_down = self.can_scene_down
        self._scene_vertical_buttons.scroll_up = self.scene_up
        self._scene_vertical_buttons.scroll_down = self.scene_down
Exemplo n.º 6
0
 def __init__(self, *a, **k):
     super(ViewControlComponent, self).__init__(*a, **k)
     self._scroll_tracks, self._scroll_scene_list, self._scroll_scenes = self.register_components(
         ScrollComponent(TrackScroller()),
         ScrollComponent(SceneListScroller()),
         ScrollComponent(SceneScroller()))
     song = self.song()
     view = song.view
     self.register_slot(song, self._scroll_tracks.update, 'visible_tracks')
     self.register_slot(song, self._scroll_tracks.update, 'return_tracks')
     self.register_slot(song, self._scroll_scenes.update, 'scenes')
     self.register_slot(song, self._scroll_scene_list.update, 'scenes')
     self.register_slot(view, self._scroll_tracks.update, 'selected_track')
     self.register_slot(view, self._scroll_scenes.update, 'selected_scene')
     self.register_slot(view, self._scroll_scene_list.update,
                        'selected_scene')
 def __init__(self, *a, **k):
     super(InstrumentScalesComponent, self).__init__(*a, **k)
     self._key_center_slots = self.register_slot_manager()
     self._key_center_buttons = []
     self._encoder_touch_button_slots = self.register_slot_manager()
     self._encoder_touch_buttons = []
     self._top_key_center_buttons = None
     self._bottom_key_center_buttons = None
     self._absolute_relative_button = None
     self._diatonic_chromatic_button = None
     table = consts.MUSICAL_MODES
     self._modus_list = [
         Modus(table[k], table[k + 1])
         for k in xrange(0, len(consts.MUSICAL_MODES), 2)
     ]
     self._selected_modus = 0
     self._line_sources = recursive_map(DisplayDataSource,
                                        SCALES_DISPLAY_STRINGS)
     self._presets = self.register_component(InstrumentPresetsComponent())
     self._presets.set_enabled(False)
     self._presets_modes = self.register_component(ModesComponent())
     self._presets_modes.add_mode('disabled', None)
     self._presets_modes.add_mode('enabled', self._presets,
                                  'Scales.PresetsEnabled')
     self._presets_modes.selected_mode = 'disabled'
     self._presets_modes.momentary_toggle = True
     self._presets.selected_mode = 'scale_p4_vertical'
     self._scales_info = self.register_component(ScalesInfoComponent())
     self._scales_info.set_enabled(True)
     self._modus_scroll = self.register_component(ScrollComponent())
     self._modus_scroll.scrollable = self
     self._update_data_sources()
 def __init__(self, *a, **k):
     super(BaseTransportComponent, self).__init__(*a, **k)
     self._tempo_scrolling = self.register_component(ScrollComponent())
     self._tempo_scrolling.can_scroll_down = self._tempo_can_decrease
     self._tempo_scrolling.can_scroll_up = self._tempo_can_increase
     self._tempo_scrolling.scroll_up = self._increase_tempo
     self._tempo_scrolling.scroll_down = self._decrease_tempo
Exemplo n.º 9
0
 def __init__(self, slideable=None, dragging_enabled=False, *a, **k):
     super(SlideComponent, self).__init__(*a, **k)
     slideable = slideable or self
     self._behaviour = DraggingBehaviour(
     ) if dragging_enabled else SelectingBehaviour()
     self._touch_strip_array = []
     self._slideable = slideable
     self._position_scroll, self._page_scroll = self.register_components(
         ScrollComponent(), ScrollComponent())
     self._position_scroll.scrollable = self
     self._page_scroll.can_scroll_up = self.can_scroll_page_up
     self._page_scroll.can_scroll_down = self.can_scroll_page_down
     self._page_scroll.scroll_down = self.scroll_page_down
     self._page_scroll.scroll_up = self.scroll_page_up
     self._on_page_length_changed.subject = slideable
     self._on_page_offset_changed.subject = slideable
     self._on_position_count_changed.subject = slideable
     self._on_position_changed.subject = slideable
     self._on_contents_changed.subject = slideable
 def __init__(self, *a, **k):
     super(SessionNavigationComponent, self).__init__(*a, **k)
     self._scroll_tracks, self._scroll_scenes = self.register_components(
         ArmingTrackScrollComponent(TrackScroller()),
         ScrollComponent(BasicSceneScroller()))
     song = self.song()
     view = song.view
     self.register_slot(song, self._scroll_tracks.update, 'visible_tracks')
     self.register_slot(song, self._scroll_tracks.update, 'return_tracks')
     self.register_slot(song, self._scroll_scenes.update, 'scenes')
     self.register_slot(view, self._scroll_tracks.update, 'selected_track')
     self.register_slot(view, self._scroll_scenes.update, 'selected_scene')
 def __init__(self, *a, **k):
     super(SpecialSessionComponent, self).__init__(*a, **k)
     self._slot_launch_button = None
     self._duplicate_button = None
     self._duplicate, self._duplicate_modes, self._paginator = self.register_components(
         DuplicateSceneComponent(self), ModesComponent(), ScrollComponent())
     self._paginator.can_scroll_up = self._can_scroll_page_up
     self._paginator.can_scroll_down = self._can_scroll_page_down
     self._paginator.scroll_up = self._scroll_page_up
     self._paginator.scroll_down = self._scroll_page_down
     self._duplicate.set_enabled(False)
     self._duplicate_modes.add_mode('disabled', None)
     self._duplicate_modes.add_mode('enabled', self._duplicate)
     self._duplicate_modes.selected_mode = 'disabled'
     self._duplicate_modes.momentary_toggle = True
     self._track_playing_slots = self.register_slot_manager()
     self._end_initialisation()
 def __init__(self, *a, **k):
     super(InstrumentComponent, self).__init__(*a, **k)
     self._matrix = None
     self._octave_index = 3
     self._scales = self.register_component(InstrumentScalesComponent())
     self._scales.set_enabled(False)
     self._scales_modes = self.register_component(ModesComponent())
     self._scales_modes.add_mode('disabled', None)
     self._scales_modes.add_mode('enabled', self._scales,
                                 'DefaultButton.On')
     self._scales_modes.selected_mode = 'disabled'
     self._paginator = self.register_component(ScrollComponent())
     self._paginator.can_scroll_up = self._can_scroll_octave_up
     self._paginator.can_scroll_down = self._can_scroll_octave_down
     self._paginator.scroll_up = self._scroll_octave_up
     self._paginator.scroll_down = self._scroll_octave_down
     self.register_slot(self._scales, self._update_matrix, 'scales_changed')
     self.register_slot(self._scales._presets,
                        lambda _: self._update_matrix(), 'selected_mode')
 def __init__(self, scrollable_list=None, data_sources=tuple(), *a, **k):
     super(ListComponent, self).__init__(*a, **k)
     self._data_sources = data_sources
     self._activation_task = Task.Task()
     self._action_on_scroll_task = Task.Task()
     self._scrollable_list = None
     self._scroller = self.register_component(ScrollComponent())
     self.last_action_item = lambda: self._last_action_item
     if scrollable_list == None:
         self.scrollable_list = ActionList(
             num_visible_items=len(data_sources))
     else:
         self.scrollable_list = scrollable_list
     self._scrollable_list.num_visible_items = len(data_sources)
     self._delay_activation = BooleanContext()
     self._selected_index_float = 0.0
     self._in_encoder_selection = BooleanContext(False)
     self._execute_action_task = self._tasks.add(
         Task.sequence(Task.delay(1), Task.run(self._execute_action)))
     self._execute_action_task.kill()
Exemplo n.º 14
0
class SessionComponent(SessionComponentBase):
    _clip_horisontal_buttons = None
    _scene_vertical_buttons = None
    scene_play_button = ButtonControl()
    scene_stop_button = ButtonControl()

    def __init__(self, *a, **k):
        super(SessionComponent, self).__init__(*a, **k)

        self._clip_horisontal_buttons = ScrollComponent()
        self._clip_horisontal_buttons.can_scroll_up = self.can_clip_left
        self._clip_horisontal_buttons.can_scroll_down = self.can_clip_right
        self._clip_horisontal_buttons.scroll_up = self.clip_left
        self._clip_horisontal_buttons.scroll_down = self.clip_right

        self._scene_vertical_buttons = ScrollComponent()
        self._scene_vertical_buttons.can_scroll_up = self.can_scene_up
        self._scene_vertical_buttons.can_scroll_down = self.can_scene_down
        self._scene_vertical_buttons.scroll_up = self.scene_up
        self._scene_vertical_buttons.scroll_down = self.scene_down

    @scene_play_button.pressed
    def scene_play_button(self, button):
        tracks = self.song().tracks
        track_offset = self.track_offset()
        scene_offset = self.scene_offset()

        for x in xrange(self._num_tracks):
            if track_offset + x < len(tracks):
                clip = tracks[track_offset + x].clip_slots[scene_offset]
                clip.fire()

    @scene_stop_button.pressed
    def scene_stop_button(self, button):
        tracks = self.song().tracks
        track_offset = self.track_offset()
        scene_offset = self.scene_offset()

        for x in xrange(self._num_tracks):
            if track_offset + x < len(tracks):
                clip = tracks[track_offset + x].clip_slots[scene_offset]
                if clip.has_clip:
                    clip.stop()

    def on_selected_scene_changed(self):
        super(SessionComponent, self).on_selected_scene_changed()
        if self._clip_horisontal_buttons:
            self._clip_horisontal_buttons.update()
        if self._scene_vertical_buttons:
            self._scene_vertical_buttons.update()

    def _reassign_tracks(self):
        if self._clip_horisontal_buttons:
            self._clip_horisontal_buttons.update()
        super(SessionComponent, self)._reassign_tracks()

    def _reassign_scenes(self):
        if self._scene_vertical_buttons:
            self._scene_vertical_buttons.update()
        super(SessionComponent, self)._reassign_scenes()

    def can_clip_left(self):
        selected_track = self.song().view.selected_track
        tracks = self.song().tracks
        return selected_track != tracks[0]

    def can_clip_right(self):
        selected_track = self.song().view.selected_track
        tracks = self.song().tracks
        return selected_track != tracks[(-1)]

    def clip_left(self):
        selected_track = self.song().view.selected_track
        tracks = self.song().tracks

        if selected_track in tracks:
            index = list(tracks).index(selected_track) - 1
        else:
            index = self.track_offset()

        self.song().view.selected_track = tracks[index]

    def clip_right(self):
        selected_track = self.song().view.selected_track
        tracks = self.song().tracks

        if selected_track in tracks:
            index = list(tracks).index(selected_track) + 1
        else:
            index = self.track_offset()

        self.song().view.selected_track = tracks[index]

    def can_scene_up(self):
        return self._get_minimal_scene_offset() > 0

    def can_scene_down(self):
        return len(self.song().scenes) > self._get_minimal_scene_offset() + 1

    def scene_up(self):
        return self.set_offsets(self.track_offset(),
                                max(0,
                                    self.scene_offset() - 1))

    def scene_down(self):
        return self.set_offsets(self.track_offset(), self.scene_offset() + 1)

    def clear_buttons(self):
        return

    def set_clip_left_button(self, button):
        if button:
            self._clip_horisontal_buttons.scroll_up_button.color = 'Color.NavButtonOn'
            self._clip_horisontal_buttons.scroll_up_button.disabled_color = 'Color.NavButtonOff'
            self._clip_horisontal_buttons.scroll_up_button.pressed_color = None
        else:
            self._clip_horisontal_buttons.scroll_up_button.color = 'Color.Off'
            self._clip_horisontal_buttons.scroll_up_button.disabled_color = 'Color.Off'

        self._clip_horisontal_buttons.set_scroll_up_button(button)

    def set_clip_right_button(self, button):
        if button:
            self._clip_horisontal_buttons.scroll_down_button.color = 'Color.NavButtonOn'
            self._clip_horisontal_buttons.scroll_down_button.disabled_color = 'Color.NavButtonOff'
            self._clip_horisontal_buttons.scroll_down_button.pressed_color = None
        else:
            self._clip_horisontal_buttons.scroll_down_button.color = 'Color.Off'
            self._clip_horisontal_buttons.scroll_down_button.disabled_color = 'Color.Off'

        self._clip_horisontal_buttons.set_scroll_down_button(button)

    def set_page_left_button(self, button):
        if button:
            self._horizontal_paginator.scroll_up_button.color = 'Color.NavButtonOn'
            self._horizontal_paginator.scroll_up_button.disabled_color = 'Color.NavButtonOff'
            self._horizontal_paginator.scroll_up_button.pressed_color = None
        else:
            self._horizontal_paginator.scroll_up_button.color = 'Color.Off'
            self._horizontal_paginator.scroll_up_button.disabled_color = 'Color.Off'

        self._horizontal_paginator.set_scroll_up_button(button)

    def set_page_right_button(self, button):
        if button:
            self._horizontal_paginator.scroll_down_button.color = 'Color.NavButtonOn'
            self._horizontal_paginator.scroll_down_button.disabled_color = 'Color.NavButtonOff'
            self._horizontal_paginator.scroll_down_button.pressed_color = None
        else:
            self._horizontal_paginator.scroll_down_button.color = 'Color.Off'
            self._horizontal_paginator.scroll_down_button.disabled_color = 'Color.Off'

        self._horizontal_paginator.set_scroll_down_button(button)

    #def set_track_bank_left_button(self, button):
    #    if button:
    #        self._horizontal_banking.scroll_up_button.color = 'Color.NavButtonOn'
    #        self._horizontal_banking.scroll_up_button.disabled_color = 'Color.NavButtonOff'
    #        self._horizontal_banking.scroll_up_button.pressed_color = None
    #    else:
    #        self._horizontal_banking.scroll_up_button.color = 'Color.Off'
    #        self._horizontal_banking.scroll_up_button.disabled_color = 'Color.Off'

    #    self._horizontal_banking.set_scroll_up_button(button)

    #def set_track_bank_right_button(self, button):
    #    if button:
    #        self._horizontal_banking.scroll_down_button.color = 'Color.NavButtonOn'
    #        self._horizontal_banking.scroll_down_button.disabled_color = 'Color.NavButtonOff'
    #        self._horizontal_banking.scroll_down_button.pressed_color = None
    #    else:
    #        self._horizontal_banking.scroll_down_button.color = 'Color.Off'
    #        self._horizontal_banking.scroll_down_button.disabled_color = 'Color.Off'

    #    self._horizontal_banking.set_scroll_down_button(button)

    def set_scene_play_button(self, button):
        if button:
            self.scene_play_button.set_control_element(button)

    def set_scene_stop_button(self, button):
        if button:
            self.scene_stop_button.set_control_element(button)

    def set_scene_up_button(self, button):
        if button:
            self._scene_vertical_buttons.scroll_up_button.color = 'Color.NavButtonOn'
            self._scene_vertical_buttons.scroll_up_button.disabled_color = 'Color.NavButtonOff'
            self._scene_vertical_buttons.scroll_up_button.pressed_color = None
        else:
            self._scene_vertical_buttons.scroll_up_button.color = 'Color.Off'
            self._scene_vertical_buttons.scroll_up_button.disabled_color = 'Color.Off'

        self._scene_vertical_buttons.set_scroll_up_button(button)

    def set_scene_down_button(self, button):
        if button:
            self._scene_vertical_buttons.scroll_down_button.color = 'Color.NavButtonOn'
            self._scene_vertical_buttons.scroll_down_button.disabled_color = 'Color.NavButtonOff'
            self._scene_vertical_buttons.scroll_down_button.pressed_color = None
        else:
            self._scene_vertical_buttons.scroll_down_button.color = 'Color.Off'
            self._scene_vertical_buttons.scroll_down_button.disabled_color = 'Color.Off'

        self._scene_vertical_buttons.set_scroll_down_button(button)

    def set_offsets(self, track_offset, scene_offset):
        super(SessionComponent, self).set_offsets(track_offset, scene_offset)
        if scene_offset != None:
            scenes = self.song().scenes
            self.song().view.selected_scene = scenes[scene_offset]
 def __init__(self, *a, **k):
     super(SpecialSessionComponent, self).__init__(*a, **k)
     self._slot_launch_button = None
     self._duplicate_button = None
     self._duplicate, self._paginator = self.register_components(DuplicateSceneComponent(self), ScrollComponent())
     self._duplicate_enabler = self.register_component(EnablingModesComponent(component=self._duplicate))
     self._duplicate_enabler.momentary_toggle = True
     self._paginator.can_scroll_up = self._can_scroll_page_up
     self._paginator.can_scroll_down = self._can_scroll_page_down
     self._paginator.scroll_up = self._scroll_page_up
     self._paginator.scroll_down = self._scroll_page_down
     self._track_playing_slots = self.register_slot_manager()
     self._end_initialisation()