* Added greying out for Bound Box Menu.
[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                 row = layout.row()
30                 
31                 row.column().itemR(ob, "location")
32                 if ob.rotation_mode == 'QUATERNION':
33                         row.column().itemR(ob, "rotation_quaternion", text="Rotation")
34                 elif ob.rotation_mode == 'AXIS_ANGLE':
35                         #row.column().itemL(text="Rotation")
36                         #row.column().itemR(pchan, "rotation_angle", text="Angle")
37                         #row.column().itemR(pchan, "rotation_axis", text="Axis")
38                         row.column().itemR(ob, "rotation_axis_angle", text="Rotation")
39                 else:
40                         row.column().itemR(ob, "rotation_euler", text="Rotation")
41                         
42                 row.column().itemR(ob, "scale")
43                 
44                 layout.itemR(ob, "rotation_mode")
45                 
46 class OBJECT_PT_transform_locks(ObjectButtonsPanel):
47         __label__ = "Transform Locks"
48         __default_closed__ = True
49         
50         def draw(self, context):
51                 layout = self.layout
52                 
53                 ob = context.object
54                 
55                 row = layout.row()
56                 
57                 col = row.column()
58                 col.itemR(ob, "lock_location")
59                 
60                 col = row.column()
61                 if ob.rotation_mode in ('QUATERNION', 'AXIS_ANGLE'):
62                         col.itemR(ob, "lock_rotations_4d", text="Lock Rotation")
63                         if ob.lock_rotations_4d:
64                                 col.itemR(ob, "lock_rotation_w", text="W")
65                         col.itemR(ob, "lock_rotation", text="")
66                 else:
67                         col.itemR(ob, "lock_rotation", text="Rotation")
68                 
69                 row.column().itemR(ob, "lock_scale")
70
71 class OBJECT_PT_relations(ObjectButtonsPanel):
72         __label__ = "Relations"
73
74         def draw(self, context):
75                 layout = self.layout
76                 
77                 ob = context.object
78
79                 split = layout.split()
80                 
81                 col = split.column()
82                 col.itemR(ob, "layers")
83                 col.itemS()
84                 col.itemR(ob, "pass_index")
85
86                 col = split.column()
87                 col.itemL(text="Parent:")
88                 col.itemR(ob, "parent", text="")
89
90                 sub = col.column()
91                 split = sub.split(percentage=0.3)
92                 split.itemL(text="Type:")
93                 split.itemR(ob, "parent_type", text="")
94                 parent = ob.parent
95                 if parent and ob.parent_type == 'BONE' and parent.type == 'ARMATURE':
96                         sub.item_pointerR(ob, "parent_bone", parent.data, "bones", text="")
97                 sub.active = parent != None
98
99 class OBJECT_PT_groups(ObjectButtonsPanel):
100         __label__ = "Groups"
101
102         def draw(self, context):
103                 layout = self.layout
104                 
105                 ob = context.object
106
107                 split = layout.split()
108                 split.item_menu_enumO("object.group_add", "group", text="Add to Group")
109                 split.itemL()
110
111                 for group in bpy.data.groups:
112                         if ob.name in group.objects:
113                                 col = layout.column(align=True)
114
115                                 col.set_context_pointer("group", group)
116
117                                 row = col.box().row()
118                                 row.itemR(group, "name", text="")
119                                 row.itemO("object.group_remove", text="", icon='VICON_X')
120
121                                 split = col.box().split()
122                                 split.column().itemR(group, "layer", text="Dupli")
123                                 split.column().itemR(group, "dupli_offset", text="")
124
125 class OBJECT_PT_display(ObjectButtonsPanel):
126         __label__ = "Display"
127
128         def draw(self, context):
129                 layout = self.layout
130                 
131                 ob = context.object
132                 
133                 split = layout.split()
134                 col = split.column()
135                 col.itemR(ob, "max_draw_type", text="Type")
136                 col = split.column()
137                 row = col.row()
138                 row.itemR(ob, "draw_bounds", text="Bounds")
139                 sub = row.row()
140                 sub.active = ob.draw_bounds
141                 sub.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)