node_presets: add back from addons_contrib
[blender-addons.git] / space_view3d_pie_menus / pie_sculpt_menu.py
blob0f919c9bde6b43feb244c0c5f34b4b1d02527911
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: 'W'",
23 "description": "Sculpt Brush Menu",
24 "author": "pitiwazou, meta-androcto",
25 "version": (0, 1, 0),
26 "blender": (2, 80, 0),
27 "location": "W key",
28 "warning": "",
29 "wiki_url": "",
30 "category": "Sculpt Pie"
33 import os
34 import bpy
35 from bpy.types import (
36 Menu,
37 Operator,
41 # Sculpt Draw
42 class PIE_OT_SculptSculptDraw(Operator):
43 bl_idname = "sculpt.sculptraw"
44 bl_label = "Sculpt SculptDraw"
45 bl_options = {'REGISTER', 'UNDO'}
47 def execute(self, context):
48 context.tool_settings.sculpt.brush = bpy.data.brushes['SculptDraw']
49 return {'FINISHED'}
52 # Pie Sculp Pie Menus - W
53 class PIE_MT_SculptPie(Menu):
54 bl_idname = "PIE_MT_sculpt"
55 bl_label = "Pie Sculpt"
57 def draw(self, context):
58 global brush_icons
59 layout = self.layout
60 pie = layout.menu_pie()
61 pie.scale_y = 1.2
62 # 4 - LEFT
63 pie.operator("paint.brush_select",
64 text=" Crease", icon_value=brush_icons["crease"]).sculpt_tool = 'CREASE'
65 # 6 - RIGHT
66 pie.operator("paint.brush_select",
67 text=" Blob", icon_value=brush_icons["blob"]).sculpt_tool = 'BLOB'
68 # 2 - BOTTOM
69 pie.menu(PIE_MT_Sculpttwo.bl_idname, text="More Brushes")
70 # 8 - TOP
71 pie.operator("sculpt.sculptraw",
72 text=" Draw", icon_value=brush_icons["draw"])
73 # 7 - TOP - LEFT
74 pie.operator("paint.brush_select",
75 text=" Clay", icon_value=brush_icons["clay"]).sculpt_tool = 'CLAY'
76 # 9 - TOP - RIGHT
77 pie.operator("paint.brush_select",
78 text=" Clay Strips", icon_value=brush_icons["clay_strips"]).sculpt_tool = 'CLAY_STRIPS'
79 # 1 - BOTTOM - LEFT
80 pie.operator("paint.brush_select",
81 text=" Inflate/Deflate", icon_value=brush_icons["inflate"]).sculpt_tool = 'INFLATE'
82 # 3 - BOTTOM - RIGHT
83 pie.menu(PIE_MT_Sculptthree.bl_idname,
84 text=" Grab Brushes", icon_value=brush_icons["grab"])
87 # Pie Sculpt 2
88 class PIE_MT_Sculpttwo(Menu):
89 bl_idname = "PIE_MT_sculpttwo"
90 bl_label = "Pie Sculpt 2"
92 def draw(self, context):
93 global brush_icons
94 layout = self.layout
95 layout.scale_y = 1.5
97 layout.operator("paint.brush_select", text=' Smooth',
98 icon_value=brush_icons["smooth"]).sculpt_tool = 'SMOOTH'
99 layout.operator("paint.brush_select", text=' Flatten',
100 icon_value=brush_icons["flatten"]).sculpt_tool = 'FLATTEN'
101 layout.operator("paint.brush_select", text=' Scrape/Peaks',
102 icon_value=brush_icons["scrape"]).sculpt_tool = 'SCRAPE'
103 layout.operator("paint.brush_select", text=' Fill/Deepen',
104 icon_value=brush_icons["fill"]).sculpt_tool = 'FILL'
105 layout.operator("paint.brush_select", text=' Pinch/Magnify',
106 icon_value=brush_icons["pinch"]).sculpt_tool = 'PINCH'
107 layout.operator("paint.brush_select", text=' Layer',
108 icon_value=brush_icons["layer"]).sculpt_tool = 'LAYER'
109 layout.operator("paint.brush_select", text=' Mask',
110 icon_value=brush_icons["mask"]).sculpt_tool = 'MASK'
113 # Pie Sculpt Three
114 class PIE_MT_Sculptthree(Menu):
115 bl_idname = "PIE_MT_sculptthree"
116 bl_label = "Pie Sculpt 3"
118 def draw(self, context):
119 global brush_icons
120 layout = self.layout
121 layout.scale_y = 1.5
123 layout.operator("paint.brush_select",
124 text=' Grab', icon_value=brush_icons["grab"]).sculpt_tool = 'GRAB'
125 layout.operator("paint.brush_select",
126 text=' Nudge', icon_value=brush_icons["nudge"]).sculpt_tool = 'NUDGE'
127 layout.operator("paint.brush_select",
128 text=' Thumb', icon_value=brush_icons["thumb"]).sculpt_tool = 'THUMB'
129 layout.operator("paint.brush_select",
130 text=' Snakehook', icon_value=brush_icons["snake_hook"]).sculpt_tool = 'SNAKE_HOOK'
131 layout.operator("paint.brush_select",
132 text=' Rotate', icon_value=brush_icons["rotate"]).sculpt_tool = 'ROTATE'
135 brush_icons = {}
137 def create_icons():
138 global brush_icons
139 icons_directory = bpy.utils.system_resource('DATAFILES', "icons")
140 brushes = ["crease", "blob", "smooth", "draw", "clay", "clay_strips", "inflate", "grab",
141 "nudge", "thumb", "snake_hook", "rotate", "flatten", "scrape", "fill", "pinch",
142 "layer", "mask"]
143 for brush in brushes:
144 filename = os.path.join(icons_directory, f"brush.sculpt.{brush}.dat")
145 icon_value = bpy.app.icons.new_triangles_from_file(filename)
146 brush_icons[brush] = icon_value
149 def release_icons():
150 global brush_icons
151 for value in brush_icons.values():
152 bpy.app.icons.release(value)
154 classes = (
155 PIE_MT_SculptPie,
156 PIE_MT_Sculpttwo,
157 PIE_MT_Sculptthree,
158 PIE_OT_SculptSculptDraw,
161 addon_keymaps = []
164 def register():
165 create_icons()
167 for cls in classes:
168 bpy.utils.register_class(cls)
170 wm = bpy.context.window_manager
171 if wm.keyconfigs.addon:
172 # Sculpt Pie Menu
173 km = wm.keyconfigs.addon.keymaps.new(name='Sculpt')
174 kmi = km.keymap_items.new('wm.call_menu_pie', 'W', 'PRESS')
175 kmi.properties.name = "PIE_MT_sculpt"
176 addon_keymaps.append((km, kmi))
179 def unregister():
180 release_icons()
182 for cls in classes:
183 bpy.utils.unregister_class(cls)
185 wm = bpy.context.window_manager
186 kc = wm.keyconfigs.addon
187 if kc:
188 for km, kmi in addon_keymaps:
189 km.keymap_items.remove(kmi)
190 addon_keymaps.clear()
193 if __name__ == "__main__":
194 register()