def _oor_menu_item_activated(self, widget, data): if data == "delete_all_before": keep_doing = True while keep_doing: try: frame, value = self.keyframes[1] if frame < self.clip_in: self.keyframes.pop(1) else: keep_doing = False except: keep_doing = False elif data == "delete_all_but_last_after": keep_doing = True index = 1 while keep_doing: try: frame, value = self.keyframes[index] if frame > self.clip_in + self.clip_length and index < (len(self.keyframes) - 1): self.keyframes.pop(index) else: index += 1 except: keep_doing = False elif data == "zero_next": frame_zero, frame_zero_value = self.keyframes[0] frame, value = self.keyframes[1] self.keyframes.pop(0) self.keyframes.insert(0, (frame_zero, value)) self.update_property_value() elif data == "delete_all_after": delete_done = False for i in range(0, len(self.keyframes)): frame, value = self.keyframes[i] if frame > self.clip_in + self.clip_length: self.keyframes.pop(i) popped = True while popped: try: self.keyframes.pop(i) except: popped = False delete_done = True if delete_done: break elif data == "edit_brightness": init_tool_for_clip(edit_data["clip"] , edit_data["track"], BRIGHTNESS_KF_EDIT) elif data == "edit_volume": init_tool_for_clip(edit_data["clip"] , edit_data["track"], VOLUME_KF_EDIT) elif data == "exit": _set_no_clip_edit_data() elif data == "playhead_follows": global _playhead_follow_kf _playhead_follow_kf = widget.get_active() updater.repaint_tline()
def exit_tool(): _set_no_clip_edit_data() global enter_mode if enter_mode != None: gui.editor_window.kf_tool_exit_to_mode(enter_mode) enter_mode = None updater.repaint_tline()
def set_waveform_displayer_clip_from_popup(data): clip, track, item_id, item_data = data global frames_cache if clip.path in frames_cache: frame_levels = frames_cache[clip.path] clip.waveform_data = frame_levels updater.repaint_tline() return cache_file_path = userfolders.get_cache_dir() + appconsts.AUDIO_LEVELS_DIR + _get_unique_name_for_media(clip.path) if os.path.isfile(cache_file_path): f = open(cache_file_path) frame_levels = pickle.load(f) frames_cache[clip.path] = frame_levels clip.waveform_data = frame_levels updater.repaint_tline() return progress_bar = Gtk.ProgressBar() title = _("Audio Levels Data Render") text = "<b>Media File: </b>" + clip.path dialog = _waveform_render_progress_dialog(_waveform_render_abort, title, text, progress_bar, gui.editor_window.window) dialog.progress_bar = progress_bar global waveform_thread waveform_thread = WaveformCreator(clip, track.height, dialog) waveform_thread.start()
def spin_value_changed(self, spin): if self.editable_property.clip.transition.info.name == "##auto_fade_in": self.editable_property.clip.set_length_from_in(int(spin.get_value())) else: self.editable_property.clip.set_length_from_out(int(spin.get_value())) updater.repaint_tline()
def set_track_normal_height(track_index, is_retry=False): track = get_track(track_index) track.height = appconsts.TRACK_HEIGHT_NORMAL # Check that new height tracks can be displayed and cancel if not. new_h = current_sequence().get_tracks_height() allocation = gui.tline_canvas.widget.get_allocation() x, y, w, h = allocation.x, allocation.y, allocation.width, allocation.height if new_h > h and is_retry == False: current_paned_pos = gui.editor_window.app_v_paned.get_position() new_paned_pos = current_paned_pos - (new_h - h) - 5 gui.editor_window.app_v_paned.set_position(new_paned_pos) GObject.timeout_add(200, lambda: set_track_normal_height(track_index, True)) return False allocation = gui.tline_canvas.widget.get_allocation() x, y, w, h = allocation.x, allocation.y, allocation.width, allocation.height if new_h > h: track.height = appconsts.TRACK_HEIGHT_SMALL dialogutils.warning_message(_("Not enough vertical space on Timeline to expand track"), _("Maximize or resize application window to get more\nspace for tracks if possible."), gui.editor_window.window, True) return False tlinewidgets.set_ref_line_y(gui.tline_canvas.widget.get_allocation()) gui.tline_column.init_listeners() updater.repaint_tline() return False
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()
def _exit_clip_end_drag(): # Go back to enter mode editorstate.edit_mode = _enter_mode tlinewidgets.set_edit_mode(None, _enter_draw_func) gui.editor_window.set_cursor_to_mode() updater.repaint_tline()
def splice_out_button_pressed(): """ Removes 1 - n long continuous clip range from track and closes the created gap. """ if movemodes.selected_track == -1: return # Edit consumes selection, so clear selected from clips movemodes.set_range_selection(movemodes.selected_track, movemodes.selected_range_in, movemodes.selected_range_out, False) track = get_track(movemodes.selected_track) if editevent.track_lock_check_and_user_info(track, splice_out_button_pressed, "splice out"): movemodes.clear_selection_values() return data = {"track":track, "from_index":movemodes.selected_range_in, "to_index":movemodes.selected_range_out} edit_action = edit.remove_multiple_action(data) edit_action.do_edit() # Nothing is selected after edit movemodes.clear_selection_values() updater.repaint_tline()
def lift_button_pressed(): """ Removes 1 - n long continuous clip range from track and fills the created gap with a black clip """ if movemodes.selected_track == -1: return # Edit consumes selection, set clips seletion attr to false movemodes.set_range_selection(movemodes.selected_track, movemodes.selected_range_in, movemodes.selected_range_out, False) track = get_track(movemodes.selected_track) if editevent.track_lock_check_and_user_info(track, lift_button_pressed, "lift"): movemodes.clear_selection_values() return data = {"track":track, "from_index":movemodes.selected_range_in, "to_index":movemodes.selected_range_out} edit_action = edit.lift_multiple_action(data) edit_action.do_edit() # Nothing is left selected after edit movemodes.clear_selection_values() updater.repaint_tline()
def delete_effect_pressed(): if len(clip.filters) == 0: return # Block updates until we have set selected row global edit_effect_update_blocked edit_effect_update_blocked = True treeselection = widgets.effect_stack_view.treeview.get_selection() (model, rows) = treeselection.get_selected_rows() try: row = rows[0] except: return # This fails when there are filters but no rows are selected row_index = max(row) data = {"clip":clip, "index":row_index, "filter_edit_done_func":filter_edit_done} action = edit.remove_filter_action(data) action.do_edit() updater.repaint_tline() # Set last filter selected and display in editor edit_effect_update_blocked = False if len(clip.filters) == 0: return path = str(len(clip.filters) - 1) # Causes edit_effect_selected() called as it is the "change" listener widgets.effect_stack_view.treeview.get_selection().select_path(path)
def overwrite_move_move(x, y, frame, state): """ User moves mouse when in overwrite move mode. """ global edit_data, drag_disabled if drag_disabled: return if edit_data == None: return _move_mode_move(frame, x, y) # Calculate overwrite area if moving if edit_data["move_on"] == True: # get in point over_in = edit_data["attempt_insert_frame"] # Check and do magnet cut_x = tlinewidgets._get_frame_x(edit_data["insert_frame"]) clip_head_x = tlinewidgets._get_frame_x(edit_data["attempt_insert_frame"]) if abs(clip_head_x - cut_x) < MAGNETIC_AREA_IN_PIX: over_in = edit_data["insert_frame"] over_out = over_in + edit_data["moving_length"] edit_data["over_in"] = over_in edit_data["over_out"] = over_out updater.repaint_tline()
def motion_notify_event(self, x, y, state): """ Mouse move callback """ lx = self._legalize_x(x) ly = self._legalize_y(y) if abs(self.mouse_start_y - ly) > DRAG_MIN_Y: self.value_drag_on = True self.mouse_x = lx self.mouse_y = ly if self.current_mouse_action == POSITION_DRAG: frame = self._get_drag_frame(lx) self.current_clip_frame = frame self.clip_editor_frame_changed(self.current_clip_frame) updater.repaint_tline() elif self.current_mouse_action == KF_DRAG or self.current_mouse_action == KF_DRAG_FRAME_ZERO_KF: frame = self._get_drag_frame(lx) if self.current_mouse_action == KF_DRAG_FRAME_ZERO_KF: frame = 0 if self.value_drag_on == True: value = round(self._get_value_for_panel_y(ly)) self.edit_value = value self.set_active_kf_frame_and_value(frame, value) else: self.set_active_kf_frame_and_value(frame, self.edit_value) if _playhead_follow_kf == True: self.current_clip_frame = frame self.clip_editor_frame_changed(self.current_clip_frame) updater.repaint_tline()
def mouse_press(event, frame): track = current_sequence().tracks[compositor.transition.b_track - 1] global edit_data, sub_mode compositor_y = tlinewidgets._get_track_y(track.id) - tlinewidgets.COMPOSITOR_HEIGHT_OFF if abs(event.x - tlinewidgets._get_frame_x(compositor.clip_in)) < TRIM_HANDLE_WIDTH: edit_data = {"clip_in":compositor.clip_in, "clip_out":compositor.clip_out, "trim_is_clip_in":True, "compositor_y": compositor_y, "compositor": compositor} tlinewidgets.set_edit_mode(edit_data, tlinewidgets.draw_compositor_trim) sub_mode = TRIM_EDIT elif abs(event.x - tlinewidgets._get_frame_x(compositor.clip_out + 1)) < TRIM_HANDLE_WIDTH: edit_data = {"clip_in":compositor.clip_in, "clip_out":compositor.clip_out, "trim_is_clip_in":False, "compositor_y": compositor_y, "compositor": compositor} tlinewidgets.set_edit_mode(edit_data, tlinewidgets.draw_compositor_trim) sub_mode = TRIM_EDIT else: edit_data = {"press_frame":frame, "current_frame":frame, "clip_in":compositor.clip_in, "clip_length":(compositor.clip_out - compositor.clip_in + 1), "compositor_y": compositor_y, "compositor": compositor} tlinewidgets.set_edit_mode(edit_data, tlinewidgets.draw_compositor_move_overlay) sub_mode = MOVE_EDIT updater.repaint_tline()
def _audio_levels_item_activated(widget, msg): if msg == "all": editorstate.display_all_audio_levels = True updater.repaint_tline() else: editorstate.display_all_audio_levels = False current_sequence().drop_audio_levels() updater.repaint_tline()
def mouse_move(x, y, frame, state): if mouse_disabled: return global edit_data edit_data["current_frame"] = frame updater.repaint_tline()
def mouse_move(x, y, frame, state): global edit_data if sub_mode == TRIM_EDIT: _bounds_check_trim(frame, edit_data) else: edit_data["current_frame"] = frame updater.repaint_tline()
def _exit_clip_end_drag(): # Go back to enter mode editorstate.edit_mode = _enter_mode tlinewidgets.set_edit_mode(None, _enter_draw_func) tlinewidgets.pointer_context = appconsts.POINTER_CONTEXT_NONE gui.editor_window.set_cursor_to_mode() updater.repaint_tline()
def resync_everything(): # Selection not valid after resync action if movemodes.selected_track == -1: movemodes.clear_selected_clips() action = edit.resync_all_action({}) action.do_edit() updater.repaint_tline()
def _exit_to_overwrite(): # If we entered box mode from overwite mode empty click, this is used to enter back into overwrite mode. global entered_from_overwrite entered_from_overwrite = False editorstate.overwrite_mode_box = False tlinewidgets.set_edit_mode_data(None) gui.editor_window.set_cursor_to_mode() # This gets set wrong in editevent.tline_canvas_mouse_released() and were putting it back here, # this could be investigated for better solution, this could cause a cursor flash, but on dev system we're not getting it. updater.repaint_tline()
def resync_clip(popup_data): clip, track, item_id, x = popup_data clip_list=[(clip, track)] data = {"clips":clip_list} action = edit.resync_some_clips_action(data) action.do_edit() updater.repaint_tline()
def multi_mode_pressed(): stop_looping() current_sequence().clear_hidden_track() editorstate.edit_mode = editorstate.MULTI_MOVE tlinewidgets.set_edit_mode(None, tlinewidgets.draw_multi_overlay) updater.set_move_mode_gui() updater.repaint_tline()
def set_track_small_height(track_index): track = get_track(track_index) track.height = appconsts.TRACK_HEIGHT_SMALL if editorstate.SCREEN_HEIGHT < 863: track.height = appconsts.TRACK_HEIGHT_SMALLEST tlinewidgets.set_ref_line_y(gui.tline_canvas.widget.get_allocation()) gui.tline_column.init_listeners() updater.repaint_tline()
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()
def init_sequence_gui(): """ Called after project load or changing current sequence to initialize interface. """ # Set initial timeline scale draw params editorstate.current_sequence().update_length() updater.update_pix_per_frame_full_view() updater.init_tline_scale() updater.repaint_tline()
def cut_single_track(event, frame): track = tlinewidgets.get_track(event.y) data = get_cut_data(track, frame) if data == None: return action = edit.cut_action(data) action.do_edit() updater.repaint_tline()
def add_currently_selected_effect(): # Check we have clip if clip == None: return filter_info = get_selected_filter_info() action = get_filter_add_action(filter_info, clip) action.do_edit() # gui update in callback from EditAction object. updater.repaint_tline()
def cut_all_tracks(frame): tracks_cut_data = [] for i in range(1, len(current_sequence().tracks) - 1): tracks_cut_data.append(get_cut_data(current_sequence().tracks[i], frame)) data = {"tracks_cut_data":tracks_cut_data} action = edit.cut_all_action(data) action.do_edit() updater.repaint_tline()
def run(self): global frames_cache frame_levels = [None] * self.clip_media_length frames_cache[self.clip.path] = frame_levels Gdk.threads_enter() self.dialog.progress_bar.set_fraction(0.0) self.dialog.progress_bar.set_text(str(0) + "%") while(Gtk.events_pending()): Gtk.main_iteration() Gdk.threads_leave() time.sleep(0.2) for frame in range(0, len(frame_levels)): if self.abort: break self.temp_clip.seek(frame) mlt.frame_get_waveform(self.temp_clip.get_frame(), 10, 50) val = self.levels.get(RIGHT_CHANNEL) if val == None: val = 0.0 frame_levels[frame] = float(val) self.last_rendered_frame = frame if frame % 500 == 0: render_fraction = float(self.last_rendered_frame) / float(self.clip_media_length) Gdk.threads_enter() self.dialog.progress_bar.set_fraction(render_fraction) pros = int(render_fraction * 100) self.dialog.progress_bar.set_text(str(pros) + "%") while(Gtk.events_pending()): Gtk.main_iteration() Gdk.threads_leave() time.sleep(0.1) if not self.abort: self.clip.waveform_data = frame_levels write_file = file(self.file_cache_path, "wb") pickle.dump(frame_levels, write_file) Gdk.threads_enter() self.dialog.progress_bar.set_fraction(1.0) self.dialog.progress_bar.set_text(_("Saving to Hard Drive")) Gdk.threads_leave() else: frames_cache.pop(self.clip.path, None) updater.repaint_tline() # Set thread ref to None to flag that no waveforms are being created global waveform_thread waveform_thread = None _waveform_render_stop(self.dialog, None)
def delete_active_keyframe(self): if self.active_kf_index == 0: # keyframe frame 0 cannot be removed return self.keyframes.pop(self.active_kf_index) self.active_kf_index -= 1 if self.active_kf_index < 0: self.active_kf_index = 0 self._set_pos_to_active_kf() updater.repaint_tline()
def run(self): # Launch render process and wait for it to end FLOG = open(utils.get_hidden_user_dir_path() + "log_audio_levels_render", 'w') process = subprocess.Popen([sys.executable, respaths.LAUNCH_DIR + "flowbladeaudiorender", \ self.rendered_media, self.profile_desc, respaths.ROOT_PATH], \ stdin=FLOG, stdout=FLOG, stderr=FLOG) process.wait() Gdk.threads_enter() updater.repaint_tline() Gdk.threads_leave()
def clear_filters(): if movemodes.selected_track == -1: return track = get_track(movemodes.selected_track) clips = [] for i in range(movemodes.selected_range_in, movemodes.selected_range_out + 1): clips.append(track.clips[i]) data = {"clips": clips} action = edit.remove_multiple_filters_action(data) action.do_edit() movemodes.clear_selected_clips() updater.repaint_tline()
def _marker_add_dialog_callback(dialog, response_id, name_entry): name = name_entry.get_text() dialog.destroy() current_frame = PLAYER().current_frame() dupl_index = -1 for i in range(0, len(current_sequence().markers)): marker_name, frame = current_sequence().markers[i] if frame == current_frame: dupl_index = i if dupl_index != -1: current_sequence().markers.pop(dupl_index) current_sequence().markers.append((name, current_frame)) current_sequence().markers = sorted(current_sequence().markers, key=itemgetter(1)) updater.repaint_tline()
def clips_drag_out_started(event): # Abort move edit global edit_data, drag_disabled edit_data = None drag_disabled = True tlinewidgets.set_edit_mode_data(None) # Set dnd track = current_sequence().tracks[selected_track] clips = [] for i in range(selected_range_in, selected_range_out + 1): clips.append(track.clips[i]) dnd.start_tline_clips_out_drag(event, clips, gui.tline_canvas.widget) # Update tlione gui updater.repaint_tline()
def mouse_press(event, frame): track = current_sequence().tracks[compositor.transition.b_track - 1] global edit_data, sub_mode compositor_y = tlinewidgets._get_track_y( track.id) - tlinewidgets.COMPOSITOR_HEIGHT_OFF if abs(event.x - tlinewidgets._get_frame_x(compositor.clip_in)) < TRIM_HANDLE_WIDTH: edit_data = { "clip_in": compositor.clip_in, "clip_out": compositor.clip_out, "trim_is_clip_in": True, "orig_clip_in": compositor.clip_in, "compositor_y": compositor_y, "compositor": compositor } tlinewidgets.set_edit_mode(edit_data, tlinewidgets.draw_compositor_trim) sub_mode = TRIM_EDIT elif abs(event.x - tlinewidgets._get_frame_x(compositor.clip_out + 1)) < TRIM_HANDLE_WIDTH: edit_data = { "clip_in": compositor.clip_in, "clip_out": compositor.clip_out, "trim_is_clip_in": False, "orig_clip_out": compositor.clip_out, "compositor_y": compositor_y, "compositor": compositor } tlinewidgets.set_edit_mode(edit_data, tlinewidgets.draw_compositor_trim) sub_mode = TRIM_EDIT else: edit_data = { "press_frame": frame, "current_frame": frame, "clip_in": compositor.clip_in, "clip_length": (compositor.clip_out - compositor.clip_in + 1), "compositor_y": compositor_y, "compositor": compositor } tlinewidgets.set_edit_mode(edit_data, tlinewidgets.draw_compositor_move_overlay) sub_mode = MOVE_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 _clip_marker_add_dialog_callback(dialog, response_id, name_entry, data): clip, track, clip_frame = data name = name_entry.get_text() dialog.destroy() # remove older on same frame dupl_index = -1 for i in range(0, len(clip.markers)): marker_name, frame = clip.markers[i] if frame == clip_frame: dupl_index = i if dupl_index != -1: current_sequence().markers.pop(dupl_index) clip.markers.append((name, clip_frame)) clip.markers = sorted(clip.markers, key=itemgetter(1)) updater.repaint_tline()
def mouse_release(x, y, frame, state): global sub_mode tlinewidgets.pointer_context = appconsts.POINTER_CONTEXT_NONE # Se we're only handling 3 editmodes here. editorstate.edit_mode = prev_edit_mode if editorstate.edit_mode == editorstate.INSERT_MOVE: tlinewidgets.set_edit_mode(None, tlinewidgets.draw_insert_overlay) elif editorstate.edit_mode == editorstate.OVERWRITE_MOVE: tlinewidgets.set_edit_mode(None, tlinewidgets.draw_overwrite_overlay) elif editorstate.edit_mode == editorstate.MULTI_MOVE: tlinewidgets.set_edit_mode(None, tlinewidgets.draw_multi_overlay) else: print("COMPOSITOR MODE EXIT PROBLEM at compositormodes.mouse_release") gui.editor_window.set_cursor_to_mode() if sub_mode == TRIM_EDIT: _bounds_check_trim(frame, edit_data) data = { "compositor": compositor, "clip_in": edit_data["clip_in"], "clip_out": edit_data["clip_out"] } action = edit.move_compositor_action(data) action.do_edit() else: press_frame = edit_data["press_frame"] current_frame = frame delta = current_frame - press_frame data = { "compositor": compositor, "clip_in": compositor.clip_in + delta, "clip_out": compositor.clip_out + delta } if data["clip_in"] < 0: data["clip_in"] = 0 if data["clip_out"] < 0: data["clip_out"] = 0 action = edit.move_compositor_action(data) action.do_edit() sub_mode = NO_COMPOSITOR_EDIT updater.repaint_tline()
def delete_effect_pressed(): if len(clip.filters) == 0: return # Block updates until we have set selected row global edit_effect_update_blocked edit_effect_update_blocked = True current_filter = clip.filters[current_filter_index] if current_filter.info.filter_mask_filter == "": # Regular filters data = {"clip":clip, "index":current_filter_index, "filter_edit_done_func":filter_edit_done} action = edit.remove_filter_action(data) action.do_edit() else: # Filter mask filters. index_1 = -1 index_2 = -1 for i in range(0, len(clip.filters)): f = clip.filters[i] if f.info.filter_mask_filter != "": if index_1 == -1: index_1 = i else: index_2 = i data = {"clip":clip, "index_1":index_1, "index_2":index_2, "filter_edit_done_func":filter_edit_done} action = edit.remove_two_filters_action(data) action.do_edit() updater.repaint_tline() # Set last filter selected and display in editor edit_effect_update_blocked = False if len(clip.filters) == 0: effect_selection_changed() # to display info text return path = str(len(clip.filters) - 1) # Causes edit_effect_selected() called as it is the "change" listener widgets.effect_stack_view.treeview.get_selection().select_path(path)
def _clip_color(data): clip, track, item_id, clip_color = data if clip_color == "default": clip.color = None elif clip_color == "red": clip.color = (1, 0, 0) elif clip_color == "green": clip.color = (0, 1, 0) elif clip_color == "blue": clip.color = (0.2, 0.2, 0.9) elif clip_color == "orange": clip.color = (0.929, 0.545, 0.376) elif clip_color == "brown": clip.color = (0.521, 0.352, 0.317) elif clip_color == "olive": clip.color = (0.5, 0.55, 0.5) updater.repaint_tline()
def set_track_normal_height(track_index): track = get_track(track_index) track.height = appconsts.TRACK_HEIGHT_NORMAL # Check that new height tracks can be displayed and cancel if not. new_h = current_sequence().get_tracks_height() x, y, w, h = gui.tline_canvas.widget.allocation if new_h > h: track.height = appconsts.TRACK_HEIGHT_SMALL dialogutils.warning_message( _("Not enough vertical space on Timeline to expand track"), _("Maximize or resize application window to get more\nspace for tracks if possible." ), gui.editor_window.window, True) return tlinewidgets.set_ref_line_y(gui.tline_canvas.widget.allocation) gui.tline_column.init_listeners() updater.repaint_tline()
def motion_notify_event(self, x, y, state): """ Mouse move callback """ lx = self._legalize_x(x) ly = self._legalize_y(y) if self.current_mouse_action == POSITION_DRAG: self._set_clip_frame(lx) self.clip_editor_frame_changed(self.current_clip_frame) elif self.current_mouse_action == KF_DRAG: frame = self._get_drag_frame(lx) value = self._get_value_for_panel_y(ly) self.set_active_kf_frame_and_value(frame, value) self.current_clip_frame = frame self.clip_editor_frame_changed(self.current_clip_frame) updater.repaint_tline()
def write_image(self): """ Writes thumbnail image from file producer """ clip_path = self.clip.path # Create consumer matchframe_new_path = userfolders.get_cache_dir() + appconsts.MATCH_FRAME_NEW consumer = mlt.Consumer(PROJECT().profile, "avformat", matchframe_new_path) consumer.set("real_time", 0) consumer.set("vcodec", "png") # Create one frame producer producer = mlt.Producer(PROJECT().profile, str(clip_path)) producer = producer.cut(int(self.clip_frame), int(self.clip_frame)) # Delete new match frame try: os.remove(matchframe_new_path) except: # This fails when done first time ever pass # Connect and write image consumer.connect(producer) consumer.run() # Wait until new file exists while os.path.isfile(matchframe_new_path) != True: time.sleep(0.1) # Copy to match frame matchframe_path = userfolders.get_cache_dir() + appconsts.MATCH_FRAME shutil.copyfile(matchframe_new_path, matchframe_path) # Update timeline data # Get frame of clip.clip_in_in on timeline. clip_index = self.track.clips.index(self.clip) clip_start_in_tline = self.track.clip_start(clip_index) tline_match_frame = clip_start_in_tline + (self.clip_frame - self.clip.clip_in) tlinewidgets.set_match_frame(tline_match_frame, self.track.id, self.display_on_right) # Update view updater.repaint_tline()
def select_sync_clip_mouse_pressed(event, frame): sync_clip = _get_sync_tline_clip(event, frame) if sync_clip == None: return # selection wasn't good if utils.is_mlt_xml_file(sync_clip.path) == True: # This isn't translated because 1.14 translation window is close, translation coming for 1.16 dialogutils.warning_message( _("Cannot Timeline Audio Sync with Compound Clips!"), _("Audio syncing for Compound Clips is not supported."), gui.editor_window.window, True) return sync_track = tlinewidgets.get_track(event.y) sync_clip_index = sync_track.clips.index(sync_clip) _tline_sync_data.sync_clip = sync_clip _tline_sync_data.sync_track = sync_track _tline_sync_data.sync_clip_index = sync_clip_index # TImeline media offset for clips sync_clip_start_in_tline = sync_track.clip_start(sync_clip_index) _tline_sync_data.origin_clip_start_in_tline = _tline_sync_data.origin_track.clip_start( _tline_sync_data.origin_clip_index) _tline_sync_data.clip_tline_media_offset = ( sync_clip_start_in_tline - sync_clip.clip_in) - (_tline_sync_data.origin_clip_start_in_tline - _tline_sync_data.origin_clip.clip_in) gdk_window = gui.tline_display.get_parent_window() gdk_window.set_cursor(Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR)) # This or GUI freezes, we really can't do Popen.wait() in a Gtk thread clapperless_thread = ClapperlesLaunchThread( _tline_sync_data.origin_clip.path, sync_clip.path, _tline_sync_offsets_computed_callback) clapperless_thread.start() # Edit consumes selection movemodes.clear_selected_clips() updater.repaint_tline()
def _marker_menu_item_activated(widget, msg): current_frame = PLAYER().current_frame() if msg == "add": dialogs.marker_name_dialog(utils.get_tc_string(current_frame), _marker_add_dialog_callback) elif msg == "delete": mrk_index = -1 for i in range(0, len(current_sequence().markers)): name, frame = current_sequence().markers[i] if frame == current_frame: mrk_index = i if mrk_index != -1: current_sequence().markers.pop(mrk_index) updater.repaint_tline() elif msg == "deleteall": current_sequence().markers = [] updater.repaint_tline() else: # seek to marker name, frame = current_sequence().markers[int(msg)] PLAYER().seek_frame(frame)
def _workflow_menu_callback(widget, data): tool_id, msg = data if msg == "activity": if widget.get_active() == False: editorpersistance.prefs.active_tools.remove(tool_id) else: editorpersistance.prefs.active_tools.append(tool_id) elif msg == "preset standard": _set_workflow_STANDARD() elif msg == "preset filmstyle": _set_workflow_FILM_STYLE() elif msg == "autofollow": active = widget.get_active() editorstate.auto_follow = active PROJECT().set_project_property(appconsts.P_PROP_AUTO_FOLLOW, active) if active == True: # Do autofollow update if auto follow activated compositor_autofollow_data = edit.get_full_compositor_sync_data() edit.do_autofollow_redo(compositor_autofollow_data) updater.repaint_tline() elif msg == "always overwrite": editorpersistance.prefs.dnd_action = appconsts.DND_ALWAYS_OVERWRITE elif msg == "overwrite nonV1": editorpersistance.prefs.dnd_action = appconsts.DND_OVERWRITE_NON_V1 elif msg == "always insert": editorpersistance.prefs.dnd_action = appconsts.DND_ALWAYS_INSERT elif msg == "tooltips": editorpersistance.prefs.show_tool_tooltips = widget.get_active() elif msg == "delete lift" and widget.get_active() == True: print "lift" elif msg == "delete splice" and widget.get_active() == True: print "splice" else: try: pos = int(msg) current_index = editorpersistance.prefs.active_tools.index(tool_id) editorpersistance.prefs.active_tools.remove(tool_id) editorpersistance.prefs.active_tools.insert(pos - 1, tool_id) except: pass editorpersistance.save()
def _add_filter_from_effect_select_panel(row_index, group_index): # Add filter group_name, filters_array = mltfilters.groups[group_index] filter_info = filters_array[row_index] data = { "clip": _filter_stack.clip, "filter_info": filter_info, "filter_edit_done_func": filter_edit_done_stack_update } action = edit.add_filter_action(data) set_stack_update_blocked() action.do_edit() set_stack_update_unblocked() clip, track, clip_index = _filter_stack.get_clip_data() set_clip(clip, track, clip_index) updater.repaint_tline()
def init_sequence_gui(): """ Called after project load or changing current sequence to initialize interface. """ # Set correct compositing mode menu item selected gui.editor_window.init_compositing_mode_menu() gui.editor_window.init_timeline_rendering_menu() # Set initial timeline scale draw params editorstate.current_sequence().update_length() # Handle timeline rendering GUI and data tlinerender.init_for_sequence(editorstate.current_sequence()) gui.editor_window.hide_tline_render_strip() if editorstate.get_tline_rendering_mode() != appconsts.TLINE_RENDERING_OFF: gui.editor_window.show_tline_render_strip() updater.update_pix_per_frame_full_view() updater.init_tline_scale() updater.repaint_tline()
def mouse_press(event, frame): global edit_data, box_selection_data if box_selection_data == None: # mouse action to select press_point = (event.x, event.y) edit_data = {"action_on":True, "press_point":press_point, "mouse_point":press_point, "box_selection_data":None} else: # mouse action to move if box_selection_data.is_hit(event.x, event.y) == False: # Back to start state edit_data = None box_selection_data = None else: edit_data = {"action_on":True, "press_frame":frame, "delta":0, "box_selection_data":box_selection_data} tlinewidgets.set_edit_mode(edit_data, tlinewidgets.draw_overwrite_box_overlay) updater.repaint_tline()
def release_event(self, x,y): """ Mouse release callback. """ lx = self._legalize_x(x) ly = self._legalize_y(y) if abs(self.mouse_start_y - ly) < DRAG_MIN_Y: value_drag_on = True self.mouse_x = lx self.mouse_y = ly if self.current_mouse_action == POSITION_DRAG: frame = self._get_drag_frame(lx) self.current_clip_frame = frame self.clip_editor_frame_changed(self.current_clip_frame) updater.repaint_tline() elif self.current_mouse_action == KF_DRAG or self.current_mouse_action == KF_DRAG_FRAME_ZERO_KF: frame = self._get_drag_frame(lx) if self.current_mouse_action == KF_DRAG_FRAME_ZERO_KF: frame = 0 if self.value_drag_on == True: value = round(self._get_value_for_panel_y(ly)) self.set_active_kf_frame_and_value(frame, value) self.hack_fix_for_zero_one_keyframe_problem() else: self.set_active_kf_frame_and_value(frame, self.edit_value) self.hack_fix_for_zero_one_keyframe_problem() if _playhead_follow_kf == True: self.current_clip_frame = frame self.clip_editor_frame_changed(self.current_clip_frame) self.update_property_value() self.edit_value = None updater.repaint_tline() self.current_mouse_action = None
def mouse_release(x, y, frame, state): if mouse_disabled: return global edit_data press_frame = edit_data["press_frame"] min_allowed_delta = -edit_data["multi_data"].max_backwards delta = frame - press_frame if delta < min_allowed_delta: delta = min_allowed_delta if delta != 0: data = {"edit_delta": delta, "multi_data": edit_data["multi_data"]} action = edit.multi_move_action(data) action.do_edit() edit_data = None tlinewidgets.set_edit_mode_data(edit_data) updater.repaint_tline()
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()
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 _kf_editor != None and _kf_editor.overlay_area_hit(x, y): _handle_edit_mouse_press(event) return # Attempt to init kf tool editing on some clip # Get pressed track track = tlinewidgets.get_track(y) # Selecting empty clears selection if track == None: #clear_selected_clips() #pressed_on_selected = False _set_no_clip_edit_data() updater.repaint_tline() return # Get pressed clip index clip_index = current_sequence().get_clip_index(track, frame) # Selecting empty clears selection if clip_index == -1: #clear_selected_clips() #pressed_on_selected = False _set_no_clip_edit_data() updater.repaint_tline() return clip = track.clips[clip_index] init_tool_for_clip(clip, track)
def select_sync_clip_mouse_pressed(event, frame): sync_clip = _get_sync_tline_clip(event, frame) if sync_clip == None: return # selection wasn't good sync_track = tlinewidgets.get_track(event.y) sync_clip_index = sync_track.clips.index(sync_clip) _tline_sync_data.sync_clip = sync_clip _tline_sync_data.sync_track = sync_track _tline_sync_data.sync_clip_index = sync_clip_index # TImeline media offset for clips sync_clip_start_in_tline = sync_track.clip_start(sync_clip_index) _tline_sync_data.origin_clip_start_in_tline = _tline_sync_data.origin_track.clip_start( _tline_sync_data.origin_clip_index) _tline_sync_data.clip_tline_media_offset = ( sync_clip_start_in_tline - sync_clip.clip_in) - (_tline_sync_data.origin_clip_start_in_tline - _tline_sync_data.origin_clip.clip_in) gdk_window = gui.tline_display.get_parent_window() gdk_window.set_cursor(Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR)) # This or GUI freezes, we really can't do Popen.wait() in a Gtk thread clapperless_thread = ClapperlesLaunchThread( _tline_sync_data.origin_clip.path, sync_clip.path, _tline_sync_offsets_computed_callback) clapperless_thread.start() # Edit consumes selection movemodes.clear_selected_clips() updater.repaint_tline()
def mouse_release(x, y, frame, state): editorstate.edit_mode = prev_edit_mode if editorstate.edit_mode == editorstate.INSERT_MOVE: tlinewidgets.set_edit_mode(None, tlinewidgets.draw_insert_overlay) elif editorstate.edit_mode == editorstate.INSERT_MOVE: tlinewidgets.set_edit_mode(None, tlinewidgets.draw_overwrite_overlay) elif editorstate.edit_mode == editorstate.MULTI_MOVE: tlinewidgets.set_edit_mode(None, tlinewidgets.draw_multi_overlay) else: print "COMPOSITOR MODE EXIT PROBLEM at compositormodes.mouse_release" gui.editor_window.set_cursor_to_mode() if sub_mode == TRIM_EDIT: _bounds_check_trim(frame, edit_data) data = {"compositor":compositor, "clip_in":edit_data["clip_in"], "clip_out":edit_data["clip_out"]} action = edit.move_compositor_action(data) action.do_edit() else: press_frame = edit_data["press_frame"] current_frame = frame delta = current_frame - press_frame data = {"compositor":compositor, "clip_in":compositor.clip_in + delta, "clip_out":compositor.clip_out + delta} if data["clip_in"] < 0: data["clip_in"] = 0 if data["clip_out"] < 0: data["clip_out"] = 0 action = edit.move_compositor_action(data) action.do_edit() updater.repaint_tline()
def delete_effect_pressed(): if len(clip.filters) == 0: return # Block updates until we have set selected row global edit_effect_update_blocked edit_effect_update_blocked = True """ treeselection = widgets.effect_stack_view.treeview.get_selection() (model, rows) = treeselection.get_selected_rows() try: row = rows[0] except: return # This fails when there are filters but no rows are selected """ #row_index = current_filter_index data = { "clip": clip, "index": current_filter_index, "filter_edit_done_func": filter_edit_done } action = edit.remove_filter_action(data) action.do_edit() updater.repaint_tline() # Set last filter selected and display in editor edit_effect_update_blocked = False if len(clip.filters) == 0: effect_selection_changed() # to display info text return path = str(len(clip.filters) - 1) # Causes edit_effect_selected() called as it is the "change" listener widgets.effect_stack_view.treeview.get_selection().select_path(path)
def release_event(self, x, y): """ Mouse release callback. """ lx = self._legalize_x(x) ly = self._legalize_y(y) if self.current_mouse_action == POSITION_DRAG: self._set_clip_frame(lx) self.clip_editor_frame_changed(self.current_clip_frame) self.update_slider_value_display(self.current_clip_frame) elif self.current_mouse_action == KF_DRAG: frame = self._get_drag_frame(lx) value = self._get_value_for_panel_y(ly) self.set_active_kf_frame_and_value(frame, value) self.current_clip_frame = frame self.clip_editor_frame_changed(self.current_clip_frame) self.update_property_value() self.update_slider_value_display(frame) updater.repaint_tline() self.current_mouse_action = None self.drag_on = False
def delete_effect_pressed(): if len(clip.filters) == 0: return # Block updates until we have set selected row global edit_effect_update_blocked edit_effect_update_blocked = True data = {"clip":clip, "index":current_filter_index, "filter_edit_done_func":filter_edit_done} action = edit.remove_filter_action(data) action.do_edit() updater.repaint_tline() # Set last filter selected and display in editor edit_effect_update_blocked = False if len(clip.filters) == 0: effect_selection_changed() # to display info text return path = str(len(clip.filters) - 1) # Causes edit_effect_selected() called as it is the "change" listener widgets.effect_stack_view.treeview.get_selection().select_path(path)
def _audio_levels_item_activated(widget, msg): if msg == "all": editorstate.display_all_audio_levels = True updater.repaint_tline() elif msg == "on request": editorstate.display_all_audio_levels = False current_sequence().drop_audio_levels() updater.repaint_tline() elif msg == "snapping": snapping.snapping_on = widget.get_active() elif msg == "magnet": snapping.show_magnet_icon = widget.get_active() elif msg == "autofollow": active = widget.get_active() editorstate.auto_follow = active PROJECT().set_project_property(appconsts.P_PROP_AUTO_FOLLOW, active) updater.repaint_tline() else: # media thumbnails editorstate.display_clip_media_thumbnails = widget.get_active() updater.repaint_tline()
def _audio_levels_item_activated(widget, msg): if msg == "all": editorstate.display_all_audio_levels = True updater.repaint_tline() elif msg == "on request": editorstate.display_all_audio_levels = False current_sequence().drop_audio_levels() updater.repaint_tline() elif msg == "snapping": snapping.snapping_on = widget.get_active() else: # media thumbnails editorstate.display_clip_media_thumbnails = widget.get_active() updater.repaint_tline()
def _audio_levels_item_activated(widget, msg): if msg == "all": editorstate.display_all_audio_levels = True updater.repaint_tline() elif msg == "on request": editorstate.display_all_audio_levels = False current_sequence().drop_audio_levels() updater.repaint_tline() elif msg == "snapping": snapping.snapping_on = widget.get_active() elif msg == "autofollow": active = widget.get_active() editorstate.auto_follow = active PROJECT().set_project_property(appconsts.P_PROP_AUTO_FOLLOW, active) if active == True: # Do autofollow update if auto follow activated compositor_autofollow_data = edit.get_full_compositor_sync_data() edit.do_autofollow_redo(compositor_autofollow_data) updater.repaint_tline() elif msg == "pointer_sensitive_item": editorstate.cursor_is_tline_sensitive = widget.get_active() else: # media thumbnails editorstate.display_clip_media_thumbnails = widget.get_active() updater.repaint_tline()