change python scripts so modules which register with blender have a register() functi...
[blender.git] / release / scripts / 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 narrowui = 180
24
25
26 class DataButtonsPanel(bpy.types.Panel):
27     bl_space_type = 'PROPERTIES'
28     bl_region_type = 'WINDOW'
29     bl_context = "data"
30
31     def poll(self, context):
32         return context.lattice
33
34
35 class DATA_PT_context_lattice(DataButtonsPanel):
36     bl_label = ""
37     bl_show_header = False
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         wide_ui = context.region.width > narrowui
46
47         if wide_ui:
48             split = layout.split(percentage=0.65)
49             if ob:
50                 split.template_ID(ob, "data")
51                 split.separator()
52             elif lat:
53                 split.template_ID(space, "pin_id")
54                 split.separator()
55         else:
56             if ob:
57                 layout.template_ID(ob, "data")
58             elif lat:
59                 layout.template_ID(space, "pin_id")
60
61
62 class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel):
63     _context_path = "object.data"
64
65
66 class DATA_PT_lattice(DataButtonsPanel):
67     bl_label = "Lattice"
68
69     def draw(self, context):
70         layout = self.layout
71
72         lat = context.lattice
73         wide_ui = context.region.width > narrowui
74
75         split = layout.split()
76         col = split.column()
77         col.prop(lat, "points_u")
78         if wide_ui:
79             col = split.column()
80         col.prop(lat, "interpolation_type_u", text="")
81
82         split = layout.split()
83         col = split.column()
84         col.prop(lat, "points_v")
85         if wide_ui:
86             col = split.column()
87         col.prop(lat, "interpolation_type_v", text="")
88
89         split = layout.split()
90         col = split.column()
91         col.prop(lat, "points_w")
92         if wide_ui:
93             col = split.column()
94         col.prop(lat, "interpolation_type_w", text="")
95
96         layout.prop(lat, "outside")
97
98
99 classes = [
100     DATA_PT_context_lattice,
101     DATA_PT_lattice,
102
103     DATA_PT_custom_props_lattice]
104
105
106 def register():
107     register = bpy.types.register
108     for cls in classes:
109         register(cls)
110
111 def unregister():
112     unregister = bpy.types.unregister
113     for cls in classes:
114         unregister(cls)