mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
flame: maintained segment selection
This commit is contained in:
parent
9d0e3363c5
commit
5d39784abb
2 changed files with 41 additions and 30 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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."""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue