Exemplo n.º 1
0
    def _get_selection_data(self,  p1, p2):
        x1, y1 = p1
        x2, y2 = p2
        
        if x1 > x2:
            x1, x2 = x2, x1
        if y1 > y2:
            y1, y2 = y2, y1
        
        start_frame = tlinewidgets.get_frame(x1)
        end_frame = tlinewidgets.get_frame(x2) 
        
        track_top_index = self.get_bounding_track_index(y1, tlinewidgets.get_track(y1))
        track_bottom_index = self.get_bounding_track_index(y2, tlinewidgets.get_track(y2))

        self.topleft_track = track_top_index - 1

        # Get compositors
        for i in range(track_bottom_index + 1, track_top_index):
            track_compositors = current_sequence().get_track_compositors(i)
            for comp in track_compositors:
                if comp.clip_in >= start_frame and comp.clip_out < end_frame:
                    self.selected_compositors.append(comp)
        
        # Get BoxTrackSelection objects
        for i in range(track_bottom_index + 1, track_top_index):
            self.track_selections.append(BoxTrackSelection(i, start_frame, end_frame))

        # Drop empty tracks from bottom up
        while len(self.track_selections) > 0:
            if self.track_selections[0].is_empty() == True:
                self.track_selections.pop(0)
            else:
                track_bottom_index = self.track_selections[0].track_id
                break
                
        # Drop empty tracks from top down
        while len(self.track_selections) > 0:
            if self.track_selections[-1].is_empty() == True:
                self.track_selections.pop(-1)
            else:
                self.topleft_track = self.track_selections[-1].track_id
                break

        self.height_tracks = self.topleft_track - track_bottom_index + 1# self.topleft_track is inclusive to height, track_bottom_index is eclusive to height
        
        # Get selection bounding box
        self.topleft_frame = 1000000000000
        for track_selection in self.track_selections:
            if track_selection.range_frame_in != -1:
                if track_selection.range_frame_in < self.topleft_frame:
                    self.topleft_frame = track_selection.range_frame_in
                
        last_frame = 0
        for track_selection in self.track_selections:
            if track_selection.range_frame_out != -1:
                if track_selection.range_frame_out > last_frame:
                    last_frame = track_selection.range_frame_out
        
        self.width_frames = last_frame - self.topleft_frame
Exemplo n.º 2
0
def _add_autofade(data):
    clip, track, item_id, item_data = data
    x, compositor_type = item_data

    frame = tlinewidgets.get_frame(x)
    clip_index = track.get_clip_index_at(frame)

    target_track_index = track.id - 1

    clip_length = clip.clip_out - clip.clip_in
    if compositor_type == "##auto_fade_in":
        compositor_in = current_sequence().tracks[track.id].clip_start(clip_index)
        compositor_out = compositor_in + int(utils.fps()) - 1
    else:
        clip_start = current_sequence().tracks[track.id].clip_start(clip_index)
        compositor_out = clip_start + clip_length
        compositor_in = compositor_out - int(utils.fps()) + 1

    edit_data = {"origin_clip_id":clip.id,
                "in_frame":compositor_in,
                "out_frame":compositor_out,
                "a_track":target_track_index,
                "b_track":track.id,
                "compositor_type":compositor_type,
                "clip":clip}
    action = edit.add_compositor_action(edit_data)
    action.do_edit()
    
    updater.repaint_tline()
Exemplo n.º 3
0
def tline_media_drop(media_file, x, y, use_marks=False):
    track = tlinewidgets.get_track(y)
    if track == None:
        return
    if track.id < 1 or track.id >= (len(current_sequence().tracks) - 1):
        return 
    if dialogutils.track_lock_check_and_user_info(track):
        #modesetting.set_default_edit_mode()
        # TODO: Info
        return
        
    modesetting.stop_looping()

    frame = tlinewidgets.get_frame(x)
    
    # Create new clip.
    if media_file.type != appconsts.PATTERN_PRODUCER:
        new_clip = current_sequence().create_file_producer_clip(media_file.path, media_file.name, False, media_file.ttl)
    else:
        new_clip = current_sequence().create_pattern_producer(media_file)

    # Set clip in and out
    if use_marks == False:
        new_clip.mark_in = 0
        new_clip.mark_out = new_clip.get_length() - 1 # - 1 because out is mark_out inclusive

        if media_file.type == appconsts.IMAGE_SEQUENCE:
            new_clip.mark_out = media_file.length
    else:
        new_clip.mark_in = media_file.mark_in
        new_clip.mark_out =  media_file.mark_out

        if new_clip.mark_in == -1:
            new_clip.mark_in = 0
        if new_clip.mark_out == -1:
            new_clip.mark_out = new_clip.get_length() - 1 # - 1 because out is mark_out inclusive
            if media_file.type == appconsts.IMAGE_SEQUENCE:
                new_clip.mark_out = media_file.length

    # Graphics files get added with their default lengths
    f_name, ext = os.path.splitext(media_file.name)
    if utils.file_extension_is_graphics_file(ext) and media_file.type != appconsts.IMAGE_SEQUENCE: # image sequences are graphics files but have own length
        in_fr, out_fr, l = editorpersistance.get_graphics_default_in_out_length()
        new_clip.mark_in = in_fr
        new_clip.mark_out = out_fr

    # Non-insert DND actions
    if editorpersistance.prefs.dnd_action == appconsts.DND_OVERWRITE_NON_V1:
        if track.id != current_sequence().first_video_track().id:
            drop_done = _attempt_dnd_overwrite(track, new_clip, frame)
            if drop_done == True:
                return
    elif editorpersistance.prefs.dnd_action == appconsts.DND_ALWAYS_OVERWRITE:
        drop_done = _attempt_dnd_overwrite(track, new_clip, frame)
        if drop_done == True:
            return
            
    do_clip_insert(track, new_clip, frame)
Exemplo n.º 4
0
    def is_hit(self, x, y):
        hit_frame = tlinewidgets.get_frame(x)
        hit_track = tlinewidgets.get_track(y).id

        if ((hit_frame >= self.topleft_frame and hit_frame < self.topleft_frame + self.width_frames) and
            (hit_track <= self.topleft_track and hit_track > self.topleft_track - self.height_tracks)):
                return True
                
        return False
Exemplo n.º 5
0
def enter_pressed():
    # With Enter key we enter keyboard trim on current pointer context
    x = editorstate.last_mouse_x
    y = editorstate.last_mouse_y
    frame = tlinewidgets.get_frame(x)
    
    _enter_trim_mode_edit(x, y, frame)
    trimmodes.submode = trimmodes.KEYB_EDIT_ON
    updater.repaint_tline()
Exemplo n.º 6
0
def _add_filter(data):
    clip, track, item_id, item_data = data
    x, filter_info = item_data
    action = clipeffectseditor.get_filter_add_action(filter_info, clip)
    action.do_edit()
    
    # (re)open clip in editor
    frame = tlinewidgets.get_frame(x)
    index = track.get_clip_index_at(frame)
    clipeffectseditor.set_clip(clip, track, index)
Exemplo n.º 7
0
def tline_range_item_drop(rows, x, y):
    track = tlinewidgets.get_track(y)
    if track == None:
        return
    if track.id < 1 or track.id >= (len(current_sequence().tracks) - 1):
        return 
    if track_lock_check_and_user_info(track):
        set_default_edit_mode()
        return
        
    frame = tlinewidgets.get_frame(x)
    clips = medialog.get_clips_for_rows(rows)
    set_default_edit_mode()
    do_multiple_clip_insert(track, clips, frame)
Exemplo n.º 8
0
def init_select_master_clip(popup_data):
    clip, track, item_id, x = popup_data
    frame = tlinewidgets.get_frame(x)
    child_index = current_sequence().get_clip_index(track, frame)

    if not (track.clips[child_index] == clip):
        # This should never happen 
        print "big fu at _init_select_master_clip(...)"
        return

    gdk_window = gui.tline_display.get_parent_window();
    gdk_window.set_cursor(gtk.gdk.Cursor(gtk.gdk.TCROSS))
    editorstate.edit_mode = editorstate.SELECT_PARENT_CLIP
    global parent_selection_data
    parent_selection_data = (clip, child_index, track)
Exemplo n.º 9
0
def tline_media_drop(media_file, x, y, use_marks=False):
    track = tlinewidgets.get_track(y)
    if track == None:
        return
    if track.id < 1 or track.id >= (len(current_sequence().tracks) - 1):
        return 
    if track_lock_check_and_user_info(track):
        set_default_edit_mode()
        return

    set_default_edit_mode()

    frame = tlinewidgets.get_frame(x)
    
    # Create new clip.
    if media_file.type != appconsts.PATTERN_PRODUCER:
        new_clip = current_sequence().create_file_producer_clip(media_file.path, media_file.name)
    else:
        new_clip = current_sequence().create_pattern_producer(media_file)

    # Set clip in and out
    if use_marks == False:
        new_clip.mark_in = 0
        new_clip.mark_out = new_clip.get_length() - 1 # - 1 because out is mark_out inclusive

        if media_file.type == appconsts.IMAGE_SEQUENCE:
            new_clip.mark_out = media_file.length
    else:
        new_clip.mark_in = media_file.mark_in
        new_clip.mark_out =  media_file.mark_out

        if new_clip.mark_in == -1:
            new_clip.mark_in = 0
        if new_clip.mark_out == -1:
            new_clip.mark_out = new_clip.get_length() - 1 # - 1 because out is mark_out inclusive
            if media_file.type == appconsts.IMAGE_SEQUENCE:
                new_clip.mark_out = media_file.length

    # Graphics files get added with their default lengths
    f_name, ext = os.path.splitext(media_file.name)
    if utils.file_extension_is_graphics_file(ext) and media_file.type != appconsts.IMAGE_SEQUENCE: # image sequences are graphics files but have own length
        in_fr, out_fr, l = editorpersistance.get_graphics_default_in_out_length()
        new_clip.mark_in = in_fr
        new_clip.mark_out = out_fr
            
    do_clip_insert(track, new_clip, frame)
Exemplo n.º 10
0
def slide_trim_mode_init(x, y):
    """
    User selects two roll mode
    """
    track = tlinewidgets.get_track(y)
    if track == None:
        return False

    stop_looping()
    editorstate.edit_mode = editorstate.SLIDE_TRIM

    movemodes.clear_selected_clips() # Entering trim edit mode clears selection 
    updater.set_trim_mode_gui()

    press_frame = tlinewidgets.get_frame(x)
    trimmodes.set_exit_mode_func = set_default_edit_mode
    trimmodes.set_no_edit_mode_func = slide_trim_no_edit_init
    success = trimmodes.set_slide_mode(track, press_frame)
    return success
Exemplo n.º 11
0
def init_select_tline_sync_clip(popup_data):

    clip, track, item_id, x = popup_data
    frame = tlinewidgets.get_frame(x)
    clip_index = current_sequence().get_clip_index(track, frame)

    if not (track.clips[clip_index] == clip):
        # This should never happen 
        print "big fu at init_select_tline_sync_clip(...)"
        return

    gdk_window = gui.tline_display.get_parent_window();
    gdk_window.set_cursor(Gdk.Cursor.new(Gdk.CursorType.TCROSS))
    editorstate.edit_mode = editorstate.SELECT_TLINE_SYNC_CLIP

    global _tline_sync_data
    _tline_sync_data = TLineSyncData()
    _tline_sync_data.origin_clip = clip
    _tline_sync_data.origin_track = track
    _tline_sync_data.origin_clip_index = clip_index
Exemplo n.º 12
0
def oneroll_trim_mode_init(x, y):
    """
    User enters ONE_ROLL_TRIM mode from ONE_ROLL_TRIM_NO_EDIT 
    """
    track = tlinewidgets.get_track(y)
    if track == None:
        return False

    stop_looping() 
    editorstate.edit_mode = editorstate.ONE_ROLL_TRIM

    movemodes.clear_selected_clips() # Entering trim edit mode clears selection 
    updater.set_trim_mode_gui()

    # init mode
    press_frame = tlinewidgets.get_frame(x)
    trimmodes.set_exit_mode_func = set_default_edit_mode
    trimmodes.set_no_edit_mode_func = oneroll_trim_no_edit_init
    success = trimmodes.set_oneroll_mode(track, press_frame)
    return success
Exemplo n.º 13
0
def _do_split_audio_edit(popup_data):
    # NOTE: THIS HARD CODES ALL SPLITS TO HAPPEN ON TRACK A1, THIS MAY CHANGE
    to_track = current_sequence().tracks[current_sequence().first_video_index - 1]

    clip, track, item_id, x = popup_data
    press_frame = tlinewidgets.get_frame(x)
    index = current_sequence().get_clip_index(track, press_frame)
    frame = track.clip_start(index)

    audio_clip = current_sequence().create_file_producer_clip(clip.path)
    audio_clip.media_type = appconsts.AUDIO
    split_length = clip.clip_out - clip.clip_in + 1 # +1 out is inclusive and we're looking for length
    data = { "parent_clip":clip,
             "audio_clip":audio_clip,
             "over_in":frame,
             "over_out":frame + split_length,
             "to_track":to_track}

    action = edit.audio_splice_action(data)
    action.do_edit()
    
    return (clip, audio_clip, to_track)
Exemplo n.º 14
0
def tworoll_trim_mode_init(x, y):
    """
    User selects two roll mode
    """
    track = tlinewidgets.get_track(y)
    if track == None:
        return False
    
    if track_lock_check_and_user_info(track, tworoll_trim_mode_init, "two roll trim mode",):
        set_default_edit_mode()
        return False

    stop_looping()
    editorstate.edit_mode = editorstate.TWO_ROLL_TRIM

    movemodes.clear_selected_clips() # Entering trim edit mode clears selection 
    updater.set_trim_mode_gui()

    press_frame = tlinewidgets.get_frame(x)
    trimmodes.set_exit_mode_func = set_default_edit_mode
    trimmodes.set_no_edit_mode_func = tworoll_trim_no_edit_init
    success = trimmodes.set_tworoll_mode(track, press_frame)
    return success
Exemplo n.º 15
0
def _add_compositor(data):
    clip, track, item_id, item_data = data
    x, compositor_type = item_data

    frame = tlinewidgets.get_frame(x)
    clip_index = track.get_clip_index_at(frame)

    target_track_index = track.id - 1

    compositor_in = current_sequence().tracks[track.id].clip_start(clip_index)
    clip_length = clip.clip_out - clip.clip_in
    compositor_out = compositor_in + clip_length

    edit_data = {"origin_clip_id":clip.id,
                "in_frame":compositor_in,
                "out_frame":compositor_out,
                "a_track":target_track_index,
                "b_track":track.id,
                "compositor_type":compositor_type}
    action = edit.add_compositor_action(edit_data)
    action.do_edit()
    
    updater.repaint_tline()
Exemplo n.º 16
0
def open_clip_in_effects_editor(data):
    clip, track, item_id, x = data
    frame = tlinewidgets.get_frame(x)
    index = current_sequence().get_clip_index(track, frame)

    clipeffectseditor.set_clip(clip, track, index)
Exemplo n.º 17
0
def tline_media_drop(media_file, x, y, use_marks=False):
    track = tlinewidgets.get_track(y)
    if track == None:
        return
    if track.id < 1 or track.id >= (len(current_sequence().tracks) - 1):
        return 
    if dialogutils.track_lock_check_and_user_info(track):
        #modesetting.set_default_edit_mode()
        # TODO: Info
        return

    modesetting.stop_looping()
    if EDIT_MODE() == editorstate.KF_TOOL:
        kftoolmode.exit_tool()

    frame = tlinewidgets.get_frame(x)
    
    # Create new clip.
    if media_file.type != appconsts.PATTERN_PRODUCER:
        new_clip = current_sequence().create_file_producer_clip(media_file.path, media_file.name, False, media_file.ttl)
    else:
        new_clip = current_sequence().create_pattern_producer(media_file)
            
    # Set clip in and out
    if use_marks == False:
        new_clip.mark_in = 0
        new_clip.mark_out = new_clip.get_length() - 1 # - 1 because out is mark_out inclusive

        if media_file.type == appconsts.IMAGE_SEQUENCE:
            new_clip.mark_out = media_file.length
    else:
        if new_clip.media_type == appconsts.IMAGE or new_clip.media_type == appconsts.PATTERN_PRODUCER:
            # Give IMAGE and PATTERN_PRODUCER media types default mark in and mark out if not already set.
            # This makes them reasonably short and trimmable in both directions.
            # NOTE: WE SHOULD BE DOING THIS AT CREATION TIME, WE'RE DOING THE SAME THING IN updater.display_clip_in_monitor() ?
            #       ...but then we would need to patch persistance.py...maybe keep this even if not too smart.
            # TODO: Make default length user settable or use graphics value
            if (hasattr(new_clip, 'mark_in') == False) or (new_clip.mark_in == -1 and new_clip.mark_out == -1):
                center_frame = new_clip.get_length() / 2
                default_length_half = 75
                mark_in = center_frame - default_length_half
                mark_out = center_frame + default_length_half - 1
                new_clip.mark_in = mark_in
                new_clip.mark_out = mark_out
        else: # All the rest
            new_clip.mark_in = media_file.mark_in
            new_clip.mark_out = media_file.mark_out

        if new_clip.mark_in == -1:
            new_clip.mark_in = 0
        if new_clip.mark_out == -1:
            new_clip.mark_out = new_clip.get_length() - 1 # - 1 because out is mark_out inclusive
            if media_file.type == appconsts.IMAGE_SEQUENCE:
                new_clip.mark_out = media_file.length

    # Graphics files get added with their default lengths
    f_name, ext = os.path.splitext(media_file.name)
    if utils.file_extension_is_graphics_file(ext) and media_file.type != appconsts.IMAGE_SEQUENCE: # image sequences are graphics files but have own length
        in_fr, out_fr, l = editorpersistance.get_graphics_default_in_out_length()
        new_clip.mark_in = in_fr
        new_clip.mark_out = out_fr

    # Non-insert DND actions
    if editorpersistance.prefs.dnd_action == appconsts.DND_OVERWRITE_NON_V1:
        if track.id != current_sequence().first_video_track().id:
            drop_done = _attempt_dnd_overwrite(track, new_clip, frame)
            if drop_done == True:
                return
    elif editorpersistance.prefs.dnd_action == appconsts.DND_ALWAYS_OVERWRITE:
        drop_done = _attempt_dnd_overwrite(track, new_clip, frame)
        if drop_done == True:
            return
            
    do_clip_insert(track, new_clip, frame)
Exemplo n.º 18
0
    def _get_selection_data(self, p1, p2):
        x1, y1 = p1
        x2, y2 = p2

        if x1 > x2:
            x1, x2 = x2, x1
        if y1 > y2:
            y1, y2 = y2, y1

        start_frame = tlinewidgets.get_frame(x1)
        end_frame = tlinewidgets.get_frame(x2)

        track_top_index = self.get_bounding_track_index(
            y1, tlinewidgets.get_track(y1))
        track_bottom_index = self.get_bounding_track_index(
            y2, tlinewidgets.get_track(y2))

        self.topleft_track = track_top_index - 1

        # Get compositors
        for i in range(track_bottom_index + 1, track_top_index):
            track_compositors = current_sequence().get_track_compositors(i)
            for comp in track_compositors:
                if comp.clip_in >= start_frame and comp.clip_out < end_frame:
                    self.selected_compositors.append(comp)

        # Get BoxTrackSelection objects
        for i in range(track_bottom_index + 1, track_top_index):
            self.track_selections.append(
                BoxTrackSelection(i, start_frame, end_frame))

        # Drop empty tracks from bottom up
        while len(self.track_selections) > 0:
            if self.track_selections[0].is_empty() == True:
                self.track_selections.pop(0)
            else:
                track_bottom_index = self.track_selections[0].track_id
                break

        # Drop empty tracks from top down
        while len(self.track_selections) > 0:
            if self.track_selections[-1].is_empty() == True:
                self.track_selections.pop(-1)
            else:
                self.topleft_track = self.track_selections[-1].track_id
                break

        self.height_tracks = self.topleft_track - track_bottom_index + 1  # self.topleft_track is inclusive to height, track_bottom_index is eclusive to height

        # Get selection bounding box
        self.topleft_frame = 1000000000000
        for track_selection in self.track_selections:
            if track_selection.range_frame_in != -1:
                if track_selection.range_frame_in < self.topleft_frame:
                    self.topleft_frame = track_selection.range_frame_in

        last_frame = 0
        for track_selection in self.track_selections:
            if track_selection.range_frame_out != -1:
                if track_selection.range_frame_out > last_frame:
                    last_frame = track_selection.range_frame_out

        self.width_frames = last_frame - self.topleft_frame
Exemplo n.º 19
0
def _add_autofade(data):
    # NOTE: These stay synhced only in "Top Down Auto Follow" mode, see: edit.get_full_compositor_sync_data()

    clip, track, item_id, item_data = data
    x, compositor_type, add_compositors_is_multi_selection = item_data

    frame = tlinewidgets.get_frame(x)
    clip_index = track.get_clip_index_at(frame)

    target_track_index = track.id - 1

    if add_compositors_is_multi_selection == True:
        for clip_index in range(movemodes.selected_range_in,
                                movemodes.selected_range_out + 1):
            composited_clip = track.clips[clip_index]
            if composited_clip.is_blanck_clip == True:
                continue

            clip_length = composited_clip.clip_out - composited_clip.clip_in
            if compositor_type == "##auto_fade_in":
                compositor_in = current_sequence().tracks[track.id].clip_start(
                    clip_index)
                compositor_out = compositor_in + int(utils.fps()) - 1
            else:  # fade out
                clip_start = current_sequence().tracks[track.id].clip_start(
                    clip_index)
                compositor_out = clip_start + clip_length
                compositor_in = compositor_out - int(utils.fps()) + 1

            edit_data = {
                "origin_clip_id": composited_clip.id,
                "in_frame": compositor_in,
                "out_frame": compositor_out,
                "a_track": target_track_index,
                "b_track": track.id,
                "compositor_type": compositor_type,
                "clip": composited_clip
            }
            action = edit.add_compositor_action(edit_data)
            action.do_edit()

        updater.repaint_tline()
        return

    clip_length = clip.clip_out - clip.clip_in
    if compositor_type == "##auto_fade_in":
        compositor_in = current_sequence().tracks[track.id].clip_start(
            clip_index)
        compositor_out = compositor_in + int(utils.fps()) - 1
    else:  # fade out
        clip_start = current_sequence().tracks[track.id].clip_start(clip_index)
        compositor_out = clip_start + clip_length
        compositor_in = compositor_out - int(utils.fps()) + 1

    edit_data = {
        "origin_clip_id": clip.id,
        "in_frame": compositor_in,
        "out_frame": compositor_out,
        "a_track": target_track_index,
        "b_track": track.id,
        "compositor_type": compositor_type,
        "clip": clip
    }
    action = edit.add_compositor_action(edit_data)
    action.do_edit()

    updater.repaint_tline()
Exemplo n.º 20
0
def tline_media_drop(media_file, x, y, use_marks=False):
    track = tlinewidgets.get_track(y)
    if track == None:
        return
    if track.id < 1 or track.id >= (len(current_sequence().tracks) - 1):
        return
    if dialogutils.track_lock_check_and_user_info(track):
        #modesetting.set_default_edit_mode()
        # TODO: Info
        return

    modesetting.stop_looping()
    if EDIT_MODE() == editorstate.KF_TOOL:
        kftoolmode.exit_tool()

    frame = tlinewidgets.get_frame(x)

    # Create new clip.
    if media_file.type != appconsts.PATTERN_PRODUCER:
        if media_file.container_data == None:
            # Standard clips
            new_clip = current_sequence().create_file_producer_clip(
                media_file.path, media_file.name, False, media_file.ttl)
        else:
            # Container clips, create new container_data object and generate uuid for clip so it gets it own folder in.$XML_DATA/.../container_clips
            new_clip = current_sequence().create_file_producer_clip(
                media_file.path, media_file.name, False, media_file.ttl)
            new_clip.container_data = copy.deepcopy(media_file.container_data)
            new_clip.container_data.generate_clip_id()
    else:
        new_clip = current_sequence().create_pattern_producer(media_file)

    # Set clip in and out
    if use_marks == False:
        new_clip.mark_in = 0
        new_clip.mark_out = new_clip.get_length(
        ) - 1  # - 1 because out is mark_out inclusive

        if media_file.type == appconsts.IMAGE_SEQUENCE:
            new_clip.mark_out = media_file.length
    else:
        if new_clip.media_type == appconsts.IMAGE or new_clip.media_type == appconsts.PATTERN_PRODUCER:
            # Give IMAGE and PATTERN_PRODUCER media types default mark in and mark out if not already set.
            # This makes them reasonably short and trimmable in both directions.
            # NOTE: WE SHOULD BE DOING THIS AT CREATION TIME, WE'RE DOING THE SAME THING IN updater.display_clip_in_monitor() ?
            #       ...but then we would need to patch persistance.py...maybe keep this even if not too smart.
            # TODO: Make default length user settable or use graphics value
            if (hasattr(new_clip, 'mark_in')
                    == False) or (new_clip.mark_in == -1
                                  and new_clip.mark_out == -1):
                center_frame = new_clip.get_length() // 2
                default_length_half = 75
                mark_in = center_frame - default_length_half
                mark_out = center_frame + default_length_half - 1
                new_clip.mark_in = mark_in
                new_clip.mark_out = mark_out
        else:  # All the rest
            new_clip.mark_in = media_file.mark_in
            new_clip.mark_out = media_file.mark_out

        if new_clip.mark_in == -1:
            new_clip.mark_in = 0
        if new_clip.mark_out == -1:
            new_clip.mark_out = new_clip.get_length(
            ) - 1  # - 1 because out is mark_out inclusive
            if media_file.type == appconsts.IMAGE_SEQUENCE:
                new_clip.mark_out = media_file.length

    # Graphics files get added with their default lengths
    f_name, ext = os.path.splitext(media_file.name)
    if utils.file_extension_is_graphics_file(
            ext
    ) and media_file.type != appconsts.IMAGE_SEQUENCE:  # image sequences are graphics files but have own length
        in_fr, out_fr, l = editorpersistance.get_graphics_default_in_out_length(
        )
        new_clip.mark_in = in_fr
        new_clip.mark_out = out_fr

    # Non-insert DND actions
    if editorpersistance.prefs.dnd_action == appconsts.DND_OVERWRITE_NON_V1:
        if track.id != current_sequence().first_video_track().id:
            drop_done = _attempt_dnd_overwrite(track, new_clip, frame)
            if drop_done == True:
                return
    elif editorpersistance.prefs.dnd_action == appconsts.DND_ALWAYS_OVERWRITE:
        drop_done = _attempt_dnd_overwrite(track, new_clip, frame)
        if drop_done == True:
            return

    do_clip_insert(track, new_clip, frame)
Exemplo n.º 21
0
def open_clip_in_effects_editor(data):
    clip, track, item_id, x = data
    frame = tlinewidgets.get_frame(x)
    index = current_sequence().get_clip_index(track, frame)

    clipeffectseditor.set_clip(clip, track, index)
Exemplo n.º 22
0
def tline_media_drop(media_file, x, y, use_marks=False):
    track = tlinewidgets.get_track(y)
    if track == None:
        return
    if track.id < 1 or track.id >= (len(current_sequence().tracks) - 1):
        return
    if track_lock_check_and_user_info(track):
        #modesetting.set_default_edit_mode()
        # Info
        return

    modesetting.stop_looping()

    frame = tlinewidgets.get_frame(x)

    # Create new clip.
    if media_file.type != appconsts.PATTERN_PRODUCER:
        new_clip = current_sequence().create_file_producer_clip(
            media_file.path, media_file.name, False, media_file.ttl)
    else:
        new_clip = current_sequence().create_pattern_producer(media_file)

    # Set clip in and out
    if use_marks == False:
        new_clip.mark_in = 0
        new_clip.mark_out = new_clip.get_length(
        ) - 1  # - 1 because out is mark_out inclusive

        if media_file.type == appconsts.IMAGE_SEQUENCE:
            new_clip.mark_out = media_file.length
    else:
        new_clip.mark_in = media_file.mark_in
        new_clip.mark_out = media_file.mark_out

        if new_clip.mark_in == -1:
            new_clip.mark_in = 0
        if new_clip.mark_out == -1:
            new_clip.mark_out = new_clip.get_length(
            ) - 1  # - 1 because out is mark_out inclusive
            if media_file.type == appconsts.IMAGE_SEQUENCE:
                new_clip.mark_out = media_file.length

    # Graphics files get added with their default lengths
    f_name, ext = os.path.splitext(media_file.name)
    if utils.file_extension_is_graphics_file(
            ext
    ) and media_file.type != appconsts.IMAGE_SEQUENCE:  # image sequences are graphics files but have own length
        in_fr, out_fr, l = editorpersistance.get_graphics_default_in_out_length(
        )
        new_clip.mark_in = in_fr
        new_clip.mark_out = out_fr

    # Non-insert DND actions
    if editorpersistance.prefs.dnd_action == appconsts.DND_OVERWRITE_NON_V1:
        if track.id != current_sequence().first_video_track().id:
            drop_done = _attempt_dnd_overwrite(track, new_clip, frame)
            if drop_done == True:
                return
    elif editorpersistance.prefs.dnd_action == appconsts.DND_ALWAYS_OVERWRITE:
        drop_done = _attempt_dnd_overwrite(track, new_clip, frame)
        if drop_done == True:
            return

    do_clip_insert(track, new_clip, frame)