d59ed604c55f034569258ea7d4f07a85794c9880
[blender.git] / release / ui / buttons_object.py
1
2 import bpy
3
4 class ObjectButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
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                 row.column().itemR(ob, "location")
31                 row.column().itemR(ob, "rotation")
32                 row.column().itemR(ob, "scale")
33
34 class OBJECT_PT_relations(ObjectButtonsPanel):
35         __label__ = "Relations"
36
37         def draw(self, context):
38                 layout = self.layout
39                 
40                 ob = context.object
41
42                 split = layout.split()
43                 
44                 col = split.column()
45                 col.itemR(ob, "layers")
46                 col.itemS()
47                 col.itemR(ob, "pass_index")
48
49                 col = split.column()
50                 col.itemL(text="Parent:")
51                 col.itemR(ob, "parent", text="")
52
53                 sub = col.column()
54                 sub.itemR(ob, "parent_type", text="Type")
55                 parent = ob.parent
56                 if parent and ob.parent_type == 'BONE' and parent.type == 'ARMATURE':
57                         sub.item_pointerR(ob, "parent_bone", parent.data, "bones", text="")
58                 sub.active = parent != None
59
60 class OBJECT_PT_groups(ObjectButtonsPanel):
61         __label__ = "Groups"
62
63         def draw(self, context):
64                 layout = self.layout
65                 
66                 ob = context.object
67
68                 split = layout.split()
69                 split.item_menu_enumO("object.group_add", "group", text="Add to Group")
70                 split.itemL()
71
72                 for group in bpy.data.groups:
73                         if ob.name in group.objects:
74                                 col = layout.column(align=True)
75
76                                 col.set_context_pointer("group", group)
77
78                                 row = col.box().row()
79                                 row.itemR(group, "name", text="")
80                                 row.itemO("object.group_remove", text="", icon="VICON_X")
81
82                                 split = col.box().split()
83                                 split.column().itemR(group, "layer", text="Dupli")
84                                 split.column().itemR(group, "dupli_offset", text="")
85
86 class OBJECT_PT_display(ObjectButtonsPanel):
87         __label__ = "Display"
88
89         def draw(self, context):
90                 layout = self.layout
91                 
92                 ob = context.object
93                         
94                 row = layout.row()
95                 row.itemR(ob, "max_draw_type", text="Type")
96                 row.itemR(ob, "draw_bounds_type", text="Bounds")
97
98                 flow = layout.column_flow()
99                 flow.itemR(ob, "draw_name", text="Name")
100                 flow.itemR(ob, "draw_axis", text="Axis")
101                 flow.itemR(ob, "draw_wire", text="Wire")
102                 flow.itemR(ob, "draw_texture_space", text="Texture Space")
103                 flow.itemR(ob, "x_ray", text="X-Ray")
104                 flow.itemR(ob, "draw_transparent", text="Transparency")
105
106 class OBJECT_PT_duplication(ObjectButtonsPanel):
107         __label__ = "Duplication"
108
109         def draw(self, context):
110                 layout = self.layout
111                 
112                 ob = context.object
113
114                 layout.itemR(ob, "dupli_type", expand=True)
115
116                 if ob.dupli_type == 'FRAMES':
117                         split = layout.split()
118                         
119                         col = split.column(align=True)
120                         col.itemR(ob, "dupli_frames_start", text="Start")
121                         col.itemR(ob, "dupli_frames_end", text="End")
122                         
123                         col = split.column(align=True)
124                         col.itemR(ob, "dupli_frames_on", text="On")
125                         col.itemR(ob, "dupli_frames_off", text="Off")
126                         
127                         layout.itemR(ob, "dupli_frames_no_speed", text="No Speed")
128
129                 elif ob.dupli_type == 'VERTS':
130                         layout.itemR(ob, "dupli_verts_rotation", text="Rotation")
131
132                 elif ob.dupli_type == 'FACES':
133                         row = layout.row()
134                         row.itemR(ob, "dupli_faces_scale", text="Scale")
135                         row.itemR(ob, "dupli_faces_inherit_scale", text="Inherit Scale")
136
137                 elif ob.dupli_type == 'GROUP':
138                         layout.itemR(ob, "dupli_group", text="Group")
139
140 class OBJECT_PT_animation(ObjectButtonsPanel):
141         __label__ = "Animation"
142
143         def draw(self, context):
144                 layout = self.layout
145                 
146                 ob = context.object
147                 
148                 split = layout.split()
149                 
150                 col = split.column()
151                 col.itemL(text="Time Offset:")
152                 col.itemR(ob, "time_offset_edit", text="Edit")
153                 row = col.row()
154                 row.itemR(ob, "time_offset_particle", text="Particle")
155                 row.active = len(ob.particle_systems) != 0
156                 row = col.row()
157                 row.itemR(ob, "time_offset_parent", text="Parent")
158                 row.active = ob.parent != None
159                 row = col.row()
160                 row.itemR(ob, "slow_parent")
161                 row.active = ob.parent != None
162                 col.itemR(ob, "time_offset", text="Offset")
163
164                 col = split.column()
165                 col.itemL(text="Track:")
166                 col.itemR(ob, "track", text="")
167                 col.itemR(ob, "track_axis", text="Axis")
168                 col.itemR(ob, "up_axis", text="Up Axis")
169                 row = col.row()
170                 row.itemR(ob, "track_override_parent", text="Override Parent")
171                 row.active = ob.parent != None
172
173 bpy.types.register(OBJECT_PT_context_object)
174 bpy.types.register(OBJECT_PT_transform)
175 bpy.types.register(OBJECT_PT_relations)
176 bpy.types.register(OBJECT_PT_groups)
177 bpy.types.register(OBJECT_PT_display)
178 bpy.types.register(OBJECT_PT_duplication)
179 bpy.types.register(OBJECT_PT_animation)