From b9dd1196ca3dff61fccd502b245e175df6334424 Mon Sep 17 00:00:00 2001 From: Pullusb Date: Wed, 31 Mar 2021 01:38:17 +0200 Subject: [PATCH] better cam ref UI and clear keyframe ops 1.0.4: - UI: Better cam ref exposition in Toolbox panel - Access to opacity - merge activation bool with source type icon - feat: Added a clear active frame operator (`gp.clear_active_frame` to add manually in keymaps) --- OP_helpers.py | 33 +++++++++++++++++++++++++++++++++ README.md | 8 ++++++++ UI_tools.py | 17 +++++++++++------ __init__.py | 11 +++++++++-- 4 files changed, 61 insertions(+), 8 deletions(-) diff --git a/OP_helpers.py b/OP_helpers.py index 9bee037..03a014b 100644 --- a/OP_helpers.py +++ b/OP_helpers.py @@ -449,6 +449,38 @@ class GPTB_OT_overlay_presets(bpy.types.Operator): return {'FINISHED'} +class GPTB_OT_clear_active_frame(bpy.types.Operator): + bl_idname = "gp.clear_active_frame" + bl_label = "Clear Active Frame" + bl_description = "Delete all strokes in active frames" + bl_options = {"REGISTER"} + + @classmethod + def poll(cls, context): + return context.object and context.object.type == 'GPENCIL' + + def execute(self, context): + obj = context.object + l = obj.data.layers.active + if not l: + self.report({'ERROR'}, 'No layers') + return {'CANCELLED'} + f = l.active_frame + if not f: + self.report({'ERROR'}, 'No active frame') + return {'CANCELLED'} + + ct = len(f.strokes) + if not ct: + self.report({'ERROR'}, 'Active frame already empty') + return {'CANCELLED'} + + for s in reversed(f.strokes): + f.strokes.remove(s) + self.report({'INFO'}, f'Cleared active frame ({ct} strokes removed)') + + return {'FINISHED'} + classes = ( GPTB_OT_copy_text, GPTB_OT_flipx_view, @@ -458,6 +490,7 @@ GPTB_OT_set_view_as_cam, GPTB_OT_reset_cam_rot, GPTB_OT_toggle_mute_animation, GPTB_OT_list_disabled_anims, +GPTB_OT_clear_active_frame, ) def register(): diff --git a/README.md b/README.md index cbc8a94..9b7601f 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,14 @@ Panel in sidebar : 3D view > sidebar 'N' > Gpencil ## Changelog: + +1.0.4: + +- UI: Better cam ref exposition in Toolbox panel + - Access to opacity + - merge activation bool with source type icon +- feat: Added a clear active frame operator (`gp.clear_active_frame` to add manually in keymaps) + 1.0.3: - feat: add "Append Materials To Selected" to material submenu. Append materials to other selected GP objects if there aren't there. diff --git a/UI_tools.py b/UI_tools.py index 6413c8d..c6bc510 100644 --- a/UI_tools.py +++ b/UI_tools.py @@ -99,14 +99,19 @@ class GPTB_PT_sidebar_panel(bpy.types.Panel): for bg_img in context.scene.camera.data.background_images: if bg_img.source == 'IMAGE' and bg_img.image: row = box.row(align=True) - row.label(text=bg_img.image.name, icon='IMAGE_RGB')# FILE_IMAGE - # row.prop(bg_img, 'alpha', text='')# options={'HIDDEN'} - row.prop(bg_img, 'show_background_image', text='')# options={'HIDDEN'} + row.prop(bg_img, 'show_background_image', text='', icon='IMAGE_RGB') + row.prop(bg_img, 'alpha', text=bg_img.image.name) # options={'HIDDEN'} + # row.label(icon='IMAGE_RGB') + # icon = 'HIDE_OFF' if bg_img.show_background_image else 'HIDE_ON' + # row.prop(bg_img, 'show_background_image', text='', icon=icon) + if bg_img.source == 'MOVIE_CLIP' and bg_img.clip: row = box.row(align=True) - row.label(text=bg_img.clip.name, icon='FILE_MOVIE') - # row.prop(bg_img, 'alpha', text='')# options={'HIDDEN'} - row.prop(bg_img, 'show_background_image', text='')# options={'HIDDEN'} + row.prop(bg_img, 'show_background_image', text='', icon='FILE_MOVIE') + row.prop(bg_img, 'alpha', text=bg_img.clip.name) # options={'HIDDEN'} + # row.label(icon='FILE_MOVIE') + # icon = 'HIDE_OFF' if bg_img.show_background_image else 'HIDE_ON' + # row.prop(bg_img, 'show_background_image', text='', icon=icon) ## playblast params layout.separator() diff --git a/__init__.py b/__init__.py index bf71677..893a83a 100644 --- a/__init__.py +++ b/__init__.py @@ -15,7 +15,7 @@ bl_info = { "name": "GP toolbox", "description": "Set of tools for Grease Pencil in animation production", "author": "Samuel Bernou", -"version": (1, 0, 3), +"version": (1, 0, 4), "blender": (2, 91, 0), "location": "sidebar (N menu) > Gpencil > Toolbox / Gpencil properties", "warning": "", @@ -371,7 +371,7 @@ class GPTB_prefs(bpy.types.AddonPreferences): if self.pref_tabs == 'MAN_OPS': # layout.separator()## notes # layout.label(text='Notes:') - layout.label(text='Following operators ID have to be set manually :') + layout.label(text='Following operators ID have to be set manually in keymap if needed :') ## keyframe jump box = layout.box() @@ -391,6 +391,13 @@ class GPTB_prefs(bpy.types.AddonPreferences): row.label(text='Replace wanted by "view3d.cusor_snap"') row.operator('wm.copytext', text='Copy "view3d.cusor_snap"', icon='COPYDOWN').text = 'view3d.cusor_snap' box.label(text='Or just create a new shortcut using cursor_snap') + + ## Clear keyframe + box = layout.box() + box.label(text='Clear active frame (delete all strokes without deleting the frame)') + row = box.row() + row.label(text='gp.clear_active_frame') + row.operator('wm.copytext', icon='COPYDOWN').text = 'gp.clear_active_frame' ## user prefs box = layout.box()