本文整理汇总了Python中tlinewidgets.get_track函数的典型用法代码示例。如果您正苦于以下问题:Python get_track函数的具体用法?Python get_track怎么用?Python get_track使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_track函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_selection_data
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
示例2: oneroll_trim_press
def oneroll_trim_press(event, frame):
"""
User presses mouse when in one roll mode.
"""
global mouse_disabled, submode
if not _pressed_on_edited_track(event.y):
track = tlinewidgets.get_track(event.y)
success = set_oneroll_mode(track, frame)
if not success:
if editorpersistance.prefs.empty_click_exits_trims == True:
set_exit_mode_func(True) # further mouse events are handled at editevent.py
else:
set_no_edit_mode_func() # further mouse events are handled at editevent.py
else:
submode = MOUSE_EDIT_ON # to stop entering keyboard edits until mouse released
if not editorpersistance.prefs.quick_enter_trims:
# new trim inited, editing non-active until release
tlinewidgets.trim_mode_in_non_active_state = True
gui.tline_canvas.widget.queue_draw()
gui.editor_window.set_tline_cursor(editorstate.ONE_ROLL_TRIM_NO_EDIT)
mouse_disabled = True
else:
# new trim inited, active immediately
oneroll_trim_move(event.x, event.y, frame, None)
gui.tline_canvas.widget.queue_draw()
return
if not _pressed_on_one_roll_active_area(frame):
track = tlinewidgets.get_track(event.y)
success = set_oneroll_mode(track, frame)
if not success:
if editorpersistance.prefs.empty_click_exits_trims == True:
set_exit_mode_func(True) # further mouse events are handled at editevent.py
else:
set_no_edit_mode_func() # no furter mouse events will come here
else:
submode = MOUSE_EDIT_ON # to stop entering keyboard edits until mouse released
if not editorpersistance.prefs.quick_enter_trims:
# new trim inited, editing non-active until release
tlinewidgets.trim_mode_in_non_active_state = True
gui.tline_canvas.widget.queue_draw()
gui.editor_window.set_tline_cursor(editorstate.ONE_ROLL_TRIM_NO_EDIT)
mouse_disabled = True
else:
# new trim inited, active immediately
oneroll_trim_move(event.x, event.y, frame, None)
gui.tline_canvas.widget.queue_draw()
return
# Get legal edit delta and set to edit mode data for overlay draw
global edit_data
frame = _legalize_one_roll_trim(frame, edit_data["trim_limits"])
edit_data["selected_frame"] = frame
PLAYER().seek_frame(frame)
示例3: display_clip_menu
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 editevent.track_lock_check_and_user_info(track, display_clip_menu, "clip context menu"):
return False
# Display popup
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
示例4: tline_canvas_double_click
def tline_canvas_double_click(frame, x, y):
if PLAYER().looping():
return
elif PLAYER().is_playing():
PLAYER().stop_playback()
if not timeline_visible():
updater.display_sequence_in_monitor()
set_default_edit_mode()
return
hit_compositor = tlinewidgets.compositor_hit(frame, y, current_sequence().compositors)
if hit_compositor != None:
compositeeditor.set_compositor(hit_compositor)
return
track = tlinewidgets.get_track(y)
if track == None:
return
clip_index = current_sequence().get_clip_index(track, frame)
if clip_index == -1:
return
clip = track.clips[clip_index]
data = (clip, track, None, x)
updater.open_clip_in_effects_editor(data)
示例5: _move_mode_move
def _move_mode_move(frame, x, y):
"""
Updates edit data needed for doing edit and drawing overlay
based on mouse movement.
"""
global edit_data
# Get frame that is the one where insert is attempted
press_frame = edit_data["press_frame"]
first_clip_start = edit_data["first_clip_start"]
attempt_insert_frame = first_clip_start + (frame - press_frame)
edit_data["attempt_insert_frame"] = attempt_insert_frame
# Get track where insert is attempted. Track selection forced into range of editable tracks.
to_track = tlinewidgets.get_track(y)
if to_track == None:
if y > tlinewidgets.REF_LINE_Y:
to_track = get_track(1)
else:
to_track = get_track(len(current_sequence().tracks) - 2)
if to_track.id < 1:
to_track = get_track(1)
if to_track.id > len(current_sequence().tracks) - 2:
to_track = get_track(len(current_sequence().tracks) - 2)
edit_data["to_track_object"] = to_track
# Get index for insert in target track
insert_index = to_track.get_clip_index_at(attempt_insert_frame)
edit_data["insert_index"] = insert_index
edit_data["insert_frame"] = to_track.clip_start(insert_index)
_set_current_move_frame_and_check_move_start(frame, x, y)
示例6: mouse_press
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 _clip_is_being_edited() and _clip_edit_area_hit(x, y):
return
# 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]
# Save data needed to do the keyframe edits.
global edit_data #, pressed_on_selected, drag_disabled
edit_data = {"draw_function":_tline_overlay,
"clip_index":clip_index,
"clip":clip,
"track":track,
"mouse_start_x":x,
"mouse_start_y":y}
# Init for volume editing if volume filter available
for i in range(0, len(clip.filters)):
filter_object = clip.filters[i]
if filter_object.info.mlt_service_id == "volume":
editable_properties = propertyedit.get_filter_editable_properties(
clip,
filter_object,
i,
track,
clip_index)
for ep in editable_properties:
if ep.name == "gain":
_init_for_editable_property(ep)
tlinewidgets.set_edit_mode_data(edit_data)
updater.repaint_tline()
示例7: track_center_pressed
def track_center_pressed(data):
if data.event.button == 1:
# handle possible mute icon presses
press_x = data.event.x
press_y = data.event.y
track = tlinewidgets.get_track(press_y)
if track == None:
return
y_off = press_y - tlinewidgets._get_track_y(track.id)
ICON_WIDTH = 12
if press_x > tlinewidgets.COLUMN_LEFT_PAD and press_x < tlinewidgets.COLUMN_LEFT_PAD + ICON_WIDTH:
# Mute icon x area hit
ix, iy = tlinewidgets.MUTE_ICON_POS
if track.height > appconsts.TRACK_HEIGHT_SMALL:
ix, iy = tlinewidgets.MUTE_ICON_POS_NORMAL
ICON_HEIGHT = 10
if track.id >= current_sequence().first_video_index:
# Video tracks
# Test mute switches
if y_off > iy and y_off < iy + ICON_HEIGHT:
# Video mute icon hit
if track.mute_state == appconsts.TRACK_MUTE_NOTHING:
new_mute_state = appconsts.TRACK_MUTE_VIDEO
elif track.mute_state == appconsts.TRACK_MUTE_VIDEO:
new_mute_state = appconsts.TRACK_MUTE_NOTHING
elif track.mute_state == appconsts.TRACK_MUTE_AUDIO:
new_mute_state = appconsts.TRACK_MUTE_ALL
elif track.mute_state == appconsts.TRACK_MUTE_ALL:
new_mute_state = appconsts.TRACK_MUTE_AUDIO
elif y_off > iy + ICON_HEIGHT and y_off < iy + ICON_HEIGHT * 2:
# Audio mute icon hit
if track.mute_state == appconsts.TRACK_MUTE_NOTHING:
new_mute_state = appconsts.TRACK_MUTE_AUDIO
elif track.mute_state == appconsts.TRACK_MUTE_VIDEO:
new_mute_state = appconsts.TRACK_MUTE_ALL
elif track.mute_state == appconsts.TRACK_MUTE_AUDIO:
new_mute_state = appconsts.TRACK_MUTE_NOTHING
elif track.mute_state == appconsts.TRACK_MUTE_ALL:
new_mute_state = appconsts.TRACK_MUTE_VIDEO
else:
return
else:
# Audio tracks
# Test mute switches
iy = iy + 6 # Mute icon is lower on audio tracks
if y_off > iy and y_off < iy + ICON_HEIGHT:
if track.mute_state == appconsts.TRACK_MUTE_VIDEO:
new_mute_state = appconsts.TRACK_MUTE_ALL
else:
new_mute_state = appconsts.TRACK_MUTE_VIDEO
else:
return
# Update track mute state
current_sequence().set_track_mute_state(track.id, new_mute_state)
gui.tline_column.widget.queue_draw()
if data.event.button == 3:
guicomponents.display_tracks_popup_menu(data.event, data.track, \
_track_menu_item_activated)
示例8: tline_media_drop
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)
示例9: maybe_init_for_mouse_press
def maybe_init_for_mouse_press(event, frame):
# See if we actually hit a clip
track = tlinewidgets.get_track(event.y)
if track == None:
return
if track.id < 1 or (track.id >= len(current_sequence().tracks) - 1):
return False
clip_index = current_sequence().get_clip_index(track, frame)
if clip_index == -1:
return
clip = track.clips[clip_index]
if clip.is_blanck_clip:
return
# Now we will in fact enter CLIP_END_DRAG edit mode
# See if we're dragging clip end or start
cut_frame = current_sequence().get_closest_cut_frame(track.id, frame)
editing_clip_end = True
if frame >= cut_frame:
editing_clip_end = False
else:
cut_frame = cut_frame - (clip.clip_out - clip.clip_in)
if editing_clip_end == True: # clip end drags
bound_end = (
cut_frame - clip.clip_in + clip.get_length() - 1
) # get_length() is available media length, not current clip length
bound_start = cut_frame - 1
if clip_index == len(track.clips) - 1: # last clip
bound_end = bound_end - 1
else: # clip beginning drags
bound_start = cut_frame - clip.clip_in
bound_end = cut_frame + (clip.clip_out - clip.clip_in) + 1
global _enter_mode, _enter_draw_func, _edit_data
_enter_mode = editorstate.edit_mode
editorstate.edit_mode = editorstate.CLIP_END_DRAG
_enter_draw_func = tlinewidgets.canvas_widget.edit_mode_overlay_draw_func
_edit_data = {}
_edit_data["track"] = track
_edit_data["clip_index"] = clip_index
_edit_data["frame"] = frame
_edit_data["press_frame"] = frame
_edit_data["editing_clip_end"] = editing_clip_end
_edit_data["bound_end"] = bound_end
_edit_data["bound_start"] = bound_start
_edit_data["track_height"] = track.height
_edit_data["orig_in"] = cut_frame - 1
_edit_data["orig_out"] = cut_frame + (clip.clip_out - clip.clip_in)
tlinewidgets.set_edit_mode(_edit_data, tlinewidgets.draw_clip_end_drag_overlay)
gui.editor_window.set_cursor_to_mode()
示例10: is_hit
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
示例11: cut_single_track
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()
示例12: mouse_press
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()
示例13: tline_range_item_drop
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)
示例14: cut_single_track
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()
示例15: _set_sync_parent_clip
def _set_sync_parent_clip(event, frame):
child_clip, child_index, child_clip_track = parent_selection_data
parent_track = tlinewidgets.get_track(event.y)
if parent_track != current_sequence().tracks[current_sequence().first_video_index]:
dialogutils.warning_message(
_("Sync parent clips must be on track V1"),
_("Selected sync parent clip is on track ")
+ utils.get_track_name(parent_track, current_sequence())
+ _(".\nYou can only sync to clips that are on track V1."),
gui.editor_window.window,
True,
)
return
# this can't have parent clip already
if child_clip.sync_data != None:
return
if parent_track == None:
return
parent_clip_index = current_sequence().get_clip_index(parent_track, frame)
if parent_clip_index == -1:
return
# Parent and child can't be on the same track.
# Now that all parent clips must be on track V1 this is no longer shoild be possible.
if parent_track == child_clip_track:
print "parent_track == child_clip_track"
return
parent_clip = parent_track.clips[parent_clip_index]
# These cannot be chained.
# Now that all parent clips must be on track V1 this is no longer shoild be possible.
if parent_clip.sync_data != None:
print "parent_clip.sync_data != None"
return
data = {
"child_index": child_index,
"child_track": child_clip_track,
"parent_index": parent_clip_index,
"parent_track": parent_track,
}
action = edit.set_sync_action(data)
action.do_edit()