[Bf-blender-cvs] [391b4dfd371] modifier-panels-ui: ShaderFX UI Panels

Hans Goudey noreply at git.blender.org
Wed Apr 29 21:35:37 CEST 2020


Commit: 391b4dfd3711cad330c9fd54e73b7b64fbb8fdf4
Author: Hans Goudey
Date:   Wed Apr 29 14:35:29 2020 -0500
Branches: modifier-panels-ui
https://developer.blender.org/rB391b4dfd3711cad330c9fd54e73b7b64fbb8fdf4

ShaderFX UI Panels

===================================================================

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/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..fba5f143494 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', 'LIST_START'}
 
     # Unused: always show for now.
 
@@ -43,118 +43,7 @@ class DATA_PT_shader_fx(ShaderFxButtonsPanel, Panel):
         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 c8386a42c9a..f49cdf55f6a 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,8 +158,13 @@ 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);
 
diff --git a/source/blender/blenkernel/intern/shader_fx.c b/source/blender/blenkernel/intern/shader_fx.c
index 8d692782413..b5b2ed9d09f 100644
--- a/source/blender/blenkernel/intern/shader_fx.c
+++ b/source/blender/blenkernel/intern/shader_fx.c
@@ -156,7 +156,7 @@ bool BKE_shaderfx_dependsOnTime(ShaderFxData *fx)
 const ShaderFxTypeInfo *BKE_shaderfxType_getInfo(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 {
@@ -198,6 +198,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/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 7cfcbf14d5b..140e3b64e3f 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -442,6 +442,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 b03c305bd13..7cade9ed824 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1996,6 +1996,7 @@ void uiTemplatePathBuilder(uiLayout *layout,
 void uiTemplateModifiers(uiLayout *layout, struct bContext *C);
 void uiTemplateGpencilModifiers(uiLayout *layout, struct bContext *C);
 void uiTemplateConstraints(uiLayout *layout, struct bContext *C);
+void uiTemplateShaderFx(uiLayout *layout, struct bContext *C);
 
 uiLayout *uiTemplateGpencilModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
 void uiTemplateGpencilColorPreview(uiLayout *layout,
@@ -2007,8 +2008,6 @@ void uiTemplateGpencilColorPreview(uiLayout *layout,
                                    float scale,
                                    int filter);
 
-uiLayout *uiTemplateShaderFx(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
-
 void uiTemplateOperatorRedoProperties(uiLayout *layout, const struct bContext *C);
 
 void uiTemplateConstraintHeader(uiLayout *layout, struct PointerRNA *ptr);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 79345ecda5c..d1b921036f1 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1822,8 +1822,6 @@ void uiTemplatePathBuilder(uiLayout *layout,
  *  Template for building the panel layout for the active object's modifiers.
  * \{ */
 
-#define ERROR_LIBDATA_MESSAGE TIP_("Can't edit external library data")
-
 static PanelType *panel_type_from_modifier(ARegion *region, Link *md_link)
 {
   ARegionType *region_type = region->type;
@@ -1872,8 +1870,6 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C)
  *  Template for building the panel layout for the active object's modifiers.
  * \{ */
 
-#define ERROR_LIBDATA_MESSAGE TIP_("Can't edit external library data")
-
 static PanelType *panel_type_from_gpencil_modifier(ARegion *region, Link *md_link)
 {
   ARegionType *region_type = region->type;
@@ -1986,7 +1982,8 @@ static PanelType *panel_type_from_constraint(ARegion *region, Link *con_link)
   bConstraint *con = (bConstraint *)con_link;
   eBConstraint_Types type = con->type;
 
-  /* Get the name of the modifier's panel type which was defined when the panel was registered. */
+  /* Get the name of the constraint's panel type which was defined when the panel was registered.
+   */
   char panel_idname[BKE_ST_MAXNAME];
   strcpy(panel_idname, CONSTRAINT_TYPE_PANEL_PREFIX);
 
@@ -2031,123 +2028,57 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C)
 /** \} */
 
 /* -------------------------------------------------------------------- */
-/** \name Grease Pencil Shader FX Template
+/** \name ShaderFx Template
+ *
+ *  Template for building the panel layout for the active object's grease pencil shader effects.
  * \{ */
 
-static uiLayout *gpencil_draw_shaderfx(uiLayout *layout, Object *ob, ShaderFxData *md)
+/**
+ * Get an effect's panel type.
+ *
+ * \note: ShaderFx panel types are assumed to be named with the struct name field concatenated to
+ * the defined prefi

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list