made scripts pass the pep8 test (though not fully pep8 yet)
[blender-staging.git] / release / scripts / ui / properties_object.py
1 # This software is distributable under the terms of the GNU
2 # General Public License (GPL) v2, the text of which can be found at
3 # http://www.gnu.org/copyleft/gpl.html. Installing, importing or otherwise
4 # using this module constitutes acceptance of the terms of this License.
5
6 # <pep8 compliant>
7 import bpy
8
9
10 class ObjectButtonsPanel(bpy.types.Panel):
11     bl_space_type = 'PROPERTIES'
12     bl_region_type = 'WINDOW'
13     bl_context = "object"
14
15
16 class OBJECT_PT_context_object(ObjectButtonsPanel):
17     bl_label = ""
18     bl_show_header = False
19
20     def draw(self, context):
21         layout = self.layout
22
23         ob = context.object
24
25         row = layout.row()
26         row.itemL(text="", icon='ICON_OBJECT_DATA')
27         row.itemR(ob, "name", text="")
28
29
30 class OBJECT_PT_transform(ObjectButtonsPanel):
31     bl_label = "Transform"
32
33     def draw(self, context):
34         layout = self.layout
35
36         ob = context.object
37
38         row = layout.row()
39
40         row.column().itemR(ob, "location")
41         if ob.rotation_mode == 'QUATERNION':
42             row.column().itemR(ob, "rotation_quaternion", text="Rotation")
43         elif ob.rotation_mode == 'AXIS_ANGLE':
44             #row.column().itemL(text="Rotation")
45             #row.column().itemR(pchan, "rotation_angle", text="Angle")
46             #row.column().itemR(pchan, "rotation_axis", text="Axis")
47             row.column().itemR(ob, "rotation_axis_angle", text="Rotation")
48         else:
49             row.column().itemR(ob, "rotation_euler", text="Rotation")
50
51         row.column().itemR(ob, "scale")
52
53         layout.itemR(ob, "rotation_mode")
54
55
56 class OBJECT_PT_transform_locks(ObjectButtonsPanel):
57     bl_label = "Transform Locks"
58     bl_default_closed = True
59
60     def draw(self, context):
61         layout = self.layout
62
63         ob = context.object
64
65         row = layout.row()
66
67         col = row.column()
68         col.itemR(ob, "lock_location")
69
70         col = row.column()
71         if ob.rotation_mode in ('QUATERNION', 'AXIS_ANGLE'):
72             col.itemR(ob, "lock_rotations_4d", text="Lock Rotation")
73             if ob.lock_rotations_4d:
74                 col.itemR(ob, "lock_rotation_w", text="W")
75             col.itemR(ob, "lock_rotation", text="")
76         else:
77             col.itemR(ob, "lock_rotation", text="Rotation")
78
79         row.column().itemR(ob, "lock_scale")
80
81
82 class OBJECT_PT_relations(ObjectButtonsPanel):
83     bl_label = "Relations"
84
85     def draw(self, context):
86         layout = self.layout
87
88         ob = context.object
89
90         split = layout.split()
91
92         col = split.column()
93         col.itemR(ob, "layers")
94         col.itemS()
95         col.itemR(ob, "pass_index")
96
97         col = split.column()
98         col.itemL(text="Parent:")
99         col.itemR(ob, "parent", text="")
100
101         sub = col.column()
102         split = sub.split(percentage=0.3)
103         split.itemL(text="Type:")
104         split.itemR(ob, "parent_type", text="")
105         parent = ob.parent
106         if parent and ob.parent_type == 'BONE' and parent.type == 'ARMATURE':
107             sub.item_pointerR(ob, "parent_bone", parent.data, "bones", text="")
108         sub.active = parent != None
109
110
111 class OBJECT_PT_groups(ObjectButtonsPanel):
112     bl_label = "Groups"
113
114     def draw(self, context):
115         layout = self.layout
116
117         ob = context.object
118
119         split = layout.split()
120         split.item_menu_enumO("object.group_add", "group", text="Add to Group")
121         split.itemL()
122
123         for group in bpy.data.groups:
124             if ob.name in group.objects:
125                 col = layout.column(align=True)
126
127                 col.set_context_pointer("group", group)
128
129                 row = col.box().row()
130                 row.itemR(group, "name", text="")
131                 row.itemO("object.group_remove", text="", icon='VICON_X')
132
133                 split = col.box().split()
134                 split.column().itemR(group, "layer", text="Dupli")
135                 split.column().itemR(group, "dupli_offset", text="")
136
137
138 class OBJECT_PT_display(ObjectButtonsPanel):
139     bl_label = "Display"
140
141     def draw(self, context):
142         layout = self.layout
143
144         ob = context.object
145
146         split = layout.split()
147         col = split.column()
148         col.itemR(ob, "max_draw_type", text="Type")
149         col = split.column()
150         row = col.row()
151         row.itemR(ob, "draw_bounds", text="Bounds")
152         sub = row.row()
153         sub.active = ob.draw_bounds
154         sub.itemR(ob, "draw_bounds_type", text="")
155
156         flow = layout.column_flow()
157         flow.itemR(ob, "draw_name", text="Name")
158         flow.itemR(ob, "draw_axis", text="Axis")
159         flow.itemR(ob, "draw_wire", text="Wire")
160         flow.itemR(ob, "draw_texture_space", text="Texture Space")
161         flow.itemR(ob, "x_ray", text="X-Ray")
162         flow.itemR(ob, "draw_transparent", text="Transparency")
163
164
165 class OBJECT_PT_duplication(ObjectButtonsPanel):
166     bl_label = "Duplication"
167
168     def draw(self, context):
169         layout = self.layout
170
171         ob = context.object
172
173         layout.itemR(ob, "dupli_type", expand=True)
174
175         if ob.dupli_type == 'FRAMES':
176             split = layout.split()
177
178             col = split.column(align=True)
179             col.itemR(ob, "dupli_frames_start", text="Start")
180             col.itemR(ob, "dupli_frames_end", text="End")
181
182             col = split.column(align=True)
183             col.itemR(ob, "dupli_frames_on", text="On")
184             col.itemR(ob, "dupli_frames_off", text="Off")
185
186             layout.itemR(ob, "dupli_frames_no_speed", text="No Speed")
187
188         elif ob.dupli_type == 'VERTS':
189             layout.itemR(ob, "dupli_verts_rotation", text="Rotation")
190
191         elif ob.dupli_type == 'FACES':
192             row = layout.row()
193             row.itemR(ob, "dupli_faces_scale", text="Scale")
194             row.itemR(ob, "dupli_faces_inherit_scale", text="Inherit Scale")
195
196         elif ob.dupli_type == 'GROUP':
197             layout.itemR(ob, "dupli_group", text="Group")
198
199
200 class OBJECT_PT_animation(ObjectButtonsPanel):
201     bl_label = "Animation"
202
203     def draw(self, context):
204         layout = self.layout
205
206         ob = context.object
207
208         split = layout.split()
209
210         col = split.column()
211         col.itemL(text="Time Offset:")
212         col.itemR(ob, "time_offset_edit", text="Edit")
213         row = col.row()
214         row.itemR(ob, "time_offset_particle", text="Particle")
215         row.active = len(ob.particle_systems) != 0
216         row = col.row()
217         row.itemR(ob, "time_offset_parent", text="Parent")
218         row.active = ob.parent != None
219         row = col.row()
220         row.itemR(ob, "slow_parent")
221         row.active = ob.parent != None
222         col.itemR(ob, "time_offset", text="Offset")
223
224         col = split.column()
225         col.itemL(text="Track:")
226         col.itemR(ob, "track", text="")
227         col.itemR(ob, "track_axis", text="Axis")
228         col.itemR(ob, "up_axis", text="Up Axis")
229         row = col.row()
230         row.itemR(ob, "track_override_parent", text="Override Parent")
231         row.active = ob.parent != None
232
233 bpy.types.register(OBJECT_PT_context_object)
234 bpy.types.register(OBJECT_PT_transform)
235 bpy.types.register(OBJECT_PT_transform_locks)
236 bpy.types.register(OBJECT_PT_relations)
237 bpy.types.register(OBJECT_PT_groups)
238 bpy.types.register(OBJECT_PT_display)
239 bpy.types.register(OBJECT_PT_duplication)
240 bpy.types.register(OBJECT_PT_animation)