fix for drawing non 1:1 aspect masks, transform and selection still need support.
authorCampbell Barton <ideasman42@gmail.com>
Thu, 13 Sep 2012 02:28:48 +0000 (02:28 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 13 Sep 2012 02:28:48 +0000 (02:28 +0000)
source/blender/editors/include/ED_mask.h
source/blender/editors/mask/mask_draw.c
source/blender/editors/space_clip/space_clip.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_sequencer/sequencer_draw.c

index 8866772..8ebf932 100644 (file)
@@ -56,7 +56,8 @@ void ED_operatormacros_mask(void);
 void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type);
 void ED_mask_draw_region(struct Mask *mask, struct ARegion *ar,
                          const char draw_flag, const char draw_type,
-                         int width, int height,
+                         const int width_i, const int height_i,
+                         const float aspx, const float aspy,
                          const short do_scale_applied, const short do_post_draw,
                          float stabmat[4][4],
                          const bContext *C);
index 00bbfcf..655458b 100644 (file)
@@ -496,7 +496,8 @@ void ED_mask_draw(const bContext *C,
  * width, height are to match the values from ED_mask_get_size() */
 void ED_mask_draw_region(Mask *mask, ARegion *ar,
                          const char draw_flag, const char draw_type,
-                         int width, int height,
+                         const int width_i, const int height_i,  /* convert directly into aspect corrected vars */
+                         const float aspx, const float aspy,
                          const short do_scale_applied, const short do_post_draw,
                          float stabmat[4][4], /* optional - only used by clip */
                          const bContext *C    /* optional - only used when do_post_draw is set */
@@ -504,6 +505,9 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
 {
        struct View2D *v2d = &ar->v2d;
 
+       /* aspect always scales vertically in movie and image spaces */
+       const float width = width_i, height = (float)height_i * (aspy / aspx);
+
        int x, y;
        /* int w, h; */
        float zoomx, zoomy;
index bb06104..7f43c40 100644 (file)
@@ -1131,10 +1131,13 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
                if (mask) {
                        ScrArea *sa = CTX_wm_area(C);
                        int width, height;
+                       float aspx, aspy;
                        ED_mask_get_size(sa, &width, &height);
+                       ED_space_clip_get_aspect(sc, &aspx, &aspy);
                        ED_mask_draw_region(mask, ar,
                                            sc->mask_info.draw_flag, sc->mask_info.draw_type,
                                            width, height,
+                                           aspx, aspy,
                                            TRUE, TRUE,
                                            sc->stabmat, C);
                }
index 9cceaf0..91a0cba 100644 (file)
@@ -682,10 +682,13 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
 
        if (mask) {
                int width, height;
+               float aspx, aspy;
                ED_space_image_get_size(sima, &width, &height);
+               ED_space_image_get_aspect(sima, &aspx, &aspy);
                ED_mask_draw_region(mask, ar,
                                    sima->mask_info.draw_flag, sima->mask_info.draw_type,
                                    width, height,
+                                   aspx, aspy,
                                    TRUE, FALSE,
                                    NULL, C);
 
index ddb6812..0c31645 100644 (file)
@@ -1049,6 +1049,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
 
                if (mask) {
                        int width, height;
+                       float aspx = 1.0f, aspy = 1.0f;
                        // ED_mask_get_size(C, &width, &height);
 
                        //Scene *scene = CTX_data_scene(C);
@@ -1058,6 +1059,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
                        ED_mask_draw_region(mask, ar,
                                            0, 0,  /* TODO */
                                            width, height,
+                                           aspx, aspy,
                                            FALSE, TRUE,
                                            NULL, C);
                }