diff options
Diffstat (limited to 'source/blender/editors')
43 files changed, 431 insertions, 383 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 398a526fbd8..4ac979d3a5c 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -41,7 +41,7 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_idprop.h" #include "BKE_library.h" #include "BKE_screen.h" @@ -1389,7 +1389,7 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, char *name, short dt, wmWindow *window; int getsizex, getsizey; - window= C->window; + window= CTX_wm_window(C); lb= ®ion->uiblocks; /* each listbase only has one block with this name, free block @@ -2196,7 +2196,7 @@ void autocomplete_end(AutoComplete *autocpl, char *autoname) static void autocomplete_id(bContext *C, char *str, void *arg_v) { int blocktype= (intptr_t)arg_v; - ListBase *listb= wich_libbase(G.main, blocktype); /* XXX */ + ListBase *listb= wich_libbase(CTX_data_main(C), blocktype); if(listb==NULL) return; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 1d1f8cb44b9..f22431ba73d 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -41,8 +41,9 @@ #include "PIL_time.h" #include "BKE_colortools.h" +#include "BKE_context.h" #include "BKE_idprop.h" -#include "BKE_global.h" +#include "BKE_report.h" #include "BKE_texture.h" #include "BKE_utildefines.h" @@ -345,7 +346,7 @@ static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data) /* XXX 2.50 missing python api */ #if 0 if(BPY_button_eval(data->str, &data->value)) { - WM_report(C, WM_LOG_WARNING, "Invalid Python expression, check console"); + BKE_report(CTX_reports(C), RPT_WARNING, "Invalid Python expression, check console"); data->value = 0.0f; /* Zero out value on error */ if(data->str[0]) { @@ -2536,14 +2537,14 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) if(ELEM(event->type, LEFTMOUSE, RETKEY)) { if(but->lock) { if(but->lockstr) { - WM_report(C, WM_LOG_WARNING, but->lockstr); + BKE_report(CTX_reports(C), RPT_WARNING, but->lockstr); button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } } else if(but->pointype && but->poin==0) { /* there's a pointer needed */ - WM_reportf(C, WM_LOG_WARNING, "DoButton pointer error: %s", but->str); + BKE_reportf(CTX_reports(C), RPT_WARNING, "DoButton pointer error: %s", but->str); button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } @@ -2862,7 +2863,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA /* setup struct */ data= MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData"); - data->window= C->window; + data->window= CTX_wm_window(C); data->region= ar; data->interactive= 0; data->state = BUTTON_STATE_INIT; @@ -3555,7 +3556,7 @@ static int ui_handler_region(bContext *C, wmEvent *event, void *userdata) int retval; /* here we handle buttons at the region level, non-modal */ - ar= C->region; + ar= CTX_wm_region(C); retval= WM_UI_HANDLER_CONTINUE; if(ar==NULL) return retval; @@ -3584,12 +3585,12 @@ static void ui_handler_remove_region(bContext *C, void *userdata) bScreen *sc; ARegion *ar; - ar= C->region; + ar= CTX_wm_region(C); if(ar == NULL) return; uiFreeBlocks(C, &ar->uiblocks); - sc= C->screen; + sc= CTX_wm_screen(C); if(sc == NULL) return; /* delayed apply callbacks, but not for screen level regions, those @@ -3608,7 +3609,7 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *userdata) /* here we handle buttons at the window level, modal, for example * while number sliding, text editing, or when a menu block is open */ - ar= C->region; + ar= CTX_wm_region(C); but= ui_but_find_activated(ar); if(but) { @@ -3654,7 +3655,7 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata) /* free if done, does not free handle itself */ if(menu->menuretval) { ui_menu_block_free(C, menu); - WM_event_remove_ui_handler(&C->window->handlers, ui_handler_popup, ui_handler_remove_popup, menu); + WM_event_remove_ui_handler(&CTX_wm_window(C)->handlers, ui_handler_popup, ui_handler_remove_popup, menu); if(menu->menuretval == UI_RETURN_OK && menu->popup_func) menu->popup_func(C, menu->popup_arg, menu->retvalue); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index a6f41195142..c60bf374e6d 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -37,7 +37,7 @@ #include "BLI_arithb.h" #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "BKE_utildefines.h" @@ -312,7 +312,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) return NULL; /* create area region */ - ar= ui_add_temporary_region(C->window->screen); + ar= ui_add_temporary_region(CTX_wm_screen(C)); memset(&type, 0, sizeof(ARegionType)); type.draw= ui_tooltip_region_draw; @@ -353,7 +353,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) y2 += butregion->winrct.ymin; } - wm_window_get_size(C->window, &winx, &winy); + wm_window_get_size(CTX_wm_window(C), &winx, &winy); if(x2 > winx) { /* super size */ @@ -387,7 +387,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) void ui_tooltip_free(bContext *C, ARegion *ar) { - ui_remove_temporary_region(C, C->window->screen, ar); + ui_remove_temporary_region(C, CTX_wm_screen(C), ar); WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); } @@ -617,6 +617,7 @@ static void ui_block_region_draw(const bContext *C, ARegion *ar) uiMenuBlockHandle *ui_menu_block_create(bContext *C, ARegion *butregion, uiBut *but, uiBlockFuncFP block_func, void *arg) { + wmWindow *window= CTX_wm_window(C); static ARegionType type; ARegion *ar; uiBlock *block; @@ -628,7 +629,7 @@ uiMenuBlockHandle *ui_menu_block_create(bContext *C, ARegion *butregion, uiBut * handle= MEM_callocN(sizeof(uiMenuBlockHandle), "uiMenuBlockHandle"); /* create area region */ - ar= ui_add_temporary_region(C->window->screen); + ar= ui_add_temporary_region(CTX_wm_screen(C)); memset(&type, 0, sizeof(ARegionType)); type.draw= ui_block_region_draw; @@ -657,7 +658,7 @@ uiMenuBlockHandle *ui_menu_block_create(bContext *C, ARegion *butregion, uiBut * if(but->flag & UI_MAKE_LEFT) block->direction |= UI_LEFT; if(but->flag & UI_MAKE_RIGHT) block->direction |= UI_RIGHT; - ui_block_position(C->window, butregion, but, block); + ui_block_position(window, butregion, but, block); } else { /* keep a list of these, needed for pulldown menus */ @@ -692,8 +693,8 @@ uiMenuBlockHandle *ui_menu_block_create(bContext *C, ARegion *butregion, uiBut * ED_region_init(C, ar); /* get winmat now that we actually have the subwindow */ - wm_subwindow_set(C->window, ar->swinid); - wm_subwindow_getmatrix(C->window, ar->swinid, block->winmat); + wm_subwindow_set(window, ar->swinid); + wm_subwindow_getmatrix(window, ar->swinid, block->winmat); /* notify change and redraw */ ED_region_tag_redraw(ar); @@ -703,7 +704,7 @@ uiMenuBlockHandle *ui_menu_block_create(bContext *C, ARegion *butregion, uiBut * void ui_menu_block_free(bContext *C, uiMenuBlockHandle *handle) { - ui_remove_temporary_region(C, C->window->screen, handle->region); + ui_remove_temporary_region(C, CTX_wm_screen(C), handle->region); MEM_freeN(handle); WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); @@ -1355,7 +1356,7 @@ uiBlock *ui_block_func_PUPMENU(bContext *C, uiMenuBlockHandle *handle, void *arg width+= 10; if (width<50) width=50; - wm_window_get_size(C->window, &xmax, &ymax); + wm_window_get_size(CTX_wm_window(C), &xmax, &ymax); /* set first item */ lastselected= 0; @@ -1527,7 +1528,7 @@ uiBlock *ui_block_func_PUPMENUCOL(bContext *C, uiMenuBlockHandle *handle, void * height= rows*MENU_BUTTON_HEIGHT; if (md->title) height+= MENU_BUTTON_HEIGHT; - wm_window_get_size(C->window, &xmax, &ymax); + wm_window_get_size(CTX_wm_window(C), &xmax, &ymax); /* find active item */ fvalue= handle->retvalue; @@ -1616,10 +1617,6 @@ uiBlock *ui_block_func_PUPMENUCOL(bContext *C, uiMenuBlockHandle *handle, void * uiBoundsBlock(block, 1); uiEndBlock(C, block); - -#if 0 - event= uiDoBlocks(&listb, 0, 1); -#endif menudata_free(md); @@ -1634,19 +1631,20 @@ uiBlock *ui_block_func_PUPMENUCOL(bContext *C, uiMenuBlockHandle *handle, void * void uiPupmenu(bContext *C, int maxrow, uiPupmenuFunc func, void *arg, char *str, ...) { + wmWindow *window= CTX_wm_window(C); uiPupMenuInfo info; uiMenuBlockHandle *menu; memset(&info, 0, sizeof(info)); - info.mx= C->window->eventstate->x; - info.my= C->window->eventstate->y; + info.mx= window->eventstate->x; + info.my= window->eventstate->y; info.maxrow= maxrow; info.instr= str; menu= ui_menu_block_create(C, NULL, NULL, ui_block_func_PUPMENU, &info); menu->popup= 1; - UI_add_popup_handlers(&C->window->handlers, menu); + UI_add_popup_handlers(&window->handlers, menu); WM_event_add_mousemove(C); menu->popup_func= func; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index cacde59145f..3213e120135 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -37,6 +37,7 @@ #include "BLI_blenlib.h" +#include "BKE_context.h" #include "BKE_global.h" #include "BKE_utildefines.h" @@ -630,16 +631,17 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked) void UI_view2d_view_ortho(const bContext *C, View2D *v2d) { + wmWindow *window= CTX_wm_window(C); rctf curmasked; /* set the matrix - pixel offsets (-0.375) for 1:1 correspondance are not applied, * as they were causing some unwanted offsets when drawing */ view2d_map_cur_using_mask(v2d, &curmasked); - wmOrtho2(C->window, curmasked.xmin, curmasked.xmax, curmasked.ymin, curmasked.ymax); + wmOrtho2(window, curmasked.xmin, curmasked.xmax, curmasked.ymin, curmasked.ymax); /* XXX is this necessary? */ - wmLoadIdentity(C->window); + wmLoadIdentity(window); } /* Set view matrices to only use one axis of 'cur' only @@ -649,7 +651,8 @@ void UI_view2d_view_ortho(const bContext *C, View2D *v2d) */ void UI_view2d_view_orthoSpecial(const bContext *C, View2D *v2d, short xaxis) { - ARegion *ar= C->region; + wmWindow *window= CTX_wm_window(C); + ARegion *ar= CTX_wm_region(C); rctf curmasked; /* set the matrix - pixel offsets (-0.375) for 1:1 correspondance are not applied, @@ -657,19 +660,19 @@ void UI_view2d_view_orthoSpecial(const bContext *C, View2D *v2d, short xaxis) */ view2d_map_cur_using_mask(v2d, &curmasked); if (xaxis) - wmOrtho2(C->window, curmasked.xmin, curmasked.xmax, 0, ar->winy); + wmOrtho2(window, curmasked.xmin, curmasked.xmax, 0, ar->winy); else - wmOrtho2(C->window, 0, ar->winx, curmasked.ymin, curmasked.ymax); + wmOrtho2(window, 0, ar->winx, curmasked.ymin, curmasked.ymax); /* XXX is this necessary? */ - wmLoadIdentity(C->window); + wmLoadIdentity(window); } /* Restore view matrices after drawing */ void UI_view2d_view_restore(const bContext *C) { - ED_region_pixelspace(C, C->region); + ED_region_pixelspace(C, CTX_wm_region(C)); } /* *********************************************************************** */ @@ -1490,24 +1493,30 @@ void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, short *regionx, /* View2D data by default resides in region, so get from region stored in context */ View2D *UI_view2d_fromcontext(const bContext *C) { - if (C->area == NULL) return NULL; - if (C->region == NULL) return NULL; - return &(C->region->v2d); + ScrArea *area= CTX_wm_area(C); + ARegion *region= CTX_wm_region(C); + + if (area == NULL) return NULL; + if (region == NULL) return NULL; + return &(region->v2d); } /* same as above, but it returns regionwindow. Utility for pulldowns or buttons */ View2D *UI_view2d_fromcontext_rwin(const bContext *C) { - if (C->area == NULL) return NULL; - if (C->region == NULL) return NULL; - if (C->region->regiontype!=RGN_TYPE_WINDOW) { - ARegion *ar= C->area->regionbase.first; + ScrArea *area= CTX_wm_area(C); + ARegion *region= CTX_wm_region(C); + + if (area == NULL) return NULL; + if (region == NULL) return NULL; + if (region->regiontype!=RGN_TYPE_WINDOW) { + ARegion *ar= area->regionbase.first; for(; ar; ar= ar->next) if(ar->regiontype==RGN_TYPE_WINDOW) return &(ar->v2d); return NULL; } - return &(C->region->v2d); + return &(region->v2d); } diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index abf114e8fd9..5995cccc874 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -37,7 +37,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_utildefines.h" #include "RNA_access.h" @@ -66,7 +66,7 @@ */ static short mouse_in_v2d_scrollers (const bContext *C, View2D *v2d, int x, int y) { - ARegion *ar= C->region; + ARegion *ar= CTX_wm_region(C); int co[2]; /* clamp x,y to region-coordinates first */ @@ -115,15 +115,14 @@ typedef struct v2dViewPanData { /* initialise panning customdata */ static int view_pan_init(bContext *C, wmOperator *op) { + ARegion *ar= CTX_wm_region(C); v2dViewPanData *vpd; - ARegion *ar; View2D *v2d; float winx, winy; /* regions now have v2d-data by default, so check for region */ - if (C->region == NULL) + if (ar == NULL) return 0; - ar= C->region; /* set custom-data for operator */ vpd= MEM_callocN(sizeof(v2dViewPanData), "v2dViewPanData"); @@ -166,8 +165,8 @@ static void view_pan_apply(bContext *C, wmOperator *op) UI_view2d_curRect_validate(v2d); /* request updates to be done... */ - ED_area_tag_redraw(C->area); - UI_view2d_sync(C->screen, v2d, V2D_LOCK_COPY); + ED_area_tag_redraw(CTX_wm_area(C)); + UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY); } /* cleanup temp customdata */ @@ -195,6 +194,7 @@ static int view_pan_exec(bContext *C, wmOperator *op) /* set up modal operator and relevant settings */ static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event) { + wmWindow *window= CTX_wm_window(C); v2dViewPanData *vpd; View2D *v2d; @@ -212,14 +212,14 @@ static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_int_set(op->ptr, "deltay", 0); if (v2d->keepofs & V2D_LOCKOFS_X) - WM_cursor_modal(C->window, BC_NS_SCROLLCURSOR); + WM_cursor_modal(window, BC_NS_SCROLLCURSOR); else if (v2d->keepofs & V2D_LOCKOFS_Y) - WM_cursor_modal(C->window, BC_EW_SCROLLCURSOR); + WM_cursor_modal(window, BC_EW_SCROLLCURSOR); else - WM_cursor_modal(C->window, BC_NSEW_SCROLLCURSOR); + WM_cursor_modal(window, BC_NSEW_SCROLLCURSOR); /* add temp handler */ - WM_event_add_modal_handler(C, &C->window->handlers, op); + WM_event_add_modal_handler(C, &window->handlers, op); return OPERATOR_RUNNING_MODAL; } @@ -251,7 +251,7 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty)); view_pan_exit(C, op); - WM_cursor_restore(C->window); + WM_cursor_restore(CTX_wm_window(C)); return OPERATOR_FINISHED; } @@ -455,12 +455,13 @@ void ED_View2D_OT_view_scrollup(wmOperatorType *ot) /* check if step-zoom can be applied */ static short view_zoomstep_ok(bContext *C) { + ARegion *ar= CTX_wm_region(C); View2D *v2d; /* check if there's a region in context to work with */ - if (C->region == NULL) + if (ar == NULL) return 0; - v2d= &C->region->v2d; + v2d= &ar->v2d; /* check that 2d-view is zoomable */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y)) @@ -473,7 +474,8 @@ static short view_zoomstep_ok(bContext *C) /* apply transform to view (i.e. adjust 'cur' rect) */ static void view_zoomstep_apply(bContext *C, wmOperator *op) { - View2D *v2d= &C->region->v2d; + ARegion *ar= CTX_wm_region(C); + View2D *v2d= &ar->v2d; float dx, dy; /* calculate amount to move view by */ @@ -494,8 +496,8 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op) UI_view2d_curRect_validate(v2d); /* request updates to be done... */ - ED_area_tag_redraw(C->area); - UI_view2d_sync(C->screen, v2d, V2D_LOCK_COPY); + ED_area_tag_redraw(CTX_wm_area(C)); + UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY); } /* --------------- Individual Operators ------------------- */ @@ -599,13 +601,14 @@ typedef struct v2dViewZoomData { /* initialise panning customdata */ static int view_zoomdrag_init(bContext *C, wmOperator *op) { + ARegion *ar= CTX_wm_region(C); v2dViewZoomData *vzd; View2D *v2d; /* regions now have v2d-data by default, so check for region */ - if (C->region == NULL) + if (ar == NULL) return 0; - v2d= &C->region->v2d; + v2d= &ar->v2d; /* check that 2d-view is zoomable */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y)) @@ -646,8 +649,8 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) UI_view2d_curRect_validate(v2d); /* request updates to be done... */ - ED_area_tag_redraw(C->area); - UI_view2d_sync(C->screen, v2d, V2D_LOCK_COPY); + ED_area_tag_redraw(CTX_wm_area(C)); + UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY); } /* cleanup temp customdata */ @@ -673,6 +676,7 @@ static int view_zoomdrag_exec(bContext *C, wmOperator *op) /* set up modal operator and relevant settings */ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) { + wmWindow *window= CTX_wm_window(C); v2dViewZoomData *vzd; View2D *v2d; @@ -690,14 +694,14 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_float_set(op->ptr, "deltay", 0); if (v2d->keepofs & V2D_LOCKOFS_X) - WM_cursor_modal(C->window, BC_NS_SCROLLCURSOR); + WM_cursor_modal(window, BC_NS_SCROLLCURSOR); else if (v2d->keepofs & V2D_LOCKOFS_Y) - WM_cursor_modal(C->window, BC_EW_SCROLLCURSOR); + WM_cursor_modal(window, BC_EW_SCROLLCURSOR); else - WM_cursor_modal(C->window, BC_NSEW_SCROLLCURSOR); + WM_cursor_modal(window, BC_NSEW_SCROLLCURSOR); /* add temp handler */ - WM_event_add_modal_handler(C, &C->window->handlers, op); + WM_event_add_modal_handler(C, &window->handlers, op); return OPERATOR_RUNNING_MODAL; } @@ -782,7 +786,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) /* free customdata */ view_zoomdrag_exit(C, op); - WM_cursor_restore(C->window); + WM_cursor_restore(CTX_wm_window(C)); return OPERATOR_FINISHED; } @@ -916,7 +920,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event, { v2dScrollerMove *vsm; View2DScrollers *scrollers; - ARegion *ar= C->region; + ARegion *ar= CTX_wm_region(C); View2D *v2d= &ar->v2d; float mask_size; int x, y; @@ -1026,8 +1030,8 @@ static void scroller_activate_apply(bContext *C, wmOperator *op) UI_view2d_curRect_validate(v2d); /* request updates to be done... */ - ED_area_tag_redraw(C->area); - UI_view2d_sync(C->screen, v2d, V2D_LOCK_COPY); + ED_area_tag_redraw(CTX_wm_area(C)); + UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY); } /* handle user input for scrollers - calculations of mouse-movement need to be done here, not in the apply callback! */ @@ -1086,15 +1090,16 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event) /* a click (or click drag in progress) should have occurred, so check if it happened in scrollbar */ static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event) { + ARegion *ar= CTX_wm_region(C); View2D *v2d= NULL; short in_scroller= 0; /* firstly, check context to see if mouse is actually in region */ // XXX isn't this the job of poll() callbacks which can't check events, but only context? - if (C->region == NULL) + if (ar == NULL) return OPERATOR_CANCELLED; else - v2d= &C->region->v2d; + v2d= &ar->v2d; /* check if mouse in scrollbars, if they're enabled */ in_scroller= mouse_in_v2d_scrollers(C, v2d, event->x, event->y); @@ -1121,7 +1126,7 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event) } /* still ok, so can add */ - WM_event_add_modal_handler(C, &C->window->handlers, op); + WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); return OPERATOR_RUNNING_MODAL; } else { diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 35b7f21910a..27f70353e39 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -35,7 +35,7 @@ #include "BLI_arithb.h" #include "BLI_rand.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "BKE_utildefines.h" @@ -95,11 +95,12 @@ static void region_draw_emboss(ARegion *ar) void ED_region_pixelspace(const bContext *C, ARegion *ar) { + wmWindow *win= CTX_wm_window(C); int width= ar->winrct.xmax-ar->winrct.xmin+1; int height= ar->winrct.ymax-ar->winrct.ymin+1; - wmOrtho2(C->window, -0.375, (float)width-0.375, -0.375, (float)height-0.375); - wmLoadIdentity(C->window); + wmOrtho2(win, -0.375, (float)width-0.375, -0.375, (float)height-0.375); + wmLoadIdentity(win); } void ED_region_do_listen(ARegion *ar, wmNotifier *note) @@ -122,7 +123,7 @@ void ED_area_overdraw_flush(bContext *C) { ScrArea *sa; - for(sa= C->screen->areabase.first; sa; sa= sa->next) { + for(sa= CTX_wm_screen(C)->areabase.first; sa; sa= sa->next) { ARegion *ar; for(ar= sa->regionbase.first; ar; ar= ar->next) { @@ -144,15 +145,17 @@ void ED_area_overdraw_flush(bContext *C) void ED_area_overdraw(bContext *C) { + wmWindow *win= CTX_wm_window(C); + bScreen *screen= CTX_wm_screen(C); ScrArea *sa; /* Draw AZones, in screenspace */ - wm_subwindow_set(C->window, C->window->screen->mainwin); + wm_subwindow_set(win, screen->mainwin); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - for(sa= C->screen->areabase.first; sa; sa= sa->next) { + for(sa= screen->areabase.first; sa; sa= sa->next) { AZone *az; for(az= sa->actionzones.first; az; az= az->next) { if(az->do_draw) { @@ -170,12 +173,14 @@ void ED_area_overdraw(bContext *C) void ED_region_do_draw(bContext *C, ARegion *ar) { + wmWindow *win= CTX_wm_window(C); + ScrArea *sa= CTX_wm_area(C); ARegionType *at= ar->type; - wm_subwindow_set(C->window, ar->swinid); + wm_subwindow_set(win, ar->swinid); if(ar->swinid && at->draw) { - UI_SetTheme(C->area); + UI_SetTheme(sa); at->draw(C, ar); UI_SetTheme(NULL); } @@ -193,7 +198,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) glRecti(20, 2, 30, 12); } - if(C->area) + if(sa) region_draw_emboss(ar); /* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */ @@ -476,7 +481,7 @@ void ED_region_init(bContext *C, ARegion *ar) // ARegionType *at= ar->type; /* refresh can be called before window opened */ - region_subwindow(C->wm, C->window, ar); + region_subwindow(CTX_wm_manager(C), CTX_wm_window(C), ar); } @@ -593,7 +598,7 @@ void area_newspace(bContext *C, ScrArea *sa, int type) } } - ED_area_initialize(C->wm, C->window, sa); + ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa); /* tell WM to refresh, cursor types etc */ WM_event_add_mousemove(C); @@ -640,13 +645,14 @@ static char *windowtype_pup(void) static void spacefunc(struct bContext *C, void *arg1, void *arg2) { - area_newspace(C, C->area, C->area->butspacetype); - ED_area_tag_redraw(C->area); + area_newspace(C, CTX_wm_area(C), CTX_wm_area(C)->butspacetype); + ED_area_tag_redraw(CTX_wm_area(C)); } /* returns offset for next button in header */ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) { + ScrArea *sa= CTX_wm_area(C); uiBut *but; int xco= 8; @@ -655,7 +661,7 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) but= uiDefIconTextButC(block, ICONTEXTROW, 0, ICON_VIEW3D, windowtype_pup(), xco, yco, XIC+10, YIC, - &(C->area->butspacetype), 1.0, SPACEICONMAX, 0, 0, + &(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. " "Click for menu of available types."); uiButSetFunc(but, spacefunc, NULL, NULL); @@ -663,18 +669,18 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) xco += XIC + 14; uiBlockSetEmboss(block, UI_EMBOSSN); - if (C->area->flag & HEADER_NO_PULLDOWN) { + if (sa->flag & HEADER_NO_PULLDOWN) { uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, ICON_DISCLOSURE_TRI_RIGHT, xco,yco,XIC,YIC-2, - &(C->area->flag), 0, 0, 0, 0, + &(sa->flag), 0, 0, 0, 0, "Show pulldown menus"); } else { uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, ICON_DISCLOSURE_TRI_DOWN, xco,yco,XIC,YIC-2, - &(C->area->flag), 0, 0, 0, 0, + &(sa->flag), 0, 0, 0, 0, "Hide pulldown menus"); } xco+=XIC; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index fbcd27cf263..b88290bd64e 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -32,6 +32,7 @@ #include "BLI_blenlib.h" +#include "BKE_context.h" #include "BKE_global.h" #include "BKE_library.h" #include "BKE_main.h" @@ -1015,33 +1016,33 @@ void ED_screens_initialize(wmWindowManager *wm) void ED_region_exit(bContext *C, ARegion *ar) { - ARegion *prevar= C->region; + ARegion *prevar= CTX_wm_region(C); - C->region= ar; + CTX_wm_region_set(C, ar); WM_event_remove_handlers(C, &ar->handlers); - C->region= prevar; + CTX_wm_region_set(C, prevar); } void ED_area_exit(bContext *C, ScrArea *sa) { - ScrArea *prevsa= C->area; + ScrArea *prevsa= CTX_wm_area(C); ARegion *ar; - C->area= sa; + CTX_wm_area_set(C, sa); for(ar= sa->regionbase.first; ar; ar= ar->next) ED_region_exit(C, ar); WM_event_remove_handlers(C, &sa->handlers); - C->area= prevsa; + CTX_wm_area_set(C, prevsa); } void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) { - wmWindow *prevwin= C?C->window:NULL; + wmWindow *prevwin= CTX_wm_window(C); ScrArea *sa; ARegion *ar; - C->window= window; + CTX_wm_window_set(C, window); for(ar= screen->regionbase.first; ar; ar= ar->next) ED_region_exit(C, ar); @@ -1049,7 +1050,7 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) for(sa= screen->areabase.first; sa; sa= sa->next) ED_area_exit(C, sa); - C->window= prevwin; + CTX_wm_window_set(C, prevwin); } /* case when on area-edge or in azones, or outside window */ @@ -1144,11 +1145,13 @@ void ED_screen_set_subwinactive(wmWindow *win, wmEvent *event) int ED_screen_area_active(const bContext *C) { + bScreen *sc= CTX_wm_screen(C); + ScrArea *sa= CTX_wm_area(C); - if(C->screen && C->area) { + if(sc && sa) { ARegion *ar; - for(ar= C->area->regionbase.first; ar; ar= ar->next) - if(ar->swinid == C->screen->subwinactive) + for(ar= sa->regionbase.first; ar; ar= ar->next) + if(ar->swinid == sc->subwinactive) return 1; } return 0; @@ -1158,7 +1161,6 @@ int ED_screen_area_active(const bContext *C) /* Do NOT call in area/region queues! */ void ed_screen_set(bContext *C, bScreen *sc) { - if(sc->full) { /* find associated full */ bScreen *sc1; for(sc1= G.main->screen.first; sc1; sc1= sc1->id.next) { @@ -1171,12 +1173,11 @@ void ed_screen_set(bContext *C, bScreen *sc) if(sc1==NULL) printf("set screen error\n"); } - if (C->screen != sc) { - ED_screen_exit(C, C->window, C->screen); - C->window->screen= sc; - C->screen= sc; + if (CTX_wm_screen(C) != sc) { + ED_screen_exit(C, CTX_wm_window(C), CTX_wm_screen(C)); + CTX_wm_window(C)->screen= sc; - ED_screen_refresh(C->wm, C->window); + ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C)); WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); } } @@ -1188,9 +1189,9 @@ void ed_screen_fullarea(bContext *C) ScrArea *newa, *old; short fulltype; - if(C->area->full) { - sc= C->area->full; /* the old screen to restore */ - oldscreen= C->screen; /* the one disappearing */ + if(CTX_wm_area(C)->full) { + sc= CTX_wm_area(C)->full; /* the old screen to restore */ + oldscreen= CTX_wm_screen(C); /* the one disappearing */ fulltype = sc->full; @@ -1211,7 +1212,7 @@ void ed_screen_fullarea(bContext *C) // in autoplay screens the headers are disabled by // default. So use the old headertype instead - area_copy_data(old, C->area, 1); /* 1 = swap spacelist */ + area_copy_data(old, CTX_wm_area(C), 1); /* 1 = swap spacelist */ old->full= NULL; @@ -1222,33 +1223,33 @@ void ed_screen_fullarea(bContext *C) } } else { + oldscreen= CTX_wm_screen(C); + /* is there only 1 area? */ - if(C->screen->areabase.first==C->screen->areabase.last) return; - if(C->area->spacetype==SPACE_INFO) return; + if(oldscreen->areabase.first==CTX_wm_screen(C)->areabase.last) return; + if(CTX_wm_area(C)->spacetype==SPACE_INFO) return; - C->screen->full = SCREENFULL; + oldscreen->full = SCREENFULL; - oldscreen= C->screen; - sc= screen_add(C->window, "temp"); + sc= screen_add(CTX_wm_window(C), "temp"); /* returns the top small area */ - newa= area_split(C->window, sc, (ScrArea *)sc->areabase.first, 'h', 0.99f); + newa= area_split(CTX_wm_window(C), sc, (ScrArea *)sc->areabase.first, 'h', 0.99f); area_newspace(C, newa, SPACE_INFO); /* copy area */ newa= newa->prev; - area_copy_data(newa, C->area, 1); /* 1 = swap spacelist */ + area_copy_data(newa, CTX_wm_area(C), 1); /* 1 = swap spacelist */ - C->area->full= oldscreen; + CTX_wm_area(C)->full= oldscreen; newa->full= oldscreen; newa->next->full= oldscreen; - C->screen= oldscreen; ed_screen_set(C, sc); } /* XXX bad code: setscreen() ends with first area active. fullscreen render assumes this too */ - C->area= sc->areabase.first; + CTX_wm_area_set(C, sc->areabase.first); /* XXX retopo_force_update(); */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index c4011550a07..4514d54e317 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -29,7 +29,7 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_screen.h" @@ -53,25 +53,25 @@ int ED_operator_areaactive(bContext *C) { - if(C->window==NULL) return 0; - if(C->screen==NULL) return 0; - if(C->area==NULL) return 0; + if(CTX_wm_window(C)==NULL) return 0; + if(CTX_wm_screen(C)==NULL) return 0; + if(CTX_wm_area(C)==NULL) return 0; return 1; } int ED_operator_screenactive(bContext *C) { - if(C->window==NULL) return 0; - if(C->screen==NULL) return 0; + if(CTX_wm_window(C)==NULL) return 0; + if(CTX_wm_screen(C)==NULL) return 0; return 1; } /* when mouse is over area-edge */ int ED_operator_screen_mainwinactive(bContext *C) { - if(C->window==NULL) return 0; - if(C->screen==NULL) return 0; - if (C->screen->subwinactive!=C->screen->mainwin) return 0; + if(CTX_wm_window(C)==NULL) return 0; + if(CTX_wm_screen(C)==NULL) return 0; + if (CTX_wm_screen(C)->subwinactive!=CTX_wm_screen(C)->mainwin) return 0; return 1; } @@ -141,7 +141,7 @@ AZone *is_in_area_actionzone(ScrArea *sa, int x, int y) static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event) { - AZone *az= is_in_area_actionzone(C->area, event->x, event->y); + AZone *az= is_in_area_actionzone(CTX_wm_area(C), event->x, event->y); sActionzoneData *sad; /* quick escape */ @@ -150,12 +150,12 @@ static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event) /* ok we do the actionzone */ sad= op->customdata= MEM_callocN(sizeof(sActionzoneData), "sActionzoneData"); - sad->sa1= C->area; + sad->sa1= CTX_wm_area(C); sad->az= az; sad->x= event->x; sad->y= event->y; /* add modal handler */ - WM_event_add_modal_handler(C, &C->window->handlers, op); + WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); return OPERATOR_RUNNING_MODAL; } @@ -171,14 +171,15 @@ static void actionzone_exit(bContext *C, wmOperator *op) static void actionzone_apply(bContext *C, wmOperator *op) { wmEvent event; + wmWindow *win= CTX_wm_window(C); - event= *(C->window->eventstate); /* XXX huh huh? make api call */ + event= *(win->eventstate); /* XXX huh huh? make api call */ event.type= EVT_ACTIONZONE; event.customdata= op->customdata; event.customdatafree= TRUE; op->customdata= NULL; - wm_event_add(C->window, &event); + wm_event_add(win, &event); } static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event) @@ -205,7 +206,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event) if(ABS(deltax) > 12 || ABS(deltay) > 12) { /* second area, for join */ - sad->sa2= screen_areahascursor(C->screen, event->x, event->y); + sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y); /* apply sends event */ actionzone_apply(C, op); actionzone_exit(C, op); @@ -243,25 +244,30 @@ void ED_SCR_OT_actionzone(wmOperatorType *ot) conventions: 'atomic' and 'dont think for user' :) */ static int screen_area_rip_op(bContext *C, wmOperator *op) { - wmWindow *win; - bScreen *newsc; + wmWindow *newwin, *win; + bScreen *newsc, *sc; + ScrArea *sa; rcti rect; + win= CTX_wm_window(C); + sc= CTX_wm_screen(C); + sa= CTX_wm_area(C); + /* poll() checks area context, but we don't accept full-area windows */ - if(C->screen->full != SCREENNORMAL) + if(sc->full != SCREENNORMAL) return OPERATOR_CANCELLED; /* adds window to WM */ - rect= C->area->totrct; - BLI_translate_rcti(&rect, C->window->posx, C->window->posy); - win= WM_window_open(C, &rect); + rect= sa->totrct; + BLI_translate_rcti(&rect, win->posx, win->posy); + newwin= WM_window_open(C, &rect); /* allocs new screen and adds to newly created window, using window size */ - newsc= screen_add(win, C->screen->id.name+2); + newsc= screen_add(newwin, sc->id.name+2); win->screen= newsc; /* copy area to new screen */ - area_copy_data((ScrArea *)newsc->areabase.first, C->area, 0); + area_copy_data((ScrArea *)newsc->areabase.first, sa, 0); /* screen, areas init */ WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); @@ -350,6 +356,7 @@ static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller /* return 0: init failed */ static int area_move_init (bContext *C, wmOperator *op) { + bScreen *sc= CTX_wm_screen(C); ScrEdge *actedge; sAreaMoveData *md; int x, y; @@ -359,7 +366,7 @@ static int area_move_init (bContext *C, wmOperator *op) y= RNA_int_get(op->ptr, "y"); /* setup */ - actedge= screen_find_active_scredge(C->screen, x, y); + actedge= screen_find_active_scredge(sc, x, y); if(actedge==NULL) return 0; md= MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData"); @@ -369,10 +376,10 @@ static int area_move_init (bContext *C, wmOperator *op) if(md->dir=='h') md->origval= actedge->v1->vec.y; else md->origval= actedge->v1->vec.x; - select_connected_scredge(C->screen, actedge); + select_connected_scredge(sc, actedge); /* now all vertices with 'flag==1' are the ones that can be moved. */ - area_move_set_limits(C->screen, md->dir, &md->bigger, &md->smaller); + area_move_set_limits(sc, md->dir, &md->bigger, &md->smaller); return 1; } @@ -380,26 +387,28 @@ static int area_move_init (bContext *C, wmOperator *op) /* moves selected screen edge amount of delta, used by split & move */ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int bigger, int smaller) { + wmWindow *win= CTX_wm_window(C); + bScreen *sc= CTX_wm_screen(C); ScrVert *v1; delta= CLAMPIS(delta, -smaller, bigger); - for (v1= C->screen->vertbase.first; v1; v1= v1->next) { + for (v1= sc->vertbase.first; v1; v1= v1->next) { if (v1->flag) { /* that way a nice AREAGRID */ - if((dir=='v') && v1->vec.x>0 && v1->vec.x<C->window->sizex-1) { + if((dir=='v') && v1->vec.x>0 && v1->vec.x<win->sizex-1) { v1->vec.x= origval + delta; if(delta != bigger && delta != -smaller) v1->vec.x-= (v1->vec.x % AREAGRID); } - if((dir=='h') && v1->vec.y>0 && v1->vec.y<C->window->sizey-1) { + if((dir=='h') && v1->vec.y>0 && v1->vec.y<win->sizey-1) { v1->vec.y= origval + delta; v1->vec.y+= AREAGRID-1; v1->vec.y-= (v1->vec.y % AREAGRID); /* prevent too small top header */ - if(v1->vec.y > C->window->sizey-AREAMINY) - v1->vec.y= C->window->sizey-AREAMINY; + if(v1->vec.y > win->sizey-AREAMINY) + v1->vec.y= win->sizey-AREAMINY; } } } @@ -423,8 +432,8 @@ static void area_move_exit(bContext *C, wmOperator *op) op->customdata= NULL; /* this makes sure aligned edges will result in aligned grabbing */ - removedouble_scrverts(C->screen); - removedouble_scredges(C->screen); + removedouble_scrverts(CTX_wm_screen(C)); + removedouble_scredges(CTX_wm_screen(C)); } static int area_move_exec(bContext *C, wmOperator *op) @@ -448,7 +457,7 @@ static int area_move_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_PASS_THROUGH; /* add temp handler */ - WM_event_add_modal_handler(C, &C->window->handlers, op); + WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); return OPERATOR_RUNNING_MODAL; } @@ -575,26 +584,27 @@ typedef struct sAreaSplitData /* generic init, no UI stuff here */ static int area_split_init(bContext *C, wmOperator *op) { + ScrArea *sa= CTX_wm_area(C); sAreaSplitData *sd; int dir; /* required context */ - if(C->area==NULL) return 0; + if(sa==NULL) return 0; /* required properties */ dir= RNA_enum_get(op->ptr, "dir"); /* minimal size */ - if(dir=='v' && C->area->winx < 2*AREAMINX) return 0; - if(dir=='h' && C->area->winy < 2*AREAMINY) return 0; + if(dir=='v' && sa->winx < 2*AREAMINX) return 0; + if(dir=='h' && sa->winy < 2*AREAMINY) return 0; /* custom data */ sd= (sAreaSplitData*)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); op->customdata= sd; - sd->sarea= C->area; - sd->origsize= dir=='v' ? C->area->winx:C->area->winy; - sd->origmin = dir=='v' ? C->area->totrct.xmin:C->area->totrct.ymin; + sd->sarea= sa; + sd->origsize= dir=='v' ? sa->winx:sa->winy; + sd->origmin = dir=='v' ? sa->totrct.xmin:sa->totrct.ymin; return 1; } @@ -632,6 +642,7 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb) /* do the split, return success */ static int area_split_apply(bContext *C, wmOperator *op) { + bScreen *sc= CTX_wm_screen(C); sAreaSplitData *sd= (sAreaSplitData *)op->customdata; float fac; int dir; @@ -639,15 +650,15 @@ static int area_split_apply(bContext *C, wmOperator *op) fac= RNA_float_get(op->ptr, "fac"); dir= RNA_enum_get(op->ptr, "dir"); - sd->narea= area_split(C->window, C->screen, sd->sarea, dir, fac); + sd->narea= area_split(CTX_wm_window(C), sc, sd->sarea, dir, fac); if(sd->narea) { ScrVert *sv; - sd->nedge= area_findsharededge(C->screen, sd->sarea, sd->narea); + sd->nedge= area_findsharededge(sc, sd->sarea, sd->narea); /* select newly created edge, prepare for moving edge */ - for(sv= C->screen->vertbase.first; sv; sv= sv->next) + for(sv= sc->vertbase.first; sv; sv= sv->next) sv->flag = 0; sd->nedge->v1->flag= 1; @@ -674,8 +685,8 @@ static void area_split_exit(bContext *C, wmOperator *op) 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); - removedouble_scredges(C->screen); + removedouble_scrverts(CTX_wm_screen(C)); + removedouble_scredges(CTX_wm_screen(C)); } @@ -693,7 +704,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_PASS_THROUGH; /* is this our *sad? if areas not equal it should be passed on */ - if(C->area!=sad->sa1 || sad->sa1!=sad->sa2) + if(CTX_wm_area(C)!=sad->sa1 || sad->sa1!=sad->sa2) return OPERATOR_PASS_THROUGH; /* prepare operator state vars */ @@ -718,10 +729,10 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) /* do the split */ if(area_split_apply(C, op)) { - area_move_set_limits(C->screen, dir, &sd->bigger, &sd->smaller); + area_move_set_limits(CTX_wm_screen(C), dir, &sd->bigger, &sd->smaller); /* add temp handler for edge move or cancel */ - WM_event_add_modal_handler(C, &C->window->handlers, op); + WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); return OPERATOR_RUNNING_MODAL; } @@ -753,9 +764,9 @@ static int area_split_cancel(bContext *C, wmOperator *op) { sAreaSplitData *sd= (sAreaSplitData *)op->customdata; - if (screen_area_join(C, C->screen, sd->sarea, sd->narea)) { - if (C->area == sd->narea) { - C->area = NULL; + if (screen_area_join(C, CTX_wm_screen(C), sd->sarea, sd->narea)) { + if (CTX_wm_area(C) == sd->narea) { + CTX_wm_area_set(C, NULL); } sd->narea = NULL; } @@ -837,7 +848,7 @@ static int frame_offset_exec(bContext *C, wmOperator *op) delta = RNA_int_get(op->ptr, "delta"); - C->scene->r.cfra += delta; + CTX_data_scene(C)->r.cfra += delta; WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); /* XXX: add WM_NOTE_TIME_CHANGED? */ @@ -864,20 +875,20 @@ void ED_SCR_OT_frame_offset(wmOperatorType *ot) /* function to be called outside UI context, or for redo */ static int screen_set_exec(bContext *C, wmOperator *op) { - bScreen *screen= C->screen; + bScreen *screen= CTX_wm_screen(C); int delta= RNA_int_get(op->ptr, "delta"); /* this screen is 'fake', solve later XXX */ - if(C->area->full) + if(CTX_wm_area(C)->full) return OPERATOR_CANCELLED; if(delta==1) { screen= screen->id.next; - if(screen==NULL) screen= G.main->screen.first; + if(screen==NULL) screen= CTX_data_main(C)->screen.first; } else if(delta== -1) { screen= screen->id.prev; - if(screen==NULL) screen= G.main->screen.last; + if(screen==NULL) screen= CTX_data_main(C)->screen.last; } else { screen= NULL; @@ -979,8 +990,8 @@ static int area_join_init(bContext *C, wmOperator *op) x2= RNA_int_get(op->ptr, "x2"); y2= RNA_int_get(op->ptr, "y2"); - sa1 = screen_areahascursor(C->screen, x1, y1); - sa2 = screen_areahascursor(C->screen, x2, y2); + sa1 = screen_areahascursor(CTX_wm_screen(C), x1, y1); + sa2 = screen_areahascursor(CTX_wm_screen(C), x2, y2); if(sa1==NULL || sa2==NULL || sa1==sa2) return 0; @@ -1002,11 +1013,11 @@ static int area_join_apply(bContext *C, wmOperator *op) sAreaJoinData *jd = (sAreaJoinData *)op->customdata; if (!jd) return 0; - if(!screen_area_join(C, C->screen, jd->sa1, jd->sa2)){ + if(!screen_area_join(C, CTX_wm_screen(C), jd->sa1, jd->sa2)){ return 0; } - if (C->area == jd->sa2) { - C->area = NULL; + if (CTX_wm_area(C) == jd->sa2) { + CTX_wm_area_set(C, NULL); } return 1; @@ -1021,9 +1032,9 @@ static void area_join_exit(bContext *C, wmOperator *op) } /* this makes sure aligned edges will result in aligned grabbing */ - removedouble_scredges(C->screen); - removenotused_scredges(C->screen); - removenotused_scrverts(C->screen); + removedouble_scredges(CTX_wm_screen(C)); + removenotused_scredges(CTX_wm_screen(C)); + removenotused_scrverts(CTX_wm_screen(C)); } static int area_join_exec(bContext *C, wmOperator *op) @@ -1062,7 +1073,7 @@ static int area_join_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_PASS_THROUGH; /* add temp handler */ - WM_event_add_modal_handler(C, &C->window->handlers, op); + WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); return OPERATOR_RUNNING_MODAL; } @@ -1093,6 +1104,7 @@ static int area_join_cancel(bContext *C, wmOperator *op) /* modal callback while selecting area (space) that will be removed */ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) { + bScreen *sc= CTX_wm_screen(C); sAreaJoinData *jd = (sAreaJoinData *)op->customdata; /* execute the events */ @@ -1100,12 +1112,12 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) case MOUSEMOVE: { - ScrArea *sa = screen_areahascursor(C->screen, event->x, event->y); + ScrArea *sa = screen_areahascursor(sc, event->x, event->y); int dir; if (sa) { if (jd->sa1 != sa) { - dir = area_getorientation(C->screen, jd->sa1, sa); + dir = area_getorientation(sc, jd->sa1, sa); if (dir >= 0) { if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO; jd->sa2 = sa; @@ -1116,7 +1128,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) we check if area has common border with the one marked for removal in this case we can swap areas. */ - dir = area_getorientation(C->screen, sa, jd->sa2); + dir = area_getorientation(sc, sa, jd->sa2); if (dir >= 0) { if (jd->sa1) jd->sa1->flag &= ~AREA_FLAG_DRAWJOINFROM; if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO; @@ -1142,13 +1154,13 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) jd->sa2 = sa; if (jd->sa1) jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM; if (jd->sa2) jd->sa2->flag |= AREA_FLAG_DRAWJOINTO; - dir = area_getorientation(C->screen, jd->sa1, jd->sa2); + dir = area_getorientation(sc, jd->sa1, jd->sa2); if (dir < 0) { printf("oops, didn't expect that!\n"); } } else { - dir = area_getorientation(C->screen, jd->sa1, sa); + dir = area_getorientation(sc, jd->sa1, sa); if (dir >= 0) { if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO; jd->sa2 = sa; @@ -1207,7 +1219,7 @@ void ED_SCR_OT_area_join(wmOperatorType *ot) static int repeat_last_exec(bContext *C, wmOperator *op) { - wmOperator *lastop= C->wm->operators.last; + wmOperator *lastop= CTX_wm_manager(C)->operators.last; if(lastop) { printf("repeat %s\n", lastop->type->idname); @@ -1236,17 +1248,19 @@ void ED_SCR_OT_repeat_last(wmOperatorType *ot) /* insert a region in the area region list */ static int region_split_exec(bContext *C, wmOperator *op) { - ARegion *newar= BKE_area_region_copy(C->region); + ScrArea *sa= CTX_wm_area(C); + ARegion *ar= CTX_wm_region(C); + ARegion *newar= BKE_area_region_copy(ar); int dir= RNA_enum_get(op->ptr, "dir"); - BLI_insertlinkafter(&C->area->regionbase, C->region, newar); + BLI_insertlinkafter(&sa->regionbase, CTX_wm_region(C), newar); - newar->alignment= C->region->alignment; + newar->alignment= ar->alignment; if(dir=='h') - C->region->alignment= RGN_ALIGN_HSPLIT; + ar->alignment= RGN_ALIGN_HSPLIT; else - C->region->alignment= RGN_ALIGN_VSPLIT; + ar->alignment= RGN_ALIGN_VSPLIT; WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); @@ -1276,14 +1290,16 @@ void ED_SCR_OT_region_split(wmOperatorType *ot) /* flip a region alignment */ static int region_flip_exec(bContext *C, wmOperator *op) { - if(C->region->alignment==RGN_ALIGN_TOP) - C->region->alignment= RGN_ALIGN_BOTTOM; - else if(C->region->alignment==RGN_ALIGN_BOTTOM) - C->region->alignment= RGN_ALIGN_TOP; - else if(C->region->alignment==RGN_ALIGN_LEFT) - C->region->alignment= RGN_ALIGN_RIGHT; - else if(C->region->alignment==RGN_ALIGN_RIGHT) - C->region->alignment= RGN_ALIGN_LEFT; + ARegion *ar= CTX_wm_region(C); + + if(ar->alignment==RGN_ALIGN_TOP) + ar->alignment= RGN_ALIGN_BOTTOM; + else if(ar->alignment==RGN_ALIGN_BOTTOM) + ar->alignment= RGN_ALIGN_TOP; + else if(ar->alignment==RGN_ALIGN_LEFT) + ar->alignment= RGN_ALIGN_RIGHT; + else if(ar->alignment==RGN_ALIGN_RIGHT) + ar->alignment= RGN_ALIGN_LEFT; WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); diff --git a/source/blender/editors/space_action/action_header.c b/source/blender/editors/space_action/action_header.c index beca0f07748..fc0299b0851 100644 --- a/source/blender/editors/space_action/action_header.c +++ b/source/blender/editors/space_action/action_header.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -66,7 +66,7 @@ static void do_viewmenu(bContext *C, void *arg, int event) static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -99,7 +99,7 @@ static void do_action_buttons(bContext *C, void *arg, int event) void action_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; + ScrArea *sa= CTX_wm_area(C); uiBlock *block; int xco, yco= 3; @@ -115,7 +115,7 @@ void action_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, + uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); xco+=XIC+xmax; } diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 26c99734d2d..35b5d592637 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -42,7 +42,7 @@ #include "BLI_rand.h" #include "BKE_colortools.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_space_api.h" @@ -159,7 +159,7 @@ static void action_main_area_init(wmWindowManager *wm, ARegion *ar) static void action_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - // SpaceAction *saction= C->area->spacedata.first; + // SpaceAction *saction= (SpaceAction*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; float col[3]; diff --git a/source/blender/editors/space_api/space.c b/source/blender/editors/space_api/space.c index 1d9e3ac97ff..3112cfffb22 100644 --- a/source/blender/editors/space_api/space.c +++ b/source/blender/editors/space_api/space.c @@ -34,7 +34,7 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 59198aaf3ba..2e958a4d6dc 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -29,7 +29,7 @@ #include "DNA_windowmanager_types.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "UI_interface.h" diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index 9ffcc107753..74e062f5888 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -66,7 +66,7 @@ static void do_viewmenu(bContext *C, void *arg, int event) static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -106,8 +106,8 @@ static void do_buttons_buttons(bContext *C, void *arg, int event) void buttons_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; - SpaceButs *sbuts= sa->spacedata.first; + ScrArea *sa= CTX_wm_area(C); + SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C); uiBlock *block; int xco, yco= 3; @@ -123,7 +123,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, + uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); xco+=XIC+xmax; @@ -182,7 +182,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) uiBlockEndAlign(block); xco+=XIC; - uiDefButI(block, NUM, B_NEWFRAME, "", (xco+20),yco,60,YIC, &(C->scene->r.cfra), 1.0, MAXFRAMEF, 0, 0, "Displays Current Frame of animation. Click to change."); + uiDefButI(block, NUM, B_NEWFRAME, "", (xco+20),yco,60,YIC, &(CTX_data_scene(C)->r.cfra), 1.0, MAXFRAMEF, 0, 0, "Displays Current Frame of animation. Click to change."); xco+= 80; // XXX buttons_active_id(&id, &idfrom); diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 9ed56afec18..6819a28406d 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -41,7 +41,7 @@ #include "BLI_rand.h" #include "BKE_colortools.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_space_api.h" @@ -158,7 +158,7 @@ static void buttons_main_area_init(wmWindowManager *wm, ARegion *ar) static void buttons_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - // SpaceButs *sbuts= C->area->spacedata.first; + // SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; float col[3], fac; diff --git a/source/blender/editors/space_file/file_header.c b/source/blender/editors/space_file/file_header.c index c1dd69de1be..3669249648f 100644 --- a/source/blender/editors/space_file/file_header.c +++ b/source/blender/editors/space_file/file_header.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -66,7 +66,7 @@ static void do_viewmenu(bContext *C, void *arg, int event) static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -100,7 +100,7 @@ static void do_file_buttons(bContext *C, void *arg, int event) void file_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; + ScrArea *sa= CTX_wm_area(C); uiBlock *block; int xco, yco= 3; @@ -116,7 +116,7 @@ void file_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, + uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); xco+=XIC+xmax; } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 36e2bae133b..ea20758884d 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -54,7 +54,7 @@ #include "BLI_storage_types.h" #include "BLI_dynstr.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index b8bc573e2cd..5e19a993b73 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -43,7 +43,7 @@ #include "BLI_rand.h" #include "BKE_colortools.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_space_api.h" @@ -141,7 +141,7 @@ static void file_main_area_init(wmWindowManager *wm, ARegion *ar) static void file_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - // SpaceFile *sfile= C->area->spacedata.first; + // SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; float col[3]; diff --git a/source/blender/editors/space_image/image_header.c b/source/blender/editors/space_image/image_header.c index a9cf0e03fe8..f741a7d44c0 100644 --- a/source/blender/editors/space_image/image_header.c +++ b/source/blender/editors/space_image/image_header.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -66,7 +66,7 @@ static void do_viewmenu(bContext *C, void *arg, int event) static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -99,7 +99,7 @@ static void do_image_buttons(bContext *C, void *arg, int event) void image_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; + ScrArea *sa= CTX_wm_area(C); uiBlock *block; int xco, yco= 3; @@ -115,7 +115,7 @@ void image_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, + uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); xco+=XIC+xmax; } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 7a96fb0622c..ca642072829 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -42,7 +42,7 @@ #include "BLI_rand.h" #include "BKE_colortools.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_space_api.h" @@ -141,7 +141,7 @@ static void image_main_area_init(wmWindowManager *wm, ARegion *ar) static void image_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - // SpaceImage *simage= C->area->spacedata.first; + // SpaceImage *simage= (SpaceImage*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; float col[3]; diff --git a/source/blender/editors/space_info/info_header.c b/source/blender/editors/space_info/info_header.c index efaae1afb2e..9d6c7be9898 100644 --- a/source/blender/editors/space_info/info_header.c +++ b/source/blender/editors/space_info/info_header.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -66,7 +66,7 @@ static void do_viewmenu(bContext *C, void *arg, int event) static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -100,7 +100,7 @@ static void do_info_buttons(bContext *C, void *arg, int event) void info_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; + ScrArea *sa= CTX_wm_area(C); uiBlock *block; int xco, yco= 3; @@ -116,23 +116,23 @@ void info_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("File"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, "File", xco, yco, xmax-3, 22, ""); + uiDefPulldownBut(block, dummy_viewmenu, sa, "File", xco, yco, xmax-3, 22, ""); xco+= xmax; xmax= GetButStringLength("Add"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, "Add", xco, yco, xmax-3, 22, ""); + uiDefPulldownBut(block, dummy_viewmenu, sa, "Add", xco, yco, xmax-3, 22, ""); xco+= xmax; xmax= GetButStringLength("Timeline"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, "Timeline", xco, yco, xmax-3, 22, ""); + uiDefPulldownBut(block, dummy_viewmenu, sa, "Timeline", xco, yco, xmax-3, 22, ""); xco+= xmax; xmax= GetButStringLength("Game"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, "Game", xco, yco, xmax-3, 22, ""); + uiDefPulldownBut(block, dummy_viewmenu, sa, "Game", xco, yco, xmax-3, 22, ""); xco+= xmax; xmax= GetButStringLength("Render"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, "Render", xco, yco, xmax-3, 22, ""); + uiDefPulldownBut(block, dummy_viewmenu, sa, "Render", xco, yco, xmax-3, 22, ""); xco+= xmax; xmax= GetButStringLength("Help"); diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 7ef08495ae1..ae6b4333150 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -40,8 +40,8 @@ #include "BLI_arithb.h" #include "BLI_rand.h" +#include "BKE_context.h" #include "BKE_colortools.h" -#include "BKE_global.h" #include "BKE_screen.h" #include "ED_space_api.h" @@ -129,7 +129,7 @@ static void info_main_area_init(wmWindowManager *wm, ARegion *ar) static void info_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - // SpaceInfo *sinfo= C->area->spacedata.first; + // SpaceInfo *sinfo= (SpaceInfo*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; float col[3]; diff --git a/source/blender/editors/space_ipo/ipo_header.c b/source/blender/editors/space_ipo/ipo_header.c index 61f7b80f703..bf088cb700e 100644 --- a/source/blender/editors/space_ipo/ipo_header.c +++ b/source/blender/editors/space_ipo/ipo_header.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -66,7 +66,7 @@ static void do_viewmenu(bContext *C, void *arg, int event) static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -99,7 +99,7 @@ static void do_ipo_buttons(bContext *C, void *arg, int event) void ipo_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; + ScrArea *sa= CTX_wm_area(C); uiBlock *block; int xco, yco= 3; @@ -115,7 +115,7 @@ void ipo_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, + uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); } diff --git a/source/blender/editors/space_ipo/space_ipo.c b/source/blender/editors/space_ipo/space_ipo.c index 325d14120ae..1c1c5997ee7 100644 --- a/source/blender/editors/space_ipo/space_ipo.c +++ b/source/blender/editors/space_ipo/space_ipo.c @@ -41,7 +41,7 @@ #include "BLI_arithb.h" #include "BLI_rand.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_space_api.h" @@ -149,7 +149,7 @@ static SpaceLink *ipo_duplicate(SpaceLink *sl) // XXX this should be defined in some general lib for anim editors... static void draw_cfra(const bContext *C, SpaceIpo *sipo, View2D *v2d) { - Scene *scene= C->scene; + Scene *scene= CTX_data_scene(C); float vec[2]; //vec[0] = get_ipo_cfra_from_cfra(sipo, scene->r.cfra); @@ -168,7 +168,7 @@ static void draw_cfra(const bContext *C, SpaceIpo *sipo, View2D *v2d) #if 0 if(sipo->blocktype==ID_OB) { - ob= (G.scene->basact) ? (G.scene->basact->object) : 0; + ob= (scene->basact) ? (scene->basact->object) : 0; if (ob && (ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)!=0.0)) { vec[0]-= give_timeoffset(ob); @@ -204,7 +204,7 @@ static void ipo_main_area_init(wmWindowManager *wm, ARegion *ar) static void ipo_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceIpo *sipo= C->area->spacedata.first; + SpaceIpo *sipo= (SpaceIpo*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; diff --git a/source/blender/editors/space_nla/nla_header.c b/source/blender/editors/space_nla/nla_header.c index 5fee33b8aa5..a2069b1aa99 100644 --- a/source/blender/editors/space_nla/nla_header.c +++ b/source/blender/editors/space_nla/nla_header.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -66,7 +66,7 @@ static void do_viewmenu(bContext *C, void *arg, int event) static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -99,7 +99,7 @@ static void do_nla_buttons(bContext *C, void *arg, int event) void nla_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; + ScrArea *sa= CTX_wm_area(C); uiBlock *block; int xco, yco= 3; @@ -115,7 +115,7 @@ void nla_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, + uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); xco+=XIC+xmax; } diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 71c5a8c0fe4..6bb42527241 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -42,7 +42,7 @@ #include "BLI_rand.h" #include "BKE_colortools.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_space_api.h" @@ -158,7 +158,7 @@ static void nla_main_area_init(wmWindowManager *wm, ARegion *ar) static void nla_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - // SpaceNla *snla= C->area->spacedata.first; + // SpaceNla *snla= (SpaceNla*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; float col[3]; diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 4252a36e4c9..5614f643578 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -66,7 +66,7 @@ static void do_viewmenu(bContext *C, void *arg, int event) static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -99,7 +99,7 @@ static void do_node_buttons(bContext *C, void *arg, int event) void node_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; + ScrArea *sa= CTX_wm_area(C); uiBlock *block; int xco, yco= 3; @@ -115,7 +115,7 @@ void node_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, + uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); } diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index ba460900bf2..642fe92d29b 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -42,7 +42,7 @@ #include "BLI_rand.h" #include "BKE_colortools.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_space_api.h" @@ -152,7 +152,7 @@ static void node_main_area_init(wmWindowManager *wm, ARegion *ar) static void node_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - // SpaceNode *snode= C->area->spacedata.first; + // SpaceNode *snode= (SpaceNode*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; //View2DGrid *grid; float col[3]; diff --git a/source/blender/editors/space_outliner/outliner_header.c b/source/blender/editors/space_outliner/outliner_header.c index 5a56e8ef0f1..fd2f6fc7576 100644 --- a/source/blender/editors/space_outliner/outliner_header.c +++ b/source/blender/editors/space_outliner/outliner_header.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -66,7 +66,7 @@ static void do_viewmenu(bContext *C, void *arg, int event) static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -99,8 +99,8 @@ static void do_outliner_buttons(bContext *C, void *arg, int event) void outliner_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; - SpaceOops *soutliner= sa->spacedata.first; + ScrArea *sa= CTX_wm_area(C); + SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C); uiBlock *block; int xco, yco= 3; char *path; @@ -117,7 +117,7 @@ void outliner_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, + uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); xco += xmax; diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 36afb206ab6..4fa10adcd91 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -47,7 +47,7 @@ #include "BLI_rand.h" #include "BKE_colortools.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "BKE_texture.h" #include "BKE_utildefines.h" @@ -108,15 +108,16 @@ void UI_table_free(uiTable *table) void UI_table_draw(const bContext *C, uiTable *table) { + ARegion *ar= CTX_wm_region(C); uiBlock *block; View2D *v2d; rcti *rct, cellrct; int y, row, col; - v2d= &C->region->v2d; + v2d= &ar->v2d; rct= &table->rct; - block= uiBeginBlock(C, C->region, "table outliner", UI_EMBOSST, UI_HELV); + block= uiBeginBlock(C, ar, "table outliner", UI_EMBOSST, UI_HELV); for(y=rct->ymax, row=0; y>rct->ymin; y-=ROW_HEIGHT, row++) { if(row%2 == 0) { @@ -161,7 +162,7 @@ typedef struct CellRNA { static void rna_back_cb(bContext *C, void *arg_unused, void *arg_unused2) { - SpaceOops *soutliner= C->area->spacedata.first; + SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C); char *newpath; newpath= RNA_path_back(soutliner->rnapath); @@ -172,7 +173,7 @@ static void rna_back_cb(bContext *C, void *arg_unused, void *arg_unused2) static void rna_pointer_cb(bContext *C, void *arg_prop, void *arg_index) { - SpaceOops *soutliner= C->area->spacedata.first; + SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C); PropertyRNA *prop= arg_prop; char *newpath; int index= GET_INT_FROM_POINTER(arg_index);; @@ -406,7 +407,7 @@ static void outliner_main_area_draw(const bContext *C, ARegion *ar) PointerRNA newptr; float col[3]; int rows, cols, awidth, aheight, width, height; - SpaceOops *soutliner= C->area->spacedata.first; + SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; View2DScrollers *scrollers; @@ -421,7 +422,7 @@ static void outliner_main_area_draw(const bContext *C, ARegion *ar) /* create table */ cell.space= soutliner; cell.lastrow= -1; - RNA_main_pointer_create(G.main, &cell.ptr); + RNA_main_pointer_create(CTX_data_main(C), &cell.ptr); cell.prop= NULL; /* solve RNA path or reset if fails */ diff --git a/source/blender/editors/space_script/script_header.c b/source/blender/editors/space_script/script_header.c index 8cc3966fdf1..7f18f4bbbeb 100644 --- a/source/blender/editors/space_script/script_header.c +++ b/source/blender/editors/space_script/script_header.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -66,7 +66,7 @@ static void do_viewmenu(bContext *C, void *arg, int event) static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -99,7 +99,7 @@ static void do_script_buttons(bContext *C, void *arg, int event) void script_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; + ScrArea *sa= CTX_wm_area(C); uiBlock *block; int xco, yco= 3; @@ -115,7 +115,7 @@ void script_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, + uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); xco+=XIC+xmax; } diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index 8b9196ac506..6693d71b507 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -41,7 +41,7 @@ #include "BLI_rand.h" #include "BKE_colortools.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_space_api.h" @@ -139,7 +139,7 @@ static void script_main_area_init(wmWindowManager *wm, ARegion *ar) static void script_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - // SpaceScript *sscript= C->area->spacedata.first; + // SpaceScript *sscript= (SpaceScript*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; float col[3]; diff --git a/source/blender/editors/space_sequencer/sequencer_header.c b/source/blender/editors/space_sequencer/sequencer_header.c index 0787920670b..26e92e67c77 100644 --- a/source/blender/editors/space_sequencer/sequencer_header.c +++ b/source/blender/editors/space_sequencer/sequencer_header.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -66,7 +66,7 @@ static void do_viewmenu(bContext *C, void *arg, int event) static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -99,7 +99,7 @@ static void do_sequencer_buttons(bContext *C, void *arg, int event) void sequencer_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; + ScrArea *sa= CTX_wm_area(C); uiBlock *block; int xco, yco= 3; @@ -115,7 +115,7 @@ void sequencer_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, + uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); xco+=XIC+xmax; } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 20618b6ab9b..2452b103a56 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -41,7 +41,7 @@ #include "BLI_rand.h" #include "BKE_colortools.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_space_api.h" @@ -158,7 +158,7 @@ static void sequencer_main_area_init(wmWindowManager *wm, ARegion *ar) static void sequencer_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - // SpaceSeq *sseq= C->area->spacedata.first; + // SpaceSeq *sseq= (SpaceSeq*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; float col[3]; diff --git a/source/blender/editors/space_sound/sound_header.c b/source/blender/editors/space_sound/sound_header.c index 8a566de4b5a..1702b3e06a0 100644 --- a/source/blender/editors/space_sound/sound_header.c +++ b/source/blender/editors/space_sound/sound_header.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -66,7 +66,7 @@ static void do_viewmenu(bContext *C, void *arg, int event) static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -99,7 +99,7 @@ static void do_sound_buttons(bContext *C, void *arg, int event) void sound_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; + ScrArea *sa= CTX_wm_area(C); uiBlock *block; int xco, yco= 3; @@ -115,7 +115,7 @@ void sound_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, + uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); xco+=XIC+xmax; } diff --git a/source/blender/editors/space_sound/space_sound.c b/source/blender/editors/space_sound/space_sound.c index 712e4f27192..82ed6082a38 100644 --- a/source/blender/editors/space_sound/space_sound.c +++ b/source/blender/editors/space_sound/space_sound.c @@ -42,7 +42,7 @@ #include "BLI_rand.h" #include "BKE_colortools.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_space_api.h" @@ -154,7 +154,7 @@ static void sound_main_area_init(wmWindowManager *wm, ARegion *ar) static void sound_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - // SpaceSound *ssound= C->area->spacedata.first; + // SpaceSound *ssound= (SpaceSound*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; float col[3]; diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index e37dbdc613e..bab9ce3c143 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -42,7 +42,7 @@ #include "BLI_rand.h" #include "BKE_colortools.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_space_api.h" @@ -132,7 +132,7 @@ static void text_main_area_init(wmWindowManager *wm, ARegion *ar) static void text_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - // SpaceText *stext= C->area->spacedata.first; + // SpaceText *stext= (SpaceText*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; float col[3]; diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c index d43f33117df..47c408f0044 100644 --- a/source/blender/editors/space_text/text_header.c +++ b/source/blender/editors/space_text/text_header.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -66,7 +66,7 @@ static void do_viewmenu(bContext *C, void *arg, int event) static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -99,7 +99,7 @@ static void do_text_buttons(bContext *C, void *arg, int event) void text_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; + ScrArea *sa= CTX_wm_area(C); uiBlock *block; int xco, yco= 3; @@ -115,7 +115,7 @@ void text_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, + uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); xco+=XIC+xmax; } diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 3c4152366ee..e89a64faf94 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" +#include "BKE_context.h" #include "BKE_global.h" #include "BKE_screen.h" @@ -64,7 +65,7 @@ /* draws a current frame indicator for the TimeLine */ static void time_draw_cfra_time(const bContext *C, SpaceTime *stime, ARegion *ar) { - Scene *scene= C->scene; + Scene *scene= CTX_data_scene(C); float vec[2]; vec[0]= scene->r.cfra*scene->r.framelen; @@ -120,7 +121,7 @@ static void time_main_area_init(wmWindowManager *wm, ARegion *ar) static void time_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceTime *stime= C->area->spacedata.first; + SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; diff --git a/source/blender/editors/space_time/time_header.c b/source/blender/editors/space_time/time_header.c index cc8ac6d1e73..5faacb29654 100644 --- a/source/blender/editors/space_time/time_header.c +++ b/source/blender/editors/space_time/time_header.c @@ -39,6 +39,7 @@ #include "BLI_blenlib.h" +#include "BKE_context.h" #include "BKE_global.h" #include "BKE_screen.h" @@ -65,7 +66,7 @@ static void do_time_redrawmenu(bContext *C, void *arg, int event) { - SpaceTime *stime= C->area->spacedata.first; + SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C); if(event < 1001) { @@ -76,7 +77,7 @@ static void do_time_redrawmenu(bContext *C, void *arg, int event) } else { if(event==1001) { -// button(&C->scene->r.frs_sec,1,120,"FPS:"); +// button(&CTX_data_scene(C)->r.frs_sec,1,120,"FPS:"); } } } @@ -84,8 +85,9 @@ static void do_time_redrawmenu(bContext *C, void *arg, int event) static uiBlock *time_redrawmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; - SpaceTime *stime= curarea->spacedata.first; + ScrArea *curarea= CTX_wm_area(C); + SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C); + Scene *scene= CTX_data_scene(C); uiBlock *block; short yco= 0, menuwidth=120, icon; char str[32]; @@ -120,7 +122,7 @@ static uiBlock *time_redrawmenu(bContext *C, uiMenuBlockHandle *handle, void *ar uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - sprintf(str, "Set Frames/Sec (%d/%f)", C->scene->r.frs_sec, C->scene->r.frs_sec_base); + sprintf(str, "Set Frames/Sec (%d/%f)", scene->r.frs_sec, scene->r.frs_sec_base); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, str, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1001, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); @@ -146,9 +148,10 @@ static uiBlock *time_redrawmenu(bContext *C, uiMenuBlockHandle *handle, void *ar static void do_time_viewmenu(bContext *C, void *arg, int event) { - ScrArea *curarea= C->area; - SpaceTime *stime= curarea->spacedata.first; + ScrArea *curarea= CTX_wm_area(C); + SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C); View2D *v2d= UI_view2d_fromcontext_rwin(C); + Scene *scene= CTX_data_scene(C); int first; switch(event) { @@ -158,12 +161,12 @@ static void do_time_viewmenu(bContext *C, void *arg, int event) break; case 3: /* View All */ if(v2d) { - first= C->scene->r.sfra; - if(first >= C->scene->r.efra) first= C->scene->r.efra; + first= scene->r.sfra; + if(first >= scene->r.efra) first= scene->r.efra; v2d->cur.xmin=v2d->tot.xmin= (float)first-2; - v2d->cur.xmax=v2d->tot.xmax= (float)C->scene->r.efra+2; + v2d->cur.xmax=v2d->tot.xmax= (float)scene->r.efra+2; - ED_area_tag_redraw(C->area); + ED_area_tag_redraw(curarea); } break; case 4: /* Maximize Window */ @@ -171,7 +174,7 @@ static void do_time_viewmenu(bContext *C, void *arg, int event) break; case 5: /* show time or frames */ stime->flag ^= TIME_DRAWFRAMES; - ED_area_tag_redraw(C->area); + ED_area_tag_redraw(curarea); break; case 6: //nextprev_marker(1); @@ -191,20 +194,20 @@ static void do_time_viewmenu(bContext *C, void *arg, int event) case 11: if(v2d) { v2d->flag ^= V2D_VIEWSYNC_X; - UI_view2d_sync(C->screen, v2d, V2D_LOCK_SET); + UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_SET); } break; case 12: /* only show keyframes from selected data */ stime->flag ^= TIME_ONLYACTSEL; - ED_area_tag_redraw(C->area); + ED_area_tag_redraw(curarea); break; } } static uiBlock *time_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; - SpaceTime *stime= curarea->spacedata.first; + ScrArea *curarea= CTX_wm_area(C); + SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C); View2D *v2d= UI_view2d_fromcontext_rwin(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -260,25 +263,27 @@ static uiBlock *time_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_ static void do_time_framemenu(bContext *C, void *arg, int event) { + Scene *scene= CTX_data_scene(C); + switch(event) { case 1: /*Set as Start */ - if (C->scene->r.psfra) { - if (C->scene->r.pefra < CFRA) - C->scene->r.pefra= CFRA; - C->scene->r.psfra= CFRA; + if (scene->r.psfra) { + if (scene->r.pefra < scene->r.cfra) + scene->r.pefra= scene->r.cfra; + scene->r.psfra= scene->r.cfra; } else - C->scene->r.sfra = CFRA; + scene->r.sfra = scene->r.cfra; WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); break; case 2: /* Set as End */ - if (C->scene->r.psfra) { - if (CFRA < C->scene->r.psfra) - C->scene->r.psfra= CFRA; - C->scene->r.pefra= CFRA; + if (scene->r.psfra) { + if (scene->r.cfra < scene->r.psfra) + scene->r.psfra= scene->r.cfra; + scene->r.pefra= scene->r.cfra; } else - C->scene->r.efra = CFRA; + scene->r.efra = scene->r.cfra; WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); break; case 3: /* Rename Marker */ @@ -289,7 +294,7 @@ static void do_time_framemenu(bContext *C, void *arg, int event) static uiBlock *time_framemenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -368,14 +373,15 @@ static void end_animated_screen(SpaceTime *stime) void do_time_buttons(bContext *C, void *arg, int event) { - SpaceTime *stime= C->area->spacedata.first; + SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C); + Scene *scene= CTX_data_scene(C); switch(event) { case B_REDRAWALL: WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); break; case B_TL_REW: - CFRA= PSFRA; + scene->r.cfra= PSFRA; //update_for_newframe(); break; case B_TL_PLAY: @@ -387,7 +393,7 @@ void do_time_buttons(bContext *C, void *arg, int event) break; case B_TL_FF: /* end frame */ - CFRA= PEFRA; + scene->r.cfra= PEFRA; //update_for_newframe(); break; case B_TL_PREVKEY: @@ -400,15 +406,15 @@ void do_time_buttons(bContext *C, void *arg, int event) break; case B_TL_PREVIEWON: - if (C->scene->r.psfra) { + if (scene->r.psfra) { /* turn on preview range */ - C->scene->r.psfra= C->scene->r.sfra; - C->scene->r.pefra= C->scene->r.efra; + scene->r.psfra= scene->r.sfra; + scene->r.pefra= scene->r.efra; } else { /* turn off preview range */ - C->scene->r.psfra= 0; - C->scene->r.pefra= 0; + scene->r.psfra= 0; + scene->r.pefra= 0; } //BIF_undo_push("Set anim-preview range"); WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); @@ -430,8 +436,9 @@ void do_time_buttons(bContext *C, void *arg, int event) void time_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; - SpaceTime *stime= sa->spacedata.first; + ScrArea *sa= CTX_wm_area(C); + SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C); + Scene *scene= CTX_data_scene(C); uiBlock *block; int xco, yco= 3; @@ -447,16 +454,16 @@ void time_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); - uiDefPulldownBut(block, time_viewmenu, C->area, + uiDefPulldownBut(block, time_viewmenu, sa, "View", xco, yco-2, xmax-3, 24, ""); xco+= xmax; xmax= GetButStringLength("Frame"); - uiDefPulldownBut(block, time_framemenu, C->area, + uiDefPulldownBut(block, time_framemenu, sa, "Frame", xco, yco-2, xmax-3, 24, ""); xco+= xmax; xmax= GetButStringLength("Playback"); - uiDefPulldownBut(block, time_redrawmenu, C->area, + uiDefPulldownBut(block, time_redrawmenu, sa, "Playback", xco, yco-2, xmax-3, 24, ""); xco+= xmax; } @@ -467,35 +474,35 @@ void time_header_buttons(const bContext *C, ARegion *ar) uiDefButI(block, TOG, B_TL_PREVIEWON,"Preview", xco,yco, XIC, YIC, - &C->scene->r.psfra,0, 1, 0, 0, + &scene->r.psfra,0, 1, 0, 0, "Show settings for frame range of animation preview"); xco += XIC; - if (C->scene->r.psfra) { + if (scene->r.psfra) { uiDefButI(block, NUM, B_REDRAWALL,"Start:", xco,yco, 4.5*XIC, YIC, - &C->scene->r.psfra,MINFRAMEF, MAXFRAMEF, 0, 0, + &scene->r.psfra,MINFRAMEF, MAXFRAMEF, 0, 0, "The start frame of the animation preview (inclusive)"); xco += (short)(4.5*XIC); uiDefButI(block, NUM, B_REDRAWALL,"End:", xco,yco,4.5*XIC,YIC, - &C->scene->r.pefra,PSFRA,MAXFRAMEF, 0, 0, + &scene->r.pefra,PSFRA,MAXFRAMEF, 0, 0, "The end frame of the animation preview (inclusive)"); } else { uiDefButI(block, NUM, B_REDRAWALL,"Start:", xco,yco, 4.5*XIC, YIC, - &C->scene->r.sfra,MINFRAMEF, MAXFRAMEF, 0, 0, + &scene->r.sfra,MINFRAMEF, MAXFRAMEF, 0, 0, "The start frame of the animation (inclusive)"); xco += (short)(4.5*XIC); uiDefButI(block, NUM, B_REDRAWALL,"End:", xco,yco,4.5*XIC,YIC, - &C->scene->r.efra,(float)SFRA,MAXFRAMEF, 0, 0, + &scene->r.efra,(float)SFRA,MAXFRAMEF, 0, 0, "The end frame of the animation (inclusive)"); } uiBlockEndAlign(block); @@ -504,7 +511,7 @@ void time_header_buttons(const bContext *C, ARegion *ar) uiDefButI(block, NUM, B_NEWFRAME, "", xco,yco,3.5*XIC,YIC, - &(C->scene->r.cfra), MINFRAMEF, MAXFRAMEF, 0, 0, + &(scene->r.cfra), MINFRAMEF, MAXFRAMEF, 0, 0, "Displays Current Frame of animation"); xco += (short)(3.5 * XIC + 16); @@ -532,12 +539,12 @@ void time_header_buttons(const bContext *C, ARegion *ar) xco+= XIC+8; uiDefIconButBitS(block, TOG, AUTOKEY_ON, REDRAWINFO, ICON_REC, - xco, yco, XIC, YIC, &(C->scene->autokey_mode), 0, 0, 0, 0, "Automatic keyframe insertion for Objects and Bones"); + xco, yco, XIC, YIC, &(scene->autokey_mode), 0, 0, 0, 0, "Automatic keyframe insertion for Objects and Bones"); xco+= XIC; - if (C->scene->autokey_mode & AUTOKEY_ON) { + if (scene->autokey_mode & AUTOKEY_ON) { uiDefButS(block, MENU, REDRAWINFO, "Auto-Keying Mode %t|Add/Replace Keys%x3|Replace Keys %x5", - xco, yco, 3.5*XIC, YIC, &(C->scene->autokey_mode), 0, 1, 0, 0, + xco, yco, 3.5*XIC, YIC, &(scene->autokey_mode), 0, 1, 0, 0, "Mode of automatic keyframe insertion for Objects and Bones"); xco+= (4*XIC); } diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index 599594a3ec0..30b0e808e05 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_utildefines.h" #include "UI_interface.h" @@ -56,7 +56,7 @@ static int change_frame_init(bContext *C, wmOperator *op) { - SpaceTime *stime= C->area->spacedata.first; + SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C); stime->flag |= TIME_CFRA_NUM; @@ -65,6 +65,7 @@ static int change_frame_init(bContext *C, wmOperator *op) static void change_frame_apply(bContext *C, wmOperator *op) { + Scene *scene= CTX_data_scene(C); int cfra; cfra= RNA_int_get(op->ptr, "frame"); @@ -83,8 +84,8 @@ static void change_frame_apply(bContext *C, wmOperator *op) else PIL_sleep_ms(30); #endif - if(cfra!=CFRA) - CFRA= cfra; + if(cfra!=scene->r.cfra) + scene->r.cfra= cfra; WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); /* XXX: add WM_NOTE_TIME_CHANGED? */ @@ -92,7 +93,7 @@ static void change_frame_apply(bContext *C, wmOperator *op) static void change_frame_exit(bContext *C, wmOperator *op) { - SpaceTime *stime= C->area->spacedata.first; + SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C); stime->flag &= ~TIME_CFRA_NUM; } @@ -109,7 +110,7 @@ static int change_frame_exec(bContext *C, wmOperator *op) static int frame_from_event(bContext *C, wmEvent *event) { - ARegion *region= C->region; + ARegion *region= CTX_wm_region(C); int x, y; float viewx; @@ -127,7 +128,7 @@ static int change_frame_invoke(bContext *C, wmOperator *op, wmEvent *event) change_frame_apply(C, op); /* add temp handler */ - WM_event_add_modal_handler(C, &C->window->handlers, op); + WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); return OPERATOR_RUNNING_MODAL; } @@ -182,12 +183,12 @@ static int toggle_time_exec(bContext *C, wmOperator *op) { SpaceTime *stime; - if (ELEM(NULL, C->area, C->area->spacedata.first)) + if (ELEM(NULL, CTX_wm_area(C), CTX_wm_space_data(C))) return OPERATOR_CANCELLED; /* simply toggle draw frames flag for now */ // XXX in past, this displayed menu to choose... (for later!) - stime= C->area->spacedata.first; + stime= (SpaceTime*)CTX_wm_space_data(C); stime->flag ^= TIME_DRAWFRAMES; return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index d98b59ac2c6..3f30d1cbd79 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -41,6 +41,7 @@ #include "BLI_arithb.h" #include "BLI_rand.h" +#include "BKE_context.h" #include "BKE_global.h" #include "BKE_screen.h" diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 337874074c3..aa950b87238 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" -#include "BKE_global.h" +#include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -66,7 +66,7 @@ static void do_viewmenu(bContext *C, void *arg, int event) static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused) { - ScrArea *curarea= C->area; + ScrArea *curarea= CTX_wm_area(C); uiBlock *block; short yco= 0, menuwidth=120; @@ -100,7 +100,7 @@ static void do_view3d_buttons(bContext *C, void *arg, int event) void view3d_header_buttons(const bContext *C, ARegion *ar) { - ScrArea *sa= C->area; + ScrArea *sa= CTX_wm_area(C); uiBlock *block; int xco, yco= 3; @@ -116,7 +116,7 @@ void view3d_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); - uiDefPulldownBut(block, dummy_viewmenu, C->area, + uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); } diff --git a/source/blender/editors/util/ed_markers.c b/source/blender/editors/util/ed_markers.c index 843a81e7086..96f7f15f8c9 100644 --- a/source/blender/editors/util/ed_markers.c +++ b/source/blender/editors/util/ed_markers.c @@ -43,6 +43,7 @@ #include "BLI_blenlib.h" +#include "BKE_context.h" #include "BKE_global.h" #include "BKE_utildefines.h" @@ -79,7 +80,7 @@ static ListBase *context_get_markers(const bContext *C) else #endif - return &C->scene->markers; + return &CTX_data_scene(C)->markers; } /* ************* Marker Drawing ************ */ @@ -162,12 +163,12 @@ void draw_markers_time(const bContext *C, int flag) /* unselected markers are drawn at the first time */ for (marker= markers->first; marker; marker= marker->next) { - if (!(marker->flag & SELECT)) draw_marker(v2d, marker, C->scene->r.cfra, flag); + if (!(marker->flag & SELECT)) draw_marker(v2d, marker, CTX_data_scene(C)->r.cfra, flag); } /* selected markers are drawn later */ for (marker= markers->first; marker; marker= marker->next) { - if (marker->flag & SELECT) draw_marker(v2d, marker, C->scene->r.cfra, flag); + if (marker->flag & SELECT) draw_marker(v2d, marker, CTX_data_scene(C)->r.cfra, flag); } } @@ -180,7 +181,7 @@ static int ed_marker_add(bContext *C, wmOperator *op) { ListBase *markers= context_get_markers(C); TimeMarker *marker; - int frame= C->scene->r.cfra; + int frame= CTX_data_scene(C)->r.cfra; /* two markers can't be at the same place */ for(marker= markers->first; marker; marker= marker->next) @@ -264,7 +265,7 @@ static int ed_marker_move_init(bContext *C, wmOperator *op) if (totmark==0) return 0; op->customdata= mm= MEM_callocN(sizeof(MarkerMove), "Markermove"); - mm->slink= C->area->spacedata.first; + mm->slink= CTX_wm_space_data(C); mm->markers= markers; mm->oldframe= MEM_callocN(totmark*sizeof(int), "MarkerMove oldframe"); @@ -298,7 +299,7 @@ static int ed_marker_move_invoke(bContext *C, wmOperator *op, wmEvent *evt) mm->event_type= evt->type; /* add temp handler */ - WM_event_add_modal_handler(C, &C->window->handlers, op); + WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); /* reset frs delta */ RNA_int_set(op->ptr, "frs", 0); @@ -563,12 +564,12 @@ static void ED_MARKER_OT_duplicate(wmOperatorType *ot) /* ************************** selection ************************************/ /* select/deselect TimeMarker at current frame */ -static void select_timeline_marker_frame(int frame, unsigned char shift) +static void select_timeline_marker_frame(ListBase *markers, int frame, unsigned char shift) { TimeMarker *marker; int select=0; - for(marker= G.scene->markers.first; marker; marker= marker->next) { + for(marker= markers->first; marker; marker= marker->next) { /* if Shift is not set, then deselect Markers */ if(!shift) marker->flag &= ~SELECT; /* this way a not-shift select will allways give 1 selected marker */ @@ -607,17 +608,17 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend) float viewx; int x, y, cfra; - x= evt->x - C->region->winrct.xmin; - y= evt->y - C->region->winrct.ymin; + x= evt->x - CTX_wm_region(C)->winrct.xmin; + y= evt->y - CTX_wm_region(C)->winrct.ymin; UI_view2d_region_to_view(v2d, x, y, &viewx, NULL); cfra= find_nearest_marker_time(markers, viewx); if (extend) - select_timeline_marker_frame(cfra, 1); + select_timeline_marker_frame(markers, cfra, 1); else - select_timeline_marker_frame(cfra, 0); + select_timeline_marker_frame(markers, cfra, 0); WM_event_add_notifier(C, WM_NOTE_MARKERS_CHANGED, 0, NULL); |