def display_clip_menu(y, event, frame): # See if we actually hit a clip track = tlinewidgets.get_track(y) if track == None: return False clip_index = current_sequence().get_clip_index(track, frame) if clip_index == -1: return False # Can't do anything to clips in locked tracks if dialogutils.track_lock_check_and_user_info(track): return False # Display popup gui.tline_canvas.drag_on = False pressed_clip = track.clips[clip_index] if pressed_clip.is_blanck_clip == False: movemodes.select_clip(track.id, clip_index) else: movemodes.select_blank_range(track, pressed_clip) if track.type == appconsts.VIDEO: guicomponents.display_clip_popup_menu(event, pressed_clip, \ track, _clip_menu_item_activated) elif track.type == appconsts.AUDIO: guicomponents.display_audio_clip_popup_menu(event, pressed_clip, \ track, _clip_menu_item_activated) return True
def display_clip_menu(y, event, frame): # See if we actually hit a clip track = tlinewidgets.get_track(y) if track == None: return False clip_index = current_sequence().get_clip_index(track, frame) if clip_index == -1: return False # Can't do anything to clips in locked tracks if dialogutils.track_lock_check_and_user_info(track): return False # Display popup gui.tline_canvas.drag_on = False pressed_clip = track.clips[clip_index] if pressed_clip.is_blanck_clip == False: movemodes.select_clip(track.id, clip_index) else: movemodes.select_blank_range(track, pressed_clip) if track.type == appconsts.VIDEO: guicomponents.display_clip_popup_menu(event, pressed_clip, \ track, _clip_menu_item_activated) elif track.type == appconsts.AUDIO: guicomponents.display_audio_clip_popup_menu(event, pressed_clip, \ track, _clip_menu_item_activated) return True
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)
def mouse_press(event, frame): x = event.x y = event.y global edit_data, mouse_disabled # Clear edit data in gui module edit_data = None mouse_disabled = False tlinewidgets.set_edit_mode_data(edit_data) # Get pressed track track = tlinewidgets.get_track(y) if track == None: mouse_disabled = True return if dialogutils.track_lock_check_and_user_info(track): mouse_disabled = True return # Get pressed clip index clip_index = current_sequence().get_clip_index(track, frame) # Selecting empty or blank clip does not define edit if clip_index == -1: mouse_disabled = True return pressed_clip = track.clips[clip_index] if pressed_clip.is_blanck_clip: mouse_disabled = True return if (event.get_state() & Gdk.ModifierType.CONTROL_MASK): move_all = False else: move_all = True first_moved_frame = track.clip_start(clip_index) multi_data = MultimoveData(track, first_moved_frame, move_all) edit_data = { "track_id": track.id, "press_frame": frame, "current_frame": frame, "first_moved_frame": first_moved_frame, "mouse_start_x": x, "mouse_start_y": y, "multi_data": multi_data } tlinewidgets.set_edit_mode_data(edit_data) updater.repaint_tline()
def mouse_press(event, frame): x = event.x y = event.y global edit_data, mouse_disabled # Clear edit data in gui module edit_data = None mouse_disabled = False tlinewidgets.set_edit_mode_data(edit_data) # Get pressed track track = tlinewidgets.get_track(y) if track == None: mouse_disabled = True return if dialogutils.track_lock_check_and_user_info(track): mouse_disabled = True return # Get pressed clip index clip_index = current_sequence().get_clip_index(track, frame) # Selecting empty or blank clip does not define edit if clip_index == -1: mouse_disabled = True return pressed_clip = track.clips[clip_index] if pressed_clip.is_blanck_clip: mouse_disabled = True return if (event.get_state() & Gdk.ModifierType.CONTROL_MASK): move_all = False else: move_all = True first_moved_frame = track.clip_start(clip_index) multi_data = MultimoveData(track, first_moved_frame, move_all) edit_data = {"track_id":track.id, "press_frame":frame, "current_frame":frame, "first_moved_frame":first_moved_frame, "mouse_start_x":x, "mouse_start_y":y, "multi_data":multi_data} tlinewidgets.set_edit_mode_data(edit_data) updater.repaint_tline()
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 dialogutils.track_lock_check_and_user_info(track): modesetting.set_default_edit_mode() return frame = tlinewidgets.get_frame(x) clips = medialog.get_clips_for_rows(rows) modesetting.set_default_edit_mode() do_multiple_clip_insert(track, clips, frame)
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 dialogutils.track_lock_check_and_user_info(track): modesetting.set_default_edit_mode() return frame = tlinewidgets.get_frame(x) clips = medialog.get_clips_for_rows(rows) modesetting.set_default_edit_mode() do_multiple_clip_insert(track, clips, frame)
def tline_effect_drop(x, y): clip, track, index = tlinewidgets.get_clip_track_and_index_for_pos(x, y) if clip == None: return 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() return if clip != clipeffectseditor.clip: clipeffectseditor.set_clip(clip, track, index) clipeffectseditor.add_currently_selected_effect() # drag start selects the dragged effect
def tline_effect_drop(x, y): clip, track, index = tlinewidgets.get_clip_track_and_index_for_pos(x, y) if clip == None: return 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() return if clip != clipeffectseditor.clip: clipeffectseditor.set_clip(clip, track, index) clipeffectseditor.add_currently_selected_effect() # drag start selects the dragged effect
def cut_single_track(event, frame): track = tlinewidgets.get_track(event.y) if track == None or track.id == 0 or track.id == len(current_sequence().tracks) - 1: return if dialogutils.track_lock_check_and_user_info(track): return data = get_cut_data(track, frame) if data == None: return action = edit.cut_action(data) action.do_edit() updater.repaint_tline()
def cut_single_track(event, frame): track = tlinewidgets.get_track(event.y) if track == None or track.id == 0 or track.id == len( current_sequence().tracks) - 1: return if dialogutils.track_lock_check_and_user_info(track): return data = get_cut_data(track, frame) if data == None: return action = edit.cut_action(data) action.do_edit() updater.repaint_tline()
def tline_effect_drop(x, y): clip, track, index = tlinewidgets.get_clip_track_and_index_for_pos(x, y) if clip == None: return 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() return selected_track_before = movemodes.selected_track selected_in_before = movemodes.selected_range_in selected_out_before = movemodes.selected_range_out if clipeffectseditor.clip_is_being_edited(clip) == False: clipeffectseditor.set_clip(clip, track, index) clipeffectseditor.add_currently_selected_effect() # drag start selects the dragged effect filter_info = clipeffectseditor.get_currently_selected_filter_info() if selected_track_before != track.id: return if not((selected_in_before <= index) and (selected_out_before >= index)): return if selected_in_before != -1: for add_index in range(selected_in_before, selected_out_before + 1): if add_index == index: continue add_clip = track.clips[add_index] if add_clip.is_blanck_clip == True: continue data = {"clip":add_clip, "filter_info":filter_info, "filter_edit_done_func":clipeffectseditor.filter_edit_done_stack_update} action = edit.add_filter_action(data) action.do_edit()
def mouse_press(event, frame): x = event.x y = event.y # If we have clip being edited and its edit area is hit, we do not need to init data. # If editor open we disregard track locking until it is closed. if _kf_editor != None and _kf_editor.overlay_area_hit(x, y): _handle_edit_mouse_press(event) return # Get pressed track track = tlinewidgets.get_track(y) # Selecting empty clears selection if track == None or track.id == 0 or track.id == len(current_sequence().tracks) - 1: exit_tool() return # No edits for locked tracks if dialogutils.track_lock_check_and_user_info(track): set_no_clip_edit_data() return # Attempt to init kf tool editing on some clip # Get pressed clip index clip_index = current_sequence().get_clip_index(track, frame) # Selecting empty clears selection if clip_index == -1: exit_tool() return clip = track.clips[clip_index] init_tool_for_clip(clip, track)
def mouse_press(event, frame): x = event.x y = event.y # If we have clip being edited and its edit area is hit, we do not need to init data. # If editor open we disregard track locking until it is closed. if _kf_editor != None and _kf_editor.overlay_area_hit(x, y): _handle_edit_mouse_press(event) return # Get pressed track track = tlinewidgets.get_track(y) # Selecting empty clears selection if track == None or track.id == 0 or track.id == len(current_sequence().tracks) - 1: exit_tool() return # No edits for locked tracks if dialogutils.track_lock_check_and_user_info(track): _set_no_clip_edit_data() return # Attempt to init kf tool editing on some clip # Get pressed clip index clip_index = current_sequence().get_clip_index(track, frame) # Selecting empty clears selection if clip_index == -1: exit_tool() return clip = track.clips[clip_index] init_tool_for_clip(clip, track)
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 new_clip = current_sequence().create_file_producer_clip(media_file.path, media_file.name, False, media_file.ttl) new_clip.container_data = media_file.container_data 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)
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: # Media types that do not have length determined by content. if new_clip.media_type == appconsts.IMAGE or new_clip.media_type == appconsts.PATTERN_PRODUCER: # If no marks use default length. # This is different from media that has length determined by content. if (hasattr(media_file, 'mark_in') == False) or (media_file.mark_in == -1 and media_file.mark_out == -1): in_fr, out_fr, l = editorpersistance.get_graphics_default_in_out_length() new_clip.mark_in = in_fr new_clip.mark_out = out_fr else: new_clip.mark_in = media_file.mark_in new_clip.mark_out = media_file.mark_out # Replace single missing mark in 3-point edit style. if new_clip.mark_in == -1: new_clip.mark_in = 0 if new_clip.mark_out == -1: new_clip.mark_out = 14999 else: # All the rest new_clip.mark_in = media_file.mark_in new_clip.mark_out = media_file.mark_out # Replace single missing mark in 3-point edit style. 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 # 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)
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)
def mouse_release(x, y, frame): global box_selection_data, edit_data, entered_from_overwrite if edit_data == None: if entered_from_overwrite == True: _exit_to_overwrite() return if box_selection_data == None: # mouse action is to select box_selection_data = BoxMoveData(edit_data["press_point"], (x, y)) locked_track = box_selection_data.get_possible_locked_track() if locked_track != None: dialogutils.track_lock_check_and_user_info(locked_track) edit_data = None box_selection_data = None tlinewidgets.set_edit_mode_data(edit_data) updater.repaint_tline() # Exit box mode if entered from overwrite if entered_from_overwrite == True: _exit_to_overwrite() return if box_selection_data.is_empty() == False: edit_data = {"action_on":True, "press_frame":frame, "delta":0, "box_selection_data":box_selection_data} else: box_selection_data = None edit_data = {"action_on":False, "press_frame":-1, "delta":0, "box_selection_data":box_selection_data} # Exit box mode if entered from overwrite with empty selection if entered_from_overwrite == True: _exit_to_overwrite() return else: # mouse action is to move # Exit if selection contains locked track locked_track = box_selection_data.get_possible_locked_track() if locked_track != None: dialogutils.track_lock_check_and_user_info(locked_track) edit_data = None box_selection_data = None tlinewidgets.set_edit_mode_data(edit_data) updater.repaint_tline() # Exit box mode if entered from overwrite if entered_from_overwrite == True: _exit_to_overwrite() return # If we lock track after delta = frame - edit_data["press_frame"] edit_data["delta"] = delta # Do edit data = {"box_selection_data":box_selection_data, "delta":delta} action = edit.box_overwrite_move_action(data) action.do_edit() # Back to start state edit_data = None box_selection_data = None # Exit box mode if entered from overwrite with empty selection if entered_from_overwrite == True: _exit_to_overwrite() return tlinewidgets.set_edit_mode_data(edit_data) updater.repaint_tline()