2.5 Smooth/Flat Shading:
[blender.git] / release / ui / space_view3d_toolbar.py
1
2 import bpy
3
4 # ********** default tools for objectmode ****************
5
6 class View3DPanel(bpy.types.Panel):
7         __space_type__ = "VIEW_3D"
8         __region_type__ = "TOOLS"
9         __context__ = "objectmode"
10
11 class VIEW3D_PT_tools_objectmode(View3DPanel):
12         __idname__ = "VIEW3D_PT_tools_objectmode"
13         __label__ = "Object Tools"
14
15         def draw(self, context):
16                 layout = self.layout
17                 
18                 layout.itemL(text="Transform:")
19                 
20                 col = layout.column(align=True)
21                 col.itemO("tfm.translate")
22                 col.itemO("tfm.rotate")
23                 col.itemO("tfm.resize", text="Scale")
24                 
25                 layout.itemL(text="Object:")
26                 
27                 col = layout.column(align=True)
28                 col.itemO("object.duplicate")
29                 col.itemO("object.delete")
30                 
31                 if context.active_object.type == 'MESH':
32                         layout.itemL(text="Shading:")
33                 
34                         col = layout.column(align=True)
35                         col.itemO("object.shade_smooth", text="Smooth")
36                         col.itemO("object.shade_flat", text="Flat")
37                 
38                 layout.itemL(text="Keyframes:")
39                 
40                 col = layout.column(align=True)
41                 col.itemO("anim.insert_keyframe_menu", text="Insert")
42                 col.itemO("anim.delete_keyframe_v3d", text="Remove")
43
44 # ********** default tools for editmode_mesh ****************
45
46 class View3DPanel(bpy.types.Panel):
47         __space_type__ = "VIEW_3D"
48         __region_type__ = "TOOLS"
49         __context__ = "editmode_mesh"
50
51 class VIEW3D_PT_tools_editmode_mesh(View3DPanel):
52         __idname__ = "VIEW3D_PT_tools_editmode_mesh"
53         __label__ = "Mesh Tools"
54
55         def draw(self, context):
56                 layout = self.layout
57                 
58                 layout.itemL(text="Transform:")
59                 
60                 col = layout.column(align=True)
61                 col.itemO("tfm.translate")
62                 col.itemO("tfm.rotate")
63                 col.itemO("tfm.resize", text="Scale")
64                 
65                 layout.itemL(text="Mesh:")
66                 
67                 col = layout.column(align=True)
68                 col.itemO("mesh.duplicate")
69                 col.itemO("mesh.delete")
70                 
71                 layout.itemL(text="Modeling:")
72                 
73                 col = layout.column(align=True)
74                 col.itemO("mesh.extrude")
75                 col.itemO("mesh.subdivide")
76                 col.itemO("mesh.spin")
77                 col.itemO("mesh.screw")
78                 
79                 layout.itemL(text="Shading:")
80                 
81                 col = layout.column(align=True)
82                 col.itemO("mesh.faces_shade_smooth", text="Smooth")
83                 col.itemO("mesh.faces_shade_flat", text="Flat")
84                 
85                 layout.itemL(text="UV Mapping:")
86                 
87                 col = layout.column(align=True)
88                 col.itemO("uv.mapping_menu", text="Unwrap")
89                 col.itemO("mesh.uvs_rotate")
90                 col.itemO("mesh.uvs_mirror")
91
92 # ********** default tools for editmode_curve ****************
93
94 class View3DPanel(bpy.types.Panel):
95         __space_type__ = "VIEW_3D"
96         __region_type__ = "TOOLS"
97         __context__ = "editmode_curve"
98
99 class VIEW3D_PT_tools_editmode_curve(View3DPanel):
100         __idname__ = "VIEW3D_PT_tools_editmode_curve"
101         __label__ = "Curve Tools"
102
103         def draw(self, context):
104                 layout = self.layout
105                 
106                 layout.itemL(text="Transform:")
107                 
108                 col = layout.column(align=True)
109                 col.itemO("tfm.translate")
110                 col.itemO("tfm.rotate")
111                 col.itemO("tfm.resize", text="Scale")
112                 
113                 layout.itemL(text="Curve:")
114
115                 col = layout.column(align=True)
116                 col.itemO("curve.duplicate")
117                 col.itemO("curve.delete")
118                 col.itemO("curve.cyclic_toggle")
119                 col.itemO("curve.switch_direction")
120                 
121                 layout.itemL(text="Modeling:")
122
123                 col = layout.column(align=True)
124                 col.itemO("curve.extrude")
125                 col.itemO("curve.subdivide")
126
127 # ********** default tools for editmode_surface ****************
128
129 class View3DPanel(bpy.types.Panel):
130         __space_type__ = "VIEW_3D"
131         __region_type__ = "TOOLS"
132         __context__ = "editmode_surface"
133
134 class VIEW3D_PT_tools_editmode_surface(View3DPanel):
135         __idname__ = "VIEW3D_PT_tools_editmode_surface"
136         __label__ = "Surface Tools"
137
138         def draw(self, context):
139                 layout = self.layout
140                 
141                 layout.itemL(text="Transform:")
142
143                 col = layout.column(align=True)
144                 col.itemO("tfm.translate")
145                 col.itemO("tfm.rotate")
146                 col.itemO("tfm.resize", text="Scale")
147                 
148                 layout.itemL(text="Curve:")
149
150                 col = layout.column(align=True)
151                 col.itemO("curve.duplicate")
152                 col.itemO("curve.delete")
153                 col.itemO("curve.cyclic_toggle")
154                 col.itemO("curve.switch_direction")
155                 
156                 layout.itemL(text="Modeling:")
157
158                 col = layout.column(align=True)
159                 col.itemO("curve.extrude")
160                 col.itemO("curve.subdivide")
161
162 # ********** default tools for editmode_text ****************
163
164 class View3DPanel(bpy.types.Panel):
165         __space_type__ = "VIEW_3D"
166         __region_type__ = "TOOLS"
167         __context__ = "editmode_text"
168
169 class VIEW3D_PT_tools_editmode_text(View3DPanel):
170         __idname__ = "VIEW3D_PT_tools_editmode_text"
171         __label__ = "Text Tools"
172
173         def draw(self, context):
174                 layout = self.layout
175
176                 col = layout.column(align=True)
177                 col.itemO("font.text_copy", text="Copy")
178                 col.itemO("font.text_paste", text="Paste")
179                 
180                 col = layout.column()
181                 col.itemO("font.case_set")
182                 col.itemO("font.style_toggle")
183
184 # ********** default tools for editmode_armature ****************
185
186 class View3DPanel(bpy.types.Panel):
187         __space_type__ = "VIEW_3D"
188         __region_type__ = "TOOLS"
189         __context__ = "editmode_armature"
190
191 class VIEW3D_PT_tools_editmode_armature(View3DPanel):
192         __idname__ = "VIEW3D_PT_tools_editmode_armature"
193         __label__ = "Armature Tools"
194
195         def draw(self, context):
196                 layout = self.layout
197                 
198                 layout.itemL(text="Transform:")
199                 
200                 col = layout.column(align=True)
201                 col.itemO("tfm.translate")
202                 col.itemO("tfm.rotate")
203                 col.itemO("tfm.resize", text="Scale")
204                 
205                 layout.itemL(text="Bones:")
206
207                 col = layout.column(align=True)
208                 col.itemO("armature.bone_primitive_add", text="Add")
209                 col.itemO("armature.duplicate", text="Duplicate")
210                 col.itemO("armature.delete", text="Delete")
211                 
212                 layout.itemL(text="Modeling:")
213                 layout.itemO("armature.extrude")
214
215 # ********** default tools for editmode_mball ****************
216
217 class View3DPanel(bpy.types.Panel):
218         __space_type__ = "VIEW_3D"
219         __region_type__ = "TOOLS"
220         __context__ = "editmode_mball"
221
222 class VIEW3D_PT_tools_editmode_mball(View3DPanel):
223         __idname__ = "VIEW3D_PT_tools_editmode_mball"
224         __label__ = "Meta Tools"
225
226         def draw(self, context):
227                 layout = self.layout
228                 
229                 layout.itemL(text="Transform:")
230                 
231                 col = layout.column(align=True)
232                 col.itemO("tfm.translate")
233                 col.itemO("tfm.rotate")
234                 col.itemO("tfm.resize", text="Scale")
235
236 # ********** default tools for editmode_lattice ****************
237
238 class View3DPanel(bpy.types.Panel):
239         __space_type__ = "VIEW_3D"
240         __region_type__ = "TOOLS"
241         __context__ = "editmode_lattice"
242
243 class VIEW3D_PT_tools_editmode_lattice(View3DPanel):
244         __idname__ = "VIEW3D_PT_tools_editmode_lattice"
245         __label__ = "Lattice Tools"
246
247         def draw(self, context):
248                 layout = self.layout
249                 
250                 layout.itemL(text="Transform:")
251
252                 col = layout.column(align=True)
253                 col.itemO("tfm.translate")
254                 col.itemO("tfm.rotate")
255                 col.itemO("tfm.resize", text="Scale")
256
257 # ********** default tools for posemode ****************
258
259 class View3DPanel(bpy.types.Panel):
260         __space_type__ = "VIEW_3D"
261         __region_type__ = "TOOLS"
262         __context__ = "posemode"
263
264 class VIEW3D_PT_tools_posemode(View3DPanel):
265         __idname__ = "VIEW3D_PT_tools_posemode"
266         __label__ = "Pose Tools"
267
268         def draw(self, context):
269                 layout = self.layout
270                 
271                 layout.itemL(text="Transform:")
272
273                 col = layout.column(align=True)
274                 col.itemO("tfm.translate")
275                 col.itemO("tfm.rotate")
276                 col.itemO("tfm.resize", text="Scale")
277                 
278                 layout.itemL(text="Bones:")
279
280                 col = layout.column(align=True)
281                 col.itemO("pose.hide", text="Hide")
282                 col.itemO("pose.reveal", text="Reveal")
283                 
284                 layout.itemL(text="Keyframes:")
285                 
286                 col = layout.column(align=True)
287                 col.itemO("anim.insert_keyframe_menu", text="Insert")
288                 col.itemO("anim.delete_keyframe_v3d", text="Remove")
289                 
290                 layout.itemL(text="Pose:")
291                 
292                 col = layout.column(align=True)
293                 col.itemO("pose.copy", text="Copy")
294                 col.itemO("pose.paste", text="Paste")
295                 
296                 layout.itemL(text="Library:")
297                 
298                 col = layout.column(align=True)
299                 col.itemO("poselib.pose_add", text="Add")
300                 col.itemO("poselib.pose_remove", text="Remove")
301
302 # ********** default tools for paint modes ****************
303
304 class VIEW3D_PT_tools_brush(bpy.types.Panel):
305         __space_type__ = "VIEW_3D"
306         __region_type__ = "TOOLS"
307         __label__ = "Brush"
308
309         def brush_src(self, context):
310                 ts = context.tool_settings
311                 if context.sculpt_object:
312                         return ts.sculpt
313                 elif context.vpaint_object:
314                         return ts.vpaint
315                 elif context.wpaint_object:
316                         return ts.wpaint
317                 elif context.tpaint_object:
318                         return ts.tpaint
319                 return False
320
321         def poll(self, context):
322                 return self.brush_src(context)
323
324         def draw(self, context):
325                 src = self.brush_src(context)
326                 brush = src.brush
327                 layout = self.layout
328
329                 layout.split().row().template_ID(src, "brush")
330
331                 if context.sculpt_object:
332                         layout.column().itemR(brush, "sculpt_tool", expand=True)
333
334                 split = layout.split()
335                 
336                 col = split.column()
337                 row = col.row(align=True)
338                 row.itemR(brush, "size", slider=True)
339                 row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
340                 
341                 if context.wpaint_object:
342                         col.itemR(context.tool_settings, "vertex_group_weight", text="Weight", slider=True)
343                         
344                 col.itemR(brush, "strength", slider=True)
345                 row = col.row(align=True)
346                 row.itemR(brush, "falloff", slider=True)
347                 row.itemR(brush, "falloff_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
348                 
349                 if context.vpaint_object:
350                         col.itemR(brush, "color", text="")
351                 if context.tpaint_object:
352                         row = col.row(align=True)
353                         row.itemR(brush, "clone_opacity", slider=True, text=Opacity)
354                         row.itemR(brush, "opacity_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
355                 
356                 row = col.row(align=True)
357                 row.itemR(brush, "space", text="")
358                 rowsub = row.row(align=True)
359                 rowsub.active = brush.space
360                 rowsub.itemR(brush, "spacing", text="Spacing", slider=True)
361                 rowsub.itemR(brush, "spacing_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
362
363                 split = layout.split()
364                 col = split.column()
365                 col.itemR(brush, "airbrush")
366                 col.itemR(brush, "anchored")
367                 col.itemR(brush, "rake")
368
369 class VIEW3D_PT_tools_brush_curve(bpy.types.Panel):
370         __space_type__ = "VIEW_3D"
371         __region_type__ = "TOOLS"
372         __label__ = "Curve"
373
374         def brush_src(self, context):
375                 ts = context.tool_settings
376                 if context.sculpt_object:
377                         return ts.sculpt
378                 elif context.vpaint_object:
379                         return ts.vpaint
380                 elif context.wpaint_object:
381                         return ts.wpaint
382                 elif context.tpaint_object:
383                         return ts.tpaint
384                 return False
385
386         def poll(self, context):
387                 return self.brush_src(context)
388
389         def draw(self, context):
390                 src = self.brush_src(context)
391                 brush = src.brush
392                 layout = self.layout
393
394                 split = layout.split()
395                 split.template_curve_mapping(brush.curve)
396                 
397 class VIEW3D_PT_sculpt_options(bpy.types.Panel):
398         __space_type__ = "VIEW_3D"
399         __region_type__ = "TOOLS"
400         __label__ = "Options"
401
402         def poll(self, context):
403                 return context.sculpt_object
404
405         def draw(self, context):
406                 layout = self.layout
407                 sculpt = context.tool_settings.sculpt
408
409                 col = layout.column()
410                 col.itemR(sculpt, "partial_redraw", text="Partial Refresh")
411                 col.itemR(sculpt, "show_brush")
412
413                 split = self.layout.split()
414                 
415                 col = split.column()
416                 col.itemL(text="Symmetry:")
417                 col.itemR(sculpt, "symmetry_x", text="X")
418                 col.itemR(sculpt, "symmetry_y", text="Y")
419                 col.itemR(sculpt, "symmetry_z", text="Z")
420                 
421                 col = split.column()
422                 col.itemL(text="Lock:")
423                 col.itemR(sculpt, "lock_x", text="X")
424                 col.itemR(sculpt, "lock_y", text="Y")
425                 col.itemR(sculpt, "lock_z", text="Z")
426
427 # ********** default tools for weightpaint ****************
428
429 class View3DPanel(bpy.types.Panel):
430         __space_type__ = "VIEW_3D"
431         __region_type__ = "TOOLS"
432         __context__ = "weightpaint"
433
434 class VIEW3D_PT_weightpaint_options(View3DPanel):
435         __idname__ = "VIEW3D_PT_tools_weightpaint"
436         __label__ = "Options"
437
438         def draw(self, context):
439                 layout = self.layout
440                 wpaint = context.tool_settings.wpaint
441
442                 col = layout.column()
443                 col.itemL(text="Blend:")
444                 col.itemR(wpaint, "mode", text="")
445                 col.itemR(wpaint, "all_faces")
446                 col.itemR(wpaint, "normals")
447                 col.itemR(wpaint, "spray")
448                 col.itemR(wpaint, "vertex_dist", text="Distance")
449
450 # Commented out because the Apply button isn't an operator yet, making these settings useless
451 #               col.itemL(text="Gamma:")
452 #               col.itemR(wpaint, "gamma", text="")
453 #               col.itemL(text="Multiply:")
454 #               col.itemR(wpaint, "mul", text="")
455
456
457 # ********** default tools for vertexpaint ****************
458
459 class View3DPanel(bpy.types.Panel):
460         __space_type__ = "VIEW_3D"
461         __region_type__ = "TOOLS"
462         __context__ = "vertexpaint"
463
464 class VIEW3D_PT_vertexpaint_options(View3DPanel):
465         __idname__ = "VIEW3D_PT_vertexpaintoptions"
466         __label__ = "Options"
467
468         def draw(self, context):
469                 layout = self.layout
470                 vpaint = context.tool_settings.vpaint
471
472                 col = layout.column()
473                 col.itemL(text="Blend:")
474                 col.itemR(vpaint, "mode", text="")
475                 col.itemR(vpaint, "all_faces")
476                 col.itemR(vpaint, "normals")
477                 col.itemR(vpaint, "spray")
478                 col.itemR(vpaint, "vertex_dist", text="Distance")
479 # Commented out because the Apply button isn't an operator yet, making these settings useless
480 #               col.itemL(text="Gamma:")
481 #               col.itemR(vpaint, "gamma", text="")
482 #               col.itemL(text="Multiply:")
483 #               col.itemR(vpaint, "mul", text="")
484
485
486 # ********** default tools for texturepaint ****************
487
488 class View3DPanel(bpy.types.Panel):
489         __space_type__ = "VIEW_3D"
490         __region_type__ = "TOOLS"
491         __context__ = "texturepaint"
492
493 class VIEW3D_PT_tools_texturepaint(View3DPanel):
494         __idname__ = "VIEW3D_PT_tools_texturepaint"
495         __label__ = "Texture Paint Tools"
496
497         def draw(self, context):
498                 layout = self.layout
499
500                 layout.itemL(text="Nothing yet")
501                 
502
503 bpy.types.register(VIEW3D_PT_tools_objectmode)
504 bpy.types.register(VIEW3D_PT_tools_editmode_mesh)
505 bpy.types.register(VIEW3D_PT_tools_editmode_curve)
506 bpy.types.register(VIEW3D_PT_tools_editmode_surface)
507 bpy.types.register(VIEW3D_PT_tools_editmode_text)
508 bpy.types.register(VIEW3D_PT_tools_editmode_armature)
509 bpy.types.register(VIEW3D_PT_tools_editmode_mball)
510 bpy.types.register(VIEW3D_PT_tools_editmode_lattice)
511 bpy.types.register(VIEW3D_PT_tools_posemode)
512 bpy.types.register(VIEW3D_PT_tools_brush)
513 bpy.types.register(VIEW3D_PT_tools_brush_curve)
514 bpy.types.register(VIEW3D_PT_sculpt_options)
515 bpy.types.register(VIEW3D_PT_vertexpaint_options)
516 bpy.types.register(VIEW3D_PT_weightpaint_options)
517 bpy.types.register(VIEW3D_PT_tools_texturepaint)