Export_3ds: Added distance cue chunk export
[blender-addons.git] / space_view3d_spacebar_menu / object_menus.py
blobc633452d9cf7405d5a736f5cf04e83d6daebebaa
1 # SPDX-FileCopyrightText: 2019-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 import bpy
6 from bpy.types import (
7 Operator,
8 Menu,
10 from bpy.props import (
11 BoolProperty,
12 StringProperty,
15 from bl_ui.properties_paint_common import UnifiedPaintPanel
17 from . edit_mesh import *
18 from . view_menus import *
19 # Object Menus #
21 # ********** Object Menu **********
22 class VIEW3D_MT_Object(Menu):
23 bl_context = "objectmode"
24 bl_label = "Object"
26 def draw(self, context):
27 layout = self.layout
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")
36 layout.separator()
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")
41 else:
42 layout.operator_menu_enum("object.convert", "target")
44 layout.menu("VIEW3D_MT_object_showhide")
45 layout.separator()
47 layout.menu("VIEW3D_MT_object_constraints")
48 layout.menu("VIEW3D_MT_object_track")
49 layout.separator()
51 layout.menu("VIEW3D_MT_object_rigid_body")
52 layout.menu("VIEW3D_MT_object_quick_effects")
53 layout.separator()
55 layout.operator("view3d.copybuffer", text="Copy Objects", icon='COPYDOWN')
56 layout.operator("view3d.pastebuffer", text="Paste Objects", icon='PASTEDOWN')
57 layout.separator()
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):
70 layout = self.layout
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):
95 layout = self.layout
96 layout.operator("object.editmode_toggle", text="Edit/Object Toggle",
97 icon='OBJECT_DATA')
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"
106 @classmethod
107 def poll(cls, context):
108 return (context.gpencil_data is not None)
110 def execute(self, context):
111 try:
112 bpy.ops.gpencil.editmode_toggle()
113 except:
114 self.report({'WARNING'}, "It is not possible to enter into the interactive mode")
115 return {'FINISHED'}
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
124 layout = self.layout
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"
138 @classmethod
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")
145 return {'FINISHED'}
148 # ********** Object Camera Options **********
149 class VIEW3D_MT_Camera_Options(Menu):
150 bl_label = "Camera"
152 def draw(self, context):
153 layout = self.layout
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):
167 layout = self.layout
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):
177 layout = self.layout
179 layout.operator("ed.undo")
180 layout.operator("ed.redo")
181 layout.separator()
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",
194 default="OBJECT"
197 def execute(self, context):
198 if (context.active_object):
199 try:
200 bpy.ops.object.mode_set(mode=self.mode)
201 except TypeError:
202 msg = context.active_object.name + ": It is not possible to enter into the interactive mode"
203 self.report(type={"WARNING"}, message=msg)
204 else:
205 self.report(type={"WARNING"}, message="There is no active object")
206 return {'FINISHED'}
209 # currently unused
210 class VIEW3D_MT_Edit_Gpencil(Menu):
211 bl_label = "GPencil"
213 def draw(self, context):
214 toolsettings = context.tool_settings
215 layout = self.layout
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")
219 layout.separator()
220 layout.menu("VIEW3D_MT_edit_gpencil_transform")
221 layout.operator("transform.mirror", text="Mirror")
222 layout.menu("GPENCIL_MT_snap")
223 layout.separator()
224 layout.menu("VIEW3D_MT_object_animation") # NOTE: provides keyingset access...
225 layout.separator()
226 layout.menu("VIEW3D_MT_edit_gpencil_delete")
227 layout.operator("gpencil.duplicate_move", text="Duplicate")
228 layout.separator()
229 layout.menu("VIEW3D_MT_select_gpencil")
230 layout.separator()
231 layout.operator("gpencil.copy", text="Copy")
232 layout.operator("gpencil.paste", text="Paste")
233 layout.separator()
234 layout.prop_menu_enum(toolsettings, "proportional_edit")
235 layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
236 layout.separator()
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
240 layout.separator()
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...")
245 # List The Classes #
247 classes = (
248 VIEW3D_MT_Object,
249 VIEW3D_MT_UndoS,
250 VIEW3D_MT_Camera_Options,
251 VIEW3D_MT_InteractiveMode,
252 VIEW3D_MT_InteractiveModeOther,
253 VIEW3D_OT_SetObjectMode,
254 VIEW3D_MT_Duplicate,
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 #
263 def register():
264 for cls in classes:
265 bpy.utils.register_class(cls)
268 # Unregister Classes & Hotkeys #
269 def unregister():
271 for cls in reversed(classes):
272 bpy.utils.unregister_class(cls)
275 if __name__ == "__main__":
276 register()