Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_toolbar.c
| Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | static void view3d_panel_operator_redo(const bContext *C, Panel *pa) | ||||
| if (WM_operator_poll((bContext *)C, op->type)) { | if (WM_operator_poll((bContext *)C, op->type)) { | ||||
| uiBlock *block = uiLayoutGetBlock(pa->layout); | uiBlock *block = uiLayoutGetBlock(pa->layout); | ||||
| if (!WM_operator_check_ui_enabled(C, op->type->name)) | if (!WM_operator_check_ui_enabled(C, op->type->name)) | ||||
| uiLayoutSetEnabled(pa->layout, false); | uiLayoutSetEnabled(pa->layout, false); | ||||
| /* note, blockfunc is a default but->func, use Handle func to allow button callbacks too */ | /* note, blockfunc is a default but->func, use Handle func to allow button callbacks too */ | ||||
| uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, op); | UI_block_func_handle_set(block, ED_undo_operator_repeat_cb_evt, op); | ||||
| view3d_panel_operator_redo_operator(C, pa, op); | view3d_panel_operator_redo_operator(C, pa, op); | ||||
| } | } | ||||
| /* set region back */ | /* set region back */ | ||||
| CTX_wm_region_set((bContext *)C, ar); | CTX_wm_region_set((bContext *)C, ar); | ||||
| } | } | ||||
| Show All 24 Lines | static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) | ||||
| GHashIterator iter; | GHashIterator iter; | ||||
| for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) { | for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) { | ||||
| wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); | wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); | ||||
| if (BLI_strcasestr(ot->name, str)) { | if (BLI_strcasestr(ot->name, str)) { | ||||
| if (WM_operator_poll((bContext *)C, ot)) { | if (WM_operator_poll((bContext *)C, ot)) { | ||||
| if (false == uiSearchItemAdd(items, ot->name, ot, 0)) | if (false == UI_search_item_add(items, ot->name, ot, 0)) | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* ID Search browse menu, open */ | /* ID Search browse menu, open */ | ||||
| static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase) | static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase) | ||||
| { | { | ||||
| static char search[OP_MAX_TYPENAME]; | static char search[OP_MAX_TYPENAME]; | ||||
| wmEvent event; | wmEvent event; | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but; | uiBut *but; | ||||
| /* clear initial search string, then all items show */ | /* clear initial search string, then all items show */ | ||||
| search[0] = 0; | search[0] = 0; | ||||
| block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); | block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); | ||||
| uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU); | UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU); | ||||
| /* fake button, it holds space for search items */ | /* fake button, it holds space for search items */ | ||||
| uiDefBut(block, LABEL, 0, "", 10, 15, uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL); | uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 15, UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL); | ||||
| but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, ""); | but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, ""); | ||||
| uiButSetSearchFunc(but, operator_search_cb, arg_listbase, operator_call_cb, NULL); | UI_but_func_search_set(but, operator_search_cb, arg_listbase, operator_call_cb, NULL); | ||||
| uiBoundsBlock(block, 6); | UI_block_bounds_set_normal(block, 6); | ||||
| uiBlockSetDirection(block, UI_DOWN); | UI_block_direction_set(block, UI_DIR_DOWN); | ||||
| uiEndBlock(C, block); | UI_block_end(C, block); | ||||
| 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); | ||||
| ▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines | |||||