diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-01 14:50:39 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-01 14:50:39 +0400 |
commit | 26cc3dd7086d7e0061322f5b6f29ce10fb9d8abb (patch) | |
tree | 831493412b0fa80ded28b294ab6e4a88602197c6 /source/blender | |
parent | 0fee289551e90865e9f2041d49f19f5a8c065304 (diff) |
misc mask fixes
- image space used wrong notifiers.
- image notifier now checks for mask mode before listening to mask edits.
- mask keyframes now draw in the image space.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_mask.h | 2 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_draw.c | 37 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_draw.c | 26 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_utils.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 36 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mask.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 14 |
8 files changed, 80 insertions, 43 deletions
diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h index 9dd25114957..88667729eee 100644 --- a/source/blender/editors/include/ED_mask.h +++ b/source/blender/editors/include/ED_mask.h @@ -61,6 +61,8 @@ void ED_mask_draw_region(struct Mask *mask, struct ARegion *ar, float stabmat[4][4], const bContext *C); +void ED_mask_draw_frames(struct Mask *mask, struct ARegion *ar, const int cfra, const int sfra, const int efra); + /* mask_shapekey.c */ void ED_mask_layer_shape_auto_key(struct MaskLayer *masklay, const int frame); int ED_mask_layer_shape_auto_key_all(struct Mask *mask, const int frame); diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index f01fad10034..2f5a918a488 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -482,7 +482,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, struct View2D *v2d = &ar->v2d; int x, y; - int w, h; + /* int w, h; */ float zoomx, zoomy; /* frame image */ @@ -492,8 +492,10 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, /* find window pixel coordinates of origin */ UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); - w = v2d->tot.xmax - v2d->tot.xmin; - h = v2d->tot.ymax - v2d->tot.ymin; + + /* w = v2d->tot.xmax - v2d->tot.xmin; */ + /* h = 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)); @@ -538,3 +540,32 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, glPopMatrix(); } + +void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra, const int efra) +{ + const float framelen = ar->winx / (float)(efra - sfra + 1); + + MaskLayer *masklay = BKE_mask_layer_active(mask); + + glBegin(GL_LINES); + glColor4ub(255, 175, 0, 255); + + if (masklay) { + MaskLayerShape *masklay_shape; + + for (masklay_shape = masklay->splines_shapes.first; + masklay_shape; + masklay_shape = masklay_shape->next) + { + int frame = masklay_shape->frame; + + /* draw_keyframe(i, CFRA, sfra, framelen, 1); */ + int height = (frame == cfra) ? 22 : 10; + int x = (frame - sfra) * framelen; + glVertex2i(x, 0); + glVertex2i(x, height); + } + } + + glEnd(); +} diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 96eb6002840..c24cdab29e5 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -53,6 +53,7 @@ #include "ED_screen.h" #include "ED_clip.h" +#include "ED_mask.h" #include "ED_gpencil.h" #include "BIF_gl.h" @@ -73,7 +74,7 @@ /*********************** main area drawing *************************/ -void clip_draw_curfra_label(SpaceClip *sc, float x, float y) +void clip_draw_curfra_label(const int framenr, const float x, const float y) { uiStyle *style = UI_GetStyle(); int fontid = style->widget.uifont_id; @@ -82,7 +83,7 @@ void clip_draw_curfra_label(SpaceClip *sc, float x, float y) /* frame number */ BLF_size(fontid, 11.0f, U.dpi); - BLI_snprintf(numstr, sizeof(numstr), "%d", sc->user.framenr); + BLI_snprintf(numstr, sizeof(numstr), "%d", framenr); BLF_width_and_height(fontid, numstr, &font_dims[0], &font_dims[1]); @@ -212,7 +213,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc UI_ThemeColor(TH_CFRAME); glRecti(x, 0, x + framelen, 8); - clip_draw_curfra_label(sc, x, 8.0f); + clip_draw_curfra_label(sc->user.framenr, x, 8.0f); /* solver keyframes */ glColor4ub(175, 255, 0, 255); @@ -221,24 +222,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc /* movie clip animation */ if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask_info.mask) { - MaskLayer *masklay = BKE_mask_layer_active(sc->mask_info.mask); - if (masklay) { - MaskLayerShape *masklay_shape; - - glColor4ub(255, 175, 0, 255); - glBegin(GL_LINES); - - for (masklay_shape = masklay->splines_shapes.first; - masklay_shape; - masklay_shape = masklay_shape->next) - { - i = masklay_shape->frame; - - draw_keyframe(i, CFRA, sfra, framelen, 1); - } - - glEnd(); - } + ED_mask_draw_frames(sc->mask_info.mask, ar, CFRA, sfra, efra); } } diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 3422aacf264..392367f9071 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -71,7 +71,7 @@ void CLIP_OT_dopesheet_select_channel(struct wmOperatorType *ot); /* clip_draw.c */ void clip_draw_main(const struct bContext *C, struct SpaceClip *sc, struct ARegion *ar); void clip_draw_grease_pencil(struct bContext *C, int onlyv2d); -void clip_draw_curfra_label(struct SpaceClip *sc, float x, float y); +void clip_draw_curfra_label(const int framenr, const float x, const float y); /* clip_graph_draw.c */ void clip_draw_graph(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 9e93aed6df7..ddc624b4cdf 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -263,7 +263,7 @@ void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene) UI_view2d_getscale(v2d, &xscale, &yscale); glScalef(1.0f / xscale, 1.0f, 1.0f); - clip_draw_curfra_label(sc, (float)sc->user.framenr * xscale, 18); + clip_draw_curfra_label(sc->user.framenr, (float)sc->user.framenr * xscale, 18); /* restore view transform */ glScalef(xscale, 1.0, 1.0); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 79cc1eba898..f97813d3dd3 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -430,22 +430,28 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_MASK: - switch (wmn->data) { - case ND_SELECT: - case ND_DATA: - case ND_DRAW: - ED_area_tag_redraw(sa); - break; - } - switch (wmn->action) { - case NA_SELECTED: - ED_area_tag_redraw(sa); - break; - case NA_EDITED: - ED_area_tag_redraw(sa); - break; + { + // Scene *scene = wmn->window->screen->scene; + /* ideally would check for: ED_space_image_check_show_maskedit(scene, sima) but we cant get the scene */ + if (sima->mode == SI_MODE_MASK) { + switch (wmn->data) { + case ND_SELECT: + case ND_DATA: + case ND_DRAW: + ED_area_tag_redraw(sa); + break; + } + switch (wmn->action) { + case NA_SELECTED: + ED_area_tag_redraw(sa); + break; + case NA_EDITED: + ED_area_tag_redraw(sa); + break; + } } break; + } case NC_GEOM: switch (wmn->data) { case ND_DATA: @@ -643,6 +649,8 @@ static void image_main_area_draw(const bContext *C, ARegion *ar) TRUE, FALSE, NULL, C); + ED_mask_draw_frames(mask, ar, CFRA, mask->sfra, mask->efra); + draw_image_cursor(sima, ar); } diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index 382f5501ca4..9ee2bb99b4e 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -731,7 +731,7 @@ static void rna_def_mask(BlenderRNA *brna) RNA_def_property_int_funcs(prop, NULL, "rna_Mask_start_frame_set", NULL); RNA_def_property_range(prop, MINFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "Start Frame", "First frame of the mask (used for sequencer)"); - RNA_def_property_update(prop, NC_SCENE | ND_FRAME_RANGE, NULL); + RNA_def_property_update(prop, NC_MASK | ND_DRAW, NULL); prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); @@ -739,7 +739,7 @@ static void rna_def_mask(BlenderRNA *brna) RNA_def_property_int_funcs(prop, NULL, "rna_Mask_end_frame_set", NULL); RNA_def_property_range(prop, MINFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "End Frame", "Final frame of the mask (used for sequencer)"); - RNA_def_property_update(prop, NC_SCENE | ND_FRAME_RANGE, NULL); + RNA_def_property_update(prop, NC_MASK | ND_DRAW, NULL); /* pointers */ rna_def_animdata_common(srna); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 6fd26e0f8c5..793eb2b7185 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -558,6 +558,13 @@ static int rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr) return ED_space_image_show_uvedit(sima, sc->scene->obedit); } +static int rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr) +{ + SpaceImage *sima = (SpaceImage *)(ptr->data); + bScreen *sc = (bScreen *)ptr->id.data; + return ED_space_image_check_show_maskedit(sc->scene, sima); +} + static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value) { SpaceImage *sima = (SpaceImage *)(ptr->data); @@ -1123,7 +1130,7 @@ void rna_def_space_mask_info(StructRNA *srna, int noteflag, const char *mask_set RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Mask", "Mask displayed and edited in this space"); RNA_def_property_pointer_funcs(prop, NULL, mask_set_func, NULL, NULL); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL); + RNA_def_property_update(prop, noteflag, NULL); /* mask drawing */ prop = RNA_def_property(srna, "mask_draw_type", PROP_ENUM, PROP_NONE); @@ -2077,6 +2084,11 @@ static void rna_def_space_image(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Show UV Editor", "Show UV editing related properties"); + prop = RNA_def_property(srna, "show_maskedit", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_SpaceImageEditor_show_maskedit_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Show Mask Editor", "Show Mask editing related properties"); + rna_def_space_image_uv(brna); /* mask */ |