Fix #129749: Use consistent GPv3 color settings in different modes

Always use the Brush.color setting in the Draw mode side bar.
Technically the "Color" panel in the sidebar can draw in other modes,
but it's polling for explicit tools that limit it to the Draw mode
implicitly.

Use the appropriate brush or unified color in other GP modes based on
the unified paint settings flag.

Worth noting this was technically broken for a long time:
The default was that unified paint is disabled, so the GP panels would
use the brush color as expected. Enabling unified paint would then break
the colors, probably wasn't done very frequently since GP files
and e.g. mesh sculpting don't mix often. The default was changed in
#129127 to enable unified paint by default, which now breaks GP colors
by default.

Pull Request: https://projects.blender.org/blender/blender/pulls/129790
This commit is contained in:
Lukas Tönne
2024-11-08 10:21:24 +01:00
parent 9a03f283e8
commit 449e7229f3
25 changed files with 139 additions and 102 deletions

View File

@@ -499,44 +499,6 @@ class GreasePencilMaterialsPanel:
row.template_ID(space, "pin_id")
class GreasePencilVertexcolorPanel:
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
tool_settings = context.scene.tool_settings
is_vertex = context.mode == 'VERTEX_GPENCIL'
gpencil_paint = tool_settings.gpencil_vertex_paint if is_vertex else tool_settings.gpencil_paint
brush = gpencil_paint.brush
gp_settings = brush.gpencil_settings
tool = brush.gpencil_vertex_tool if is_vertex else brush.gpencil_tool
ob = context.object
if ob:
col = layout.column()
col.template_color_picker(brush, "color", value_slider=True)
sub_row = layout.row(align=True)
sub_row.prop(brush, "color", text="")
sub_row.prop(brush, "secondary_color", text="")
sub_row.operator("gpencil.tint_flip", icon='FILE_REFRESH', text="")
row = layout.row(align=True)
row.template_ID(gpencil_paint, "palette", new="palette.new")
if gpencil_paint.palette:
layout.template_palette(gpencil_paint, "palette", color=True)
if tool in {'DRAW', 'FILL'} and is_vertex is False:
row = layout.row(align=True)
row.prop(gp_settings, "vertex_mode", text="Mode")
row = layout.row(align=True)
row.prop(gp_settings, "vertex_color_factor", slider=True, text="Mix Factor")
class GPENCIL_UL_layer(UIList):
def draw_item(self, _context, layout, _data, item, icon, _active_data, _active_propname, _index):
# assert(isinstance(item, bpy.types.GPencilLayer)

View File

@@ -20,7 +20,6 @@ from bl_ui.properties_grease_pencil_common import (
AnnotationDataPanel,
AnnotationOnionSkin,
GreasePencilMaterialsPanel,
GreasePencilVertexcolorPanel,
)
from bl_ui.space_toolsystem_common import (
ToolActivePanelHelper,
@@ -8594,17 +8593,22 @@ class TOPBAR_PT_grease_pencil_vertex_color(Panel):
paint = context.scene.tool_settings.gpencil_paint
elif ob.mode == 'VERTEX_GREASE_PENCIL':
paint = context.scene.tool_settings.gpencil_vertex_paint
use_unified_paint = (ob.mode != 'PAINT_GREASE_PENCIL')
ups = context.tool_settings.unified_paint_settings
brush = paint.brush
prop_owner = ups if ups.use_unified_color else brush
prop_owner = ups if use_unified_paint and ups.use_unified_color else brush
col = layout.column()
col.template_color_picker(prop_owner, "color", value_slider=True)
sub_row = layout.row(align=True)
UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "color", text="")
UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "secondary_color", text="")
if use_unified_paint:
UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "color", text="")
UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "secondary_color", text="")
else:
sub_row.prop(brush, "color", text="")
sub_row.prop(brush, "secondary_color", text="")
sub_row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="")

View File

@@ -2159,16 +2159,25 @@ class VIEW3D_PT_tools_grease_pencil_brush_vertex_color(View3DPanel, Panel):
tool_settings = context.tool_settings
settings = tool_settings.gpencil_vertex_paint
brush = settings.brush
use_unified_paint = (context.object.mode != 'PAINT_GREASE_PENCIL')
ups = context.tool_settings.unified_paint_settings
prop_owner = ups if use_unified_paint and ups.use_unified_color else brush
col = layout.column()
col.template_color_picker(brush, "color", value_slider=True)
col.template_color_picker(prop_owner, "color", value_slider=True)
sub_row = col.row(align=True)
sub_row.prop(brush, "color", text="")
sub_row.prop(brush, "secondary_color", text="")
if use_unified_paint:
UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "color", text="")
UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "secondary_color", text="")
else:
sub_row.prop(brush, "color", text="")
sub_row.prop(brush, "secondary_color", text="")
sub_row.operator("gpencil.tint_flip", icon='FILE_REFRESH', text="")
sub_row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="")
if use_unified_paint:
sub_row.prop(ups, "use_unified_color", text="", icon='BRUSHES_ALL')
class VIEW3D_PT_tools_grease_pencil_brush_vertex_falloff(GreasePencilBrushFalloff, Panel, View3DPaintPanel):
@@ -2272,7 +2281,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_mixcolor(View3DPanel, Panel):
sub_row.prop(brush, "color", text="")
sub_row.prop(brush, "secondary_color", text="")
sub_row.operator("gpencil.tint_flip", icon='FILE_REFRESH', 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")
@@ -2778,6 +2787,9 @@ class VIEW3D_PT_tools_grease_pencil_v3_brush_mixcolor(View3DPanel, Panel):
settings = tool_settings.gpencil_paint
brush = settings.brush
gp_settings = brush.gpencil_settings
use_unified_paint = (context.object.mode != 'PAINT_GREASE_PENCIL')
ups = context.tool_settings.unified_paint_settings
prop_owner = ups if use_unified_paint and ups.use_unified_color else brush
row = layout.row()
row.prop(settings, "color_mode", expand=True)
@@ -2787,11 +2799,16 @@ class VIEW3D_PT_tools_grease_pencil_v3_brush_mixcolor(View3DPanel, Panel):
col = layout.column()
col.enabled = settings.color_mode == 'VERTEXCOLOR'
col.template_color_picker(brush, "color", value_slider=True)
# This panel is only used for Draw mode, which does not use unified paint settings.
col.template_color_picker(prop_owner, "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="")
if use_unified_paint:
UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "color", text="")
UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "secondary_color", text="")
else:
sub_row.prop(brush, "color", text="")
sub_row.prop(brush, "secondary_color", text="")
sub_row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="")