diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-24 13:53:29 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-24 13:53:29 +0400 |
commit | 7949f0057fb97773ee1f4937703c1b34bfd32c28 (patch) | |
tree | b2c51cc42df6a899df1a00a03b1f5b7b21ad91a9 /source/blender/editors | |
parent | 69f7e96c5cdbaf65bdbbc4688e921a950832e20d (diff) |
generalize mask poll functions and sequencer mask code.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_sequencer.h | 5 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_draw.c | 3 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_edit.c | 27 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_draw.c | 104 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_edit.c | 27 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/space_sequencer.c | 14 |
7 files changed, 118 insertions, 64 deletions
diff --git a/source/blender/editors/include/ED_sequencer.h b/source/blender/editors/include/ED_sequencer.h index 7ba26f30c39..7807f06594e 100644 --- a/source/blender/editors/include/ED_sequencer.h +++ b/source/blender/editors/include/ED_sequencer.h @@ -29,10 +29,15 @@ struct Scene; struct Sequence; +struct SpaceSeq; void ED_sequencer_select_sequence_single(struct Scene *scene, struct Sequence *seq, int deselect_all); void ED_sequencer_deselect_all(struct Scene *scene); +int ED_space_sequencer_maskedit_mask_poll(struct bContext *C); +int ED_space_sequencer_check_show_maskedit(struct SpaceSeq *sseq, struct Scene *scene); +int ED_space_sequencer_maskedit_poll(bContext *C); + void ED_operatormacros_sequencer(void); #endif /* __ED_SEQUENCER_H__ */ diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index f378d5452a4..8503c538a8d 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -129,7 +129,8 @@ static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline, if (!spline->tot_point) return; - hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE); + /* TODO, add this to sequence editor */ + hsize = 4; /* UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE); */ glPointSize(hsize); diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index b9522540e67..3ba198b60be 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -44,6 +44,7 @@ #include "ED_mask.h" /* own include */ #include "ED_object.h" /* ED_keymap_proportional_maskmode only */ #include "ED_clip.h" +#include "ED_sequencer.h" #include "ED_transform.h" #include "RNA_access.h" @@ -54,23 +55,29 @@ int ED_maskedit_poll(bContext *C) { - SpaceClip *sc = CTX_wm_space_clip(C); - - if (sc) { - return ED_space_clip_maskedit_poll(C); + ScrArea *sa = CTX_wm_area(C); + if (sa) { + switch (sa->spacetype) { + case SPACE_CLIP: + return ED_space_clip_maskedit_poll(C); + case SPACE_SEQ: + return ED_space_sequencer_maskedit_poll(C); + } } - return FALSE; } int ED_maskedit_mask_poll(bContext *C) { - SpaceClip *sc = CTX_wm_space_clip(C); - - if (sc) { - return ED_space_clip_maskedit_mask_poll(C); + ScrArea *sa = CTX_wm_area(C); + if (sa) { + switch (sa->spacetype) { + case SPACE_CLIP: + return ED_space_clip_maskedit_mask_poll(C); + case SPACE_SEQ: + return ED_space_sequencer_maskedit_mask_poll(C); + } } - return FALSE; } diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 3623cd1d58b..af96644a254 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1066,10 +1066,10 @@ static void clip_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); - /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Clip", SPACE_CLIP, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 38f29e8816e..09bfa384db0 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -798,6 +798,61 @@ static void UNUSED_FUNCTION(set_special_seq_update) (int val) else special_seq_update = NULL; } +static void sequencer_main_area_draw_mask(const bContext *C, Scene *scene, ARegion *ar) +{ + Mask *mask = BKE_sequencer_mask_get(scene); + + if (mask) { + struct View2D *v2d = &ar->v2d; + + int x, y; + int width, height; + float zoomx, zoomy; + + /* frame image */ + float maxdim; + float xofs, yofs; + + /* find window pixel coordinates of origin */ + UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); + + width = v2d->tot.xmax - v2d->tot.xmin; + height = v2d->tot.ymax - v2d->tot.ymin; + + zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)); + zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)); + + x += v2d->tot.xmin * zoomx; + y += v2d->tot.ymin * zoomy; + + /* frame the image */ + maxdim = maxf(width, height); + if (width == height) { + xofs = yofs = 0; + } + else if (width < height) { + xofs = ((height - width) / -2.0f) * zoomx; + yofs = 0.0f; + } + else { /* (width > height) */ + xofs = 0.0f; + yofs = ((width - height) / -2.0f) * zoomy; + } + + /* apply transformation so mask editing tools will assume drawing from the origin in normalized space */ + glPushMatrix(); + glTranslatef(x + xofs, y + yofs, 0); + glScalef(maxdim * zoomx, maxdim * zoomy, 0); + + ED_mask_draw((bContext *)C, 0, 0); // sc->mask_draw_flag, sc->mask_draw_type + + ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); + + glPopMatrix(); + } +} + + void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs) { struct Main *bmain = CTX_data_main(C); @@ -992,54 +1047,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq //if (sc->mode == SC_MODE_MASKEDIT) { if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { - Sequence *seq_act = BKE_sequencer_active_get(scene); - - if (seq_act && seq_act->type == SEQ_TYPE_MASK && seq_act->mask) { - int x, y; - int width, height; - float zoomx, zoomy; - - /* frame image */ - float maxdim; - float xofs, yofs; - - /* find window pixel coordinates of origin */ - UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); - - width = v2d->tot.xmax - v2d->tot.xmin; - height = v2d->tot.ymax - v2d->tot.ymin; - - zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)); - zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)); - - x += v2d->tot.xmin * zoomx; - y += v2d->tot.ymin * zoomy; - - /* frame the image */ - maxdim = maxf(width, height); - if (width == height) { - xofs = yofs = 0; - } - else if (width < height) { - xofs = ((height - width) / -2.0f) * zoomx; - yofs = 0.0f; - } - else { /* (width > height) */ - xofs = 0.0f; - yofs = ((width - height) / -2.0f) * zoomy; - } - - /* apply transformation so mask editing tools will assume drawing from the origin in normalized space */ - glPushMatrix(); - glTranslatef(x + xofs, y + yofs, 0); - glScalef(maxdim * zoomx, maxdim * zoomy, 0); - - ED_mask_draw((bContext *)C, 0, 0); // sc->mask_draw_flag, sc->mask_draw_type - - ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); - - glPopMatrix(); - } + sequencer_main_area_draw_mask(C, scene, ar); } } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 82e2730c59e..92c0f785ccb 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -466,6 +466,33 @@ void recurs_sel_seq(Sequence *seqm) } } +int ED_space_sequencer_maskedit_mask_poll(bContext *C) +{ + /* in this case both funcs are the same, for clip editor not */ + return ED_space_sequencer_maskedit_poll(C); +} + +int ED_space_sequencer_check_show_maskedit(SpaceSeq *sseq, Scene *scene) +{ + if (sseq && sseq->mainb == SEQ_DRAW_IMG_IMBUF) { + return (BKE_sequencer_mask_get(scene) != NULL); + } + + return FALSE; +} + +int ED_space_sequencer_maskedit_poll(bContext *C) +{ + SpaceSeq *sseq = CTX_wm_space_seq(C); + + if (sseq) { + Scene *scene = CTX_data_scene(C); + return ED_space_sequencer_check_show_maskedit(sseq, scene); + } + + return FALSE; +} + int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequence **selseq1, Sequence **selseq2, Sequence **selseq3, const char **error_str) { Editing *ed = BKE_sequencer_editing_get(scene, FALSE); diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index cabc761161e..34ca26a3176 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -300,7 +300,10 @@ static void sequencer_main_area_init(wmWindowManager *wm, ARegion *ar) ListBase *lb; UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); - + +// keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0); +// WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + keymap = WM_keymap_find(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -409,9 +412,9 @@ static int sequencer_context(const bContext *C, const char *member, bContextData return TRUE; } else if (CTX_data_equals(member, "edit_mask")) { - Sequence *seq_act = BKE_sequencer_active_get(scene); - if (seq_act && seq_act->type == SEQ_TYPE_MASK && seq_act->mask) { - CTX_data_id_pointer_set(result, &seq_act->mask->id); + Mask *mask = BKE_sequencer_mask_get(scene); + if (mask) { + CTX_data_id_pointer_set(result, &mask->id); } return TRUE; } @@ -468,6 +471,9 @@ static void sequencer_preview_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); +// keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0); +// WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + keymap = WM_keymap_find(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); |