diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-09-25 18:32:26 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-09-25 18:32:26 +0400 |
commit | 58082beda937b05cb2aa42e4f9f0b801a3e8663d (patch) | |
tree | 0d396166631478123871c7cbdcbd6d20db0c7c81 /source/blender/editors/interface | |
parent | cd429bdb505d7ef05503bd1b60960df8f9b849a1 (diff) |
Fix #23847: keyframe insert on button not working in popup menus, e.g.
the vector popup for node inputs.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_anim.c | 40 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 93 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 12 |
3 files changed, 107 insertions, 38 deletions
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index 0e4de9fabaa..2a30a36ffe0 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -114,74 +114,50 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) } } -void uiAnimContextProperty(const bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index) -{ - ARegion *ar= CTX_wm_region(C); - uiBlock *block; - uiBut *but; - - memset(ptr, 0, sizeof(*ptr)); - *prop= NULL; - *index= 0; - - if(ar) { - for(block=ar->uiblocks.first; block; block=block->next) { - for(but=block->buttons.first; but; but= but->next) { - if((but->active || but->flag & UI_BUT_LAST_ACTIVE) && but->rnapoin.data) { - *ptr= but->rnapoin; - *prop= but->rnaprop; - *index= but->rnaindex; - return; - } - } - } - } -} - void ui_but_anim_insert_keyframe(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_keyframe_insert_button", WM_OP_INVOKE_DEFAULT, NULL); } void ui_but_anim_delete_keyframe(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_keyframe_delete_button", WM_OP_INVOKE_DEFAULT, NULL); } void ui_but_anim_add_driver(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_driver_button_add", WM_OP_INVOKE_DEFAULT, NULL); } void ui_but_anim_remove_driver(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_driver_button_remove", WM_OP_INVOKE_DEFAULT, NULL); } void ui_but_anim_copy_driver(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_copy_driver_button", WM_OP_INVOKE_DEFAULT, NULL); } void ui_but_anim_paste_driver(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_paste_driver_button", WM_OP_INVOKE_DEFAULT, NULL); } void ui_but_anim_add_keyingset(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_keyingset_button_add", WM_OP_INVOKE_DEFAULT, NULL); } void ui_but_anim_remove_keyingset(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_keyingset_button_remove", WM_OP_INVOKE_DEFAULT, NULL); } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index e411872964a..5bcde844d45 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4255,6 +4255,7 @@ static int ui_but_menu(bContext *C, uiBut *but) static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) { + Scene *scene= CTX_data_scene(C); uiHandleButtonData *data; int retval; @@ -4906,6 +4907,98 @@ void ui_button_active_free(const bContext *C, uiBut *but) } } +/* helper function for insert keyframe, reset to default, etc operators */ +void uiContextActiveProperty(const bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index) +{ + ARegion *ar= CTX_wm_region(C); + uiBlock *block; + uiBut *but, *activebut; + + memset(ptr, 0, sizeof(*ptr)); + *prop= NULL; + *index= 0; + + while(ar) { + /* find active button */ + activebut= NULL; + + for(block=ar->uiblocks.first; block; block=block->next) { + for(but=block->buttons.first; but; but= but->next) { + if(but->active) + activebut= but; + else if(!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) + activebut= but; + } + } + + if(activebut) { + if(activebut->rnapoin.data) { + /* found RNA button */ + *ptr= activebut->rnapoin; + *prop= activebut->rnaprop; + *index= activebut->rnaindex; + return; + } + else { + /* recurse into opened menu */ + uiHandleButtonData *data= activebut->active; + if(data && data->menu) + ar = data->menu->region; + else + return; + } + } + else { + /* no active button */ + return; + } + } +} + +/* helper function for insert keyframe, reset to default, etc operators */ +void uiContextAnimUpdate(const bContext *C) +{ + Scene *scene= CTX_data_scene(C); + ARegion *ar= CTX_wm_region(C); + uiBlock *block; + uiBut *but, *activebut; + + while(ar) { + /* find active button */ + activebut= NULL; + + for(block=ar->uiblocks.first; block; block=block->next) { + for(but=block->buttons.first; but; but= but->next) { + ui_but_anim_flag(but, (scene)? scene->r.cfra: 0.0f); + + if(but->active) + activebut= but; + else if(!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) + activebut= but; + } + } + + if(activebut) { + if(activebut->rnapoin.data) { + /* found RNA button */ + return; + } + else { + /* recurse into opened menu */ + uiHandleButtonData *data= activebut->active; + if(data && data->menu) + ar = data->menu->region; + else + return; + } + } + else { + /* no active button */ + return; + } + } +} + /************** handle activating a button *************/ static uiBut *uit_but_find_open_event(ARegion *ar, wmEvent *event) diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index f0f69e06299..bcde54f473a 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -68,7 +68,7 @@ static int eyedropper_init(bContext *C, wmOperator *op) op->customdata= eye= MEM_callocN(sizeof(Eyedropper), "Eyedropper"); - uiAnimContextProperty(C, &eye->ptr, &eye->prop, &eye->index); + uiContextActiveProperty(C, &eye->ptr, &eye->prop, &eye->index); return (eye->ptr.data && eye->prop && RNA_property_editable(&eye->ptr, eye->prop)); } @@ -228,7 +228,7 @@ static int copy_data_path_button_exec(bContext *C, wmOperator *op) int index; /* try to create driver using property retrieved from UI */ - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); if (ptr.id.data && ptr.data && prop) { path= RNA_path_from_ID_to_property(&ptr, prop); @@ -266,7 +266,7 @@ static int reset_default_button_poll(bContext *C) PropertyRNA *prop; int index; - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); return (ptr.data && prop && RNA_property_editable(&ptr, prop)); } @@ -279,7 +279,7 @@ static int reset_default_button_exec(bContext *C, wmOperator *op) int index, all = RNA_boolean_get(op->ptr, "all"); /* try to reset the nominated setting to its default value */ - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); /* if there is a valid property that is editable... */ if (ptr.data && prop && RNA_property_editable(&ptr, prop)) { @@ -335,7 +335,7 @@ static int copy_to_selected_button_poll(bContext *C) PropertyRNA *prop; int index, success= 0; - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); if (ptr.data && prop) { CollectionPointerLink *link; @@ -361,7 +361,7 @@ static int copy_to_selected_button_exec(bContext *C, wmOperator *op) int index, all = RNA_boolean_get(op->ptr, "all"); /* try to reset the nominated setting to its default value */ - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); /* if there is a valid property that is editable... */ if (ptr.data && prop) { |