Fix #144760: Some (Input) Nodes not changeable in Properties Editor
A node would not show the "Collapse/Expand" arrows (caused by87c011f8bbwhich moved the drawing code for the input nodes a new `custom_draw_fn` callback on the socket declaration). Related fix:7f07124d30So in order to resolve, make sure we have correct conditions to show the expander and also make sure we draw the custo buttons in appropriate places. NOTE: not sure if there are better ways to achieve the correct UI split alignment, since we draw with empty labels, I had to flag with `UI_ITEM_R_SPLIT_EMPTY_NAME` in the new `custom_draw_fn` callbacks. Pull Request: https://projects.blender.org/blender/blender/pulls/144993
This commit is contained in:
committed by
Philipp Oeser
parent
39990303a0
commit
d7fa455e66
@@ -769,14 +769,21 @@ static void ui_node_draw_recursive(uiLayout &layout,
|
||||
continue;
|
||||
}
|
||||
if (const auto *socket_decl = dynamic_cast<const nodes::SocketDeclaration *>(item_decl)) {
|
||||
if (socket_decl->in_out == SOCK_IN) {
|
||||
ui_node_draw_input(*panel_layout.body,
|
||||
C,
|
||||
ntree,
|
||||
node,
|
||||
node.socket_by_decl(*socket_decl),
|
||||
depth,
|
||||
panel_decl.name.c_str());
|
||||
bNodeSocket &socket = node.socket_by_decl(*socket_decl);
|
||||
if (socket_decl->custom_draw_fn) {
|
||||
nodes::CustomSocketDrawParams params{
|
||||
C,
|
||||
*panel_layout.body,
|
||||
ntree,
|
||||
node,
|
||||
socket,
|
||||
RNA_pointer_create_discrete(&ntree.id, &RNA_Node, &node),
|
||||
RNA_pointer_create_discrete(&ntree.id, &RNA_NodeSocket, &socket)};
|
||||
(*socket_decl->custom_draw_fn)(params);
|
||||
}
|
||||
else if (socket_decl->in_out == SOCK_IN) {
|
||||
ui_node_draw_input(
|
||||
*panel_layout.body, C, ntree, node, socket, depth, panel_decl.name.c_str());
|
||||
}
|
||||
}
|
||||
else if (const auto *sub_panel_decl = dynamic_cast<const nodes::PanelDeclaration *>(item_decl))
|
||||
@@ -795,7 +802,15 @@ static void ui_node_draw_node(
|
||||
{
|
||||
PointerRNA nodeptr = RNA_pointer_create_discrete(&ntree.id, &RNA_Node, &node);
|
||||
|
||||
if (node.declaration() && node.declaration()->use_custom_socket_order) {
|
||||
/* Draw top-level node buttons. */
|
||||
if (node.typeinfo->draw_buttons) {
|
||||
if (node.type_legacy != NODE_GROUP) {
|
||||
layout.use_property_split_set(true);
|
||||
node.typeinfo->draw_buttons(&layout, &C, &nodeptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (node.declaration()) {
|
||||
const nodes::NodeDeclaration &node_decl = *node.declaration();
|
||||
for (const nodes::ItemDeclaration *item_decl : node_decl.root_items) {
|
||||
if (const auto *panel_decl = dynamic_cast<const nodes::PanelDeclaration *>(item_decl)) {
|
||||
@@ -803,9 +818,20 @@ static void ui_node_draw_node(
|
||||
}
|
||||
else if (const auto *socket_decl = dynamic_cast<const nodes::SocketDeclaration *>(item_decl))
|
||||
{
|
||||
if (socket_decl->in_out == SOCK_IN) {
|
||||
ui_node_draw_input(
|
||||
layout, C, ntree, node, node.socket_by_decl(*socket_decl), depth + 1, nullptr);
|
||||
bNodeSocket &socket = node.socket_by_decl(*socket_decl);
|
||||
if (socket_decl->custom_draw_fn) {
|
||||
nodes::CustomSocketDrawParams params{
|
||||
C,
|
||||
layout,
|
||||
ntree,
|
||||
node,
|
||||
socket,
|
||||
RNA_pointer_create_discrete(&ntree.id, &RNA_Node, &node),
|
||||
RNA_pointer_create_discrete(&ntree.id, &RNA_NodeSocket, &socket)};
|
||||
(*socket_decl->custom_draw_fn)(params);
|
||||
}
|
||||
else if (socket_decl->in_out == SOCK_IN) {
|
||||
ui_node_draw_input(layout, C, ntree, node, socket, depth + 1, nullptr);
|
||||
}
|
||||
}
|
||||
else if (const auto *layout_decl = dynamic_cast<const nodes::LayoutDeclaration *>(item_decl))
|
||||
@@ -816,13 +842,7 @@ static void ui_node_draw_node(
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (node.typeinfo->draw_buttons) {
|
||||
if (node.type_legacy != NODE_GROUP) {
|
||||
layout.use_property_split_set(true);
|
||||
node.typeinfo->draw_buttons(&layout, &C, &nodeptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw socket values using the flat inputs list. */
|
||||
LISTBASE_FOREACH (bNodeSocket *, input, &node.inputs) {
|
||||
ui_node_draw_input(layout, C, ntree, node, *input, depth + 1, nullptr);
|
||||
}
|
||||
@@ -872,11 +892,33 @@ static void ui_node_draw_input(uiLayout &layout,
|
||||
if (depth > 0) {
|
||||
UI_block_emboss_set(block, ui::EmbossType::None);
|
||||
|
||||
if (lnode && (lnode->inputs.first ||
|
||||
(lnode->typeinfo->draw_buttons && lnode->type_legacy != NODE_GROUP)))
|
||||
{
|
||||
int icon = (input.flag & SOCK_COLLAPSED) ? ICON_RIGHTARROW : ICON_DOWNARROW_HLT;
|
||||
sub->prop(&inputptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", icon);
|
||||
if (lnode) {
|
||||
/* Input linked to a node, we can expand/collapse if
|
||||
* - linked node has inputs
|
||||
* - linked node has dedicated button drawing
|
||||
* - linked node has dedicated socket drawing */
|
||||
bool can_expand = lnode->inputs.first;
|
||||
if (lnode->type_legacy != NODE_GROUP) {
|
||||
if (lnode->typeinfo->draw_buttons) {
|
||||
can_expand = true;
|
||||
}
|
||||
else if (lnode->declaration()) {
|
||||
const nodes::NodeDeclaration &lnode_decl = *lnode->declaration();
|
||||
for (const nodes::ItemDeclaration *item_decl : lnode_decl.root_items) {
|
||||
if (const auto *socket_decl = dynamic_cast<const nodes::SocketDeclaration *>(
|
||||
item_decl))
|
||||
{
|
||||
if (socket_decl->custom_draw_fn) {
|
||||
can_expand = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (can_expand) {
|
||||
int icon = (input.flag & SOCK_COLLAPSED) ? ICON_RIGHTARROW : ICON_DOWNARROW_HLT;
|
||||
sub->prop(&inputptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", icon);
|
||||
}
|
||||
}
|
||||
|
||||
UI_block_emboss_set(block, ui::EmbossType::Emboss);
|
||||
|
||||
@@ -31,7 +31,11 @@ static void cmp_node_rgb_declare(NodeDeclarationBuilder &b)
|
||||
uiLayout &col = params.layout.column(false);
|
||||
uiTemplateColorPicker(
|
||||
&col, ¶ms.socket_ptr, "default_value", true, false, false, false);
|
||||
col.prop(¶ms.socket_ptr, "default_value", UI_ITEM_R_SLIDER, "", ICON_NONE);
|
||||
col.prop(¶ms.socket_ptr,
|
||||
"default_value",
|
||||
UI_ITEM_R_SLIDER | UI_ITEM_R_SPLIT_EMPTY_NAME,
|
||||
"",
|
||||
ICON_NONE);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_output<decl::Bool>("Boolean").custom_draw([](CustomSocketDrawParams ¶ms) {
|
||||
uiLayout &row = params.layout.row(true);
|
||||
row.prop(¶ms.node_ptr, "boolean", UI_ITEM_NONE, IFACE_("Boolean"), ICON_NONE);
|
||||
row.prop(
|
||||
¶ms.node_ptr, "boolean", UI_ITEM_R_SPLIT_EMPTY_NAME, IFACE_("Boolean"), ICON_NONE);
|
||||
if (gizmos::value_node_has_gizmo(params.tree, params.node)) {
|
||||
row.prop(¶ms.socket_ptr, "pin_gizmo", UI_ITEM_NONE, "", ICON_GIZMO);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_output<decl::Int>("Integer").custom_draw([](CustomSocketDrawParams ¶ms) {
|
||||
uiLayout &row = params.layout.row(true);
|
||||
row.prop(¶ms.node_ptr, "integer", UI_ITEM_NONE, "", ICON_NONE);
|
||||
row.prop(¶ms.node_ptr, "integer", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
|
||||
if (gizmos::value_node_has_gizmo(params.tree, params.node)) {
|
||||
row.prop(¶ms.socket_ptr, "pin_gizmo", UI_ITEM_NONE, "", ICON_GIZMO);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_output<decl::Rotation>("Rotation").custom_draw([](CustomSocketDrawParams ¶ms) {
|
||||
uiLayout &row = params.layout.row(true);
|
||||
row.column(true).prop(¶ms.node_ptr, "rotation_euler", UI_ITEM_NONE, "", ICON_NONE);
|
||||
row.column(true).prop(
|
||||
¶ms.node_ptr, "rotation_euler", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
|
||||
if (gizmos::value_node_has_gizmo(params.tree, params.node)) {
|
||||
row.prop(¶ms.socket_ptr, "pin_gizmo", UI_ITEM_NONE, "", ICON_GIZMO);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,14 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_output<decl::String>("String").custom_draw([](CustomSocketDrawParams ¶ms) {
|
||||
params.layout.alignment_set(ui::LayoutAlign::Expand);
|
||||
PropertyRNA *prop = RNA_struct_find_property(¶ms.node_ptr, "string");
|
||||
params.layout.prop(
|
||||
¶ms.node_ptr, prop, -1, 0, UI_ITEM_NONE, "", ICON_NONE, IFACE_("String"));
|
||||
params.layout.prop(¶ms.node_ptr,
|
||||
prop,
|
||||
-1,
|
||||
0,
|
||||
UI_ITEM_R_SPLIT_EMPTY_NAME,
|
||||
"",
|
||||
ICON_NONE,
|
||||
IFACE_("String"));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_output<decl::Vector>("Vector").custom_draw([](CustomSocketDrawParams ¶ms) {
|
||||
uiLayout &row = params.layout.row(true);
|
||||
row.column(true).prop(¶ms.node_ptr, "vector", UI_ITEM_NONE, "", ICON_NONE);
|
||||
row.column(true).prop(¶ms.node_ptr, "vector", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
|
||||
if (gizmos::value_node_has_gizmo(params.tree, params.node)) {
|
||||
row.prop(¶ms.socket_ptr, "pin_gizmo", UI_ITEM_NONE, "", ICON_GIZMO);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_output<decl::Collection>("Collection").custom_draw([](CustomSocketDrawParams ¶ms) {
|
||||
params.layout.alignment_set(ui::LayoutAlign::Expand);
|
||||
params.layout.prop(¶ms.node_ptr, "collection", UI_ITEM_NONE, "", ICON_NONE);
|
||||
params.layout.prop(¶ms.node_ptr, "collection", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_output<decl::Material>("Material").custom_draw([](CustomSocketDrawParams ¶ms) {
|
||||
params.layout.alignment_set(ui::LayoutAlign::Expand);
|
||||
params.layout.prop(¶ms.node_ptr, "material", UI_ITEM_NONE, "", ICON_NONE);
|
||||
params.layout.prop(¶ms.node_ptr, "material", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_output<decl::Object>("Object").custom_draw([](CustomSocketDrawParams ¶ms) {
|
||||
params.layout.alignment_set(ui::LayoutAlign::Expand);
|
||||
params.layout.prop(¶ms.node_ptr, "object", UI_ITEM_NONE, "", ICON_NONE);
|
||||
params.layout.prop(¶ms.node_ptr, "object", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ static void sh_node_value_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_output<decl::Float>("Value").custom_draw([](CustomSocketDrawParams ¶ms) {
|
||||
uiLayout &row = params.layout.row(true);
|
||||
row.prop(¶ms.socket_ptr, "default_value", UI_ITEM_NONE, "", ICON_NONE);
|
||||
row.prop(¶ms.socket_ptr, "default_value", UI_ITEM_R_SPLIT_EMPTY_NAME, " ", ICON_NONE);
|
||||
if (gizmos::value_node_has_gizmo(params.tree, params.node)) {
|
||||
row.prop(¶ms.socket_ptr, "pin_gizmo", UI_ITEM_NONE, "", ICON_GIZMO);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user