From 8e3b3871e67facf0c0175c3745b890fe5e53202c Mon Sep 17 00:00:00 2001 From: Pullusb Date: Fri, 7 Oct 2022 02:20:28 +0200 Subject: [PATCH] code fix on operators and draw cam handler 2.0.5 - changed: redo panel for GP layer picker has better name and display active layer name - changed: some operator id_name to expose "add shortcut" in context menu for some button - fixed: error with draw_cam handler when no camera is active --- CHANGELOG.md | 6 ++++++ OP_helpers.py | 14 +++++++------- OP_layer_picker.py | 9 ++++++++- UI_tools.py | 13 ++++++------- __init__.py | 2 +- handler_draw_cam.py | 2 +- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4b5045..70e4d9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +2.0.5 + +- changed: redo panel for GP layer picker has better name and display active layer name +- changed: some operator id_name to expose "add shortcut" in context menu for some button +- fixed: error with draw_cam handler when no camera is active + 2.0.3 - changed: `X-ray` to `In Front`, match original object property name diff --git a/OP_helpers.py b/OP_helpers.py index 0dafaa6..7485847 100644 --- a/OP_helpers.py +++ b/OP_helpers.py @@ -11,7 +11,7 @@ from . import utils class GPTB_OT_copy_text(bpy.types.Operator): bl_idname = "wm.copytext" - bl_label = "Copy to clipboard" + bl_label = "Copy To Clipboard" bl_description = "Insert passed text to clipboard" bl_options = {"REGISTER", "INTERNAL"} @@ -24,8 +24,8 @@ class GPTB_OT_copy_text(bpy.types.Operator): return {"FINISHED"} class GPTB_OT_flipx_view(bpy.types.Operator): - bl_idname = "gp.mirror_flipx" - bl_label = "cam mirror flipx" + bl_idname = "view3d.camera_mirror_flipx" + bl_label = "Cam Mirror Flipx" bl_description = "Invert X scale on camera to flip image horizontally" bl_options = {"REGISTER"} @@ -39,7 +39,7 @@ class GPTB_OT_flipx_view(bpy.types.Operator): class GPTB_OT_rename_data_from_obj(bpy.types.Operator): bl_idname = "gp.rename_data_from_obj" - bl_label = "Rename GP from object" + bl_label = "Rename GP From Object" bl_description = "Rename the GP datablock with the same name as the object" bl_options = {"REGISTER"} @@ -120,7 +120,7 @@ def get_gp_alignement_vector(context): class GPTB_OT_draw_cam(bpy.types.Operator): bl_idname = "gp.draw_cam_switch" - bl_label = "Draw cam switch" + bl_label = "Draw Cam Switch" bl_description = "switch between main camera and draw (manipulate) camera" bl_options = {"REGISTER"} @@ -245,7 +245,7 @@ class GPTB_OT_draw_cam(bpy.types.Operator): class GPTB_OT_set_view_as_cam(bpy.types.Operator): bl_idname = "gp.set_view_as_cam" - bl_label = "Cam at view" + bl_label = "Cam At View" bl_description = "Place the active camera at current viewpoint, parent to active object. (need to be out of camera)" bl_options = {"REGISTER"} @@ -286,7 +286,7 @@ class GPTB_OT_set_view_as_cam(bpy.types.Operator): class GPTB_OT_reset_cam_rot(bpy.types.Operator): bl_idname = "gp.reset_cam_rot" - bl_label = "Reset rotation" + bl_label = "Reset Rotation" bl_description = "Reset rotation of the draw manipulation camera" bl_options = {"REGISTER"} diff --git a/OP_layer_picker.py b/OP_layer_picker.py index fd871c4..d4e46f3 100644 --- a/OP_layer_picker.py +++ b/OP_layer_picker.py @@ -16,7 +16,8 @@ class GP_OT_pick_closest_layer(Operator): def poll(cls, context): return context.object and context.object.type == 'GPENCIL' and context.mode == 'PAINT_GPENCIL' - stroke_filter : bpy.props.EnumProperty(default='STROKE', + stroke_filter : bpy.props.EnumProperty(name='Target', + default='STROKE', items=( ('STROKE', 'Stroke', 'Target only Stroke', 0), ('FILL', 'Fill', 'Target only Fill', 1), @@ -43,6 +44,12 @@ class GP_OT_pick_closest_layer(Operator): context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} + def draw(self, context): + layout = self.layout + if context.object.data.layers.active: + layout.label(text=f'Layer: {context.object.data.layers.active.info}') + layout.prop(self, 'stroke_filter') + def modal(self, context, event): if time() > self.limit: return {'CANCELLED'} diff --git a/UI_tools.py b/UI_tools.py index a23e30f..6af9dd2 100644 --- a/UI_tools.py +++ b/UI_tools.py @@ -58,15 +58,14 @@ class GPTB_PT_sidebar_panel(Panel): # layout.label(text='View options:') col = layout.column() + ## flip X cam - if context.scene.camera and context.scene.camera.scale.x < 0: - # layout.label(text='! Flipped !') - row = col.row(align=True) + # layout.label(text='! Flipped !') + row = col.row(align=True) - row.operator('gp.mirror_flipx', text = 'Mirror flip', icon = 'MOD_MIRROR')# ARROW_LEFTRIGHT + row.operator('view3d.camera_mirror_flipx', text = 'Mirror Flip', icon = 'MOD_MIRROR')# ARROW_LEFTRIGHT + if context.scene.camera and context.scene.camera.scale.x < 0: row.label(text='',icon='LOOP_BACK') - else: - col.operator('gp.mirror_flipx', text = 'Mirror flip', icon = 'MOD_MIRROR')# ARROW_LEFTRIGHT ## draw/manipulation camera if context.scene.camera and context.scene.camera.name.startswith(('draw', 'obj')): @@ -130,7 +129,7 @@ class GPTB_PT_sidebar_panel(Panel): ## Straight line ops from official greasepencil_tools addon if enabled. # if any(x in context.preferences.addons.keys() for x in ('greasepencil_tools', 'greasepencil-addon')): # check enabled addons if hasattr(bpy.types, 'GP_OT_straight_stroke'): # check if operator exists : bpy.ops.gp.straight_stroke.idname() - layout.operator('gp.straight_stroke', icon ="CURVE_PATH") + layout.operator(bpy.types.GP_OT_straight_stroke.bl_idname, icon ="CURVE_PATH") ## Options col = layout.column() diff --git a/__init__.py b/__init__.py index 34d969e..0cc898c 100755 --- a/__init__.py +++ b/__init__.py @@ -4,7 +4,7 @@ bl_info = { "name": "GP toolbox", "description": "Tool set for Grease Pencil in animation production", "author": "Samuel Bernou, Christophe Seux", -"version": (2, 0, 4), +"version": (2, 0, 5), "blender": (2, 91, 0), "location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties", "warning": "", diff --git a/handler_draw_cam.py b/handler_draw_cam.py index 1088c20..ef4fffc 100644 --- a/handler_draw_cam.py +++ b/handler_draw_cam.py @@ -34,7 +34,7 @@ def draw_cam_frame_callback_2d(): context = bpy.context if context.region_data.view_perspective != 'CAMERA': return - if context.scene.camera.name != 'draw_cam': + if not context.scene.camera or context.scene.camera.name != 'draw_cam': return main_cam = context.scene.camera.parent