Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / release / ui / buttons_data_mesh.py
1
2 import bpy
3
4 class DataButtonsPanel(bpy.types.Panel):
5         __space_type__ = "PROPERTIES"
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()
110                         
111                         sub = row.row(align=True)
112                         sub.itemO("object.vertex_group_assign", text="Assign")
113                         sub.itemO("object.vertex_group_remove_from", text="Remove")
114                         
115                         sub = row.row(align=True)
116                         sub.itemO("object.vertex_group_select", text="Select")
117                         sub.itemO("object.vertex_group_deselect", text="Deselect")
118
119                         layout.itemR(context.tool_settings, "vertex_group_weight", text="Weight")
120
121 class DATA_PT_shape_keys(DataButtonsPanel):
122         __label__ = "Shape Keys"
123         
124         def poll(self, context):
125                 return (context.object and context.object.type in ('MESH', 'LATTICE'))
126
127         def draw(self, context):
128                 layout = self.layout
129                 
130                 ob = context.object
131                 key = ob.data.shape_keys
132                 kb = ob.active_shape_key
133
134                 row = layout.row()
135                 row.template_list(key, "keys", ob, "active_shape_key_index")
136
137                 col = row.column()
138
139                 subcol = col.column(align=True)
140                 subcol.itemO("object.shape_key_add", icon="ICON_ZOOMIN", text="")
141                 subcol.itemO("object.shape_key_remove", icon="ICON_ZOOMOUT", text="")
142
143                 if kb:
144                         col.itemS()
145
146                         subcol = col.column(align=True)
147                         subcol.itemR(ob, "shape_key_lock", icon="ICON_UNPINNED", text="")
148                         subcol.itemR(kb, "mute", icon="ICON_MUTE_IPO_ON", text="")
149
150                         if key.relative:
151                                 row = layout.row()
152                                 row.itemR(key, "relative")
153                                 row.itemL()
154
155                                 row = layout.row()
156                                 row.itemR(kb, "name")
157
158                                 if ob.active_shape_key_index != 0:
159                                         
160                                         row = layout.row()
161                                         row.enabled = ob.shape_key_lock == False
162                                         row.itemR(kb, "value", slider=True)
163                                         
164                                         split = layout.split()
165                                         sub = split.column(align=True)
166                                         sub.enabled = ob.shape_key_lock == False
167                                         sub.itemL(text="Range:")
168                                         sub.itemR(kb, "slider_min", text="Min")
169                                         sub.itemR(kb, "slider_max", text="Max")
170                                         
171                                         sub = split.column()
172                                         sub.itemL(text="Blend:")
173                                         sub.item_pointerR(kb, "vertex_group", ob, "vertex_groups", text="")
174                                         sub.item_pointerR(kb, "relative_key", key, "keys", text="")
175                                         
176                         else:
177                                 row = layout.row()
178                                 row.itemR(key, "relative")
179                                 row.itemR(key, "slurph")
180
181                                 layout.itemR(kb, "name")
182
183                 if context.edit_object:
184                         layout.enabled = False
185
186 class DATA_PT_uv_texture(DataButtonsPanel):
187         __label__ = "UV Texture"
188         
189         def draw(self, context):
190                 layout = self.layout
191                 
192                 me = context.mesh
193
194                 row = layout.row()
195                 col = row.column()
196                 
197                 col.template_list(me, "uv_textures", me, "active_uv_texture_index", rows=2)
198
199                 col = row.column(align=True)
200                 col.itemO("mesh.uv_texture_add", icon="ICON_ZOOMIN", text="")
201                 col.itemO("mesh.uv_texture_remove", icon="ICON_ZOOMOUT", text="")
202
203                 lay = me.active_uv_texture
204                 if lay:
205                         layout.itemR(lay, "name")
206
207 class DATA_PT_vertex_colors(DataButtonsPanel):
208         __label__ = "Vertex Colors"
209         
210         def draw(self, context):
211                 layout = self.layout
212                 
213                 me = context.mesh
214
215                 row = layout.row()
216                 col = row.column()
217
218                 col.template_list(me, "vertex_colors", me, "active_vertex_color_index", rows=2)
219
220                 col = row.column(align=True)
221                 col.itemO("mesh.vertex_color_add", icon="ICON_ZOOMIN", text="")
222                 col.itemO("mesh.vertex_color_remove", icon="ICON_ZOOMOUT", text="")
223
224                 lay = me.active_vertex_color
225                 if lay:
226                         layout.itemR(lay, "name")
227
228 bpy.types.register(DATA_PT_context_mesh)
229 bpy.types.register(DATA_PT_normals)
230 bpy.types.register(DATA_PT_meshdraw)
231 bpy.types.register(DATA_PT_vertex_groups)
232 bpy.types.register(DATA_PT_shape_keys)
233 bpy.types.register(DATA_PT_uv_texture)
234 bpy.types.register(DATA_PT_vertex_colors)