diff options
Diffstat (limited to 'release/scripts/startup/bl_ui/properties_grease_pencil_common.py')
-rw-r--r-- | release/scripts/startup/bl_ui/properties_grease_pencil_common.py | 76 |
1 files changed, 23 insertions, 53 deletions
diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py index c663a736441..de4937a959a 100644 --- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -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: |