From 167ac3606b0ac42d2e005cb6e80cead0bf140f30 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 3 Dec 2008 13:44:16 +0000 Subject: 2.5 - Made view2d manipulations redraw on area level - simplified call to send Notifiers: WM_event_add_notifier(bContext *C, int type, int value, void *data) This brings back more control to WM, no context messing within operators. :) Handlers that execute operators will be responsible for delivering correct contextes. In general: should lead to making context not exposed, but only readable via some callbacks. --- source/blender/editors/interface/interface_ops.c | 16 ++++++++-------- .../blender/editors/interface/interface_regions.c | 16 ++++++++-------- source/blender/editors/interface/view2d_ops.c | 6 ++++-- source/blender/editors/screen/screen_ops.c | 18 +++++++++--------- source/blender/editors/space_time/ed_markers.c | 21 +++++++++------------ source/blender/editors/space_time/time_ops.c | 2 +- 6 files changed, 39 insertions(+), 40 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 2852b758c81..70aa9b4cd2b 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1183,7 +1183,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiActiva } if(changed || handled) - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); } static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, uiActivateBut *data, wmEvent *event) @@ -1209,7 +1209,7 @@ static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, u if(handled) { ui_check_but(but); - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); } } @@ -1265,7 +1265,7 @@ static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiActivate if(data->interactive) ui_apply_button(block, but, data, 1); else ui_check_but(but); - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); } /* ****************** block opening for various types **************** */ @@ -2647,7 +2647,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiActivateButState st } data->state= state; - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); } static void button_activate_init(bContext *C, ARegion *ar, wmOperator *op, uiBut *but, uiBut *lastbut) @@ -2746,7 +2746,7 @@ static void button_activate_exit(bContext *C, uiActivateBut *data, wmOperator *o } /* redraw */ - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); /* clean up */ button_disable_timers(C, data); @@ -2863,7 +2863,7 @@ static int button_activate_modal(bContext *C, wmOperator *op, wmEvent *event) if(event->customdata == data->tooltiptimer) { if(!data->tooltip) { data->tooltip= ui_tooltip_create(C, data->region, but); - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); } WM_event_remove_window_timer(C->window, data->tooltiptimer); @@ -2891,14 +2891,14 @@ static int button_activate_modal(bContext *C, wmOperator *op, wmEvent *event) if(but && but->activate == data) { if(!(but->flag & UI_SELECT)) { but->flag |= UI_SELECT; - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); } } else { but= ui_but_find_activated(data->region, data, &block); if(but->flag & UI_SELECT) { but->flag &= ~UI_SELECT; - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); } } break; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 8f2f933a946..ba7add6c875 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -332,8 +332,8 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) ar->winrct.ymax= y2; /* notify change and redraw */ - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL); - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); return ar; } @@ -342,8 +342,8 @@ void ui_tooltip_free(bContext *C, ARegion *ar) { ui_remove_temporary_region(C, C->window->screen, ar); - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL); - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); } /************************* Creating Menu Blocks **********************/ @@ -650,8 +650,8 @@ uiMenuBlockHandle *ui_menu_block_create(bContext *C, ARegion *butregion, uiBut * block->flag |= UI_BLOCK_LOOP|UI_BLOCK_MOVEMOUSE_QUIT; /* notify change and redraw */ - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL); - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); SWAP(ARegion*, C->region, ar); /* XXX 2.50 bad context swapping */ WM_operator_invoke(C, WM_operatortype_find("ED_UI_OT_menu_block_handle"), NULL); @@ -665,8 +665,8 @@ void ui_menu_block_free(bContext *C, uiMenuBlockHandle *handle) ui_remove_temporary_region(C, C->window->screen, handle->region); MEM_freeN(handle); - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL); - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); } /***************************** Menu Button ***************************/ diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 0fd01ea18ed..9a6389cadc9 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -34,6 +34,8 @@ #include "DNA_space_types.h" #include "DNA_view2d_types.h" +#include "BLI_blenlib.h" + #include "BKE_global.h" #include "BKE_utildefines.h" @@ -157,7 +159,7 @@ static void view_pan_apply(bContext *C, wmOperator *op) } /* request updates to be done... */ - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_AREA_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL); /* XXX: add WM_NOTE_TIME_CHANGED? */ } @@ -480,7 +482,7 @@ static void view_zoom_apply(bContext *C, wmOperator *op) } /* request updates to be done... */ - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_AREA_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL); /* XXX: add WM_NOTE_TIME_CHANGED? */ } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index ef8b47a368f..881f7719e1e 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -335,7 +335,7 @@ static int screen_area_rip_op(bContext *C, wmOperator *op) area_copy_data((ScrArea *)newsc->areabase.first, C->area, 0); /* screen, areas init */ - WM_event_add_notifier(C->wm, win, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); return OPERATOR_FINISHED; } @@ -517,7 +517,7 @@ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int } } - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); } static void area_move_apply(bContext *C, wmOperator *op) @@ -766,7 +766,7 @@ static int area_split_apply(bContext *C, wmOperator *op) if(dir=='h') sd->origval= sd->nedge->v1->vec.y; else sd->origval= sd->nedge->v1->vec.x; - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); return 1; } @@ -781,7 +781,7 @@ static void area_split_exit(bContext *C, wmOperator *op) op->customdata = NULL; } - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); /* this makes sure aligned edges will result in aligned grabbing */ removedouble_scrverts(C->screen); @@ -887,7 +887,7 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) sd->delta= (dir == 'v')? event->x - sd->origval: event->y - sd->origval; area_move_apply_do(C, sd->origval, sd->delta, dir, sd->bigger, sd->smaller); - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); break; case LEFTMOUSE: @@ -1090,7 +1090,7 @@ static int area_join_cancel(bContext *C, wmOperator *op) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO; } - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); area_join_exit(C, op); @@ -1137,7 +1137,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) jd->sa2 = NULL; } } - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); } else { /* we are back in the area previously selected for keeping @@ -1162,7 +1162,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) jd->sa2->flag |= AREA_FLAG_DRAWJOINTO; } } - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); } } } @@ -1170,7 +1170,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) case LEFTMOUSE: if(event->val==0) { area_join_apply(C, op); - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); area_join_exit(C, op); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_time/ed_markers.c b/source/blender/editors/space_time/ed_markers.c index 1829435bf8d..0fcd9e910a7 100644 --- a/source/blender/editors/space_time/ed_markers.c +++ b/source/blender/editors/space_time/ed_markers.c @@ -56,6 +56,7 @@ #include "UI_interface_icons.h" #include "UI_view2d.h" #include "UI_resources.h" +#include "UI_text.h" #include "ED_markers.h" #include "ED_screen.h" @@ -244,7 +245,6 @@ typedef struct MarkerMove { ListBase *markers; int event_type; /* store invoke-event, to verify */ int *oldframe, evtx, firstx; - short swinid; } MarkerMove; /* copy selection to temp buffer */ @@ -293,7 +293,6 @@ static int ed_marker_move_invoke(bContext *C, wmOperator *op, wmEvent *evt) mm->evtx= evt->x; mm->firstx= evt->x; - mm->swinid= C->region->swinid; mm->event_type= evt->type; /* add temp handler */ @@ -327,13 +326,12 @@ static void ed_marker_move_apply(bContext *C, wmOperator *op) /* only for modal */ static void ed_marker_move_cancel(bContext *C, wmOperator *op) { - MarkerMove *mm= op->customdata; RNA_int_set(op->ptr, "frs", 0); ed_marker_move_apply(C, op); ed_marker_move_exit(C, op); - WM_event_add_notifier(C->wm, C->window, mm->swinid, WM_NOTE_AREA_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL); } @@ -375,7 +373,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) case RIGHTMOUSE: if(WM_modal_tweak_check(evt, mm->event_type)) { ed_marker_move_exit(C, op); - WM_event_add_notifier(C->wm, C->window, mm->swinid, WM_NOTE_AREA_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL); return OPERATOR_FINISHED; } @@ -452,7 +450,7 @@ XXX else if (mm->slink->spacetype == SPACE_ACTION) { } } - WM_event_add_notifier(C->wm, C->window, mm->swinid, WM_NOTE_AREA_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL); // headerprint(str); XXX } } @@ -620,7 +618,7 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend) select_timeline_marker_frame(cfra, 0); /* XXX notifier for markers... */ - WM_event_add_notifier(C->wm, C->window, C->region->swinid, WM_NOTE_AREA_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL); return OPERATOR_PASS_THROUGH; } @@ -682,7 +680,6 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) { View2D *v2d= UI_view2d_fromcontext(C); ListBase *markers= context_get_markers(C); - wmGesture *gesture= op->customdata; TimeMarker *marker; float xminf, xmaxf, yminf, ymaxf; int event_type= RNA_int_get(op->ptr, "event_type"); @@ -714,8 +711,8 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) } } - /* XXX notifier for markers..., XXX swinid??? */ - WM_event_add_notifier(C->wm, C->window, gesture->swinid, WM_NOTE_AREA_REDRAW, 0, NULL); + /* XXX notifier for markers... */ + WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL); return 1; } @@ -769,7 +766,7 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op) } /* XXX notifier for markers... */ - WM_event_add_notifier(C->wm, C->window, C->region->swinid, WM_NOTE_AREA_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL); return OPERATOR_FINISHED; } @@ -817,7 +814,7 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *op) /* XXX notifier for markers... */ if(changed) - WM_event_add_notifier(C->wm, C->window, C->region->swinid, WM_NOTE_AREA_REDRAW, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index 657cf30e17e..207804dae3e 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -85,7 +85,7 @@ static void change_frame_apply(bContext *C, wmOperator *op) if(cfra!=CFRA) CFRA= cfra; - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); /* XXX: add WM_NOTE_TIME_CHANGED? */ } -- cgit v1.2.3