3930d1029da705b5a4df8b4a74dc457a3348feaf
[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         __show_header__ = False
14         
15         def draw(self, context):
16                 layout = self.layout
17                 
18                 ob = context.object
19                 mesh = context.mesh
20                 space = context.space_data
21
22                 split = layout.split(percentage=0.65)
23
24                 if ob:
25                         split.template_ID(ob, "data")
26                         split.itemS()
27                 elif mesh:
28                         split.template_ID(space, "pin_id")
29                         split.itemS()
30
31 class DATA_PT_normals(DataButtonsPanel):
32         __label__ = "Normals"
33
34         def draw(self, context):
35                 layout = self.layout
36                 
37                 mesh = context.mesh
38                 
39                 split = layout.split()
40                 
41                 col = split.column()
42                 col.itemR(mesh, "autosmooth")
43                 sub = col.column()
44                 sub.active = mesh.autosmooth
45                 sub.itemR(mesh, "autosmooth_angle", text="Angle")
46                 
47                 col = split.column()
48                 col.itemR(mesh, "vertex_normal_flip")
49                 col.itemR(mesh, "double_sided")
50
51 class DATA_PT_meshdraw(DataButtonsPanel):
52         __label__ = "Draw"
53
54         def draw(self, context):
55                 layout = self.layout
56                 
57                 mesh = context.mesh
58                 
59                 layout.itemL(text="Edit Mode only, WIP")
60                 
61                 split = layout.split()
62                 
63                 col = split.column()
64                 col.itemR(mesh, "draw_edges", text="Edges")
65                 col.itemR(mesh, "draw_faces", text="Faces")
66                 col.itemR(mesh, "draw_creases", text="Creases")
67                 col.itemR(mesh, "draw_bevel_weights", text="Bevel Weights")
68                 col.itemR(mesh, "draw_seams", text="Seams")
69                 col.itemR(mesh, "draw_sharp", text="Sharp")
70                 
71                 col = split.column()
72                 col.itemR(mesh, "draw_normals", text="Face Normals")
73                 col.itemR(mesh, "draw_vertex_normals", text="Vertex Normals")
74                 
75                 col.itemS()
76                 
77                 col.itemR(mesh, "draw_edge_lenght")
78                 col.itemR(mesh, "draw_edge_angle")
79                 col.itemR(mesh, "draw_face_area")
80
81 class DATA_PT_vertex_groups(DataButtonsPanel):
82         __label__ = "Vertex Groups"
83         
84         def poll(self, context):
85                 return (context.object and context.object.type in ('MESH', 'LATTICE'))
86
87         def draw(self, context):
88                 layout = self.layout
89                 
90                 ob = context.object
91
92                 row = layout.row()
93                 row.template_list(ob, "vertex_groups", ob, "active_vertex_group_index")
94
95                 col = row.column(align=True)
96                 col.itemO("object.vertex_group_add", icon="ICON_ZOOMIN", text="")
97                 col.itemO("object.vertex_group_remove", icon="ICON_ZOOMOUT", text="")
98
99                 col.itemO("object.vertex_group_copy", icon="ICON_BLANK1", text="")
100                 if ob.data.users > 1:
101                         col.itemO("object.vertex_group_copy_to_linked", icon="ICON_BLANK1", text="")
102
103                 group = ob.active_vertex_group
104                 if group:
105                         row = layout.row()
106                         row.itemR(group, "name")
107
108                 if context.edit_object:
109                         row = layout.row(align=True)
110
111                         row.itemO("object.vertex_group_assign", text="Assign")
112                         row.itemO("object.vertex_group_remove_from", text="Remove")
113                         row.itemO("object.vertex_group_select", text="Select")
114                         row.itemO("object.vertex_group_deselect", text="Deselect")
115
116                         layout.itemR(context.tool_settings, "vertex_group_weight", text="Weight")
117
118 class DATA_PT_shape_keys(DataButtonsPanel):
119         __label__ = "Shape Keys"
120         
121         def poll(self, context):
122                 return (context.object and context.object.type in ('MESH', 'LATTICE'))
123
124         def draw(self, context):
125                 layout = self.layout
126                 
127                 ob = context.object
128                 key = ob.data.shape_keys
129                 kb = ob.active_shape_key
130
131                 row = layout.row()
132                 row.template_list(key, "keys", ob, "active_shape_key_index")
133
134                 col = row.column()
135
136                 subcol = col.column(align=True)
137                 subcol.itemO("object.shape_key_add", icon="ICON_ZOOMIN", text="")
138                 subcol.itemO("object.shape_key_remove", icon="ICON_ZOOMOUT", text="")
139
140                 if kb:
141                         col.itemS()
142
143                         subcol = col.column(align=True)
144                         subcol.itemR(ob, "shape_key_lock", icon="ICON_UNPINNED", text="")
145                         subcol.itemR(kb, "mute", icon="ICON_MUTE_IPO_ON", text="")
146
147                         if key.relative:
148                                 row = layout.row()
149                                 row.itemR(key, "relative")
150                                 row.itemL()
151
152                                 row = layout.row()
153                                 row.itemR(kb, "name")
154
155                                 if ob.active_shape_key_index != 0:
156                                         
157                                         row = layout.row()
158                                         row.enabled = ob.shape_key_lock == False
159                                         row.itemR(kb, "value", slider=True)
160                                         
161                                         split = layout.split()
162                                         sub = split.column()
163                                         sub.enabled = ob.shape_key_lock == False
164                                         sub.itemL(text="Range:")
165                                         sub.itemR(kb, "slider_min", text="Min")
166                                         sub.itemR(kb, "slider_max", text="Max")
167                                         
168                                         sub = split.column()
169                                         sub.itemL(text="Blend:")
170                                         sub.item_pointerR(kb, "vertex_group", ob, "vertex_groups", text="")
171                                         sub.item_pointerR(kb, "relative_key", key, "keys", text="")
172                                         
173                         else:
174                                 row = layout.row()
175                                 row.itemR(key, "relative")
176                                 row.itemR(key, "slurph")
177
178                                 layout.itemR(kb, "name")
179
180                 if context.edit_object:
181                         layout.enabled = False
182
183 class DATA_PT_uv_texture(DataButtonsPanel):
184         __label__ = "UV Texture"
185         
186         def draw(self, context):
187                 layout = self.layout
188                 
189                 me = context.mesh
190
191                 row = layout.row()
192                 col = row.column()
193                 
194                 col.template_list(me, "uv_textures", me, "active_uv_texture_index", rows=2)
195
196                 col = row.column(align=True)
197                 col.itemO("mesh.uv_texture_add", icon="ICON_ZOOMIN", text="")
198                 col.itemO("mesh.uv_texture_remove", icon="ICON_ZOOMOUT", text="")
199
200                 lay = me.active_uv_texture
201                 if lay:
202                         layout.itemR(lay, "name")
203
204 class DATA_PT_vertex_colors(DataButtonsPanel):
205         __label__ = "Vertex Colors"
206         
207         def draw(self, context):
208                 layout = self.layout
209                 
210                 me = context.mesh
211
212                 row = layout.row()
213                 col = row.column()
214
215                 col.template_list(me, "vertex_colors", me, "active_vertex_color_index", rows=2)
216
217                 col = row.column(align=True)
218                 col.itemO("mesh.vertex_color_add", icon="ICON_ZOOMIN", text="")
219                 col.itemO("mesh.vertex_color_remove", icon="ICON_ZOOMOUT", text="")
220
221                 lay = me.active_vertex_color
222                 if lay:
223                         layout.itemR(lay, "name")
224
225 bpy.types.register(DATA_PT_context_mesh)
226 bpy.types.register(DATA_PT_normals)
227 bpy.types.register(DATA_PT_meshdraw)
228 bpy.types.register(DATA_PT_vertex_groups)
229 bpy.types.register(DATA_PT_shape_keys)
230 bpy.types.register(DATA_PT_uv_texture)
231 bpy.types.register(DATA_PT_vertex_colors)