Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/properties_grease_pencil_common.py
| Show First 20 Lines • Show All 575 Lines • ▼ Show 20 Lines | class AnnotationDataPanel: | ||||
| bl_label = "Annotations" | bl_label = "Annotations" | ||||
| bl_region_type = 'UI' | bl_region_type = 'UI' | ||||
| bl_options = {'DEFAULT_CLOSED'} | bl_options = {'DEFAULT_CLOSED'} | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| # Show this panel as long as someone that might own this exists | # Show this panel as long as someone that might own this exists | ||||
| # AND the owner isn't an object (e.g. GP Object) | # AND the owner isn't an object (e.g. GP Object) | ||||
| if context.gpencil_data_owner is None: | if context.annotation_data_owner is None: | ||||
| return False | return False | ||||
| elif type(context.gpencil_data_owner) is bpy.types.Object: | elif type(context.annotation_data_owner) is bpy.types.Object: | ||||
| return False | return False | ||||
| else: | else: | ||||
| return True | return True | ||||
| def draw_header(self, context): | def draw_header(self, context): | ||||
| if context.space_data.type not in {'VIEW_3D', 'TOPBAR'}: | if context.space_data.type not in {'VIEW_3D', 'TOPBAR'}: | ||||
| self.layout.prop(context.space_data, "show_annotation", text="") | self.layout.prop(context.space_data, "show_annotation", text="") | ||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| layout.use_property_decorate = False | layout.use_property_decorate = False | ||||
| # Grease Pencil owner. | # Grease Pencil owner. | ||||
| gpd_owner = context.gpencil_data_owner | gpd_owner = context.annotation_data_owner | ||||
| gpd = context.gpencil_data | gpd = context.annotation_data | ||||
| # Owner selector. | # Owner selector. | ||||
| if context.space_data.type == 'CLIP_EDITOR': | if context.space_data.type == 'CLIP_EDITOR': | ||||
| layout.row().prop(context.space_data, "grease_pencil_source", expand=True) | layout.row().prop(context.space_data, "grease_pencil_source", expand=True) | ||||
| layout.template_ID(gpd_owner, "grease_pencil", new="gpencil.data_add", unlink="gpencil.data_unlink") | layout.template_ID(gpd_owner, "grease_pencil", new="gpencil.annotation_add", unlink="gpencil.data_unlink") | ||||
| # List of layers/notes. | # List of layers/notes. | ||||
| if gpd and gpd.layers: | if gpd and gpd.layers: | ||||
| self.draw_layers(context, layout, gpd) | self.draw_layers(context, layout, gpd) | ||||
| def draw_layers(self, context, layout, gpd): | def draw_layers(self, context, layout, gpd): | ||||
| row = layout.row() | row = layout.row() | ||||
| col = row.column() | col = row.column() | ||||
| if len(gpd.layers) >= 2: | if len(gpd.layers) >= 2: | ||||
| layer_rows = 5 | layer_rows = 5 | ||||
| else: | else: | ||||
| layer_rows = 3 | layer_rows = 3 | ||||
| col.template_list("GPENCIL_UL_annotation_layer", "", gpd, "layers", gpd.layers, "active_index", | col.template_list("GPENCIL_UL_annotation_layer", "", gpd, "layers", gpd.layers, "active_index", | ||||
| rows=layer_rows, sort_reverse=True, sort_lock=True) | rows=layer_rows, sort_reverse=True, sort_lock=True) | ||||
| col = row.column() | col = row.column() | ||||
| sub = col.column(align=True) | sub = col.column(align=True) | ||||
| sub.operator("gpencil.layer_add", icon='ADD', text="") | sub.operator("gpencil.layer_annotation_add", icon='ADD', text="") | ||||
| sub.operator("gpencil.layer_remove", icon='REMOVE', text="") | sub.operator("gpencil.layer_annotation_remove", icon='REMOVE', text="") | ||||
| gpl = context.active_gpencil_layer | gpl = context.active_annotation_layer | ||||
| if gpl: | if gpl: | ||||
| if len(gpd.layers) > 1: | if len(gpd.layers) > 1: | ||||
| col.separator() | col.separator() | ||||
| sub = col.column(align=True) | sub = col.column(align=True) | ||||
| sub.operator("gpencil.layer_move", icon='TRIA_UP', text="").type = 'UP' | sub.operator("gpencil.layer_annotation_move", icon='TRIA_UP', text="").type = 'UP' | ||||
| sub.operator("gpencil.layer_move", icon='TRIA_DOWN', text="").type = 'DOWN' | sub.operator("gpencil.layer_annotation_move", icon='TRIA_DOWN', text="").type = 'DOWN' | ||||
| tool_settings = context.tool_settings | tool_settings = context.tool_settings | ||||
| if gpd and gpl: | if gpd and gpl: | ||||
| layout.prop(gpl, "thickness") | layout.prop(gpl, "thickness") | ||||
| else: | else: | ||||
| layout.prop(tool_settings, "annotation_thickness", text="Thickness") | layout.prop(tool_settings, "annotation_thickness", text="Thickness") | ||||
| if gpl: | if gpl: | ||||
| # Full-Row - Frame Locking (and Delete Frame) | # Full-Row - Frame Locking (and Delete Frame) | ||||
| row = layout.row(align=True) | row = layout.row(align=True) | ||||
| row.active = not gpl.lock | row.active = not gpl.lock | ||||
| if gpl.active_frame: | if gpl.active_frame: | ||||
| lock_status = iface_("Locked") if gpl.lock_frame else iface_("Unlocked") | lock_status = iface_("Locked") if gpl.lock_frame else iface_("Unlocked") | ||||
| lock_label = iface_("Frame: %d (%s)") % (gpl.active_frame.frame_number, lock_status) | lock_label = iface_("Frame: %d (%s)") % (gpl.active_frame.frame_number, lock_status) | ||||
| else: | else: | ||||
| lock_label = iface_("Lock Frame") | lock_label = iface_("Lock Frame") | ||||
| row.prop(gpl, "lock_frame", text=lock_label, icon='UNLOCKED') | row.prop(gpl, "lock_frame", text=lock_label, icon='UNLOCKED') | ||||
| row.operator("gpencil.active_frame_delete", text="", icon='X') | row.operator("gpencil.annotation_active_frame_delete", text="", icon='X') | ||||
| class AnnotationOnionSkin: | class AnnotationOnionSkin: | ||||
| bl_label = "Onion Skin" | bl_label = "Onion Skin" | ||||
| bl_region_type = 'UI' | bl_region_type = 'UI' | ||||
| bl_options = {'DEFAULT_CLOSED'} | bl_options = {'DEFAULT_CLOSED'} | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| # Show this panel as long as someone that might own this exists | # Show this panel as long as someone that might own this exists | ||||
| # AND the owner isn't an object (e.g. GP Object) | # AND the owner isn't an object (e.g. GP Object) | ||||
| if context.gpencil_data_owner is None: | if context.annotation_data_owner is None: | ||||
| return False | return False | ||||
| elif type(context.gpencil_data_owner) is bpy.types.Object: | elif type(context.annotation_data_owner) is bpy.types.Object: | ||||
| return False | return False | ||||
| else: | else: | ||||
| gpl = context.active_gpencil_layer | gpl = context.active_annotation_layer | ||||
| if gpl is None: | if gpl is None: | ||||
| return False | return False | ||||
| return True | return True | ||||
| def draw_header(self, context): | def draw_header(self, context): | ||||
| gpl = context.active_gpencil_layer | gpl = context.active_annotation_layer | ||||
| self.layout.prop(gpl, "use_annotation_onion_skinning", text="") | self.layout.prop(gpl, "use_annotation_onion_skinning", text="") | ||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| layout.use_property_decorate = False | layout.use_property_decorate = False | ||||
| gpl = context.active_gpencil_layer | gpl = context.active_annotation_layer | ||||
| col = layout.column() | col = layout.column() | ||||
| split = col.split(factor=0.5) | split = col.split(factor=0.5) | ||||
| split.active = gpl.use_annotation_onion_skinning | split.active = gpl.use_annotation_onion_skinning | ||||
| # - Before Frames | # - Before Frames | ||||
| sub = split.column(align=True) | sub = split.column(align=True) | ||||
| row = sub.row(align=True) | row = sub.row(align=True) | ||||
| row.prop(gpl, "annotation_onion_before_color", text="") | row.prop(gpl, "annotation_onion_before_color", text="") | ||||
| ▲ Show 20 Lines • Show All 279 Lines • Show Last 20 Lines | |||||