1 # SPDX-License-Identifier: GPL-2.0-or-later
4 from bpy
.types
import Menu
5 from . import utils_core
6 from bl_ui
.properties_paint_common
import UnifiedPaintPanel
23 'SCULPT': "tool_settings.sculpt.brush",
24 'VERTEX_PAINT': "tool_settings.vertex_paint.brush",
25 'WEIGHT_PAINT': "tool_settings.weight_paint.brush",
26 'TEXTURE_PAINT': "tool_settings.image_paint.brush",
27 'PARTICLE_EDIT': "tool_settings.particle_edit.tool"
35 "BOUNDARY": 'BRUSH_GRAB',
37 "CLAY_STRIPS": 'BRUSH_CLAY_STRIPS',
38 "CLAY_THUMB": 'BRUSH_CLAY_STRIPS',
39 "CLOTH": 'BRUSH_SCULPT_DRAW',
40 "CREASE": 'BRUSH_CREASE',
41 "DISPLACEMENT_ERASER": 'BRUSH_SCULPT_DRAW',
42 "DISPLACEMENT_SMEAR": 'BRUSH_SCULPT_DRAW',
43 "DRAW": 'BRUSH_SCULPT_DRAW',
44 "DRAW_FACE_SETS": 'BRUSH_MASK',
45 "DRAW_SHARP": 'BRUSH_SCULPT_DRAW',
46 "ELASTIC_DEFORM": 'BRUSH_GRAB',
48 "FLATTEN": 'BRUSH_FLATTEN',
50 "INFLATE": 'BRUSH_INFLATE',
51 "LAYER": 'BRUSH_LAYER',
53 "MULTIPLANE_SCRAPE": 'BRUSH_SCRAPE',
54 "NUDGE": 'BRUSH_NUDGE',
55 "PAINT": 'BRUSH_SCULPT_DRAW',
56 "PINCH": 'BRUSH_PINCH',
58 "ROTATE": 'BRUSH_ROTATE',
59 "SCRAPE": 'BRUSH_SCRAPE',
60 "SIMPLIFY": 'BRUSH_DATA',
61 "SMOOTH": 'BRUSH_SMOOTH',
62 "SNAKE_HOOK": 'BRUSH_SNAKE_HOOK',
63 "THUMB": 'BRUSH_THUMB',
64 "TOPOLOGY": 'BRUSH_GRAB',
68 "AVERAGE": 'BRUSH_BLUR',
71 "SMEAR": 'BRUSH_BLUR',
75 "AVERAGE": 'BRUSH_BLUR',
78 "SMEAR": 'BRUSH_BLUR',
82 "CLONE": 'BRUSH_CLONE',
83 "DRAW": 'BRUSH_TEXDRAW',
84 "FILL": 'BRUSH_TEXFILL',
85 "MASK": 'BRUSH_TEXMASK',
86 "SMEAR": 'BRUSH_SMEAR',
87 "SOFTEN": 'BRUSH_SOFTEN',
91 def get_brush_icon(mode
, tool
):
92 mode_icons
= brush_icon
.get(mode
, None)
94 if mode_icons
== None:
95 print(f
"Warning: icons for mode {mode} aren't supported")
98 icon
= mode_icons
.get(tool
, None)
101 print(f
"Warning: Could not find icon for tool {tool} in mode {mode}")
108 class BrushesMenu(Menu
):
110 bl_idname
= "VIEW3D_MT_sv3_brushes_menu"
112 def draw(self
, context
):
113 mode
= utils_core
.get_mode()
115 settings
= UnifiedPaintPanel
.paint_settings(context
)
116 colum_n
= utils_core
.addon_settings()
118 layout
.row().label(text
="Brush")
119 layout
.row().separator()
121 has_brush
= utils_core
.get_brush_link(context
, types
="brush")
122 current_brush
= eval("bpy.context.{}".format(brush_datapath
[mode
])) if has_brush
else None
124 # get the current brush's name
125 if current_brush
and utils_core
.get_mode() != 'PARTICLE_EDIT':
126 current_brush
= current_brush
.name
128 if mode
== 'PARTICLE_EDIT':
129 # if you are in particle edit mode add the menu items for particle mode
130 for tool
in particle_tools
:
132 layout
.row(), tool
[0], tool
[1], brush_datapath
[mode
],
133 icon
='RADIOBUT_OFF', disable
=True,
134 disable_icon
='RADIOBUT_ON'
137 column_flow
= layout
.column_flow(columns
=colum_n
)
139 # iterate over all the brushes
140 for item
in bpy
.data
.brushes
:
142 if item
.use_paint_sculpt
:
143 # if you are in sculpt mode and the brush
144 # is a sculpt brush add the brush to the menu
146 column_flow
.row(), item
.name
,
147 'bpy.data.brushes["%s"]' % item
.name
,
148 brush_datapath
[mode
], icon
=get_brush_icon(mode
, item
.sculpt_tool
),
149 disable
=True, custom_disable_exp
=(item
.name
, current_brush
),
152 if mode
== 'VERTEX_PAINT':
153 if item
.use_paint_vertex
:
154 # if you are in vertex paint mode and the brush
155 # is a vertex paint brush add the brush to the menu
157 column_flow
.row(), item
.name
,
158 'bpy.data.brushes["%s"]' % item
.name
,
159 brush_datapath
[mode
], icon
=get_brush_icon(mode
, item
.vertex_tool
),
160 disable
=True, custom_disable_exp
=(item
.name
, current_brush
),
163 if mode
== 'WEIGHT_PAINT':
164 if item
.use_paint_weight
:
165 # if you are in weight paint mode and the brush
166 # is a weight paint brush add the brush to the menu
168 column_flow
.row(), item
.name
,
169 'bpy.data.brushes["%s"]' % item
.name
,
170 brush_datapath
[mode
], icon
=get_brush_icon(mode
, item
.weight_tool
),
171 disable
=True, custom_disable_exp
=(item
.name
, current_brush
),
174 if utils_core
.get_mode() == 'TEXTURE_PAINT':
175 if item
.use_paint_image
:
176 # if you are in texture paint mode and the brush
177 # is a texture paint brush add the brush to the menu
179 column_flow
.row(), item
.name
,
180 'bpy.data.brushes["%s"]' % item
.name
,
181 brush_datapath
[mode
], icon
=get_brush_icon(mode
, item
.image_tool
),
182 disable
=True, custom_disable_exp
=(item
.name
, current_brush
),
188 bpy
.utils
.register_class(BrushesMenu
)
191 bpy
.utils
.unregister_class(BrushesMenu
)