diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-02-08 02:12:59 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-02-08 02:42:26 +0400 |
commit | ff0ceb9926d23d1af37c2a09fa90abf28b482556 (patch) | |
tree | 3b0cdaed54792027c4af33aee108e53b80aeeb89 /source/blender | |
parent | 2dafd1bfb8294acd996607f2b31961f66b5a3587 (diff) |
UI: split ui_button_execute_do into begin/end
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/interface/interface.c | 6 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 19 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 3 |
3 files changed, 20 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 40e3b15e191..8ad96b4f325 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -723,7 +723,11 @@ bool uiButActiveOnly(const bContext *C, ARegion *ar, uiBlock *block, uiBut *but) /* simulate button click */ void uiButExecute(const bContext *C, uiBut *but) { - ui_button_execute_do((bContext *)C, CTX_wm_region(C), but); + ARegion *ar = CTX_wm_region(C); + void *active_back; + ui_button_execute_begin((bContext *)C, ar, but, &active_back); + /* Value is applied in begin. No further action required. */ + ui_button_execute_end((bContext *)C, ar, but, active_back); } /* use to check if we need to disable undo, but don't make any changes diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index b5d7bbd022a..625e38e3d00 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -6662,18 +6662,25 @@ void ui_button_activate_do(bContext *C, ARegion *ar, uiBut *but) ui_do_button(C, but->block, but, &event); } -void ui_button_execute_do(struct bContext *C, struct ARegion *ar, uiBut *but) +void ui_button_execute_begin(struct bContext *UNUSED(C), struct ARegion *ar, uiBut *but, void **active_back) { /* note: ideally we would not have to change 'but->active' howevwer * some functions we call don't use data (as they should be doing) */ - void *active_back = but->active; - uiHandleButtonData *data = MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData_Fake"); + uiHandleButtonData *data; + *active_back = but->active; + data = MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData_Fake"); but->active = data; data->region = ar; - ui_apply_button(C, but->block, but, data, true); - /* use onfree event so undo is handled by caller and apply is already done above */ +} + +void ui_button_execute_end(struct bContext *C, struct ARegion *UNUSED(ar), uiBut *but, void *active_back) +{ + ui_apply_button(C, but->block, but, but->active, true); + ui_apply_autokey(C, but); - button_activate_exit((bContext *)C, but, data, false, true); + + /* use onfree event so undo is handled by caller and apply is already done above */ + button_activate_exit((bContext *)C, but, but->active, false, true); but->active = active_back; } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index f3d720305bf..928ad8a4466 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -521,7 +521,8 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol PointerRNA *ui_handle_afterfunc_add_operator(struct wmOperatorType *ot, int opcontext, bool create_props); extern void ui_pan_to_scroll(const struct wmEvent *event, int *type, int *val); extern void ui_button_activate_do(struct bContext *C, struct ARegion *ar, uiBut *but); -extern void ui_button_execute_do(struct bContext *C, struct ARegion *ar, uiBut *but); +extern void ui_button_execute_begin(struct bContext *C, struct ARegion *ar, uiBut *but, void **active_back); +extern void ui_button_execute_end(struct bContext *C, struct ARegion *ar, uiBut *but, void *active_back); extern void ui_button_active_free(const struct bContext *C, uiBut *but); extern bool ui_button_is_active(struct ARegion *ar) ATTR_WARN_UNUSED_RESULT; extern int ui_button_open_menu_direction(uiBut *but); |