1 # gpl author: Ryan Inch (Imaginer)
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"
36 "CLAY_STRIPS": 'BRUSH_CLAY_STRIPS',
37 "CREASE": 'BRUSH_CREASE',
38 "DRAW": 'BRUSH_SCULPT_DRAW',
39 "DRAW_SHARP": 'BRUSH_SCULPT_DRAW',
40 "ELASTIC_DEFORM": 'BRUSH_GRAB',
42 "FLATTEN": 'BRUSH_FLATTEN',
44 "INFLATE": 'BRUSH_INFLATE',
45 "LAYER": 'BRUSH_LAYER',
47 "NUDGE": 'BRUSH_NUDGE',
48 "PINCH": 'BRUSH_PINCH',
50 "ROTATE": 'BRUSH_ROTATE',
51 "SCRAPE": 'BRUSH_SCRAPE',
52 "SIMPLIFY": 'BRUSH_DATA',
53 "SMOOTH": 'BRUSH_SMOOTH',
54 "SNAKE_HOOK": 'BRUSH_SNAKE_HOOK',
55 "THUMB": 'BRUSH_THUMB'
59 "AVERAGE": 'BRUSH_BLUR',
66 "AVERAGE": 'BRUSH_BLUR',
73 "CLONE": 'BRUSH_CLONE',
74 "DRAW": 'BRUSH_TEXDRAW',
75 "FILL": 'BRUSH_TEXFILL',
76 "MASK": 'BRUSH_TEXMASK',
77 "SMEAR": 'BRUSH_SMEAR',
78 "SOFTEN": 'BRUSH_SOFTEN'
83 class BrushesMenu(Menu
):
85 bl_idname
= "VIEW3D_MT_sv3_brushes_menu"
87 def draw(self
, context
):
88 mode
= utils_core
.get_mode()
90 settings
= UnifiedPaintPanel
.paint_settings(context
)
91 colum_n
= utils_core
.addon_settings()
93 layout
.row().label(text
="Brush")
94 layout
.row().separator()
96 has_brush
= utils_core
.get_brush_link(context
, types
="brush")
97 current_brush
= eval("bpy.context.{}".format(brush_datapath
[mode
])) if has_brush
else None
99 # get the current brush's name
100 if current_brush
and utils_core
.get_mode() != 'PARTICLE_EDIT':
101 current_brush
= current_brush
.name
103 if mode
== 'PARTICLE_EDIT':
104 # if you are in particle edit mode add the menu items for particle mode
105 for tool
in particle_tools
:
107 layout
.row(), tool
[0], tool
[1], brush_datapath
[mode
],
108 icon
='RADIOBUT_OFF', disable
=True,
109 disable_icon
='RADIOBUT_ON'
112 column_flow
= layout
.column_flow(columns
=colum_n
)
114 # iterate over all the brushes
115 for item
in bpy
.data
.brushes
:
117 if item
.use_paint_sculpt
:
118 # if you are in sculpt mode and the brush
119 # is a sculpt brush add the brush to the menu
121 column_flow
.row(), item
.name
,
122 'bpy.data.brushes["%s"]' % item
.name
,
123 brush_datapath
[mode
], icon
=brush_icon
[mode
][item
.sculpt_tool
],
124 disable
=True, custom_disable_exp
=(item
.name
, current_brush
),
127 if mode
== 'VERTEX_PAINT':
128 if item
.use_paint_vertex
:
129 # if you are in vertex paint mode and the brush
130 # is a vertex paint brush add the brush to the menu
132 column_flow
.row(), item
.name
,
133 'bpy.data.brushes["%s"]' % item
.name
,
134 brush_datapath
[mode
], icon
=brush_icon
[mode
][item
.vertex_tool
],
135 disable
=True, custom_disable_exp
=(item
.name
, current_brush
),
138 if mode
== 'WEIGHT_PAINT':
139 if item
.use_paint_weight
:
140 # if you are in weight paint mode and the brush
141 # is a weight paint brush add the brush to the menu
143 column_flow
.row(), item
.name
,
144 'bpy.data.brushes["%s"]' % item
.name
,
145 brush_datapath
[mode
], icon
=brush_icon
[mode
][item
.vertex_tool
],
146 disable
=True, custom_disable_exp
=(item
.name
, current_brush
),
149 if utils_core
.get_mode() == 'TEXTURE_PAINT':
150 if item
.use_paint_image
:
151 # if you are in texture paint mode and the brush
152 # is a texture paint brush add the brush to the menu
154 column_flow
.row(), item
.name
,
155 'bpy.data.brushes["%s"]' % item
.name
,
156 brush_datapath
[mode
], icon
=brush_icon
[mode
][item
.image_tool
],
157 disable
=True, custom_disable_exp
=(item
.name
, current_brush
),
163 bpy
.utils
.register_class(BrushesMenu
)
166 bpy
.utils
.unregister_class(BrushesMenu
)