From 7021bd527380b4d87cf48057f0039509326b03dd Mon Sep 17 00:00:00 2001 From: Antonioya Date: Mon, 25 Mar 2019 17:02:42 +0100 Subject: GPencil: Only brushes with pinned materials have materials Using GP_BRUSH_MATERIAL_PINNED to switch between active material and brush material, instead of updating all brushes on active material changes. This will allow brushes to have no material and therefore to not inflate the user count. This fix T62465. Patch contributed by @matc Reviewers: @brecht @antoniov @billreynish @mendio --- .../scripts/startup/bl_ui/properties_grease_pencil_common.py | 11 +++++++++++ release/scripts/startup/bl_ui/space_topbar.py | 3 ++- release/scripts/startup/bl_ui/space_view3d_toolbar.py | 10 +++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'release') diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py index 5f2ac7e7123..bb059d6befc 100644 --- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -832,6 +832,11 @@ class GreasePencilMaterialsPanel: layout = self.layout show_full_ui = (self.bl_space_type == 'PROPERTIES') + is_view3d = (self.bl_space_type == 'VIEW_3D') + tool_settings = context.scene.tool_settings + gpencil_paint = tool_settings.gpencil_paint + brush = gpencil_paint.brush + ob = context.object row = layout.row() @@ -841,6 +846,12 @@ class GreasePencilMaterialsPanel: row.template_list("GPENCIL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows) + # if topbar popover and brush pinned, disable + if is_view3d and brush is not None: + gp_settings = brush.gpencil_settings + if gp_settings.use_material_pin: + row.enabled = False + col = row.column(align=True) if show_full_ui: col.operator("object.material_slot_add", icon='ADD', text="") diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index 0e687452e5c..7b9b324066a 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -316,7 +316,8 @@ class _draw_left_context_mode: def draw_color_selector(): ma = gp_settings.material row = layout.row(align=True) - + if not gp_settings.use_material_pin: + ma = context.object.active_material icon_id = 0 if ma: icon_id = ma.id_data.preview.icon_id diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 212427dead9..17dd35d9fc4 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1679,7 +1679,15 @@ class VIEW3D_PT_tools_grease_pencil_brush(View3DPanel, Panel): gp_settings = brush.gpencil_settings if brush.gpencil_tool in {'DRAW', 'FILL'}: - layout.row(align=True).template_ID(gp_settings, "material") + 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 to change material in active slot + + row.prop(gp_settings, "use_material_pin", text="") if not self.is_popover: from .properties_paint_common import ( -- cgit v1.2.3