[Bf-blender-cvs] [b611d03952b] greasepencil-object: UI: New parent layer panel

Antonio Vazquez noreply at git.blender.org
Wed Jul 12 16:19:49 CEST 2017


Commit: b611d03952bb5055d430a43f8a2267da31a26043
Author: Antonio Vazquez
Date:   Wed Jul 12 16:19:42 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBb611d03952bb5055d430a43f8a2267da31a26043

UI: New parent layer panel

Move these options to new panel and reorganize layer options

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

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 5e430a22a86..53dc43cb747 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -21,7 +21,8 @@ import bpy
 from bpy.types import Panel
 from bl_ui.properties_grease_pencil_common import (
         GreasePencilDataPanel,
-        GreasePencilOnionPanel
+        GreasePencilOnionPanel,
+        GreasePencilParentLayerPanel
         )
 
 
@@ -67,12 +68,22 @@ class DATA_PT_gpencil_onionpanel(GreasePencilOnionPanel, Panel):
     # NOTE: this is just a wrapper around the generic GP Panel
 
 
+class DATA_PT_gpencilparentpanel(GreasePencilParentLayerPanel, Panel):
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "data"
+    bl_label = "Parent Layer"
+
+    # NOTE: this is just a wrapper around the generic GP Panel
+
+
 class DATA_PT_gpencil_display(DataButtonsPanel, Panel):
     bl_label = "Display"
 
     def draw(self, context):
         layout = self.layout
         ob = context.object
+        ts = context.tool_settings
         layout.prop(ob, "empty_draw_size", text="Size")
 
         gpd = context.gpencil_data
@@ -89,12 +100,16 @@ class DATA_PT_gpencil_display(DataButtonsPanel, Panel):
             row = layout.row()
             row.prop(gpl, "show_points")
 
+            if ts.grease_pencil_source == 'OBJECT' and context.space_data.type in ('VIEW_3D', 'PROPERTIES'):
+                row = layout.row(align=True)
+                row.prop(gpl, "use_stroke_location")
 
 
 classes = (
     DATA_PT_gpencil,
     DATA_PT_gpencil_datapanel,
     DATA_PT_gpencil_onionpanel,
+    DATA_PT_gpencilparentpanel,
     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 ffb00232589..c80bb8245c7 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -1029,10 +1029,6 @@ class GreasePencilDataPanel:
         row = layout.row(align=True)
         row.prop(gpl, "opacity", text="Opacity", slider=True)
 
-        if ts.grease_pencil_source == 'OBJECT' and context.space_data.type in ('VIEW_3D', 'PROPERTIES'):
-            row = layout.row(align=True)
-            row.prop(gpl, "use_stroke_location")
-
         # Layer options
         if context.space_data.type not in ('VIEW_3D', 'PROPERTIES'):
             split = layout.split(percentage=0.5)
@@ -1043,34 +1039,22 @@ class GreasePencilDataPanel:
         if context.space_data.type in ('VIEW_3D', 'PROPERTIES'):
             split = layout.split(percentage=0.5)
         else:
-            split = layout.column()  # parenting is not available in 2D editors...
+            split = layout.column()
         split.active = not gpl.lock
 
         # Offsets - Color Tint
         col = split.column()
         subcol = col.column(align=True)
-        subcol.label("Tint")
         subcol.enabled = not gpl.lock
         subcol.prop(gpl, "tint_color", text="")
         subcol.prop(gpl, "tint_factor", text="Factor", slider=True)
 
         # Offsets - Thickness
+        col = split.column(align=True)
         row = col.row(align=True)
         row.prop(gpl, "line_change", text="Thickness Change", slider=True)
         row.operator("gpencil.stroke_apply_thickness", icon='STYLUS_PRESSURE', text="")
 
-        # Parenting 
-        if context.space_data.type in ('VIEW_3D', 'PROPERTIES'):
-            col = split.column(align=True)
-            col.label(text="Parent:")
-            col.prop(gpl, "parent", text="")
-
-            sub = col.column()
-            sub.prop(gpl, "parent_type", text="")
-            parent = gpl.parent
-            if parent and gpl.parent_type == 'BONE' and parent.type == 'ARMATURE':
-                sub.prop_search(gpl, "parent_bone", parent.data, "bones", text="")
-
         layout.separator()
 
         # Full-Row - Frame Locking (and Delete Frame)
@@ -1148,6 +1132,53 @@ class GreasePencilOnionPanel:
         sub.prop(gpl, "ghost_after_range", text="After")
 
 
+class GreasePencilParentLayerPanel:
+    bl_label = "Parent Layer"
+    bl_region_type = 'UI'
+
+    @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 ts.grease_pencil_source == 'OBJECT':
+                if context.space_data.context != 'DATA':
+                    return False
+
+            if context.space_data.context == 'DATA':
+                if context.object.type != 'GPENCIL':
+                    return False
+                else:
+                    if context.object.grease_pencil != context.gpencil_data:
+                        return False
+
+        gpl = context.active_gpencil_layer
+        if gpl is None:
+            return False;
+
+        return True
+
+    @staticmethod
+    def draw(self, context):
+        layout = self.layout
+        gpl = context.active_gpencil_layer
+        row = layout.row()
+
+        col = row.column(align=True)
+        col.active = not gpl.lock
+        col.label(text="Parent:")
+        col.prop(gpl, "parent", text="")
+
+        sub = col.column()
+        sub.prop(gpl, "parent_type", text="")
+        parent = gpl.parent
+        if parent and gpl.parent_type == 'BONE' and parent.type == 'ARMATURE':
+            sub.prop_search(gpl, "parent_bone", parent.data, "bones", text="")
+
+
 class GreasePencilPaletteColorPanel:
     # subclass must set
     bl_label = "Grease Pencil Colors"




More information about the Bf-blender-cvs mailing list