[Bf-blender-cvs] [3c5342649b1] greasepencil-object: Cleanup: Move GP Object specific properties panels to properties_data_gpencil.py

Joshua Leung noreply at git.blender.org
Tue Mar 20 08:14:57 CET 2018


Commit: 3c5342649b131b46c05807c27d12e0a690c85aa8
Author: Joshua Leung
Date:   Tue Mar 20 20:12:37 2018 +1300
Branches: greasepencil-object
https://developer.blender.org/rB3c5342649b131b46c05807c27d12e0a690c85aa8

Cleanup: Move GP Object specific properties panels to properties_data_gpencil.py

Note:
* Layers and Onion Skinning panels haven't been moved yet.
  This is so that we can reconsider what (if any) changes
  need to be made to share common elements between GP Object
  and annotation GP use cases.

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

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 c593cdf55f3..9c93fffbf53 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -18,16 +18,14 @@
 
 # <pep8 compliant>
 import bpy
-from bpy.types import Panel
+from bpy.types import Panel, UIList
 from .properties_grease_pencil_common import (
         GreasePencilDataPanel,
-        GreasePencilLayerOptionPanel,
         GreasePencilOnionPanel,
-        GreasePencilParentLayerPanel,
-        GreasePencilVertexGroupPanel,
-        GreasePencilInfoPanel,
         )
 
+###############################
+# Base-Classes (for shared stuff - e.g. poll, attributes, etc.)
 
 class DataButtonsPanel:
     bl_space_type = 'PROPERTIES'
@@ -37,8 +35,23 @@ class DataButtonsPanel:
     @classmethod
     def poll(cls, context):
         return context.object and context.object.type == 'GPENCIL'
+        
+
+class LayerDataButtonsPanel:
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "data"
+    
+    @classmethod
+    def poll(cls, context):
+        return (context.object and
+                context.object.type == 'GPENCIL' and
+                context.active_gpencil_layer)
 
 
+###############################
+# GP Object Properties Panels and Helper Classes
+
 class DATA_PT_gpencil(DataButtonsPanel, Panel):
     bl_label = ""
     bl_options = {'HIDE_HEADER'}
@@ -62,14 +75,41 @@ 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):
+class DATA_PT_gpencil_layeroptionpanel(LayerDataButtonsPanel, Panel):
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
     bl_context = "data"
     bl_label = "Layer Adjustments"
     bl_options = {'DEFAULT_CLOSED'}
 
-    # NOTE: this is just a wrapper around the generic GP Panel
+    def draw(self, context):
+        layout = self.layout
+        gpl = context.active_gpencil_layer
+        ts = context.scene.tool_settings
+
+        # Layer options
+        split = layout.split(percentage=0.5)
+        split.active = not gpl.lock
+        split.prop(gpl, "show_points")
+
+        split = layout.split(percentage=0.5)
+        split.active = not gpl.lock
+
+        # Offsets - Color Tint
+        col = split.column()
+        subcol = col.column(align=True)
+        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")
+        row.operator("gpencil.stroke_apply_thickness", icon='STYLUS_PRESSURE', text="")
+
+        row = layout.row(align=True)
+        row.prop(gpl, "use_stroke_location", text="Draw on Stroke Location")
 
 
 class DATA_PT_gpencil_onionpanel(GreasePencilOnionPanel, Panel):
@@ -82,32 +122,113 @@ class DATA_PT_gpencil_onionpanel(GreasePencilOnionPanel, Panel):
     # NOTE: this is just a wrapper around the generic GP Panel
 
 
-class DATA_PT_gpencilparentpanel(GreasePencilParentLayerPanel, Panel):
+class DATA_PT_gpencil_parentpanel(LayerDataButtonsPanel, Panel):
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
     bl_context = "data"
     bl_label = "Layer Relations"
     bl_options = {'DEFAULT_CLOSED'}
 
-    # NOTE: this is just a wrapper around the generic GP Panel
+    def draw(self, context):
+        layout = self.layout
+        scene = context.scene
+        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="")
 
-class DATA_PT_gpencilvertexpanel(GreasePencilVertexGroupPanel, Panel):
+        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="")
+
+        row = layout.row()
+        row.label("Render Settings:")
+        row = layout.row(align=True)
+        row.prop_search(gpl, "view_layer", scene, "view_layers", text="View Layer")
+        row.prop(gpl, "invert_view_layer", text="", icon='ARROW_LEFTRIGHT')
+
+
+class GPENCIL_UL_vgroups(UIList):
+    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
+        vgroup = item
+        if self.layout_type in {'DEFAULT', 'COMPACT'}:
+            layout.prop(vgroup, "name", text="", emboss=False, icon_value=icon)
+            # icon = 'LOCKED' if vgroup.lock_weight else 'UNLOCKED'
+            # layout.prop(vgroup, "lock_weight", text="", icon=icon, emboss=False)
+        elif self.layout_type == 'GRID':
+            layout.alignment = 'CENTER'
+            layout.label(text="", icon_value=icon)
+
+
+class DATA_PT_gpencil_vertexpanel(DataButtonsPanel, Panel):
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
     bl_context = "data"
     bl_label = "Vertex Groups"
     bl_options = {'DEFAULT_CLOSED'}
+    
+    def draw(self, context):
+        layout = self.layout
+
+        ob = context.object
+        group = ob.vertex_groups.active
+
+        rows = 2
+        if group:
+            rows = 4
+
+        row = layout.row()
+        row.template_list("GPENCIL_UL_vgroups", "", ob, "vertex_groups", ob.vertex_groups, "active_index", rows=rows)
+
+        col = row.column(align=True)
+        col.operator("object.vertex_group_add", icon='ZOOMIN', text="")
+        col.operator("object.vertex_group_remove", icon='ZOOMOUT', text="").all = False
+
+        if ob.vertex_groups:
+            row = layout.row()
+
+            sub = row.row(align=True)
+            sub.operator("gpencil.vertex_group_assign", text="Assign")
+            sub.operator("gpencil.vertex_group_remove_from", text="Remove")
+
+            sub = row.row(align=True)
+            sub.operator("gpencil.vertex_group_select", text="Select")
+            sub.operator("gpencil.vertex_group_deselect", text="Deselect")
 
+            layout.prop(context.tool_settings, "vertex_group_weight", text="Weight")
 
-class DATA_PT_gpencil_infopanel(GreasePencilInfoPanel, Panel):
+
+class DATA_PT_gpencil_infopanel(DataButtonsPanel, Panel):
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
     bl_context = "data"
     bl_label = "Information"
     bl_options = {'DEFAULT_CLOSED'}
 
-    # NOTE: this is just a wrapper around the generic GP Panel
+    def draw(self, context):
+        layout = self.layout
+        gpd = context.gpencil_data
+
+        split = layout.split(percentage=0.5)
+
+        col = split.column(align=True)
+        col.label("Layers:", icon="LAYER_ACTIVE")
+        col.label("Frames:", icon="LAYER_ACTIVE")
+        col.label("Strokes:", icon="LAYER_ACTIVE")
+        col.label("Points:", icon="LAYER_ACTIVE")
+        col.label("Palettes:", icon="LAYER_ACTIVE")
+
+        col = split.column(align=True)
+        col.label(str(gpd.info_total_layers))
+        col.label(str(gpd.info_total_frames))
+        col.label(str(gpd.info_total_strokes))
+        col.label(str(gpd.info_total_points))
+        col.label(str(gpd.info_total_palettes))
 
 
 class DATA_PT_gpencil_display(DataButtonsPanel, Panel):
@@ -149,15 +270,19 @@ class DATA_PT_gpencil_display(DataButtonsPanel, Panel):
         col.prop(gpd, "show_multiedit_line_only", text="Only Lines in MultiEdit")
 
 
+###############################
+
 classes = (
     DATA_PT_gpencil,
     DATA_PT_gpencil_datapanel,
     DATA_PT_gpencil_onionpanel,
     DATA_PT_gpencil_layeroptionpanel,
-    DATA_PT_gpencilvertexpanel,
-    DATA_PT_gpencilparentpanel,
+    DATA_PT_gpencil_vertexpanel,
+    DATA_PT_gpencil_parentpanel,
     DATA_PT_gpencil_display,
     DATA_PT_gpencil_infopanel,
+
+    GPENCIL_UL_vgroups,
 )
 
 if __name__ == "__main__":  # only for live edit.
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 f943e5612d4..d70f3cfa049 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -914,62 +914,6 @@ class GreasePencilDataPanel:
             row.operator("gpencil.active_frame_delete", text="", icon='X')
 
 
-class GreasePencilLayerOptionPanel:
-    bl_label = "Options"
-    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
-        gpl = context.active_gpencil_layer
-        ts = context.scene.tool_settings
-
-        # Layer options
-        if context.space_data.type not in ('VIEW_3D', 'PROPERTIES'):
-            split = layout.split(percentage=0.5)
-            split.active = not gpl.lock
-            split.prop(gpl, "show_points")
-
-        split = layout.split(percentage=0.5)
-        split.active = not gpl.lock
-
-        # Offsets - Color Tint
-        col = split.column()
-        subcol = col.column(align=True)
-        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")
-        row.operator("gpe

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list