Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_context_menu.c
| Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | static IDProperty *shortcut_property_from_rna(bContext *C, uiBut *but) | ||||
| /* Compute data path from context to property. */ | /* Compute data path from context to property. */ | ||||
| /* If this returns null, we won't be able to bind shortcuts to these RNA properties. | /* If this returns null, we won't be able to bind shortcuts to these RNA properties. | ||||
| * Support can be added at #wm_context_member_from_ptr. */ | * Support can be added at #wm_context_member_from_ptr. */ | ||||
| const char *member_id = WM_context_member_from_ptr(C, &but->rnapoin); | const char *member_id = WM_context_member_from_ptr(C, &but->rnapoin); | ||||
| if (member_id == NULL) { | if (member_id == NULL) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| char *data_path; | |||||
| const char *data_path = RNA_path_from_ID_to_struct(&but->rnapoin); | if (RNA_struct_is_a(but->rnapoin.type, &RNA_Sequence)) { | ||||
| data_path = NULL; | |||||
| } | |||||
| else { | |||||
| data_path = RNA_path_from_ID_to_struct(&but->rnapoin); | |||||
| } | |||||
| const char *member_id_data_path = member_id; | const char *member_id_data_path = member_id; | ||||
campbellbarton: This block isn't needed once `wm_context_member_from_ptr` handles the active sequence. | |||||
| if (data_path) { | if (data_path) { | ||||
| member_id_data_path = BLI_sprintfN("%s.%s", member_id, data_path); | member_id_data_path = BLI_sprintfN("%s.%s", member_id, data_path); | ||||
| MEM_freeN((void *)data_path); | MEM_freeN((void *)data_path); | ||||
| } | } | ||||
| const char *prop_id = RNA_property_identifier(but->rnaprop); | const char *prop_id = RNA_property_identifier(but->rnaprop); | ||||
| const char *final_data_path = BLI_sprintfN("%s.%s", member_id_data_path, prop_id); | const char *final_data_path = BLI_sprintfN("%s.%s", member_id_data_path, prop_id); | ||||
| ▲ Show 20 Lines • Show All 251 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| if (but->optype) { | if (but->optype) { | ||||
| IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; | IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; | ||||
| return (bUserMenuItem *)ED_screen_user_menu_item_find_operator( | return (bUserMenuItem *)ED_screen_user_menu_item_find_operator( | ||||
| &um->items, but->optype, prop, but->opcontext); | &um->items, but->optype, prop, but->opcontext); | ||||
| } | } | ||||
| if (but->rnaprop) { | if (but->rnaprop) { | ||||
| const char *member_id = WM_context_member_from_ptr(C, &but->rnapoin); | const char *member_id = WM_context_member_from_ptr(C, &but->rnapoin); | ||||
| const char *data_path = RNA_path_from_ID_to_struct(&but->rnapoin); | char *data_path; | ||||
| if (RNA_struct_is_a(but->rnapoin.type, &RNA_Sequence)) { | |||||
| data_path = RNA_path_resolve_from_type_to_property(&but->rnapoin, but->rnaprop, &RNA_Sequence); | |||||
| } | |||||
| else { | |||||
| data_path = RNA_path_from_ID_to_struct(&but->rnapoin); | |||||
| } | |||||
| const char *member_id_data_path = member_id; | const char *member_id_data_path = member_id; | ||||
Not Done Inline ActionsThis block isn't needed once wm_context_member_from_ptr handles the active sequence. campbellbarton: This block isn't needed once `wm_context_member_from_ptr` handles the active sequence. | |||||
| if (data_path) { | if (data_path) { | ||||
| member_id_data_path = BLI_sprintfN("%s.%s", member_id, data_path); | member_id_data_path = BLI_sprintfN("%s.%s", member_id, data_path); | ||||
| } | } | ||||
| const char *prop_id = RNA_property_identifier(but->rnaprop); | const char *prop_id = RNA_property_identifier(but->rnaprop); | ||||
| bUserMenuItem *umi = (bUserMenuItem *)ED_screen_user_menu_item_find_prop( | bUserMenuItem *umi = (bUserMenuItem *)ED_screen_user_menu_item_find_prop( | ||||
| &um->items, member_id_data_path, prop_id, but->rnaindex); | &um->items, member_id_data_path, prop_id, but->rnaindex); | ||||
| if (data_path) { | if (data_path) { | ||||
| MEM_freeN((void *)data_path); | MEM_freeN((void *)data_path); | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | #endif | ||||
| } | } | ||||
| } | } | ||||
| ED_screen_user_menu_item_add_operator( | ED_screen_user_menu_item_add_operator( | ||||
| &um->items, drawstr, but->optype, but->opptr ? but->opptr->data : NULL, but->opcontext); | &um->items, drawstr, but->optype, but->opptr ? but->opptr->data : NULL, but->opcontext); | ||||
| } | } | ||||
| else if (but->rnaprop) { | else if (but->rnaprop) { | ||||
| /* NOTE: 'member_id' may be a path. */ | /* NOTE: 'member_id' may be a path. */ | ||||
| const char *member_id = WM_context_member_from_ptr(C, &but->rnapoin); | const char *member_id = WM_context_member_from_ptr(C, &but->rnapoin); | ||||
| const char *data_path = RNA_path_from_ID_to_struct(&but->rnapoin); | char *data_path; | ||||
| if (RNA_struct_is_a(but->rnapoin.type, &RNA_Sequence)) { | |||||
| data_path = RNA_path_resolve_from_type_to_property(&but->rnapoin, but->rnaprop, &RNA_Sequence); | |||||
| } | |||||
| else { | |||||
| data_path = RNA_path_from_ID_to_struct(&but->rnapoin); | |||||
| } | |||||
| const char *member_id_data_path = member_id; | const char *member_id_data_path = member_id; | ||||
Not Done Inline ActionsThis block isn't needed once wm_context_member_from_ptr handles the active sequence. campbellbarton: This block isn't needed once `wm_context_member_from_ptr` handles the active sequence. | |||||
| if (data_path) { | if (data_path) { | ||||
| member_id_data_path = BLI_sprintfN("%s.%s", member_id, data_path); | member_id_data_path = BLI_sprintfN("%s.%s", member_id, data_path); | ||||
| } | } | ||||
| const char *prop_id = RNA_property_identifier(but->rnaprop); | const char *prop_id = RNA_property_identifier(but->rnaprop); | ||||
| /* NOTE: ignore 'drawstr', use property idname always. */ | /* NOTE: ignore 'drawstr', use property idname always. */ | ||||
| ED_screen_user_menu_item_add_prop(&um->items, "", member_id_data_path, prop_id, but->rnaindex); | ED_screen_user_menu_item_add_prop(&um->items, "", member_id_data_path, prop_id, but->rnaindex); | ||||
| if (data_path) { | if (data_path) { | ||||
| MEM_freeN((void *)data_path); | MEM_freeN((void *)data_path); | ||||
| ▲ Show 20 Lines • Show All 871 Lines • Show Last 20 Lines | |||||
This block isn't needed once wm_context_member_from_ptr handles the active sequence.