Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ui_panels.py « greasepencil_tools - git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 06ad6cb263b4489358880188ee9d3ce26a114615 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

import bpy

class GP_PT_sidebarPanel(bpy.types.Panel):
    bl_label = "Grease Pencil Tools"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "Grease Pencil"

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True

        # Box deform ops
        self.layout.operator_context = 'INVOKE_DEFAULT'
        layout.operator('gp.latticedeform', icon ="MOD_MESHDEFORM")# MOD_LATTICE, LATTICE_DATA

        # Straight line ops
        layout.operator('gp.straight_stroke', icon ="CURVE_PATH")# IPO_LINEAR


        # Expose Native view operators
        # if context.scene.camera:
        row = layout.row(align=True)
        row.operator('view3d.zoom_camera_1_to_1', text = 'Zoom 1:1', icon = 'ZOOM_PREVIOUS')# FULLSCREEN_EXIT?
        row.operator('view3d.view_center_camera', text = 'Zoom Fit', icon = 'FULLSCREEN_ENTER')
        row = layout.row(align=True)
        row.operator('view3d.rotate_canvas_reset', text = 'Reset Rotation', icon = 'FILE_REFRESH')
        row.operator('view3d.rotate_canvas_set', text = 'Save Rotation', icon = 'DRIVER_ROTATIONAL_DIFFERENCE')


def menu_boxdeform_entry(self, context):
    """Transform shortcut to append in existing menu"""
    layout = self.layout
    obj = bpy.context.object
    # {'EDIT_GPENCIL', 'PAINT_GPENCIL','SCULPT_GPENCIL','WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}
    if obj and obj.type == 'GPENCIL' and context.mode in {'OBJECT', 'EDIT_GPENCIL', 'PAINT_GPENCIL'}:
        self.layout.operator_context = 'INVOKE_DEFAULT'
        layout.operator('gp.latticedeform', text='Box Deform')

def menu_stroke_entry(self, context):
    layout = self.layout
    # Gpencil modes : {'EDIT_GPENCIL', 'PAINT_GPENCIL','SCULPT_GPENCIL','WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}
    if context.mode in {'EDIT_GPENCIL', 'PAINT_GPENCIL'}:
        self.layout.operator_context = 'INVOKE_DEFAULT'
        layout.operator('gp.straight_stroke', text='Straight Stroke')

def menu_brush_pack(self, context):
    layout = self.layout
    # if context.mode in {'EDIT_GPENCIL', 'PAINT_GPENCIL'}:
    self.layout.operator_context = 'INVOKE_DEFAULT'
    layout.operator('gp.import_brush_pack')#, text='Import brush pack'


def register():
    bpy.utils.register_class(GP_PT_sidebarPanel)
    ## VIEW3D_MT_edit_gpencil.append# Grease pencil menu
    bpy.types.VIEW3D_MT_transform_object.append(menu_boxdeform_entry)
    bpy.types.VIEW3D_MT_edit_gpencil_transform.append(menu_boxdeform_entry)
    bpy.types.VIEW3D_MT_edit_gpencil_stroke.append(menu_stroke_entry)
    bpy.types.VIEW3D_MT_brush_gpencil_context_menu.append(menu_brush_pack)


def unregister():
    bpy.types.VIEW3D_MT_brush_gpencil_context_menu.remove(menu_brush_pack)
    bpy.types.VIEW3D_MT_transform_object.remove(menu_boxdeform_entry)
    bpy.types.VIEW3D_MT_edit_gpencil_transform.remove(menu_boxdeform_entry)
    bpy.types.VIEW3D_MT_edit_gpencil_stroke.remove(menu_stroke_entry)
    bpy.utils.unregister_class(GP_PT_sidebarPanel)