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