Patch from William
[blender-staging.git] / release / ui / buttons_objects.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(ObjectButtonsPanel):
10         __idname__ = "OBJECT_PT_context"
11         __label__ = " "
12
13         def draw(self, context):
14                 layout = self.layout
15                 ob = context.object
16                 
17                 split = layout.split(percentage=0.06)
18                 split.itemL(text="", icon="ICON_OBJECT_DATA")
19                 split.itemR(ob, "name", text="")
20                 
21                         
22                         
23 class OBJECT_PT_transform(ObjectButtonsPanel):
24         __idname__ = "OBJECT_PT_transform"
25         __label__ = "Transform"
26
27         def draw(self, context):
28                 layout = self.layout
29                 ob = context.object
30
31                 row = layout.row()
32                 row.column().itemR(ob, "location")
33                 row.column().itemR(ob, "rotation")
34                 row.column().itemR(ob, "scale")
35
36 class OBJECT_PT_groups(ObjectButtonsPanel):
37         __idname__ = "OBJECT_PT_groups"
38         __label__ = "Groups"
39
40         def draw(self, context):
41                 layout = self.layout
42                 ob = context.object
43
44                 row = layout.row()
45                 row.itemR(ob, "pass_index")
46                 row.itemR(ob, "parent")
47
48                 # layout.left_right()
49                 # layout.itemO("OBJECT_OT_add_group");
50
51                 for group in bpy.data.groups:
52                         if ob.name in group.objects:
53                                 col = layout.column(align=True)
54
55                                 row = col.box().row()
56                                 row.itemR(group, "name", text="")
57                                 #row.itemO("OBJECT_OT_remove_group")
58
59                                 split = col.box().split()
60                                 split.column().itemR(group, "layer")
61                                 split.column().itemR(group, "dupli_offset")
62
63 class OBJECT_PT_display(ObjectButtonsPanel):
64         __idname__ = "OBJECT_PT_display"
65         __label__ = "Display"
66
67         def draw(self, context):
68                 layout = self.layout
69                 ob = context.object
70                         
71                 row = layout.row()
72                 row.itemR(ob, "max_draw_type", text="Type")
73                 row.itemR(ob, "draw_bounds_type", text="Bounds")
74
75                 flow = layout.column_flow()
76                 flow.itemR(ob, "draw_name", text="Name")
77                 flow.itemR(ob, "draw_axis", text="Axis")
78                 flow.itemR(ob, "draw_wire", text="Wire")
79                 flow.itemR(ob, "draw_texture_space", text="Texture Space")
80                 flow.itemR(ob, "x_ray", text="X-Ray")
81                 flow.itemR(ob, "draw_transparent", text="Transparency")
82
83 class OBJECT_PT_duplication(ObjectButtonsPanel):
84         __idname__ = "OBJECT_PT_duplication"
85         __label__ = "Duplication"
86
87         def draw(self, context):
88                 layout = self.layout
89                 ob = context.object
90
91                 layout.itemR(ob, "dupli_type", expand=True)
92
93                 if ob.dupli_type == 'FRAMES':
94                         split = layout.split()
95                         
96                         sub = split.column(align=True)
97                         sub.itemR(ob, "dupli_frames_start", text="Start")
98                         sub.itemR(ob, "dupli_frames_end", text="End")
99                         
100                         sub = split.column(align=True)
101                         sub.itemR(ob, "dupli_frames_on", text="On")
102                         sub.itemR(ob, "dupli_frames_off", text="Off")
103                         
104                         layout.itemR(ob, "dupli_frames_no_speed", text="No Speed")
105
106                 elif ob.dupli_type == 'VERTS':
107                         layout.itemR(ob, "dupli_verts_rotation", text="Rotation")
108
109                 elif ob.dupli_type == 'FACES':
110                         row = layout.row()
111                         row.itemR(ob, "dupli_faces_scale", text="Scale")
112                         row.itemR(ob, "dupli_faces_inherit_scale", text="Inherit Scale")
113
114                 elif ob.dupli_type == 'GROUP':
115                         layout.itemR(ob, "dupli_group", text="Group")
116
117 class OBJECT_PT_animation(ObjectButtonsPanel):
118         __idname__ = "OBJECT_PT_animation"
119         __label__ = "Animation"
120
121         def draw(self, context):
122                 layout = self.layout
123                 ob = context.object
124                 
125                 split = layout.split()
126                 
127                 sub = split.column()
128                 sub.itemL(text="Time Offset:")
129                 sub.itemR(ob, "time_offset_edit", text="Edit")
130                 sub.itemR(ob, "time_offset_particle", text="Particle")
131                 sub.itemR(ob, "time_offset_parent", text="Parent")
132                 sub.itemR(ob, "slow_parent")
133                 sub.itemR(ob, "time_offset", text="Offset")
134                 
135                 sub = split.column()
136                 sub.itemL(text="Tracking:")
137                 sub.itemR(ob, "track_axis", text="Axis")
138                 sub.itemR(ob, "up_axis", text="Up Axis")
139                 sub.itemR(ob, "track_rotation", text="Rotation")
140
141 bpy.types.register(OBJECT_PT_context)
142 bpy.types.register(OBJECT_PT_transform)
143 bpy.types.register(OBJECT_PT_groups)
144 bpy.types.register(OBJECT_PT_display)
145 bpy.types.register(OBJECT_PT_duplication)
146 bpy.types.register(OBJECT_PT_animation)