diff options
author | Antonioya <blendergit@gmail.com> | 2018-08-25 00:59:56 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-08-25 01:04:40 +0300 |
commit | 1a7837596cb983fd3328eb680007147761f29f5b (patch) | |
tree | 9b5ca8f17bfaa1d7229f3687655ec490c18ed893 /source/blender/makesrna/intern | |
parent | 6901712734c306df6ff38ea8c64b442981545a2a (diff) |
GP: Select color in Brush or in Properties
After some artist feedback the material selection was not clear.
Now, the material can be selected in the top bar or in the properties panel.
1) If the material is selected in properties panel, all Brushes except pinned will be assigned to this material.
2) If the material is selected in the brush, the properties panel is updated to set the active material.
Added a new Pin icon to keep locked the material to one brush
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 36 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 18 |
2 files changed, 51 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 8ad77b88702..3df84a3a85b 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -171,6 +171,7 @@ static EnumPropertyItem rna_enum_gpencil_brush_icons_items[] = { #include "BKE_colorband.h" #include "BKE_brush.h" #include "BKE_icons.h" +#include "BKE_gpencil.h" #include "BKE_paint.h" #include "WM_api.h" @@ -411,6 +412,31 @@ static void rna_Brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR /*WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); */ } +static void rna_Brush_material_update(bContext *C, PointerRNA *ptr) +{ + Main *bmain = CTX_data_main(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); + Brush *br = (Brush *)ptr->id.data; + int index; + + /* set material slot to same material */ + if ((ob) && (ob->type == OB_GPENCIL) && (br->gpencil_settings != NULL)) { + BrushGpencilSettings *gpencil_settings = br->gpencil_settings; + if (gpencil_settings->material != NULL) { + + index = BKE_gpencil_get_material_index(ob, gpencil_settings->material); + if ((index > 0) && (ob->actcol != index)) { + ob->actcol = index; + /* update other brushes to keep all synchro */ + BKE_brush_update_material(bmain, gpencil_settings->material, br); + } + + } + WM_main_add_notifier(NC_SPACE | ND_SPACE_PROPERTIES, NULL); + } +} + static void rna_Brush_main_tex_update(bContext *C, PointerRNA *ptr) { Main *bmain = CTX_data_main(C); @@ -1202,10 +1228,10 @@ static void rna_def_gpencil_options(BlenderRNA *brna) prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Material"); RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_BrushGpencilSettings_material_poll"); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Material", "Material used for strokes drawn using this brush"); RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_Brush_material_update"); prop = RNA_def_property(srna, "gpencil_fill_show_boundary", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_FILL_SHOW_HELPLINES); @@ -1236,6 +1262,12 @@ static void rna_def_gpencil_options(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_GROUP_RANDOM); RNA_def_property_ui_text(prop, "Random Settings", "Enable random settings for brush"); RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + + prop = RNA_def_property(srna, "pin_material", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_MATERIAL_PINNED); + RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1); + RNA_def_property_ui_text(prop, "Pin Material", "Keep material assigned to brush"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); } static void rna_def_brush(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 44e13437b9f..cf5b3aff571 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -28,6 +28,7 @@ #include <stdlib.h> #include "DNA_action_types.h" +#include "DNA_brush_types.h" #include "DNA_customdata_types.h" #include "DNA_group_types.h" #include "DNA_material_types.h" @@ -193,6 +194,7 @@ const EnumPropertyItem rna_enum_object_axis_items[] = { #include "DNA_node_types.h" #include "BKE_armature.h" +#include "BKE_brush.h" #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_curve.h" @@ -242,6 +244,20 @@ static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id); } +static void rna_MaterialIndex_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +{ + /* update the material of all brushes not pinned */ + Object *ob = (Object *)ptr->id.data; + if (ob && ob->type == OB_GPENCIL) { + Material *ma = give_current_material(ob, ob->actcol); + if (ma != NULL) { + BKE_brush_update_material(bmain, ma, NULL); + WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL); + } + } +} + + static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) { Object *ob = ptr->id.data; @@ -2215,7 +2231,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set", "rna_Object_active_material_index_range"); RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot"); - RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, NULL); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, "rna_MaterialIndex_update"); /* transform */ prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); |