From f78aa0ab65524f70ab7d0610835068718fb5a56f Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 7 Feb 2009 16:43:55 +0000 Subject: 2.5 F6 menu "redo last operation" now works, mostly :) Try it in editmode on add-UV-Sphere, or Subdivide, those work fine. Transform ops have some feedback issues or so. This is a temporary commit; brecht will take this further with nice code (event system doesn't make menus as active region but sets the original context instead, as stored in ui handler.) --- source/blender/editors/interface/interface_handlers.c | 12 +++++++++++- source/blender/editors/interface/interface_intern.h | 2 ++ source/blender/editors/interface/interface_regions.c | 4 ++++ source/blender/editors/screen/screen_ops.c | 13 +++++++------ 4 files changed, 24 insertions(+), 7 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index c7a2e46cecb..c23124de586 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3539,8 +3539,18 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, if((/*inside &&*/ !menu->menuretval && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) { but= ui_but_find_activated(ar); - if(but) + if(but) { + ScrArea *ctx_area= CTX_wm_area(C); + ARegion *ctx_region= CTX_wm_region(C); + + if(menu->ctx_area) CTX_wm_area_set(C, menu->ctx_area); + if(menu->ctx_region) CTX_wm_region_set(C, menu->ctx_region); + retval= ui_handle_button_event(C, event, but); + + if(menu->ctx_area) CTX_wm_area_set(C, ctx_area); + if(menu->ctx_region) CTX_wm_region_set(C, ctx_region); + } else retval= ui_handle_button_over(C, event, ar); } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 07c8ad04c6f..4f3b211c9de 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -284,6 +284,8 @@ struct uiPopupBlockHandle { /* for operator popups */ const char *opname; int opcontext; + ScrArea *ctx_area; + ARegion *ctx_region; /* return values */ int butretval; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index eadb3f9b2aa..4dd5dd76637 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -635,6 +635,10 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut /* create handle */ handle= MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle"); + /* store context for operator */ + handle->ctx_area= CTX_wm_area(C); + handle->ctx_region= CTX_wm_region(C); + /* create area region */ ar= ui_add_temporary_region(CTX_wm_screen(C)); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 028c0105f11..cfb4e2220a4 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1457,12 +1457,13 @@ static int redo_last_exec(bContext *C, wmOperator *op) static void redo_last_cb(bContext *C, void *arg1, void *arg2) { -#if 0 - /* XXX context here is not correct .. we get the popup block region - * context but should actually have where ever the last operator was - * executed. */ - WM_operator_name_call(C, "SCREEN_OT_redo_last", WM_OP_EXEC_DEFAULT, NULL); -#endif + wmOperator *lastop= CTX_wm_manager(C)->operators.last; + + if(lastop) { + ED_undo_pop(C); + WM_operator_repeat(C, lastop); + } + } static uiBlock *ui_block_create_redo_last(bContext *C, ARegion *ar, void *arg_op) -- cgit v1.2.3