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 activegpv2
parent
43a28876d1
commit
8e3b3871e6
|
@ -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
|
||||
|
|
|
@ -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"}
|
||||
|
||||
|
|
|
@ -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'}
|
||||
|
|
15
UI_tools.py
15
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)
|
||||
|
||||
row.operator('gp.mirror_flipx', text = 'Mirror flip', icon = 'MOD_MIRROR')# ARROW_LEFTRIGHT
|
||||
## flip X cam
|
||||
# layout.label(text='! Flipped !')
|
||||
row = col.row(align=True)
|
||||
|
||||
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()
|
||||
|
|
|
@ -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": "",
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue