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.)
This commit is contained in:
2009-02-07 16:43:55 +00:00
parent d28a05080c
commit f78aa0ab65
4 changed files with 24 additions and 7 deletions

View File

@@ -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);
}

View File

@@ -284,6 +284,8 @@ struct uiPopupBlockHandle {
/* for operator popups */
const char *opname;
int opcontext;
ScrArea *ctx_area;
ARegion *ctx_region;
/* return values */
int butretval;

View File

@@ -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));

View File

@@ -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)