Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonioya <blendergit@gmail.com>2016-11-11 22:04:30 +0300
committerAntonioya <blendergit@gmail.com>2016-11-11 22:04:58 +0300
commitcdeaec3b0d151e020f532e0b2cc46742b41a379f (patch)
tree1c44f4ad68eed4b3f08b28b7a5554def00d35c89 /source/blender/editors/gpencil/gpencil_data.c
parented957768a06788f2a0586870c34e032f43cfc311 (diff)
GPencil: Create brush set when create new datablock or layer
Before this commit, the brush set was created with the first stroke drawing, but if the user creates the datablock or the layer manually (not drawing) the brush list was empty. This commit complement the python fix by Sergey: https://developer.blender.org/rB89c1f9db37cc1becdd437fcfdb1877306cc2b329
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_data.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 7dcbe2cc24c..ae83e899649 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -84,7 +84,8 @@
static int gp_data_add_exec(bContext *C, wmOperator *op)
{
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
-
+ ToolSettings *ts = CTX_data_tool_settings(C);
+
if (gpd_ptr == NULL) {
BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go");
return OPERATOR_CANCELLED;
@@ -95,6 +96,15 @@ static int gp_data_add_exec(bContext *C, wmOperator *op)
id_us_min(&gpd->id);
*gpd_ptr = BKE_gpencil_data_addnew(DATA_("GPencil"));
+
+ /* if not exist brushes, create a new set */
+ if (ts) {
+ if (BLI_listbase_is_empty(&ts->gp_brushes)) {
+ /* create new brushes */
+ BKE_gpencil_brush_init_presets(ts);
+ }
+ }
+
}
/* notifiers */
@@ -174,7 +184,8 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot)
static int gp_layer_add_exec(bContext *C, wmOperator *op)
{
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
-
+ ToolSettings *ts = CTX_data_tool_settings(C);
+
/* if there's no existing Grease-Pencil data there, add some */
if (gpd_ptr == NULL) {
BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go");
@@ -183,6 +194,14 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op)
if (*gpd_ptr == NULL)
*gpd_ptr = BKE_gpencil_data_addnew(DATA_("GPencil"));
+ /* if not exist brushes, create a new set */
+ if (ts) {
+ if (BLI_listbase_is_empty(&ts->gp_brushes)) {
+ /* create new brushes */
+ BKE_gpencil_brush_init_presets(ts);
+ }
+ }
+
/* add new layer now */
BKE_gpencil_layer_addnew(*gpd_ptr, DATA_("GP_Layer"), true);