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/space_clip/clip_editor.c
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/space_clip/clip_editor.c')
-rw-r--r--source/blender/editors/space_clip/clip_editor.c46
1 files changed, 19 insertions, 27 deletions
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 92fcbc2964d..c04cd864d2e 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -124,10 +124,8 @@ int ED_space_clip_maskedit_mask_poll(bContext *C)
/* ******** common editing functions ******** */
-void ED_space_clip_get_size(const bContext *C, int *width, int *height)
+void ED_space_clip_get_size(struct SpaceClip *sc, int *width, int *height)
{
- SpaceClip *sc = CTX_wm_space_clip(C);
-
if (sc->clip) {
BKE_movieclip_get_size(sc->clip, &sc->user, width, height);
}
@@ -136,20 +134,19 @@ void ED_space_clip_get_size(const bContext *C, int *width, int *height)
}
}
-void ED_space_clip_get_size_fl(const bContext *C, float size[2])
+void ED_space_clip_get_size_fl(struct SpaceClip *sc, float size[2])
{
int size_i[2];
- ED_space_clip_get_size(C, &size_i[0], &size_i[1]);
+ ED_space_clip_get_size(sc, &size_i[0], &size_i[1]);
size[0] = size_i[0];
size[1] = size_i[1];
}
-void ED_space_clip_get_zoom(const bContext *C, float *zoomx, float *zoomy)
+void ED_space_clip_get_zoom(struct SpaceClip *sc, struct ARegion *ar, float *zoomx, float *zoomy)
{
- ARegion *ar = CTX_wm_region(C);
int width, height;
- ED_space_clip_get_size(C, &width, &height);
+ ED_space_clip_get_size(sc, &width, &height);
*zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width);
*zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height);
@@ -273,9 +270,8 @@ void ED_clip_update_frame(const Main *mainp, int cfra)
}
}
-static int selected_boundbox(const bContext *C, float min[2], float max[2])
+static int selected_boundbox(SpaceClip *sc, float min[2], float max[2])
{
- SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTrackingTrack *track;
int width, height, ok = FALSE;
@@ -284,7 +280,7 @@ static int selected_boundbox(const bContext *C, float min[2], float max[2])
INIT_MINMAX2(min, max);
- ED_space_clip_get_size(C, &width, &height);
+ ED_space_clip_get_size(sc, &width, &height);
track = tracksbase->first;
while (track) {
@@ -327,17 +323,17 @@ int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit)
int w, h, frame_width, frame_height;
float min[2], max[2];
- ED_space_clip_get_size(C, &frame_width, &frame_height);
+ ED_space_clip_get_size(sc, &frame_width, &frame_height);
if (frame_width == 0 || frame_height == 0)
return FALSE;
- if (!selected_boundbox(C, min, max))
+ if (!selected_boundbox(sc, min, max))
return FALSE;
/* center view */
- clip_view_center_to_point(C, (max[0] + min[0]) / (2 * frame_width),
- (max[1] + min[1]) / (2 * frame_height));
+ clip_view_center_to_point(sc, (max[0] + min[0]) / (2 * frame_width),
+ (max[1] + min[1]) / (2 * frame_height));
w = max[0] - min[0];
h = max[1] - min[1];
@@ -385,15 +381,13 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[
}
}
-void ED_clip_point_stable_pos(const bContext *C, float x, float y, float *xr, float *yr)
+void ED_clip_point_stable_pos(struct SpaceClip *sc, struct ARegion *ar, float x, float y, float *xr, float *yr)
{
- ARegion *ar = CTX_wm_region(C);
- SpaceClip *sc = CTX_wm_space_clip(C);
int sx, sy, width, height;
float zoomx, zoomy, pos[3], imat[4][4];
- ED_space_clip_get_zoom(C, &zoomx, &zoomy);
- ED_space_clip_get_size(C, &width, &height);
+ ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
+ ED_space_clip_get_size(sc, &width, &height);
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
@@ -424,18 +418,16 @@ void ED_clip_point_stable_pos(const bContext *C, float x, float y, float *xr, fl
* \brief the reverse of ED_clip_point_stable_pos(), gets the marker region coords.
* better name here? view_to_track / track_to_view or so?
*/
-void ED_clip_point_stable_pos__reverse(const bContext *C, const float co[2], float r_co[2])
+void ED_clip_point_stable_pos__reverse(struct SpaceClip *sc, struct ARegion *ar, const float co[2], float r_co[2])
{
- SpaceClip *sc = CTX_wm_space_clip(C);
- ARegion *ar = CTX_wm_region(C);
float zoomx, zoomy;
float pos[3];
int width, height;
int sx, sy;
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
- 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_clip_point_undistorted_pos(sc, co, pos);
pos[2] = 0.0f;
@@ -447,9 +439,9 @@ void ED_clip_point_stable_pos__reverse(const bContext *C, const float co[2], flo
r_co[1] = (pos[1] * height * zoomy) + (float)sy;
}
-void ED_clip_mouse_pos(const bContext *C, wmEvent *event, float co[2])
+void ED_clip_mouse_pos(struct SpaceClip *sc, struct ARegion *ar, wmEvent *event, float co[2])
{
- ED_clip_point_stable_pos(C, event->mval[0], event->mval[1], &co[0], &co[1]);
+ ED_clip_point_stable_pos(sc, ar, event->mval[0], event->mval[1], &co[0], &co[1]);
}
int ED_space_clip_check_show_trackedit(SpaceClip *sc)