Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_nodes.cc
| Show First 20 Lines • Show All 1,536 Lines • ▼ Show 20 Lines | static void add_attribute_search_or_value_buttons(const bContext &C, | ||||
| char socket_id_esc[sizeof(socket.identifier) * 2]; | char socket_id_esc[sizeof(socket.identifier) * 2]; | ||||
| BLI_str_escape(socket_id_esc, socket.identifier, sizeof(socket_id_esc)); | BLI_str_escape(socket_id_esc, socket.identifier, sizeof(socket_id_esc)); | ||||
| const std::string rna_path = "[\"" + std::string(socket_id_esc) + "\"]"; | const std::string rna_path = "[\"" + std::string(socket_id_esc) + "\"]"; | ||||
| const std::string rna_path_use_attribute = "[\"" + std::string(socket_id_esc) + | const std::string rna_path_use_attribute = "[\"" + std::string(socket_id_esc) + | ||||
| use_attribute_suffix + "\"]"; | use_attribute_suffix + "\"]"; | ||||
| const std::string rna_path_attribute_name = "[\"" + std::string(socket_id_esc) + | const std::string rna_path_attribute_name = "[\"" + std::string(socket_id_esc) + | ||||
| attribute_name_suffix + "\"]"; | attribute_name_suffix + "\"]"; | ||||
| /* We're handling this manually in this case. */ | |||||
| uiLayoutSetPropDecorate(layout, false); | |||||
| uiLayout *split = uiLayoutSplit(layout, 0.4f, false); | uiLayout *split = uiLayoutSplit(layout, 0.4f, false); | ||||
| uiLayout *name_row = uiLayoutRow(split, false); | uiLayout *name_row = uiLayoutRow(split, false); | ||||
| uiLayoutSetAlignment(name_row, UI_LAYOUT_ALIGN_RIGHT); | uiLayoutSetAlignment(name_row, UI_LAYOUT_ALIGN_RIGHT); | ||||
| uiItemL(name_row, socket.name, ICON_NONE); | uiItemL(name_row, socket.name, ICON_NONE); | ||||
| uiLayout *row = uiLayoutRow(split, true); | uiLayout *prop_row = uiLayoutRow(split, true); | ||||
| PointerRNA props; | PointerRNA props; | ||||
| uiItemFullO(row, | uiItemFullO(prop_row, | ||||
| "object.geometry_nodes_input_attribute_toggle", | "object.geometry_nodes_input_attribute_toggle", | ||||
| "", | "", | ||||
| ICON_SPREADSHEET, | ICON_SPREADSHEET, | ||||
| nullptr, | nullptr, | ||||
| WM_OP_INVOKE_DEFAULT, | WM_OP_INVOKE_DEFAULT, | ||||
| 0, | 0, | ||||
| &props); | &props); | ||||
| RNA_string_set(&props, "modifier_name", nmd.modifier.name); | RNA_string_set(&props, "modifier_name", nmd.modifier.name); | ||||
| RNA_string_set(&props, "prop_path", rna_path_use_attribute.c_str()); | RNA_string_set(&props, "prop_path", rna_path_use_attribute.c_str()); | ||||
| const int use_attribute = RNA_int_get(md_ptr, rna_path_use_attribute.c_str()) != 0; | const int use_attribute = RNA_int_get(md_ptr, rna_path_use_attribute.c_str()) != 0; | ||||
| if (use_attribute) { | if (use_attribute) { | ||||
| add_attribute_search_button(C, row, nmd, md_ptr, rna_path_attribute_name, socket, false); | add_attribute_search_button(C, prop_row, nmd, md_ptr, rna_path_attribute_name, socket, false); | ||||
| uiItemL(row, "", ICON_BLANK1); | uiItemL(layout, "", ICON_BLANK1); | ||||
| } | } | ||||
| else { | else { | ||||
| uiItemR(row, md_ptr, rna_path.c_str(), 0, "", ICON_NONE); | uiItemR(prop_row, md_ptr, rna_path.c_str(), 0, "", ICON_NONE); | ||||
| uiItemDecoratorR(row, md_ptr, rna_path.c_str(), -1); | uiItemDecoratorR(layout, md_ptr, rna_path.c_str(), -1); | ||||
| } | } | ||||
| } | } | ||||
| /* Drawing the properties manually with #uiItemR instead of #uiDefAutoButsRNA allows using | /* Drawing the properties manually with #uiItemR instead of #uiDefAutoButsRNA allows using | ||||
| * the node socket identifier for the property names, since they are unique, but also having | * the node socket identifier for the property names, since they are unique, but also having | ||||
| * the correct label displayed in the UI. */ | * the correct label displayed in the UI. */ | ||||
| static void draw_property_for_socket(const bContext &C, | static void draw_property_for_socket(const bContext &C, | ||||
| uiLayout *layout, | uiLayout *layout, | ||||
| Show All 13 Lines | static void draw_property_for_socket(const bContext &C, | ||||
| } | } | ||||
| char socket_id_esc[sizeof(socket.identifier) * 2]; | char socket_id_esc[sizeof(socket.identifier) * 2]; | ||||
| BLI_str_escape(socket_id_esc, socket.identifier, sizeof(socket_id_esc)); | BLI_str_escape(socket_id_esc, socket.identifier, sizeof(socket_id_esc)); | ||||
| char rna_path[sizeof(socket_id_esc) + 4]; | char rna_path[sizeof(socket_id_esc) + 4]; | ||||
| BLI_snprintf(rna_path, ARRAY_SIZE(rna_path), "[\"%s\"]", socket_id_esc); | BLI_snprintf(rna_path, ARRAY_SIZE(rna_path), "[\"%s\"]", socket_id_esc); | ||||
| uiLayout *row = uiLayoutRow(layout, true); | |||||
| uiLayoutSetPropDecorate(row, true); | |||||
| /* Use #uiItemPointerR to draw pointer properties because #uiItemR would not have enough | /* Use #uiItemPointerR to draw pointer properties because #uiItemR would not have enough | ||||
| * information about what type of ID to select for editing the values. This is because | * information about what type of ID to select for editing the values. This is because | ||||
| * pointer IDProperties contain no information about their type. */ | * pointer IDProperties contain no information about their type. */ | ||||
| switch (socket.type) { | switch (socket.type) { | ||||
| case SOCK_OBJECT: { | case SOCK_OBJECT: { | ||||
| uiItemPointerR( | uiItemPointerR(row, md_ptr, rna_path, bmain_ptr, "objects", socket.name, ICON_OBJECT_DATA); | ||||
| layout, md_ptr, rna_path, bmain_ptr, "objects", socket.name, ICON_OBJECT_DATA); | |||||
| break; | break; | ||||
| } | } | ||||
| case SOCK_COLLECTION: { | case SOCK_COLLECTION: { | ||||
| uiItemPointerR(layout, | uiItemPointerR( | ||||
| md_ptr, | row, md_ptr, rna_path, bmain_ptr, "collections", socket.name, ICON_OUTLINER_COLLECTION); | ||||
| rna_path, | |||||
| bmain_ptr, | |||||
| "collections", | |||||
| socket.name, | |||||
| ICON_OUTLINER_COLLECTION); | |||||
| break; | break; | ||||
| } | } | ||||
| case SOCK_MATERIAL: { | case SOCK_MATERIAL: { | ||||
| uiItemPointerR(layout, md_ptr, rna_path, bmain_ptr, "materials", socket.name, ICON_MATERIAL); | uiItemPointerR(row, md_ptr, rna_path, bmain_ptr, "materials", socket.name, ICON_MATERIAL); | ||||
| break; | break; | ||||
| } | } | ||||
| case SOCK_TEXTURE: { | case SOCK_TEXTURE: { | ||||
| uiItemPointerR(layout, md_ptr, rna_path, bmain_ptr, "textures", socket.name, ICON_TEXTURE); | uiItemPointerR(row, md_ptr, rna_path, bmain_ptr, "textures", socket.name, ICON_TEXTURE); | ||||
| break; | break; | ||||
| } | } | ||||
| case SOCK_IMAGE: { | case SOCK_IMAGE: { | ||||
| uiItemPointerR(layout, md_ptr, rna_path, bmain_ptr, "images", socket.name, ICON_IMAGE); | uiItemPointerR(row, md_ptr, rna_path, bmain_ptr, "images", socket.name, ICON_IMAGE); | ||||
| break; | break; | ||||
| } | } | ||||
| default: { | default: { | ||||
| if (input_has_attribute_toggle(*nmd->node_group, socket_index)) { | if (input_has_attribute_toggle(*nmd->node_group, socket_index)) { | ||||
| add_attribute_search_or_value_buttons(C, layout, *nmd, md_ptr, socket); | add_attribute_search_or_value_buttons(C, row, *nmd, md_ptr, socket); | ||||
| } | } | ||||
| else { | else { | ||||
| uiLayout *row = uiLayoutRow(layout, false); | |||||
| uiLayoutSetPropDecorate(row, true); | |||||
| uiItemR(row, md_ptr, rna_path, 0, socket.name, ICON_NONE); | uiItemR(row, md_ptr, rna_path, 0, socket.name, ICON_NONE); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void draw_property_for_output_socket(const bContext &C, | static void draw_property_for_output_socket(const bContext &C, | ||||
| uiLayout *layout, | uiLayout *layout, | ||||
| ▲ Show 20 Lines • Show All 273 Lines • Show Last 20 Lines | |||||