FBX exporter conversion almost done.
[blender.git] / release / ui / buttons_data_mesh.py
1
2 import bpy
3
4 class DataButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "data"
8         
9         def poll(self, context):
10                 return (context.mesh != None)
11
12 class DATA_PT_context_mesh(DataButtonsPanel):
13         __idname__ = "DATA_PT_context_mesh"
14         __no_header__ = True
15         
16         def draw(self, context):
17                 layout = self.layout
18                 
19                 ob = context.object
20                 mesh = context.mesh
21                 space = context.space_data
22
23                 split = layout.split(percentage=0.65)
24
25                 if ob:
26                         split.template_ID(ob, "data")
27                         split.itemS()
28                 elif mesh:
29                         split.template_ID(space, "pin_id")
30                         split.itemS()
31
32 class DATA_PT_mesh(DataButtonsPanel):
33         __idname__ = "DATA_PT_mesh"
34         __label__ = "Mesh"
35
36         def draw(self, context):
37                 layout = self.layout
38                 
39                 mesh = context.mesh
40                 
41                 split = layout.split()
42                 
43                 col = split.column()
44                 col.itemR(mesh, "autosmooth")
45                 colsub = col.column()
46                 colsub.active = mesh.autosmooth
47                 colsub.itemR(mesh, "autosmooth_angle", text="Angle")
48                 sub = split.column()
49                 sub.itemR(mesh, "vertex_normal_flip")
50                 sub.itemR(mesh, "double_sided")
51                         
52                 layout.itemS()
53                 layout.itemR(mesh, "texco_mesh")
54
55 class DATA_PT_materials(DataButtonsPanel):
56         __idname__ = "DATA_PT_materials"
57         __label__ = "Materials"
58         
59         def poll(self, context):
60                 return (context.object and context.object.type in ('MESH', 'CURVE', 'FONT', 'SURFACE'))
61
62         def draw(self, context):
63                 layout = self.layout
64                 ob = context.object
65
66                 row = layout.row()
67
68                 row.template_list(ob, "materials", ob, "active_material_index")
69
70                 col = row.column(align=True)
71                 col.itemO("OBJECT_OT_material_slot_add", icon="ICON_ZOOMIN", text="")
72                 col.itemO("OBJECT_OT_material_slot_remove", icon="ICON_ZOOMOUT", text="")
73
74                 if context.edit_object:
75                         row = layout.row(align=True)
76
77                         row.itemO("OBJECT_OT_material_slot_assign", text="Assign")
78                         row.itemO("OBJECT_OT_material_slot_select", text="Select")
79                         row.itemO("OBJECT_OT_material_slot_deselect", text="Deselect")
80
81                 """
82                 layout.itemS()
83
84                 box= layout.box()
85
86                 row = box.row()
87                 row.template_list(ob, "materials", ob, "active_material_index", compact=True)
88
89                 subrow = row.row(align=True)
90                 subrow.itemO("OBJECT_OT_material_slot_add", icon="ICON_ZOOMIN", text="")
91                 subrow.itemO("OBJECT_OT_material_slot_remove", icon="ICON_ZOOMOUT", text="")
92                 """
93
94 class DATA_PT_vertex_groups(DataButtonsPanel):
95         __idname__ = "DATA_PT_vertex_groups"
96         __label__ = "Vertex Groups"
97         
98         def poll(self, context):
99                 return (context.object and context.object.type in ('MESH', 'LATTICE'))
100
101         def draw(self, context):
102                 layout = self.layout
103                 ob = context.object
104
105                 row = layout.row()
106
107                 row.template_list(ob, "vertex_groups", ob, "active_vertex_group_index")
108
109                 col = row.column(align=True)
110                 col.itemO("OBJECT_OT_vertex_group_add", icon="ICON_ZOOMIN", text="")
111                 col.itemO("OBJECT_OT_vertex_group_remove", icon="ICON_ZOOMOUT", text="")
112
113                 col.itemO("OBJECT_OT_vertex_group_copy", icon="ICON_BLANK1", text="")
114                 if ob.data.users > 1:
115                         col.itemO("OBJECT_OT_vertex_group_copy_to_linked", icon="ICON_BLANK1", text="")
116
117                 if context.edit_object:
118                         row = layout.row(align=True)
119
120                         row.itemO("OBJECT_OT_vertex_group_assign", text="Assign")
121                         row.itemO("OBJECT_OT_vertex_group_remove_from", text="Remove")
122                         row.itemO("OBJECT_OT_vertex_group_select", text="Select")
123                         row.itemO("OBJECT_OT_vertex_group_deselect", text="Deselect")
124
125                         layout.itemR(context.tool_settings, "vertex_group_weight", text="Weight")
126
127 class DATA_PT_shape_keys(DataButtonsPanel):
128         __idname__ = "DATA_PT_shape_keys"
129         __label__ = "Shape Keys"
130         
131         def poll(self, context):
132                 return (context.object and context.object.type in ('MESH', 'LATTICE'))
133
134         def draw(self, context):
135                 layout = self.layout
136                 ob = context.object
137                 key = ob.data.shape_keys
138                 kb = ob.active_shape_key
139
140                 row = layout.row()
141                 row.template_list(key, "keys", ob, "active_shape_key_index")
142
143                 col = row.column()
144
145                 subcol = col.column(align=True)
146                 subcol.itemO("OBJECT_OT_shape_key_add", icon="ICON_ZOOMIN", text="")
147                 subcol.itemO("OBJECT_OT_shape_key_remove", icon="ICON_ZOOMOUT", text="")
148
149                 if kb:
150                         col.itemS()
151
152                         subcol = col.column(align=True)
153                         subcol.itemR(ob, "shape_key_lock", icon="ICON_PINNED", text="")
154                         subcol.itemR(kb, "mute", icon="ICON_MUTE_IPO_ON", text="")
155
156                         if key.relative:
157                                 row = layout.row()
158                                 row.itemR(key, "relative")
159                                 row.itemL()
160
161                                 if ob.active_shape_key_index != 0:
162                                         if not ob.shape_key_lock:
163                                                 row = layout.row(align=True)
164                                                 row.itemR(kb, "value", text="")
165                                                 row.itemR(kb, "slider_min", text="Min")
166                                                 row.itemR(kb, "slider_max", text="Max")
167
168                                         row = layout.row()
169                                         row.item_pointerR(kb, "vertex_group", ob, "vertex_groups", text="")
170                                         row.item_pointerR(kb, "relative_key", key, "keys", text="")
171                         else:
172                                 row = layout.row()
173                                 row.itemR(key, "relative")
174                                 row.itemR(key, "slurph")
175
176                 if context.edit_object:
177                         layout.enabled = False
178
179 class DATA_PT_uv_texture(DataButtonsPanel):
180         __idname__ = "DATA_PT_uv_texture"
181         __label__ = "UV Texture"
182         
183         def draw(self, context):
184                 layout = self.layout
185                 me = context.mesh
186
187                 row = layout.row()
188
189                 row.template_list(me, "uv_textures", me, "active_uv_texture_index")
190
191                 col = row.column(align=True)
192                 col.itemO("MESH_OT_uv_texture_add", icon="ICON_ZOOMIN", text="")
193                 col.itemO("MESH_OT_uv_texture_remove", icon="ICON_ZOOMOUT", text="")
194
195 class DATA_PT_vertex_colors(DataButtonsPanel):
196         __idname__ = "DATA_PT_vertex_colors"
197         __label__ = "Vertex Colors"
198         
199         def draw(self, context):
200                 layout = self.layout
201                 me = context.mesh
202
203                 row = layout.row()
204
205                 row.template_list(me, "vertex_colors", me, "active_vertex_color_index")
206
207                 col = row.column(align=True)
208                 col.itemO("MESH_OT_vertex_color_add", icon="ICON_ZOOMIN", text="")
209                 col.itemO("MESH_OT_vertex_color_remove", icon="ICON_ZOOMOUT", text="")
210
211 bpy.types.register(DATA_PT_context_mesh)
212 bpy.types.register(DATA_PT_mesh)
213 bpy.types.register(DATA_PT_materials)
214 bpy.types.register(DATA_PT_vertex_groups)
215 bpy.types.register(DATA_PT_shape_keys)
216 bpy.types.register(DATA_PT_uv_texture)
217 bpy.types.register(DATA_PT_vertex_colors)
218