[Bf-blender-cvs] [c4b6fd81251] temp-geometry-nodes-attribute-search: Attribute Search: Mirror fix from rB1239cab11ff97f
Hans Goudey
noreply at git.blender.org
Tue Feb 23 22:51:16 CET 2021
Commit: c4b6fd8125188f550822cecd7d141b9dc7153212
Author: Hans Goudey
Date: Tue Feb 23 15:51:06 2021 -0600
Branches: temp-geometry-nodes-attribute-search
https://developer.blender.org/rBc4b6fd8125188f550822cecd7d141b9dc7153212
Attribute Search: Mirror fix from rB1239cab11ff97f
I tried adding this as one of the fixes to fix the interaction with the
attribute name buttons. It didn't fix that problem, but I'm not sure
I should remove it since it seemed to fix a valid situation where the
button pointer changed for RNA collection search.
===================================================================
M source/blender/editors/interface/interface.c
M source/blender/editors/space_node/drawnode.c
M source/blender/editors/space_node/node_geometry_attribute_search.cc
M source/blender/editors/space_node/node_intern.h
M source/blender/makesrna/intern/rna_nodetree.c
===================================================================
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 636efbc50ce..be1e6190061 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -819,6 +819,7 @@ static void ui_but_update_old_active_from_new(uiBut *oldbut, uiBut *but)
SWAP(ListBase, but->extra_op_icons, oldbut->extra_op_icons);
if (oldbut->type == UI_BTYPE_SEARCH_MENU) {
+ printf("MOVING OLD SEARCHBUT TO NEW SEARCHBUT\n");
uiButSearch *search_oldbut = (uiButSearch *)oldbut, *search_but = (uiButSearch *)but;
SWAP(uiButSearchArgFreeFn, search_oldbut->arg_free_fn, search_but->arg_free_fn);
@@ -874,6 +875,10 @@ static bool ui_but_update_from_old_block(const bContext *C,
uiBlock *oldblock = block->oldblock;
uiBut *but = *but_p;
+ if (but->type == UI_BTYPE_SEARCH_MENU) {
+ printf("UPDATING SEARCH MENU BUTTON FROM OLD BLOCK\n");
+ }
+
#if 0
/* Simple method - search every time. Keep this for easy testing of the "fast path." */
uiBut *oldbut = ui_but_find_old(oldblock, but);
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 34fbe65f115..220bf9a8e68 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -22,8 +22,6 @@
* \brief lower level node drawing for nodes (boarders, headers etc), also node layout.
*/
-#include "MEM_guardedalloc.h"
-
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_system.h"
@@ -3398,6 +3396,22 @@ static void std_node_socket_draw(
// uiBut *but = uiDefSearchBut(
// block, buffer, 0, ICON_NONE, 256, 10, 10, 200, UI_UNIT_Y, 0, 0, "");
+ // uiBut *but = uiDefButR(block,
+ // UI_BTYPE_SEARCH_MENU,
+ // 0,
+ // "",
+ // 0,
+ // 0,
+ // UI_UNIT_X * 10,
+ // UI_UNIT_Y,
+ // ptr,
+ // "default_value",
+ // 0,
+ // 0.0f,
+ // 0.0f,
+ // 0.0f,
+ // 0.0f,
+ // "");
uiBut *but = uiDefIconTextButR(block,
UI_BTYPE_SEARCH_MENU,
0,
@@ -3415,7 +3429,7 @@ static void std_node_socket_draw(
0.0f,
0.0f,
"");
- button_add_attribute_search(C, node, sock, but);
+ button_add_attribute_search(C, node, sock, block, but);
break;
}
case SOCK_OBJECT: {
diff --git a/source/blender/editors/space_node/node_geometry_attribute_search.cc b/source/blender/editors/space_node/node_geometry_attribute_search.cc
index b8054e4bedc..83b1b14b081 100644
--- a/source/blender/editors/space_node/node_geometry_attribute_search.cc
+++ b/source/blender/editors/space_node/node_geometry_attribute_search.cc
@@ -69,6 +69,13 @@ struct AttributeSearchData {
const bNode &node;
bNodeSocket &socket;
std::string current_value;
+
+ /* Needed for proper interaction with the search button. Otherwise the interface code can't keep
+ * track of which button is active by comparing pointers to this struct, because it is newly
+ * allocated for every redraw. */
+ uiBut *search_button;
+ uiButStore *button_store;
+ uiBlock *button_store_block;
};
static void attribute_search_update_fn(const bContext *C,
@@ -122,10 +129,13 @@ static void attribute_search_exec_fn(struct bContext *UNUSED(C), void *arg1, voi
static void attribute_search_free_fn(void *arg)
{
AttributeSearchData *data = static_cast<AttributeSearchData *>(arg);
+
+ UI_butstore_free(data->button_store_block, data->button_store);
delete data;
}
-void button_add_attribute_search(const bContext *C, bNode *node, bNodeSocket *socket, uiBut *but)
+void button_add_attribute_search(
+ const bContext *C, bNode *node, bNodeSocket *socket, uiBlock *block, uiBut *but)
{
BLI_assert(socket->type == SOCK_STRING);
@@ -145,7 +155,16 @@ void button_add_attribute_search(const bContext *C, bNode *node, bNodeSocket *so
}
AttributeSearchData *data = new AttributeSearchData{
- *space_node->edittree, *node, *socket, current_value};
+ *space_node->edittree,
+ *node,
+ *socket,
+ current_value,
+ but,
+ UI_butstore_create(block),
+ block,
+ };
+
+ UI_butstore_register(data->button_store, &data->search_button);
UI_but_func_search_set(but,
nullptr,
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 42ade9ffb44..ce070963c06 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -42,6 +42,7 @@ struct uiBut;
struct wmGizmoGroupType;
struct wmKeyConfig;
struct wmWindow;
+struct uiBlock;
#ifdef __cplusplus
extern "C" {
@@ -331,6 +332,7 @@ enum eNodeSpace_ButEvents {
void button_add_attribute_search(const struct bContext *C,
struct bNode *node,
struct bNodeSocket *socket,
+ struct uiBlock *block,
struct uiBut *but);
#ifdef __cplusplus
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 77684b03d7c..46fdfe4a862 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -9796,8 +9796,6 @@ static void rna_def_node_socket_string(BlenderRNA *brna,
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
- // prop = RNA_def_property(srna, "attributes", PROP_COLLECTION, PROP_NONE);
-
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
}
More information about the Bf-blender-cvs
mailing list