diff options
author | Charlie Jolly <charlie> | 2022-02-07 18:29:16 +0300 |
---|---|---|
committer | Fabian Schempp <fabianschempp@googlemail.com> | 2022-04-11 01:29:07 +0300 |
commit | b7d259f6962b0750a9f37ff0fdb4ce8aa3684159 (patch) | |
tree | 98a537549435144e7b7fffcf9e4f49ca89fd0c92 /source/blender/editors/space_node/node_draw.cc | |
parent | dca1a6d193ba3999151dd2bd2c2d74ba78c7a477 (diff) |
Nodes: Dynamic node class for Map Range node
This patch makes it possible to set the UI color of a node's
header bar and override the default from the node's typeinfo.
Currently the color is taken from the `.nclass`
member of the node's bNodeType->TypeInfo struct.
This is created once when registering the node.
The TypeInfo is used for both UI and non-UI functionality.
Since the TypeInfo is shared, the header bar for the node
can't be changed without changing all nodes of that type.
The Map Range node is shown as a `Converter` or blue color by default.
This patch allows this to be changed dynamically to `Vector` or purple.
This is done by adding a `ui_class` callback to node typeinfo struct.
Reviewed By: HooglyBoogly
Differential Revision: https://developer.blender.org/D13936
Diffstat (limited to 'source/blender/editors/space_node/node_draw.cc')
-rw-r--r-- | source/blender/editors/space_node/node_draw.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 834bb3e5802..81c63e9bddb 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -626,7 +626,9 @@ static void node_update_hidden(bNode &node, uiBlock &block) static int node_get_colorid(const bNode &node) { - switch (node.typeinfo->nclass) { + const int nclass = (node.typeinfo->ui_class == nullptr) ? node.typeinfo->nclass : + node.typeinfo->ui_class(&node); + switch (nclass) { case NODE_CLASS_INPUT: return TH_NODE_INPUT; case NODE_CLASS_OUTPUT: |