Commit: 92d185faebeac60ec2591c2a7c0f870e7726593d
Author: Dalai Felinto
Date:   Thu Mar 7 14:55:03 2019 +0000
Branches: master
https://developer.blender.org/rB92d185faebeac60ec2591c2a7c0f870e7726593d

Properties Editor: Grease Pencil and pinning fixes

The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.

Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.

This would lead to all sort of pinning problems:

* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.

* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.

* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.

I also sanitized the name of the panels, their inheritance and poll
functions.

Reviewers: antoniov, brecht

Subscribers: billrey

Differential Revision: https://developer.blender.org/D4470

===================================================================

M       intern/cycles/blender/addon/ui.py
M       release/scripts/startup/bl_ui/properties_data_gpencil.py
M       release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M       release/scripts/startup/bl_ui/properties_material.py
M       release/scripts/startup/bl_ui/properties_material_gpencil.py
M       source/blender/editors/space_buttons/buttons_context.c

===================================================================

diff --git a/intern/cycles/blender/addon/ui.py 
b/intern/cycles/blender/addon/ui.py
index 542f02f1a6d..d0cfb5c5e72 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -1613,7 +1613,8 @@ class CYCLES_MATERIAL_PT_preview(CyclesButtonsPanel, 
Panel):
 
     @classmethod
     def poll(cls, context):
-        return context.material and CyclesButtonsPanel.poll(context)
+        mat = context.material
+        return mat and (not mat.grease_pencil) and 
CyclesButtonsPanel.poll(context)
 
     def draw(self, context):
         self.layout.template_preview(context.material)
@@ -1625,7 +1626,8 @@ class CYCLES_MATERIAL_PT_surface(CyclesButtonsPanel, 
Panel):
 
     @classmethod
     def poll(cls, context):
-        return context.material and CyclesButtonsPanel.poll(context)
+        mat = context.material
+        return mat and (not mat.grease_pencil) and 
CyclesButtonsPanel.poll(context)
 
     def draw(self, context):
         layout = self.layout
@@ -1643,7 +1645,7 @@ class CYCLES_MATERIAL_PT_volume(CyclesButtonsPanel, 
Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        return mat and mat.node_tree and CyclesButtonsPanel.poll(context)
+        return mat and (not mat.grease_pencil) and mat.node_tree and 
CyclesButtonsPanel.poll(context)
 
     def draw(self, context):
         layout = self.layout
@@ -1661,7 +1663,7 @@ class CYCLES_MATERIAL_PT_displacement(CyclesButtonsPanel, 
Panel):
     @classmethod
     def poll(cls, context):
         mat = context.material
-        return mat and mat.node_tree and CyclesButtonsPanel.poll(context)
+        return mat and (not mat.grease_pencil) and mat.node_tree and 
CyclesButtonsPanel.poll(context)
 
     def draw(self, context):
         layout = self.layout
@@ -1677,7 +1679,8 @@ class CYCLES_MATERIAL_PT_settings(CyclesButtonsPanel, 
Panel):
 
     @classmethod
     def poll(cls, context):
-        return context.material and CyclesButtonsPanel.poll(context)
+        mat = context.material
+        return mat and (not mat.grease_pencil) and 
CyclesButtonsPanel.poll(context)
 
     @staticmethod
     def draw_shared(self, mat):
diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py 
b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index a5e526ed670..c6626b555fb 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -35,7 +35,7 @@ class DataButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        return context.gpencil_data
+        return context.gpencil
 
 
 class ObjectButtonsPanel:
@@ -45,7 +45,8 @@ class ObjectButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        return context.object and context.object.type == 'GPENCIL'
+        ob = context.object
+        return ob and ob.type == 'GPENCIL'
 
 
 class LayerDataButtonsPanel:
@@ -55,24 +56,28 @@ class LayerDataButtonsPanel:
 
     @classmethod
     def poll(cls, context):
-        return (context.gpencil_data and
-                context.active_gpencil_layer)
+        gpencil = context.gpencil
+        return gpencil and gpencil.layers.active
 
 
 ###############################
 # GP Object Properties Panels and Helper Classes
 
-class DATA_PT_gpencil(DataButtonsPanel, Panel):
+class DATA_PT_context_gpencil(DataButtonsPanel, Panel):
     bl_label = ""
     bl_options = {'HIDE_HEADER'}
 
     def draw(self, context):
         layout = self.layout
 
-        # Grease Pencil data selector
-        gpd_owner = context.gpencil_data_owner
+        ob = context.object
+        gpencil = context.gpencil
+        space = context.space_data
 
-        layout.template_ID(gpd_owner, "data")
+        if ob:
+            layout.template_ID(ob, "data")
+        else:
+            layout.template_ID(space, "pin_id")
 
 
 class GPENCIL_MT_layer_specials(Menu):
@@ -80,7 +85,7 @@ class GPENCIL_MT_layer_specials(Menu):
 
     def draw(self, context):
         layout = self.layout
-        gpd = context.gpencil_data
+        gpd = context.gpencil
 
         layout.operator("gpencil.layer_duplicate", icon='ADD')  # XXX: needs a 
dedicated icon
 
@@ -103,23 +108,15 @@ class GPENCIL_MT_layer_specials(Menu):
         layout.menu("VIEW3D_MT_gpencil_copy_layer")
 
 
-class DATA_PT_gpencil_datapanel(Panel):
-    bl_space_type = 'PROPERTIES'
-    bl_region_type = 'WINDOW'
-    bl_context = "data"
+class DATA_PT_gpencil_layers(DataButtonsPanel, Panel):
     bl_label = "Layers"
 
-    @classmethod
-    def poll(cls, context):
-        return context.gpencil_data
-
-    @staticmethod
     def draw(self, context):
         layout = self.layout
         #layout.use_property_split = True
         layout.use_property_decorate = False
 
-        gpd = context.gpencil_data
+        gpd = context.gpencil
 
         # Grease Pencil data...
         if (gpd is None) or (not gpd.layers):
@@ -136,7 +133,8 @@ class DATA_PT_gpencil_datapanel(Panel):
         col.template_list("GPENCIL_UL_layer", "", gpd, "layers", gpd.layers, 
"active_index",
                           rows=layer_rows, sort_reverse=True, sort_lock=True)
 
-        gpl = context.active_gpencil_layer
+        gpl = gpd.layers.active
+
         if gpl:
             srow = col.row(align=True)
             srow.prop(gpl, "blend_mode", text="Blend")
@@ -172,12 +170,9 @@ class DATA_PT_gpencil_datapanel(Panel):
                 sub.operator("gpencil.layer_isolate", icon='RESTRICT_VIEW_ON', 
text="").affect_visibility = True
 
 
-class DATA_PT_gpencil_layer_optionpanel(LayerDataButtonsPanel, Panel):
-    bl_space_type = 'PROPERTIES'
-    bl_region_type = 'WINDOW'
-    bl_context = "data"
+class DATA_PT_gpencil_layer_adjustments(LayerDataButtonsPanel, Panel):
     bl_label = "Adjustments"
-    bl_parent_id = 'DATA_PT_gpencil_datapanel'
+    bl_parent_id = 'DATA_PT_gpencil_layers'
     bl_options = {'DEFAULT_CLOSED'}
 
     def draw(self, context):
@@ -185,7 +180,8 @@ class 
DATA_PT_gpencil_layer_optionpanel(LayerDataButtonsPanel, Panel):
         layout.use_property_split = True
         scene = context.scene
 
-        gpl = context.active_gpencil_layer
+        gpd = context.gpencil
+        gpl = gpd.layers.active
         layout.active = not gpl.lock
 
         # Layer options
@@ -209,12 +205,9 @@ class 
DATA_PT_gpencil_layer_optionpanel(LayerDataButtonsPanel, Panel):
         col.prop(gpl, "lock_material")
 
 
-class DATA_PT_gpencil_parentpanel(LayerDataButtonsPanel, Panel):
-    bl_space_type = 'PROPERTIES'
-    bl_region_type = 'WINDOW'
-    bl_context = "data"
+class DATA_PT_gpencil_layer_relations(LayerDataButtonsPanel, Panel):
     bl_label = "Relations"
-    bl_parent_id = 'DATA_PT_gpencil_datapanel'
+    bl_parent_id = 'DATA_PT_gpencil_layers'
     bl_options = {'DEFAULT_CLOSED'}
 
     def draw(self, context):
@@ -222,7 +215,9 @@ class DATA_PT_gpencil_parentpanel(LayerDataButtonsPanel, 
Panel):
         layout.use_property_split = True
         layout.use_property_decorate = False
 
-        gpl = context.active_gpencil_layer
+        gpd = context.gpencil
+        gpl = gpd.layers.active
+
         col = layout.column()
         col.active = not gpl.lock
         col.prop(gpl, "parent")
@@ -233,19 +228,12 @@ class DATA_PT_gpencil_parentpanel(LayerDataButtonsPanel, 
Panel):
             col.prop_search(gpl, "parent_bone", parent.data, "bones", 
text="Bone")
 
 
-class DATA_PT_gpencil_onionpanel(Panel):
-    bl_space_type = 'PROPERTIES'
-    bl_region_type = 'WINDOW'
-    bl_context = "data"
+class DATA_PT_gpencil_onion_skinning(DataButtonsPanel, Panel):
     bl_label = "Onion Skinning"
     bl_options = {'DEFAULT_CLOSED'}
 
-    @classmethod
-    def poll(cls, context):
-        return bool(context.active_gpencil_layer)
-
     def draw(self, context):
-        gpd = context.gpencil_data
+        gpd = context.gpencil
 
         layout = self.layout
         layout.use_property_split = True
@@ -268,21 +256,18 @@ class DATA_PT_gpencil_onionpanel(Panel):
             col.prop(gpd, "ghost_after_range", text="Keyframes After")
 
 
-class DATA_PT_gpencil_onionpanel_custom_colors(Panel):
-    bl_space_type = 'PROPERTIES'
-    bl_region_type = 'WINDOW'
-    bl_context = "data"
-    bl_parent_id = "DATA_PT_gpencil_onionpanel"
+class DATA_PT_gpencil_onion_skinning_custom_colors(DataButtonsPanel, Panel):
+    bl_parent_id = "DATA_PT_gpencil_onion_skinning"
     bl_label = "Custom Colors"
     bl_options = {'DEFAULT_CLOSED'}
 
     def draw_header(self, context):
-        gpd = context.gpencil_data
+        gpd = context.gpencil
 
         self.layout.prop(gpd, "use_ghost_custom_colors", text="")
 
     def draw(self, context):
-        gpd = context.gpencil_data
+        gpd = context.gpencil
 
         layout = self.layout
         layout.use_property_split = True
@@ -292,16 +277,13 @@ class DATA_PT_gpencil_onionpanel_custom_colors(Panel):
         layout.prop(gpd, "after_color", text="After")
 
 
-class DATA_PT_gpencil_onionpanel_display(Panel):
-    bl_space_type = 'PROPERTIES'
-    bl_region_type = 'WINDOW'
-    bl_context = "data"
-    bl_parent_id = "DATA_PT_gpencil_onionpanel"
+class DATA_PT_gpencil_onion_skinning_display(DataButtonsPanel, Panel):
+    bl_parent_id = "DATA_PT_gpencil_onion_skinning"
     bl_label = "Display"
     bl_options = {'DEFAULT_CLOSED'}
 
     def draw(self, context):
-        gpd = context.gpencil_data
+        gpd = context.gpencil
 
         layout = self.layout
         layout.use_property_split = True
@@ -354,10 +336,7 @@ class GPENCIL_UL_vgroups(UIList):
             layout.label(text="", icon_value=icon)
 
 
-class DATA_PT_gpencil_vertexpanel(ObjectButtonsPanel, Panel):
-    bl_space_type = 'PROPERTIES'
-    bl_region_type = 'WINDOW'
-    bl_context = "data"
+class DATA_PT_gpencil_vertex_groups(ObjectButtonsPanel, Panel):
     bl_label = "Vertex Groups"
     bl_options = {'DEFAULT_CLOSED'}
 
@@ -402,12 +381,13 @@ class DATA_PT_gpencil_strokes(DataButtonsPanel, Panel):
         layout.use_property_decorate = False
 
         ob = context.object
-
-        gpd = context.gpencil_data
+        gpd = context.gpencil
 
         col = layout.column(align=True)
         col.prop(gpd, "stroke_depth_order")
-     

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to