[Bf-blender-cvs] [bb4cef71eea] master: UI: ShaderFx Drag and Drop, Layout Updates
Hans Goudey
noreply at git.blender.org
Fri Jun 19 21:07:20 CEST 2020
Commit: bb4cef71eeaf36aa61187d47b8a8ae06ba55f7c0
Author: Hans Goudey
Date: Fri Jun 19 15:07:13 2020 -0400
Branches: master
https://developer.blender.org/rBbb4cef71eeaf36aa61187d47b8a8ae06ba55f7c0
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
===================================================================
M release/scripts/startup/bl_ui/properties_data_shaderfx.py
M source/blender/blenkernel/BKE_shader_fx.h
M source/blender/blenkernel/intern/shader_fx.c
M source/blender/blenloader/intern/versioning_290.c
M source/blender/editors/include/ED_object.h
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/interface_templates.c
M source/blender/editors/object/object_intern.h
M source/blender/editors/object/object_ops.c
M source/blender/editors/object/object_shader_fx.c
M source/blender/editors/space_buttons/space_buttons.c
M source/blender/makesdna/DNA_shader_fx_types.h
M source/blender/makesrna/intern/rna_shader_fx.c
M source/blender/makesrna/intern/rna_ui_api.c
M source/blender/shader_fx/CMakeLists.txt
M source/blender/shader_fx/intern/FX_shader_blur.c
M source/blender/shader_fx/intern/FX_shader_colorize.c
M source/blender/shader_fx/intern/FX_shader_flip.c
M source/blender/shader_fx/intern/FX_shader_glow.c
M source/blender/shader_fx/intern/FX_shader_light.c
M source/blender/shader_fx/intern/FX_shader_pixel.c
M source/blender/shader_fx/intern/FX_shader_rim.c
M source/blender/shader_fx/intern/FX_shader_shadow.c
M source/blender/shader_fx/intern/FX_shader_swirl.c
M source/blender/shader_fx/intern/FX_shader_wave.c
A source/blender/shader_fx/intern/FX_ui_common.c
A source/blender/shader_fx/intern/FX_ui_common.h
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_shaderfx.py b/release/scripts/startup/bl_ui/properties_data_shaderfx.py
index 1d4bf37b282..a96fef018c7 100644
--- a/release/scripts/startup/bl_ui/properties_data_shaderfx.py
+++ b/release/scripts/startup/bl_ui/properties_data_shaderfx.py
@@ -24,11 +24,11 @@ class ShaderFxButtonsPanel:
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "shaderfx"
- bl_options = {'HIDE_HEADER'}
class DATA_PT_shader_fx(ShaderFxButtonsPanel, Panel):
bl_label = "Effects"
+ bl_options = {'HIDE_HEADER'}
# Unused: always show for now.
@@ -39,122 +39,8 @@ class DATA_PT_shader_fx(ShaderFxButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
-
- ob = context.object
-
layout.operator_menu_enum("object.shaderfx_add", "type")
-
- for fx in ob.shader_effects:
- box = layout.template_shaderfx(fx)
- if box:
- # match enum type to our functions, avoids a lookup table.
- getattr(self, fx.type)(box, fx)
-
- # the mt.type enum is (ab)used for a lookup on function names
- # ...to avoid lengthy if statements
- # so each type must have a function here.
-
- def FX_BLUR(self, layout, fx):
-
- layout.prop(fx, "use_dof_mode", text="Use Depth of Field")
- layout.separator()
-
- col = layout.column()
- col.enabled = not fx.use_dof_mode
- col.prop(fx, "size", text="Size")
- col.separator()
- col.prop(fx, "rotation")
-
- layout.prop(fx, "samples", text="Samples")
-
-
- def FX_COLORIZE(self, layout, fx):
- layout.prop(fx, "mode", text="Mode")
-
- if fx.mode == 'DUOTONE':
- layout.prop(fx, "low_color", text="Low Color")
- if fx.mode == 'CUSTOM':
- layout.prop(fx, "low_color", text="Color")
-
- if fx.mode == 'DUOTONE':
- layout.prop(fx, "high_color", text="High Color")
-
- layout.prop(fx, "factor")
-
- def FX_WAVE(self, layout, fx):
- row = layout.row(align=True)
- row.prop(fx, "orientation", expand=True)
-
- layout.separator()
- layout.prop(fx, "amplitude")
- layout.prop(fx, "period")
- layout.prop(fx, "phase")
-
- def FX_PIXEL(self, layout, fx):
- layout.prop(fx, "size", text="Size")
-
- def FX_RIM(self, layout, fx):
- layout.prop(fx, "offset", text="Offset")
-
- layout.prop(fx, "rim_color")
- layout.prop(fx, "mask_color")
- layout.prop(fx, "mode", text="Blend")
- layout.prop(fx, "blur")
- layout.prop(fx, "samples")
-
- def FX_SHADOW(self, layout, fx):
- layout.prop(fx, "offset", text="Offset")
-
- layout.prop(fx, "shadow_color")
- layout.prop(fx, "scale")
- layout.prop(fx, "rotation")
-
- layout.separator()
- layout.prop(fx, "blur")
- layout.prop(fx, "samples")
-
- layout.separator()
- layout.prop(fx, "use_object", text="Use Object as Pivot")
- if fx.use_object:
- row = layout.row()
- row.prop(fx, "object", text="Object")
-
- layout.separator()
- layout.prop(fx, "use_wave", text="Use Wave Effect")
- if fx.use_wave is True:
- row = layout.row(align=True)
- row.prop(fx, "orientation", expand=True)
- layout.prop(fx, "amplitude")
- layout.prop(fx, "period")
- layout.prop(fx, "phase")
-
- def FX_GLOW(self, layout, fx):
- layout.prop(fx, "mode")
- if fx.mode == 'LUMINANCE':
- layout.prop(fx, "threshold")
- else:
- layout.prop(fx, "select_color")
-
- layout.prop(fx, "glow_color")
- layout.separator()
- layout.prop(fx, "blend_mode", text="Blend")
- layout.prop(fx, "opacity")
-
- layout.prop(fx, "size")
- layout.prop(fx, "rotation")
- layout.prop(fx, "samples")
-
- layout.prop(fx, "use_glow_under", text="Glow Under")
-
- def FX_SWIRL(self, layout, fx):
- layout.prop(fx, "object", text="Object")
-
- layout.prop(fx, "radius")
- layout.prop(fx, "angle")
-
- def FX_FLIP(self, layout, fx):
- layout.prop(fx, "flip_horizontal")
- layout.prop(fx, "flip_vertical")
+ layout.template_shaderfx()
classes = (
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);
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 00c73ebe9a7..bf4ed270e33 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -30,6 +30,7 @@
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
+#include "DNA_shader_fx_types.h"
#include "BKE_collection.h"
#include "BKE_colortools.h"
@@ -317,5 +318,19 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+
+ /* Transition to saving expansion for all of an effect's subpanels. */
+ if (!DNA_struct_elem_find(fd->filesdna, "ShaderFxData", "short", "ui_expand_flag")) {
+ for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
+ LISTBASE_FOREACH (ShaderFxData *, fx, &object->shader_fx) {
+ if (fx->mode & eShaderFxMode_Expanded_DEPRECATED) {
+ fx->ui_expand_flag = 1;
+ }
+ else {
+ fx->ui_expand_flag = 0;
+ }
+ }
+ }
+ }
}
}
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 0cc926987b2..73c58753531 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -453,6 +453,10 @@ int ED_object_shaderfx_move_down(struct ReportList *reports,
int ED_object_shaderfx_move_up(struct ReportList *reports,
struct Object *ob,
struct ShaderFxData *fx);
+bool ED_object_shaderfx_move_to_index(struct ReportList *reports,
+ struct Object *ob,
+ struct ShaderFxData *fx,
+ const int index);
/* object_select.c */
void ED_object_select_linked_by_id(struct bContext *C, struct ID *id);
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 8e9591c1963..bcbee51246e 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2005,6 +2005,7 @@ void uiTemplatePathBuilder(uiLayout *layout,
const char *text);
void uiTemplateModifiers(uiLayout *layout, struct bContext *C);
void uiTemplateGpencilModifiers(uiLayout *layout, struct bContext *C);
+void uiTemplateShaderFx(uiLayout *layout, struct bContext *C);
void uiTemplateConstraints(uiLayout *layout, struct bContext *C, bool use_bone_c
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list