GPencil Tools: Added mirror flip
[blender-addons.git] / space_view3d_spacebar_menu / view_menus.py
blob03f7318dd4b67b2a775c0dfe109ee5e988ce6251
1 # SPDX-License-Identifier: GPL-2.0-or-later
2 # Contributed to by: meta-androcto, JayDez, sim88, sam, lijenstina, mkb, wisaac, CoDEmanX.
5 import bpy
6 from bpy.types import (
7 Operator,
8 Menu,
10 from bpy.props import (
11 BoolProperty,
12 StringProperty,
15 from . edit_mesh import *
17 # View Menu's #
18 class VIEW3D_MT_View_Menu(Menu):
19 bl_label = "View"
21 def draw(self, context):
22 layout = self.layout
23 view = context.space_data
25 layout.menu("VIEW3D_MT_view_viewpoint")
26 layout.menu("VIEW3D_MT_view_align")
27 layout.menu("VIEW3D_MT_view_navigation")
28 layout.menu("INFO_MT_area")
29 layout.operator_context = 'INVOKE_REGION_WIN'
30 layout.menu("VIEW3D_MT_view_regions", text="View Regions")
31 layout.menu("VIEW3D_MT_Shade")
32 layout.separator()
34 layout.operator("view3d.view_selected", text="Frame Selected").use_all_regions = False
35 if view.region_quadviews:
36 layout.operator("view3d.view_selected", text="Frame Selected (Quad View)").use_all_regions = True
37 layout.operator("view3d.view_all").center = False
38 layout.separator()
40 layout.operator("view3d.view_persportho", text="Perspective/Orthographic")
41 layout.menu("VIEW3D_MT_view_local")
42 layout.separator()
44 layout.operator("render.opengl", text="Viewport Render Image", icon='RENDER_STILL')
45 layout.operator("render.opengl", text="Viewport Render Animation", icon='RENDER_ANIMATION').animation = True
46 layout.separator()
48 layout.prop(view, "show_region_toolbar")
49 layout.prop(view, "show_region_ui")
50 layout.prop(view, "show_region_tool_header")
51 layout.prop(view, "show_region_hud")
55 # Display Wire (Thanks to marvin.k.breuer) #
56 class VIEW3D_OT_Display_Wire_All(Operator):
57 bl_label = "Wire on All Objects"
58 bl_idname = "view3d.display_wire_all"
59 bl_description = "Enable/Disable Display Wire on All Objects"
61 @classmethod
62 def poll(cls, context):
63 return context.active_object is not None
65 def execute(self, context):
66 is_error = False
67 for obj in bpy.data.objects:
68 try:
69 if obj.show_wire:
70 obj.show_all_edges = False
71 obj.show_wire = False
72 else:
73 obj.show_all_edges = True
74 obj.show_wire = True
75 except:
76 is_error = True
77 pass
79 if is_error:
80 self.report({'WARNING'},
81 "Wire on All Objects could not be completed for some objects")
83 return {'FINISHED'}
86 # Matcap and AO, Wire all and X-Ray entries thanks to marvin.k.breuer
87 class VIEW3D_MT_Shade(Menu):
88 bl_label = "Shade"
90 def draw(self, context):
91 layout = self.layout
93 # layout.prop(context.space_data, "viewport_shade", expand=True)
95 if context.active_object:
96 if(context.mode == 'EDIT_MESH'):
97 layout.operator("MESH_OT_faces_shade_smooth", icon='SHADING_RENDERED')
98 layout.operator("MESH_OT_faces_shade_flat", icon='SHADING_SOLID')
99 else:
100 layout.operator("OBJECT_OT_shade_smooth", icon='SHADING_RENDERED')
101 layout.operator("OBJECT_OT_shade_flat", icon='SHADING_SOLID')
103 layout.separator()
104 layout.operator("view3d.display_wire_all", text="Wire all", icon='SHADING_WIRE')
106 # layout.prop(context.space_data, "use_matcap", icon="MATCAP_01")
108 # if context.space_data.use_matcap:
109 # row = layout.column(1)
110 # row.scale_y = 0.3
111 # row.scale_x = 0.5
112 # row.template_icon_view(context.space_data, "matcap_icon")
114 def menu_func(self, context):
115 self.layout.menu("VIEW3D_MT_Shade")
117 # List The Classes #
119 classes = (
120 VIEW3D_MT_Shade,
121 VIEW3D_OT_Display_Wire_All,
122 VIEW3D_MT_View_Menu
126 # Register Classes & Hotkeys #
127 def register():
128 for cls in classes:
129 bpy.utils.register_class(cls)
132 # Unregister Classes & Hotkeys #
133 def unregister():
135 for cls in reversed(classes):
136 bpy.utils.unregister_class(cls)
138 if __name__ == "__main__":
139 register()