flame: maintained segment selection

This commit is contained in:
Jakub Jezek 2022-01-05 22:32:07 +01:00
parent 9d0e3363c5
commit 5d39784abb
No known key found for this signature in database
GPG key ID: D8548FBF690B100A
2 changed files with 41 additions and 30 deletions

View file

@ -393,15 +393,13 @@ def set_segment_pype_tag(segment, data=None):
tag_data.update(data)
# update marker with tag data
marker.comment = json.dumps(tag_data)
return True
else:
# update tag data with new data
marker = create_pype_marker(segment)
# add tag data to marker's comment
marker.comment = json.dumps(data)
return True
return True
@ -486,4 +484,43 @@ def create_pype_marker(segment):
# set colour
marker.colour = ctx.marker_color
return marker
return marker
@contextlib.contextmanager
def maintained_segment_selection(sequence):
"""Maintain selection during context
Example:
>>> with maintained_selection():
... node['selected'].setValue(True)
>>> print(node['selected'].value())
False
"""
selected_segments = []
for ver in sequence.versions:
for track in ver.tracks:
if len(track.segments) == 0 and track.hidden:
continue
for segment in track.segments:
if segment.selected != True:
continue
selected_segments.append(segment)
try:
# do the operation
yield
finally:
reset_segment_selection(sequence)
for segment in selected_segments:
segment.selected = True
def reset_segment_selection(sequence):
"""Deselect all selected nodes
"""
for ver in sequence.versions:
for track in ver.tracks:
if len(track.segments) == 0 and track.hidden:
continue
for segment in track.segments:
segment.selected = False

View file

@ -97,32 +97,6 @@ def update_container(tl_segment, data=None):
# TODO: update_container
pass
@contextlib.contextmanager
def maintained_selection():
"""Maintain selection during context
Example:
>>> with maintained_selection():
... node['selected'].setValue(True)
>>> print(node['selected'].value())
False
"""
# TODO: maintained_selection + remove undo steps
try:
# do the operation
yield
finally:
pass
def reset_selection():
"""Deselect all selected nodes
"""
pass
def on_pyblish_instance_toggled(instance, old_value, new_value):
"""Toggle node passthrough states on instance toggles."""