[Bf-blender-cvs] [ce1b57227da] blender2.8: GP: Add new popover with layers panel

Antonioya noreply at git.blender.org
Thu Sep 20 18:50:25 CEST 2018


Commit: ce1b57227dad714723b68174e44a81aa775b08b9
Author: Antonioya
Date:   Thu Sep 20 17:54:11 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBce1b57227dad714723b68174e44a81aa775b08b9

GP: Add new popover with layers panel

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

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_topbar.py

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

diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index cc0baeb3f35..5a8fe41a483 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -22,6 +22,7 @@ from bpy.types import Menu, Panel, UIList
 from rna_prop_ui import PropertyPanel
 from .properties_grease_pencil_common import (
     GreasePencilOnionPanel,
+    GPENCIL_UL_layer,
 )
 
 ###############################
@@ -66,39 +67,6 @@ class DATA_PT_gpencil(DataButtonsPanel, Panel):
         layout.template_ID(gpd_owner, "data")
 
 
-class GPENCIL_UL_layer(UIList):
-    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
-        # assert(isinstance(item, bpy.types.GPencilLayer)
-        gpl = item
-        gpd = context.gpencil_data
-
-        if self.layout_type in {'DEFAULT', 'COMPACT'}:
-            if gpl.lock:
-                layout.active = False
-
-            row = layout.row(align=True)
-            if gpl.is_parented:
-                icon = 'BONE_DATA'
-            else:
-                icon = 'BLANK1'
-
-            row.label(text="", icon=icon)
-            row.prop(gpl, "info", text="", emboss=False)
-
-            row = layout.row(align=True)
-            row.prop(gpl, "lock", text="", emboss=False)
-            row.prop(gpl, "hide", text="", emboss=False)
-            row.prop(gpl, "unlock_color", text="", emboss=False)
-            if gpl.use_onion_skinning is False:
-                icon = 'GHOST_DISABLED'
-            else:
-                icon = 'GHOST_ENABLED'
-            subrow = row.row(align=True)
-            subrow.prop(gpl, "use_onion_skinning", text="", icon=icon, emboss=False)
-            subrow.active = gpd.use_onion_skinning
-        elif self.layout_type == 'GRID':
-            layout.alignment = 'CENTER'
-            layout.label(text="", icon_value=icon)
 
 
 class GPENCIL_MT_layer_specials(Menu):
@@ -397,7 +365,6 @@ classes = (
     DATA_PT_gpencil_display,
     DATA_PT_custom_props_gpencil,
 
-    GPENCIL_UL_layer,
     GPENCIL_UL_vgroups,
 
     GPENCIL_MT_layer_specials,
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 0f520b05256..0cb8b4b5d6e 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -805,6 +805,41 @@ class GreasePencilToolsPanel:
         gpencil_stroke_placement_settings(context, layout)
 
 
+class GPENCIL_UL_layer(UIList):
+    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
+        # assert(isinstance(item, bpy.types.GPencilLayer)
+        gpl = item
+        gpd = context.gpencil_data
+
+        if self.layout_type in {'DEFAULT', 'COMPACT'}:
+            if gpl.lock:
+                layout.active = False
+
+            row = layout.row(align=True)
+            if gpl.is_parented:
+                icon = 'BONE_DATA'
+            else:
+                icon = 'BLANK1'
+
+            row.label(text="", icon=icon)
+            row.prop(gpl, "info", text="", emboss=False)
+
+            row = layout.row(align=True)
+            row.prop(gpl, "lock", text="", emboss=False)
+            row.prop(gpl, "hide", text="", emboss=False)
+            row.prop(gpl, "unlock_color", text="", emboss=False)
+            if gpl.use_onion_skinning is False:
+                icon = 'GHOST_DISABLED'
+            else:
+                icon = 'GHOST_ENABLED'
+            subrow = row.row(align=True)
+            subrow.prop(gpl, "use_onion_skinning", text="", icon=icon, emboss=False)
+            subrow.active = gpd.use_onion_skinning
+        elif self.layout_type == 'GRID':
+            layout.alignment = 'CENTER'
+            layout.label(text="", icon_value=icon)
+
+
 classes = (
     GPENCIL_MT_pie_tool_palette,
     GPENCIL_MT_pie_settings_palette,
@@ -819,6 +854,7 @@ classes = (
     GPENCIL_MT_gpencil_draw_delete,
 
     GPENCIL_UL_annotation_layer,
+    GPENCIL_UL_layer,
 )
 
 if __name__ == "__main__":  # only for live edit.
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 9347e849627..88af0c53c3d 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -19,7 +19,9 @@
 # <pep8 compliant>
 import bpy
 from bpy.types import Header, Menu, Panel
-
+from .properties_grease_pencil_common import (
+    GPENCIL_UL_layer,
+)
 
 class TOPBAR_HT_upper_bar(Header):
     bl_space_type = 'TOPBAR'
@@ -147,6 +149,15 @@ class TOPBAR_HT_lower_bar(Header):
         # we just want them not to be confused with tool options.
         mode = context.mode
 
+        # grease pencil layer
+        gpl = context.active_gpencil_layer
+        if gpl and gpl.info is not None:
+            txt = gpl.info
+            if len(txt) > 10:
+                txt = txt[:7] + '..' + txt[-2:]
+        else:
+            txt = ""
+
         if mode == 'SCULPT':
             layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".sculpt_mode", category="")
         elif mode == 'PAINT_VERTEX':
@@ -173,7 +184,19 @@ class TOPBAR_HT_lower_bar(Header):
             layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".particlemode", category="")
         elif mode == 'OBJECT':
             layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".objectmode", category="")
+        elif mode in ('GPENCIL_EDIT', 'GPENCIL_WEIGHT'):
+            layout.label(text="Layer:")
+            layout.popover(
+                panel="TOPBAR_PT_gpencil_layers",
+                text=txt
+            )
         elif mode == 'GPENCIL_PAINT':
+            layout.label(text="Layer:")
+            layout.popover(
+                panel="TOPBAR_PT_gpencil_layers",
+                text=txt
+            )
+
             layout.prop(context.tool_settings, "gpencil_stroke_placement_view3d", text='')
             if context.tool_settings.gpencil_stroke_placement_view3d in ('ORIGIN', 'CURSOR'):
                 layout.prop(context.tool_settings.gpencil_sculpt, "lockaxis", text='')
@@ -182,6 +205,11 @@ class TOPBAR_HT_lower_bar(Header):
             layout.prop(context.tool_settings, "use_gpencil_additive_drawing", text="", icon='FREEZE')
 
         elif mode == 'GPENCIL_SCULPT':
+            layout.label(text="Layer:")
+            layout.popover(
+                panel="TOPBAR_PT_gpencil_layers",
+                text=txt
+            )
             layout.prop(context.tool_settings.gpencil_sculpt, "lockaxis", text='')
 
 
@@ -262,6 +290,71 @@ class _draw_left_context_mode:
                     layout.prop(brush, "use_puff_volume")
 
 
+class TOPBAR_PT_gpencil_layers(Panel):
+    bl_space_type = 'VIEW_3D'
+    bl_region_type = 'HEADER'
+    bl_label = "Layers"
+
+    @classmethod
+    def poll(cls, context):
+        if context.gpencil_data is None:
+            return False
+
+        ob = context.object
+        if ob is not None and ob.type == 'GPENCIL':
+            return True
+
+        return False
+
+    @staticmethod
+    def draw(self, context):
+        layout = self.layout
+        gpd = context.gpencil_data
+
+        # Grease Pencil data...
+        if (gpd is None) or (not gpd.layers):
+            layout.operator("gpencil.layer_add", text="New Layer")
+        else:
+            self.draw_layers(context, layout, gpd)
+
+    def draw_layers(self, context, layout, gpd):
+        row = layout.row()
+
+        col = row.column()
+        if len(gpd.layers) >= 2:
+            layer_rows = 5
+        else:
+            layer_rows = 2
+        col.template_list("GPENCIL_UL_layer", "", gpd, "layers", gpd.layers, "active_index", rows=layer_rows)
+
+        col = row.column()
+
+        sub = col.column(align=True)
+        sub.operator("gpencil.layer_add", icon='ZOOMIN', text="")
+        sub.operator("gpencil.layer_remove", icon='ZOOMOUT', text="")
+
+        gpl = context.active_gpencil_layer
+        if gpl:
+            sub.menu("GPENCIL_MT_layer_specials", icon='DOWNARROW_HLT', text="")
+
+            if len(gpd.layers) > 1:
+                col.separator()
+
+                sub = col.column(align=True)
+                sub.operator("gpencil.layer_move", icon='TRIA_UP', text="").type = 'UP'
+                sub.operator("gpencil.layer_move", icon='TRIA_DOWN', text="").type = 'DOWN'
+
+                col.separator()
+
+                sub = col.column(align=True)
+                sub.operator("gpencil.layer_isolate", icon='LOCKED', text="").affect_visibility = False
+                sub.operator("gpencil.layer_isolate", icon='HIDE_OFF', text="").affect_visibility = True
+
+        row = layout.row(align=True)
+        if gpl:
+            row.prop(gpl, "opacity", text="Opacity", slider=True)
+
+
 class TOPBAR_MT_editor_menus(Menu):
     bl_idname = "TOPBAR_MT_editor_menus"
     bl_label = ""
@@ -756,6 +849,7 @@ classes = (
     TOPBAR_MT_window,
     TOPBAR_MT_help,
     TOPBAR_PT_active_tool,
+    TOPBAR_PT_gpencil_layers,
 )
 
 if __name__ == "__main__":  # only for live edit.



More information about the Bf-blender-cvs mailing list