Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_anim.cc
| Show First 20 Lines • Show All 107 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(uiButDecorator *but_decorate) | static uiBut *ui_but_anim_decorate_find_attached_button(uiButDecorator *but) | ||||
| { | { | ||||
| uiBut *but_iter = nullptr; | uiBut *but_iter = nullptr; | ||||
| BLI_assert(UI_but_is_decorator(&but_decorate->but)); | BLI_assert(UI_but_is_decorator(but)); | ||||
| BLI_assert(but_decorate->rnapoin.data && but_decorate->rnaprop); | BLI_assert(but->rnapoin.data && but->rnaprop); | ||||
| LISTBASE_CIRCULAR_BACKWARD_BEGIN ( | LISTBASE_CIRCULAR_BACKWARD_BEGIN (uiBut *, &but->block->buttons, but_iter, but->prev) { | ||||
| uiBut *, &but_decorate->but.block->buttons, but_iter, but_decorate->but.prev) { | if (but_iter != but && | ||||
| if (but_iter != (uiBut *)but_decorate && | ui_but_rna_equals_ex(but_iter, &but->rnapoin, but->rnaprop, but->rnaindex)) { | ||||
| ui_but_rna_equals_ex( | |||||
| but_iter, &but_decorate->rnapoin, but_decorate->rnaprop, but_decorate->rnaindex)) { | |||||
| return but_iter; | return but_iter; | ||||
| } | } | ||||
| } | } | ||||
| LISTBASE_CIRCULAR_BACKWARD_END( | LISTBASE_CIRCULAR_BACKWARD_END(uiBut *, &but->block->buttons, but_iter, but->prev); | ||||
| uiBut *, &but_decorate->but.block->buttons, but_iter, but_decorate->but.prev); | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| void ui_but_anim_decorate_update_from_flag(uiButDecorator *decorator_but) | void ui_but_anim_decorate_update_from_flag(uiButDecorator *but) | ||||
| { | { | ||||
| if (!decorator_but->rnapoin.data || !decorator_but->rnaprop) { | if (!but->rnapoin.data || !but->rnaprop) { | ||||
| /* Nothing to do. */ | /* Nothing to do. */ | ||||
| return; | return; | ||||
| } | } | ||||
| const uiBut *but_anim = ui_but_anim_decorate_find_attached_button(decorator_but); | const uiBut *but_anim = ui_but_anim_decorate_find_attached_button(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(decorator_but->rnapoin.type), | RNA_struct_identifier(but->rnapoin.type), | ||||
| RNA_property_identifier(decorator_but->rnaprop)); | RNA_property_identifier(but->rnaprop)); | ||||
| return; | return; | ||||
| } | } | ||||
| const int flag = but_anim->flag; | const 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 162 Lines • ▼ Show 20 Lines | void ui_but_anim_decorate_cb(bContext *C, void *arg_but, void * /*arg_dummy*/) | ||||
| uiButDecorator *but_decorate = static_cast<uiButDecorator *>(arg_but); | uiButDecorator *but_decorate = static_cast<uiButDecorator *>(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(@campbellbarton): swapping active pointer is weak. */ | /* FIXME(@campbellbarton): swapping active pointer is weak. */ | ||||
| std::swap(but_anim->active, but_decorate->but.active); | std::swap(but_anim->active, but_decorate->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, nullptr); | WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr, nullptr); | ||||
| 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, nullptr); | WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr, nullptr); | ||||
| WM_operator_properties_free(&props_ptr); | WM_operator_properties_free(&props_ptr); | ||||
| } | } | ||||
| std::swap(but_anim->active, but_decorate->but.active); | std::swap(but_anim->active, but_decorate->active); | ||||
| wm->op_undo_depth--; | wm->op_undo_depth--; | ||||
| } | } | ||||