[Bf-blender-cvs] [4a09bb1e8a0] greasepencil-object: Annotations: WIP access to tool settings in topbar

Joshua Leung noreply at git.blender.org
Mon Jul 9 09:26:31 CEST 2018


Commit: 4a09bb1e8a022e5d433c650fa9316a82cd17dc7f
Author: Joshua Leung
Date:   Mon Jul 9 19:26:22 2018 +1200
Branches: greasepencil-object
https://developer.blender.org/rB4a09bb1e8a022e5d433c650fa9316a82cd17dc7f

Annotations: WIP access to tool settings in topbar

Lots of stuff to fix still - Not final UI at all
(in terms of widgets + properties exposed)

What works now:
* Exposed access to the setting controlling the default color to use
  when adding new layers
* Exposed access to change which color (layer) and thickness new strokes
  get drawn with (as per the current implementation). Now all annotation
  tools have tool settings exposed.

Big Todo's:
* Find a way to display color previews of GP Layers as icons
  (e.g. how to register all the necessary icon_id's, etc.)
* Replace the prop_search() with an enum prop
* Separate annotation RNA type defines? Context issues? etc.

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

M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	source/blender/editors/gpencil/gpencil_utils.c
M	source/blender/makesrna/intern/rna_gpencil.c

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

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index b9d030e0de4..b760fbe0187 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -128,12 +128,25 @@ class _defs_view3d_generic:
 class _defs_annotate:
     @classmethod
     def draw_settings_common(cls, context, layout, tool):
-        pass
+        user_prefs = context.user_preferences
+        #tool_settings = context.tool_settings
+
+        # XXX: These context checks are needed for layer-dependent settings,
+        # but this breaks for using topbar for 2D editor active tools, etc.
+        gpd = context.gpencil_data
+        gpl = context.active_gpencil_layer
+
+        if gpd and gpl:
+            layout.prop_search(gpd.layers, "active", gpd, "layers", text="")
+            layout.prop(gpl, "line_change", text="Thickness")  # XXX: Replace with proper thickness control
+        else:
+            layout.prop(user_prefs.edit, "grease_pencil_default_color", text="Color")
+            layout.label("Thickness: [...]")
 
     @ToolDef.from_fn
     def scribble():
         def draw_settings(context, layout, tool):
-            pass
+            _defs_annotate.draw_settings_common(context, layout, tool)
 
         return dict(
             text="Annotate",
@@ -149,8 +162,7 @@ class _defs_annotate:
     @ToolDef.from_fn
     def line():
         def draw_settings(context, layout, tool):
-            # XXX: Reuse
-            pass
+            _defs_annotate.draw_settings_common(context, layout, tool)
 
         return dict(
             text="Draw Line",
@@ -166,8 +178,7 @@ class _defs_annotate:
     @ToolDef.from_fn
     def poly():
         def draw_settings(context, layout, tool):
-            # XXX: Reuse
-            pass
+            _defs_annotate.draw_settings_common(context, layout, tool)
 
         return dict(
             text="Draw Polygon",
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 29473dd595f..d94c28eaa2f 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -100,7 +100,6 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ID *screen_id, ScrArea *sa, Scene
 			/* XXX: Should we reduce reliance on context.gpencil_data for these cases? */
 			case SPACE_BUTS: /* properties */
 			case SPACE_INFO: /* header info (needed after workspaces merge) */
-			case SPACE_TOPBAR: /* Topbar (needed after topbar merge) */
 			{
 				if (ob && (ob->type == OB_GPENCIL)) {
 					/* GP Object */
@@ -114,6 +113,7 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ID *screen_id, ScrArea *sa, Scene
 				break;
 			}
 
+			case SPACE_TOPBAR: /* Topbar (needed after topbar merge) */
 			case SPACE_VIEW3D: /* 3D-View */
 			{
 				if (ob && (ob->type == OB_GPENCIL)) {
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index e2dac94d9ad..f4df82ae2c8 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -288,6 +288,15 @@ static void rna_GPencil_active_layer_set(PointerRNA *ptr, PointerRNA value)
 {
 	bGPdata *gpd = ptr->id.data;
 
+	/* Don't allow setting active layer to NULL if layers exist
+	 * as this breaks various tools. Tools should be used instead
+	 * if it's necessary to remove layers
+	 */
+	if (value.data == NULL) {
+		printf("%s: Setting active layer to None is not allowed\n", __func__);
+		return;
+	}
+
 	if (GS(gpd->id.name) == ID_GD) { /* why would this ever be not GD */
 		bGPDlayer *gl;
 
@@ -1044,7 +1053,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
 
 
-	/* expose as layers.active */
+	/* exposed as layers.active */
 #if 0
 	prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_ACTIVE);
@@ -1058,7 +1067,6 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Select", "Layer is selected for editing in the Dope Sheet");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, "rna_GPencil_update");
 
-	/* XXX keep this option? */
 	prop = RNA_def_property(srna, "show_points", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_DRAWDEBUG);
 	RNA_def_property_ui_text(prop, "Show Points", "Draw the points which make up the strokes (for debugging purposes)");



More information about the Bf-blender-cvs mailing list