From ce104ca89643c4b0e6358fd22a2b056ecd603e62 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Tue, 26 Feb 2019 19:40:07 -0300 Subject: Fix: Grease Pencil data panels not working with pinning Note: Things were working fine if you were to pin the Grease Pencil object, but not if you were pinning the GP data. In too many poll functions context.object was being requested when a simple context.gpencil_data would suffit. Panels that are still not showing in pinning: * DATA_PT_gpencil_display. The panel needs to be split in sub-panels, leaving all object-dependent properties in its own panel so we can poll it away, while showing the rest. * * * This commit doesn't handle greasepencil material. In this case I recommend we do as properties_material.py and have a generous poll(), followed by different drawing logics whether or not we have an object. --- .../startup/bl_ui/properties_data_gpencil.py | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'release/scripts/startup/bl_ui/properties_data_gpencil.py') diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py index 8b4b927ffde..7a723901e4b 100644 --- a/release/scripts/startup/bl_ui/properties_data_gpencil.py +++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py @@ -34,6 +34,16 @@ class DataButtonsPanel: bl_region_type = 'WINDOW' bl_context = "data" + @classmethod + def poll(cls, context): + return context.gpencil_data + + +class ObjectButtonsPanel: + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_context = "data" + @classmethod def poll(cls, context): return context.object and context.object.type == 'GPENCIL' @@ -46,8 +56,7 @@ class LayerDataButtonsPanel: @classmethod def poll(cls, context): - return (context.object and - context.object.type == 'GPENCIL' and + return (context.gpencil_data and context.active_gpencil_layer) @@ -103,14 +112,7 @@ class DATA_PT_gpencil_datapanel(Panel): @classmethod def poll(cls, context): - if context.gpencil_data is None: - return False - - ob = context.object - if ob is not None and ob.type == 'GPENCIL': - return True - - return False + return context.gpencil_data @staticmethod def draw(self, context): @@ -294,7 +296,7 @@ class GPENCIL_UL_vgroups(UIList): layout.label(text="", icon_value=icon) -class DATA_PT_gpencil_vertexpanel(DataButtonsPanel, Panel): +class DATA_PT_gpencil_vertexpanel(ObjectButtonsPanel, Panel): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "data" @@ -359,7 +361,7 @@ class DATA_PT_gpencil_strokes(DataButtonsPanel, Panel): layout.prop(gpd, "use_adaptive_uv", text="Adaptive UVs") -class DATA_PT_gpencil_display(DataButtonsPanel, Panel): +class DATA_PT_gpencil_display(ObjectButtonsPanel, Panel): bl_label = "Viewport Display" bl_options = {'DEFAULT_CLOSED'} -- cgit v1.2.3