7f0294cdd20040df0e8242370e923e1940181b97
[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 bpy.types import Panel
22 from rna_prop_ui import PropertyPanel
23
24
25 class DataButtonsPanel:
26     bl_space_type = 'PROPERTIES'
27     bl_region_type = 'WINDOW'
28     bl_context = "data"
29
30     @classmethod
31     def poll(cls, context):
32         return context.lattice
33
34
35 class DATA_PT_context_lattice(DataButtonsPanel, Panel):
36     bl_label = ""
37     bl_options = {'HIDE_HEADER'}
38
39     def draw(self, context):
40         layout = self.layout
41
42         ob = context.object
43         lat = context.lattice
44         space = context.space_data
45
46         split = layout.split(percentage=0.65)
47         if ob:
48             split.template_ID(ob, "data")
49             split.separator()
50         elif lat:
51             split.template_ID(space, "pin_id")
52             split.separator()
53
54
55 class DATA_PT_lattice(DataButtonsPanel, Panel):
56     bl_label = "Lattice"
57
58     def draw(self, context):
59         layout = self.layout
60
61         lat = context.lattice
62
63         row = layout.row()
64         row.prop(lat, "points_u")
65         row.prop(lat, "interpolation_type_u", text="")
66
67         row = layout.row()
68         row.prop(lat, "points_v")
69         row.prop(lat, "interpolation_type_v", text="")
70
71         row = layout.row()
72         row.prop(lat, "points_w")
73         row.prop(lat, "interpolation_type_w", text="")
74
75         row = layout.row()
76         row.prop(lat, "use_outside")
77         row.prop_search(lat, "vertex_group", context.object, "vertex_groups", text="")
78
79
80 class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel, Panel):
81     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
82     _context_path = "object.data"
83     _property_type = bpy.types.Lattice
84
85
86 classes = (
87     DATA_PT_context_lattice,
88     DATA_PT_custom_props_lattice,
89     DATA_PT_lattice,
90 )
91
92 if __name__ == "__main__":  # only for live edit.
93     from bpy.utils import register_class
94     for cls in classes:
95         register_class(cls)