Export_3ds: Added distance cue chunk export
[blender-addons.git] / greasepencil_tools / ui_panels.py
blobde4dff8aae83ebbf5ca1a6149db73dbceda74332
1 # SPDX-FileCopyrightText: 2020-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 import bpy
7 class GP_PT_sidebarPanel(bpy.types.Panel):
8 bl_label = "Grease Pencil Tools"
9 bl_space_type = "VIEW_3D"
10 bl_region_type = "UI"
11 bl_category = "Grease Pencil"
13 def draw(self, context):
14 layout = self.layout
15 layout.use_property_split = True
17 # Box deform ops
18 self.layout.operator_context = 'INVOKE_DEFAULT'
19 layout.operator('view3d.gp_box_deform', icon ="MOD_MESHDEFORM")
21 # Straight line ops
22 layout.operator('gpencil.straight_stroke', icon ="CURVE_PATH")
25 # Expose native view operators
26 row = layout.row(align=True)
27 row.operator('view3d.zoom_camera_1_to_1', text = 'Zoom 1:1', icon = 'ZOOM_PREVIOUS')
28 row.operator('view3d.view_center_camera', text = 'Zoom Fit', icon = 'FULLSCREEN_ENTER')
30 # Rotation save/load
31 row = layout.row(align=True)
32 row.operator('view3d.rotate_canvas_reset', text = 'Reset Rotation', icon = 'FILE_REFRESH')
33 row.operator('view3d.rotate_canvas_set', text = 'Save Rotation', icon = 'DRIVER_ROTATIONAL_DIFFERENCE')
35 # View flip
36 if context.scene.camera and context.scene.camera.scale.x < 0:
37 row = layout.row(align=True)
38 row.operator('view3d.camera_flip_x', text = 'Camera Mirror Flip', icon = 'MOD_MIRROR')
39 row.label(text='', icon='LOOP_BACK')
40 else:
41 layout.operator('view3d.camera_flip_x', text = 'Camera Mirror Flip', icon = 'MOD_MIRROR')
44 def menu_boxdeform_entry(self, context):
45 """Transform shortcut to append in existing menu"""
46 layout = self.layout
47 obj = bpy.context.object
48 # {'EDIT_GPENCIL', 'PAINT_GPENCIL','SCULPT_GPENCIL','WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}
49 if obj and obj.type == 'GPENCIL' and context.mode in {'OBJECT', 'EDIT_GPENCIL', 'PAINT_GPENCIL'}:
50 self.layout.operator_context = 'INVOKE_DEFAULT'
51 layout.operator('view3d.gp_box_deform', text='Box Deform')
53 def menu_stroke_entry(self, context):
54 layout = self.layout
55 # Gpencil modes : {'EDIT_GPENCIL', 'PAINT_GPENCIL','SCULPT_GPENCIL','WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}
56 if context.mode in {'EDIT_GPENCIL', 'PAINT_GPENCIL'}:
57 self.layout.operator_context = 'INVOKE_DEFAULT'
58 layout.operator('gpencil.straight_stroke', text='Straight Stroke')
60 def menu_brush_pack(self, context):
61 layout = self.layout
62 # if context.mode in {'EDIT_GPENCIL', 'PAINT_GPENCIL'}:
63 self.layout.operator_context = 'INVOKE_DEFAULT'
64 layout.operator('gp.import_brush_pack')#, text='Import brush pack'
67 def register():
68 bpy.utils.register_class(GP_PT_sidebarPanel)
69 ## VIEW3D_MT_edit_gpencil.append# Grease pencil menu
70 bpy.types.VIEW3D_MT_transform_object.append(menu_boxdeform_entry)
71 bpy.types.VIEW3D_MT_edit_gpencil_transform.append(menu_boxdeform_entry)
72 bpy.types.VIEW3D_MT_edit_gpencil_stroke.append(menu_stroke_entry)
73 bpy.types.VIEW3D_MT_brush_gpencil_context_menu.append(menu_brush_pack)
76 def unregister():
77 bpy.types.VIEW3D_MT_brush_gpencil_context_menu.remove(menu_brush_pack)
78 bpy.types.VIEW3D_MT_transform_object.remove(menu_boxdeform_entry)
79 bpy.types.VIEW3D_MT_edit_gpencil_transform.remove(menu_boxdeform_entry)
80 bpy.types.VIEW3D_MT_edit_gpencil_stroke.remove(menu_stroke_entry)
81 bpy.utils.unregister_class(GP_PT_sidebarPanel)