diff options
3 files changed, 44 insertions, 5 deletions
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 82f18a15469..75f6921b0c3 100644 --- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -302,9 +302,11 @@ class GPENCIL_UL_layer(UIList): if gpl.lock: layout.active = False - split = layout.split(percentage=0.2) - split.prop(gpl, "color", text="") - split.prop(gpl, "info", text="", emboss=False) + split = layout.split(percentage=0.25) + row = split.row(align=True) + row.prop(gpl, "color", text="", emboss = gpl.is_stroke_visible) + row.prop(gpl, "fill_color", text="", emboss = gpl.is_fill_visible) + split.prop(gpl, "info", text="", emboss=False) row = layout.row(align=True) row.prop(gpl, "lock", text="", emboss=False) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index baab8a05030..9f992e1063a 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -3966,16 +3966,24 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale /* color swatch for layer color */ bGPDlayer *gpl = (bGPDlayer *)ale->data; PointerRNA ptr; + float w = ICON_WIDTH / 2.0f; RNA_pointer_create(ale->id, &RNA_GPencilLayer, ale->data, &ptr); - UI_block_emboss_set(block, UI_EMBOSS); + UI_block_align_begin(block); - uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset, yminc, ICON_WIDTH, ICON_WIDTH, + UI_block_emboss_set(block, RNA_boolean_get(&ptr, "is_stroke_visible") ? UI_EMBOSS : UI_EMBOSS_NONE); + uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset, yminc, w, ICON_WIDTH, &ptr, "color", -1, 0, 0, 0, 0, gpl->info); + UI_block_emboss_set(block, RNA_boolean_get(&ptr, "is_fill_visible") ? UI_EMBOSS : UI_EMBOSS_NONE); + uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset + w, yminc, w, ICON_WIDTH, + &ptr, "fill_color", -1, + 0, 0, 0, 0, gpl->info); + UI_block_emboss_set(block, UI_EMBOSS_NONE); + UI_block_align_end(block); offset += ICON_WIDTH; } diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 96d02016336..6b61b37ce5c 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -104,6 +104,24 @@ static void rna_GPencilLayer_line_width_range(PointerRNA *ptr, int *min, int *ma } } +static int rna_GPencilLayer_is_stroke_visible_get(PointerRNA *ptr) +{ + /* see drawgpencil.c -> gp_draw_data_layers() for more details + * about this limit for showing/not showing + */ + bGPDlayer *gpl = (bGPDlayer *)ptr->data; + return (gpl->color[3] > 0.001f); +} + +static int rna_GPencilLayer_is_fill_visible_get(PointerRNA *ptr) +{ + /* see drawgpencil.c -> gp_draw_data_layers() for more details + * about this limit for showing/not showing + */ + bGPDlayer *gpl = (bGPDlayer *)ptr->data; + return (gpl->fill[3] > 0.001f); +} + static PointerRNA rna_GPencil_active_layer_get(PointerRNA *ptr) { bGPdata *gpd = ptr->id.data; @@ -764,6 +782,17 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + /* Read-only state props (for simpler UI code) */ + prop = RNA_def_property(srna, "is_stroke_visible", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_GPencilLayer_is_stroke_visible_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Is Stroke Visible", "True when opacity of stroke is set high enough to be visible"); + + prop = RNA_def_property(srna, "is_fill_visible", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_GPencilLayer_is_fill_visible_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Is Fill Visible", "True when opacity of fill is set high enough to be visible"); + /* Layers API */ func = RNA_def_function(srna, "clear", "rna_GPencil_layer_clear"); RNA_def_function_ui_description(func, "Remove all the grease pencil layer data"); |