diff options
author | Antonioya <blendergit@gmail.com> | 2018-08-02 20:21:12 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-08-02 20:21:23 +0300 |
commit | 45751065c0e13242e08ef0d0b3dbecf9b4a05baa (patch) | |
tree | 9cffdfaf4a706a8f19c449edbd89bf750aa82d67 /source/blender/editors/gpencil/gpencil_data.c | |
parent | acdb136dcec5cbf200e7cf1825d4735e193c5b89 (diff) |
Add list of color to Assign color operator
It's more clear for user to see the name of the color
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_data.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_data.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 01cf8aeb7f1..8598d45ff01 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -1131,12 +1131,29 @@ void GPENCIL_OT_stroke_arrange(wmOperatorType *ot) /* ******************* Move Stroke to new color ************************** */ -static int gp_stroke_change_color_exec(bContext *C, wmOperator *UNUSED(op)) +static int gp_stroke_change_color_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); + Material *ma = NULL; + char name[MAX_ID_NAME - 2]; + RNA_string_get(op->ptr, "material", name); + bGPdata *gpd = ED_gpencil_data_get_active(C); Object *ob = CTX_data_active_object(C); - Material *ma = give_current_material(ob, ob->actcol); + if (name[0] == '\0') { + ma = give_current_material(ob, ob->actcol); + } + else { + ma = (Material *)BKE_libblock_find_name(bmain, ID_MA, name); + if (ma == NULL) { + return OPERATOR_CANCELLED; + } + } + /* try to find slot */ int idx = BKE_object_material_slot_find_index(ob, ma) - 1; + if (idx == 0) { + return OPERATOR_CANCELLED; + } /* sanity checks */ if (ELEM(NULL, gpd)) { @@ -1200,6 +1217,9 @@ void GPENCIL_OT_stroke_change_color(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_string(ot->srna, "material", NULL, MAX_ID_NAME - 2, "Material", "Name of the material"); + } /* ******************* Lock color of non selected Strokes colors ************************** */ |