Merge branch 'blender-v2.92-release'
[blender-addons.git] / space_view3d_pie_menus / pie_shading_menu.py
blob28603d25d5477e5d907722e993eacfa2706c6ebe
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 #####
19 # <pep8 compliant>
21 bl_info = {
22 "name": "Hotkey: 'Z'",
23 "description": "Viewport Shading Menus",
24 "author": "pitiwazou, meta-androcto",
25 "version": (0, 1, 1),
26 "blender": (2, 80, 0),
27 "location": "3D View",
28 "warning": "",
29 "doc_url": "",
30 "category": "Shading Pie"
33 import bpy
34 from bpy.types import Menu
37 # Pie Shading - Z
38 class PIE_MT_ShadingView(Menu):
39 bl_idname = "PIE_MT_shadingview"
40 bl_label = "Pie Shading"
42 def draw(self, context):
43 layout = self.layout
45 pie = layout.menu_pie()
46 pie.prop(context.space_data.shading, "type", expand=True)
48 if context.active_object:
49 if context.mode == 'EDIT_MESH':
50 pie.operator("MESH_OT_faces_shade_smooth")
51 pie.operator("MESH_OT_faces_shade_flat")
52 else:
53 pie.operator("OBJECT_OT_shade_smooth")
54 pie.operator("OBJECT_OT_shade_flat")
57 classes = (
58 PIE_MT_ShadingView,
61 addon_keymaps = []
64 def register():
65 for cls in classes:
66 bpy.utils.register_class(cls)
68 wm = bpy.context.window_manager
69 if wm.keyconfigs.addon:
70 # Shading
71 km = wm.keyconfigs.addon.keymaps.new(name='3D View Generic', space_type='VIEW_3D')
72 kmi = km.keymap_items.new('wm.call_menu_pie', 'Z', 'PRESS')
73 kmi.properties.name = "PIE_MT_shadingview"
74 addon_keymaps.append((km, kmi))
77 def unregister():
78 for cls in classes:
79 bpy.utils.unregister_class(cls)
81 wm = bpy.context.window_manager
82 kc = wm.keyconfigs.addon
83 if kc:
84 for km, kmi in addon_keymaps:
85 km.keymap_items.remove(kmi)
86 addon_keymaps.clear()
89 if __name__ == "__main__":
90 register()