diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 1 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 60 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_draw.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_clip/tracking_ops.c | 33 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 61 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 5 |
6 files changed, 97 insertions, 68 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index f0fffb34b73..f62befdaa31 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -66,6 +66,7 @@ void ED_region_header(const struct bContext *C, struct ARegion *ar); void ED_region_toggle_hidden(struct bContext *C, struct ARegion *ar); void region_scissor_winrct(struct ARegion *ar, struct rcti *winrct); void ED_region_info_draw(struct ARegion *ar, const char *text, int block, float alpha); +void ED_region_grid_draw(struct ARegion *ar, float zoomx, float zoomy); /* spaces */ void ED_spacetypes_init(void); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index eb1688a76e2..2a561a6bc6c 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1813,3 +1813,63 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha) BLF_position(fontid, 12, rect.ymin + 5, 0.0f); BLF_draw(fontid, text, BLF_DRAW_STR_DUMMY_MAX); } + +void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy) +{ + float gridsize, gridstep = 1.0f / 32.0f; + float fac, blendfac; + int x1, y1, x2, y2; + + /* the image is located inside (0,0),(1, 1) as set by view2d */ + UI_ThemeColorShade(TH_BACK, 20); + + UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x1, &y1); + UI_view2d_to_region_no_clip(&ar->v2d, 1.0f, 1.0f, &x2, &y2); + glRectf(x1, y1, x2, y2); + + /* gridsize adapted to zoom level */ + gridsize = 0.5f * (zoomx + zoomy); + if (gridsize <= 0.0f) + return; + + if (gridsize < 1.0f) { + while (gridsize < 1.0f) { + gridsize *= 4.0f; + gridstep *= 4.0f; + } + } + else { + while (gridsize >= 4.0f) { + gridsize /= 4.0f; + gridstep /= 4.0f; + } + } + + /* the fine resolution level */ + blendfac = 0.25f * gridsize - floorf(0.25f * gridsize); + CLAMP(blendfac, 0.0f, 1.0f); + UI_ThemeColorShade(TH_BACK, (int)(20.0f * (1.0f - blendfac))); + + fac = 0.0f; + glBegin(GL_LINES); + while (fac < 1.0f) { + glVertex2f(x1, y1 * (1.0f - fac) + y2 * fac); + glVertex2f(x2, y1 * (1.0f - fac) + y2 * fac); + glVertex2f(x1 * (1.0f - fac) + x2 * fac, y1); + glVertex2f(x1 * (1.0f - fac) + x2 * fac, y2); + fac += gridstep; + } + + /* the large resolution level */ + UI_ThemeColor(TH_BACK); + + fac = 0.0f; + while (fac < 1.0f) { + glVertex2f(x1, y1 * (1.0f - fac) + y2 * fac); + glVertex2f(x2, y1 * (1.0f - fac) + y2 * fac); + glVertex2f(x1 * (1.0f - fac) + x2 * fac, y1); + glVertex2f(x1 * (1.0f - fac) + x2 * fac, y2); + fac += 4.0f * gridstep; + } + glEnd(); +} diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index bf8976035a8..2f9956fc143 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -1380,7 +1380,12 @@ void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) if (ibuf) { draw_movieclip_buffer(sc, ar, ibuf, width, height, zoomx, zoomy); IMB_freeImBuf(ibuf); + } + else { + ED_region_grid_draw(ar, zoomx, zoomy); + } + if (width && height) { draw_tracking_tracks(sc, ar, clip, width, height, zoomx, zoomy); draw_distortion(sc, ar, clip, width, height, zoomx, zoomy); } diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 2b1b311b89d..f4454394ca3 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -92,6 +92,25 @@ static int space_clip_frame_poll(bContext *C) return FALSE; } +static int space_clip_size_poll(bContext *C) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + + if (sc) { + MovieClip *clip = ED_space_clip(sc); + + if (clip) { + int width, height; + + BKE_movieclip_get_size(clip, &sc->user, &width, &height); + + return width > 0 && height > 0; + } + } + + return FALSE; +} + /********************** add marker operator *********************/ static void add_marker(SpaceClip *sc, float x, float y) @@ -156,7 +175,7 @@ void CLIP_OT_add_marker(wmOperatorType *ot) /* api callbacks */ ot->invoke = add_marker_invoke; ot->exec = add_marker_exec; - ot->poll = space_clip_frame_poll; + ot->poll = space_clip_size_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -643,7 +662,7 @@ void CLIP_OT_slide_marker(wmOperatorType *ot) ot->idname = "CLIP_OT_slide_marker"; /* api callbacks */ - ot->poll = space_clip_frame_poll; + ot->poll = space_clip_size_poll; ot->invoke = slide_marker_invoke; ot->modal = slide_marker_modal; @@ -1200,7 +1219,7 @@ void CLIP_OT_select_grouped(wmOperatorType *ot) /* api callbacks */ ot->exec = select_groped_exec; - ot->poll = space_clip_frame_poll; + ot->poll = space_clip_size_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2016,7 +2035,7 @@ static Object *get_orientation_object(bContext *C) static int set_orientation_poll(bContext *C) { - if (space_clip_frame_poll(C)) { + if (space_clip_size_poll(C)) { Scene *scene = CTX_data_scene(C); SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip(sc); @@ -2626,7 +2645,7 @@ void CLIP_OT_set_scale(wmOperatorType *ot) static int set_solution_scale_poll(bContext *C) { - if (space_clip_frame_poll(C)) { + if (space_clip_size_poll(C)) { SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip(sc); MovieTracking *tracking = &clip->tracking; @@ -2974,7 +2993,7 @@ void CLIP_OT_frame_jump(wmOperatorType *ot) /* api callbacks */ ot->exec = frame_jump_exec; - ot->poll = space_clip_frame_poll; + ot->poll = ED_space_clip_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3031,7 +3050,7 @@ void CLIP_OT_join_tracks(wmOperatorType *ot) /* api callbacks */ ot->exec = join_tracks_exec; - ot->poll = space_clip_frame_poll; + ot->poll = space_clip_size_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 29bd5f5117d..793e5712c8c 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -334,65 +334,6 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int /* image drawing */ -static void draw_image_grid(ARegion *ar, float zoomx, float zoomy) -{ - float gridsize, gridstep = 1.0f / 32.0f; - float fac, blendfac; - int x1, y1, x2, y2; - - /* the image is located inside (0,0),(1, 1) as set by view2d */ - UI_ThemeColorShade(TH_BACK, 20); - - UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x1, &y1); - UI_view2d_to_region_no_clip(&ar->v2d, 1.0f, 1.0f, &x2, &y2); - glRectf(x1, y1, x2, y2); - - /* gridsize adapted to zoom level */ - gridsize = 0.5f * (zoomx + zoomy); - if (gridsize <= 0.0f) return; - - if (gridsize < 1.0f) { - while (gridsize < 1.0f) { - gridsize *= 4.0f; - gridstep *= 4.0f; - } - } - else { - while (gridsize >= 4.0f) { - gridsize /= 4.0f; - gridstep /= 4.0f; - } - } - - /* the fine resolution level */ - blendfac = 0.25f * gridsize - floorf(0.25f * gridsize); - CLAMP(blendfac, 0.0f, 1.0f); - UI_ThemeColorShade(TH_BACK, (int)(20.0f * (1.0f - blendfac))); - - fac = 0.0f; - glBegin(GL_LINES); - while (fac < 1.0f) { - glVertex2f(x1, y1 * (1.0f - fac) + y2 * fac); - glVertex2f(x2, y1 * (1.0f - fac) + y2 * fac); - glVertex2f(x1 * (1.0f - fac) + x2 * fac, y1); - glVertex2f(x1 * (1.0f - fac) + x2 * fac, y2); - fac += gridstep; - } - - /* the large resolution level */ - UI_ThemeColor(TH_BACK); - - fac = 0.0f; - while (fac < 1.0f) { - glVertex2f(x1, y1 * (1.0f - fac) + y2 * fac); - glVertex2f(x2, y1 * (1.0f - fac) + y2 * fac); - glVertex2f(x1 * (1.0f - fac) + x2 * fac, y1); - glVertex2f(x1 * (1.0f - fac) + x2 * fac, y2); - fac += 4.0f * gridstep; - } - glEnd(); -} - static void sima_draw_alpha_pixels(float x1, float y1, int rectx, int recty, unsigned int *recti) { @@ -781,7 +722,7 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) /* draw the image or grid */ if (ibuf == NULL) - draw_image_grid(ar, zoomx, zoomy); + ED_region_grid_draw(ar, zoomx, zoomy); else if (sima->flag & SI_DRAW_TILE) draw_image_buffer_repeated(sima, ar, scene, ima, ibuf, zoomx, zoomy); else if (ima && (ima->tpageflag & IMA_TILES)) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index d33b8787121..ebbc2ca9267 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5731,10 +5731,13 @@ static void createTransTrackingData(bContext *C, TransInfo *t) ARegion *ar = CTX_wm_region(C); SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip(sc); + int width, height; t->total = 0; - if (!clip || !BKE_movieclip_has_frame(clip, &sc->user)) + BKE_movieclip_get_size(clip, &sc->user, &width, &height); + + if (!clip || width == 0 || height == 0) return; if (!ELEM(t->mode, TFM_RESIZE, TFM_TRANSLATION)) |