From bb4cef71eeaf36aa61187d47b8a8ae06ba55f7c0 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 19 Jun 2020 15:07:13 -0400 Subject: UI: ShaderFx Drag and Drop, Layout Updates This patch implements the list panel system D7490 for grease pencil shader effects. It also moves their drawing to a callback in ShaderFxTypeInfo in line with the extensible architecture refactoring goal T75724. The implementation is basically exactly the same as for the modifier patch (9b099c86123fc82). Thanks to Matias Mendiola (@mendio) for helping to develop the layout changes. Differential Revision: https://developer.blender.org/D7985 --- source/blender/blenkernel/intern/shader_fx.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern/shader_fx.c') diff --git a/source/blender/blenkernel/intern/shader_fx.c b/source/blender/blenkernel/intern/shader_fx.c index 0ad61de1ff2..2923298c5d5 100644 --- a/source/blender/blenkernel/intern/shader_fx.c +++ b/source/blender/blenkernel/intern/shader_fx.c @@ -82,8 +82,9 @@ ShaderFxData *BKE_shaderfx_new(int type) BLI_strncpy(fx->name, DATA_(fxi->name), sizeof(fx->name)); fx->type = type; - fx->mode = eShaderFxMode_Realtime | eShaderFxMode_Render | eShaderFxMode_Expanded; + fx->mode = eShaderFxMode_Realtime | eShaderFxMode_Render; fx->flag = eShaderFxFlag_OverrideLibrary_Local; + fx->ui_expand_flag = 1; /* Expand only the parent panel by default. */ if (fxi->flags & eShaderFxTypeFlag_EnableInEditmode) { fx->mode |= eShaderFxMode_Editmode; @@ -156,7 +157,7 @@ bool BKE_shaderfx_depends_ontime(ShaderFxData *fx) const ShaderFxTypeInfo *BKE_shaderfx_get_info(ShaderFxType type) { /* type unsigned, no need to check < 0 */ - if (type < NUM_SHADER_FX_TYPES && shader_fx_types[type]->name[0] != '\0') { + if (type < NUM_SHADER_FX_TYPES && type > 0 && shader_fx_types[type]->name[0] != '\0') { return shader_fx_types[type]; } else { @@ -164,6 +165,20 @@ const ShaderFxTypeInfo *BKE_shaderfx_get_info(ShaderFxType type) } } +/** + * Get an effect's panel type, which was defined in the #panelRegister callback. + * + * \note ShaderFx panel types are assumed to be named with the struct name field concatenated to + * the defined prefix. + */ +void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname) +{ + const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(type); + + strcpy(r_idname, SHADERFX_TYPE_PANEL_PREFIX); + strcat(r_idname, fxi->name); +} + void BKE_shaderfx_copydata_generic(const ShaderFxData *fx_src, ShaderFxData *fx_dst) { const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(fx_src->type); @@ -198,6 +213,7 @@ void BKE_shaderfx_copydata_ex(ShaderFxData *fx, ShaderFxData *target, const int target->mode = fx->mode; target->flag = fx->flag; + target->ui_expand_flag = fx->ui_expand_flag; if (fxi->copyData) { fxi->copyData(fx, target); -- cgit v1.2.3