Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_context_menu.c
| Show First 20 Lines • Show All 488 Lines • ▼ Show 20 Lines | uiItemFullO_ptr(layout, | ||||
| ICON_NONE, | ICON_NONE, | ||||
| NULL, | NULL, | ||||
| WM_OP_INVOKE_DEFAULT, | WM_OP_INVOKE_DEFAULT, | ||||
| 0, | 0, | ||||
| &props_ptr); | &props_ptr); | ||||
| RNA_string_set(&props_ptr, "filepath", dir); | RNA_string_set(&props_ptr, "filepath", dir); | ||||
| } | } | ||||
| bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) | bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *event) | ||||
| { | { | ||||
| /* ui_but_is_interactive() may let some buttons through that should not get a context menu - it | /* ui_but_is_interactive() may let some buttons through that should not get a context menu - it | ||||
| * doesn't make sense for them. */ | * doesn't make sense for them. */ | ||||
| if (ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_IMAGE)) { | if (ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_IMAGE)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| uiPopupMenu *pup; | uiPopupMenu *pup; | ||||
| ▲ Show 20 Lines • Show All 441 Lines • ▼ Show 20 Lines | #endif | ||||
| if (type == PROP_STRING && ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)) { | if (type == PROP_STRING && ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)) { | ||||
| ui_but_menu_add_path_operators(layout, ptr, prop); | ui_but_menu_add_path_operators(layout, ptr, prop); | ||||
| uiItemS(layout); | uiItemS(layout); | ||||
| } | } | ||||
| } | } | ||||
| /* If the button represents an id, it can set the "id" context pointer. */ | /* If the button represents an id, it can set the "id" context pointer. */ | ||||
| if (U.experimental.use_asset_browser && ED_asset_can_make_single_from_context(C)) { | if (U.experimental.use_asset_browser && ED_asset_can_mark_single_from_context(C)) { | ||||
| ID *id = CTX_data_pointer_get_type(C, "id", &RNA_ID).data; | ID *id = CTX_data_pointer_get_type(C, "id", &RNA_ID).data; | ||||
| /* Gray out items depending on if data-block is an asset. Preferably this could be done via | /* Gray out items depending on if data-block is an asset. Preferably this could be done via | ||||
| * operator poll, but that doesn't work since the operator also works with "selected_ids", | * operator poll, but that doesn't work since the operator also works with "selected_ids", | ||||
| * which isn't cheap to check. */ | * which isn't cheap to check. */ | ||||
| uiLayout *sub = uiLayoutColumn(layout, true); | uiLayout *sub = uiLayoutColumn(layout, true); | ||||
| uiLayoutSetEnabled(sub, !id->asset_data); | uiLayoutSetEnabled(sub, !id->asset_data); | ||||
| uiItemO(sub, NULL, ICON_NONE, "ASSET_OT_mark"); | uiItemO(sub, NULL, ICON_NONE, "ASSET_OT_mark"); | ||||
| ▲ Show 20 Lines • Show All 257 Lines • ▼ Show 20 Lines | else if (region->regiontype == RGN_TYPE_NAV_BAR) { | ||||
| ED_screens_navigation_bar_tools_menu_create, | ED_screens_navigation_bar_tools_menu_create, | ||||
| NULL); | NULL); | ||||
| } | } | ||||
| else if (region->regiontype == RGN_TYPE_FOOTER) { | else if (region->regiontype == RGN_TYPE_FOOTER) { | ||||
| uiItemMenuF(layout, IFACE_("Footer"), ICON_NONE, ED_screens_footer_tools_menu_create, NULL); | uiItemMenuF(layout, IFACE_("Footer"), ICON_NONE, ED_screens_footer_tools_menu_create, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* UI List item context menu. Scripts can add items to it, by default there's nothing shown. */ | |||||
| ARegion *region = CTX_wm_region(C); | |||||
| const bool is_inside_listbox = ui_list_find_mouse_over(region, event) != NULL; | |||||
| const bool is_inside_listrow = is_inside_listbox ? | |||||
| ui_list_row_find_mouse_over(region, event->x, event->y) != | |||||
| NULL : | |||||
| false; | |||||
| if (is_inside_listrow) { | |||||
| MenuType *mt = WM_menutype_find("UI_MT_list_item_context_menu", true); | |||||
| if (mt) { | |||||
| UI_menutype_draw(C, mt, uiLayoutColumn(layout, false)); | |||||
| } | |||||
| } | |||||
| MenuType *mt = WM_menutype_find("WM_MT_button_context", true); | MenuType *mt = WM_menutype_find("WM_MT_button_context", true); | ||||
| if (mt) { | if (mt) { | ||||
| UI_menutype_draw(C, mt, uiLayoutColumn(layout, false)); | UI_menutype_draw(C, mt, uiLayoutColumn(layout, false)); | ||||
| } | } | ||||
| if (but->context) { | if (but->context) { | ||||
| CTX_store_set(C, previous_ctx); | CTX_store_set(C, previous_ctx); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines | |||||