Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-07-27 02:41:40 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-07-27 02:41:40 +0400
commitff078d309e65d2383fa0829954c724fc49189492 (patch)
treee383ad5f7fa69eba20adfa691f7a90f49925c64d /source/blender/editors/mask
parentee572a9642d5360f0ba852c17cc345f21ad1f985 (diff)
change clip utility function arguments to take space data and region rather then the context.
this allows a fix to be applied that corrects the helper line in the image view when transforming a mask.
Diffstat (limited to 'source/blender/editors/mask')
-rw-r--r--source/blender/editors/mask/mask_add.c24
-rw-r--r--source/blender/editors/mask/mask_draw.c6
-rw-r--r--source/blender/editors/mask/mask_edit.c49
-rw-r--r--source/blender/editors/mask/mask_ops.c34
-rw-r--r--source/blender/editors/mask/mask_select.c31
5 files changed, 88 insertions, 56 deletions
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index c9f6dc0c5fb..48c81894b55 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -38,6 +38,7 @@
#include "BKE_mask.h"
#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
#include "DNA_mask_types.h"
#include "DNA_object_types.h" /* SELECT */
@@ -57,6 +58,9 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no
float *u_r, float tangent[2],
const short use_deform)
{
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+
MaskLayer *masklay, *point_masklay;
MaskSpline *point_spline;
MaskSplinePoint *point = NULL;
@@ -65,9 +69,9 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no
float u;
float scalex, scaley, aspx, aspy;
- ED_mask_size(C, &width, &height);
- ED_mask_aspect(C, &aspx, &aspy);
- ED_mask_pixelspace_factor(C, &scalex, &scaley);
+ ED_mask_get_size(sa, &width, &height);
+ ED_mask_get_aspect(sa, ar, &aspx, &aspy);
+ ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley);
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
@@ -180,6 +184,8 @@ static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline
const float point_co[2], const float tangent[2], const float u,
MaskSplinePoint *reference_point, const short reference_adjacent)
{
+ ScrArea *sa = CTX_wm_area(C);
+
MaskSplinePoint *prev_point = NULL;
MaskSplinePoint *next_point = NULL;
BezTriple *bezt;
@@ -190,7 +196,7 @@ static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline
copy_v2_v2(co, point_co);
co[2] = 0.0f;
- ED_mask_size(C, &width, &height);
+ ED_mask_get_size(sa, &width, &height);
/* point coordinate */
bezt = &new_point->bezt;
@@ -610,9 +616,12 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+
float co[2];
- ED_mask_mouse_pos(C, event, co);
+ ED_mask_mouse_pos(sa, ar, event, co);
RNA_float_set_array(op->ptr, "location", co);
@@ -681,9 +690,12 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op)
static int add_feather_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+
float co[2];
- ED_mask_mouse_pos(C, event, co);
+ ED_mask_mouse_pos(sa, ar, event, co);
RNA_float_set_array(op->ptr, "location", co);
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index c79920eeb01..f416e31c1de 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -456,19 +456,21 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type
void ED_mask_draw(const bContext *C,
const char draw_flag, const char draw_type)
{
+ ScrArea *sa = CTX_wm_area(C);
+
Mask *mask = CTX_data_edit_mask(C);
int width, height;
if (!mask)
return;
- ED_mask_size(C, &width, &height);
+ ED_mask_get_size(sa, &width, &height);
draw_masklays(mask, draw_flag, draw_type, width, height);
}
/* sets up the opengl context.
- * width, height are to match the values from ED_mask_size() */
+ * 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,
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c
index 5c724d9e5a3..7b94cb83fe9 100644
--- a/source/blender/editors/mask/mask_edit.c
+++ b/source/blender/editors/mask/mask_edit.c
@@ -90,21 +90,19 @@ int ED_maskedit_mask_poll(bContext *C)
/********************** registration *********************/
-void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2])
+void ED_mask_mouse_pos(ScrArea *sa, ARegion *ar, wmEvent *event, float co[2])
{
- ScrArea *sa = CTX_wm_area(C);
if (sa) {
switch (sa->spacetype) {
case SPACE_CLIP:
{
SpaceClip *sc = sa->spacedata.first;
- ED_clip_mouse_pos(C, event, co);
+ ED_clip_mouse_pos(sc, ar, event, co);
BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
break;
}
case SPACE_SEQ:
{
- ARegion *ar = CTX_wm_region(C);
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
break;
}
@@ -112,7 +110,6 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2])
{
float frame_size[2];
SpaceImage *sima = sa->spacedata.first;
- ARegion *ar = CTX_wm_region(C);
ED_space_image_get_size_fl(sima, frame_size);
ED_image_mouse_pos(sima, ar, event, co);
BKE_mask_coord_from_frame(co, co, frame_size);
@@ -133,9 +130,8 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2])
/* input: x/y - mval space
* output: xr/yr - mask point space */
-void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr)
+void ED_mask_point_pos(struct ScrArea *sa, struct ARegion *ar, float x, float y, float *xr, float *yr)
{
- ScrArea *sa = CTX_wm_area(C);
float co[2];
if (sa) {
@@ -143,7 +139,7 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr
case SPACE_CLIP:
{
SpaceClip *sc = sa->spacedata.first;
- ED_clip_point_stable_pos(C, x, y, &co[0], &co[1]);
+ ED_clip_point_stable_pos(sc, ar, x, y, &co[0], &co[1]);
BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
break;
}
@@ -154,7 +150,6 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr
{
float frame_size[2];
SpaceImage *sima = sa->spacedata.first;
- ARegion *ar = CTX_wm_region(C);
ED_space_image_get_size_fl(sima, frame_size);
ED_image_point_pos(sima, ar, x, y, &co[0], &co[1]);
BKE_mask_coord_from_frame(co, co, frame_size);
@@ -176,9 +171,8 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr
*yr = co[1];
}
-void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, float *yr)
+void ED_mask_point_pos__reverse(ScrArea *sa, ARegion *ar, float x, float y, float *xr, float *yr)
{
- ScrArea *sa = CTX_wm_area(C);
float co[2];
if (sa) {
@@ -189,7 +183,7 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr,
co[0] = x;
co[1] = y;
BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co);
- ED_clip_point_stable_pos__reverse(C, co, co);
+ ED_clip_point_stable_pos__reverse(sc, ar, co, co);
break;
}
case SPACE_SEQ:
@@ -199,7 +193,6 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr,
{
float frame_size[2];
SpaceImage *sima = sa->spacedata.first;
- ARegion *ar = CTX_wm_region(C);
ED_space_image_get_size_fl(sima, frame_size);
co[0] = x;
@@ -224,21 +217,21 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr,
*yr = co[1];
}
-void ED_mask_size(const bContext *C, int *width, int *height)
+void ED_mask_get_size(struct ScrArea *sa, int *width, int *height)
{
- ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacedata.first) {
switch (sa->spacetype) {
case SPACE_CLIP:
{
- ED_space_clip_get_size(C, width, height);
+ SpaceClip *sc = sa->spacedata.first;
+ ED_space_clip_get_size(sc, width, height);
break;
}
case SPACE_SEQ:
{
- Scene *scene = CTX_data_scene(C);
- *width = (scene->r.size * scene->r.xsch) / 100;
- *height = (scene->r.size * scene->r.ysch) / 100;
+// Scene *scene = CTX_data_scene(C);
+// *width = (scene->r.size * scene->r.xsch) / 100;
+// *height = (scene->r.size * scene->r.ysch) / 100;
break;
}
case SPACE_IMAGE:
@@ -262,14 +255,14 @@ void ED_mask_size(const bContext *C, int *width, int *height)
}
}
-void ED_mask_zoom(const bContext *C, float *zoomx, float *zoomy)
+void ED_mask_zoom(struct ScrArea *sa, struct ARegion *ar, float *zoomx, float *zoomy)
{
- ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacedata.first) {
switch (sa->spacetype) {
case SPACE_CLIP:
{
- ED_space_clip_get_zoom(C, zoomx, zoomy);
+ SpaceClip *sc = sa->spacedata.first;
+ ED_space_clip_get_zoom(sc, ar, zoomx, zoomy);
break;
}
case SPACE_SEQ:
@@ -280,7 +273,6 @@ void ED_mask_zoom(const bContext *C, float *zoomx, float *zoomy)
case SPACE_IMAGE:
{
SpaceImage *sima = sa->spacedata.first;
- ARegion *ar = CTX_wm_region(C);
ED_space_image_get_zoom(sima, ar, zoomx, zoomy);
break;
}
@@ -297,9 +289,8 @@ void ED_mask_zoom(const bContext *C, float *zoomx, float *zoomy)
}
}
-void ED_mask_aspect(const bContext *C, float *aspx, float *aspy)
+void ED_mask_get_aspect(struct ScrArea *sa, struct ARegion *UNUSED(ar), float *aspx, float *aspy)
{
- ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacedata.first) {
switch (sa->spacetype) {
case SPACE_CLIP:
@@ -332,9 +323,8 @@ void ED_mask_aspect(const bContext *C, float *aspx, float *aspy)
}
}
-void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley)
+void ED_mask_pixelspace_factor(struct ScrArea *sa, struct ARegion *ar, float *scalex, float *scaley)
{
- ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacedata.first) {
switch (sa->spacetype) {
case SPACE_CLIP:
@@ -343,8 +333,8 @@ void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley)
int width, height;
float zoomx, zoomy, aspx, aspy;
- ED_space_clip_get_size(C, &width, &height);
- ED_space_clip_get_zoom(C, &zoomx, &zoomy);
+ ED_space_clip_get_size(sc, &width, &height);
+ ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
ED_space_clip_get_aspect(sc, &aspx, &aspy);
*scalex = ((float)width * aspx) * zoomx;
@@ -359,7 +349,6 @@ void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley)
case SPACE_IMAGE:
{
SpaceImage *sima = sa->spacedata.first;
- ARegion *ar = CTX_wm_region(C);
int width, height;
float zoomx, zoomy, aspx, aspy;
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index 99c46c38bfc..116c3dcede1 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -62,6 +62,9 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, Mask *mask, float
MaskLayer **masklay_r, MaskSpline **spline_r, int *is_handle_r,
float *score)
{
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+
MaskLayer *masklay;
MaskLayer *point_masklay = NULL;
MaskSpline *point_spline = NULL;
@@ -70,9 +73,9 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, Mask *mask, float
float len = FLT_MAX, scalex, scaley;
int is_handle = FALSE, width, height;
- ED_mask_size(C, &width, &height);
- ED_mask_aspect(C, &aspx, &aspy);
- ED_mask_pixelspace_factor(C, &scalex, &scaley);
+ ED_mask_get_size(sa, &width, &height);
+ ED_mask_get_aspect(sa, ar, &aspx, &aspy);
+ ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley);
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
@@ -158,6 +161,9 @@ int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[
MaskLayer **masklay_r, MaskSpline **spline_r, MaskSplinePoint **point_r,
MaskSplinePointUW **uw_r, float *score)
{
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+
MaskLayer *masklay, *point_masklay = NULL;
MaskSpline *point_spline = NULL;
MaskSplinePoint *point = NULL;
@@ -166,9 +172,9 @@ int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[
float scalex, scaley, aspx, aspy;
int width, height;
- ED_mask_size(C, &width, &height);
- ED_mask_aspect(C, &aspx, &aspy);
- ED_mask_pixelspace_factor(C, &scalex, &scaley);
+ ED_mask_get_size(sa, &width, &height);
+ ED_mask_get_aspect(sa, ar, &aspx, &aspy);
+ ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley);
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
@@ -426,6 +432,9 @@ static int slide_point_check_initial_feather(MaskSpline *spline)
static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event)
{
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+
Mask *mask = CTX_data_edit_mask(C);
SlidePointData *customdata = NULL;
MaskLayer *masklay, *cv_masklay, *feather_masklay;
@@ -437,8 +446,8 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event)
float co[2], cv_score, feather_score;
const float threshold = 19;
- ED_mask_mouse_pos(C, event, co);
- ED_mask_size(C, &width, &height);
+ ED_mask_mouse_pos(sa, ar, event, co);
+ ED_mask_get_size(sa, &width, &height);
cv_point = ED_mask_point_find_nearest(C, mask, co, threshold, &cv_masklay, &cv_spline, &is_handle, &cv_score);
@@ -502,7 +511,7 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event)
copy_m3_m3(customdata->vec, point->bezt.vec);
if (BKE_mask_point_has_handle(point))
BKE_mask_point_handle(point, customdata->handle);
- ED_mask_mouse_pos(C, event, customdata->co);
+ ED_mask_mouse_pos(sa, ar, event, customdata->co);
}
return customdata;
@@ -639,7 +648,11 @@ static int slide_point_modal(bContext *C, wmOperator *op, wmEvent *event)
/* no break! update CV position */
case MOUSEMOVE:
- ED_mask_mouse_pos(C, event, co);
+ {
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+
+ ED_mask_mouse_pos(sa, ar, event, co);
sub_v2_v2v2(dco, co, data->co);
if (data->action == SLIDE_ACTION_HANDLE) {
@@ -768,6 +781,7 @@ static int slide_point_modal(bContext *C, wmOperator *op, wmEvent *event)
DAG_id_tag_update(&data->mask->id, 0);
break;
+ }
case LEFTMOUSE:
if (event->val == KM_RELEASE) {
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index 565beaf34ef..2f5fef1d59a 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -343,9 +343,12 @@ static int select_exec(bContext *C, wmOperator *op)
static int select_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+
float co[2];
- ED_mask_mouse_pos(C, event, co);
+ ED_mask_mouse_pos(sa, ar, event, co);
RNA_float_set_array(op->ptr, "location", co);
@@ -380,6 +383,9 @@ void MASK_OT_select(wmOperatorType *ot)
static int border_select_exec(bContext *C, wmOperator *op)
{
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
int i;
@@ -394,8 +400,8 @@ static int border_select_exec(bContext *C, wmOperator *op)
rect.xmax = RNA_int_get(op->ptr, "xmax");
rect.ymax = RNA_int_get(op->ptr, "ymax");
- ED_mask_point_pos(C, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
- ED_mask_point_pos(C, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
+ ED_mask_point_pos(sa, ar, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
+ ED_mask_point_pos(sa, ar, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
mode = RNA_int_get(op->ptr, "gesture_mode");
extend = RNA_boolean_get(op->ptr, "extend");
@@ -465,6 +471,9 @@ void MASK_OT_select_border(wmOperatorType *ot)
static int do_lasso_select_mask(bContext *C, int mcords[][2], short moves, short select)
{
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
int i;
@@ -496,7 +505,7 @@ static int do_lasso_select_mask(bContext *C, int mcords[][2], short moves, short
float screen_co[2];
/* marker in screen coords */
- ED_mask_point_pos__reverse(C,
+ ED_mask_point_pos__reverse(sa, ar,
point_deform->bezt.vec[1][0], point_deform->bezt.vec[1][1],
&screen_co[0], &screen_co[1]);
@@ -578,6 +587,9 @@ static int mask_spline_point_inside_ellipse(BezTriple *bezt, float offset[2], fl
static int circle_select_exec(bContext *C, wmOperator *op)
{
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
int i;
@@ -593,14 +605,14 @@ static int circle_select_exec(bContext *C, wmOperator *op)
mode = RNA_int_get(op->ptr, "gesture_mode");
/* compute ellipse and position in unified coordinates */
- ED_mask_size(C, &width, &height);
- ED_mask_zoom(C, &zoomx, &zoomy);
+ ED_mask_get_size(sa, &width, &height);
+ ED_mask_zoom(sa, ar, &zoomx, &zoomy);
width = height = MAX2(width, height);
ellipse[0] = width * zoomx / radius;
ellipse[1] = height * zoomy / radius;
- ED_mask_point_pos(C, x, y, &offset[0], &offset[1]);
+ ED_mask_point_pos(sa, ar, x, y, &offset[0], &offset[1]);
/* do actual selection */
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
@@ -663,6 +675,9 @@ void MASK_OT_select_circle(wmOperatorType *ot)
static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *masklay;
MaskSpline *spline;
@@ -674,7 +689,7 @@ static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *
const float threshold = 19;
int change = FALSE;
- ED_mask_mouse_pos(C, event, co);
+ ED_mask_mouse_pos(sa, ar, event, co);
point = ED_mask_point_find_nearest(C, mask, co, threshold, &masklay, &spline, &is_handle, NULL);