[Bf-blender-cvs] [7931a1357a0] greasepencil-object: Add annotation layer with the right name

Antonio Vazquez noreply at git.blender.org
Sun Jul 1 11:00:38 CEST 2018


Commit: 7931a1357a0f93ac0d7b8e6a564faa0b735a96ff
Author: Antonio Vazquez
Date:   Sun Jul 1 11:00:29 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB7931a1357a0f93ac0d7b8e6a564faa0b735a96ff

Add annotation layer with the right name

When adding layers, the name of the layer is different for grease pencil object and annotation.

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	source/blender/editors/gpencil/gpencil_data.c

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

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 9e0ae2c7860..57bf1c0745c 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -783,7 +783,7 @@ class GreasePencilDataPanel:
         col = row.column()
 
         sub = col.column(align=True)
-        sub.operator("gpencil.layer_add", icon='ZOOMIN', text="")
+        sub.operator("gpencil.layer_add", icon='ZOOMIN', text="").annotation = True
         sub.operator("gpencil.layer_remove", icon='ZOOMOUT', text="")
 
         gpl = context.active_gpencil_layer
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index f7e7184d519..f2b55b82bb1 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -198,6 +198,7 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot)
 /* add new layer - wrapper around API */
 static int gp_layer_add_exec(bContext *C, wmOperator *op)
 {
+	bool is_annotation = RNA_boolean_get(op->ptr, "annotation");
 	bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
 
 	/* if there's no existing Grease-Pencil data there, add some */
@@ -207,14 +208,24 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op)
 	}
 	if (*gpd_ptr == NULL) {
 		Main *bmain = CTX_data_main(C);
-		*gpd_ptr = BKE_gpencil_data_addnew(bmain, DATA_("GPencil"));
+		if (!is_annotation) {
+			*gpd_ptr = BKE_gpencil_data_addnew(bmain, DATA_("GPencil"));
+		}
+		else {
+			*gpd_ptr = BKE_gpencil_data_addnew(bmain, DATA_("Notes"));
+		}
 	}
 
 	/* add default sets of colors and brushes */
 	ED_gpencil_add_defaults(C);
 
 	/* add new layer now */
-	BKE_gpencil_layer_addnew(*gpd_ptr, DATA_("GP_Layer"), true);
+	if (!is_annotation) {
+		BKE_gpencil_layer_addnew(*gpd_ptr, DATA_("GP_Layer"), true);
+	}
+	else {
+		BKE_gpencil_layer_addnew(*gpd_ptr, DATA_("Note"), true);
+	}
 
 	/* notifiers */
 	WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
@@ -227,13 +238,17 @@ void GPENCIL_OT_layer_add(wmOperatorType *ot)
 	/* identifiers */
 	ot->name = "Add New Layer";
 	ot->idname = "GPENCIL_OT_layer_add";
-	ot->description = "Add new Grease Pencil layer for the active Grease Pencil data-block";
+	ot->description = "Add new layer or note for the active data-block";
 
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
 	/* callbacks */
 	ot->exec = gp_layer_add_exec;
 	ot->poll = gp_add_poll;
+
+	/* parameters */
+	ot->prop = RNA_def_boolean(ot->srna, "annotation", false, "Annotation", "");
+	RNA_def_property_flag(ot->prop, PROP_HIDDEN | PROP_SKIP_SAVE);
 }
 
 /* ******************* Remove Active Layer ************************* */



More information about the Bf-blender-cvs mailing list