diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-09-05 23:34:27 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-09-05 23:34:27 +0400 |
commit | 59a823c48aec80a48b39e27f8474302caf2dbf26 (patch) | |
tree | 16c70594284aaa154b99f8b91e605b447955001f /source/blender/editors | |
parent | a6d9a5a972595c898e596deb95eb683430621188 (diff) |
Code cleanup: remove context from RNA update functions, only one left.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/anim_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/include/ED_sequencer.h | 4 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 17 | ||||
-rw-r--r-- | source/blender/editors/sound/sound_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/space_sequencer.c | 138 |
7 files changed, 102 insertions, 69 deletions
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index eaba8343f4d..aa61afbac78 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -41,6 +41,7 @@ #include "BKE_context.h" #include "BKE_global.h" +#include "BKE_main.h" #include "BKE_sound.h" #include "UI_view2d.h" @@ -76,6 +77,7 @@ static int change_frame_poll(bContext *C) /* Set the new frame number */ static void change_frame_apply(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); /* set the new frame number */ @@ -84,7 +86,7 @@ static void change_frame_apply(bContext *C, wmOperator *op) SUBFRA = 0.f; /* do updates */ - sound_seek_scene(C); + sound_seek_scene(bmain, scene); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); } diff --git a/source/blender/editors/include/ED_sequencer.h b/source/blender/editors/include/ED_sequencer.h index cd22a5c6ca4..5be1403c97b 100644 --- a/source/blender/editors/include/ED_sequencer.h +++ b/source/blender/editors/include/ED_sequencer.h @@ -31,8 +31,4 @@ #define SEQ_ZOOM_FAC(szoom) ((szoom) > 0.0f)? (szoom) : ((szoom) == 0.0f)? (1.0f) : (-1.0f/(szoom)) - -/* in space_sequencer.c, for rna update function */ -void ED_sequencer_update_view(bContext *C, int view); - #endif /* ED_SEQUENCER_H */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 66a67d7c4f2..b199f54cde1 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1732,14 +1732,16 @@ static void SCREEN_OT_region_scale(wmOperatorType *ot) /* function to be called outside UI context, or for redo */ static int frame_offset_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); int delta; delta = RNA_int_get(op->ptr, "delta"); - CTX_data_scene(C)->r.cfra += delta; - CTX_data_scene(C)->r.subframe = 0.f; + scene->r.cfra += delta; + scene->r.subframe = 0.f; - sound_seek_scene(C); + sound_seek_scene(bmain, scene); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, CTX_data_scene(C)); @@ -1764,6 +1766,7 @@ static void SCREEN_OT_frame_offset(wmOperatorType *ot) /* function to be called outside UI context, or for redo */ static int frame_jump_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); wmTimer *animtimer= CTX_wm_screen(C)->animtimer; @@ -1787,7 +1790,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) else CFRA= PSFRA; - sound_seek_scene(C); + sound_seek_scene(bmain, scene); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); } @@ -1816,6 +1819,7 @@ static void SCREEN_OT_frame_jump(wmOperatorType *ot) /* function to be called outside UI context, or for redo */ static int keyframe_jump_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); bDopeSheet ads= {NULL}; @@ -1870,7 +1874,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) /* free temp stuff */ BLI_dlrbTree_free(&keys); - sound_seek_scene(C); + sound_seek_scene(bmain, scene); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); @@ -2796,6 +2800,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e bScreen *screen= CTX_wm_screen(C); if(screen->animtimer && screen->animtimer==event->customdata) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); wmTimer *wt= screen->animtimer; ScreenAnimData *sad= wt->customdata; @@ -2872,7 +2877,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e } if (sad->flag & ANIMPLAY_FLAG_JUMPED) - sound_seek_scene(C); + sound_seek_scene(bmain, scene); /* since we follow drawflags, we can't send notifier but tag regions ourselves */ ED_update_for_newframe(CTX_data_main(C), scene, screen, 1); diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 70884d47c23..72dbbd9da9a 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -119,7 +119,7 @@ static int open_exec(bContext *C, wmOperator *op) info = AUD_getInfo(sound->playback_handle); if (info.specs.channels == AUD_CHANNELS_INVALID) { - sound_delete(C, sound); + sound_delete(bmain, sound); if(op->customdata) MEM_freeN(op->customdata); BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 0d7cdf94bc7..46918407447 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -41,6 +41,7 @@ #include "BLI_utildefines.h" #include "BKE_context.h" +#include "BKE_main.h" #include "BKE_sound.h" #include "UI_view2d.h" @@ -70,6 +71,7 @@ /* Set the new frame number */ static void graphview_cursor_apply(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); SpaceIpo *sipo= CTX_wm_space_graph(C); @@ -78,7 +80,7 @@ static void graphview_cursor_apply(bContext *C, wmOperator *op) */ CFRA= RNA_int_get(op->ptr, "frame"); SUBFRA=0.f; - sound_seek_scene(C); + sound_seek_scene(bmain, scene); /* set the cursor value */ sipo->cursorVal= RNA_float_get(op->ptr, "value"); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index df347506e74..e7673651546 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2174,7 +2174,7 @@ static int sequencer_view_toggle_exec(bContext *C, wmOperator *UNUSED(op)) sseq->view++; if (sseq->view > SEQ_VIEW_SEQUENCE_PREVIEW) sseq->view = SEQ_VIEW_SEQUENCE; - ED_sequencer_update_view(C, sseq->view); + ED_area_tag_refresh(CTX_wm_area(C)); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 36471c7ffcf..5a0369ef80b 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -98,61 +98,6 @@ static ARegion *sequencer_find_region(ScrArea *sa, short type) return ar; } -void ED_sequencer_update_view(bContext *C, int view) -{ - ScrArea *sa= CTX_wm_area(C); - - ARegion *ar_main= sequencer_find_region(sa, RGN_TYPE_WINDOW); - ARegion *ar_preview= sequencer_find_region(sa, RGN_TYPE_PREVIEW); - - switch (view) { - case SEQ_VIEW_SEQUENCE: - if (ar_main && (ar_main->flag & RGN_FLAG_HIDDEN)) { - ar_main->flag &= ~RGN_FLAG_HIDDEN; - ar_main->v2d.flag &= ~V2D_IS_INITIALISED; - } - if (ar_preview && !(ar_preview->flag & RGN_FLAG_HIDDEN)) { - ar_preview->flag |= RGN_FLAG_HIDDEN; - ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; - WM_event_remove_handlers(C, &ar_preview->handlers); - } - if (ar_main) ar_main->alignment= RGN_ALIGN_NONE; - if (ar_preview) ar_preview->alignment= RGN_ALIGN_NONE; - break; - case SEQ_VIEW_PREVIEW: - if (ar_main && !(ar_main->flag & RGN_FLAG_HIDDEN)) { - ar_main->flag |= RGN_FLAG_HIDDEN; - ar_main->v2d.flag &= ~V2D_IS_INITIALISED; - WM_event_remove_handlers(C, &ar_main->handlers); - } - if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) { - ar_preview->flag &= ~RGN_FLAG_HIDDEN; - ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; - ar_preview->v2d.cur = ar_preview->v2d.tot; - } - if (ar_main) ar_main->alignment= RGN_ALIGN_NONE; - if (ar_preview) ar_preview->alignment= RGN_ALIGN_NONE; - break; - case SEQ_VIEW_SEQUENCE_PREVIEW: - if (ar_main && (ar_main->flag & RGN_FLAG_HIDDEN)) { - ar_main->flag &= ~RGN_FLAG_HIDDEN; - ar_main->v2d.flag &= ~V2D_IS_INITIALISED; - } - if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) { - ar_preview->flag &= ~RGN_FLAG_HIDDEN; - ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; - ar_preview->v2d.cur = ar_preview->v2d.tot; - } - if (ar_main) ar_main->alignment= RGN_ALIGN_NONE; - if (ar_preview) ar_preview->alignment= RGN_ALIGN_TOP; - break; - } - - ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa); - ED_area_tag_redraw(sa); -} - - /* ******************** default callbacks for sequencer space ***************** */ static SpaceLink *sequencer_new(const bContext *C) @@ -256,6 +201,88 @@ static void sequencer_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(s } +static void sequencer_refresh(const bContext *C, ScrArea *sa) +{ + wmWindowManager *wm= CTX_wm_manager(C); + wmWindow *window= CTX_wm_window(C); + SpaceSeq *sseq= (SpaceSeq *)sa->spacedata.first; + ARegion *ar_main= sequencer_find_region(sa, RGN_TYPE_WINDOW); + ARegion *ar_preview= sequencer_find_region(sa, RGN_TYPE_PREVIEW); + int view_changed= 0; + + switch (sseq->view) { + case SEQ_VIEW_SEQUENCE: + if (ar_main && (ar_main->flag & RGN_FLAG_HIDDEN)) { + ar_main->flag &= ~RGN_FLAG_HIDDEN; + ar_main->v2d.flag &= ~V2D_IS_INITIALISED; + view_changed= 1; + } + if (ar_preview && !(ar_preview->flag & RGN_FLAG_HIDDEN)) { + ar_preview->flag |= RGN_FLAG_HIDDEN; + ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; + WM_event_remove_handlers((bContext*)C, &ar_preview->handlers); + view_changed= 1; + } + if (ar_main && ar_main->alignment != RGN_ALIGN_TOP) { + ar_main->alignment= RGN_ALIGN_NONE; + view_changed= 1; + } + if (ar_preview && ar_preview->alignment != RGN_ALIGN_TOP) { + ar_preview->alignment= RGN_ALIGN_NONE; + view_changed= 1; + } + break; + case SEQ_VIEW_PREVIEW: + if (ar_main && !(ar_main->flag & RGN_FLAG_HIDDEN)) { + ar_main->flag |= RGN_FLAG_HIDDEN; + ar_main->v2d.flag &= ~V2D_IS_INITIALISED; + WM_event_remove_handlers((bContext*)C, &ar_main->handlers); + view_changed= 1; + } + if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) { + ar_preview->flag &= ~RGN_FLAG_HIDDEN; + ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; + ar_preview->v2d.cur = ar_preview->v2d.tot; + view_changed= 1; + } + if (ar_main && ar_main->alignment != RGN_ALIGN_TOP) { + ar_main->alignment= RGN_ALIGN_NONE; + view_changed= 1; + } + if (ar_preview && ar_preview->alignment != RGN_ALIGN_TOP) { + ar_preview->alignment= RGN_ALIGN_NONE; + view_changed= 1; + } + break; + case SEQ_VIEW_SEQUENCE_PREVIEW: + if (ar_main && (ar_main->flag & RGN_FLAG_HIDDEN)) { + ar_main->flag &= ~RGN_FLAG_HIDDEN; + ar_main->v2d.flag &= ~V2D_IS_INITIALISED; + view_changed= 1; + } + if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) { + ar_preview->flag &= ~RGN_FLAG_HIDDEN; + ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; + ar_preview->v2d.cur = ar_preview->v2d.tot; + view_changed= 1; + } + if (ar_main && ar_main->alignment != RGN_ALIGN_TOP) { + ar_main->alignment= RGN_ALIGN_NONE; + view_changed= 1; + } + if (ar_preview && ar_preview->alignment != RGN_ALIGN_TOP) { + ar_preview->alignment= RGN_ALIGN_TOP; + view_changed= 1; + } + break; + } + + if(view_changed) { + ED_area_initialize(wm, window, sa); + ED_area_tag_redraw(sa); + } +} + static SpaceLink *sequencer_duplicate(SpaceLink *sl) { SpaceSeq *sseqn= MEM_dupallocN(sl); @@ -516,6 +543,7 @@ void ED_spacetype_sequencer(void) st->operatortypes= sequencer_operatortypes; st->keymap= sequencer_keymap; st->dropboxes= sequencer_dropboxes; + st->refresh= sequencer_refresh; /* regions: main window */ art= MEM_callocN(sizeof(ARegionType), "spacetype sequencer region"); |