fix [#26754] Live Edit and Editing UI scripts don't work
[blender-staging.git] / release / scripts / startup / bl_ui / properties_data_lattice.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from rna_prop_ui import PropertyPanel
22
23
24 class DataButtonsPanel():
25     bl_space_type = 'PROPERTIES'
26     bl_region_type = 'WINDOW'
27     bl_context = "data"
28
29     @classmethod
30     def poll(cls, context):
31         return context.lattice
32
33
34 class DATA_PT_context_lattice(DataButtonsPanel, bpy.types.Panel):
35     bl_label = ""
36     bl_options = {'HIDE_HEADER'}
37
38     def draw(self, context):
39         layout = self.layout
40
41         ob = context.object
42         lat = context.lattice
43         space = context.space_data
44
45         split = layout.split(percentage=0.65)
46         if ob:
47             split.template_ID(ob, "data")
48             split.separator()
49         elif lat:
50             split.template_ID(space, "pin_id")
51             split.separator()
52
53
54 class DATA_PT_lattice(DataButtonsPanel, bpy.types.Panel):
55     bl_label = "Lattice"
56
57     def draw(self, context):
58         layout = self.layout
59
60         lat = context.lattice
61
62         row = layout.row()
63         row.prop(lat, "points_u")
64         row.prop(lat, "interpolation_type_u", text="")
65
66         row = layout.row()
67         row.prop(lat, "points_v")
68         row.prop(lat, "interpolation_type_v", text="")
69
70         row = layout.row()
71         row.prop(lat, "points_w")
72         row.prop(lat, "interpolation_type_w", text="")
73
74         row = layout.row()
75         row.prop(lat, "use_outside")
76         row.prop_search(lat, "vertex_group", context.object, "vertex_groups", text="")
77
78
79 class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel, bpy.types.Panel):
80     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
81     _context_path = "object.data"
82     _property_type = bpy.types.Lattice
83
84 if __name__ == "__main__":  # only for live edit.
85     bpy.utils.register_module(__name__)