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