1 # ##### BEGIN GPL LICENSE BLOCK #####
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.
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.
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.
17 # ##### END GPL LICENSE BLOCK #####
18 # Contributed to by: meta-androcto, JayDez, sim88, sam, lijenstina, mkb, wisaac, CoDEmanX #
22 from bpy
.types
import (
26 from bpy
.props
import (
31 from bl_ui
.properties_paint_common
import UnifiedPaintPanel
33 from . edit_mesh
import *
34 from . view_menus
import *
37 # ********** Object Menu **********
38 class VIEW3D_MT_Object(Menu
):
39 bl_context
= "objectmode"
42 def draw(self
, context
):
44 view
= context
.space_data
46 layout
.menu("VIEW3D_MT_mirror")
47 layout
.menu("VIEW3D_MT_object_parent")
48 layout
.menu("VIEW3D_MT_Duplicate")
49 layout
.operator("object.join")
50 layout
.menu("VIEW3D_MT_make_links", text
="Make Links")
51 layout
.menu("VIEW3D_MT_object_relations")
54 ob
= context
.active_object
55 if ob
and ob
.type == 'GPENCIL' and context
.gpencil_data
:
56 layout
.operator_menu_enum("gpencil.convert", "type", text
="Convert to")
58 layout
.operator_menu_enum("object.convert", "target")
60 layout
.menu("VIEW3D_MT_object_showhide")
63 layout
.menu("VIEW3D_MT_object_constraints")
64 layout
.menu("VIEW3D_MT_object_track")
67 layout
.menu("VIEW3D_MT_object_rigid_body")
68 layout
.menu("VIEW3D_MT_object_quick_effects")
71 layout
.operator("view3d.copybuffer", text
="Copy Objects", icon
='COPYDOWN')
72 layout
.operator("view3d.pastebuffer", text
="Paste Objects", icon
='PASTEDOWN')
75 layout
.operator_context
= 'EXEC_DEFAULT'
76 layout
.operator("object.delete", text
="Delete").use_global
= False
77 layout
.operator("object.delete", text
="Delete Global").use_global
= True
80 # ********** Object Interactive Mode **********
81 class VIEW3D_MT_InteractiveMode(Menu
):
82 bl_label
= "Interactive Mode"
83 bl_description
= "Menu of objects' interactive modes (Window Types)"
85 def draw(self
, context
):
87 obj
= context
.active_object
88 psys
= hasattr(obj
, "particle_systems")
89 psys_items
= len(obj
.particle_systems
.items()) > 0 if psys
else False
91 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Object", icon
="OBJECT_DATAMODE").mode
= "OBJECT"
92 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Edit", icon
="EDITMODE_HLT").mode
= "EDIT"
93 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Sculpt", icon
="SCULPTMODE_HLT").mode
= "SCULPT"
94 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Vertex Paint", icon
="VPAINT_HLT").mode
= "VERTEX_PAINT"
95 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Weight Paint", icon
="WPAINT_HLT").mode
= "WEIGHT_PAINT"
96 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Texture Paint", icon
="TPAINT_HLT").mode
= "TEXTURE_PAINT"
97 if obj
and psys_items
:
98 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Particle Edit",
99 icon
="PARTICLEMODE").mode
= "PARTICLE_EDIT"
100 # if context.gpencil_data:
101 # layout.operator("view3d.interactive_mode_grease_pencil", icon="GREASEPENCIL")
104 # ********** Interactive Mode Other **********
105 class VIEW3D_MT_InteractiveModeOther(Menu
):
106 bl_idname
= "VIEW3D_MT_Object_Interactive_Other"
107 bl_label
= "Interactive Mode"
108 bl_description
= "Menu of objects interactive mode"
110 def draw(self
, context
):
112 layout
.operator("object.editmode_toggle", text
="Edit/Object Toggle",
116 # ********** Grease Pencil Interactive Mode **********
117 class VIEW3D_OT_Interactive_Mode_Grease_Pencil(Operator
):
118 bl_idname
= "view3d.interactive_mode_grease_pencil"
119 bl_label
= "Edit Strokes"
120 bl_description
= "Toggle Edit Strokes for Grease Pencil"
123 def poll(cls
, context
):
124 return (context
.gpencil_data
is not None)
126 def execute(self
, context
):
128 bpy
.ops
.gpencil
.editmode_toggle()
130 self
.report({'WARNING'}, "It is not possible to enter into the interactive mode")
133 class VIEW3D_MT_Interactive_Mode_GPencil(Menu
):
134 bl_idname
= "VIEW3D_MT_interactive_mode_gpencil"
135 bl_label
= "Interactive Mode"
136 bl_description
= "Menu of objects interactive mode"
138 def draw(self
, context
):
139 toolsettings
= context
.tool_settings
141 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Object", icon
="OBJECT_DATAMODE").mode
= "OBJECT"
142 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Edit", icon
="EDITMODE_HLT").mode
= "EDIT_GPENCIL"
143 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Sculpt", icon
="SCULPTMODE_HLT").mode
= "SCULPT_GPENCIL"
144 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Draw", icon
="GREASEPENCIL").mode
= "PAINT_GPENCIL"
145 layout
.operator(VIEW3D_OT_SetObjectMode
.bl_idname
, text
="Weight Paint", icon
="WPAINT_HLT").mode
= "WEIGHT_GPENCIL"
148 # ********** Text Interactive Mode **********
149 class VIEW3D_OT_Interactive_Mode_Text(Operator
):
150 bl_idname
= "view3d.interactive_mode_text"
151 bl_label
= "Enter Edit Mode"
152 bl_description
= "Toggle object's editmode"
155 def poll(cls
, context
):
156 return (context
.active_object
is not None)
158 def execute(self
, context
):
159 bpy
.ops
.object.editmode_toggle()
160 self
.report({'INFO'}, "Spacebar shortcut won't work in the Text Edit mode")
164 # ********** Object Camera Options **********
165 class VIEW3D_MT_Camera_Options(Menu
):
168 def draw(self
, context
):
170 layout
.operator_context
= 'EXEC_REGION_WIN'
171 layout
.operator("object.select_camera", text
="Select Camera")
172 layout
.operator("object.camera_add", text
="Add Camera")
173 layout
.operator("view3d.view_camera", text
="View Camera")
174 layout
.operator("view3d.camera_to_view", text
="Camera to View")
175 layout
.operator("view3d.camera_to_view_selected", text
="Camera to Selected")
176 layout
.operator("view3d.object_as_camera", text
="Object As Camera")
179 class VIEW3D_MT_Duplicate(Menu
):
180 bl_label
= "Duplicate"
182 def draw(self
, context
):
185 layout
.operator("object.duplicate_move")
186 layout
.operator("object.duplicate_move_linked")
189 class VIEW3D_MT_UndoS(Menu
):
190 bl_label
= "Undo/Redo"
192 def draw(self
, context
):
195 layout
.operator("ed.undo")
196 layout
.operator("ed.redo")
198 layout
.operator("ed.undo_history")
201 # Set Mode Operator #
202 class VIEW3D_OT_SetObjectMode(Operator
):
203 bl_idname
= "object.set_object_mode"
204 bl_label
= "Set the object interactive mode"
205 bl_description
= "I set the interactive mode of object"
206 bl_options
= {'REGISTER'}
208 mode
: StringProperty(
209 name
="Interactive mode",
213 def execute(self
, context
):
214 if (context
.active_object
):
216 bpy
.ops
.object.mode_set(mode
=self
.mode
)
218 msg
= context
.active_object
.name
+ ": It is not possible to enter into the interactive mode"
219 self
.report(type={"WARNING"}, message
=msg
)
221 self
.report(type={"WARNING"}, message
="There is no active object")
226 class VIEW3D_MT_Edit_Gpencil(Menu
):
229 def draw(self
, context
):
230 toolsettings
= context
.tool_settings
233 layout
.operator("gpencil.brush_paint", text
="Sculpt Strokes").wait_for_input
= True
234 layout
.prop_menu_enum(toolsettings
.gpencil_sculpt
, "tool", text
="Sculpt Brush")
236 layout
.menu("VIEW3D_MT_edit_gpencil_transform")
237 layout
.operator("transform.mirror", text
="Mirror")
238 layout
.menu("GPENCIL_MT_snap")
240 layout
.menu("VIEW3D_MT_object_animation") # NOTE: provides keyingset access...
242 layout
.menu("VIEW3D_MT_edit_gpencil_delete")
243 layout
.operator("gpencil.duplicate_move", text
="Duplicate")
245 layout
.menu("VIEW3D_MT_select_gpencil")
247 layout
.operator("gpencil.copy", text
="Copy")
248 layout
.operator("gpencil.paste", text
="Paste")
250 layout
.prop_menu_enum(toolsettings
, "proportional_edit")
251 layout
.prop_menu_enum(toolsettings
, "proportional_edit_falloff")
253 layout
.operator("gpencil.reveal")
254 layout
.operator("gpencil.hide", text
="Show Active Layer Only").unselected
= True
255 layout
.operator("gpencil.hide", text
="Hide Active Layer").unselected
= False
257 layout
.operator_menu_enum("gpencil.move_to_layer", "layer", text
="Move to Layer")
258 layout
.operator_menu_enum("gpencil.convert", "type", text
="Convert to Geometry...")
266 VIEW3D_MT_Camera_Options
,
267 VIEW3D_MT_InteractiveMode
,
268 VIEW3D_MT_InteractiveModeOther
,
269 VIEW3D_OT_SetObjectMode
,
271 VIEW3D_OT_Interactive_Mode_Text
,
272 VIEW3D_OT_Interactive_Mode_Grease_Pencil
,
273 VIEW3D_MT_Interactive_Mode_GPencil
,
274 VIEW3D_MT_Edit_Gpencil
,
278 # Register Classes & Hotkeys #
281 bpy
.utils
.register_class(cls
)
284 # Unregister Classes & Hotkeys #
287 for cls
in reversed(classes
):
288 bpy
.utils
.unregister_class(cls
)
291 if __name__
== "__main__":