diff --git a/scripts/startup/bl_ui/properties_paint_common.py b/scripts/startup/bl_ui/properties_paint_common.py index 7f3f0f70d35..381426eafec 100644 --- a/scripts/startup/bl_ui/properties_paint_common.py +++ b/scripts/startup/bl_ui/properties_paint_common.py @@ -1388,6 +1388,65 @@ def brush_basic_gpencil_paint_settings(layout, context, brush, *, compact=False) layout.template_curve_mapping(settings, "thickness_primitive_curve", brush=True) +def brush_basic_grease_pencil_paint_settings(layout, context, brush, *, compact=False): + tool_settings = context.tool_settings + settings = tool_settings.gpencil_paint + gp_settings = brush.gpencil_settings + tool = context.workspace.tools.from_space_view3d_mode(context.mode, create=False) + if gp_settings is None: + return + + grease_pencil_tool = brush.gpencil_tool + + UnifiedPaintPanel.prop_unified( + layout, + context, + brush, + "size", + unified_name="use_unified_size", + pressure_name="use_pressure_size", + text="Radius", + slider=True, + header=compact, + ) + + if brush.use_pressure_size and not compact: + col = layout.column() + col.template_curve_mapping(gp_settings, "curve_sensitivity", brush=True, + use_negative_slope=True) + + UnifiedPaintPanel.prop_unified( + layout, + context, + brush, + "strength", + unified_name="use_unified_strength", + pressure_name="use_pressure_strength", + slider=True, + header=compact, + ) + + if brush.use_pressure_strength and not compact: + col = layout.column() + col.template_curve_mapping(gp_settings, "curve_strength", brush=True, + use_negative_slope=True) + + if grease_pencil_tool == 'DRAW': + layout.prop(gp_settings, "active_smooth_factor") + row = layout.row(align=True) + if compact: + row.prop(gp_settings, "caps_type", text="", expand=True) + else: + row.prop(gp_settings, "caps_type", text="Caps Type") + # TODO: Remove this when caps work. + row.enabled = False + elif grease_pencil_tool == 'ERASE': + layout.prop(gp_settings, "eraser_mode", expand=True) + if gp_settings.eraser_mode == "HARD": + layout.prop(gp_settings, "use_keep_caps_eraser") + layout.prop(gp_settings, "use_active_layer_only") + + def brush_basic_gpencil_sculpt_settings(layout, _context, brush, *, compact=False): if brush is None: return diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index a2029153f92..009c3e7566d 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -605,36 +605,12 @@ class _draw_tool_settings_context_mode: ) brush_basic__draw_color_selector(context, layout, brush, brush.gpencil_settings, None) - UnifiedPaintPanel.prop_unified( - layout, - context, - brush, - "size", - unified_name="use_unified_size", - pressure_name="use_pressure_size", - text="Radius", - slider=True, - header=True, + from bl_ui.properties_paint_common import ( + brush_basic__draw_color_selector, + brush_basic_grease_pencil_paint_settings, ) - UnifiedPaintPanel.prop_unified( - layout, - context, - brush, - "strength", - pressure_name="use_pressure_strength", - unified_name="use_unified_strength", - slider=True, - header=True, - ) - - if grease_pencil_tool == 'DRAW': - layout.prop(brush.gpencil_settings, "active_smooth_factor") - elif grease_pencil_tool == 'ERASE': - layout.prop(brush.gpencil_settings, "eraser_mode", expand=True) - if brush.gpencil_settings.eraser_mode == "HARD": - layout.prop(brush.gpencil_settings, "use_keep_caps_eraser") - layout.prop(brush.gpencil_settings, "use_active_layer_only") + brush_basic_grease_pencil_paint_settings(layout, context, brush, compact=True) return True diff --git a/scripts/startup/bl_ui/space_view3d_toolbar.py b/scripts/startup/bl_ui/space_view3d_toolbar.py index e25bb7d60cb..a5226064fe8 100644 --- a/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -2490,6 +2490,194 @@ class VIEW3D_PT_gpencil_brush_presets(Panel, PresetPanel): preset_add_operator = "scene.gpencil_brush_preset_add" +# ********** grease pencil v3 object tool panels **************** + + +class GreasePencilV3PaintPanel: + bl_context = ".grease_pencil_paint" + bl_category = "Tool" + + @classmethod + def poll(cls, context): + if context.space_data.type in {'VIEW_3D', 'PROPERTIES'}: + # Hide for tools not using brushes. + if tool_use_brush(context) is False: + return False + + return True + else: + return True + + +class VIEW3D_PT_tools_grease_pencil_v3_brush_select(Panel, View3DPanel, GreasePencilV3PaintPanel): + bl_label = "Brushes" + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False + + tool_settings = context.scene.tool_settings + gpencil_paint = tool_settings.gpencil_paint + + row = layout.row() + row.column().template_ID_preview(gpencil_paint, "brush", new="brush.add_gpencil", rows=3, cols=8) + + col = row.column() + col.menu("VIEW3D_MT_brush_gpencil_context_menu", icon='DOWNARROW_HLT', text="") + + brush = tool_settings.gpencil_paint.brush + if brush is not None: + col.prop(brush, "use_custom_icon", toggle=True, icon='FILE_IMAGE', text="") + + if brush.use_custom_icon: + layout.row().prop(brush, "icon_filepath", text="") + + +class VIEW3D_PT_tools_grease_pencil_v3_brush_settings(Panel, View3DPanel, GreasePencilV3PaintPanel): + bl_label = "Brush Settings" + bl_options = {'DEFAULT_CLOSED'} + + # What is the point of brush presets? Seems to serve the exact same purpose as brushes themselves?? + def draw_header_preset(self, _context): + VIEW3D_PT_gpencil_brush_presets.draw_panel_header(self.layout) + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False + + tool_settings = context.scene.tool_settings + gpencil_paint = tool_settings.gpencil_paint + + brush = gpencil_paint.brush + + if brush is not None: + gp_settings = brush.gpencil_settings + + if brush.gpencil_tool in {'DRAW', 'FILL'}: + row = layout.row(align=True) + row_mat = row.row() + if gp_settings.use_material_pin: + row_mat.template_ID(gp_settings, "material", live_icon=True) + else: + row_mat.template_ID(context.active_object, "active_material", live_icon=True) + row_mat.enabled = False # will otherwise allow changing material in active slot + + row.prop(gp_settings, "use_material_pin", text="") + + if not self.is_popover: + from bl_ui.properties_paint_common import ( + brush_basic_grease_pencil_paint_settings, + ) + brush_basic_grease_pencil_paint_settings(layout, context, brush, compact=False) + + +class VIEW3D_PT_tools_grease_pencil_v3_brush_mixcolor(View3DPanel, Panel): + bl_context = ".grease_pencil_paint" + bl_label = "Color" + bl_category = "Tool" + + @classmethod + def poll(cls, context): + ob = context.object + tool_settings = context.tool_settings + settings = tool_settings.gpencil_paint + brush = settings.brush + + if ob is None or brush is None: + return False + + if context.region.type == 'TOOL_HEADER': + return False + + from bl_ui.space_toolsystem_common import ToolSelectPanelHelper + tool = ToolSelectPanelHelper.tool_active_from_context(context) + if tool and tool.idname in {'builtin.cutter', 'builtin.eyedropper', 'builtin.interpolate'}: + return False + + if brush.gpencil_tool == 'TINT': + return True + + if brush.gpencil_tool not in {'DRAW', 'FILL'}: + return False + + return True + + def draw(self, context): + layout = self.layout + tool_settings = context.tool_settings + settings = tool_settings.gpencil_paint + brush = settings.brush + gp_settings = brush.gpencil_settings + + row = layout.row() + row.prop(settings, "color_mode", expand=True) + + layout.use_property_split = True + layout.use_property_decorate = False + col = layout.column() + col.enabled = settings.color_mode == 'VERTEXCOLOR' + + col.template_color_picker(brush, "color", value_slider=True) + + sub_row = col.row(align=True) + UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "color", text="") + UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "secondary_color", text="") + + sub_row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="") + + if brush.gpencil_tool in {'DRAW', 'FILL'}: + col.prop(gp_settings, "vertex_mode", text="Mode") + col.prop(gp_settings, "vertex_color_factor", slider=True, text="Mix Factor") + + +class VIEW3D_PT_tools_grease_pencil_v3_brush_mix_palette(View3DPanel, Panel): + bl_context = ".grease_pencil_paint" + bl_label = "Palette" + bl_category = "Tool" + bl_parent_id = "VIEW3D_PT_tools_grease_pencil_v3_brush_mixcolor" + + @classmethod + def poll(cls, context): + ob = context.object + tool_settings = context.tool_settings + settings = tool_settings.gpencil_paint + brush = settings.brush + + if ob is None or brush is None: + return False + + from bl_ui.space_toolsystem_common import ToolSelectPanelHelper + tool = ToolSelectPanelHelper.tool_active_from_context(context) + if tool and tool.idname in {'builtin.cutter', 'builtin.eyedropper', 'builtin.interpolate'}: + return False + + if brush.gpencil_tool == 'TINT': + return True + + if brush.gpencil_tool not in {'DRAW', 'FILL'}: + return False + + return True + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False + tool_settings = context.tool_settings + settings = tool_settings.gpencil_paint + brush = settings.brush + + col = layout.column() + col.enabled = settings.color_mode == 'VERTEXCOLOR' + + row = col.row(align=True) + row.template_ID(settings, "palette", new="palette.new") + if settings.palette: + col.template_palette(settings, "palette", color=True) + + classes = ( VIEW3D_MT_brush_context_menu, VIEW3D_MT_brush_gpencil_context_menu, @@ -2581,6 +2769,11 @@ classes = ( VIEW3D_PT_tools_grease_pencil_brush_mixcolor, VIEW3D_PT_tools_grease_pencil_brush_mix_palette, + VIEW3D_PT_tools_grease_pencil_v3_brush_select, + VIEW3D_PT_tools_grease_pencil_v3_brush_settings, + VIEW3D_PT_tools_grease_pencil_v3_brush_mixcolor, + VIEW3D_PT_tools_grease_pencil_v3_brush_mix_palette, + VIEW3D_PT_tools_grease_pencil_brush_paint_falloff, VIEW3D_PT_tools_grease_pencil_brush_sculpt_falloff, VIEW3D_PT_tools_grease_pencil_brush_weight_falloff, diff --git a/source/blender/editors/space_view3d/space_view3d.cc b/source/blender/editors/space_view3d/space_view3d.cc index 138fe99c718..7e200da2bd3 100644 --- a/source/blender/editors/space_view3d/space_view3d.cc +++ b/source/blender/editors/space_view3d/space_view3d.cc @@ -1709,6 +1709,9 @@ void ED_view3d_buttons_region_layout_ex(const bContext *C, case CTX_MODE_EDIT_GREASE_PENCIL: ARRAY_SET_ITEMS(contexts, ".grease_pencil_edit"); break; + case CTX_MODE_PAINT_GREASE_PENCIL: + ARRAY_SET_ITEMS(contexts, ".grease_pencil_paint"); + break; case CTX_MODE_EDIT_POINT_CLOUD: ARRAY_SET_ITEMS(contexts, ".point_cloud_edit"); break;