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.
This commit is contained in:
Dalai Felinto
2019-02-26 19:40:07 -03:00
parent 1beada2c62
commit ce104ca896

View File

@@ -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'}