Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_anim.c
| Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | if (!driven) { | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| but->flag |= UI_BUT_DRIVEN; | but->flag |= UI_BUT_DRIVEN; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static uiBut *ui_but_anim_decorate_find_attached_button(uiBut *but_decorate) | static uiBut *ui_but_anim_decorate_find_attached_button(uiButDecorator *but_decorate) | ||||
| { | { | ||||
| uiBut *but_iter = NULL; | uiBut *but_iter = NULL; | ||||
| BLI_assert(UI_but_is_decorator(but_decorate)); | BLI_assert(UI_but_is_decorator(&but_decorate->but)); | ||||
| BLI_assert(but_decorate->rnasearchpoin.data && but_decorate->rnasearchprop); | BLI_assert(but_decorate->rnapoin.data && but_decorate->rnaprop); | ||||
| LISTBASE_CIRCULAR_BACKWARD_BEGIN (&but_decorate->block->buttons, but_iter, but_decorate->prev) { | LISTBASE_CIRCULAR_BACKWARD_BEGIN ( | ||||
| if (but_iter != but_decorate && | &but_decorate->but.block->buttons, but_iter, but_decorate->but.prev) { | ||||
| ui_but_rna_equals_ex(but_iter, | if (but_iter != (uiBut *)but_decorate && | ||||
| &but_decorate->rnasearchpoin, | ui_but_rna_equals_ex( | ||||
| but_decorate->rnasearchprop, | but_iter, &but_decorate->rnapoin, but_decorate->rnaprop, but_decorate->rnaindex)) { | ||||
| POINTER_AS_INT(but_decorate->custom_data))) { | |||||
| return but_iter; | return but_iter; | ||||
| } | } | ||||
| } | } | ||||
| LISTBASE_CIRCULAR_BACKWARD_END(&but_decorate->block->buttons, but_iter, but_decorate->prev); | LISTBASE_CIRCULAR_BACKWARD_END( | ||||
| &but_decorate->but.block->buttons, but_iter, but_decorate->but.prev); | |||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| void ui_but_anim_decorate_update_from_flag(uiBut *but) | void ui_but_anim_decorate_update_from_flag(uiButDecorator *decorator_but) | ||||
| { | { | ||||
| const uiBut *but_anim = ui_but_anim_decorate_find_attached_button(but); | if (!decorator_but->rnapoin.data || !decorator_but->rnaprop) { | ||||
| /* Nothing to do. */ | |||||
| return; | |||||
| } | |||||
| const uiBut *but_anim = ui_but_anim_decorate_find_attached_button(decorator_but); | |||||
| uiBut *but = &decorator_but->but; | |||||
| if (!but_anim) { | if (!but_anim) { | ||||
| printf("Could not find button with matching property to decorate (%s.%s)\n", | printf("Could not find button with matching property to decorate (%s.%s)\n", | ||||
| RNA_struct_identifier(but->rnasearchpoin.type), | RNA_struct_identifier(decorator_but->rnapoin.type), | ||||
| RNA_property_identifier(but->rnasearchprop)); | RNA_property_identifier(decorator_but->rnaprop)); | ||||
| return; | return; | ||||
| } | } | ||||
| int flag = but_anim->flag; | int flag = but_anim->flag; | ||||
| if (flag & UI_BUT_DRIVEN) { | if (flag & UI_BUT_DRIVEN) { | ||||
| but->icon = ICON_DECORATE_DRIVER; | but->icon = ICON_DECORATE_DRIVER; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| /* this operator calls UI_context_active_but_prop_get */ | /* this operator calls UI_context_active_but_prop_get */ | ||||
| WM_operator_name_call(C, "ANIM_OT_paste_driver_button", WM_OP_INVOKE_DEFAULT, NULL); | WM_operator_name_call(C, "ANIM_OT_paste_driver_button", WM_OP_INVOKE_DEFAULT, NULL); | ||||
| } | } | ||||
| void ui_but_anim_decorate_cb(bContext *C, void *arg_but, void *UNUSED(arg_dummy)) | void ui_but_anim_decorate_cb(bContext *C, void *arg_but, void *UNUSED(arg_dummy)) | ||||
| { | { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| uiBut *but_decorate = arg_but; | uiButDecorator *but_decorate = arg_but; | ||||
| uiBut *but_anim = ui_but_anim_decorate_find_attached_button(but_decorate); | uiBut *but_anim = ui_but_anim_decorate_find_attached_button(but_decorate); | ||||
| if (!but_anim) { | if (!but_anim) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* FIXME(campbell), swapping active pointer is weak. */ | /* FIXME(campbell), swapping active pointer is weak. */ | ||||
| SWAP(struct uiHandleButtonData *, but_anim->active, but_decorate->active); | SWAP(struct uiHandleButtonData *, but_anim->active, but_decorate->but.active); | ||||
| wm->op_undo_depth++; | wm->op_undo_depth++; | ||||
| if (but_anim->flag & UI_BUT_DRIVEN) { | if (but_anim->flag & UI_BUT_DRIVEN) { | ||||
| /* pass */ | /* pass */ | ||||
| /* TODO: report? */ | /* TODO: report? */ | ||||
| } | } | ||||
| else if (but_anim->flag & UI_BUT_ANIMATED_KEY) { | else if (but_anim->flag & UI_BUT_ANIMATED_KEY) { | ||||
| PointerRNA props_ptr; | PointerRNA props_ptr; | ||||
| wmOperatorType *ot = WM_operatortype_find("ANIM_OT_keyframe_delete_button", false); | wmOperatorType *ot = WM_operatortype_find("ANIM_OT_keyframe_delete_button", false); | ||||
| WM_operator_properties_create_ptr(&props_ptr, ot); | WM_operator_properties_create_ptr(&props_ptr, ot); | ||||
| RNA_boolean_set(&props_ptr, "all", but_anim->rnaindex == -1); | RNA_boolean_set(&props_ptr, "all", but_anim->rnaindex == -1); | ||||
| WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr); | WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr); | ||||
| WM_operator_properties_free(&props_ptr); | WM_operator_properties_free(&props_ptr); | ||||
| } | } | ||||
| else { | else { | ||||
| PointerRNA props_ptr; | PointerRNA props_ptr; | ||||
| wmOperatorType *ot = WM_operatortype_find("ANIM_OT_keyframe_insert_button", false); | wmOperatorType *ot = WM_operatortype_find("ANIM_OT_keyframe_insert_button", false); | ||||
| WM_operator_properties_create_ptr(&props_ptr, ot); | WM_operator_properties_create_ptr(&props_ptr, ot); | ||||
| RNA_boolean_set(&props_ptr, "all", but_anim->rnaindex == -1); | RNA_boolean_set(&props_ptr, "all", but_anim->rnaindex == -1); | ||||
| WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr); | WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr); | ||||
| WM_operator_properties_free(&props_ptr); | WM_operator_properties_free(&props_ptr); | ||||
| } | } | ||||
| SWAP(struct uiHandleButtonData *, but_anim->active, but_decorate->active); | SWAP(struct uiHandleButtonData *, but_anim->active, but_decorate->but.active); | ||||
| wm->op_undo_depth--; | wm->op_undo_depth--; | ||||
| } | } | ||||