diff options
author | Hans Goudey <h.goudey@me.com> | 2020-06-19 22:07:13 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-06-19 22:07:13 +0300 |
commit | bb4cef71eeaf36aa61187d47b8a8ae06ba55f7c0 (patch) | |
tree | 35700820beee851c984c9162d40952387cca5e39 /source/blender/blenkernel | |
parent | 702e00f91088031f83cfed1528d5ed22069a9d35 (diff) |
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
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_shader_fx.h | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/shader_fx.c | 20 |
2 files changed, 25 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_shader_fx.h b/source/blender/blenkernel/BKE_shader_fx.h index bdc782a606e..31e14c6c884 100644 --- a/source/blender/blenkernel/BKE_shader_fx.h +++ b/source/blender/blenkernel/BKE_shader_fx.h @@ -28,6 +28,7 @@ extern "C" { #endif +struct ARegionType; struct ID; struct ListBase; struct ModifierUpdateDepsgraphContext; @@ -157,11 +158,17 @@ typedef struct ShaderFxTypeInfo { struct Object *ob, ShaderFxIDWalkFunc walk, void *userData); + + /* Register the panel types for the effect's UI. */ + void (*panelRegister)(struct ARegionType *region_type); } ShaderFxTypeInfo; +#define SHADERFX_TYPE_PANEL_PREFIX "FX_PT_" + /* Initialize global data (type info and some common global storages). */ void BKE_shaderfx_init(void); +void BKE_shaderfxType_panel_id(ShaderFxType type, char *panel_id); const ShaderFxTypeInfo *BKE_shaderfx_get_info(ShaderFxType type); struct ShaderFxData *BKE_shaderfx_new(int type); void BKE_shaderfx_free_ex(struct ShaderFxData *fx, const int flag); 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); |