Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_template_search_menu.c
| Show First 20 Lines • Show All 1,031 Lines • ▼ Show 20 Lines | |||||
| * This uses a fake button to create a context menu, | * This uses a fake button to create a context menu, | ||||
| * if this ever causes hard to solve bugs we may need to create | * if this ever causes hard to solve bugs we may need to create | ||||
| * a separate context menu just for the search, however this is fairly involved. | * a separate context menu just for the search, however this is fairly involved. | ||||
| * \{ */ | * \{ */ | ||||
| static bool ui_search_menu_create_context_menu(struct bContext *C, | static bool ui_search_menu_create_context_menu(struct bContext *C, | ||||
| void *arg, | void *arg, | ||||
| void *active, | void *active, | ||||
| const struct wmEvent *UNUSED(event)) | const struct wmEvent *event) | ||||
| { | { | ||||
| struct MenuSearch_Data *data = arg; | struct MenuSearch_Data *data = arg; | ||||
| struct MenuSearch_Item *item = active; | struct MenuSearch_Item *item = active; | ||||
| bool has_menu = false; | bool has_menu = false; | ||||
| memset(&data->context_menu_data, 0x0, sizeof(data->context_menu_data)); | memset(&data->context_menu_data, 0x0, sizeof(data->context_menu_data)); | ||||
| uiBut *but = &data->context_menu_data.but; | uiBut *but = &data->context_menu_data.but; | ||||
| uiBlock *block = &data->context_menu_data.block; | uiBlock *block = &data->context_menu_data.block; | ||||
| but->block = block; | but->block = block; | ||||
| if (menu_items_to_ui_button(item, but)) { | if (menu_items_to_ui_button(item, but)) { | ||||
| ScrArea *area_prev = CTX_wm_area(C); | ScrArea *area_prev = CTX_wm_area(C); | ||||
| ARegion *region_prev = CTX_wm_region(C); | ARegion *region_prev = CTX_wm_region(C); | ||||
| if (item->wm_context != NULL) { | if (item->wm_context != NULL) { | ||||
| CTX_wm_area_set(C, item->wm_context->area); | CTX_wm_area_set(C, item->wm_context->area); | ||||
| CTX_wm_region_set(C, item->wm_context->region); | CTX_wm_region_set(C, item->wm_context->region); | ||||
| } | } | ||||
| if (ui_popup_context_menu_for_button(C, but)) { | if (ui_popup_context_menu_for_button(C, but, event)) { | ||||
| has_menu = true; | has_menu = true; | ||||
| } | } | ||||
| if (item->wm_context != NULL) { | if (item->wm_context != NULL) { | ||||
| CTX_wm_area_set(C, area_prev); | CTX_wm_area_set(C, area_prev); | ||||
| CTX_wm_region_set(C, region_prev); | CTX_wm_region_set(C, region_prev); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 108 Lines • Show Last 20 Lines | |||||