Movie Clip: Annotation UI Improvements

Previously, the Annotation panels were a bit buggy in the movie clip editor.
This commit fixes the issue of the panel in the sidebar would disappear
when selecting  "Tracks" if no tracks were added to the clip.
To solve this issue the user if given a label text saying "No annotation source"

This commit also removes some grease pencil operators from the toolbar
that do not work with the new annotation system.

This commit also moves the data source choice from the toolbar to the sidebar.
This is needed to migrate the current toolbar to the new tool system
(see T83612)

Some old invalid code was also removed.

Reviewed By: #grease_pencil, antoniov

Differential Revision: https://developer.blender.org/D9729
This commit is contained in:
Aaron Carlisle 2020-12-19 14:48:36 -05:00 committed by Aaron Carlisle
parent 6538f1e600
commit 0144b70948
1 changed files with 23 additions and 53 deletions

View File

@ -23,28 +23,8 @@ from bpy.types import Menu, UIList, Operator
from bpy.app.translations import pgettext_iface as iface_
def gpencil_stroke_placement_settings(context, layout):
if context.space_data.type == 'VIEW_3D':
propname = "annotation_stroke_placement_view3d"
elif context.space_data.type == 'SEQUENCE_EDITOR':
propname = "annotation_stroke_placement_sequencer_preview"
elif context.space_data.type == 'IMAGE_EDITOR':
propname = "annotation_stroke_placement_image_editor"
else:
propname = "annotation_stroke_placement_view2d"
tool_settings = context.tool_settings
col = layout.column(align=True)
if context.space_data.type != 'VIEW_3D':
col.label(text="Stroke Placement:")
row = col.row(align=True)
row.prop_enum(tool_settings, propname, 'VIEW')
row.prop_enum(tool_settings, propname, 'CURSOR', text="Cursor")
# XXX: To be replaced with active tools
# Currently only used by the clip editor
class AnnotationDrawingToolsPanel:
# subclass must set
# bl_space_type = 'IMAGE_EDITOR'
@ -55,7 +35,8 @@ class AnnotationDrawingToolsPanel:
def draw(self, context):
layout = self.layout
is_3d_view = context.space_data.type == 'VIEW_3D'
tool_settings = context.tool_settings
is_clip_editor = context.space_data.type == 'CLIP_EDITOR'
col = layout.column(align=True)
@ -72,23 +53,10 @@ class AnnotationDrawingToolsPanel:
col.separator()
sub = col.column(align=True)
sub.operator("gpencil.blank_frame_add", icon='FILE_NEW')
sub.operator("gpencil.active_frames_delete_all", icon='X', text="Delete Frame(s)")
col.separator()
col.separator()
if context.space_data.type == 'CLIP_EDITOR':
col.separator()
col.label(text="Data Source:")
row = col.row(align=True)
if is_3d_view:
row.prop(context.tool_settings, "annotation_source", expand=True)
elif is_clip_editor:
row.prop(context.space_data, "annotation_source", expand=True)
gpencil_stroke_placement_settings(context, col)
col.label(text="Stroke Placement:")
row = col.row(align=True)
row.prop_enum(tool_settings, "annotation_stroke_placement_view2d", 'VIEW')
row.prop_enum(tool_settings, "annotation_stroke_placement_view2d", 'CURSOR', text="Cursor")
class GreasePencilSculptOptionsPanel:
@ -447,17 +415,6 @@ class AnnotationDataPanel:
bl_region_type = 'UI'
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
# Show this panel as long as someone that might own this exists
# AND the owner isn't an object (e.g. GP Object)
if context.annotation_data_owner is None:
return False
elif type(context.annotation_data_owner) is bpy.types.Object:
return False
else:
return True
def draw_header(self, context):
if context.space_data.type not in {'VIEW_3D', 'TOPBAR'}:
self.layout.prop(context.space_data, "show_annotation", text="")
@ -466,15 +423,28 @@ class AnnotationDataPanel:
layout = self.layout
layout.use_property_decorate = False
is_clip_editor = context.space_data.type == 'CLIP_EDITOR'
# Grease Pencil owner.
gpd_owner = context.annotation_data_owner
gpd = context.annotation_data
# Owner selector.
if context.space_data.type == 'CLIP_EDITOR':
layout.row().prop(context.space_data, "annotation_source", expand=True)
if is_clip_editor:
col = layout.column()
col.label(text="Data Source:")
row = col.row()
row.prop(context.space_data, "annotation_source", expand=True)
layout.template_ID(gpd_owner, "grease_pencil", new="gpencil.annotation_add", unlink="gpencil.data_unlink")
# Only allow adding annotation ID if its owner exist
if context.annotation_data_owner is None:
row = layout.row()
row.active = False
row.label(text="No annotation source")
return
row = layout.row()
row.template_ID(gpd_owner, "grease_pencil", new="gpencil.annotation_add", unlink="gpencil.data_unlink")
# List of layers/notes.
if gpd and gpd.layers: