diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2020-04-30 17:12:34 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2020-04-30 17:13:23 +0300 |
commit | 6a7e9f2b7647fb1883fc77f72c3d411c0a692cf7 (patch) | |
tree | d4de80b3a153a5dea35b669e39912917b6ebb95d /source/blender/editors/gpencil/gpencil_utils.c | |
parent | dc0a564c0616e181e06cd4f38b6c0920ea9e2348 (diff) |
GPencil: Add material selector to context menus
Now it's possible to select the material in context menu and new menu to select material.
The patch and workflow has been tested in greasepencil-object branch.
* New Material selector in Draw mode Context menu:
{F8499259}
* Pressing `U`key in Draw mode display material menu.
{F8503224}
Reviewed By: mendio, pepeland
Differential Revision: https://developer.blender.org/D7554
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_utils.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 3d571773bc8..6a7bb2012a7 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -481,6 +481,40 @@ const EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf(bContext *C, return item; } +/* Just existing Materials */ +const EnumPropertyItem *ED_gpencil_material_enum_itemf(bContext *C, + PointerRNA *UNUSED(ptr), + PropertyRNA *UNUSED(prop), + bool *r_free) +{ + Object *ob = CTX_data_active_object(C); + EnumPropertyItem *item = NULL, item_tmp = {0}; + int totitem = 0; + int i = 0; + + if (ELEM(NULL, C, ob)) { + return DummyRNA_DEFAULT_items; + } + + /* Existing materials */ + for (i = 1; i <= ob->totcol; i++) { + Material *ma = BKE_object_material_get(ob, i); + if (ma) { + item_tmp.identifier = ma->id.name + 2; + item_tmp.name = ma->id.name + 2; + item_tmp.value = i; + item_tmp.icon = ma->preview->icon_id; + + RNA_enum_item_add(&item, &totitem, &item_tmp); + } + } + + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; +} + /* ******************************************************** */ /* Brush Tool Core */ |