CMake/macOS: Use custom LIBDIR if set on CLI
[blender.git] / release / scripts / startup / bl_ui / space_view3d.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import (
22     Header,
23     Menu,
24     Panel,
25 )
26 from bl_ui.properties_paint_common import (
27     UnifiedPaintPanel,
28     brush_basic_texpaint_settings,
29 )
30 from bl_ui.properties_grease_pencil_common import (
31     AnnotationDataPanel,
32     AnnotationOnionSkin,
33     GreasePencilMaterialsPanel,
34     GreasePencilVertexcolorPanel,
35 )
36 from bl_ui.space_toolsystem_common import (
37     ToolActivePanelHelper,
38 )
39 from bpy.app.translations import contexts as i18n_contexts
40
41
42 class VIEW3D_HT_tool_header(Header):
43     bl_space_type = 'VIEW_3D'
44     bl_region_type = 'TOOL_HEADER'
45
46     def draw(self, context):
47         layout = self.layout
48
49         layout.row(align=True).template_header()
50
51         self.draw_tool_settings(context)
52
53         layout.separator_spacer()
54
55         VIEW3D_HT_header.draw_xform_template(layout, context)
56
57         layout.separator_spacer()
58
59         self.draw_mode_settings(context)
60
61     def draw_tool_settings(self, context):
62         layout = self.layout
63         tool_mode = context.mode
64
65         # Active Tool
66         # -----------
67         from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
68         tool = ToolSelectPanelHelper.draw_active_tool_header(
69             context, layout,
70             tool_key=('VIEW_3D', tool_mode),
71         )
72         # Object Mode Options
73         # -------------------
74
75         # Example of how tool_settings can be accessed as pop-overs.
76
77         # TODO(campbell): editing options should be after active tool options
78         # (obviously separated for from the users POV)
79         draw_fn = getattr(_draw_tool_settings_context_mode, tool_mode, None)
80         if draw_fn is not None:
81             is_valid_context = draw_fn(context, layout, tool)
82
83         def draw_3d_brush_settings(layout, tool_mode):
84             layout.popover("VIEW3D_PT_tools_brush_settings_advanced", text="Brush")
85             if tool_mode != 'PAINT_WEIGHT':
86                 layout.popover("VIEW3D_PT_tools_brush_texture")
87             if tool_mode == 'PAINT_TEXTURE':
88                 layout.popover("VIEW3D_PT_tools_mask_texture")
89             layout.popover("VIEW3D_PT_tools_brush_stroke")
90             layout.popover("VIEW3D_PT_tools_brush_falloff")
91             layout.popover("VIEW3D_PT_tools_brush_display")
92
93         # Note: general mode options should be added to 'draw_mode_settings'.
94         if tool_mode == 'SCULPT':
95             if is_valid_context:
96                 draw_3d_brush_settings(layout, tool_mode)
97         elif tool_mode == 'PAINT_VERTEX':
98             if is_valid_context:
99                 draw_3d_brush_settings(layout, tool_mode)
100         elif tool_mode == 'PAINT_WEIGHT':
101             if is_valid_context:
102                 draw_3d_brush_settings(layout, tool_mode)
103         elif tool_mode == 'PAINT_TEXTURE':
104             if is_valid_context:
105                 draw_3d_brush_settings(layout, tool_mode)
106         elif tool_mode == 'EDIT_ARMATURE':
107             pass
108         elif tool_mode == 'EDIT_CURVE':
109             pass
110         elif tool_mode == 'EDIT_MESH':
111             pass
112         elif tool_mode == 'POSE':
113             pass
114         elif tool_mode == 'PARTICLE':
115             # Disable, only shows "Brush" panel, which is already in the top-bar.
116             # if tool.has_datablock:
117             #     layout.popover_group(context=".paint_common", **popover_kw)
118             pass
119         elif tool_mode == 'PAINT_GPENCIL':
120             if is_valid_context:
121                 brush = context.tool_settings.gpencil_paint.brush
122                 if brush.gpencil_tool != 'ERASE':
123                     if brush.gpencil_tool != 'TINT':
124                         layout.popover("VIEW3D_PT_tools_grease_pencil_brush_advanced")
125
126                     if brush.gpencil_tool not in {'FILL', 'TINT'}:
127                         layout.popover("VIEW3D_PT_tools_grease_pencil_brush_stroke")
128
129                     layout.popover("VIEW3D_PT_tools_grease_pencil_paint_appearance")
130         elif tool_mode == 'SCULPT_GPENCIL':
131             if is_valid_context:
132                 brush = context.tool_settings.gpencil_sculpt_paint.brush
133                 tool = brush.gpencil_tool
134                 if tool in {'SMOOTH', 'RANDOMIZE'}:
135                     layout.popover("VIEW3D_PT_tools_grease_pencil_sculpt_options")
136                 layout.popover("VIEW3D_PT_tools_grease_pencil_sculpt_appearance")
137         elif tool_mode == 'WEIGHT_GPENCIL':
138             if is_valid_context:
139                 layout.popover("VIEW3D_PT_tools_grease_pencil_weight_appearance")
140         elif tool_mode == 'VERTEX_GPENCIL':
141             if is_valid_context:
142                 layout.popover("VIEW3D_PT_tools_grease_pencil_vertex_appearance")
143
144     def draw_mode_settings(self, context):
145         layout = self.layout
146         mode_string = context.mode
147
148         def row_for_mirror():
149             row = layout.row(align=True)
150             row.label(icon='MOD_MIRROR')
151             sub = row.row(align=True)
152             sub.scale_x = 0.6
153             return row, sub
154
155         if mode_string == 'EDIT_ARMATURE':
156             _row, sub = row_for_mirror()
157             sub.prop(context.object.data, "use_mirror_x", text="X", toggle=True)
158         elif mode_string == 'POSE':
159             _row, sub = row_for_mirror()
160             sub.prop(context.object.pose, "use_mirror_x", text="X", toggle=True)
161         elif mode_string in {'EDIT_MESH', 'PAINT_WEIGHT', 'SCULPT', 'PAINT_VERTEX'}:
162             # Mesh Modes, Use Mesh Symmetry
163             row, sub = row_for_mirror()
164             sub.prop(context.object.data, "use_mirror_x", text="X", toggle=True)
165             sub.prop(context.object.data, "use_mirror_y", text="Y", toggle=True)
166             sub.prop(context.object.data, "use_mirror_z", text="Z", toggle=True)
167             if mode_string == 'EDIT_MESH':
168                 tool_settings = context.tool_settings
169                 layout.prop(tool_settings, "use_mesh_automerge", text="")
170             elif mode_string == 'PAINT_WEIGHT':
171                 row.popover(panel="VIEW3D_PT_tools_weightpaint_symmetry_for_topbar", text="")
172             elif mode_string == 'SCULPT':
173                 row.popover(panel="VIEW3D_PT_sculpt_symmetry_for_topbar", text="")
174             elif mode_string == 'PAINT_VERTEX':
175                 row.popover(panel="VIEW3D_PT_tools_vertexpaint_symmetry_for_topbar", text="")
176
177         # Expand panels from the side-bar as popovers.
178         popover_kw = {"space_type": 'VIEW_3D', "region_type": 'UI', "category": "Tool"}
179
180         if mode_string == 'SCULPT':
181             layout.popover_group(context=".sculpt_mode", **popover_kw)
182         elif mode_string == 'PAINT_VERTEX':
183             layout.popover_group(context=".vertexpaint", **popover_kw)
184         elif mode_string == 'PAINT_WEIGHT':
185             layout.popover_group(context=".weightpaint", **popover_kw)
186         elif mode_string == 'PAINT_TEXTURE':
187             layout.popover_group(context=".imagepaint", **popover_kw)
188         elif mode_string == 'EDIT_TEXT':
189             layout.popover_group(context=".text_edit", **popover_kw)
190         elif mode_string == 'EDIT_ARMATURE':
191             layout.popover_group(context=".armature_edit", **popover_kw)
192         elif mode_string == 'EDIT_METABALL':
193             layout.popover_group(context=".mball_edit", **popover_kw)
194         elif mode_string == 'EDIT_LATTICE':
195             layout.popover_group(context=".lattice_edit", **popover_kw)
196         elif mode_string == 'EDIT_CURVE':
197             layout.popover_group(context=".curve_edit", **popover_kw)
198         elif mode_string == 'EDIT_MESH':
199             layout.popover_group(context=".mesh_edit", **popover_kw)
200         elif mode_string == 'POSE':
201             layout.popover_group(context=".posemode", **popover_kw)
202         elif mode_string == 'PARTICLE':
203             layout.popover_group(context=".particlemode", **popover_kw)
204         elif mode_string == 'OBJECT':
205             layout.popover_group(context=".objectmode", **popover_kw)
206         elif mode_string in {'PAINT_GPENCIL', 'EDIT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'}:
207             # Grease pencil layer.
208             gpl = context.active_gpencil_layer
209             if gpl and gpl.info is not None:
210                 text = gpl.info
211                 maxw = 25
212                 if len(text) > maxw:
213                     text = text[:maxw - 5] + '..' + text[-3:]
214             else:
215                 text = ""
216
217             layout.label(text="Layer:")
218             sub = layout.row()
219             sub.ui_units_x = 8
220             sub.popover(
221                 panel="TOPBAR_PT_gpencil_layers",
222                 text=text,
223             )
224
225
226 class _draw_tool_settings_context_mode:
227     @staticmethod
228     def SCULPT(context, layout, tool):
229         if (tool is None) or (not tool.has_datablock):
230             return False
231
232         paint = context.tool_settings.sculpt
233         layout.template_ID_preview(paint, "brush", rows=3, cols=8, hide_buttons=True)
234
235         brush = paint.brush
236         if brush is None:
237             return False
238
239         tool_settings = context.tool_settings
240         capabilities = brush.sculpt_capabilities
241
242         ups = tool_settings.unified_paint_settings
243
244         size = "size"
245         size_owner = ups if ups.use_unified_size else brush
246         if size_owner.use_locked_size == 'SCENE':
247             size = "unprojected_radius"
248
249         UnifiedPaintPanel.prop_unified(
250             layout,
251             context,
252             brush,
253             size,
254             pressure_name="use_pressure_size",
255             unified_name="use_unified_size",
256             text="Radius",
257             slider=True,
258             header=True
259         )
260
261         # strength, use_strength_pressure
262         pressure_name = "use_pressure_strength" if capabilities.has_strength_pressure else None
263         UnifiedPaintPanel.prop_unified(
264             layout,
265             context,
266             brush,
267             "strength",
268             pressure_name=pressure_name,
269             unified_name="use_unified_strength",
270             text="Strength",
271             header=True
272         )
273
274         # direction
275         if not capabilities.has_direction:
276             layout.row().prop(brush, "direction", expand=True, text="")
277
278         if capabilities.has_color:
279             UnifiedPaintPanel.prop_unified_color(layout, context, brush, "color", text="")
280             layout.prop(brush, "blend", text="", expand=False)
281
282         return True
283
284     @staticmethod
285     def PAINT_TEXTURE(context, layout, tool):
286         if (tool is None) or (not tool.has_datablock):
287             return False
288
289         paint = context.tool_settings.image_paint
290         layout.template_ID_preview(paint, "brush", rows=3, cols=8, hide_buttons=True)
291
292         brush = paint.brush
293         if brush is None:
294             return False
295
296         brush_basic_texpaint_settings(layout, context, brush, compact=True)
297
298         return True
299
300     @staticmethod
301     def PAINT_VERTEX(context, layout, tool):
302         if (tool is None) or (not tool.has_datablock):
303             return False
304
305         paint = context.tool_settings.vertex_paint
306         layout.template_ID_preview(paint, "brush", rows=3, cols=8, hide_buttons=True)
307
308         brush = paint.brush
309         if brush is None:
310             return False
311
312         brush_basic_texpaint_settings(layout, context, brush, compact=True)
313
314         return True
315
316     @staticmethod
317     def PAINT_WEIGHT(context, layout, tool):
318         if (tool is None) or (not tool.has_datablock):
319             return False
320
321         paint = context.tool_settings.weight_paint
322         layout.template_ID_preview(paint, "brush", rows=3, cols=8, hide_buttons=True)
323         brush = paint.brush
324         if brush is None:
325             return False
326
327         capabilities = brush.weight_paint_capabilities
328         if capabilities.has_weight:
329             UnifiedPaintPanel.prop_unified(
330                 layout,
331                 context,
332                 brush,
333                 "weight",
334                 unified_name="use_unified_weight",
335                 slider=True,
336                 header=True
337             )
338
339         UnifiedPaintPanel.prop_unified(
340             layout,
341             context,
342             brush,
343             "size",
344             pressure_name="use_pressure_size",
345             unified_name="use_unified_size",
346             slider=True,
347             text="Radius",
348             header=True
349         )
350         UnifiedPaintPanel.prop_unified(
351             layout,
352             context,
353             brush,
354             "strength",
355             pressure_name="use_pressure_strength",
356             unified_name="use_unified_strength",
357             header=True
358         )
359
360         return True
361
362     @staticmethod
363     def PAINT_GPENCIL(context, layout, tool):
364         if tool is None:
365             return False
366
367         if tool.idname == "builtin.cutter":
368             row = layout.row(align=True)
369             row.prop(context.tool_settings.gpencil_sculpt, "intersection_threshold")
370             return False
371         elif not tool.has_datablock:
372             return False
373
374         paint = context.tool_settings.gpencil_paint
375         brush = paint.brush
376         if brush is None:
377             return False
378
379         gp_settings = brush.gpencil_settings
380
381         row = layout.row(align=True)
382         tool_settings = context.scene.tool_settings
383         settings = tool_settings.gpencil_paint
384         row.template_ID_preview(settings, "brush", rows=3, cols=8, hide_buttons=True)
385
386         if context.object and brush.gpencil_tool in {'FILL', 'DRAW'}:
387             from bl_ui.properties_paint_common import (
388                 brush_basic__draw_color_selector,
389             )
390             brush_basic__draw_color_selector(context, layout, brush, gp_settings, None)
391
392         if context.object and brush.gpencil_tool == 'TINT':
393             row.separator(factor=0.4)
394             row.prop_with_popover(brush, "color", text="", panel="TOPBAR_PT_gpencil_vertexcolor")
395
396         from bl_ui.properties_paint_common import (
397             brush_basic_gpencil_paint_settings,
398         )
399         brush_basic_gpencil_paint_settings(layout, context, brush, compact=True)
400
401         return True
402
403     @staticmethod
404     def SCULPT_GPENCIL(context, layout, tool):
405         if (tool is None) or (not tool.has_datablock):
406             return False
407         paint = context.tool_settings.gpencil_sculpt_paint
408         brush = paint.brush
409
410         from bl_ui.properties_paint_common import (
411             brush_basic_gpencil_sculpt_settings,
412         )
413         brush_basic_gpencil_sculpt_settings(layout, context, brush, compact=True)
414
415         return True
416
417     @staticmethod
418     def WEIGHT_GPENCIL(context, layout, tool):
419         if (tool is None) or (not tool.has_datablock):
420             return False
421         paint = context.tool_settings.gpencil_weight_paint
422         brush = paint.brush
423
424         from bl_ui.properties_paint_common import (
425             brush_basic_gpencil_weight_settings,
426         )
427         brush_basic_gpencil_weight_settings(layout, context, brush, compact=True)
428
429         return True
430
431     @staticmethod
432     def VERTEX_GPENCIL(context, layout, tool):
433         if (tool is None) or (not tool.has_datablock):
434             return False
435
436         paint = context.tool_settings.gpencil_vertex_paint
437         brush = paint.brush
438
439         row = layout.row(align=True)
440         tool_settings = context.scene.tool_settings
441         settings = tool_settings.gpencil_vertex_paint
442         row.template_ID_preview(settings, "brush", rows=3, cols=8, hide_buttons=True)
443
444         if brush.gpencil_vertex_tool not in {'BLUR', 'AVERAGE', 'SMEAR'}:
445             row.separator(factor=0.4)
446             row.prop_with_popover(brush, "color", text="", panel="TOPBAR_PT_gpencil_vertexcolor")
447
448         from bl_ui.properties_paint_common import (
449             brush_basic_gpencil_vertex_settings,
450         )
451
452         brush_basic_gpencil_vertex_settings(layout, context, brush, compact=True)
453
454         return True
455
456     @staticmethod
457     def PARTICLE(context, layout, tool):
458         if (tool is None) or (not tool.has_datablock):
459             return False
460
461         # See: 'VIEW3D_PT_tools_brush', basically a duplicate
462         settings = context.tool_settings.particle_edit
463         brush = settings.brush
464         tool = settings.tool
465         if tool == 'NONE':
466             return False
467
468         layout.prop(brush, "size", slider=True)
469         if tool == 'ADD':
470             layout.prop(brush, "count")
471
472             layout.prop(settings, "use_default_interpolate")
473             layout.prop(brush, "steps", slider=True)
474             layout.prop(settings, "default_key_count", slider=True)
475         else:
476             layout.prop(brush, "strength", slider=True)
477
478             if tool == 'LENGTH':
479                 layout.row().prop(brush, "length_mode", expand=True)
480             elif tool == 'PUFF':
481                 layout.row().prop(brush, "puff_mode", expand=True)
482                 layout.prop(brush, "use_puff_volume")
483             elif tool == 'COMB':
484                 row = layout.row()
485                 row.active = settings.is_editable
486                 row.prop(settings, "use_emitter_deflect", text="Deflect Emitter")
487                 sub = row.row(align=True)
488                 sub.active = settings.use_emitter_deflect
489                 sub.prop(settings, "emitter_distance", text="Distance")
490
491         return True
492
493
494 class VIEW3D_HT_header(Header):
495     bl_space_type = 'VIEW_3D'
496
497     @staticmethod
498     def draw_xform_template(layout, context):
499         obj = context.active_object
500         object_mode = 'OBJECT' if obj is None else obj.mode
501         has_pose_mode = (
502             (object_mode == 'POSE') or
503             (object_mode == 'WEIGHT_PAINT' and context.pose_object is not None)
504         )
505
506         tool_settings = context.tool_settings
507
508         # Mode & Transform Settings
509         scene = context.scene
510
511         # Orientation
512         if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL'} or has_pose_mode:
513             orient_slot = scene.transform_orientation_slots[0]
514             row = layout.row(align=True)
515
516             sub = row.row()
517             sub.ui_units_x = 4
518             sub.prop_with_popover(
519                 orient_slot,
520                 "type",
521                 text="",
522                 panel="VIEW3D_PT_transform_orientations",
523             )
524
525         # Pivot
526         if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL', 'SCULPT_GPENCIL'} or has_pose_mode:
527             layout.prop(tool_settings, "transform_pivot_point", text="", icon_only=True)
528
529         # Snap
530         show_snap = False
531         if obj is None:
532             show_snap = True
533         else:
534             if (object_mode not in {
535                     'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT',
536                     'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL', 'VERTEX_GPENCIL'
537             }) or has_pose_mode:
538                 show_snap = True
539             else:
540
541                 paint_settings = UnifiedPaintPanel.paint_settings(context)
542
543                 if paint_settings:
544                     brush = paint_settings.brush
545                     if brush and hasattr(brush, "stroke_method") and brush.stroke_method == 'CURVE':
546                         show_snap = True
547
548         if show_snap:
549             snap_items = bpy.types.ToolSettings.bl_rna.properties["snap_elements"].enum_items
550             snap_elements = tool_settings.snap_elements
551             if len(snap_elements) == 1:
552                 text = ""
553                 for elem in snap_elements:
554                     icon = snap_items[elem].icon
555                     break
556             else:
557                 text = "Mix"
558                 icon = 'NONE'
559             del snap_items, snap_elements
560
561             row = layout.row(align=True)
562             row.prop(tool_settings, "use_snap", text="")
563
564             sub = row.row(align=True)
565             sub.popover(
566                 panel="VIEW3D_PT_snapping",
567                 icon=icon,
568                 text=text,
569             )
570
571         # Proportional editing
572         if object_mode in {'EDIT', 'PARTICLE_EDIT', 'SCULPT_GPENCIL', 'EDIT_GPENCIL', 'OBJECT'}:
573             row = layout.row(align=True)
574             kw = {}
575             if object_mode == 'OBJECT':
576                 attr = "use_proportional_edit_objects"
577             else:
578                 attr = "use_proportional_edit"
579
580                 if tool_settings.use_proportional_edit:
581                     if tool_settings.use_proportional_connected:
582                         kw["icon"] = 'PROP_CON'
583                     elif tool_settings.use_proportional_projected:
584                         kw["icon"] = 'PROP_PROJECTED'
585                     else:
586                         kw["icon"] = 'PROP_ON'
587                 else:
588                     kw["icon"] = 'PROP_OFF'
589
590             row.prop(tool_settings, attr, icon_only=True, **kw)
591             sub = row.row(align=True)
592             sub.active = getattr(tool_settings, attr)
593             sub.prop_with_popover(
594                 tool_settings,
595                 "proportional_edit_falloff",
596                 text="",
597                 icon_only=True,
598                 panel="VIEW3D_PT_proportional_edit",
599             )
600
601     def draw(self, context):
602         layout = self.layout
603
604         tool_settings = context.tool_settings
605         view = context.space_data
606         shading = view.shading
607         show_region_tool_header = view.show_region_tool_header
608
609         if not show_region_tool_header:
610             layout.row(align=True).template_header()
611
612         row = layout.row(align=True)
613         obj = context.active_object
614         # mode_string = context.mode
615         object_mode = 'OBJECT' if obj is None else obj.mode
616         has_pose_mode = (
617             (object_mode == 'POSE') or
618             (object_mode == 'WEIGHT_PAINT' and context.pose_object is not None)
619         )
620
621         # Note: This is actually deadly in case enum_items have to be dynamically generated
622         #       (because internal RNA array iterator will free everything immediately...).
623         # XXX This is an RNA internal issue, not sure how to fix it.
624         # Note: Tried to add an accessor to get translated UI strings instead of manual call
625         #       to pgettext_iface below, but this fails because translated enumitems
626         #       are always dynamically allocated.
627         act_mode_item = bpy.types.Object.bl_rna.properties["mode"].enum_items[object_mode]
628         act_mode_i18n_context = bpy.types.Object.bl_rna.properties["mode"].translation_context
629
630         sub = row.row(align=True)
631         sub.ui_units_x = 5.5
632         sub.operator_menu_enum(
633             "object.mode_set", "mode",
634             text=bpy.app.translations.pgettext_iface(act_mode_item.name, act_mode_i18n_context),
635             icon=act_mode_item.icon,
636         )
637         del act_mode_item
638
639         layout.template_header_3D_mode()
640
641         # Contains buttons like Mode, Pivot, Layer, Mesh Select Mode...
642         if obj:
643             # Particle edit
644             if object_mode == 'PARTICLE_EDIT':
645                 row = layout.row()
646                 row.prop(tool_settings.particle_edit, "select_mode", text="", expand=True)
647
648         # Grease Pencil
649         if obj and obj.type == 'GPENCIL' and context.gpencil_data:
650             gpd = context.gpencil_data
651
652             if gpd.is_stroke_paint_mode:
653                 row = layout.row()
654                 sub = row.row(align=True)
655                 sub.prop(tool_settings, "use_gpencil_draw_onback", text="", icon='MOD_OPACITY')
656                 sub.separator(factor=0.4)
657                 sub.prop(tool_settings, "use_gpencil_weight_data_add", text="", icon='WPAINT_HLT')
658                 sub.separator(factor=0.4)
659                 sub.prop(tool_settings, "use_gpencil_draw_additive", text="", icon='FREEZE')
660                 sub.separator(factor=0.4)
661                 sub.prop(tool_settings, "use_gpencil_automerge_strokes", text="")
662
663             # Select mode for Editing
664             if gpd.use_stroke_edit_mode:
665                 row = layout.row(align=True)
666                 row.prop_enum(tool_settings, "gpencil_selectmode_edit", text="", value='POINT')
667                 row.prop_enum(tool_settings, "gpencil_selectmode_edit", text="", value='STROKE')
668
669                 subrow = row.row(align=True)
670                 subrow.enabled = not gpd.use_curve_edit
671                 subrow.prop_enum(tool_settings, "gpencil_selectmode_edit", text="", value='SEGMENT')
672
673                 # Curve edit submode
674                 row = layout.row(align=True)
675                 row.prop(gpd, "use_curve_edit", text="",
676                          icon='IPO_BEZIER')
677                 sub = row.row(align=True)
678                 sub.active = gpd.use_curve_edit
679                 sub.popover(
680                     panel="VIEW3D_PT_gpencil_curve_edit",
681                     text="Curve Editing",
682                 )
683
684             # Select mode for Sculpt
685             if gpd.is_stroke_sculpt_mode:
686                 row = layout.row(align=True)
687                 row.prop(tool_settings, "use_gpencil_select_mask_point", text="")
688                 row.prop(tool_settings, "use_gpencil_select_mask_stroke", text="")
689                 row.prop(tool_settings, "use_gpencil_select_mask_segment", text="")
690
691             # Select mode for Vertex Paint
692             if gpd.is_stroke_vertex_mode:
693                 row = layout.row(align=True)
694                 row.prop(tool_settings, "use_gpencil_vertex_select_mask_point", text="")
695                 row.prop(tool_settings, "use_gpencil_vertex_select_mask_stroke", text="")
696                 row.prop(tool_settings, "use_gpencil_vertex_select_mask_segment", text="")
697
698             if (
699                     gpd.use_stroke_edit_mode or
700                     gpd.is_stroke_sculpt_mode or
701                     gpd.is_stroke_weight_mode or
702                     gpd.is_stroke_vertex_mode
703             ):
704                 row = layout.row(align=True)
705                 row.prop(gpd, "use_multiedit", text="", icon='GP_MULTIFRAME_EDITING')
706
707                 sub = row.row(align=True)
708                 sub.enabled = gpd.use_multiedit
709                 sub.popover(
710                     panel="VIEW3D_PT_gpencil_multi_frame",
711                     text="Multiframe",
712                 )
713
714             if gpd.use_stroke_edit_mode or gpd.is_stroke_paint_mode:
715                 row = layout.row(align=True)
716                 row.popover(
717                     panel="VIEW3D_PT_tools_grease_pencil_interpolate",
718                     text="Interpolate",
719                 )
720
721         overlay = view.overlay
722
723         VIEW3D_MT_editor_menus.draw_collapsible(context, layout)
724
725         layout.separator_spacer()
726
727         if object_mode in {'PAINT_GPENCIL', 'SCULPT_GPENCIL'}:
728             # Grease pencil
729             if object_mode == 'PAINT_GPENCIL':
730                 layout.prop_with_popover(
731                     tool_settings,
732                     "gpencil_stroke_placement_view3d",
733                     text="",
734                     panel="VIEW3D_PT_gpencil_origin",
735                 )
736
737             if object_mode in {'PAINT_GPENCIL', 'SCULPT_GPENCIL'}:
738                 layout.prop_with_popover(
739                     tool_settings.gpencil_sculpt,
740                     "lock_axis",
741                     text="",
742                     panel="VIEW3D_PT_gpencil_lock",
743                 )
744
745             if object_mode == 'PAINT_GPENCIL':
746                 # FIXME: this is bad practice!
747                 # Tool options are to be displayed in the topbar.
748                 if context.workspace.tools.from_space_view3d_mode(object_mode).idname == "builtin_brush.Draw":
749                     settings = tool_settings.gpencil_sculpt.guide
750                     row = layout.row(align=True)
751                     row.prop(settings, "use_guide", text="", icon='GRID')
752                     sub = row.row(align=True)
753                     sub.active = settings.use_guide
754                     sub.popover(
755                         panel="VIEW3D_PT_gpencil_guide",
756                         text="Guides",
757                     )
758
759             layout.separator_spacer()
760         elif not show_region_tool_header:
761             # Transform settings depending on tool header visibility
762             VIEW3D_HT_header.draw_xform_template(layout, context)
763
764             layout.separator_spacer()
765
766         # Viewport Settings
767         layout.popover(
768             panel="VIEW3D_PT_object_type_visibility",
769             icon_value=view.icon_from_show_object_viewport,
770             text="",
771         )
772
773         # Gizmo toggle & popover.
774         row = layout.row(align=True)
775         # FIXME: place-holder icon.
776         row.prop(view, "show_gizmo", text="", toggle=True, icon='GIZMO')
777         sub = row.row(align=True)
778         sub.active = view.show_gizmo
779         sub.popover(
780             panel="VIEW3D_PT_gizmo_display",
781             text="",
782         )
783
784         # Overlay toggle & popover.
785         row = layout.row(align=True)
786         row.prop(overlay, "show_overlays", icon='OVERLAY', text="")
787         sub = row.row(align=True)
788         sub.active = overlay.show_overlays
789         sub.popover(panel="VIEW3D_PT_overlay", text="")
790
791         row = layout.row()
792         row.active = (object_mode == 'EDIT') or (shading.type in {'WIREFRAME', 'SOLID'})
793
794         # While exposing 'shading.show_xray(_wireframe)' is correct.
795         # this hides the key shortcut from users: T70433.
796         if has_pose_mode:
797             draw_depressed = overlay.show_xray_bone
798         elif shading.type == 'WIREFRAME':
799             draw_depressed = shading.show_xray_wireframe
800         else:
801             draw_depressed = shading.show_xray
802         row.operator(
803             "view3d.toggle_xray",
804             text="",
805             icon='XRAY',
806             depress=draw_depressed,
807         )
808
809         row = layout.row(align=True)
810         row.prop(shading, "type", text="", expand=True)
811         sub = row.row(align=True)
812         # TODO, currently render shading type ignores mesh two-side, until it's supported
813         # show the shading popover which shows double-sided option.
814
815         # sub.enabled = shading.type != 'RENDERED'
816         sub.popover(panel="VIEW3D_PT_shading", text="")
817
818
819 class VIEW3D_MT_editor_menus(Menu):
820     bl_label = ""
821
822     def draw(self, context):
823         layout = self.layout
824         obj = context.active_object
825         mode_string = context.mode
826         edit_object = context.edit_object
827         gp_edit = obj and obj.mode in {'EDIT_GPENCIL', 'PAINT_GPENCIL', 'SCULPT_GPENCIL',
828                                        'WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}
829         ts = context.scene.tool_settings
830
831         layout.menu("VIEW3D_MT_view")
832
833         # Select Menu
834         if gp_edit:
835             if mode_string not in {'PAINT_GPENCIL', 'WEIGHT_GPENCIL'}:
836                 if (
837                         mode_string == 'SCULPT_GPENCIL' and
838                         (ts.use_gpencil_select_mask_point or
839                          ts.use_gpencil_select_mask_stroke or
840                          ts.use_gpencil_select_mask_segment)
841                 ):
842                     layout.menu("VIEW3D_MT_select_gpencil")
843                 elif mode_string == 'EDIT_GPENCIL':
844                     layout.menu("VIEW3D_MT_select_gpencil")
845                 elif mode_string == 'VERTEX_GPENCIL':
846                     layout.menu("VIEW3D_MT_select_gpencil")
847         elif mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
848             mesh = obj.data
849             if mesh.use_paint_mask:
850                 layout.menu("VIEW3D_MT_select_paint_mask")
851             elif mesh.use_paint_mask_vertex and mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX'}:
852                 layout.menu("VIEW3D_MT_select_paint_mask_vertex")
853         elif mode_string != 'SCULPT':
854             layout.menu("VIEW3D_MT_select_%s" % mode_string.lower())
855
856         if gp_edit:
857             pass
858         elif mode_string == 'OBJECT':
859             layout.menu("VIEW3D_MT_add", text="Add", text_ctxt=i18n_contexts.operator_default)
860         elif mode_string == 'EDIT_MESH':
861             layout.menu("VIEW3D_MT_mesh_add", text="Add", text_ctxt=i18n_contexts.operator_default)
862         elif mode_string == 'EDIT_CURVE':
863             layout.menu("VIEW3D_MT_curve_add", text="Add", text_ctxt=i18n_contexts.operator_default)
864         elif mode_string == 'EDIT_SURFACE':
865             layout.menu("VIEW3D_MT_surface_add", text="Add", text_ctxt=i18n_contexts.operator_default)
866         elif mode_string == 'EDIT_METABALL':
867             layout.menu("VIEW3D_MT_metaball_add", text="Add", text_ctxt=i18n_contexts.operator_default)
868         elif mode_string == 'EDIT_ARMATURE':
869             layout.menu("TOPBAR_MT_edit_armature_add", text="Add", text_ctxt=i18n_contexts.operator_default)
870
871         if gp_edit:
872             if obj and obj.mode == 'PAINT_GPENCIL':
873                 layout.menu("VIEW3D_MT_paint_gpencil")
874             elif obj and obj.mode == 'EDIT_GPENCIL':
875                 layout.menu("VIEW3D_MT_edit_gpencil")
876                 layout.menu("VIEW3D_MT_edit_gpencil_stroke")
877                 layout.menu("VIEW3D_MT_edit_gpencil_point")
878             elif obj and obj.mode == 'WEIGHT_GPENCIL':
879                 layout.menu("VIEW3D_MT_weight_gpencil")
880
881         elif edit_object:
882             layout.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
883
884             if mode_string == 'EDIT_MESH':
885                 layout.menu("VIEW3D_MT_edit_mesh_vertices")
886                 layout.menu("VIEW3D_MT_edit_mesh_edges")
887                 layout.menu("VIEW3D_MT_edit_mesh_faces")
888                 layout.menu("VIEW3D_MT_uv_map", text="UV")
889             elif mode_string in {'EDIT_CURVE', 'EDIT_SURFACE'}:
890                 layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
891                 layout.menu("VIEW3D_MT_edit_curve_segments")
892
893         elif obj:
894             if mode_string != 'PAINT_TEXTURE':
895                 layout.menu("VIEW3D_MT_%s" % mode_string.lower())
896             if mode_string == 'SCULPT':
897                 layout.menu("VIEW3D_MT_mask")
898                 layout.menu("VIEW3D_MT_face_sets")
899
900         else:
901             layout.menu("VIEW3D_MT_object")
902
903
904 # ********** Menu **********
905
906
907 # ********** Utilities **********
908
909
910 class ShowHideMenu:
911     bl_label = "Show/Hide"
912     _operator_name = ""
913
914     def draw(self, _context):
915         layout = self.layout
916
917         layout.operator("%s.reveal" % self._operator_name)
918         layout.operator("%s.hide" % self._operator_name, text="Hide Selected").unselected = False
919         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
920
921
922 # Standard transforms which apply to all cases (mix-in class, not used directly).
923 class VIEW3D_MT_transform_base:
924     bl_label = "Transform"
925     bl_category = "View"
926
927     # TODO: get rid of the custom text strings?
928     def draw(self, context):
929         layout = self.layout
930
931         layout.operator("transform.translate")
932         layout.operator("transform.rotate")
933         layout.operator("transform.resize", text="Scale")
934
935         layout.separator()
936
937         layout.operator("transform.tosphere", text="To Sphere")
938         layout.operator("transform.shear", text="Shear")
939         layout.operator("transform.bend", text="Bend")
940         layout.operator("transform.push_pull", text="Push/Pull")
941
942         if context.mode != 'OBJECT':
943             layout.operator("transform.vertex_warp", text="Warp")
944             layout.operator_context = 'EXEC_REGION_WIN'
945             layout.operator("transform.vertex_random", text="Randomize").offset = 0.1
946             layout.operator_context = 'INVOKE_REGION_WIN'
947
948
949 # Generic transform menu - geometry types
950 class VIEW3D_MT_transform(VIEW3D_MT_transform_base, Menu):
951     def draw(self, context):
952         # base menu
953         VIEW3D_MT_transform_base.draw(self, context)
954
955         # generic...
956         layout = self.layout
957         if context.mode == 'EDIT_MESH':
958             layout.operator("transform.shrink_fatten", text="Shrink Fatten")
959             layout.operator("transform.skin_resize")
960         elif context.mode == 'EDIT_CURVE':
961             layout.operator("transform.transform", text="Radius").mode = 'CURVE_SHRINKFATTEN'
962
963         layout.separator()
964
965         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
966         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
967
968
969 # Object-specific extensions to Transform menu
970 class VIEW3D_MT_transform_object(VIEW3D_MT_transform_base, Menu):
971     def draw(self, context):
972         layout = self.layout
973
974         # base menu
975         VIEW3D_MT_transform_base.draw(self, context)
976
977         # object-specific option follow...
978         layout.separator()
979
980         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
981         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
982
983         layout.separator()
984
985         layout.operator_context = 'EXEC_REGION_WIN'
986         # XXX see alignmenu() in edit.c of b2.4x to get this working
987         layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN'
988
989         layout.separator()
990
991         layout.operator("object.randomize_transform")
992         layout.operator("object.align")
993
994         # TODO: there is a strange context bug here.
995         """
996         layout.operator_context = 'INVOKE_REGION_WIN'
997         layout.operator("object.transform_axis_target")
998         """
999
1000
1001 # Armature EditMode extensions to Transform menu
1002 class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base, Menu):
1003     def draw(self, context):
1004         layout = self.layout
1005
1006         # base menu
1007         VIEW3D_MT_transform_base.draw(self, context)
1008
1009         # armature specific extensions follow...
1010         obj = context.object
1011         if obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'}:
1012             if obj.data.display_type == 'BBONE':
1013                 layout.separator()
1014
1015                 layout.operator("transform.transform", text="Scale BBone").mode = 'BONE_SIZE'
1016             elif obj.data.display_type == 'ENVELOPE':
1017                 layout.separator()
1018
1019                 layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONE_SIZE'
1020                 layout.operator("transform.transform", text="Scale Radius").mode = 'BONE_ENVELOPE'
1021
1022         if context.edit_object and context.edit_object.type == 'ARMATURE':
1023             layout.separator()
1024
1025             layout.operator("armature.align")
1026
1027
1028 class VIEW3D_MT_mirror(Menu):
1029     bl_label = "Mirror"
1030
1031     def draw(self, _context):
1032         layout = self.layout
1033
1034         layout.operator("transform.mirror", text="Interactive Mirror")
1035
1036         layout.separator()
1037
1038         layout.operator_context = 'EXEC_REGION_WIN'
1039
1040         for (space_name, space_id) in (("Global", 'GLOBAL'), ("Local", 'LOCAL')):
1041             for axis_index, axis_name in enumerate("XYZ"):
1042                 props = layout.operator("transform.mirror", text="%s %s" % (axis_name, space_name))
1043                 props.constraint_axis[axis_index] = True
1044                 props.orient_type = space_id
1045
1046             if space_id == 'GLOBAL':
1047                 layout.separator()
1048
1049
1050 class VIEW3D_MT_snap(Menu):
1051     bl_label = "Snap"
1052
1053     def draw(self, _context):
1054         layout = self.layout
1055
1056         layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
1057         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor").use_offset = False
1058         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor (Keep Offset)").use_offset = True
1059         layout.operator("view3d.snap_selected_to_active", text="Selection to Active")
1060
1061         layout.separator()
1062
1063         layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
1064         layout.operator("view3d.snap_cursor_to_center", text="Cursor to World Origin")
1065         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
1066         layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
1067
1068
1069 class VIEW3D_MT_uv_map(Menu):
1070     bl_label = "UV Mapping"
1071
1072     def draw(self, context):
1073         layout = self.layout
1074
1075         layout.operator("uv.unwrap")
1076
1077         layout.separator()
1078
1079         layout.operator_context = 'INVOKE_DEFAULT'
1080         layout.operator("uv.smart_project")
1081         layout.operator("uv.lightmap_pack")
1082         layout.operator("uv.follow_active_quads")
1083
1084         layout.separator()
1085
1086         layout.operator_context = 'EXEC_REGION_WIN'
1087         layout.operator("uv.cube_project")
1088         layout.operator("uv.cylinder_project")
1089         layout.operator("uv.sphere_project")
1090
1091         layout.separator()
1092
1093         layout.operator_context = 'INVOKE_REGION_WIN'
1094         layout.operator("uv.project_from_view").scale_to_bounds = False
1095         layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True
1096
1097         layout.separator()
1098
1099         layout.operator("mesh.mark_seam").clear = False
1100         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1101
1102         layout.separator()
1103
1104         layout.operator("uv.reset")
1105
1106
1107 # ********** View menus **********
1108
1109
1110 class VIEW3D_MT_view(Menu):
1111     bl_label = "View"
1112
1113     def draw(self, context):
1114         layout = self.layout
1115         view = context.space_data
1116
1117         layout.prop(view, "show_region_toolbar")
1118         layout.prop(view, "show_region_ui")
1119         layout.prop(view, "show_region_tool_header")
1120         layout.prop(view, "show_region_hud")
1121
1122         layout.separator()
1123
1124         layout.operator("view3d.view_selected", text="Frame Selected").use_all_regions = False
1125         if view.region_quadviews:
1126             layout.operator("view3d.view_selected", text="Frame Selected (Quad View)").use_all_regions = True
1127
1128         layout.operator("view3d.view_all").center = False
1129         layout.operator("view3d.view_persportho", text="Perspective/Orthographic")
1130         layout.menu("VIEW3D_MT_view_local")
1131
1132         layout.separator()
1133
1134         layout.menu("VIEW3D_MT_view_cameras", text="Cameras")
1135
1136         layout.separator()
1137         layout.menu("VIEW3D_MT_view_viewpoint")
1138         layout.menu("VIEW3D_MT_view_navigation")
1139         layout.menu("VIEW3D_MT_view_align")
1140
1141         layout.separator()
1142
1143         layout.operator_context = 'INVOKE_REGION_WIN'
1144         layout.menu("VIEW3D_MT_view_regions", text="View Regions")
1145
1146         layout.separator()
1147
1148         layout.operator("screen.animation_play", text="Play Animation")
1149
1150         layout.separator()
1151
1152         layout.operator("render.opengl", text="Viewport Render Image", icon='RENDER_STILL')
1153         layout.operator("render.opengl", text="Viewport Render Animation", icon='RENDER_ANIMATION').animation = True
1154         props = layout.operator("render.opengl",
1155                                 text="Viewport Render Keyframes",
1156                                 icon='RENDER_ANIMATION',
1157                                 )
1158         props.animation = True
1159         props.render_keyed_only = True
1160
1161         layout.separator()
1162
1163         layout.menu("INFO_MT_area")
1164
1165
1166 class VIEW3D_MT_view_local(Menu):
1167     bl_label = "Local View"
1168
1169     def draw(self, _context):
1170         layout = self.layout
1171
1172         layout.operator("view3d.localview", text="Toggle Local View")
1173         layout.operator("view3d.localview_remove_from")
1174
1175
1176 class VIEW3D_MT_view_cameras(Menu):
1177     bl_label = "Cameras"
1178
1179     def draw(self, _context):
1180         layout = self.layout
1181
1182         layout.operator("view3d.object_as_camera")
1183         layout.operator("view3d.view_camera", text="Active Camera")
1184         layout.operator("view3d.view_center_camera")
1185
1186
1187 class VIEW3D_MT_view_viewpoint(Menu):
1188     bl_label = "Viewpoint"
1189
1190     def draw(self, _context):
1191         layout = self.layout
1192
1193         layout.operator("view3d.view_camera", text="Camera")
1194
1195         layout.separator()
1196
1197         layout.operator("view3d.view_axis", text="Top").type = 'TOP'
1198         layout.operator("view3d.view_axis", text="Bottom").type = 'BOTTOM'
1199
1200         layout.separator()
1201
1202         layout.operator("view3d.view_axis", text="Front").type = 'FRONT'
1203         layout.operator("view3d.view_axis", text="Back").type = 'BACK'
1204
1205         layout.separator()
1206
1207         layout.operator("view3d.view_axis", text="Right").type = 'RIGHT'
1208         layout.operator("view3d.view_axis", text="Left").type = 'LEFT'
1209
1210
1211 class VIEW3D_MT_view_navigation(Menu):
1212     bl_label = "Navigation"
1213
1214     def draw(self, _context):
1215         from math import pi
1216         layout = self.layout
1217
1218         layout.operator_enum("view3d.view_orbit", "type")
1219         props = layout.operator("view3d.view_orbit", text="Orbit Opposite")
1220         props.type = 'ORBITRIGHT'
1221         props.angle = pi
1222
1223         layout.separator()
1224
1225         layout.operator("view3d.view_roll", text="Roll Left").type = 'LEFT'
1226         layout.operator("view3d.view_roll", text="Roll Right").type = 'RIGHT'
1227
1228         layout.separator()
1229
1230         layout.operator_enum("view3d.view_pan", "type")
1231
1232         layout.separator()
1233
1234         layout.operator("view3d.zoom", text="Zoom In").delta = 1
1235         layout.operator("view3d.zoom", text="Zoom Out").delta = -1
1236         layout.operator("view3d.zoom_border", text="Zoom Region...")
1237         layout.operator("view3d.zoom_camera_1_to_1", text="Zoom Camera 1:1")
1238
1239         layout.separator()
1240
1241         layout.operator("view3d.fly")
1242         layout.operator("view3d.walk")
1243
1244
1245 class VIEW3D_MT_view_align(Menu):
1246     bl_label = "Align View"
1247
1248     def draw(self, _context):
1249         layout = self.layout
1250
1251         layout.menu("VIEW3D_MT_view_align_selected")
1252
1253         layout.separator()
1254
1255         layout.operator("view3d.camera_to_view", text="Align Active Camera to View")
1256         layout.operator("view3d.camera_to_view_selected", text="Align Active Camera to Selected")
1257
1258         layout.separator()
1259
1260         layout.operator("view3d.view_all", text="Center Cursor and Frame All").center = True
1261         layout.operator("view3d.view_center_cursor")
1262
1263         layout.separator()
1264
1265         layout.operator("view3d.view_lock_to_active")
1266         layout.operator("view3d.view_lock_clear")
1267
1268
1269 class VIEW3D_MT_view_align_selected(Menu):
1270     bl_label = "Align View to Active"
1271
1272     def draw(self, _context):
1273         layout = self.layout
1274
1275         props = layout.operator("view3d.view_axis", text="Top")
1276         props.align_active = True
1277         props.type = 'TOP'
1278
1279         props = layout.operator("view3d.view_axis", text="Bottom")
1280         props.align_active = True
1281         props.type = 'BOTTOM'
1282
1283         layout.separator()
1284
1285         props = layout.operator("view3d.view_axis", text="Front")
1286         props.align_active = True
1287         props.type = 'FRONT'
1288
1289         props = layout.operator("view3d.view_axis", text="Back")
1290         props.align_active = True
1291         props.type = 'BACK'
1292
1293         layout.separator()
1294
1295         props = layout.operator("view3d.view_axis", text="Right")
1296         props.align_active = True
1297         props.type = 'RIGHT'
1298
1299         props = layout.operator("view3d.view_axis", text="Left")
1300         props.align_active = True
1301         props.type = 'LEFT'
1302
1303
1304 class VIEW3D_MT_view_regions(Menu):
1305     bl_label = "View Regions"
1306
1307     def draw(self, _context):
1308         layout = self.layout
1309         layout.operator("view3d.clip_border", text="Clipping Region...")
1310         layout.operator("view3d.render_border", text="Render Region...")
1311
1312         layout.separator()
1313
1314         layout.operator("view3d.clear_render_border")
1315
1316
1317 # ********** Select menus, suffix from context.mode **********
1318
1319 class VIEW3D_MT_select_object_more_less(Menu):
1320     bl_label = "Select More/Less"
1321
1322     def draw(self, _context):
1323         layout = self.layout
1324
1325         layout = self.layout
1326
1327         layout.operator("object.select_more", text="More")
1328         layout.operator("object.select_less", text="Less")
1329
1330         layout.separator()
1331
1332         props = layout.operator("object.select_hierarchy", text="Parent")
1333         props.extend = False
1334         props.direction = 'PARENT'
1335
1336         props = layout.operator("object.select_hierarchy", text="Child")
1337         props.extend = False
1338         props.direction = 'CHILD'
1339
1340         layout.separator()
1341
1342         props = layout.operator("object.select_hierarchy", text="Extend Parent")
1343         props.extend = True
1344         props.direction = 'PARENT'
1345
1346         props = layout.operator("object.select_hierarchy", text="Extend Child")
1347         props.extend = True
1348         props.direction = 'CHILD'
1349
1350
1351 class VIEW3D_MT_select_object(Menu):
1352     bl_label = "Select"
1353
1354     def draw(self, _context):
1355         layout = self.layout
1356
1357         layout.operator("object.select_all", text="All").action = 'SELECT'
1358         layout.operator("object.select_all", text="None").action = 'DESELECT'
1359         layout.operator("object.select_all", text="Invert").action = 'INVERT'
1360
1361         layout.separator()
1362
1363         layout.operator("view3d.select_box")
1364         layout.operator("view3d.select_circle")
1365
1366         layout.separator()
1367
1368         layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type")
1369         layout.operator("object.select_camera", text="Select Active Camera")
1370         layout.operator("object.select_mirror", text="Mirror Selection")
1371         layout.operator("object.select_random", text="Select Random")
1372
1373         layout.separator()
1374
1375         layout.menu("VIEW3D_MT_select_object_more_less")
1376
1377         layout.separator()
1378
1379         layout.operator_menu_enum("object.select_grouped", "type", text="Select Grouped")
1380         layout.operator_menu_enum("object.select_linked", "type", text="Select Linked")
1381         layout.operator("object.select_pattern", text="Select Pattern...")
1382
1383
1384 class VIEW3D_MT_select_pose_more_less(Menu):
1385     bl_label = "Select More/Less"
1386
1387     def draw(self, _context):
1388         layout = self.layout
1389
1390         layout = self.layout
1391
1392         props = layout.operator("pose.select_hierarchy", text="Parent")
1393         props.extend = False
1394         props.direction = 'PARENT'
1395
1396         props = layout.operator("pose.select_hierarchy", text="Child")
1397         props.extend = False
1398         props.direction = 'CHILD'
1399
1400         layout.separator()
1401
1402         props = layout.operator("pose.select_hierarchy", text="Extend Parent")
1403         props.extend = True
1404         props.direction = 'PARENT'
1405
1406         props = layout.operator("pose.select_hierarchy", text="Extend Child")
1407         props.extend = True
1408         props.direction = 'CHILD'
1409
1410
1411 class VIEW3D_MT_select_pose(Menu):
1412     bl_label = "Select"
1413
1414     def draw(self, _context):
1415         layout = self.layout
1416
1417         layout.operator("pose.select_all", text="All").action = 'SELECT'
1418         layout.operator("pose.select_all", text="None").action = 'DESELECT'
1419         layout.operator("pose.select_all", text="Invert").action = 'INVERT'
1420
1421         layout.separator()
1422
1423         layout.operator("view3d.select_box")
1424         layout.operator("view3d.select_circle")
1425
1426         layout.separator()
1427
1428         layout.operator("pose.select_mirror", text="Flip Active")
1429
1430         layout.separator()
1431
1432         layout.operator("pose.select_constraint_target", text="Constraint Target")
1433         layout.operator("pose.select_linked", text="Linked")
1434
1435         layout.separator()
1436
1437         layout.menu("VIEW3D_MT_select_pose_more_less")
1438
1439         layout.separator()
1440
1441         layout.operator_menu_enum("pose.select_grouped", "type", text="Grouped")
1442         layout.operator("object.select_pattern", text="Select Pattern...")
1443
1444
1445 class VIEW3D_MT_select_particle(Menu):
1446     bl_label = "Select"
1447
1448     def draw(self, _context):
1449         layout = self.layout
1450
1451         layout.operator("particle.select_all", text="All").action = 'SELECT'
1452         layout.operator("particle.select_all", text="None").action = 'DESELECT'
1453         layout.operator("particle.select_all", text="Invert").action = 'INVERT'
1454
1455         layout.separator()
1456
1457         layout.operator("view3d.select_box")
1458         layout.operator("view3d.select_circle")
1459
1460         layout.separator()
1461
1462         layout.operator("particle.select_linked", text="Select Linked")
1463
1464         layout.separator()
1465
1466         layout.operator("particle.select_more")
1467         layout.operator("particle.select_less")
1468
1469         layout.separator()
1470
1471         layout.operator("particle.select_random")
1472
1473         layout.separator()
1474
1475         layout.operator("particle.select_roots", text="Roots")
1476         layout.operator("particle.select_tips", text="Tips")
1477
1478
1479 class VIEW3D_MT_edit_mesh_select_similar(Menu):
1480     bl_label = "Select Similar"
1481
1482     def draw(self, _context):
1483         layout = self.layout
1484
1485         layout.operator_enum("mesh.select_similar", "type")
1486
1487         layout.separator()
1488
1489         layout.operator("mesh.select_similar_region", text="Face Regions")
1490
1491
1492 class VIEW3D_MT_edit_mesh_select_by_trait(Menu):
1493     bl_label = "Select All by Trait"
1494
1495     def draw(self, context):
1496         layout = self.layout
1497         tool_settings = context.tool_settings
1498         if tool_settings.mesh_select_mode[2] is False:
1499             layout.operator("mesh.select_non_manifold", text="Non Manifold")
1500         layout.operator("mesh.select_loose", text="Loose Geometry")
1501         layout.operator("mesh.select_interior_faces", text="Interior Faces")
1502         layout.operator("mesh.select_face_by_sides", text="Faces by Sides")
1503
1504         layout.separator()
1505
1506         layout.operator("mesh.select_ungrouped", text="Ungrouped Vertices")
1507
1508
1509 class VIEW3D_MT_edit_mesh_select_more_less(Menu):
1510     bl_label = "Select More/Less"
1511
1512     def draw(self, _context):
1513         layout = self.layout
1514
1515         layout.operator("mesh.select_more", text="More")
1516         layout.operator("mesh.select_less", text="Less")
1517
1518         layout.separator()
1519
1520         layout.operator("mesh.select_next_item", text="Next Active")
1521         layout.operator("mesh.select_prev_item", text="Previous Active")
1522
1523
1524 class VIEW3D_MT_edit_mesh_select_linked(Menu):
1525     bl_label = "Select Linked"
1526
1527     def draw(self, _context):
1528         layout = self.layout
1529
1530         layout.operator("mesh.select_linked", text="Linked")
1531         layout.operator("mesh.shortest_path_select", text="Shortest Path")
1532         layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces")
1533
1534
1535 class VIEW3D_MT_edit_mesh_select_loops(Menu):
1536     bl_label = "Select Loops"
1537
1538     def draw(self, _context):
1539         layout = self.layout
1540
1541         layout.operator("mesh.loop_multi_select", text="Edge Loops").ring = False
1542         layout.operator("mesh.loop_multi_select", text="Edge Rings").ring = True
1543
1544         layout.separator()
1545
1546         layout.operator("mesh.loop_to_region")
1547         layout.operator("mesh.region_to_loop")
1548
1549
1550 class VIEW3D_MT_select_edit_mesh(Menu):
1551     bl_label = "Select"
1552
1553     def draw(self, _context):
1554         layout = self.layout
1555
1556         # primitive
1557         layout.operator("mesh.select_all", text="All").action = 'SELECT'
1558         layout.operator("mesh.select_all", text="None").action = 'DESELECT'
1559         layout.operator("mesh.select_all", text="Invert").action = 'INVERT'
1560
1561         layout.separator()
1562
1563         layout.operator("view3d.select_box")
1564         layout.operator("view3d.select_circle")
1565
1566         layout.separator()
1567
1568         # numeric
1569         layout.operator("mesh.select_random", text="Select Random")
1570         layout.operator("mesh.select_nth")
1571
1572         layout.separator()
1573
1574         # geometric
1575         layout.operator("mesh.edges_select_sharp", text="Select Sharp Edges")
1576
1577         layout.separator()
1578
1579         # other ...
1580         layout.menu("VIEW3D_MT_edit_mesh_select_similar")
1581
1582         layout.separator()
1583
1584         layout.menu("VIEW3D_MT_edit_mesh_select_by_trait")
1585
1586         layout.separator()
1587
1588         layout.menu("VIEW3D_MT_edit_mesh_select_more_less")
1589
1590         layout.separator()
1591
1592         layout.menu("VIEW3D_MT_edit_mesh_select_loops")
1593
1594         layout.separator()
1595
1596         layout.menu("VIEW3D_MT_edit_mesh_select_linked")
1597
1598         layout.separator()
1599
1600         layout.operator("mesh.select_axis", text="Side of Active")
1601         layout.operator("mesh.select_mirror", text="Mirror Selection")
1602
1603
1604 class VIEW3D_MT_select_edit_curve(Menu):
1605     bl_label = "Select"
1606
1607     def draw(self, _context):
1608         layout = self.layout
1609
1610         layout.operator("curve.select_all", text="All").action = 'SELECT'
1611         layout.operator("curve.select_all", text="None").action = 'DESELECT'
1612         layout.operator("curve.select_all", text="Invert").action = 'INVERT'
1613
1614         layout.separator()
1615
1616         layout.operator("view3d.select_box")
1617         layout.operator("view3d.select_circle")
1618
1619         layout.separator()
1620
1621         layout.operator("curve.select_random")
1622         layout.operator("curve.select_nth")
1623         layout.operator("curve.select_linked", text="Select Linked")
1624         layout.operator("curve.select_similar", text="Select Similar")
1625
1626         layout.separator()
1627
1628         layout.operator("curve.de_select_first")
1629         layout.operator("curve.de_select_last")
1630         layout.operator("curve.select_next")
1631         layout.operator("curve.select_previous")
1632
1633         layout.separator()
1634
1635         layout.operator("curve.select_more")
1636         layout.operator("curve.select_less")
1637
1638
1639 class VIEW3D_MT_select_edit_surface(Menu):
1640     bl_label = "Select"
1641
1642     def draw(self, _context):
1643         layout = self.layout
1644
1645         layout.operator("curve.select_all", text="All").action = 'SELECT'
1646         layout.operator("curve.select_all", text="None").action = 'DESELECT'
1647         layout.operator("curve.select_all", text="Invert").action = 'INVERT'
1648
1649         layout.separator()
1650
1651         layout.operator("view3d.select_box")
1652         layout.operator("view3d.select_circle")
1653
1654         layout.separator()
1655
1656         layout.operator("curve.select_random")
1657         layout.operator("curve.select_nth")
1658         layout.operator("curve.select_linked", text="Select Linked")
1659         layout.operator("curve.select_similar", text="Select Similar")
1660
1661         layout.separator()
1662
1663         layout.operator("curve.select_row")
1664
1665         layout.separator()
1666
1667         layout.operator("curve.select_more")
1668         layout.operator("curve.select_less")
1669
1670
1671 class VIEW3D_MT_select_edit_text(Menu):
1672     bl_label = "Select"
1673
1674     def draw(self, _context):
1675         layout = self.layout
1676
1677         layout.operator("font.select_all", text="All")
1678
1679         layout.separator()
1680
1681         layout.operator("font.move_select", text="Previous Block").type = 'PREVIOUS_PAGE'
1682         layout.operator("font.move_select", text="Next Block").type = 'NEXT_PAGE'
1683
1684         layout.separator()
1685
1686         layout.operator("font.move_select", text="Line Begin").type = 'LINE_BEGIN'
1687         layout.operator("font.move_select", text="Line End").type = 'LINE_END'
1688
1689         layout.separator()
1690
1691         layout.operator("font.move_select", text="Previous Line").type = 'PREVIOUS_LINE'
1692         layout.operator("font.move_select", text="Next Line").type = 'NEXT_LINE'
1693
1694         layout.separator()
1695
1696         layout.operator("font.move_select", text="Previous Word").type = 'PREVIOUS_WORD'
1697         layout.operator("font.move_select", text="Next Word").type = 'NEXT_WORD'
1698
1699
1700 class VIEW3D_MT_select_edit_metaball(Menu):
1701     bl_label = "Select"
1702
1703     def draw(self, _context):
1704         layout = self.layout
1705
1706         layout.operator("mball.select_all", text="All").action = 'SELECT'
1707         layout.operator("mball.select_all", text="None").action = 'DESELECT'
1708         layout.operator("mball.select_all", text="Invert").action = 'INVERT'
1709
1710         layout.separator()
1711
1712         layout.operator("view3d.select_box")
1713         layout.operator("view3d.select_circle")
1714
1715         layout.separator()
1716
1717         layout.operator("mball.select_random_metaelems")
1718
1719         layout.separator()
1720
1721         layout.operator_menu_enum("mball.select_similar", "type", text="Similar")
1722
1723
1724 class VIEW3D_MT_edit_lattice_context_menu(Menu):
1725     bl_label = "Lattice Context Menu"
1726
1727     def draw(self, _context):
1728         layout = self.layout
1729
1730         layout = self.layout
1731
1732         layout.menu("VIEW3D_MT_mirror")
1733         layout.operator_menu_enum("lattice.flip", "axis")
1734         layout.menu("VIEW3D_MT_snap")
1735
1736         layout.separator()
1737
1738         layout.operator("lattice.make_regular")
1739
1740
1741 class VIEW3D_MT_select_edit_lattice(Menu):
1742     bl_label = "Select"
1743
1744     def draw(self, _context):
1745         layout = self.layout
1746
1747         layout.operator("lattice.select_all", text="All").action = 'SELECT'
1748         layout.operator("lattice.select_all", text="None").action = 'DESELECT'
1749         layout.operator("lattice.select_all", text="Invert").action = 'INVERT'
1750
1751         layout.separator()
1752
1753         layout.operator("view3d.select_box")
1754         layout.operator("view3d.select_circle")
1755
1756         layout.separator()
1757
1758         layout.operator("lattice.select_mirror")
1759         layout.operator("lattice.select_random")
1760
1761         layout.separator()
1762
1763         layout.operator("lattice.select_more")
1764         layout.operator("lattice.select_less")
1765
1766         layout.separator()
1767
1768         layout.operator("lattice.select_ungrouped", text="Ungrouped Vertices")
1769
1770
1771 class VIEW3D_MT_select_edit_armature(Menu):
1772     bl_label = "Select"
1773
1774     def draw(self, _context):
1775         layout = self.layout
1776
1777         layout.operator("armature.select_all", text="All").action = 'SELECT'
1778         layout.operator("armature.select_all", text="None").action = 'DESELECT'
1779         layout.operator("armature.select_all", text="Invert").action = 'INVERT'
1780
1781         layout.separator()
1782
1783         layout.operator("view3d.select_box")
1784         layout.operator("view3d.select_circle")
1785
1786         layout.separator()
1787
1788         layout.operator("armature.select_mirror", text="Mirror").extend = False
1789
1790         layout.separator()
1791
1792         layout.operator("armature.select_more", text="More")
1793         layout.operator("armature.select_less", text="Less")
1794
1795         layout.separator()
1796
1797         layout.operator("armature.select_linked", text="Linked")
1798
1799         layout.separator()
1800
1801         props = layout.operator("armature.select_hierarchy", text="Parent")
1802         props.extend = False
1803         props.direction = 'PARENT'
1804
1805         props = layout.operator("armature.select_hierarchy", text="Child")
1806         props.extend = False
1807         props.direction = 'CHILD'
1808
1809         layout.separator()
1810
1811         props = layout.operator("armature.select_hierarchy", text="Extend Parent")
1812         props.extend = True
1813         props.direction = 'PARENT'
1814
1815         props = layout.operator("armature.select_hierarchy", text="Extend Child")
1816         props.extend = True
1817         props.direction = 'CHILD'
1818
1819         layout.operator_menu_enum("armature.select_similar", "type", text="Similar")
1820         layout.operator("object.select_pattern", text="Select Pattern...")
1821
1822
1823 class VIEW3D_MT_select_gpencil(Menu):
1824     bl_label = "Select"
1825
1826     def draw(self, context):
1827         layout = self.layout
1828
1829         layout.operator("gpencil.select_all", text="All").action = 'SELECT'
1830         layout.operator("gpencil.select_all", text="None").action = 'DESELECT'
1831         layout.operator("gpencil.select_all", text="Invert").action = 'INVERT'
1832
1833         layout.separator()
1834
1835         layout.operator("gpencil.select_box")
1836         layout.operator("gpencil.select_circle")
1837
1838         layout.separator()
1839
1840         layout.operator("gpencil.select_linked", text="Linked")
1841         layout.operator("gpencil.select_alternate")
1842         layout.operator_menu_enum("gpencil.select_grouped", "type", text="Grouped")
1843
1844         if context.mode == 'VERTEX_GPENCIL':
1845             layout.operator("gpencil.select_vertex_color", text="Vertex Color")
1846
1847         layout.separator()
1848
1849         layout.operator("gpencil.select_first")
1850         layout.operator("gpencil.select_last")
1851
1852         layout.separator()
1853
1854         layout.operator("gpencil.select_more")
1855         layout.operator("gpencil.select_less")
1856
1857
1858 class VIEW3D_MT_select_paint_mask(Menu):
1859     bl_label = "Select"
1860
1861     def draw(self, _context):
1862         layout = self.layout
1863
1864         layout.operator("paint.face_select_all", text="All").action = 'SELECT'
1865         layout.operator("paint.face_select_all", text="None").action = 'DESELECT'
1866         layout.operator("paint.face_select_all", text="Invert").action = 'INVERT'
1867
1868         layout.separator()
1869
1870         layout.operator("view3d.select_box")
1871         layout.operator("view3d.select_circle")
1872
1873         layout.separator()
1874
1875         layout.operator("paint.face_select_linked", text="Linked")
1876
1877
1878 class VIEW3D_MT_select_paint_mask_vertex(Menu):
1879     bl_label = "Select"
1880
1881     def draw(self, _context):
1882         layout = self.layout
1883
1884         layout.operator("paint.vert_select_all", text="All").action = 'SELECT'
1885         layout.operator("paint.vert_select_all", text="None").action = 'DESELECT'
1886         layout.operator("paint.vert_select_all", text="Invert").action = 'INVERT'
1887
1888         layout.separator()
1889
1890         layout.operator("view3d.select_box")
1891         layout.operator("view3d.select_circle")
1892
1893         layout.separator()
1894
1895         layout.operator("paint.vert_select_ungrouped", text="Ungrouped Vertices")
1896
1897
1898 class VIEW3D_MT_angle_control(Menu):
1899     bl_label = "Angle Control"
1900
1901     @classmethod
1902     def poll(cls, context):
1903         settings = UnifiedPaintPanel.paint_settings(context)
1904         if not settings:
1905             return False
1906
1907         brush = settings.brush
1908         tex_slot = brush.texture_slot
1909
1910         return tex_slot.has_texture_angle and tex_slot.has_texture_angle_source
1911
1912     def draw(self, context):
1913         layout = self.layout
1914
1915         settings = UnifiedPaintPanel.paint_settings(context)
1916         brush = settings.brush
1917
1918         sculpt = (context.sculpt_object is not None)
1919
1920         tex_slot = brush.texture_slot
1921
1922         layout.prop(tex_slot, "use_rake", text="Rake")
1923
1924         if brush.brush_capabilities.has_random_texture_angle and tex_slot.has_random_texture_angle:
1925             if sculpt:
1926                 if brush.sculpt_capabilities.has_random_texture_angle:
1927                     layout.prop(tex_slot, "use_random", text="Random")
1928             else:
1929                 layout.prop(tex_slot, "use_random", text="Random")
1930
1931
1932 class VIEW3D_MT_mesh_add(Menu):
1933     bl_idname = "VIEW3D_MT_mesh_add"
1934     bl_label = "Mesh"
1935
1936     def draw(self, _context):
1937         layout = self.layout
1938
1939         layout.operator_context = 'INVOKE_REGION_WIN'
1940
1941         layout.operator("mesh.primitive_plane_add", text="Plane", icon='MESH_PLANE')
1942         layout.operator("mesh.primitive_cube_add", text="Cube", icon='MESH_CUBE')
1943         layout.operator("mesh.primitive_circle_add", text="Circle", icon='MESH_CIRCLE')
1944         layout.operator("mesh.primitive_uv_sphere_add", text="UV Sphere", icon='MESH_UVSPHERE')
1945         layout.operator("mesh.primitive_ico_sphere_add", text="Ico Sphere", icon='MESH_ICOSPHERE')
1946         layout.operator("mesh.primitive_cylinder_add", text="Cylinder", icon='MESH_CYLINDER')
1947         layout.operator("mesh.primitive_cone_add", text="Cone", icon='MESH_CONE')
1948         layout.operator("mesh.primitive_torus_add", text="Torus", icon='MESH_TORUS')
1949
1950         layout.separator()
1951
1952         layout.operator("mesh.primitive_grid_add", text="Grid", icon='MESH_GRID')
1953         layout.operator("mesh.primitive_monkey_add", text="Monkey", icon='MESH_MONKEY')
1954
1955
1956 class VIEW3D_MT_curve_add(Menu):
1957     bl_idname = "VIEW3D_MT_curve_add"
1958     bl_label = "Curve"
1959
1960     def draw(self, _context):
1961         layout = self.layout
1962
1963         layout.operator_context = 'INVOKE_REGION_WIN'
1964
1965         layout.operator("curve.primitive_bezier_curve_add", text="Bezier", icon='CURVE_BEZCURVE')
1966         layout.operator("curve.primitive_bezier_circle_add", text="Circle", icon='CURVE_BEZCIRCLE')
1967
1968         layout.separator()
1969
1970         layout.operator("curve.primitive_nurbs_curve_add", text="Nurbs Curve", icon='CURVE_NCURVE')
1971         layout.operator("curve.primitive_nurbs_circle_add", text="Nurbs Circle", icon='CURVE_NCIRCLE')
1972         layout.operator("curve.primitive_nurbs_path_add", text="Path", icon='CURVE_PATH')
1973
1974
1975 class VIEW3D_MT_surface_add(Menu):
1976     bl_idname = "VIEW3D_MT_surface_add"
1977     bl_label = "Surface"
1978
1979     def draw(self, _context):
1980         layout = self.layout
1981
1982         layout.operator_context = 'INVOKE_REGION_WIN'
1983
1984         layout.operator("surface.primitive_nurbs_surface_curve_add", text="Nurbs Curve", icon='SURFACE_NCURVE')
1985         layout.operator("surface.primitive_nurbs_surface_circle_add", text="Nurbs Circle", icon='SURFACE_NCIRCLE')
1986         layout.operator("surface.primitive_nurbs_surface_surface_add", text="Nurbs Surface", icon='SURFACE_NSURFACE')
1987         layout.operator("surface.primitive_nurbs_surface_cylinder_add",
1988                         text="Nurbs Cylinder", icon='SURFACE_NCYLINDER')
1989         layout.operator("surface.primitive_nurbs_surface_sphere_add", text="Nurbs Sphere", icon='SURFACE_NSPHERE')
1990         layout.operator("surface.primitive_nurbs_surface_torus_add", text="Nurbs Torus", icon='SURFACE_NTORUS')
1991
1992
1993 class VIEW3D_MT_edit_metaball_context_menu(Menu):
1994     bl_label = "Metaball Context Menu"
1995
1996     def draw(self, _context):
1997         layout = self.layout
1998
1999         layout.operator_context = 'INVOKE_REGION_WIN'
2000
2001         # Add
2002         layout.operator("mball.duplicate_move")
2003
2004         layout.separator()
2005
2006         # Modify
2007         layout.menu("VIEW3D_MT_mirror")
2008         layout.menu("VIEW3D_MT_snap")
2009
2010         layout.separator()
2011
2012         # Remove
2013         layout.operator_context = 'EXEC_REGION_WIN'
2014         layout.operator("mball.delete_metaelems", text="Delete")
2015
2016
2017 class VIEW3D_MT_metaball_add(Menu):
2018     bl_idname = "VIEW3D_MT_metaball_add"
2019     bl_label = "Metaball"
2020
2021     def draw(self, _context):
2022         layout = self.layout
2023
2024         layout.operator_context = 'INVOKE_REGION_WIN'
2025         layout.operator_enum("object.metaball_add", "type")
2026
2027
2028 class TOPBAR_MT_edit_curve_add(Menu):
2029     bl_idname = "TOPBAR_MT_edit_curve_add"
2030     bl_label = "Add"
2031     bl_translation_context = i18n_contexts.operator_default
2032
2033     def draw(self, context):
2034         is_surf = context.active_object.type == 'SURFACE'
2035
2036         layout = self.layout
2037         layout.operator_context = 'EXEC_REGION_WIN'
2038
2039         if is_surf:
2040             VIEW3D_MT_surface_add.draw(self, context)
2041         else:
2042             VIEW3D_MT_curve_add.draw(self, context)
2043
2044
2045 class TOPBAR_MT_edit_armature_add(Menu):
2046     bl_idname = "TOPBAR_MT_edit_armature_add"
2047     bl_label = "Armature"
2048
2049     def draw(self, _context):
2050         layout = self.layout
2051
2052         layout.operator_context = 'EXEC_REGION_WIN'
2053         layout.operator("armature.bone_primitive_add", text="Single Bone", icon='BONE_DATA')
2054
2055
2056 class VIEW3D_MT_armature_add(Menu):
2057     bl_idname = "VIEW3D_MT_armature_add"
2058     bl_label = "Armature"
2059
2060     def draw(self, _context):
2061         layout = self.layout
2062
2063         layout.operator_context = 'EXEC_REGION_WIN'
2064         layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA')
2065
2066
2067 class VIEW3D_MT_light_add(Menu):
2068     bl_idname = "VIEW3D_MT_light_add"
2069     bl_label = "Light"
2070
2071     def draw(self, _context):
2072         layout = self.layout
2073
2074         layout.operator_context = 'INVOKE_REGION_WIN'
2075         layout.operator_enum("object.light_add", "type")
2076
2077
2078 class VIEW3D_MT_lightprobe_add(Menu):
2079     bl_idname = "VIEW3D_MT_lightprobe_add"
2080     bl_label = "Light Probe"
2081
2082     def draw(self, _context):
2083         layout = self.layout
2084
2085         layout.operator_context = 'INVOKE_REGION_WIN'
2086         layout.operator_enum("object.lightprobe_add", "type")
2087
2088
2089 class VIEW3D_MT_camera_add(Menu):
2090     bl_idname = "VIEW3D_MT_camera_add"
2091     bl_label = "Camera"
2092
2093     def draw(self, _context):
2094         layout = self.layout
2095         layout.operator_context = 'EXEC_REGION_WIN'
2096         layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
2097
2098
2099 class VIEW3D_MT_volume_add(Menu):
2100     bl_idname = "VIEW3D_MT_volume_add"
2101     bl_label = "Volume"
2102
2103     def draw(self, _context):
2104         layout = self.layout
2105         layout.operator("object.volume_import", text="Import OpenVDB...", icon='OUTLINER_DATA_VOLUME')
2106         layout.operator("object.volume_add", text="Empty", icon='OUTLINER_DATA_VOLUME')
2107
2108
2109 class VIEW3D_MT_add(Menu):
2110     bl_label = "Add"
2111     bl_translation_context = i18n_contexts.operator_default
2112
2113     def draw(self, context):
2114         layout = self.layout
2115
2116         # note, don't use 'EXEC_SCREEN' or operators won't get the 'v3d' context.
2117
2118         # Note: was EXEC_AREA, but this context does not have the 'rv3d', which prevents
2119         #       "align_view" to work on first call (see T32719).
2120         layout.operator_context = 'EXEC_REGION_WIN'
2121
2122         # layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH')
2123         layout.menu("VIEW3D_MT_mesh_add", icon='OUTLINER_OB_MESH')
2124
2125         # layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
2126         layout.menu("VIEW3D_MT_curve_add", icon='OUTLINER_OB_CURVE')
2127         # layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
2128         layout.menu("VIEW3D_MT_surface_add", icon='OUTLINER_OB_SURFACE')
2129         layout.menu("VIEW3D_MT_metaball_add", text="Metaball", icon='OUTLINER_OB_META')
2130         layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
2131         if context.preferences.experimental.use_new_hair_type:
2132             layout.operator("object.hair_add", text="Hair", icon='OUTLINER_OB_HAIR')
2133         if context.preferences.experimental.use_new_point_cloud_type:
2134             layout.operator("object.pointcloud_add", text="Point Cloud", icon='OUTLINER_OB_POINTCLOUD')
2135         layout.menu("VIEW3D_MT_volume_add", text="Volume", icon='OUTLINER_OB_VOLUME')
2136         layout.operator_menu_enum("object.gpencil_add", "type", text="Grease Pencil", icon='OUTLINER_OB_GREASEPENCIL')
2137
2138         layout.separator()
2139
2140         if VIEW3D_MT_armature_add.is_extended():
2141             layout.menu("VIEW3D_MT_armature_add", icon='OUTLINER_OB_ARMATURE')
2142         else:
2143             layout.operator("object.armature_add", text="Armature", icon='OUTLINER_OB_ARMATURE')
2144
2145         layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
2146
2147         layout.separator()
2148
2149         layout.operator_menu_enum("object.empty_add", "type", text="Empty", icon='OUTLINER_OB_EMPTY')
2150         layout.menu("VIEW3D_MT_image_add", text="Image", icon='OUTLINER_OB_IMAGE')
2151
2152         layout.separator()
2153
2154         layout.menu("VIEW3D_MT_light_add", icon='OUTLINER_OB_LIGHT')
2155         layout.menu("VIEW3D_MT_lightprobe_add", icon='OUTLINER_OB_LIGHTPROBE')
2156
2157         layout.separator()
2158
2159         if VIEW3D_MT_camera_add.is_extended():
2160             layout.menu("VIEW3D_MT_camera_add", icon='OUTLINER_OB_CAMERA')
2161         else:
2162             VIEW3D_MT_camera_add.draw(self, context)
2163
2164         layout.separator()
2165
2166         layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER')
2167
2168         layout.separator()
2169
2170         layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_FORCE_FIELD')
2171
2172         layout.separator()
2173
2174         has_collections = bool(bpy.data.collections)
2175         col = layout.column()
2176         col.enabled = has_collections
2177
2178         if not has_collections or len(bpy.data.collections) > 10:
2179             col.operator_context = 'INVOKE_REGION_WIN'
2180             col.operator(
2181                 "object.collection_instance_add",
2182                 text="Collection Instance..." if has_collections else "No Collections to Instance",
2183                 icon='OUTLINER_OB_GROUP_INSTANCE',
2184             )
2185         else:
2186             col.operator_menu_enum(
2187                 "object.collection_instance_add",
2188                 "collection",
2189                 text="Collection Instance",
2190                 icon='OUTLINER_OB_GROUP_INSTANCE',
2191             )
2192
2193
2194 class VIEW3D_MT_image_add(Menu):
2195     bl_label = "Add Image"
2196
2197     def draw(self, _context):
2198         layout = self.layout
2199         layout.operator("object.load_reference_image", text="Reference", icon='IMAGE_REFERENCE')
2200         layout.operator("object.load_background_image", text="Background", icon='IMAGE_BACKGROUND')
2201
2202
2203 class VIEW3D_MT_object_relations(Menu):
2204     bl_label = "Relations"
2205
2206     def draw(self, _context):
2207         layout = self.layout
2208
2209         layout.operator("object.proxy_make", text="Make Proxy...")
2210
2211         layout.operator("object.make_override_library", text="Make Library Override...")
2212
2213         layout.operator("object.convert_proxy_to_override")
2214
2215         layout.operator("object.make_dupli_face")
2216
2217         layout.separator()
2218
2219         layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
2220         layout.menu("VIEW3D_MT_make_single_user")
2221
2222         layout.separator()
2223
2224         layout.operator("object.data_transfer")
2225         layout.operator("object.datalayout_transfer")
2226
2227
2228 class VIEW3D_MT_object(Menu):
2229     bl_context = "objectmode"
2230     bl_label = "Object"
2231
2232     def draw(self, context):
2233         layout = self.layout
2234
2235         layout.menu("VIEW3D_MT_transform_object")
2236         layout.operator_menu_enum("object.origin_set", text="Set Origin", property="type")
2237         layout.menu("VIEW3D_MT_mirror")
2238         layout.menu("VIEW3D_MT_object_clear")
2239         layout.menu("VIEW3D_MT_object_apply")
2240         layout.menu("VIEW3D_MT_snap")
2241
2242         layout.separator()
2243
2244         layout.operator("object.duplicate_move")
2245         layout.operator("object.duplicate_move_linked")
2246         layout.operator("object.join")
2247
2248         layout.separator()
2249
2250         layout.operator("view3d.copybuffer", text="Copy Objects", icon='COPYDOWN')
2251         layout.operator("view3d.pastebuffer", text="Paste Objects", icon='PASTEDOWN')
2252
2253         layout.separator()
2254
2255         layout.menu("VIEW3D_MT_object_parent")
2256         layout.menu("VIEW3D_MT_object_collection")
2257         layout.menu("VIEW3D_MT_object_relations")
2258         layout.menu("VIEW3D_MT_object_constraints")
2259         layout.menu("VIEW3D_MT_object_track")
2260         layout.menu("VIEW3D_MT_make_links", text="Make Links")
2261
2262         layout.separator()
2263
2264         layout.operator("object.shade_smooth")
2265         layout.operator("object.shade_flat")
2266
2267         layout.separator()
2268
2269         layout.menu("VIEW3D_MT_object_animation")
2270         layout.menu("VIEW3D_MT_object_rigid_body")
2271
2272         layout.separator()
2273
2274         layout.menu("VIEW3D_MT_object_quick_effects")
2275
2276         layout.separator()
2277
2278         ob = context.active_object
2279         if ob and ob.type == 'GPENCIL' and context.gpencil_data:
2280             layout.operator_menu_enum("gpencil.convert", "type", text="Convert To")
2281         else:
2282             layout.operator_menu_enum("object.convert", "target")
2283
2284         # Potrace lib dependency
2285         if bpy.app.build_options.potrace:
2286             layout.separator()
2287             layout.operator("gpencil.trace_image")
2288
2289         layout.separator()
2290
2291         layout.menu("VIEW3D_MT_object_showhide")
2292         layout.menu("VIEW3D_MT_object_cleanup")
2293
2294         layout.separator()
2295
2296         layout.operator_context = 'EXEC_REGION_WIN'
2297         layout.operator("object.delete", text="Delete").use_global = False
2298         layout.operator("object.delete", text="Delete Global").use_global = True
2299
2300
2301 class VIEW3D_MT_object_animation(Menu):
2302     bl_label = "Animation"
2303
2304     def draw(self, _context):
2305         layout = self.layout
2306
2307         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
2308         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframes...")
2309         layout.operator("anim.keyframe_clear_v3d", text="Clear Keyframes...")
2310         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
2311
2312         layout.separator()
2313
2314         layout.operator("nla.bake", text="Bake Action...")
2315         layout.operator("gpencil.bake_mesh_animation", text="Bake Mesh to Grease Pencil...")
2316
2317
2318 class VIEW3D_MT_object_rigid_body(Menu):
2319     bl_label = "Rigid Body"
2320
2321     def draw(self, _context):
2322         layout = self.layout
2323
2324         layout.operator("rigidbody.objects_add", text="Add Active").type = 'ACTIVE'
2325         layout.operator("rigidbody.objects_add", text="Add Passive").type = 'PASSIVE'
2326
2327         layout.separator()
2328
2329         layout.operator("rigidbody.objects_remove", text="Remove")
2330
2331         layout.separator()
2332
2333         layout.operator("rigidbody.shape_change", text="Change Shape")
2334         layout.operator("rigidbody.mass_calculate", text="Calculate Mass")
2335         layout.operator("rigidbody.object_settings_copy", text="Copy from Active")
2336         layout.operator("object.visual_transform_apply", text="Apply Transformation")
2337         layout.operator("rigidbody.bake_to_keyframes", text="Bake to Keyframes")
2338
2339         layout.separator()
2340
2341         layout.operator("rigidbody.connect", text="Connect")
2342
2343
2344 class VIEW3D_MT_object_clear(Menu):
2345     bl_label = "Clear"
2346
2347     def draw(self, _context):
2348         layout = self.layout
2349
2350         layout.operator("object.location_clear", text="Location").clear_delta = False
2351         layout.operator("object.rotation_clear", text="Rotation").clear_delta = False
2352         layout.operator("object.scale_clear", text="Scale").clear_delta = False
2353
2354         layout.separator()
2355
2356         layout.operator("object.origin_clear", text="Origin")
2357
2358
2359 class VIEW3D_MT_object_context_menu(Menu):
2360     bl_label = "Object Context Menu"
2361
2362     def draw(self, context):
2363
2364         layout = self.layout
2365         view = context.space_data
2366
2367         obj = context.object
2368
2369         selected_objects_len = len(context.selected_objects)
2370
2371         # If nothing is selected
2372         # (disabled for now until it can be made more useful).
2373         '''
2374         if selected_objects_len == 0:
2375
2376             layout.menu("VIEW3D_MT_add", text="Add", text_ctxt=i18n_contexts.operator_default)
2377             layout.operator("view3d.pastebuffer", text="Paste Objects", icon='PASTEDOWN')
2378
2379             return
2380         '''
2381
2382         # If something is selected
2383         if obj is not None and obj.type in {'MESH', 'CURVE', 'SURFACE'}:
2384             layout.operator("object.shade_smooth", text="Shade Smooth")
2385             layout.operator("object.shade_flat", text="Shade Flat")
2386
2387             layout.separator()
2388
2389         if obj is None:
2390             pass
2391         elif obj.type == 'MESH':
2392             layout.operator_context = 'INVOKE_REGION_WIN'
2393             layout.operator_menu_enum("object.origin_set", text="Set Origin", property="type")
2394
2395             layout.operator_context = 'INVOKE_DEFAULT'
2396             # If more than one object is selected
2397             if selected_objects_len > 1:
2398                 layout.operator("object.join")
2399
2400             layout.separator()
2401
2402         elif obj.type == 'CAMERA':
2403             layout.operator_context = 'INVOKE_REGION_WIN'
2404
2405             if obj.data.type == 'PERSP':
2406                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle")
2407                 props.data_path_iter = "selected_editable_objects"
2408                 props.data_path_item = "data.lens"
2409                 props.input_scale = 0.1
2410                 if obj.data.lens_unit == 'MILLIMETERS':
2411                     props.header_text = "Camera Lens Angle: %.1fmm"
2412                 else:
2413                     props.header_text = "Camera Lens Angle: %.1f\u00B0"
2414
2415             else:
2416                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale")
2417                 props.data_path_iter = "selected_editable_objects"
2418                 props.data_path_item = "data.ortho_scale"
2419                 props.input_scale = 0.01
2420                 props.header_text = "Camera Lens Scale: %.3f"
2421
2422             if not obj.data.dof.focus_object:
2423                 if view and view.camera == obj and view.region_3d.view_perspective == 'CAMERA':
2424                     props = layout.operator("ui.eyedropper_depth", text="DOF Distance (Pick)")
2425                 else:
2426                     props = layout.operator("wm.context_modal_mouse", text="DOF Distance")
2427                     props.data_path_iter = "selected_editable_objects"
2428                     props.data_path_item = "data.dof.focus_distance"
2429                     props.input_scale = 0.02
2430                     props.header_text = "DOF Distance: %.3f"
2431
2432             layout.separator()
2433
2434         elif obj.type in {'CURVE', 'FONT'}:
2435             layout.operator_context = 'INVOKE_REGION_WIN'
2436
2437             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
2438             props.data_path_iter = "selected_editable_objects"
2439             props.data_path_item = "data.extrude"
2440             props.input_scale = 0.01
2441             props.header_text = "Extrude Size: %.3f"
2442
2443             props = layout.operator("wm.context_modal_mouse", text="Width Size")
2444             props.data_path_iter = "selected_editable_objects"
2445             props.data_path_item = "data.offset"
2446             props.input_scale = 0.01
2447             props.header_text = "Width Size: %.3f"
2448
2449             layout.separator()
2450
2451             layout.operator("object.convert", text="Convert to Mesh").target = 'MESH'
2452             layout.operator("object.convert", text="Convert to Grease Pencil").target = 'GPENCIL'
2453             layout.operator_menu_enum("object.origin_set", text="Set Origin", property="type")
2454
2455             layout.separator()
2456
2457         elif obj.type == 'GPENCIL':
2458             layout.operator("gpencil.convert", text="Convert to Path").type = 'PATH'
2459             layout.operator("gpencil.convert", text="Convert to Bezier Curve").type = 'CURVE'
2460             layout.operator("gpencil.convert", text="Convert to Polygon Curve").type = 'POLY'
2461
2462             layout.operator_menu_enum("object.origin_set", text="Set Origin", property="type")
2463
2464             layout.separator()
2465
2466         elif obj.type == 'EMPTY':
2467             layout.operator_context = 'INVOKE_REGION_WIN'
2468
2469             props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size")
2470             props.data_path_iter = "selected_editable_objects"
2471             props.data_path_item = "empty_display_size"
2472             props.input_scale = 0.01
2473             props.header_text = "Empty Draw Size: %.3f"
2474
2475             layout.separator()
2476
2477         elif obj.type == 'LIGHT':
2478             light = obj.data
2479
2480             layout.operator_context = 'INVOKE_REGION_WIN'
2481
2482             props = layout.operator("wm.context_modal_mouse", text="Power")
2483             props.data_path_iter = "selected_editable_objects"
2484             props.data_path_item = "data.energy"
2485             props.header_text = "Light Power: %.3f"
2486
2487             if light.type == 'AREA':
2488                 props = layout.operator("wm.context_modal_mouse", text="Size X")
2489                 props.data_path_iter = "selected_editable_objects"
2490                 props.data_path_item = "data.size"
2491                 props.header_text = "Light Size X: %.3f"
2492
2493                 if light.shape in {'RECTANGLE', 'ELLIPSE'}:
2494                     props = layout.operator("wm.context_modal_mouse", text="Size Y")
2495                     props.data_path_iter = "selected_editable_objects"
2496                     props.data_path_item = "data.size_y"
2497                     props.header_text = "Light Size Y: %.3f"
2498
2499             elif light.type in {'SPOT', 'POINT'}:
2500                 props = layout.operator("wm.context_modal_mouse", text="Radius")
2501                 props.data_path_iter = "selected_editable_objects"
2502                 props.data_path_item = "data.shadow_soft_size"
2503                 props.header_text = "Light Radius: %.3f"
2504
2505             elif light.type == 'SUN':
2506                 props = layout.operator("wm.context_modal_mouse", text="Angle")
2507                 props.data_path_iter = "selected_editable_objects"
2508                 props.data_path_item = "data.angle"
2509                 props.header_text = "Light Angle: %.3f"
2510
2511             if light.type == 'SPOT':
2512                 layout.separator()
2513
2514                 props = layout.operator("wm.context_modal_mouse", text="Spot Size")
2515                 props.data_path_iter = "selected_editable_objects"
2516                 props.data_path_item = "data.spot_size"
2517                 props.input_scale = 0.01
2518                 props.header_text = "Spot Size: %.2f"
2519
2520                 props = layout.operator("wm.context_modal_mouse", text="Spot Blend")
2521                 props.data_path_iter = "selected_editable_objects"
2522                 props.data_path_item = "data.spot_blend"
2523                 props.input_scale = -0.01
2524                 props.header_text = "Spot Blend: %.2f"
2525
2526             layout.separator()
2527
2528         layout.operator("view3d.copybuffer", text="Copy Objects", icon='COPYDOWN')
2529         layout.operator("view3d.pastebuffer", text="Paste Objects", icon='PASTEDOWN')
2530
2531         layout.separator()
2532
2533         layout.operator("object.duplicate_move", icon='DUPLICATE')
2534         layout.operator("object.duplicate_move_linked")
2535
2536         layout.separator()
2537
2538         props = layout.operator("wm.call_panel", text="Rename Active Object...")
2539         props.name = "TOPBAR_PT_name"
2540         props.keep_open = False
2541
2542         layout.separator()
2543
2544         layout.menu("VIEW3D_MT_mirror")
2545         layout.menu("VIEW3D_MT_snap")
2546         layout.menu("VIEW3D_MT_object_parent")
2547         layout.operator_context = 'INVOKE_REGION_WIN'
2548
2549         if view and view.local_view:
2550             layout.operator("view3d.localview_remove_from")
2551         else:
2552             layout.operator("object.move_to_collection")
2553
2554         layout.separator()
2555
2556         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
2557
2558         layout.separator()
2559
2560         layout.operator_context = 'EXEC_REGION_WIN'
2561         layout.operator("object.delete", text="Delete").use_global = False
2562
2563
2564 class VIEW3D_MT_object_shading(Menu):
2565     # XXX, this menu is a place to store shading operator in object mode
2566     bl_label = "Shading"
2567
2568     def draw(self, _context):
2569         layout = self.layout
2570         layout.operator("object.shade_smooth", text="Smooth")
2571         layout.operator("object.shade_flat", text="Flat")
2572
2573
2574 class VIEW3D_MT_object_apply(Menu):
2575     bl_label = "Apply"
2576
2577     def draw(self, _context):
2578         layout = self.layout
2579
2580         props = layout.operator("object.transform_apply", text="Location", text_ctxt=i18n_contexts.default)
2581         props.location, props.rotation, props.scale = True, False, False
2582
2583         props = layout.operator("object.transform_apply", text="Rotation", text_ctxt=i18n_contexts.default)
2584         props.location, props.rotation, props.scale = False, True, False
2585
2586         props = layout.operator("object.transform_apply", text="Scale", text_ctxt=i18n_contexts.default)
2587         props.location, props.rotation, props.scale = False, False, True
2588
2589         props = layout.operator("object.transform_apply", text="All Transforms", text_ctxt=i18n_contexts.default)
2590         props.location, props.rotation, props.scale = True, True, True
2591
2592         props = layout.operator("object.transform_apply", text="Rotation & Scale", text_ctxt=i18n_contexts.default)
2593         props.location, props.rotation, props.scale = False, True, True
2594
2595         layout.separator()
2596
2597         layout.operator(
2598             "object.transforms_to_deltas",
2599             text="Location to Deltas",
2600             text_ctxt=i18n_contexts.default,
2601         ).mode = 'LOC'
2602         layout.operator(
2603             "object.transforms_to_deltas",
2604             text="Rotation to Deltas",
2605             text_ctxt=i18n_contexts.default,
2606         ).mode = 'ROT'
2607         layout.operator(
2608             "object.transforms_to_deltas",
2609             text="Scale to Deltas",
2610             text_ctxt=i18n_contexts.default,
2611         ).mode = 'SCALE'
2612
2613         layout.operator(
2614             "object.transforms_to_deltas",
2615             text="All Transforms to Deltas",
2616             text_ctxt=i18n_contexts.default,
2617         ).mode = 'ALL'
2618         layout.operator("object.anim_transforms_to_deltas")
2619
2620         layout.separator()
2621
2622         layout.operator(
2623             "object.visual_transform_apply",
2624             text="Visual Transform",
2625             text_ctxt=i18n_contexts.default,
2626         )
2627         layout.operator(
2628             "object.convert",
2629             text="Visual Geometry to Mesh",
2630             text_ctxt=i18n_contexts.default,
2631         ).target = 'MESH'
2632         layout.operator("object.duplicates_make_real")
2633
2634
2635 class VIEW3D_MT_object_parent(Menu):
2636     bl_label = "Parent"
2637
2638     def draw(self, _context):
2639         layout = self.layout
2640         operator_context_default = layout.operator_context
2641
2642         layout.operator_enum("object.parent_set", "type")
2643
2644         layout.separator()
2645
2646         layout.operator_context = 'EXEC_REGION_WIN'
2647         layout.operator("object.parent_no_inverse_set")
2648         layout.operator_context = operator_context_default
2649
2650         layout.separator()
2651
2652         layout.operator_enum("object.parent_clear", "type")
2653
2654
2655 class VIEW3D_MT_object_track(Menu):
2656     bl_label = "Track"
2657
2658     def draw(self, _context):
2659         layout = self.layout
2660
2661         layout.operator_enum("object.track_set", "type")
2662
2663         layout.separator()
2664
2665         layout.operator_enum("object.track_clear", "type")
2666
2667
2668 class VIEW3D_MT_object_collection(Menu):
2669     bl_label = "Collection"
2670
2671     def draw(self, _context):
2672         layout = self.layout
2673
2674         layout.operator("object.move_to_collection")
2675         layout.operator("object.link_to_collection")
2676
2677         layout.separator()
2678
2679         layout.operator("collection.create")
2680         # layout.operator_menu_enum("collection.objects_remove", "collection")  # BUGGY
2681         layout.operator("collection.objects_remove")
2682         layout.operator("collection.objects_remove_all")
2683
2684         layout.separator()
2685
2686         layout.operator("collection.objects_add_active")
2687         layout.operator("collection.objects_remove_active")
2688
2689
2690 class VIEW3D_MT_object_constraints(Menu):
2691     bl_label = "Constraints"
2692
2693     def draw(self, _context):
2694         layout = self.layout
2695
2696         layout.operator("object.constraint_add_with_targets")
2697         layout.operator("object.constraints_copy")
2698
2699         layout.separator()
2700
2701         layout.operator("object.constraints_clear")
2702
2703
2704 class VIEW3D_MT_object_quick_effects(Menu):
2705     bl_label = "Quick Effects"
2706
2707     def draw(self, context):
2708         layout = self.layout
2709
2710         layout.operator("object.quick_fur")
2711         layout.operator("object.quick_explode")
2712         layout.operator("object.quick_smoke")
2713         layout.operator("object.quick_liquid")
2714
2715
2716 class VIEW3D_MT_object_showhide(Menu):
2717     bl_label = "Show/Hide"
2718
2719     def draw(self, _context):
2720         layout = self.layout
2721
2722         layout.operator("object.hide_view_clear")
2723
2724         layout.separator()
2725
2726         layout.operator("object.hide_view_set", text="Hide Selected").unselected = False
2727         layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True
2728
2729
2730 class VIEW3D_MT_object_cleanup(Menu):
2731     bl_label = "Clean Up"
2732
2733     def draw(self, _context):
2734         layout = self.layout
2735
2736         layout.operator("object.vertex_group_clean", text="Clean Vertex Group Weights").group_select_mode = 'ALL'
2737         layout.operator("object.vertex_group_limit_total", text="Limit Total Vertex Groups").group_select_mode = 'ALL'
2738
2739         layout.separator()
2740
2741         layout.operator("object.material_slot_remove_unused", text="Remove Unused Material Slots")
2742
2743
2744 class VIEW3D_MT_make_single_user(Menu):
2745     bl_label = "Make Single User"
2746
2747     def draw(self, _context):
2748         layout = self.layout
2749         layout.operator_context = 'EXEC_REGION_WIN'
2750
2751         props = layout.operator("object.make_single_user", text="Object")
2752         props.object = True
2753         props.obdata = props.material = props.animation = False
2754
2755         props = layout.operator("object.make_single_user", text="Object & Data")
2756         props.object = props.obdata = True
2757         props.material = props.animation = False
2758
2759         props = layout.operator("object.make_single_user", text="Object & Data & Materials")
2760         props.object = props.obdata = props.material = True
2761         props.animation = False
2762
2763         props = layout.operator("object.make_single_user", text="Materials")
2764         props.material = True
2765         props.object = props.obdata = props.animation = False
2766
2767         props = layout.operator("object.make_single_user", text="Object Animation")
2768         props.animation = True
2769         props.object = props.obdata = props.material = False
2770
2771
2772 class VIEW3D_MT_make_links(Menu):
2773     bl_label = "Make Links"
2774
2775     def draw(self, _context):
2776         layout = self.layout
2777         operator_context_default = layout.operator_context
2778
2779         if len(bpy.data.scenes) > 10:
2780             layout.operator_context = 'INVOKE_REGION_WIN'
2781             layout.operator("object.make_links_scene", text="Objects to Scene...", icon='OUTLINER_OB_EMPTY')
2782         else:
2783             layout.operator_context = 'EXEC_REGION_WIN'
2784             layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene")
2785
2786         layout.separator()
2787
2788         layout.operator_context = operator_context_default
2789
2790         layout.operator_enum("object.make_links_data", "type")  # inline
2791
2792         layout.operator("object.join_uvs")  # stupid place to add this!
2793
2794
2795 class VIEW3D_MT_brush_paint_modes(Menu):
2796     bl_label = "Enabled Modes"
2797
2798     def draw(self, context):
2799         layout = self.layout
2800
2801         settings = UnifiedPaintPanel.paint_settings(context)
2802         brush = settings.brush
2803
2804         layout.prop(brush, "use_paint_sculpt", text="Sculpt")
2805         layout.prop(brush, "use_paint_uv_sculpt", text="UV Sculpt")
2806         layout.prop(brush, "use_paint_vertex", text="Vertex Paint")
2807         layout.prop(brush, "use_paint_weight", text="Weight Paint")
2808         layout.prop(brush, "use_paint_image", text="Texture Paint")
2809
2810
2811 class VIEW3D_MT_paint_vertex(Menu):
2812     bl_label = "Paint"
2813
2814     def draw(self, _context):
2815         layout = self.layout
2816
2817         layout.operator("paint.vertex_color_set")
2818         layout.operator("paint.vertex_color_smooth")
2819         layout.operator("paint.vertex_color_dirt")
2820         layout.operator("paint.vertex_color_from_weight")
2821
2822         layout.separator()
2823
2824         layout.operator("paint.vertex_color_invert", text="Invert")
2825         layout.operator("paint.vertex_color_levels", text="Levels")
2826         layout.operator("paint.vertex_color_hsv", text="Hue Saturation Value")
2827         layout.operator("paint.vertex_color_brightness_contrast", text="Bright/Contrast")
2828
2829
2830 class VIEW3D_MT_hook(Menu):
2831     bl_label = "Hooks"
2832
2833     def draw(self, context):
2834         layout = self.layout
2835         layout.operator_context = 'EXEC_AREA'
2836         layout.operator("object.hook_add_newob")
2837         layout.operator("object.hook_add_selob").use_bone = False
2838         layout.operator("object.hook_add_selob", text="Hook to Selected Object Bone").use_bone = True
2839
2840         if any([mod.type == 'HOOK' for mod in context.active_object.modifiers]):
2841             layout.separator()
2842
2843             layout.operator_menu_enum("object.hook_assign", "modifier")
2844             layout.operator_menu_enum("object.hook_remove", "modifier")
2845
2846             layout.separator()
2847
2848             layout.operator_menu_enum("object.hook_select", "modifier")
2849             layout.operator_menu_enum("object.hook_reset", "modifier")
2850             layout.operator_menu_enum("object.hook_recenter", "modifier")
2851
2852
2853 class VIEW3D_MT_vertex_group(Menu):
2854     bl_label = "Vertex Groups"
2855
2856     def draw(self, context):
2857         layout = self.layout
2858
2859         layout.operator_context = 'EXEC_AREA'
2860         layout.operator("object.vertex_group_assign_new")
2861
2862         ob = context.active_object
2863         if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex):
2864             if ob.vertex_groups.active:
2865                 layout.separator()
2866
2867                 layout.operator("object.vertex_group_assign", text="Assign to Active Group")
2868                 layout.operator(
2869                     "object.vertex_group_remove_from",
2870                     text="Remove from Active Group",
2871                 ).use_all_groups = False
2872                 layout.operator("object.vertex_group_remove_from", text="Remove from All").use_all_groups = True
2873
2874         if ob.vertex_groups.active:
2875             layout.separator()
2876
2877             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
2878             layout.operator("object.vertex_group_remove", text="Remove Active Group").all = False
2879             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
2880
2881
2882 class VIEW3D_MT_gpencil_vertex_group(Menu):
2883     bl_label = "Vertex Groups"
2884
2885     def draw(self, context):
2886         layout = self.layout
2887
2888         layout.operator_context = 'EXEC_AREA'
2889         ob = context.active_object
2890
2891         layout.operator("object.vertex_group_add", text="Add New Group")
2892         ob = context.active_object
2893         if ob.vertex_groups.active:
2894             layout.separator()
2895
2896             layout.operator("gpencil.vertex_group_assign", text="Assign")
2897             layout.operator("gpencil.vertex_group_remove_from", text="Remove")
2898
2899             layout.operator("gpencil.vertex_group_select", text="Select")
2900             layout.operator("gpencil.vertex_group_deselect", text="Deselect")
2901
2902
2903 class VIEW3D_MT_paint_weight_lock(Menu):
2904     bl_label = "Vertex Group Locks"
2905
2906     def draw(self, _context):
2907         layout = self.layout
2908
2909         op = layout.operator("object.vertex_group_lock", icon='LOCKED', text="Lock All")
2910         op.action, op.mask = 'LOCK', 'ALL'
2911         op = layout.operator("object.vertex_group_lock", icon='UNLOCKED', text="Unlock All")
2912         op.action, op.mask = 'UNLOCK', 'ALL'
2913         op = layout.operator("object.vertex_group_lock", icon='LOCKED', text="Lock Selected")
2914         op.action, op.mask = 'LOCK', 'SELECTED'
2915         op = layout.operator("object.vertex_group_lock", icon='UNLOCKED', text="Unlock Selected")
2916         op.action, op.mask = 'UNLOCK', 'SELECTED'
2917         op = layout.operator("object.vertex_group_lock", icon='LOCKED', text="Lock Unselected")
2918         op.action, op.mask = 'LOCK', 'UNSELECTED'
2919         op = layout.operator("object.vertex_group_lock", icon='UNLOCKED', text="Unlock Unselected")
2920         op.action, op.mask = 'UNLOCK', 'UNSELECTED'
2921         op = layout.operator("object.vertex_group_lock", text="Lock Only Selected")
2922         op.action, op.mask = 'LOCK', 'INVERT_UNSELECTED'
2923         op = layout.operator("object.vertex_group_lock", text="Lock Only Unselected")
2924         op.action, op.mask = 'UNLOCK', 'INVERT_UNSELECTED'
2925         op = layout.operator("object.vertex_group_lock", text="Invert Locks")
2926         op.action, op.mask = 'INVERT', 'ALL'
2927
2928
2929 class VIEW3D_MT_paint_weight(Menu):
2930     bl_label = "Weights"
2931
2932     @staticmethod
2933     def draw_generic(layout, is_editmode=False):
2934
2935         if not is_editmode:
2936
2937             layout.operator("paint.weight_from_bones", text="Assign Automatic from Bones").type = 'AUTOMATIC'
2938             layout.operator("paint.weight_from_bones", text="Assign from Bone Envelopes").type = 'ENVELOPES'
2939
2940             layout.separator()
2941
2942         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
2943         layout.operator("object.vertex_group_normalize", text="Normalize")
2944
2945         layout.separator()
2946
2947         layout.operator("object.vertex_group_mirror", text="Mirror")
2948         layout.operator("object.vertex_group_invert", text="Invert")
2949         layout.operator("object.vertex_group_clean", text="Clean")
2950
2951         layout.separator()
2952
2953         layout.operator("object.vertex_group_quantize", text="Quantize")
2954         layout.operator("object.vertex_group_levels", text="Levels")
2955         layout.operator("object.vertex_group_smooth", text="Smooth")
2956
2957         if not is_editmode:
2958             props = layout.operator("object.data_transfer", text="Transfer Weights")
2959             props.use_reverse_transfer = True
2960             props.data_type = 'VGROUP_WEIGHTS'
2961
2962         layout.operator("object.vertex_group_limit_total", text="Limit Total")
2963         layout.operator("object.vertex_group_fix", text="Fix Deforms")
2964
2965         if not is_editmode:
2966             layout.separator()
2967
2968             layout.operator("paint.weight_set")
2969
2970         layout.menu("VIEW3D_MT_paint_weight_lock", text="Locks")
2971
2972     def draw(self, _context):
2973         self.draw_generic(self.layout, is_editmode=False)
2974
2975
2976 class VIEW3D_MT_sculpt(Menu):
2977     bl_label = "Sculpt"
2978
2979     def draw(self, _context):
2980         layout = self.layout
2981
2982         props = layout.operator("paint.hide_show", text="Show All")
2983         props.action = 'SHOW'
2984         props.area = 'ALL'
2985
2986         props = layout.operator("paint.hide_show", text="Show Bounding Box")
2987         props.action = 'SHOW'
2988         props.area = 'INSIDE'
2989
2990         props = layout.operator("paint.hide_show", text="Hide Bounding Box")
2991         props.action = 'HIDE'
2992         props.area = 'INSIDE'
2993
2994         props = layout.operator("paint.hide_show", text="Hide Masked")
2995         props.action = 'HIDE'
2996         props.area = 'MASKED'
2997
2998         layout.separator()
2999
3000         layout.menu("VIEW3D_MT_sculpt_set_pivot", text="Set Pivot")
3001
3002         layout.separator()
3003
3004         layout.operator("sculpt.optimize")
3005
3006
3007 class VIEW3D_MT_mask(Menu):
3008     bl_label = "Mask"
3009
3010     def draw(self, _context):
3011         layout = self.layout
3012
3013         props = layout.operator("paint.mask_flood_fill", text="Invert Mask")
3014         props.mode = 'INVERT'
3015
3016         props = layout.operator("paint.mask_flood_fill", text="Fill Mask")
3017         props.mode = 'VALUE'
3018         props.value = 1
3019
3020         props = layout.operator("paint.mask_flood_fill", text="Clear Mask")
3021         props.mode = 'VALUE'
3022         props.value = 0
3023
3024         props = layout.operator("paint.mask_box_gesture", text="Box Mask")
3025         props.mode = 'VALUE'
3026         props.value = 0
3027
3028         props = layout.operator("paint.mask_lasso_gesture", text="Lasso Mask")
3029
3030         layout.separator()
3031
3032         props = layout.operator("sculpt.mask_filter", text='Smooth Mask')
3033         props.filter_type = 'SMOOTH'
3034         props.auto_iteration_count = True
3035
3036         props = layout.operator("sculpt.mask_filter", text='Sharpen Mask')
3037         props.filter_type = 'SHARPEN'
3038         props.auto_iteration_count = True
3039
3040         props = layout.operator("sculpt.mask_filter", text='Grow Mask')
3041         props.filter_type = 'GROW'
3042         props.auto_iteration_count = True
3043
3044         props = layout.operator("sculpt.mask_filter", text='Shrink Mask')
3045         props.filter_type = 'SHRINK'
3046         props.auto_iteration_count = True
3047
3048         props = layout.operator("sculpt.mask_filter", text='Increase Contrast')
3049         props.filter_type = 'CONTRAST_INCREASE'
3050         props.auto_iteration_count = False
3051
3052         props = layout.operator("sculpt.mask_filter", text='Decrease Contrast')
3053         props.filter_type = 'CONTRAST_DECREASE'
3054         props.auto_iteration_count = False
3055
3056         layout.separator()
3057
3058         props = layout.operator("sculpt.mask_expand", text="Expand Mask by Topology")
3059         props.use_normals = False
3060         props.keep_previous_mask = False
3061         props.invert = True
3062         props.smooth_iterations = 2
3063         props.create_face_set = False
3064
3065         props = layout.operator("sculpt.mask_expand", text="Expand Mask by Curvature")
3066         props.use_normals = True
3067         props.keep_previous_mask = True
3068         props.invert = False
3069         props.smooth_iterations = 0
3070         props.create_face_set = False
3071
3072         layout.separator()
3073
3074         props = layout.operator("mesh.paint_mask_extract", text="Mask Extract")
3075
3076         layout.separator()
3077
3078         props = layout.operator("mesh.paint_mask_slice", text="Mask Slice")
3079         props.fill_holes = False
3080         props.new_object = False
3081         props = layout.operator("mesh.paint_mask_slice", text="Mask Slice and Fill Holes")
3082         props.new_object = False
3083         props = layout.operator("mesh.paint_mask_slice", text="Mask Slice to New Object")
3084
3085         layout.separator()
3086
3087         props = layout.operator("sculpt.dirty_mask", text='Dirty Mask')
3088
3089
3090 class VIEW3D_MT_face_sets(Menu):
3091     bl_label = "Face Sets"
3092
3093     def draw(self, _context):
3094         layout = self.layout
3095
3096         op = layout.operator("sculpt.face_sets_create", text='Face Set from Masked')
3097         op.mode = 'MASKED'
3098
3099         op = layout.operator("sculpt.face_sets_create", text='Face Set from Visible')
3100         op.mode = 'VISIBLE'
3101
3102         op = layout.operator("sculpt.face_sets_create", text='Face Set from Edit Mode Selection')
3103         op.mode = 'SELECTION'
3104
3105         layout.separator()
3106
3107         layout.menu("VIEW3D_MT_face_sets_init", text="Init Face Sets")
3108
3109         layout.separator()
3110
3111         op = layout.operator("sculpt.face_set_edit", text='Grow Face Set')
3112         op.mode = 'GROW'
3113
3114         op = layout.operator("sculpt.face_set_edit", text='Shrink Face Set')
3115         op.mode = 'SHRINK'
3116
3117         layout.separator()
3118
3119         op = layout.operator("mesh.face_set_extract", text='Extract Face Set')
3120
3121         layout.separator()
3122
3123         op = layout.operator("sculpt.face_set_change_visibility", text='Invert Visible Face Sets')
3124         op.mode = 'INVERT'
3125
3126         op = layout.operator("sculpt.face_set_change_visibility", text='Show All Face Sets')
3127         op.mode = 'SHOW_ALL'
3128
3129         layout.separator()
3130
3131         op = layout.operator("sculpt.face_sets_randomize_colors", text='Randomize Colors')
3132
3133
3134 class VIEW3D_MT_sculpt_set_pivot(Menu):
3135     bl_label = "Sculpt Set Pivot"
3136
3137     def draw(self, _context):
3138         layout = self.layout
3139
3140         props = layout.operator("sculpt.set_pivot_position", text="Pivot to Origin")
3141         props.mode = 'ORIGIN'
3142
3143         props = layout.operator("sculpt.set_pivot_position", text="Pivot to Unmasked")
3144         props.mode = 'UNMASKED'
3145
3146         props = layout.operator("sculpt.set_pivot_position", text="Pivot to Mask Border")
3147         props.mode = 'BORDER'
3148
3149         props = layout.operator("sculpt.set_pivot_position", text="Pivot to Active Vertex")
3150         props.mode = 'ACTIVE'
3151
3152         props = layout.operator("sculpt.set_pivot_position", text="Pivot to Surface Under Cursor")
3153         props.mode = 'SURFACE'
3154
3155
3156 class VIEW3D_MT_face_sets_init(Menu):
3157     bl_label = "Face Sets Init"
3158
3159     def draw(self, _context):
3160         layout = self.layout
3161
3162         op = layout.operator("sculpt.face_sets_init", text='By Loose Parts')
3163         op.mode = 'LOOSE_PARTS'
3164
3165         op = layout.operator("sculpt.face_sets_init", text='By Materials')
3166         op.mode = 'MATERIALS'
3167
3168         op = layout.operator("sculpt.face_sets_init", text='By Normals')
3169         op.mode = 'NORMALS'
3170
3171         op = layout.operator("sculpt.face_sets_init", text='By UV Seams')
3172         op.mode = 'UV_SEAMS'
3173
3174         op = layout.operator("sculpt.face_sets_init", text='By Edge Creases')
3175         op.mode = 'CREASES'
3176
3177         op = layout.operator("sculpt.face_sets_init", text='By Edge Bevel Weight')
3178         op.mode = 'BEVEL_WEIGHT'
3179
3180         op = layout.operator("sculpt.face_sets_init", text='By Sharp Edges')
3181         op.mode = 'SHARP_EDGES'
3182
3183         op = layout.operator("sculpt.face_sets_init", text='By Face Maps')
3184         op.mode = 'FACE_MAPS'
3185
3186
3187 class VIEW3D_MT_particle(Menu):
3188     bl_label = "Particle"
3189
3190     def draw(self, context):
3191         layout = self.layout
3192         tool_settings = context.tool_settings
3193
3194         particle_edit = tool_settings.particle_edit
3195
3196         layout.operator("particle.mirror")
3197
3198         layout.operator("particle.remove_doubles")
3199
3200         layout.separator()
3201
3202         if particle_edit.select_mode == 'POINT':
3203             layout.operator("particle.subdivide")
3204
3205         layout.operator("particle.unify_length")
3206         layout.operator("particle.rekey")
3207         layout.operator("particle.weight_set")
3208
3209         layout.separator()
3210
3211         layout.menu("VIEW3D_MT_particle_showhide")
3212
3213         layout.separator()
3214
3215         layout.operator("particle.delete")
3216
3217
3218 class VIEW3D_MT_particle_context_menu(Menu):
3219     bl_label = "Particle Context Menu"
3220
3221     def draw(self, context):
3222         layout = self.layout
3223         tool_settings = context.tool_settings
3224
3225         particle_edit = tool_settings.particle_edit
3226
3227         layout.operator("particle.rekey")
3228
3229         layout.separator()
3230
3231         layout.operator("particle.delete")
3232
3233         layout.separator()
3234
3235         layout.operator("particle.remove_doubles")
3236         layout.operator("particle.unify_length")
3237
3238         if particle_edit.select_mode == 'POINT':
3239             layout.operator("particle.subdivide")
3240
3241         layout.operator("particle.weight_set")
3242
3243         layout.separator()
3244
3245         layout.operator("particle.mirror")
3246
3247         if particle_edit.select_mode == 'POINT':
3248             layout.separator()
3249
3250             layout.operator("particle.select_all", text="All").action = 'SELECT'
3251             layout.operator("particle.select_all", text="None").action = 'DESELECT'
3252             layout.operator("particle.select_all", text="Invert").action = 'INVERT'
3253
3254             layout.separator()
3255
3256             layout.operator("particle.select_roots")
3257             layout.operator("particle.select_tips")
3258
3259             layout.separator()
3260
3261             layout.operator("particle.select_random")
3262
3263             layout.separator()
3264
3265             layout.operator("particle.select_more")
3266             layout.operator("particle.select_less")
3267
3268             layout.separator()
3269
3270             layout.operator("particle.select_linked", text="Select Linked")
3271
3272
3273 class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
3274     _operator_name = "particle"
3275
3276
3277 class VIEW3D_MT_pose(Menu):
3278     bl_label = "Pose"
3279
3280     def draw(self, _context):
3281         layout = self.layout
3282
3283         layout.menu("VIEW3D_MT_transform_armature")
3284
3285         layout.menu("VIEW3D_MT_pose_transform")
3286         layout.menu("VIEW3D_MT_pose_apply")
3287
3288         layout.menu("VIEW3D_MT_snap")
3289
3290         layout.separator()
3291
3292         layout.menu("VIEW3D_MT_object_animation")
3293
3294         layout.separator()
3295
3296         layout.menu("VIEW3D_MT_pose_slide")
3297         layout.menu("VIEW3D_MT_pose_propagate")
3298
3299         layout.separator()
3300
3301         layout.operator("pose.copy", icon='COPYDOWN')
3302         layout.operator("pose.paste", icon='PASTEDOWN').flipped = False
3303         layout.operator("pose.paste", icon='PASTEFLIPDOWN', text="Paste Pose Flipped").flipped = True
3304
3305         layout.separator()
3306
3307         layout.menu("VIEW3D_MT_pose_library")
3308         layout.menu("VIEW3D_MT_pose_motion")
3309         layout.menu("VIEW3D_MT_pose_group")
3310
3311         layout.separator()
3312
3313         layout.menu("VIEW3D_MT_object_parent")
3314         layout.menu("VIEW3D_MT_pose_ik")
3315         layout.menu("VIEW3D_MT_pose_constraints")
3316
3317         layout.separator()
3318
3319         layout.menu("VIEW3D_MT_pose_names")
3320         layout.operator("pose.quaternions_flip")
3321
3322         layout.separator()
3323
3324         layout.operator_context = 'INVOKE_AREA'
3325         layout.operator("armature.armature_layers", text="Change Armature Layers...")
3326         layout.operator("pose.bone_layers", text="Change Bone Layers...")
3327
3328         layout.separator()
3329
3330         layout.menu("VIEW3D_MT_pose_showhide")
3331         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
3332
3333
3334 class VIEW3D_MT_pose_transform(Menu):
3335     bl_label = "Clear Transform"
3336
3337     def draw(self, _context):
3338         layout = self.layout
3339
3340         layout.operator("pose.transforms_clear", text="All")
3341
3342         layout.separator()
3343
3344         layout.operator("pose.loc_clear", text="Location")
3345         layout.operator("pose.rot_clear", text="Rotation")
3346         layout.operator("pose.scale_clear", text="Scale")
3347
3348         layout.separator()
3349
3350         layout.operator("pose.user_transforms_clear", text="Reset Unkeyed")
3351
3352
3353 class VIEW3D_MT_pose_slide(Menu):
3354     bl_label = "In-Betweens"
3355
3356     def draw(self, _context):
3357         layout = self.layout
3358
3359         layout.operator("pose.push_rest")
3360         layout.operator("pose.relax_rest")
3361         layout.operator("pose.push")
3362         layout.operator("pose.relax")
3363         layout.operator("pose.breakdown")
3364
3365
3366 class VIEW3D_MT_pose_propagate(Menu):
3367     bl_label = "Propagate"
3368
3369     def draw(self, _context):
3370         layout = self.layout
3371
3372         layout.operator("pose.propagate").mode = 'WHILE_HELD'
3373
3374         layout.separator()
3375
3376         layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY'
3377         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
3378
3379         layout.separator()
3380
3381         layout.operator("pose.propagate", text="On Selected Keyframes").mode = 'SELECTED_KEYS'
3382
3383         layout.separator()
3384
3385         layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS'
3386
3387
3388 class VIEW3D_MT_pose_library(Menu):
3389     bl_label = "Pose Library"
3390
3391     def draw(self, _context):
3392         layout = self.layout
3393
3394         layout.operator("poselib.browse_interactive", text="Browse Poses...")
3395
3396         layout.separator()
3397
3398         layout.operator("poselib.pose_add", text="Add Pose...")
3399         layout.operator("poselib.pose_rename", text="Rename Pose...")
3400         layout.operator("poselib.pose_remove", text="Remove Pose...")
3401
3402
3403 class VIEW3D_MT_pose_motion(Menu):
3404     bl_label = "Motion Paths"
3405
3406     def draw(self, _context):
3407         layout = self.layout
3408
3409         layout.operator("pose.paths_calculate", text="Calculate")
3410         layout.operator("pose.paths_clear", text="Clear")
3411
3412
3413 class VIEW3D_MT_pose_group(Menu):
3414     bl_label = "Bone Groups"
3415
3416     def draw(self, context):
3417         layout = self.layout
3418
3419         pose = context.active_object.pose
3420
3421         layout.operator_context = 'EXEC_AREA'
3422         layout.operator("pose.group_assign", text="Assign to New Group").type = 0
3423
3424         if pose.bone_groups:
3425             active_group = pose.bone_groups.active_index + 1
3426             layout.operator("pose.group_assign", text="Assign to Group").type = active_group
3427
3428             layout.separator()
3429
3430             # layout.operator_context = 'INVOKE_AREA'
3431             layout.operator("pose.group_unassign")
3432             layout.operator("pose.group_remove")
3433
3434
3435 class VIEW3D_MT_pose_ik(Menu):
3436     bl_label = "Inverse Kinematics"
3437
3438     def draw(self, _context):
3439         layout = self.layout
3440
3441         layout.operator("pose.ik_add")
3442         layout.operator("pose.ik_clear")
3443
3444
3445 class VIEW3D_MT_pose_constraints(Menu):
3446     bl_label = "Constraints"
3447
3448     def draw(self, _context):
3449         layout = self.layout
3450
3451         layout.operator("pose.constraint_add_with_targets", text="Add (with Targets)...")
3452         layout.operator("pose.constraints_copy")
3453         layout.operator("pose.constraints_clear")
3454
3455
3456 class VIEW3D_MT_pose_names(Menu):
3457     bl_label = "Names"
3458
3459     def draw(self, _context):
3460         layout = self.layout
3461
3462         layout.operator_context = 'EXEC_REGION_WIN'
3463         layout.operator("pose.autoside_names", text="Auto-Name Left/Right").axis = 'XAXIS'
3464         layout.operator("pose.autoside_names", text="Auto-Name Front/Back").axis = 'YAXIS'
3465         layout.operator("pose.autoside_names", text="Auto-Name Top/Bottom").axis = 'ZAXIS'
3466         layout.operator("pose.flip_names")
3467
3468
3469 class VIEW3D_MT_pose_showhide(ShowHideMenu, Menu):
3470     _operator_name = "pose"
3471
3472
3473 class VIEW3D_MT_pose_apply(Menu):
3474     bl_label = "Apply"
3475
3476     def draw(self, _context):
3477         layout = self.layout
3478
3479         layout.operator("pose.armature_apply").selected = False
3480         layout.operator("pose.armature_apply", text="Apply Selected as Rest Pose").selected = True
3481         layout.operator("pose.visual_transform_apply")
3482
3483         layout.separator()
3484
3485         props = layout.operator("object.assign_property_defaults")
3486         props.process_bones = True
3487
3488
3489 class VIEW3D_MT_pose_context_menu(Menu):
3490     bl_label = "Pose Context Menu"
3491
3492     def draw(self, _context):
3493         layout = self.layout
3494
3495         layout.operator_context = 'INVOKE_REGION_WIN'
3496
3497         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
3498
3499         layout.separator()
3500
3501         layout.operator("pose.copy", icon='COPYDOWN')
3502         layout.operator("pose.paste", icon='PASTEDOWN').flipped = False
3503         layout.operator("pose.paste", icon='PASTEFLIPDOWN', text="Paste X-Flipped Pose").flipped = True
3504
3505         layout.separator()
3506
3507         props = layout.operator("wm.call_panel", text="Rename Active Bone...")
3508         props.name = "TOPBAR_PT_name"
3509         props.keep_open = False
3510
3511         layout.separator()
3512
3513         layout.operator("pose.push")
3514         layout.operator("pose.relax")
3515         layout.operator("pose.breakdown")
3516
3517         layout.separator()
3518
3519         layout.operator("pose.paths_calculate", text="Calculate Motion Paths")
3520         layout.operator("pose.paths_clear", text="Clear Motion Paths")
3521
3522         layout.separator()
3523
3524         layout.operator("pose.hide").unselected = False
3525         layout.operator("pose.reveal")
3526
3527         layout.separator()
3528
3529         layout.operator("pose.user_transforms_clear")
3530
3531
3532 class BoneOptions:
3533     def draw(self, context):
3534         layout = self.layout
3535
3536         options = [
3537             "show_wire",
3538             "use_deform",
3539             "use_envelope_multiply",
3540             "use_inherit_rotation",
3541         ]
3542
3543         if context.mode == 'EDIT_ARMATURE':
3544             bone_props = bpy.types.EditBone.bl_rna.properties
3545             data_path_iter = "selected_bones"
3546             opt_suffix = ""
3547             options.append("lock")
3548         else:  # pose-mode
3549             bone_props = bpy.types.Bone.bl_rna.properties
3550             data_path_iter = "selected_pose_bones"
3551             opt_suffix = "bone."
3552
3553         for opt in options:
3554             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name,
3555                                     text_ctxt=i18n_contexts.default)
3556             props.data_path_iter = data_path_iter
3557             props.data_path_item = opt_suffix + opt
3558             props.type = self.type
3559
3560
3561 class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions):
3562     bl_label = "Toggle Bone Options"
3563     type = 'TOGGLE'
3564
3565
3566 class VIEW3D_MT_bone_options_enable(Menu, BoneOptions):
3567     bl_label = "Enable Bone Options"
3568     type = 'ENABLE'
3569
3570
3571 class VIEW3D_MT_bone_options_disable(Menu, BoneOptions):
3572     bl_label = "Disable Bone Options"
3573     type = 'DISABLE'
3574
3575
3576 # ********** Edit Menus, suffix from ob.type **********
3577
3578
3579 class VIEW3D_MT_edit_mesh(Menu):
3580     bl_label = "Mesh"
3581
3582     def draw(self, _context):
3583         layout = self.layout
3584
3585         with_bullet = bpy.app.build_options.bullet
3586
3587         layout.menu("VIEW3D_MT_transform")
3588         layout.menu("VIEW3D_MT_mirror")
3589         layout.menu("VIEW3D_MT_snap")
3590
3591         layout.separator()
3592
3593         layout.operator("mesh.duplicate_move", text="Duplicate")
3594         layout.menu("VIEW3D_MT_edit_mesh_extrude")
3595
3596         layout.separator()
3597
3598         layout.menu("VIEW3D_MT_edit_mesh_merge", text="Merge")
3599         layout.menu("VIEW3D_MT_edit_mesh_split", text="Split")
3600         layout.operator_menu_enum("mesh.separate", "type")
3601
3602         layout.separator()
3603
3604         layout.operator("mesh.bisect")
3605         layout.operator("mesh.knife_project")
3606
3607         if with_bullet:
3608             layout.operator("mesh.convex_hull")
3609
3610         layout.separator()
3611
3612         layout.operator("mesh.symmetrize")
3613         layout.operator("mesh.symmetry_snap")
3614
3615         layout.separator()
3616
3617         layout.menu("VIEW3D_MT_edit_mesh_normals")
3618         layout.menu("VIEW3D_MT_edit_mesh_shading")
3619         layout.menu("VIEW3D_MT_edit_mesh_weights")
3620         layout.operator_menu_enum("mesh.sort_elements", "type", text="Sort Elements...")
3621
3622         layout.separator()
3623
3624         layout.menu("VIEW3D_MT_edit_mesh_showhide")
3625         layout.menu("VIEW3D_MT_edit_mesh_clean")
3626
3627         layout.separator()
3628
3629         layout.menu("VIEW3D_MT_edit_mesh_delete")
3630
3631
3632 class VIEW3D_MT_edit_mesh_context_menu(Menu):
3633     bl_label = ""
3634
3635     def draw(self, context):
3636
3637         def count_selected_items_for_objects_in_mode():
3638             selected_verts_len = 0
3639             selected_edges_len = 0
3640             selected_faces_len = 0
3641             for ob in context.objects_in_mode_unique_data:
3642                 v, e, f = ob.data.count_selected_items()
3643                 selected_verts_len += v
3644                 selected_edges_len += e
3645                 selected_faces_len += f
3646             return (selected_verts_len, selected_edges_len, selected_faces_len)
3647
3648         is_vert_mode, is_edge_mode, is_face_mode = context.tool_settings.mesh_select_mode
3649         selected_verts_len, selected_edges_len, selected_faces_len = count_selected_items_for_objects_in_mode()
3650
3651         del count_selected_items_for_objects_in_mode
3652
3653         layout = self.layout
3654
3655         layout.operator_context = 'INVOKE_REGION_WIN'
3656
3657         # If nothing is selected
3658         # (disabled for now until it can be made more useful).
3659         '''
3660         # If nothing is selected
3661         if not (selected_verts_len or selected_edges_len or selected_faces_len):
3662             layout.menu("VIEW3D_MT_mesh_add", text="Add", text_ctxt=i18n_contexts.operator_default)
3663
3664             return
3665         '''
3666
3667         # Else something is selected
3668
3669         row = layout.row()
3670
3671         if is_vert_mode:
3672             col = row.column(align=True)
3673
3674             col.label(text="Vertex Context Menu", icon='VERTEXSEL')
3675             col.separator()
3676
3677             # Additive Operators
3678             col.operator("mesh.subdivide", text="Subdivide")
3679
3680             col.separator()
3681
3682             col.operator("mesh.extrude_vertices_move", text="Extrude Vertices")
3683             col.operator("mesh.bevel", text="Bevel Vertices").affect = 'VERTICES'
3684
3685             if selected_verts_len > 1:
3686                 col.separator()
3687                 col.operator("mesh.edge_face_add", text="New Edge/Face from Vertices")
3688                 col.operator("mesh.vert_connect_path", text="Connect Vertex Path")
3689                 col.operator("mesh.vert_connect", text="Connect Vertex Pairs")
3690
3691             col.separator()
3692
3693             # Deform Operators
3694             col.operator("transform.push_pull", text="Push/Pull")
3695             col.operator("transform.shrink_fatten", text="Shrink/Fatten")
3696             col.operator("transform.shear", text="Shear")
3697             col.operator("transform.vert_slide", text="Slide Vertices")
3698             col.operator_context = 'EXEC_REGION_WIN'
3699             col.operator("transform.vertex_random", text="Randomize Vertices").offset = 0.1
3700             col.operator("mesh.vertices_smooth", text="Smooth Vertices").factor = 0.5
3701             col.operator_context = 'INVOKE_REGION_WIN'
3702             col.operator("mesh.vertices_smooth_laplacian", text="Smooth Laplacian")
3703
3704             col.separator()
3705
3706             col.menu("VIEW3D_MT_mirror", text="Mirror Vertices")
3707             col.menu("VIEW3D_MT_snap", text="Snap Vertices")
3708
3709             col.separator()
3710
3711             # Removal Operators
3712             if selected_verts_len > 1:
3713                 col.menu("VIEW3D_MT_edit_mesh_merge", text="Merge Vertices")
3714             col.operator("mesh.split")
3715             col.operator_menu_enum("mesh.separate", "type")
3716             col.operator("mesh.dissolve_verts")
3717             col.operator("mesh.delete", text="Delete Vertices").type = 'VERT'
3718
3719         if is_edge_mode:
3720             render = context.scene.render
3721
3722             col = row.column(align=True)
3723             col.label(text="Edge Context Menu", icon='EDGESEL')
3724             col.separator()
3725
3726             # Additive Operators
3727             col.operator("mesh.subdivide", text="Subdivide")
3728
3729             col.separator()
3730
3731             col.operator("mesh.extrude_edges_move", text="Extrude Edges")
3732             col.operator("mesh.bevel", text="Bevel Edges").affect = 'EDGES'
3733             if selected_edges_len >= 2:
3734                 col.operator("mesh.bridge_edge_loops")
3735             if selected_edges_len >= 1:
3736                 col.operator("mesh.edge_face_add", text="New Face from Edges")
3737             if selected_edges_len >= 2:
3738                 col.operator("mesh.fill")
3739
3740             col.separator()
3741
3742             props = col.operator("mesh.loopcut_slide")
3743             props.TRANSFORM_OT_edge_slide.release_confirm = False
3744             col.operator("mesh.offset_edge_loops_slide")
3745
3746             col.separator()
3747
3748             col.operator("mesh.knife_tool")
3749             col.operator("mesh.bisect")
3750
3751             col.separator()
3752
3753             # Deform Operators
3754             col.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
3755             col.operator("transform.edge_slide")
3756             col.operator("mesh.edge_split")
3757
3758             col.separator()
3759
3760             # Edge Flags
3761             col.operator("transform.edge_crease")
3762             col.operator("transform.edge_bevelweight")
3763
3764             col.separator()
3765
3766             col.operator("mesh.mark_seam").clear = False
3767             col.operator("mesh.mark_seam", text="Clear Seam").clear = True
3768
3769             col.separator()
3770
3771             col.operator("mesh.mark_sharp")
3772             col.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
3773
3774             if render.use_freestyle:
3775                 col.separator()
3776
3777                 col.operator("mesh.mark_freestyle_edge").clear = False
3778                 col.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
3779
3780             col.separator()
3781
3782             # Removal Operators
3783             col.operator("mesh.unsubdivide")
3784             col.operator("mesh.split")
3785             col.operator_menu_enum("mesh.separate", "type")
3786             col.operator("mesh.dissolve_edges")
3787             col.operator("mesh.delete", text="Delete Edges").type = 'EDGE'
3788
3789         if is_face_mode:
3790             col = row.column(align=True)
3791
3792             col.label(text="Face Context Menu", icon='FACESEL')
3793             col.separator()
3794
3795             # Additive Operators
3796             col.operator("mesh.subdivide", text="Subdivide")
3797
3798             col.separator()
3799
3800             col.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces")
3801             col.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals")
3802             col.operator("mesh.extrude_faces_move", text="Extrude Individual Faces")
3803
3804             col.operator("mesh.inset")
3805             col.operator("mesh.poke")
3806
3807             if selected_faces_len >= 2:
3808                 col.operator("mesh.bridge_edge_loops", text="Bridge Faces")
3809
3810             col.separator()
3811
3812             # Modify Operators
3813             col.menu("VIEW3D_MT_uv_map", text="UV Unwrap Faces")
3814
3815             col.separator()
3816
3817             props = col.operator("mesh.quads_convert_to_tris")
3818             props.quad_method = props.ngon_method = 'BEAUTY'
3819             col.operator("mesh.tris_convert_to_quads")
3820
3821             col.separator()
3822
3823             col.operator("mesh.faces_shade_smooth")
3824             col.operator("mesh.faces_shade_flat")
3825
3826             col.separator()
3827
3828             # Removal Operators
3829             col.operator("mesh.unsubdivide")
3830             col.operator("mesh.split")
3831             col.operator_menu_enum("mesh.separate", "type")
3832             col.operator("mesh.dissolve_faces")
3833             col.operator("mesh.delete", text="Delete Faces").type = 'FACE'
3834
3835
3836 class VIEW3D_MT_edit_mesh_select_mode(Menu):
3837     bl_label = "Mesh Select Mode"
3838
3839     def draw(self, _context):
3840         layout = self.layout
3841
3842         layout.operator_context = 'INVOKE_REGION_WIN'
3843         layout.operator("mesh.select_mode", text="Vertex", icon='VERTEXSEL').type = 'VERT'
3844         layout.operator("mesh.select_mode", text="Edge", icon='EDGESEL').type = 'EDGE'
3845         layout.operator("mesh.select_mode", text="Face", icon='FACESEL').type = 'FACE'
3846
3847
3848 class VIEW3D_MT_edit_mesh_extrude(Menu):
3849     bl_label = "Extrude"
3850
3851     _extrude_funcs = {
3852         'VERT': lambda layout:
3853         layout.operator("mesh.extrude_vertices_move", text="Extrude Vertices"),
3854         'EDGE': lambda layout:
3855         layout.operator("mesh.extrude_edges_move", text="Extrude Edges"),
3856         'REGION': lambda layout:
3857         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces"),
3858         'REGION_VERT_NORMAL': lambda layout:
3859         layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals"),
3860         'FACE': lambda layout:
3861         layout.operator("mesh.extrude_faces_move", text="Extrude Individual Faces"),
3862         'MANIFOLD': lambda layout:
3863         layout.operator("view3d.edit_mesh_extrude_manifold_normal", text="Extrude Manifold"),
3864     }
3865
3866     @staticmethod
3867     def extrude_options(context):
3868         tool_settings = context.tool_settings
3869         select_mode = tool_settings.mesh_select_mode
3870         mesh = context.object.data
3871
3872         menu = []
3873         if mesh.total_face_sel:
3874             menu += ['REGION', 'REGION_VERT_NORMAL', 'FACE', 'MANIFOLD']
3875         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
3876             menu += ['EDGE']
3877         if mesh.total_vert_sel and select_mode[0]:
3878             menu += ['VERT']
3879
3880         # should never get here
3881         return menu
3882
3883     def draw(self, context):
3884         from math import pi
3885
3886         layout = self.layout
3887         layout.operator_context = 'INVOKE_REGION_WIN'
3888
3889         for menu_id in self.extrude_options(context):
3890             self._extrude_funcs[menu_id](layout)
3891
3892         layout.separator()
3893
3894         layout.operator("mesh.extrude_repeat")
3895         layout.operator("mesh.spin").angle = pi * 2
3896
3897
3898 class VIEW3D_MT_edit_mesh_vertices(Menu):
3899     bl_label = "Vertex"
3900
3901     def draw(self, _context):
3902         layout = self.layout
3903         layout.operator_context = 'INVOKE_REGION_WIN'
3904
3905         layout.operator("mesh.extrude_vertices_move", text="Extrude Vertices")
3906         layout.operator("mesh.bevel", text="Bevel Vertices").affect = 'VERTICES'
3907
3908         layout.separator()
3909
3910         layout.operator("mesh.edge_face_add", text="New Edge/Face from Vertices")
3911         layout.operator("mesh.vert_connect_path", text="Connect Vertex Path")
3912         layout.operator("mesh.vert_connect", text="Connect Vertex Pairs")
3913
3914         layout.separator()
3915
3916         props = layout.operator("mesh.rip_move", text="Rip Vertices")
3917         props.MESH_OT_rip.use_fill = False
3918         props = layout.operator("mesh.rip_move", text="Rip Vertices and Fill")
3919         props.MESH_OT_rip.use_fill = True
3920         layout.operator("mesh.rip_edge_move", text="Rip Vertices and Extend")
3921
3922         layout.separator()
3923
3924         layout.operator("transform.vert_slide", text="Slide Vertices")
3925         layout.operator_context = 'EXEC_REGION_WIN'
3926         layout.operator("mesh.vertices_smooth", text="Smooth Vertices").factor = 0.5
3927         layout.operator("mesh.vertices_smooth_laplacian", text="Smooth Vertices (Laplacian)")
3928         layout.operator_context = 'INVOKE_REGION_WIN'
3929
3930         layout.separator()
3931
3932         layout.operator("mesh.blend_from_shape")
3933         layout.operator("mesh.shape_propagate_to_all", text="Propagate to Shapes")
3934
3935         layout.separator()
3936
3937         layout.menu("VIEW3D_MT_vertex_group")
3938         layout.menu("VIEW3D_MT_hook")
3939
3940         layout.separator()
3941
3942         layout.operator("object.vertex_parent_set")
3943
3944
3945 class VIEW3D_MT_edit_mesh_edges_data(Menu):
3946     bl_label = "Edge Data"
3947
3948     def draw(self, context):
3949         layout = self.layout
3950
3951         render = context.scene.render
3952
3953         layout.operator_context = 'INVOKE_REGION_WIN'
3954
3955         layout.operator("transform.edge_crease")
3956         layout.operator("transform.edge_bevelweight")
3957
3958         layout.separator()
3959
3960         layout.operator("mesh.mark_seam").clear = False
3961         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
3962
3963         layout.separator()
3964
3965         layout.operator("mesh.mark_sharp")
3966         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
3967
3968         layout.operator("mesh.mark_sharp", text="Mark Sharp from Vertices").use_verts = True
3969         props = layout.operator("mesh.mark_sharp", text="Clear Sharp from Vertices")
3970         props.use_verts = True
3971         props.clear = True
3972
3973         if render.use_freestyle:
3974             layout.separator()
3975
3976             layout.operator("mesh.mark_freestyle_edge").clear = False
3977             layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
3978
3979
3980 class VIEW3D_MT_edit_mesh_edges(Menu):
3981     bl_label = "Edge"
3982
3983     def draw(self, _context):
3984         layout = self.layout
3985
3986         with_freestyle = bpy.app.build_options.freestyle
3987