[Bf-blender-cvs] [c52f6b11c0f] greasepencil-object: GP Properties: Separate onion skinning for datablock + per-layer override into separate panels

Joshua Leung noreply at git.blender.org
Tue May 1 19:13:07 CEST 2018


Commit: c52f6b11c0fb997a0bcee78f05cbf8f45e14d868
Author: Joshua Leung
Date:   Tue May 1 19:00:28 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rBc52f6b11c0fb997a0bcee78f05cbf8f45e14d868

GP Properties: Separate onion skinning for datablock + per-layer override into separate panels

The panel layouts are still a mess, but at least there's less code duplication
and weirdness now, with everything taking advantage of more conventions here.

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

M	release/scripts/startup/bl_ui/properties_data_gpencil.py
M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py

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

diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index 9c93fffbf53..70b9ce84692 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -75,7 +75,7 @@ class DATA_PT_gpencil_datapanel(GreasePencilDataPanel, Panel):
     # NOTE: this is just a wrapper around the generic GP Panel
 
 
-class DATA_PT_gpencil_layeroptionpanel(LayerDataButtonsPanel, Panel):
+class DATA_PT_gpencil_layer_optionpanel(LayerDataButtonsPanel, Panel):
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
     bl_context = "data"
@@ -112,14 +112,48 @@ class DATA_PT_gpencil_layeroptionpanel(LayerDataButtonsPanel, Panel):
         row.prop(gpl, "use_stroke_location", text="Draw on Stroke Location")
 
 
-class DATA_PT_gpencil_onionpanel(GreasePencilOnionPanel, Panel):
+class DATA_PT_gpencil_onionpanel(Panel):
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
     bl_context = "data"
     bl_label = "Onion Skinning"
     bl_options = {'DEFAULT_CLOSED'}
 
-    # NOTE: this is just a wrapper around the generic GP Panel
+    @staticmethod
+    def draw_header(self, context):
+        self.layout.prop(context.gpencil_data, "use_onion_skinning", text="")
+
+    def draw(self, context):
+        gpd = context.gpencil_data
+
+        layout = self.layout
+        layout.enabled = gpd.use_onion_skinning
+
+        GreasePencilOnionPanel.draw_settings(layout, gpd)
+
+
+class DATA_PT_gpencil_layer_onionpanel(Panel):
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "data"
+    bl_label = "Onion Skinning (Layer Override)"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        return bool(context.active_gpencil_layer)
+
+    def draw_header(self, context):
+        self.layout.prop(context.active_gpencil_layer, "override_onion", text="")
+
+    def draw(self, context):
+        gpd = context.gpencil_data
+        gpl = context.active_gpencil_layer
+
+        layout = self.layout
+        layout.enabled = gpd.use_onion_skinning and gpl.override_onion
+
+        GreasePencilOnionPanel.draw_settings(layout, gpl)
 
 
 class DATA_PT_gpencil_parentpanel(LayerDataButtonsPanel, Panel):
@@ -276,7 +310,8 @@ classes = (
     DATA_PT_gpencil,
     DATA_PT_gpencil_datapanel,
     DATA_PT_gpencil_onionpanel,
-    DATA_PT_gpencil_layeroptionpanel,
+    DATA_PT_gpencil_layer_onionpanel,
+    DATA_PT_gpencil_layer_optionpanel,
     DATA_PT_gpencil_vertexpanel,
     DATA_PT_gpencil_parentpanel,
     DATA_PT_gpencil_display,
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 1c18bd8703b..8b47561c58d 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -905,134 +905,49 @@ class GreasePencilDataPanel:
 
 
 class GreasePencilOnionPanel:
-    bl_label = "Onion Skinning"
-    bl_region_type = 'UI'
-    bl_options = {'DEFAULT_CLOSED'}
-
-    @classmethod
-    def poll(cls, context):
-        ts = context.scene.tool_settings
-
-        if context.gpencil_data is None:
-            return False
-
-        if context.space_data.type in ('VIEW_3D', 'PROPERTIES'):
-            if context.space_data.context == 'DATA':
-                if context.object.type != 'GPENCIL':
-                    return False
-
-        gpl = context.active_gpencil_layer
-        if gpl is None:
-            return False;
-
-        return True
-
     @staticmethod
-    def draw(self, context):
-        layout = self.layout
-        gpd = context.gpencil_data
-        gpl = context.active_gpencil_layer
-
-        col = layout.column(align=True)
+    def draw_settings(layout, gp):
+        col = layout.column(align=False)
+        col.row().prop(gp, "onion_mode", expand=True)
 
         row = col.row()
-        row.prop(gpd, "use_onion_skinning")
+        row.prop(gp, "onion_factor", text="Opacity", slider=True)
         sub = row.row(align=True)
-        icon = 'RESTRICT_RENDER_OFF' if gpd.use_ghosts_always else 'RESTRICT_RENDER_ON'
-        sub.prop(gpd, "use_ghosts_always", text="", icon=icon)
-        sub.prop(gpd, "use_ghost_custom_colors", text="", icon='COLOR')
-
-        row = layout.row(align=True)
-        row.active = gpd.use_onion_skinning
-        row.prop(gpd, "onion_mode", expand=True)
-
-        row = layout.row(align=True)
-        row.active = gpd.use_onion_skinning
-        row.prop(gpd, "onion_factor", text="Opacity", slider=True)
+        icon = 'RESTRICT_RENDER_OFF' if gp.use_ghosts_always else 'RESTRICT_RENDER_ON'
+        sub.prop(gp, "use_ghosts_always", text="", icon=icon)
+        sub.prop(gp, "use_ghost_custom_colors", text="", icon='COLOR')
 
         split = layout.split(percentage=0.5)
-        split.active = gpd.use_onion_skinning
 
         # - Before Frames
         sub = split.column(align=True)
         row = sub.row(align=True)
-        row.active = gpd.use_ghost_custom_colors
-        row.prop(gpd, "before_color", text="")
+        row.active = gp.use_ghost_custom_colors
+        row.prop(gp, "before_color", text="")
 
         row = sub.row(align=True)
-        row.active = gpd.onion_mode in ('ABSOLUTE', 'RELATIVE')
-        row.prop(gpd, "ghost_before_range", text="Before")
+        row.active = gp.onion_mode in ('ABSOLUTE', 'RELATIVE')
+        row.prop(gp, "ghost_before_range", text="Before")
 
         # - After Frames
         sub = split.column(align=True)
         row = sub.row(align=True)
-        row.active = gpd.use_ghost_custom_colors
-        row.prop(gpd, "after_color", text="")
+        row.active = gp.use_ghost_custom_colors
+        row.prop(gp, "after_color", text="")
 
         row = sub.row(align=True)
-        row.active = gpd.onion_mode in ('ABSOLUTE', 'RELATIVE')
-        row.prop(gpd, "ghost_after_range", text="After")
+        row.active = gp.onion_mode in ('ABSOLUTE', 'RELATIVE')
+        row.prop(gp, "ghost_after_range", text="After")
 
         # - fade and loop
         row = layout.row()
-        row.active = gpd.use_onion_skinning
-        row.prop(gpd, "use_onion_fade", text="Fade")
-        subrow = row.row()
-        subrow.active = gpd.onion_mode in ('RELATIVE', 'SELECTED')
-        subrow.prop(gpd, "use_onion_loop", text="Loop")
-
-        # -----------------
-        # layer override
-        # -----------------
-        ovr = gpd.use_onion_skinning and gpl.override_onion
-        layout.separator()
-        box = layout.box()
-        col = box.column(align=True)
-        col.active = gpd.use_onion_skinning
+        row.active = gp.use_onion_skinning
+        row.prop(gp, "use_onion_fade", text="Fade")
+        if hasattr(gp, "use_onion_loop"): # XXX
+            subrow = row.row()
+            subrow.active = gp.onion_mode in ('RELATIVE', 'SELECTED')
+            subrow.prop(gp, "use_onion_loop", text="Loop")
 
-        row = col.row()
-        row.prop(gpl, "override_onion", text="Layer Override")
-        if gpl.override_onion:
-            sub = row.row(align=True)
-            icon = 'RESTRICT_RENDER_OFF' if gpd.use_ghosts_always else 'RESTRICT_RENDER_ON'
-            sub.prop(gpl, "use_ghosts_always", text="", icon=icon)
-            sub.prop(gpl, "use_ghost_custom_colors", text="", icon='COLOR')
-
-            row = box.row(align=True)
-            row.active = ovr
-            row.prop(gpl, "onion_mode", expand=True)
-
-            split = box.split(percentage=0.5)
-            split.active = ovr
-
-            # - Before Frames
-            sub = split.column(align=True)
-            row = sub.row(align=True)
-            row.active = gpl.use_ghost_custom_colors
-            
-            row.prop(gpl, "before_color", text="")
-            row = sub.row(align=True)
-            row.active = gpl.onion_mode in ('ABSOLUTE', 'RELATIVE')
-            row.prop(gpl, "ghost_before_range", text="Before")
-
-            # - After Frames
-            sub = split.column(align=True)
-            row = sub.row(align=True)
-            row.active = gpl.use_ghost_custom_colors
-            row.prop(gpl, "after_color", text="")
-            
-            row = sub.row(align=True)
-            row.active = gpl.onion_mode in ('ABSOLUTE', 'RELATIVE')
-            row.prop(gpl, "ghost_after_range", text="After")
-
-            # - Fade
-            split = box.split(percentage=0.5)
-            split.active = ovr
-            sub = split.column(align=True)
-            sub.prop(gpl, "use_onion_fade", text="Fade")
-
-            sub = split.column(align=True)
-            sub.prop(gpl, "onion_factor", text="Opacity", slider=True)
 
 ###############################



More information about the Bf-blender-cvs mailing list