GPencil: Some tweaks to make GPencil UI more compact when there are 0 or 1 layer...
authorJoshua Leung <aligorith@gmail.com>
Thu, 12 Feb 2015 13:24:49 +0000 (02:24 +1300)
committerJoshua Leung <aligorith@gmail.com>
Thu, 12 Feb 2015 13:48:49 +0000 (02:48 +1300)
As brought up in T43595, the Grease Pencil layers list could sometimes end up
taking up too much space when there are no layers. Another issue raised there
was that the up/down buttons are redundant when there is only a single layer.
This commit makes some changes to get these a bit more compact for the case where
you have an empty GPencil datablock left over from previous work.

release/scripts/startup/bl_ui/properties_grease_pencil_common.py

index 9969c568bf967dd93e59289a3b35241725d02c56..5b5a7648d837cbc9a9a54f49b55118dfccf1c03f 100644 (file)
@@ -361,7 +361,11 @@ class GreasePencilDataPanel:
         row = layout.row()
 
         col = row.column()
-        col.template_list("GPENCIL_UL_layer", "", gpd, "layers", gpd.layers, "active_index", rows=5)
+        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()
 
@@ -373,11 +377,12 @@ class GreasePencilDataPanel:
         if gpl:
             sub.operator("gpencil.layer_duplicate", icon='COPY_ID', text="")  # XXX: needs a dedicated icon
 
-            col.separator()
+            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'
+                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'
 
         if gpl:
             self.draw_layer(layout, gpl)