1 # SPDX-FileCopyrightText: 2019-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 from bpy
.types
import (
10 from bpy
.props
import (
15 from bl_ui
.properties_paint_common
import UnifiedPaintPanel
17 from . edit_mesh
import *
18 from . view_menus
import *
21 # ********** Object Menu **********
22 class VIEW3D_MT_Object(Menu
):
23 bl_context
= "objectmode"
26 def draw(self
, context
):
28 view
= context
.space_data
30 layout
.menu("VIEW3D_MT_mirror")
31 layout
.menu("VIEW3D_MT_object_parent")
32 layout
.menu("VIEW3D_MT_Duplicate")
33 layout
.operator("object.join")
34 layout
.menu("VIEW3D_MT_make_links", text
="Make Links")
35 layout
.menu("VIEW3D_MT_object_relations")
38 ob
= context
.active_object
39 if ob
and ob
.type == 'GPENCIL' and context
.gpencil_data
:
40 layout
.operator_menu_enum("gpencil.convert", "type", text
="Convert to")
42 layout
.operator_menu_enum("object.convert", "target")
44 layout
.menu("VIEW3D_MT_object_showhide")
47 layout
.menu("VIEW3D_MT_object_constraints")
48 layout
.menu("VIEW3D_MT_object_track")
51 layout
.menu("VIEW3D_MT_object_rigid_body")
52 layout
.menu("VIEW3D_MT_object_quick_effects")
55 layout
.operator("view3d.copybuffer", text
="Copy Objects", icon
='COPYDOWN')
56 layout
.operator("view3d.pastebuffer", text
="Paste Objects", icon
='PASTEDOWN')
59 layout
.operator_context
= 'EXEC_DEFAULT'
60 layout
.operator("object.delete", text
="Delete").use_global
= False
61 layout
.operator("object.delete", text
="Delete Global").use_global
= True
64 # ********** Object Interactive Mode **********
65 class VIEW3D_MT_InteractiveMode(Menu
):
66 bl_label
= "Interactive Mode"
67 bl_description
= "Menu of objects' interactive modes (Window Types)"
69 def draw(self
, context
):
71 obj
= context
.active_object
72 psys
= hasattr(obj
, "particle_systems")
73 psys_items
= len(obj
.particle_systems
.items()) > 0 if psys
else False
75 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Object", icon
="OBJECT_DATAMODE").mode
= "OBJECT"
76 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Edit", icon
="EDITMODE_HLT").mode
= "EDIT"
77 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Sculpt", icon
="SCULPTMODE_HLT").mode
= "SCULPT"
78 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Vertex Paint", icon
="VPAINT_HLT").mode
= "VERTEX_PAINT"
79 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Weight Paint", icon
="WPAINT_HLT").mode
= "WEIGHT_PAINT"
80 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Texture Paint", icon
="TPAINT_HLT").mode
= "TEXTURE_PAINT"
81 if obj
and psys_items
:
82 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Particle Edit",
83 icon
="PARTICLEMODE").mode
= "PARTICLE_EDIT"
84 # if context.gpencil_data:
85 # layout.operator("view3d.interactive_mode_grease_pencil", icon="GREASEPENCIL")
88 # ********** Interactive Mode Other **********
89 class VIEW3D_MT_InteractiveModeOther(Menu
):
90 bl_idname
= "VIEW3D_MT_Object_Interactive_Other"
91 bl_label
= "Interactive Mode"
92 bl_description
= "Menu of objects interactive mode"
94 def draw(self
, context
):
96 layout
.operator("object.editmode_toggle", text
="Edit/Object Toggle",
100 # ********** Grease Pencil Interactive Mode **********
101 class VIEW3D_OT_Interactive_Mode_Grease_Pencil(Operator
):
102 bl_idname
= "view3d.interactive_mode_grease_pencil"
103 bl_label
= "Edit Strokes"
104 bl_description
= "Toggle Edit Strokes for Grease Pencil"
107 def poll(cls
, context
):
108 return (context
.gpencil_data
is not None)
110 def execute(self
, context
):
112 bpy
.ops
.gpencil
.editmode_toggle()
114 self
.report({'WARNING'}, "It is not possible to enter into the interactive mode")
117 class VIEW3D_MT_Interactive_Mode_GPencil(Menu
):
118 bl_idname
= "VIEW3D_MT_interactive_mode_gpencil"
119 bl_label
= "Interactive Mode"
120 bl_description
= "Menu of objects interactive mode"
122 def draw(self
, context
):
123 toolsettings
= context
.tool_settings
125 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Object", icon
="OBJECT_DATAMODE").mode
= "OBJECT"
126 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Edit", icon
="EDITMODE_HLT").mode
= "EDIT_GPENCIL"
127 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Sculpt", icon
="SCULPTMODE_HLT").mode
= "SCULPT_GPENCIL"
128 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Draw", icon
="GREASEPENCIL").mode
= "PAINT_GPENCIL"
129 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Weight Paint", icon
="WPAINT_HLT").mode
= "WEIGHT_GPENCIL"
132 # ********** Text Interactive Mode **********
133 class VIEW3D_OT_Interactive_Mode_Text(Operator
):
134 bl_idname
= "view3d.interactive_mode_text"
135 bl_label
= "Enter Edit Mode"
136 bl_description
= "Toggle object's editmode"
139 def poll(cls
, context
):
140 return (context
.active_object
is not None)
142 def execute(self
, context
):
143 bpy
.ops
.object.editmode_toggle()
144 self
.report({'INFO'}, "Spacebar shortcut won't work in the Text Edit mode")
148 # ********** Object Camera Options **********
149 class VIEW3D_MT_Camera_Options(Menu
):
152 def draw(self
, context
):
154 layout
.operator_context
= 'EXEC_REGION_WIN'
155 layout
.operator("object.select_camera", text
="Select Camera")
156 layout
.operator("object.camera_add", text
="Add Camera")
157 layout
.operator("view3d.view_camera", text
="View Camera")
158 layout
.operator("view3d.camera_to_view", text
="Camera to View")
159 layout
.operator("view3d.camera_to_view_selected", text
="Camera to Selected")
160 layout
.operator("view3d.object_as_camera", text
="Object As Camera")
163 class VIEW3D_MT_Duplicate(Menu
):
164 bl_label
= "Duplicate"
166 def draw(self
, context
):
169 layout
.operator("object.duplicate_move")
170 layout
.operator("object.duplicate_move_linked")
173 class VIEW3D_MT_UndoS(Menu
):
174 bl_label
= "Undo/Redo"
176 def draw(self
, context
):
179 layout
.operator("ed.undo")
180 layout
.operator("ed.redo")
182 layout
.operator("ed.undo_history")
185 # Set Mode Operator #
186 class VIEW3D_OT_SetObjectMode(Operator
):
187 bl_idname
= "object.set_object_mode"
188 bl_label
= "Set the object interactive mode"
189 bl_description
= "I set the interactive mode of object"
190 bl_options
= {'REGISTER'}
192 mode
: StringProperty(
193 name
="Interactive mode",
197 def execute(self
, context
):
198 if (context
.active_object
):
200 bpy
.ops
.object.mode_set(mode
=self
.mode
)
202 msg
= context
.active_object
.name
+ ": It is not possible to enter into the interactive mode"
203 self
.report(type={"WARNING"}, message
=msg
)
205 self
.report(type={"WARNING"}, message
="There is no active object")
210 class VIEW3D_MT_Edit_Gpencil(Menu
):
213 def draw(self
, context
):
214 toolsettings
= context
.tool_settings
217 layout
.operator("gpencil.brush_paint", text
="Sculpt Strokes").wait_for_input
= True
218 layout
.prop_menu_enum(toolsettings
.gpencil_sculpt
, "tool", text
="Sculpt Brush")
220 layout
.menu("VIEW3D_MT_edit_gpencil_transform")
221 layout
.operator("transform.mirror", text
="Mirror")
222 layout
.menu("GPENCIL_MT_snap")
224 layout
.menu("VIEW3D_MT_object_animation") # NOTE: provides keyingset access...
226 layout
.menu("VIEW3D_MT_edit_gpencil_delete")
227 layout
.operator("gpencil.duplicate_move", text
="Duplicate")
229 layout
.menu("VIEW3D_MT_select_gpencil")
231 layout
.operator("gpencil.copy", text
="Copy")
232 layout
.operator("gpencil.paste", text
="Paste")
234 layout
.prop_menu_enum(toolsettings
, "proportional_edit")
235 layout
.prop_menu_enum(toolsettings
, "proportional_edit_falloff")
237 layout
.operator("gpencil.reveal")
238 layout
.operator("gpencil.hide", text
="Show Active Layer Only").unselected
= True
239 layout
.operator("gpencil.hide", text
="Hide Active Layer").unselected
= False
241 layout
.operator_menu_enum("gpencil.move_to_layer", "layer", text
="Move to Layer")
242 layout
.operator_menu_enum("gpencil.convert", "type", text
="Convert to Geometry...")
250 VIEW3D_MT_Camera_Options
,
251 VIEW3D_MT_InteractiveMode
,
252 VIEW3D_MT_InteractiveModeOther
,
253 VIEW3D_OT_SetObjectMode
,
255 VIEW3D_OT_Interactive_Mode_Text
,
256 VIEW3D_OT_Interactive_Mode_Grease_Pencil
,
257 VIEW3D_MT_Interactive_Mode_GPencil
,
258 VIEW3D_MT_Edit_Gpencil
,
262 # Register Classes & Hotkeys #
265 bpy
.utils
.register_class(cls
)
268 # Unregister Classes & Hotkeys #
271 for cls
in reversed(classes
):
272 bpy
.utils
.unregister_class(cls
)
275 if __name__
== "__main__":