[Bf-blender-cvs] [119ee390e77] greasepencil-object: UI: New Options panel by layer

Antonio Vazquez noreply at git.blender.org
Wed Jul 12 16:54:05 CEST 2017


Commit: 119ee390e77c5ff075d03ccb852fb9e06a9c734f
Author: Antonio Vazquez
Date:   Wed Jul 12 16:53:52 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB119ee390e77c5ff075d03ccb852fb9e06a9c734f

UI: New Options panel by layer

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

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 53dc43cb747..f6d2ab5f1ef 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -21,6 +21,7 @@ import bpy
 from bpy.types import Panel
 from bl_ui.properties_grease_pencil_common import (
         GreasePencilDataPanel,
+        GreasePencilLayerOptionPanel,
         GreasePencilOnionPanel,
         GreasePencilParentLayerPanel
         )
@@ -59,6 +60,15 @@ class DATA_PT_gpencil_datapanel(GreasePencilDataPanel, Panel):
     # NOTE: this is just a wrapper around the generic GP Panel
 
 
+class DATA_PT_gpencil_layeroptionpanel(GreasePencilLayerOptionPanel, Panel):
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "data"
+    bl_label = "Options"
+
+    # NOTE: this is just a wrapper around the generic GP Panel
+
+
 class DATA_PT_gpencil_onionpanel(GreasePencilOnionPanel, Panel):
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
@@ -83,7 +93,6 @@ class DATA_PT_gpencil_display(DataButtonsPanel, Panel):
     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
@@ -100,14 +109,11 @@ 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_layeroptionpanel,
     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 c80bb8245c7..c4da1545338 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -1021,11 +1021,42 @@ class GreasePencilDataPanel:
                 sub.operator("gpencil.layer_isolate", icon='LOCKED', text="").affect_visibility = False
                 sub.operator("gpencil.layer_isolate", icon='RESTRICT_VIEW_OFF', text="").affect_visibility = True
 
-        if gpl:
-            self.draw_layer(context, layout, gpl)
 
-    def draw_layer(self, context, layout, gpl):
-        ts = context.tool_settings
+class GreasePencilLayerOptionPanel:
+    bl_label = "Options"
+    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
+        ts = context.scene.tool_settings
+
         row = layout.row(align=True)
         row.prop(gpl, "opacity", text="Opacity", slider=True)
 
@@ -1035,11 +1066,7 @@ class GreasePencilDataPanel:
             split.active = not gpl.lock
             split.prop(gpl, "show_points")
 
-        # Offsets + Parenting (where available)
-        if context.space_data.type in ('VIEW_3D', 'PROPERTIES'):
-            split = layout.split(percentage=0.5)
-        else:
-            split = layout.column()
+        split = layout.split(percentage=0.5)
         split.active = not gpl.lock
 
         # Offsets - Color Tint
@@ -1055,6 +1082,10 @@ class GreasePencilDataPanel:
         row.prop(gpl, "line_change", text="Thickness Change", slider=True)
         row.operator("gpencil.stroke_apply_thickness", icon='STYLUS_PRESSURE', text="")
 
+        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", text="Draw on Stroke Location")
+
         layout.separator()
 
         # Full-Row - Frame Locking (and Delete Frame)




More information about the Bf-blender-cvs mailing list