Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Carlisle <carlisle.b3d@gmail.com>2022-01-09 08:59:34 +0300
committerAaron Carlisle <carlisle.b3d@gmail.com>2022-01-09 08:59:34 +0300
commite17ac8dc58c7108cfb3a784a595912c063e09cf4 (patch)
tree3a0a30fce007550c2743e423dd5f5017a0ca7753 /source/blender/nodes/shader/nodes/node_shader_map_range.cc
parented1ced24848824a4acbaaf7aa7ccb34441f6a8f4 (diff)
Cleanup: Nodes: Begin splitting shader node buttons into individual files
Currently, most node buttons are defined in `drawnode.cc` however, this is inconvenient because it requires editing many files when adding new nodes. The goal is to minimize the number of files needed to add or update a node. This commit moves most of the node layout functions for shader nodes into their respected source/blender/nodes/shader/nodes file. In the future, these functions will be simplified to node_layout. Some nodes were left in `drawnode.cc` as this would require duplicating code while this is likely fine it is best to leave that to a seperate commit.
Diffstat (limited to 'source/blender/nodes/shader/nodes/node_shader_map_range.cc')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_map_range.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_map_range.cc b/source/blender/nodes/shader/nodes/node_shader_map_range.cc
index c4527fd3420..71adf607869 100644
--- a/source/blender/nodes/shader/nodes/node_shader_map_range.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_map_range.cc
@@ -29,6 +29,9 @@
#include "NOD_socket_search_link.hh"
+#include "UI_interface.h"
+#include "UI_resources.h"
+
namespace blender::nodes::node_shader_map_range_cc {
NODE_STORAGE_FUNCS(NodeMapRange)
@@ -52,6 +55,17 @@ static void sh_node_map_range_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Vector>(N_("Vector"));
};
+static void node_shader_buts_map_range(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "data_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
+ uiItemR(layout, ptr, "interpolation_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
+ if (!ELEM(RNA_enum_get(ptr, "interpolation_type"),
+ NODE_MAP_RANGE_SMOOTHSTEP,
+ NODE_MAP_RANGE_SMOOTHERSTEP)) {
+ uiItemR(layout, ptr, "clamp", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
+ }
+}
+
static void node_shader_update_map_range(bNodeTree *ntree, bNode *node)
{
const NodeMapRange &storage = node_storage(*node);
@@ -650,6 +664,7 @@ void register_node_type_sh_map_range()
sh_fn_node_type_base(&ntype, SH_NODE_MAP_RANGE, "Map Range", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::sh_node_map_range_declare;
+ ntype.draw_buttons = file_ns::node_shader_buts_map_range;
node_type_init(&ntype, file_ns::node_shader_init_map_range);
node_type_storage(
&ntype, "NodeMapRange", node_free_standard_storage, node_copy_standard_storage);