Exemplo n.º 1
0
def play_pressed():
    if editorstate.current_is_active_trim_mode(
    ) and trimmodes.submode != trimmodes.NOTHING_ON:
        return

    if current_is_move_mode():
        movemodes.play_pressed()
    elif EDIT_MODE() == editorstate.ONE_ROLL_TRIM:
        trimmodes.oneroll_play_pressed()
    elif EDIT_MODE() == editorstate.ONE_ROLL_TRIM_NO_EDIT:
        movemodes.play_pressed()
    elif EDIT_MODE() == editorstate.TWO_ROLL_TRIM:
        trimmodes.tworoll_play_pressed()
    elif EDIT_MODE() == editorstate.TWO_ROLL_TRIM_NO_EDIT:
        movemodes.play_pressed()
    elif EDIT_MODE() == editorstate.SLIDE_TRIM:
        trimmodes.slide_play_pressed()
    elif EDIT_MODE() == editorstate.SLIDE_TRIM_NO_EDIT:
        movemodes.play_pressed()
    elif EDIT_MODE() == editorstate.KF_TOOL:
        movemodes.play_pressed()
    elif EDIT_MODE() == editorstate.MULTI_TRIM:
        movemodes.play_pressed()
    elif EDIT_MODE() == editorstate.CUT:
        movemodes.play_pressed()
Exemplo n.º 2
0
def play_pressed():    
    if editorstate.current_is_active_trim_mode() and trimmodes.submode != trimmodes.NOTHING_ON:
        return

    if current_is_move_mode():
        movemodes.play_pressed()
    elif EDIT_MODE() == editorstate.ONE_ROLL_TRIM:
        trimmodes.oneroll_play_pressed()
    elif EDIT_MODE() == editorstate.ONE_ROLL_TRIM_NO_EDIT:
        movemodes.play_pressed()
    elif EDIT_MODE() == editorstate.TWO_ROLL_TRIM:
        trimmodes.tworoll_play_pressed()
    elif EDIT_MODE() == editorstate.TWO_ROLL_TRIM_NO_EDIT:
        movemodes.play_pressed()
    elif EDIT_MODE() == editorstate.SLIDE_TRIM:
        trimmodes.slide_play_pressed()
    elif EDIT_MODE() == editorstate.SLIDE_TRIM_NO_EDIT:
        movemodes.play_pressed()
    elif EDIT_MODE() == editorstate.KF_TOOL:
        movemodes.play_pressed()
    elif EDIT_MODE() == editorstate.MULTI_TRIM:
        movemodes.play_pressed()
    elif EDIT_MODE() == editorstate.CUT:
        movemodes.play_pressed()
Exemplo n.º 3
0
def _handle_tline_key_event(event):
    """
    This is called when timeline widgets have focus and key is pressed.
    Returns True for handled key presses to stop those
    keyevents from going forward.
    """

    tool_was_selected = workflow.tline_tool_keyboard_selected(event)
    if tool_was_selected == True:
        return True
    
    action = _get_shortcut_action(event)
    prefs = editorpersistance.prefs

    if action == 'mark_in':
        monitorevent.mark_in_pressed()
        return True
    if action == 'to_mark_in':
        monitorevent.to_mark_in_pressed()
        return True
    if action == 'zoom_out':
        updater.zoom_out()
    if action == 'zoom_in':
        updater.zoom_in()
    if action == 'mark_out':
        monitorevent.mark_out_pressed()
        return True
    if action == 'to_mark_out':
        monitorevent.to_mark_out_pressed()
        return True
    if action == 'play_pause':
        if PLAYER().is_playing():
            monitorevent.stop_pressed()
        else:
            monitorevent.play_pressed()
        return True
    if action == 'switch_monitor':
        updater.switch_monitor_display()
        return True
    if action == 'add_marker':
        tlineaction.add_marker()
        return True    
    if action == 'cut':
        tlineaction.cut_pressed()
        return True
    if action == 'sequence_split':
        tlineaction.sequence_split_pressed()
        return True
    if action == 'log_range':
        medialog.log_range_clicked()
        return True
    """
    THis may need rethinking
    if action == 'toggle_ripple':
        gui.editor_window.toggle_trim_ripple_mode()
        return True
    """
    
    # Key bindings for keyboard trimming
    if editorstate.current_is_active_trim_mode() == True:
        if action == 'prev_frame':
            trimmodes.left_arrow_pressed((event.get_state() & Gdk.ModifierType.CONTROL_MASK))
            return True
        elif action == 'next_frame':
            trimmodes.right_arrow_pressed((event.get_state() & Gdk.ModifierType.CONTROL_MASK))
            return True
        elif action == 'enter_edit':
            trimmodes.enter_pressed()
            return True

    # Key bindings for MOVE MODES and _NO_EDIT modes
    if editorstate.current_is_move_mode() or editorstate.current_is_active_trim_mode() == False:
        if action == 'next_cut':
            if editorstate.timeline_visible():
                tline_frame = PLAYER().tracktor_producer.frame()
                frame = current_sequence().find_next_cut_frame(tline_frame)
                if frame != -1:
                    PLAYER().seek_frame(frame)
                    if editorpersistance.prefs.center_on_arrow_move == True:
                        updater.center_tline_to_current_frame()
                    return True
            else:
                monitorevent.up_arrow_seek_on_monitor_clip()
        if action == 'prev_cut':
            if editorstate.timeline_visible():
                tline_frame = PLAYER().tracktor_producer.frame()
                frame = current_sequence().find_prev_cut_frame(tline_frame)
                if frame != -1:
                    PLAYER().seek_frame(frame)
                    if editorpersistance.prefs.center_on_arrow_move == True:
                        updater.center_tline_to_current_frame()
                    return True
            else:
                 monitorevent.down_arrow_seek_on_monitor_clip()
                 return True
        # Apr-2017 - SvdB - Add different speeds for different modifiers
        # Allow user to select what speed belongs to what modifier, knowing that a combo of mods
        # will MULTIPLY all speeds
        # Available: SHIFT_MASK LOCK_MASK CONTROL_MASK
        if action == 'prev_frame' or action == 'next_frame':
            if action == 'prev_frame':
                seek_amount = -1
            else:
                seek_amount = 1
                
            if (event.get_state() & Gdk.ModifierType.SHIFT_MASK):
                seek_amount = seek_amount * prefs.ffwd_rev_shift
            if (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                seek_amount = seek_amount * prefs.ffwd_rev_ctrl
            if (event.get_state() & Gdk.ModifierType.LOCK_MASK):
                seek_amount = seek_amount * prefs.ffwd_rev_caps
            PLAYER().seek_delta(seek_amount)
            return True
        if action == '3_point_overwrite':
            tlineaction.three_point_overwrite_pressed()
            return True
        if action == 'insert':
            if not (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                tlineaction.insert_button_pressed()
                return True
        if action == 'append':
            tlineaction.append_button_pressed()
            return True
        if action == 'slower':
            monitorevent.j_pressed()
            return True
        if action == 'stop':
            monitorevent.k_pressed()
            return True
        if action == 'faster':
            monitorevent.l_pressed()
            return True
        if action == 'log_range':
            medialog.log_range_clicked()
            return True
        if action == 'resync':
            tlineaction.resync_button_pressed()
            return True
        if action == 'delete':
            # Clip selection and compositor selection are mutually exclusive, 
            # so max one one these will actually delete something
            tlineaction.splice_out_button_pressed()
            compositormodes.delete_current_selection()
        if action == 'to_start':
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            PLAYER().seek_frame(0)
            _move_to_beginning()
            return True
        if action == 'to_end':
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            PLAYER().seek_end()
            _move_to_end()
            return True
    else:
        if action == 'to_start':
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            gui.editor_window.set_default_edit_tool()
            PLAYER().seek_frame(0)
            _move_to_beginning()
            return True
        if action == 'to_end':
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            gui.editor_window.set_default_edit_tool()
            PLAYER().seek_end()
            _move_to_end()
            return True

    return False
Exemplo n.º 4
0
def tline_canvas_mouse_pressed(event, frame):
    """
    Mouse event callback from timeline canvas widget
    """
    editorstate.timeline_mouse_disabled = False # This is used to disable "move and "release" events when they would get bad data.
    
    if PLAYER().looping():
        return
    elif PLAYER().is_playing():
        PLAYER().stop_playback()
    
    # Double click handled separately
    if event.type == Gdk.EventType._2BUTTON_PRESS:
        return

    # Handle and exit parent clip selecting
    if EDIT_MODE() == editorstate.SELECT_PARENT_CLIP:
        syncsplitevent.select_sync_parent_mouse_pressed(event, frame)
        editorstate.timeline_mouse_disabled = True
        # Set INSERT_MODE
        modesetting.set_default_edit_mode()  
        return

    # Handle and exit tline sync clip selecting
    if EDIT_MODE() == editorstate.SELECT_TLINE_SYNC_CLIP:
        audiosync.select_sync_clip_mouse_pressed(event, frame)
        editorstate.timeline_mouse_disabled = True
        # Set INSERT_MODE
        modesetting.set_default_edit_mode()
        return
        
    # Hitting timeline in clip display mode displays timeline in
    # default mode.
    if not timeline_visible():
        updater.display_sequence_in_monitor()
        if (event.button == 1):
            # Now that we have correct edit mode we'll reenter
            # this method to get e.g. a select action
            tline_canvas_mouse_pressed(event, frame)
            return
        if (event.button == 3):
            # Right mouse + CTRL displays clip menu if we hit clip
            if (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                PLAYER().seek_frame(frame)
            # Right mouse on timeline seeks frame
            else:
                success = display_clip_menu_pop_up(event.y, event, frame)
                if not success:
                    PLAYER().seek_frame(frame)
        return

    # If clip end drag mode is for some reason still active, exit to default edit mode
    if EDIT_MODE() == editorstate.CLIP_END_DRAG:
        modesetting.set_default_edit_mode()
        # This shouldn't happen unless for some reason mouse release didn't hit clipenddragmode listener.
        print("EDIT_MODE() == editorstate.CLIP_END_DRAG at mouse press!")

    #  Check if match frame close is hit
    if editorstate.current_is_move_mode() and timeline_visible():
        if tlinewidgets.match_frame_close_hit(event.x, event.y) == True:
            tlinewidgets.set_match_frame(-1, -1, True)
            updater.repaint_tline()
            return

    #  Check if compositor is hit and if so, handle compositor editing
    if editorstate.current_is_move_mode() and timeline_visible():
        hit_compositor = tlinewidgets.compositor_hit(frame, event.x, event.y, current_sequence().compositors)
        if hit_compositor != None:
            if editorstate.get_compositing_mode() == appconsts.COMPOSITING_MODE_STANDARD_AUTO_FOLLOW:
                compositeeditor.set_compositor(hit_compositor)
                compositormodes.set_compositor_selected(hit_compositor)
                movemodes.clear_selected_clips()
                editorstate.timeline_mouse_disabled = True
                return
            elif editorstate.auto_follow_active() == False or hit_compositor.obey_autofollow == False:
                movemodes.clear_selected_clips()
                if event.button == 1 or (event.button == 3 and event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                    compositormodes.set_compositor_mode(hit_compositor)
                    mode_funcs = EDIT_MODE_FUNCS[editorstate.COMPOSITOR_EDIT]
                    press_func = mode_funcs[TL_MOUSE_PRESS]
                    press_func(event, frame)
                    return
            if event.button == 3:
                compositormodes.set_compositor_selected(hit_compositor)
                guicomponents.display_compositor_popup_menu(event, hit_compositor,
                                                            compositor_menu_item_activated)
                return
            elif event.button == 2:
                updater.zoom_project_length()
                return

    compositormodes.clear_compositor_selection()

    # Check if we should enter clip end drag mode
    if (event.button == 3 and editorstate.current_is_move_mode()
        and timeline_visible() and (event.get_state() & Gdk.ModifierType.CONTROL_MASK)):
        # with CTRL right mouse
        clipenddragmode.maybe_init_for_mouse_press(event, frame)
    elif (timeline_visible() and (EDIT_MODE() == editorstate.INSERT_MOVE or EDIT_MODE() == editorstate.OVERWRITE_MOVE)
        and (tlinewidgets.pointer_context == appconsts.POINTER_CONTEXT_END_DRAG_LEFT or tlinewidgets.pointer_context == appconsts.POINTER_CONTEXT_END_DRAG_RIGHT)):
        # with pointer context
        clipenddragmode.maybe_init_for_mouse_press(event, frame)

    # Handle mouse button presses depending which button was pressed and
    # editor state.
    # RIGHT BUTTON: seek frame or display clip menu if not dragging clip end
    if (event.button == 3 and EDIT_MODE() != editorstate.CLIP_END_DRAG and EDIT_MODE() != editorstate.KF_TOOL):
        if ((not editorstate.current_is_active_trim_mode()) and timeline_visible()):
            if not(event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                success = display_clip_menu_pop_up(event.y, event, frame)
                if not success:
                    PLAYER().seek_frame(frame)
        else:
            # For trim modes set <X>_NO_EDIT edit mode and seek frame. and seek frame
            trimmodes.set_no_edit_trim_mode()
            PLAYER().seek_frame(frame)
        return
    # LEFT BUTTON: Select new trimmed clip in active one roll trim mode	with sensitive cursor.
    elif (event.button == 1 and EDIT_MODE() == editorstate.ONE_ROLL_TRIM):	
        track = tlinewidgets.get_track(event.y)	
        if track == None:	
            modesetting.set_default_edit_mode(True)	
            return	
        success = trimmodes.set_oneroll_mode(track, frame)	
        if not success:
            modesetting.set_default_edit_mode(True)	
            return	
            	
        if trimmodes.edit_data["to_side_being_edited"] == True:	
            pointer_context = appconsts.POINTER_CONTEXT_TRIM_LEFT	
        else:	
            pointer_context = appconsts.POINTER_CONTEXT_TRIM_RIGHT	
        gui.editor_window.set_tline_cursor_to_context(pointer_context)	
        gui.editor_window.set_tool_selector_to_mode()	
        if not editorpersistance.prefs.quick_enter_trims:	
            editorstate.timeline_mouse_disabled = True	
        else:	
            trimmodes.oneroll_trim_move(event.x, event.y, frame, None)
    elif event.button == 2:
        updater.zoom_project_length()
    # LEFT BUTTON: Handle left mouse button edits by passing event to current edit mode
    # handler func
    elif event.button == 1 or event.button == 3:
        mode_funcs = EDIT_MODE_FUNCS[EDIT_MODE()]
        press_func = mode_funcs[TL_MOUSE_PRESS]
        press_func(event, frame)
Exemplo n.º 5
0
def _handle_tline_key_event(event):
    """
    This is called when timeline widgets have focus and key is pressed.
    Returns True for handled key presses to stop those
    keyevents from going forward.
    """
    # I
    if event.keyval == Gdk.KEY_i:
        if (event.get_state() & Gdk.ModifierType.MOD1_MASK):
            monitorevent.to_mark_in_pressed()
            return True
        monitorevent.mark_in_pressed()
        return True
    if event.keyval == Gdk.KEY_I:
        if (event.get_state() & Gdk.ModifierType.MOD1_MASK):
            monitorevent.to_mark_in_pressed()
            return True
        monitorevent.to_mark_in_pressed()
        return True

    # O
    if event.keyval == Gdk.KEY_o:
        if (event.get_state() & Gdk.ModifierType.MOD1_MASK):
            monitorevent.to_mark_out_pressed()
            return True
        monitorevent.mark_out_pressed()
        return True
    if event.keyval == Gdk.KEY_O:
        if (event.get_state() & Gdk.ModifierType.MOD1_MASK):
            monitorevent.to_mark_out_pressed()
            return True
        monitorevent.to_mark_out_pressed()
        return True

    # SPACE
    if event.keyval == Gdk.KEY_space:
        if PLAYER().is_playing():
            monitorevent.stop_pressed()
        else:
            monitorevent.play_pressed()
        return True

    # TAB
    if event.keyval == Gdk.KEY_Tab:
        updater.switch_monitor_display()
        return True

    # M
    if event.keyval == Gdk.KEY_m:
        tlineaction.add_marker()
        return True

    # Number edit mode changes
    if event.keyval == Gdk.KEY_1:
        gui.editor_window.handle_insert_move_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == Gdk.KEY_2:
        gui.editor_window.handle_over_move_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == Gdk.KEY_3:
        if editorstate.edit_mode != editorstate.ONE_ROLL_TRIM and editorstate.edit_mode != editorstate.ONE_ROLL_TRIM_NO_EDIT:
            gui.editor_window.handle_one_roll_mode_button_press()
            gui.editor_window.set_mode_selector_to_mode()
        else:
            gui.editor_window.toggle_trim_ripple_mode()
        return True
    if event.keyval == Gdk.KEY_4:
        gui.editor_window.handle_two_roll_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == Gdk.KEY_5:
        gui.editor_window.handle_slide_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == Gdk.KEY_6:
        gui.editor_window.handle_multi_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == Gdk.KEY_7:
        gui.editor_window.handle_box_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True

    # X
    if event.keyval == Gdk.KEY_x:
        tlineaction.cut_pressed()
        return True

    # G
    if event.keyval == Gdk.KEY_g:
        medialog.log_range_clicked()
        return True

    # R
    if event.keyval == Gdk.KEY_r:
        gui.editor_window.toggle_trim_ripple_mode()
        return True

    # Key bindings for keyboard trimming
    if editorstate.current_is_active_trim_mode() == True:
        # LEFT ARROW, prev frame
        if event.keyval == Gdk.KEY_Left:
            trimmodes.left_arrow_pressed(
                (event.get_state() & Gdk.ModifierType.CONTROL_MASK))
            return True

        # RIGHT ARROW, next frame
        if event.keyval == Gdk.KEY_Right:
            trimmodes.right_arrow_pressed(
                (event.get_state() & Gdk.ModifierType.CONTROL_MASK))
            return True

        if event.keyval == Gdk.KEY_Return:
            trimmodes.enter_pressed()
            return True

    # Key bindings for MOVE MODES and _NO_EDIT modes
    if editorstate.current_is_move_mode(
    ) or editorstate.current_is_active_trim_mode() == False:
        # UP ARROW, next cut
        if event.keyval == Gdk.KEY_Up:
            if editorstate.timeline_visible():
                tline_frame = PLAYER().tracktor_producer.frame()
                frame = current_sequence().find_next_cut_frame(tline_frame)
                if frame != -1:
                    PLAYER().seek_frame(frame)
                    if editorpersistance.prefs.center_on_arrow_move == True:
                        updater.center_tline_to_current_frame()
                    return True
            else:
                monitorevent.up_arrow_seek_on_monitor_clip()

        # DOWN ARROW, prev cut
        if event.keyval == Gdk.KEY_Down:
            if editorstate.timeline_visible():
                tline_frame = PLAYER().tracktor_producer.frame()
                frame = current_sequence().find_prev_cut_frame(tline_frame)
                if frame != -1:
                    PLAYER().seek_frame(frame)
                    if editorpersistance.prefs.center_on_arrow_move == True:
                        updater.center_tline_to_current_frame()
                    return True
            else:
                monitorevent.down_arrow_seek_on_monitor_clip()
                return True

        # LEFT ARROW, prev frame
        if event.keyval == Gdk.KEY_Left:
            if (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                PLAYER().seek_delta(-10)
            else:
                PLAYER().seek_delta(-1)
            return True

        # RIGHT ARROW, next frame
        if event.keyval == Gdk.KEY_Right:
            if (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                PLAYER().seek_delta(10)
            else:
                PLAYER().seek_delta(1)
            return True

        # T
        if event.keyval == Gdk.KEY_t:
            tlineaction.three_point_overwrite_pressed()
            return True

        # Y
        if event.keyval == Gdk.KEY_y:
            if not (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                tlineaction.insert_button_pressed()
                return True

        # U
        if event.keyval == Gdk.KEY_u:
            tlineaction.append_button_pressed()
            return True

        # J
        if event.keyval == Gdk.KEY_j:
            monitorevent.j_pressed()
            return True

        # K
        if event.keyval == Gdk.KEY_k:
            monitorevent.k_pressed()
            return True

        # L
        if event.keyval == Gdk.KEY_l:
            if (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                medialog.log_range_clicked()
            else:
                monitorevent.l_pressed()
            return True

        # S
        if event.keyval == Gdk.KEY_s:
            tlineaction.resync_button_pressed()
            return True

        # DELETE
        if event.keyval == Gdk.KEY_Delete:
            # Clip selection and compositor selection are mutually exclusive,
            # so max one one these will actually delete something
            tlineaction.splice_out_button_pressed()
            compositormodes.delete_current_selection()

        # HOME
        if event.keyval == Gdk.KEY_Home:
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            PLAYER().seek_frame(0)
            _move_to_beginning()
            return True

        # END
        if event.keyval == Gdk.KEY_End:
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            PLAYER().seek_end()
            _move_to_end()
            return True
    else:
        # HOME
        if event.keyval == Gdk.KEY_Home:
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            gui.editor_window.handle_insert_move_mode_button_press()
            gui.editor_window.set_mode_selector_to_mode()
            PLAYER().seek_frame(0)
            _move_to_beginning()
            return True

        # END
        if event.keyval == Gdk.KEY_End:
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            gui.editor_window.handle_insert_move_mode_button_press()
            gui.editor_window.set_mode_selector_to_mode()
            PLAYER().seek_end()
            _move_to_end()
            return True

    return False
Exemplo n.º 6
0
def tline_canvas_mouse_pressed(event, frame):
    """
    Mouse event callback from timeline canvas widget
    """
    global mouse_disabled

    if PLAYER().looping():
        return
    elif PLAYER().is_playing():
        PLAYER().stop_playback()

    # Double click handled separately
    if event.type == Gdk.EventType._2BUTTON_PRESS:
        return

    # Handle and exit parent clip selecting
    if EDIT_MODE() == editorstate.SELECT_PARENT_CLIP:
        syncsplitevent.select_sync_parent_mouse_pressed(event, frame)
        mouse_disabled = True
        # Set INSERT_MODE
        set_default_edit_mode()
        return

    # Handle and exit tline sync clip selecting
    if EDIT_MODE() == editorstate.SELECT_TLINE_SYNC_CLIP:
        audiosync.select_sync_clip_mouse_pressed(event, frame)
        mouse_disabled = True
        # Set INSERT_MODE
        set_default_edit_mode()
        return

    # Hitting timeline in clip display mode displays timeline in
    # default mode.
    if not timeline_visible():
        updater.display_sequence_in_monitor()
        if (event.button == 1):
            # Now that we have correct edit mode we'll reenter
            # this method to get e.g. a select action
            tline_canvas_mouse_pressed(event, frame)
            return
        if (event.button == 3):
            mouse_disabled == True
            # Right mouse + CTRL displays clip menu if we hit clip
            if (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                PLAYER().seek_frame(frame)
            # Right mouse on timeline seeks frame
            else:
                success = display_clip_menu_pop_up(event.y, event, frame)
                if not success:
                    PLAYER().seek_frame(frame)
        return

    # If clip end drag mode is for some reason still active, exit to default edit mode
    if EDIT_MODE() == editorstate.CLIP_END_DRAG:
        editorstate.edit_mode = editorstate.INSERT_MOVE
        # This shouldn't happen unless for some reason mouse release didn't hit clipenddragmode listener.
        print "EDIT_MODE() == editorstate.CLIP_END_DRAG at mouse press!"

    #  Check if match frame close is hit
    if editorstate.current_is_move_mode() and timeline_visible():
        if tlinewidgets.match_frame_close_hit(event.x, event.y) == True:
            tlinewidgets.set_match_frame(-1, -1, True)
            updater.repaint_tline()
            return

    #  Check if compositor is hit and if so handle compositor editing
    if editorstate.current_is_move_mode() and timeline_visible():
        hit_compositor = tlinewidgets.compositor_hit(
            frame, event.y,
            current_sequence().compositors)
        if hit_compositor != None:
            movemodes.clear_selected_clips()
            if event.button == 1 or (event.button == 3 and event.get_state()
                                     & Gdk.ModifierType.CONTROL_MASK):
                compositormodes.set_compositor_mode(hit_compositor)
                mode_funcs = EDIT_MODE_FUNCS[editorstate.COMPOSITOR_EDIT]
                press_func = mode_funcs[TL_MOUSE_PRESS]
                press_func(event, frame)
            elif event.button == 3:
                mouse_disabled == True
                compositormodes.set_compositor_selected(hit_compositor)
                guicomponents.display_compositor_popup_menu(
                    event, hit_compositor, compositor_menu_item_activated)
            elif event.button == 2:
                updater.zoom_project_length()
            return

    compositormodes.clear_compositor_selection()

    # Check if we should enter clip end drag mode.
    if (event.button == 3 and editorstate.current_is_move_mode()
            and timeline_visible()
            and (event.get_state() & Gdk.ModifierType.CONTROL_MASK)):
        clipenddragmode.maybe_init_for_mouse_press(event, frame)

    # Handle mouse button presses depending which button was pressed and
    # editor state.
    # RIGHT BUTTON: seek frame or display clip menu if not dragging clip end
    if (event.button == 3 and EDIT_MODE() != editorstate.CLIP_END_DRAG):
        if ((not editorstate.current_is_active_trim_mode())
                and timeline_visible()):
            if not (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                success = display_clip_menu_pop_up(event.y, event, frame)
                if not success:
                    PLAYER().seek_frame(frame)
            #else:
            #    PLAYER().seek_frame(frame)
        else:
            # For trim modes set <X>_NO_EDIT edit mode and seek frame. and seek frame
            trimmodes.set_no_edit_trim_mode()
            PLAYER().seek_frame(frame)
        return
    # LEFT BUTTON + CTRL: Select new trimmed clip in one roll trim mode
    elif (event.button == 1
          and (event.get_state() & Gdk.ModifierType.CONTROL_MASK)
          and EDIT_MODE() == editorstate.ONE_ROLL_TRIM):
        track = tlinewidgets.get_track(event.y)
        if track == None:
            if editorpersistance.prefs.empty_click_exits_trims == True:
                set_default_edit_mode(True)
            return
        success = trimmodes.set_oneroll_mode(track, frame)
        if (not success
            ) and editorpersistance.prefs.empty_click_exits_trims == True:
            set_default_edit_mode(True)
            return
        gui.editor_window.set_cursor_to_mode()
        gui.editor_window.set_mode_selector_to_mode()
        if not editorpersistance.prefs.quick_enter_trims:
            mouse_disabled = True
        else:
            trimmodes.oneroll_trim_move(event.x, event.y, frame, None)
    # LEFT BUTTON + CTRL: Select new trimmed clip in two roll trim mode
    elif (event.button == 1
          and (event.get_state() & Gdk.ModifierType.CONTROL_MASK)
          and EDIT_MODE() == editorstate.TWO_ROLL_TRIM):
        track = tlinewidgets.get_track(event.y)
        if track == None:
            if editorpersistance.prefs.empty_click_exits_trims == True:
                set_default_edit_mode(True)
            return
        success = trimmodes.set_tworoll_mode(track, frame)
        if (not success
            ) and editorpersistance.prefs.empty_click_exits_trims == True:
            set_default_edit_mode(True)
            return
        if not editorpersistance.prefs.quick_enter_trims:
            mouse_disabled = True
        else:
            trimmodes.tworoll_trim_move(event.x, event.y, frame, None)
    elif event.button == 2:
        updater.zoom_project_length()
    # LEFT BUTTON: Handle left mouse button edits by passing event to current edit mode
    # handler func
    elif event.button == 1 or event.button == 3:
        mode_funcs = EDIT_MODE_FUNCS[EDIT_MODE()]
        press_func = mode_funcs[TL_MOUSE_PRESS]
        press_func(event, frame)
Exemplo n.º 7
0
def _handle_tline_key_event(event):
    """
    This is called when timeline widgets have focus and key is pressed.
    Returns True for handled key presses to stop those
    keyevents from going forward.
    """
    # I
    if event.keyval == Gdk.KEY_i:
        if (event.get_state() & Gdk.ModifierType.MOD1_MASK):
            monitorevent.to_mark_in_pressed()
            return True
        monitorevent.mark_in_pressed()
        return True
    if event.keyval == Gdk.KEY_I:
        if (event.get_state() & Gdk.ModifierType.MOD1_MASK):
            monitorevent.to_mark_in_pressed()
            return True
        monitorevent.to_mark_in_pressed()
        return True

    # O
    if event.keyval == Gdk.KEY_o:
        if (event.get_state() & Gdk.ModifierType.MOD1_MASK):
            monitorevent.to_mark_out_pressed()
            return True
        monitorevent.mark_out_pressed()
        return True
    if event.keyval == Gdk.KEY_O:
        if (event.get_state() & Gdk.ModifierType.MOD1_MASK):
            monitorevent.to_mark_out_pressed()
            return True
        monitorevent.to_mark_out_pressed()
        return True

    # SPACE
    if event.keyval == Gdk.KEY_space:
        if PLAYER().is_playing():
            monitorevent.stop_pressed()
        else:
            monitorevent.play_pressed()
        return True
    
    # TAB
    if event.keyval == Gdk.KEY_Tab:
        updater.switch_monitor_display()
        return True

    # M
    if event.keyval == Gdk.KEY_m:
        tlineaction.add_marker()
        return True

    # Number edit mode changes
    if event.keyval == Gdk.KEY_1:
        gui.editor_window.handle_insert_move_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == Gdk.KEY_2:
        gui.editor_window.handle_over_move_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == Gdk.KEY_3:
        gui.editor_window.handle_one_roll_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == Gdk.KEY_4:
        gui.editor_window.handle_two_roll_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == Gdk.KEY_5:
        gui.editor_window.handle_slide_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == Gdk.KEY_6:
        gui.editor_window.handle_multi_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
        
    # X
    if event.keyval == Gdk.KEY_x:
        tlineaction.cut_pressed()
        return True

    # G
    if event.keyval == Gdk.KEY_g:
        medialog.log_range_clicked()
        return True

    # Key bindings for MOVE MODES and _NO_EDIT modes
    if editorstate.current_is_move_mode() or editorstate.current_is_active_trim_mode() == False:
         # UP ARROW, next cut
        if event.keyval == Gdk.KEY_Up:
            if editorstate.timeline_visible():
                tline_frame = PLAYER().tracktor_producer.frame()
                frame = current_sequence().find_next_cut_frame(tline_frame)
                if frame != -1:
                    PLAYER().seek_frame(frame)
                    return True
            else:
                monitorevent.up_arrow_seek_on_monitor_clip()
        
        # DOWN ARROW, prev cut
        if event.keyval == Gdk.KEY_Down:
            if editorstate.timeline_visible():
                tline_frame = PLAYER().tracktor_producer.frame()
                frame = current_sequence().find_prev_cut_frame(tline_frame)
                if frame != -1:
                    PLAYER().seek_frame(frame)
                    return True
            else:
                 monitorevent.down_arrow_seek_on_monitor_clip()
                 return True
            
        # LEFT ARROW, prev frame
        if event.keyval == Gdk.KEY_Left:
            if (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                PLAYER().seek_delta(-10)
            else:
                PLAYER().seek_delta(-1)
            return True

        # RIGHT ARROW, next frame
        if event.keyval == Gdk.KEY_Right:
            if (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                PLAYER().seek_delta(10)
            else:
                PLAYER().seek_delta(1)
            return True
            
        # T
        if event.keyval == Gdk.KEY_t:
            tlineaction.three_point_overwrite_pressed()
            return True

        # Y
        if event.keyval == Gdk.KEY_y:
            if not (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                tlineaction.insert_button_pressed()
                return True

        # U
        if event.keyval == Gdk.KEY_u:
            tlineaction.append_button_pressed()
            return True

        # J
        if event.keyval == Gdk.KEY_j:
            monitorevent.j_pressed()
            return True

        # K
        if event.keyval == Gdk.KEY_k:
            monitorevent.k_pressed()
            return True

        # L
        if event.keyval == Gdk.KEY_l:
            if (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                medialog.log_range_clicked()
            else:
                monitorevent.l_pressed()
            return True

        # CTRL+C
        if event.keyval == Gdk.KEY_c:
            if (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                tlineaction.do_timeline_objects_copy()
                return True

        # CTRL+V
        if event.keyval == Gdk.KEY_v:
            if (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                tlineaction.do_timeline_objects_paste()
                return True

        # DELETE
        if event.keyval == Gdk.KEY_Delete:
            # Clip selection and compositor selection are mutually exclusive, 
            # so max one one these will actually delete something
            tlineaction.splice_out_button_pressed()
            compositormodes.delete_current_selection()
        
        # HOME
        if event.keyval == Gdk.KEY_Home:
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            PLAYER().seek_frame(0)
            return True
    else:
        # HOME
        if event.keyval == Gdk.KEY_Home:
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            gui.editor_window.handle_insert_move_mode_button_press()
            gui.editor_window.set_mode_selector_to_mode()
            PLAYER().seek_frame(0)
            return True

    return False
Exemplo n.º 8
0
def tline_canvas_mouse_pressed(event, frame):
    """
    Mouse event callback from timeline canvas widget
    """
    global mouse_disabled

    if PLAYER().looping():
        return
    elif PLAYER().is_playing():
        PLAYER().stop_playback()
    
    # Double click handled separately
    if event.type == gtk.gdk._2BUTTON_PRESS:
        return

    # Handle and exit parent clip selecting
    if EDIT_MODE() == editorstate.SELECT_PARENT_CLIP:
        syncsplitevent.select_sync_parent_mouse_pressed(event, frame)
        mouse_disabled = True
        # Set INSERT_MODE
        set_default_edit_mode()  
        return

    # Hitting timeline in clip display mode displays timeline in
    # default mode.
    if not timeline_visible():
        updater.display_sequence_in_monitor()
        if (event.button == 1):
            # Now that we have correct edit mode we'll reenter
            # this method to get e.g. a select action
            tline_canvas_mouse_pressed(event, frame)
            return
        if (event.button == 3):
            mouse_disabled == True
            # Right mouse + CTRL displays clip menu if we hit clip
            if (event.state & gtk.gdk.CONTROL_MASK):
                PLAYER().seek_frame(frame)
            # Right mouse on timeline seeks frame
            else:
                success = display_clip_menu_pop_up(event.y, event, frame)
                if not success:
                    PLAYER().seek_frame(frame)
        return

    #  Check if compositor is hit and if so handle compositor editing
    if editorstate.current_is_move_mode() and timeline_visible():
        hit_compositor = tlinewidgets.compositor_hit(frame, event.y, current_sequence().compositors)
        if hit_compositor != None:
            movemodes.clear_selected_clips()
            if event.button == 1:
                compositormodes.set_compositor_mode(hit_compositor)
                mode_funcs = EDIT_MODE_FUNCS[editorstate.COMPOSITOR_EDIT]
                press_func = mode_funcs[TL_MOUSE_PRESS]
                press_func(event, frame)
            elif event.button == 3:
                mouse_disabled == True
                compositormodes.set_compositor_selected(hit_compositor)
                guicomponents.display_compositor_popup_menu(event, hit_compositor,
                                                            compositor_menu_item_activated)
            elif event.button == 2:
                updater.zoom_project_length()
            return

    compositormodes.clear_compositor_selection()

    # Handle mouse button presses depending which button was pressed and
    # editor state.
    # RIGHT BUTTON: seek frame or display clip menu
    if (event.button == 3):
        if ((not editorstate.current_is_active_trim_mode()) and timeline_visible()):
            if not(event.state & gtk.gdk.CONTROL_MASK):
                success = display_clip_menu_pop_up(event.y, event, frame)
                if not success:
                    PLAYER().seek_frame(frame)
            else:
                PLAYER().seek_frame(frame) 
        else:
            # For trim modes set <X>_NO_EDIT edit mode and seek frame. and seek frame
            trimmodes.set_no_edit_trim_mode()
            PLAYER().seek_frame(frame)
        return
    # LEFT BUTTON + CTRL: Select new trimmed clip in one roll trim mode
    elif (event.button == 1 
          and (event.state & gtk.gdk.CONTROL_MASK)
          and EDIT_MODE() == editorstate.ONE_ROLL_TRIM):
        track = tlinewidgets.get_track(event.y)
        if track == None:
            if editorpersistance.prefs.empty_click_exits_trims == True:
                set_default_edit_mode(True)
            return
        success = trimmodes.set_oneroll_mode(track, frame)
        if (not success) and editorpersistance.prefs.empty_click_exits_trims == True:
            set_default_edit_mode(True)
            return
        gui.editor_window.set_cursor_to_mode()
        gui.editor_window.set_mode_selector_to_mode()
        if not editorpersistance.prefs.quick_enter_trims:
            mouse_disabled = True
        else:
            trimmodes.oneroll_trim_move(event.x, event.y, frame, None)
    # LEFT BUTTON + CTRL: Select new trimmed clip in two roll trim mode
    elif (event.button == 1 
          and (event.state & gtk.gdk.CONTROL_MASK)
          and EDIT_MODE() == editorstate.TWO_ROLL_TRIM):
        track = tlinewidgets.get_track(event.y)
        if track == None:
            if editorpersistance.prefs.empty_click_exits_trims == True:
                set_default_edit_mode(True)
            return
        success = trimmodes.set_tworoll_mode(track, frame)
        if (not success) and  editorpersistance.prefs.empty_click_exits_trims == True:
            set_default_edit_mode(True)
            return
        if not editorpersistance.prefs.quick_enter_trims:
            mouse_disabled = True
        else:
            trimmodes.tworoll_trim_move(event.x, event.y, frame, None)
    # LEFT BUTTON: Handle left mouse button edits by passing event to current edit mode
    # handler func
    elif event.button == 1:
        mode_funcs = EDIT_MODE_FUNCS[EDIT_MODE()]
        press_func = mode_funcs[TL_MOUSE_PRESS]
        press_func(event, frame)
    elif event.button == 2:
        updater.zoom_project_length()
Exemplo n.º 9
0
def _handle_tline_key_event(event):
    """
    This is called when timeline widgets have focus and key is pressed.
    Returns True for handled key presses to stop those
    keyevents from going forward.
    """

    tool_was_selected = workflow.tline_tool_keyboard_selected(event)
    if tool_was_selected == True:
        return True
    
    action = _get_shortcut_action(event)
    prefs = editorpersistance.prefs

    if action == 'mark_in':
        monitorevent.mark_in_pressed()
        return True
    if action == 'to_mark_in':
        monitorevent.to_mark_in_pressed()
        return True
    if action == 'zoom_out':
        updater.zoom_out()
    if action == 'zoom_in':
        updater.zoom_in()
    if action == 'mark_out':
        monitorevent.mark_out_pressed()
        return True
    if action == 'to_mark_out':
        monitorevent.to_mark_out_pressed()
        return True
    if action == 'play_pause':
        if PLAYER().is_playing():
            monitorevent.stop_pressed()
        else:
            monitorevent.play_pressed()
        return True
    if action == 'switch_monitor':
        updater.switch_monitor_display()
        return True
    if action == 'add_marker':
        tlineaction.add_marker()
        return True    
    if action == 'cut':
        tlineaction.cut_pressed()
        return True
    if action == 'sequence_split':
        tlineaction.sequence_split_pressed()
        return True
    if action == 'log_range':
        medialog.log_range_clicked()
        return True
    """
    THis may need rethinking
    if action == 'toggle_ripple':
        gui.editor_window.toggle_trim_ripple_mode()
        return True
    """
    
    # Key bindings for keyboard trimming
    if editorstate.current_is_active_trim_mode() == True:
        if action == 'prev_frame':
            trimmodes.left_arrow_pressed((event.get_state() & Gdk.ModifierType.CONTROL_MASK))
            return True
        elif action == 'next_frame':
            trimmodes.right_arrow_pressed((event.get_state() & Gdk.ModifierType.CONTROL_MASK))
            return True
        elif action == 'enter_edit':
            trimmodes.enter_pressed()
            return True

    # Key bindings for MOVE MODES and _NO_EDIT modes
    if editorstate.current_is_move_mode() or editorstate.current_is_active_trim_mode() == False:
        if action == 'next_cut':
            if editorstate.timeline_visible():
                tline_frame = PLAYER().tracktor_producer.frame()
                frame = current_sequence().find_next_cut_frame(tline_frame)
                if frame != -1:
                    PLAYER().seek_frame(frame)
                    if editorpersistance.prefs.center_on_arrow_move == True:
                        updater.center_tline_to_current_frame()
                    return True
            else:
                monitorevent.up_arrow_seek_on_monitor_clip()
        if action == 'prev_cut':
            if editorstate.timeline_visible():
                tline_frame = PLAYER().tracktor_producer.frame()
                frame = current_sequence().find_prev_cut_frame(tline_frame)
                if frame != -1:
                    PLAYER().seek_frame(frame)
                    if editorpersistance.prefs.center_on_arrow_move == True:
                        updater.center_tline_to_current_frame()
                    return True
            else:
                 monitorevent.down_arrow_seek_on_monitor_clip()
                 return True
        # Apr-2017 - SvdB - Add different speeds for different modifiers
        # Allow user to select what speed belongs to what modifier, knowing that a combo of mods
        # will MULTIPLY all speeds
        # Available: SHIFT_MASK LOCK_MASK CONTROL_MASK
        if action == 'prev_frame' or action == 'next_frame':
            if action == 'prev_frame':
                seek_amount = -1
            else:
                seek_amount = 1
                
            if (event.get_state() & Gdk.ModifierType.SHIFT_MASK):
                seek_amount = seek_amount * prefs.ffwd_rev_shift
            if (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                seek_amount = seek_amount * prefs.ffwd_rev_ctrl
            if (event.get_state() & Gdk.ModifierType.LOCK_MASK):
                seek_amount = seek_amount * prefs.ffwd_rev_caps
            PLAYER().seek_delta(seek_amount)
            return True
        if action == '3_point_overwrite':
            tlineaction.three_point_overwrite_pressed()
            return True
        if action == 'insert':
            if not (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                tlineaction.insert_button_pressed()
                return True
        if action == 'append':
            tlineaction.append_button_pressed()
            return True
        if action == 'slower':
            monitorevent.j_pressed()
            return True
        if action == 'stop':
            monitorevent.k_pressed()
            return True
        if action == 'faster':
            monitorevent.l_pressed()
            return True
        if action == 'log_range':
            medialog.log_range_clicked()
            return True
        if action == 'resync':
            tlineaction.resync_button_pressed()
            return True
        if action == 'delete':
            # Clip selection and compositor selection are mutually exclusive, 
            # so max one one these will actually delete something
            tlineaction.splice_out_button_pressed()
            compositormodes.delete_current_selection()
        if action == 'to_start':
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            PLAYER().seek_frame(0)
            _move_to_beginning()
            return True
        if action == 'to_end':
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            PLAYER().seek_end()
            _move_to_end()
            return True
    else:
        if action == 'to_start':
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            gui.editor_window.set_default_edit_tool()
            PLAYER().seek_frame(0)
            _move_to_beginning()
            return True
        if action == 'to_end':
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            gui.editor_window.set_default_edit_tool()
            PLAYER().seek_end()
            _move_to_end()
            return True

    return False
Exemplo n.º 10
0
def tline_canvas_mouse_pressed(event, frame):
    """
    Mouse event callback from timeline canvas widget
    """
    editorstate.timeline_mouse_disabled = False # This is used to disable "move and "release" events when they would get bad data.
    
    if PLAYER().looping():
        return
    elif PLAYER().is_playing():
        PLAYER().stop_playback()
    
    # Double click handled separately
    if event.type == Gdk.EventType._2BUTTON_PRESS:
        return

    # Handle and exit parent clip selecting
    if EDIT_MODE() == editorstate.SELECT_PARENT_CLIP:
        syncsplitevent.select_sync_parent_mouse_pressed(event, frame)
        editorstate.timeline_mouse_disabled = True
        # Set INSERT_MODE
        modesetting.set_default_edit_mode()  
        return

    # Handle and exit tline sync clip selecting
    if EDIT_MODE() == editorstate.SELECT_TLINE_SYNC_CLIP:
        audiosync.select_sync_clip_mouse_pressed(event, frame)
        editorstate.timeline_mouse_disabled = True
        # Set INSERT_MODE
        modesetting.set_default_edit_mode()
        return
        
    # Hitting timeline in clip display mode displays timeline in
    # default mode.
    if not timeline_visible():
        updater.display_sequence_in_monitor()
        if (event.button == 1):
            # Now that we have correct edit mode we'll reenter
            # this method to get e.g. a select action
            tline_canvas_mouse_pressed(event, frame)
            return
        if (event.button == 3):
            # Right mouse + CTRL displays clip menu if we hit clip
            if (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                PLAYER().seek_frame(frame)
            # Right mouse on timeline seeks frame
            else:
                success = display_clip_menu_pop_up(event.y, event, frame)
                if not success:
                    PLAYER().seek_frame(frame)
        return

    # If clip end drag mode is for some reason still active, exit to default edit mode
    if EDIT_MODE() == editorstate.CLIP_END_DRAG:
        modesetting.set_default_edit_mode()
        # This shouldn't happen unless for some reason mouse release didn't hit clipenddragmode listener.
        print "EDIT_MODE() == editorstate.CLIP_END_DRAG at mouse press!"

    #  Check if match frame close is hit
    if editorstate.current_is_move_mode() and timeline_visible():
        if tlinewidgets.match_frame_close_hit(event.x, event.y) == True:
            tlinewidgets.set_match_frame(-1, -1, True)
            updater.repaint_tline()
            return

    #  Check if compositor is hit and if so, handle compositor editing
    if editorstate.current_is_move_mode() and timeline_visible():
        hit_compositor = tlinewidgets.compositor_hit(frame, event.y, current_sequence().compositors)
        if hit_compositor != None:         
            if editorstate.auto_follow == False or hit_compositor.obey_autofollow == False:
                movemodes.clear_selected_clips()
                if event.button == 1 or (event.button == 3 and event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                    compositormodes.set_compositor_mode(hit_compositor)
                    mode_funcs = EDIT_MODE_FUNCS[editorstate.COMPOSITOR_EDIT]
                    press_func = mode_funcs[TL_MOUSE_PRESS]
                    press_func(event, frame)
                    return
            if event.button == 3:
                compositormodes.set_compositor_selected(hit_compositor)
                guicomponents.display_compositor_popup_menu(event, hit_compositor,
                                                            compositor_menu_item_activated)
                return
            elif event.button == 2:
                updater.zoom_project_length()
                return

    compositormodes.clear_compositor_selection()

    # Check if we should enter clip end drag mode
    if (event.button == 3 and editorstate.current_is_move_mode()
        and timeline_visible() and (event.get_state() & Gdk.ModifierType.CONTROL_MASK)):
        # with CTRL right mouse
        clipenddragmode.maybe_init_for_mouse_press(event, frame)
    elif (timeline_visible() and (EDIT_MODE() == editorstate.INSERT_MOVE or EDIT_MODE() == editorstate.OVERWRITE_MOVE)
        and (tlinewidgets.pointer_context == appconsts.POINTER_CONTEXT_END_DRAG_LEFT or tlinewidgets.pointer_context == appconsts.POINTER_CONTEXT_END_DRAG_RIGHT)):
        # with pointer context
        clipenddragmode.maybe_init_for_mouse_press(event, frame)

    # Handle mouse button presses depending which button was pressed and
    # editor state.
    # RIGHT BUTTON: seek frame or display clip menu if not dragging clip end
    if (event.button == 3 and EDIT_MODE() != editorstate.CLIP_END_DRAG and EDIT_MODE() != editorstate.KF_TOOL):
        if ((not editorstate.current_is_active_trim_mode()) and timeline_visible()):
            if not(event.get_state() & Gdk.ModifierType.CONTROL_MASK):
                success = display_clip_menu_pop_up(event.y, event, frame)
                if not success:
                    PLAYER().seek_frame(frame)
        else:
            # For trim modes set <X>_NO_EDIT edit mode and seek frame. and seek frame
            trimmodes.set_no_edit_trim_mode()
            PLAYER().seek_frame(frame)
        return
    # LEFT BUTTON: Select new trimmed clip in active one roll trim mode	with sensitive cursor.
    elif (event.button == 1 and EDIT_MODE() == editorstate.ONE_ROLL_TRIM):	
        track = tlinewidgets.get_track(event.y)	
        if track == None:	
            modesetting.set_default_edit_mode(True)	
            return	
        success = trimmodes.set_oneroll_mode(track, frame)	
        if not success:
            modesetting.set_default_edit_mode(True)	
            return	
            	
        if trimmodes.edit_data["to_side_being_edited"] == True:	
            pointer_context = appconsts.POINTER_CONTEXT_TRIM_LEFT	
        else:	
            pointer_context = appconsts.POINTER_CONTEXT_TRIM_RIGHT	
        gui.editor_window.set_tline_cursor_to_context(pointer_context)	
        gui.editor_window.set_tool_selector_to_mode()	
        if not editorpersistance.prefs.quick_enter_trims:	
            editorstate.timeline_mouse_disabled = True	
        else:	
            trimmodes.oneroll_trim_move(event.x, event.y, frame, None)
    elif event.button == 2:
        updater.zoom_project_length()
    # LEFT BUTTON: Handle left mouse button edits by passing event to current edit mode
    # handler func
    elif event.button == 1 or event.button == 3:
        mode_funcs = EDIT_MODE_FUNCS[EDIT_MODE()]
        press_func = mode_funcs[TL_MOUSE_PRESS]
        press_func(event, frame)
Exemplo n.º 11
0
def _handle_tline_key_event(event):
    """
    This is called when timeline widgets have focus and key is pressed.
    Returns True for handled key presses to stop those
    keyevents from going forward.
    """
    # I
    if event.keyval == gtk.keysyms.i:
        if (event.state & gtk.gdk.MOD1_MASK):
            monitorevent.to_mark_in_pressed()
            return True
        monitorevent.mark_in_pressed()
        return True
    if event.keyval == gtk.keysyms.I:
        if (event.state & gtk.gdk.MOD1_MASK):
            monitorevent.to_mark_in_pressed()
            return True
        monitorevent.to_mark_in_pressed()
        return True

    # O
    if event.keyval == gtk.keysyms.o:
        if (event.state & gtk.gdk.MOD1_MASK):
            monitorevent.to_mark_out_pressed()
            return True
        monitorevent.mark_out_pressed()
        return True
    if event.keyval == gtk.keysyms.O:
        if (event.state & gtk.gdk.MOD1_MASK):
            monitorevent.to_mark_out_pressed()
            return True
        monitorevent.to_mark_out_pressed()
        return True

    # SPACE
    if event.keyval == gtk.keysyms.space:
        if PLAYER().is_playing():
            monitorevent.stop_pressed()
        else:
            monitorevent.play_pressed()
        return True

    # TAB
    if event.keyval == gtk.keysyms.Tab:
        updater.switch_monitor_display()
        return True

    # M
    if event.keyval == gtk.keysyms.m:
        tlineaction.add_marker()
        return True

    # Number edit mode changes
    if event.keyval == gtk.keysyms._1:
        gui.editor_window.handle_insert_move_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == gtk.keysyms._2:
        gui.editor_window.handle_over_move_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == gtk.keysyms._3:
        gui.editor_window.handle_one_roll_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == gtk.keysyms._4:
        gui.editor_window.handle_two_roll_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == gtk.keysyms._5:
        gui.editor_window.handle_slide_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True
    if event.keyval == gtk.keysyms._6:
        gui.editor_window.handle_multi_mode_button_press()
        gui.editor_window.set_mode_selector_to_mode()
        return True

    # X
    if event.keyval == gtk.keysyms.x:
        tlineaction.cut_pressed()
        return True

    # G
    if event.keyval == gtk.keysyms.g:
        medialog.log_range_clicked()
        return True

    # Key bindings for MOVE MODES and _NO_EDIT modes
    if editorstate.current_is_move_mode(
    ) or editorstate.current_is_active_trim_mode() == False:
        # UP ARROW, next cut
        if event.keyval == gtk.keysyms.Up:
            if editorstate.timeline_visible():
                tline_frame = PLAYER().tracktor_producer.frame()
                frame = current_sequence().find_next_cut_frame(tline_frame)
                if frame != -1:
                    PLAYER().seek_frame(frame)
                    return True
            else:
                monitorevent.up_arrow_seek_on_monitor_clip()

        # DOWN ARROW, prev cut
        if event.keyval == gtk.keysyms.Down:
            if editorstate.timeline_visible():
                tline_frame = PLAYER().tracktor_producer.frame()
                frame = current_sequence().find_prev_cut_frame(tline_frame)
                if frame != -1:
                    PLAYER().seek_frame(frame)
                    return True
            else:
                monitorevent.down_arrow_seek_on_monitor_clip()
                return True

        # LEFT ARROW, prev frame
        if event.keyval == gtk.keysyms.Left:
            PLAYER().seek_delta(-1)
            return True

        # RIGHT ARROW, next frame
        if event.keyval == gtk.keysyms.Right:
            PLAYER().seek_delta(1)
            return True

        # T
        if event.keyval == gtk.keysyms.t:
            tlineaction.three_point_overwrite_pressed()
            return True

        # Y
        if event.keyval == gtk.keysyms.y:
            if not (event.state & gtk.gdk.CONTROL_MASK):
                tlineaction.insert_button_pressed()
                return True

        # U
        if event.keyval == gtk.keysyms.u:
            tlineaction.append_button_pressed()
            return True

        # J
        if event.keyval == gtk.keysyms.j:
            monitorevent.j_pressed()
            return True

        # K
        if event.keyval == gtk.keysyms.k:
            monitorevent.k_pressed()
            return True

        # L
        if event.keyval == gtk.keysyms.l:
            if (event.state & gtk.gdk.CONTROL_MASK):
                medialog.log_range_clicked()
            else:
                monitorevent.l_pressed()
            return True

        # CTRL+C
        if event.keyval == gtk.keysyms.c:
            if (event.state & gtk.gdk.CONTROL_MASK):
                tlineaction.do_timeline_objects_copy()
                return True

        # CTRL+V
        if event.keyval == gtk.keysyms.v:
            if (event.state & gtk.gdk.CONTROL_MASK):
                tlineaction.do_timeline_objects_paste()
                return True

        # DELETE
        if event.keyval == gtk.keysyms.Delete:
            # Clip selection and compositor selection are mutually exclusive,
            # so max one one these will actually delete something
            tlineaction.splice_out_button_pressed()
            compositormodes.delete_current_selection()

        # HOME
        if event.keyval == gtk.keysyms.Home:
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            PLAYER().seek_frame(0)
            return True
    else:
        # HOME
        if event.keyval == gtk.keysyms.Home:
            if PLAYER().is_playing():
                monitorevent.stop_pressed()
            gui.editor_window.handle_insert_move_mode_button_press()
            gui.editor_window.set_mode_selector_to_mode()
            PLAYER().seek_frame(0)
            return True

    return False