[Bf-blender-cvs] [cfa48c84d06] master: Cleanup: Register node property layout callbacks in files
Hans Goudey
noreply at git.blender.org
Mon Feb 8 22:09:56 CET 2021
Commit: cfa48c84d06ca8197f86b6d3ceef8a2c7c311a82
Author: Hans Goudey
Date: Mon Feb 8 15:09:49 2021 -0600
Branches: master
https://developer.blender.org/rBcfa48c84d06ca8197f86b6d3ceef8a2c7c311a82
Cleanup: Register node property layout callbacks in files
This commit moves the property layout callbacks for node types to their
implementation files from `drawnode.c`. This was proposed a while ago in
T75724.
**Benefits**
- Fewer files need to be changed when adding a new node.
- Makes it possible to reuse functions from the node's implementation
in the layout code.
- Except for RNA, all of the node "inputs" are in the same place.
- Code gets shorter overall, avoids the large switch statements.
**Downsides**
- Requires including two UI headers.
- Requires adding an editors dependency to the nodes folder.
This commit only changes function nodes and geometry nodes, more can be
moved later.
Differential Revision: https://developer.blender.org/D10352
===================================================================
M source/blender/editors/include/UI_interface_icons.h
M source/blender/editors/space_node/drawnode.c
M source/blender/nodes/CMakeLists.txt
M source/blender/nodes/function/nodes/node_fn_boolean_math.cc
M source/blender/nodes/function/nodes/node_fn_float_compare.cc
M source/blender/nodes/function/nodes/node_fn_input_vector.cc
M source/blender/nodes/function/nodes/node_fn_switch.cc
M source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
M source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
M source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc
M source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
M source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
M source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
M source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc
M source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc
M source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc
M source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
M source/blender/nodes/geometry/nodes/node_geo_boolean.cc
M source/blender/nodes/geometry/nodes/node_geo_collection_info.cc
M source/blender/nodes/geometry/nodes/node_geo_object_info.cc
M source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
M source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
M source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc
M source/blender/nodes/geometry/nodes/node_geo_point_scale.cc
M source/blender/nodes/geometry/nodes/node_geo_point_translate.cc
M source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
M source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc
M source/blender/nodes/geometry/nodes/node_geo_triangulate.cc
M source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc
===================================================================
diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h
index d77a87e7200..4d860be285d 100644
--- a/source/blender/editors/include/UI_interface_icons.h
+++ b/source/blender/editors/include/UI_interface_icons.h
@@ -23,6 +23,9 @@
#pragma once
+/* Required for enum iconSizes which can't be forward declared if this file is included in C++. */
+#include "DNA_ID.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -34,8 +37,6 @@ struct PreviewImage;
struct Scene;
struct bContext;
-enum eIconSizes;
-
typedef struct IconFile {
struct IconFile *next, *prev;
char filename[256]; /* FILE_MAXFILE size */
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 132dcd8a9fb..2d65302c656 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3126,393 +3126,6 @@ static void node_texture_set_butfunc(bNodeType *ntype)
}
}
-/* ****************** BUTTON CALLBACKS FOR GEOMETRY NODES ***************** */
-
-static void node_geometry_buts_boolean_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE);
-}
-
-static void node_geometry_buts_attribute_compare(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE);
- uiItemR(layout, ptr, "input_type_a", DEFAULT_FLAGS, IFACE_("Type A"), ICON_NONE);
- uiItemR(layout, ptr, "input_type_b", DEFAULT_FLAGS, IFACE_("Type B"), ICON_NONE);
-}
-
-static void node_geometry_buts_subdivision_surface(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *UNUSED(ptr))
-{
-#ifndef WITH_OPENSUBDIV
- uiItemL(layout, IFACE_("Disabled, built without OpenSubdiv"), ICON_ERROR);
-#else
- UNUSED_VARS(layout);
-#endif
-}
-
-static void node_geometry_buts_triangulate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "quad_method", DEFAULT_FLAGS, "", ICON_NONE);
- uiItemR(layout, ptr, "ngon_method", DEFAULT_FLAGS, "", ICON_NONE);
-}
-
-static void node_geometry_buts_random_attribute(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "data_type", DEFAULT_FLAGS, "", ICON_NONE);
-}
-
-static bool node_attribute_math_operation_use_input_b(const NodeMathOperation operation)
-{
- switch (operation) {
- case NODE_MATH_ADD:
- case NODE_MATH_SUBTRACT:
- case NODE_MATH_MULTIPLY:
- case NODE_MATH_DIVIDE:
- case NODE_MATH_POWER:
- case NODE_MATH_LOGARITHM:
- case NODE_MATH_MINIMUM:
- case NODE_MATH_MAXIMUM:
- case NODE_MATH_LESS_THAN:
- case NODE_MATH_GREATER_THAN:
- case NODE_MATH_MODULO:
- case NODE_MATH_ARCTAN2:
- case NODE_MATH_SNAP:
- case NODE_MATH_WRAP:
- case NODE_MATH_COMPARE:
- case NODE_MATH_MULTIPLY_ADD:
- case NODE_MATH_PINGPONG:
- case NODE_MATH_SMOOTH_MIN:
- case NODE_MATH_SMOOTH_MAX:
- return true;
- case NODE_MATH_SINE:
- case NODE_MATH_COSINE:
- case NODE_MATH_TANGENT:
- case NODE_MATH_ARCSINE:
- case NODE_MATH_ARCCOSINE:
- case NODE_MATH_ARCTANGENT:
- case NODE_MATH_ROUND:
- case NODE_MATH_ABSOLUTE:
- case NODE_MATH_FLOOR:
- case NODE_MATH_CEIL:
- case NODE_MATH_FRACTION:
- case NODE_MATH_SQRT:
- case NODE_MATH_INV_SQRT:
- case NODE_MATH_SIGN:
- case NODE_MATH_EXPONENT:
- case NODE_MATH_RADIANS:
- case NODE_MATH_DEGREES:
- case NODE_MATH_SINH:
- case NODE_MATH_COSH:
- case NODE_MATH_TANH:
- case NODE_MATH_TRUNC:
- return false;
- }
- BLI_assert(false);
- return false;
-}
-
-static void node_geometry_buts_attribute_math(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
-{
- bNode *node = (bNode *)ptr->data;
- NodeAttributeMath *node_storage = (NodeAttributeMath *)node->storage;
- NodeMathOperation operation = (NodeMathOperation)node_storage->operation;
-
- uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE);
- uiItemR(layout, ptr, "input_type_a", DEFAULT_FLAGS, IFACE_("Type A"), ICON_NONE);
-
- /* These "use input b / c" checks are copied from the node's code.
- * They could be de-duplicated if the drawing code was moved to the node's file. */
- if (node_attribute_math_operation_use_input_b(operation)) {
- uiItemR(layout, ptr, "input_type_b", DEFAULT_FLAGS, IFACE_("Type B"), ICON_NONE);
- }
- if (ELEM(operation,
- NODE_MATH_MULTIPLY_ADD,
- NODE_MATH_SMOOTH_MIN,
- NODE_MATH_SMOOTH_MAX,
- NODE_MATH_WRAP,
- NODE_MATH_COMPARE)) {
- uiItemR(layout, ptr, "input_type_c", DEFAULT_FLAGS, IFACE_("Type C"), ICON_NONE);
- }
-}
-
-static void node_geometry_buts_attribute_vector_math(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
-{
- bNode *node = (bNode *)ptr->data;
- NodeAttributeVectorMath *node_storage = (NodeAttributeVectorMath *)node->storage;
-
- uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE);
- uiItemR(layout, ptr, "input_type_a", DEFAULT_FLAGS, IFACE_("Type A"), ICON_NONE);
-
- /* These "use input b / c" checks are copied from the node's code.
- * They could be de-duplicated if the drawing code was moved to the node's file. */
- if (!ELEM(node_storage->operation,
- NODE_VECTOR_MATH_NORMALIZE,
- NODE_VECTOR_MATH_FLOOR,
- NODE_VECTOR_MATH_CEIL,
- NODE_VECTOR_MATH_FRACTION,
- NODE_VECTOR_MATH_ABSOLUTE,
- NODE_VECTOR_MATH_SINE,
- NODE_VECTOR_MATH_COSINE,
- NODE_VECTOR_MATH_TANGENT,
- NODE_VECTOR_MATH_LENGTH)) {
- uiItemR(layout, ptr, "input_type_b", DEFAULT_FLAGS, IFACE_("Type B"), ICON_NONE);
- }
- if (ELEM(node_storage->operation, NODE_VECTOR_MATH_WRAP)) {
- uiItemR(layout, ptr, "input_type_c", DEFAULT_FLAGS, IFACE_("Type C"), ICON_NONE);
- }
-}
-
-static void node_geometry_buts_point_instance(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "instance_type", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "instance_type") == GEO_NODE_POINT_INSTANCE_TYPE_COLLECTION) {
- uiItemR(layout, ptr, "use_whole_collection", DEFAULT_FLAGS, NULL, ICON_NONE);
- }
-}
-
-static void node_geometry_buts_attribute_fill(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "data_type", DEFAULT_FLAGS, "", ICON_NONE);
- // uiItemR(layout, ptr, "domain", DEFAULT_FLAGS, "", ICON_NONE);
-}
-
-static void node_geometry_buts_attribute_mix(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "blend_type", DEFAULT_FLAGS, "", ICON_NONE);
- uiLayout *col = uiLayoutColumn(layout, false);
- uiItemR(col, ptr, "input_type_factor", DEFAULT_FLAGS, IFACE_("Factor"), ICON_NONE);
- uiItemR(col, ptr, "input_type_a", DEFAULT_FLAGS, IFACE_("A"), ICON_NONE);
- uiItemR(col, ptr, "input_type_b", DEFAULT_FLAGS, IFACE_("B"), ICON_NONE);
-}
-
-static void node_geometry_buts_attribute_point_distribute(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "distribute_method", DEFAULT_FLAGS, "", ICON_NONE);
-}
-
-static void node_geometry_buts_attribute_color_ramp(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
-{
- uiTemplateColorRamp(layout, ptr, "color_ramp", 0);
-}
-
-static void node_geometry_buts_point_rotate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
- NodeGeometryRotatePoints *storage = (NodeGeometryRotatePoints *)((bNode *)ptr->data)->storage;
-
- uiItemR(layout, ptr, "type", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, NULL, ICON_NONE);
- uiItemR(layout, ptr, "space", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, NULL, ICON_NONE);
-
- uiLayout *col = uiLayoutColumn(layout, false);
- if (storage->type == GEO_NODE_POINT_ROTATE_TYPE_AXIS_ANGLE) {
- uiItemR(col, ptr, "input_type_axis", DEFAULT_FLAGS, IFACE_("Axis"), ICON_NONE);
- uiItemR(col, ptr, "input_type_angle", DEFAULT_FLAGS, IFACE_("Angle"), ICON_NONE);
- }
- else {
- uiItemR(col, ptr, "input_type_rotation", DEFAULT_FLAGS, IFACE_("Rotation"), ICON_NONE);
- }
-}
-
-static void node_geometry_buts_align_rotation_to_vector(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "axis", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, NULL, ICON_NONE);
- uiItemR(layout, ptr, "pivot_axis", DEFAULT_FLAGS, IFACE_("Pivot"), ICON_NONE);
- uiLayout *col = uiLayoutColumn(layout, false);
- uiItemR(col, ptr, "input_type_factor", DEFAULT_FLAGS, IFACE_("Factor"), ICON_NONE);
- uiItemR(col, ptr, "input_type_vector", DEFAULT_FLAGS, IFACE_("Vector"), ICON_NONE);
-}
-static void node_geometry_buts_point_translate(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "input_type", DEFAULT_FLAGS, IFACE_("Type"), ICON_NONE);
-}
-
-static void node_geometry_buts_point_scale(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "input_type", DEFAULT_FLAGS, IFACE_("Ty
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list