Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_select.c
| Show First 20 Lines • Show All 966 Lines • ▼ Show 20 Lines | for (node = snode->edittree->nodes.first; node; node = node->next) { | ||||
| if (BLI_strcasestr(node->name, str) || BLI_strcasestr(node->label, str)) { | if (BLI_strcasestr(node->name, str) || BLI_strcasestr(node->label, str)) { | ||||
| char name[256]; | char name[256]; | ||||
| if (node->label[0]) | if (node->label[0]) | ||||
| BLI_snprintf(name, 256, "%s (%s)", node->name, node->label); | BLI_snprintf(name, 256, "%s (%s)", node->name, node->label); | ||||
| else | else | ||||
| BLI_strncpy(name, node->name, 256); | BLI_strncpy(name, node->name, 256); | ||||
| if (false == uiSearchItemAdd(items, name, node, 0)) | if (false == UI_search_item_add(items, name, node, 0)) | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void node_find_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2) | static void node_find_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2) | ||||
| { | { | ||||
| SpaceNode *snode = CTX_wm_space_node(C); | SpaceNode *snode = CTX_wm_space_node(C); | ||||
| Show All 17 Lines | |||||
| { | { | ||||
| static char search[256] = ""; | static char search[256] = ""; | ||||
| wmEvent event; | wmEvent event; | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but; | uiBut *but; | ||||
| wmOperator *op = (wmOperator *)arg_op; | wmOperator *op = (wmOperator *)arg_op; | ||||
| block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); | block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); | ||||
| uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU); | UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU); | ||||
| but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, ""); | but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, ""); | ||||
| uiButSetSearchFunc(but, node_find_cb, op->type, node_find_call_cb, NULL); | UI_but_func_search_set(but, node_find_cb, op->type, node_find_call_cb, NULL); | ||||
| /* fake button, it holds space for search items */ | /* fake button, it holds space for search items */ | ||||
| uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxHeight(), uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL); | uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - UI_searchbox_size_y(), UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL); | ||||
| uiPopupBoundsBlock(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */ | UI_block_bounds_set_popup(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */ | ||||
| // uiButActiveOnly(C, ar, block, but); XXX using this here makes Blender hang - investigate | // UI_but_active_only(C, ar, block, but); XXX using this here makes Blender hang - investigate | ||||
| wm_event_init_from_window(win, &event); | wm_event_init_from_window(win, &event); | ||||
| event.type = EVT_BUT_OPEN; | event.type = EVT_BUT_OPEN; | ||||
| event.val = KM_PRESS; | event.val = KM_PRESS; | ||||
| event.customdata = but; | event.customdata = but; | ||||
| event.customdatafree = false; | event.customdatafree = false; | ||||
| wm_event_add(win, &event); | wm_event_add(win, &event); | ||||
| return block; | return block; | ||||
| } | } | ||||
| static int node_find_node_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | static int node_find_node_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| uiPupBlock(C, node_find_menu, op); | UI_popup_block_invoke(C, node_find_menu, op); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| void NODE_OT_find_node(wmOperatorType *ot) | void NODE_OT_find_node(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Find Node"; | ot->name = "Find Node"; | ||||
| Show All 15 Lines | |||||