1 # SPDX-License-Identifier: GPL-2.0-or-later
4 from bpy
.types
import Menu
5 from . import utils_core
6 from .brushes
import brush_datapath
8 # stroke methods: 'AIRBRUSH' 'ANCHORED' 'SPACE' 'DRAG_DOT' 'DOTS' 'LINE' 'CURVE'
10 class PaintCurvesMenu(Menu
):
11 bl_label
= "Paint Curves"
12 bl_idname
= "VIEW3D_MT_sv3_paint_curves_menu"
14 def draw(self
, context
):
15 mode
= utils_core
.get_mode()
17 colum_n
= utils_core
.addon_settings()
19 layout
.row().label(text
="Paint Curves")
20 layout
.row().separator()
22 has_brush
= utils_core
.get_brush_link(context
, types
="brush")
24 has_current_curve
= has_brush
.paint_curve
if has_brush
else None
25 current_curve
= has_current_curve
.name
if has_current_curve
else ''
27 column_flow
= layout
.column_flow(columns
=colum_n
)
29 if len(bpy
.data
.paint_curves
) != 0:
30 for x
, item
in enumerate(bpy
.data
.paint_curves
):
34 'bpy.data.paint_curves["%s"]' % item
.name
,
35 brush_datapath
[mode
] + ".paint_curve",
38 disable_icon
='RADIOBUT_ON',
39 custom_disable_exp
=(item
.name
, current_curve
),
44 layout
.row().label(text
="No Paint Curves Available", icon
="INFO")
46 class StrokeOptionsMenu(Menu
):
47 bl_label
= "Stroke Options"
48 bl_idname
= "VIEW3D_MT_sv3_stroke_options"
51 def poll(self
, context
):
52 return utils_core
.get_mode() in (
53 'SCULPT', 'VERTEX_PAINT',
54 'WEIGHT_PAINT', 'TEXTURE_PAINT',
59 has_brush
= utils_core
.get_brush_link(bpy
.context
, types
="brush")
60 if utils_core
.get_mode() == 'SCULPT':
61 settings
= bpy
.context
.tool_settings
.sculpt
63 elif utils_core
.get_mode() == 'VERTEX_PAINT':
64 settings
= bpy
.context
.tool_settings
.vertex_paint
66 elif utils_core
.get_mode() == 'WEIGHT_PAINT':
67 settings
= bpy
.context
.tool_settings
.weight_paint
69 elif utils_core
.get_mode() == 'TEXTURE_PAINT':
70 settings
= bpy
.context
.tool_settings
.image_paint
75 stroke_method
= has_brush
.stroke_method
if has_brush
else None
77 return settings
, has_brush
, stroke_method
79 def draw(self
, context
):
80 settings
, brush
, stroke_method
= self
.init()
83 layout
.row().menu(StrokeMethodMenu
.bl_idname
)
84 layout
.row().separator()
88 if stroke_method
in ('SPACE', 'LINE') and brush
:
89 layout
.row().prop(brush
, "spacing",
90 text
=utils_core
.PIW
+ "Spacing", slider
=True)
92 elif stroke_method
== 'AIRBRUSH' and brush
:
93 layout
.row().prop(brush
, "rate",
94 text
=utils_core
.PIW
+ "Rate", slider
=True)
96 elif stroke_method
== 'ANCHORED' and brush
:
97 layout
.row().prop(brush
, "use_edge_to_edge")
99 elif stroke_method
== 'CURVE' and brush
:
100 has_current_curve
= brush
.paint_curve
if brush
else None
101 current_curve
= has_current_curve
.name
if has_current_curve
else 'No Curve Selected'
103 layout
.row().menu(PaintCurvesMenu
.bl_idname
, text
=current_curve
,
104 icon
='CURVE_BEZCURVE')
105 layout
.row().operator("paintcurve.new", icon
='ADD')
106 layout
.row().operator("paintcurve.draw")
108 layout
.row().separator()
110 layout
.row().prop(brush
, "spacing",
111 text
=utils_core
.PIW
+ "Spacing",
117 if utils_core
.get_mode() == 'SCULPT' and stroke_method
in ('DRAG_DOT', 'ANCHORED'):
121 layout
.row().prop(brush
, "jitter",
122 text
=utils_core
.PIW
+ "Jitter", slider
=True)
124 layout
.row().prop(settings
, "input_samples",
125 text
=utils_core
.PIW
+ "Input Samples", slider
=True)
127 if stroke_method
in ('DOTS', 'SPACE', 'AIRBRUSH') and brush
:
128 layout
.row().separator()
130 layout
.row().prop(brush
, "use_smooth_stroke", toggle
=True)
132 if brush
.use_smooth_stroke
:
133 layout
.row().prop(brush
, "smooth_stroke_radius",
134 text
=utils_core
.PIW
+ "Radius", slider
=True)
135 layout
.row().prop(brush
, "smooth_stroke_factor",
136 text
=utils_core
.PIW
+ "Factor", slider
=True)
138 layout
.row().label(text
="No Stroke Options available", icon
="INFO")
141 class StrokeMethodMenu(Menu
):
142 bl_label
= "Stroke Method"
143 bl_idname
= "VIEW3D_MT_sv3_stroke_method"
146 has_brush
= utils_core
.get_brush_link(bpy
.context
, types
="brush")
147 if utils_core
.get_mode() == 'SCULPT':
148 path
= "tool_settings.sculpt.brush.stroke_method"
150 elif utils_core
.get_mode() == 'VERTEX_PAINT':
151 path
= "tool_settings.vertex_paint.brush.stroke_method"
153 elif utils_core
.get_mode() == 'WEIGHT_PAINT':
154 path
= "tool_settings.weight_paint.brush.stroke_method"
156 elif utils_core
.get_mode() == 'TEXTURE_PAINT':
157 path
= "tool_settings.image_paint.brush.stroke_method"
162 return has_brush
, path
164 def draw(self
, context
):
165 brush
, path
= self
.init()
168 layout
.row().label(text
="Stroke Method")
169 layout
.row().separator()
172 # add the menu items dynamically based on values in enum property
173 for tool
in brush
.bl_rna
.properties
['stroke_method'].enum_items
:
174 if tool
.identifier
in ('ANCHORED', 'DRAG_DOT') and \
175 utils_core
.get_mode() in ('VERTEX_PAINT',
180 layout
.row(), tool
.name
, tool
.identifier
, path
,
181 icon
='RADIOBUT_OFF', disable
=True,
182 disable_icon
='RADIOBUT_ON'
185 layout
.row().label(text
="No Stroke Method available", icon
="INFO")
196 bpy
.utils
.register_class(cls
)
200 bpy
.utils
.unregister_class(cls
)