Commit: fdb4dc34131674e2e9bd55f05266aa0f47ce6a68
Author: Antonio Vazquez
Date:   Tue Dec 3 11:20:27 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rBfdb4dc34131674e2e9bd55f05266aa0f47ce6a68

GPencil: Remove duplicate panel code for layer properties

Now it uses a parent class for both panels.

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

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/space_dopesheet.py

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

diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py 
b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index 5e7fc368fbc..fde5b0272ce 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -21,6 +21,11 @@ import bpy
 from bpy.types import Menu, Panel, UIList
 from rna_prop_ui import PropertyPanel
 
+from bl_ui.properties_grease_pencil_common import (
+    GreasePencilLayerAdjustmentsPanel,
+    GreasePencilLayerRelationsPanel,
+    GreasePencilLayerDisplayPanel,
+)
 
 ###############################
 # Base-Classes (for shared stuff - e.g. poll, attributes, etc.)
@@ -173,87 +178,23 @@ class DATA_PT_gpencil_layers(DataButtonsPanel, Panel):
             col.prop(gpl, "opacity", text="Opacity", slider=True)
 
 
-class DATA_PT_gpencil_layer_adjustments(LayerDataButtonsPanel, Panel):
+class DATA_PT_gpencil_layer_adjustments(LayerDataButtonsPanel, 
GreasePencilLayerAdjustmentsPanel, Panel):
     bl_label = "Adjustments"
     bl_parent_id = 'DATA_PT_gpencil_layers'
     bl_options = {'DEFAULT_CLOSED'}
 
-    def draw(self, context):
-        layout = self.layout
-        layout.use_property_split = True
-        scene = context.scene
-
-        gpd = context.gpencil
-        gpl = gpd.layers.active
-        layout.active = not gpl.lock
-
-        # Layer options
-        # Offsets - Color Tint
-        layout.enabled = not gpl.lock
-        col = layout.column(align=True)
-        col.prop(gpl, "tint_color")
-        col.prop(gpl, "tint_factor", text="Factor", slider=True)
-
-        # Vertex Paint Opacity
-        col = layout.row(align=True)
-        col.prop(gpl, "vertex_paint_opacity", text="Vertex Paint Opacity")
-
-        # Offsets - Thickness
-        col = layout.row(align=True)
-        col.prop(gpl, "line_change", text="Stroke Thickness")
-
-        col = layout.row(align=True)
-        col.prop(gpl, "pass_index")
-
-        col = layout.row(align=True)
-        col.prop_search(gpl, "viewlayer_render", scene, "view_layers", 
text="View Layer")
-
-        col = layout.row(align=True)
-        col.prop(gpl, "lock_material")
 
-
-class DATA_PT_gpencil_layer_relations(LayerDataButtonsPanel, Panel):
+class DATA_PT_gpencil_layer_relations(LayerDataButtonsPanel, 
GreasePencilLayerRelationsPanel, Panel):
     bl_label = "Relations"
     bl_parent_id = 'DATA_PT_gpencil_layers'
     bl_options = {'DEFAULT_CLOSED'}
 
-    def draw(self, context):
-        layout = self.layout
-        layout.use_property_split = True
-        layout.use_property_decorate = False
-
-        gpd = context.gpencil
-        gpl = gpd.layers.active
 
-        col = layout.column()
-        col.active = not gpl.lock
-        col.prop(gpl, "parent")
-        col.prop(gpl, "parent_type", text="Type")
-        parent = gpl.parent
-
-        if parent and gpl.parent_type == 'BONE' and parent.type == 'ARMATURE':
-            col.prop_search(gpl, "parent_bone", parent.data, "bones", 
text="Bone")
-
-
-class DATA_PT_gpencil_layer_display(LayerDataButtonsPanel, Panel):
+class DATA_PT_gpencil_layer_display(LayerDataButtonsPanel, 
GreasePencilLayerDisplayPanel, Panel):
     bl_label = "Display"
     bl_parent_id = 'DATA_PT_gpencil_layers'
     bl_options = {'DEFAULT_CLOSED'}
 
-    def draw(self, context):
-        layout = self.layout
-        layout.use_property_split = True
-        layout.use_property_decorate = False
-
-        gpd = context.gpencil
-        gpl = gpd.layers.active
-
-        col = layout.row(align=True)
-        col.prop(gpl, "channel_color")
-
-        col = layout.row(align=True)
-        col.prop(gpl, "use_solo_mode", text="Show Only On Keyframed")
-
 
 class DATA_PT_gpencil_onion_skinning(DataButtonsPanel, Panel):
     bl_label = "Onion Skinning"
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 571944eb65f..45f2e36c936 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -813,6 +813,91 @@ class GreasePencilSimplifyPanel:
         sub.prop(rd, "simplify_gpencil_remove_lines", text="Lines")
 
 
+class GreasePencilLayerAdjustmentsPanel:
+    bl_label = "Adjustments"
+    bl_parent_id = 'DOPESHEET_PT_gpencil_mode'
+    bl_options = {'DEFAULT_CLOSED'}
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        scene = context.scene
+
+        ob = context.object
+        gpd = ob.data
+        gpl = gpd.layers.active
+        layout.active = not gpl.lock
+
+        # Layer options
+        # Offsets - Color Tint
+        layout.enabled = not gpl.lock
+        col = layout.column(align=True)
+        col.prop(gpl, "tint_color")
+        col.prop(gpl, "tint_factor", text="Factor", slider=True)
+
+        # Vertex Paint Opacity
+        col = layout.row(align=True)
+        col.prop(gpl, "vertex_paint_opacity", text="Vertex Paint Opacity")
+
+        # Offsets - Thickness
+        col = layout.row(align=True)
+        col.prop(gpl, "line_change", text="Stroke Thickness")
+
+        col = layout.row(align=True)
+        col.prop(gpl, "pass_index")
+
+        col = layout.row(align=True)
+        col.prop_search(gpl, "viewlayer_render", scene, "view_layers", 
text="View Layer")
+
+        col = layout.row(align=True)
+        col.prop(gpl, "lock_material")
+
+
+class GreasePencilLayerRelationsPanel:
+    bl_label = "Relations"
+    bl_parent_id = 'DOPESHEET_PT_gpencil_mode'
+    bl_options = {'DEFAULT_CLOSED'}
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+
+        ob = context.object
+        gpd = ob.data
+        gpl = gpd.layers.active
+
+        col = layout.column()
+        col.active = not gpl.lock
+        col.prop(gpl, "parent")
+        col.prop(gpl, "parent_type", text="Type")
+        parent = gpl.parent
+
+        if parent and gpl.parent_type == 'BONE' and parent.type == 'ARMATURE':
+            col.prop_search(gpl, "parent_bone", parent.data, "bones", 
text="Bone")
+
+
+class GreasePencilLayerDisplayPanel:
+    bl_label = "Display"
+    bl_parent_id = 'DOPESHEET_PT_gpencil_mode'
+    bl_options = {'DEFAULT_CLOSED'}
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+
+        ob = context.object
+        gpd = ob.data
+        gpl = gpd.layers.active
+
+        col = layout.row(align=True)
+        col.prop(gpl, "channel_color")
+
+        col = layout.row(align=True)
+        col.prop(gpl, "use_solo_mode", text="Show Only On Keyframed")
+
+
 class GreasePencilFlipTintColors(Operator):
     bl_label = "Flip Colors"
     bl_idname = "gpencil.tint_flip"
diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py 
b/release/scripts/startup/bl_ui/space_dopesheet.py
index 08371cf6190..a26261f0e93 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -25,6 +25,12 @@ from bpy.types import (
     Panel,
 )
 
+from bl_ui.properties_grease_pencil_common import (
+    GreasePencilLayerAdjustmentsPanel,
+    GreasePencilLayerRelationsPanel,
+    GreasePencilLayerDisplayPanel,
+)
+
 #######################################
 # DopeSheet Filtering - Header Buttons
 
@@ -672,9 +678,6 @@ class LayersDopeSheetPanel:
 
 
 class DOPESHEET_PT_gpencil_mode(LayersDopeSheetPanel, Panel):
-    # bl_space_type = 'DOPESHEET_EDITOR'
-    # bl_region_type = 'UI'
-    # bl_category = "View"
     bl_label = "Layer"
 
     def draw(self, context):
@@ -692,75 +695,23 @@ class DOPESHEET_PT_gpencil_mode(LayersDopeSheetPanel, 
Panel):
             row = layout.row(align=True)
             row.prop(gpl, "opacity", text="Opacity", slider=True)
 
-            row = layout.row(align=True)
-            row.prop(gpl, "channel_color")
-
-            row = layout.row(align=True)
-            row.prop(gpl, "use_solo_mode", text="Show Only On Keyframed")
-
 
-class DOPESHEET_PT_gpencil_layer_adjustments(LayersDopeSheetPanel, Panel):
+class DOPESHEET_PT_gpencil_layer_adjustments(LayersDopeSheetPanel, 
GreasePencilLayerAdjustmentsPanel, Panel):
     bl_label = "Adjustments"
     bl_parent_id = 'DOPESHEET_PT_gpencil_mode'
     bl_options = {'DEFAULT_CLOSED'}
 
-    def draw(self, context):
-        layout = self.layout
-        layout.use_property_split = True
-        scene = context.scene
-
-        ob = context.object
-        gpd = ob.data
-        gpl = gpd.layers.active
-        layout.active = not gpl.lock
-
-        # Layer options
-        # Offsets - Color Tint
-        layout.enabled = not gpl.lock
-        col = layout.column(align=True)
-        col.prop(gpl, "tint_color")
-        col.prop(gpl, "tint_factor", text="Factor", slider=True)
-
-        # Vertex Paint Opacity
-        col = layout.row(align=True)
-        col.prop(gpl, "vertex_paint_opacity", text="Vertex Paint Opacity")
 
-        # Offsets - Thickness
-        col = layout.row(align=True)
-        col.prop(gpl, "line_change", text="Stroke Thickness")
-
-        col = layout.row(align=True)
-        col.prop(gpl, "pass_index")
-
-        col = layout.row(align=True)
-        col.prop_search(gpl, "viewlayer_render", scene, "view_layers", 
text="View Layer")
-
-        col = layout.row(align=True)
-        col.prop(gpl, "lock_material")
-
-
-class DOPESHEET_PT_gpencil_layer_relations(LayersDopeSheetPanel, Panel):
+class DOPESHEET_PT_gpencil_layer_relations(LayersDopeSheetPanel, 
GreasePencilLayerRelationsPanel, Panel):
     bl_label = "Relations"
     bl_parent_id = 'DOPESHEET_PT_gpencil_mode'
     bl_options = {'DEFAULT_CLOSED'}
 
-    def draw(self, context):
-        layout = self.layout
-        layout.use_property_split = True
-        layout.use_property_decorate = False
-
-        ob = context.object
-        gpd = ob.data
-        gpl = gpd.layers.active
-
-        col = layout.column()
-        col.active = not gpl.lock
-        col.prop(gpl, "parent")
-        col.prop(gpl, "parent_type", text="Type")
-     

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