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-26 13:54:52 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-07-26 13:54:52 +0400
commit77e7ca6aa81e0874b53dd79dc6135e2fd6fb37db (patch)
tree5a4b26ceeb63cd17bf0de53d28c4077b3877b6ab /source/blender/editors
parentc8ce3b76fff32342d267d9da1e3ac4186b98bdb2 (diff)
mask/image editor now works for border select and lasso
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/ED_image.h2
-rw-r--r--source/blender/editors/include/ED_mask.h1
-rw-r--r--source/blender/editors/include/ED_uvedit.h1
-rw-r--r--source/blender/editors/mask/mask_edit.c63
-rw-r--r--source/blender/editors/mask/mask_intern.h3
-rw-r--r--source/blender/editors/mask/mask_select.c6
-rw-r--r--source/blender/editors/space_image/image_edit.c28
-rw-r--r--source/blender/editors/space_image/space_image.c31
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c4
9 files changed, 119 insertions, 20 deletions
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index 393a400b7bd..6edbe33de32 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -63,6 +63,8 @@ void ED_image_get_size(struct Image *ima, int *width, int *height);
void ED_image_get_aspect(struct Image *ima, float *aspx, float *aspy);
void ED_image_get_uv_aspect(struct Image *ima, float *aspx, float *aspy);
void ED_image_mouse_pos(struct SpaceImage *sima, struct ARegion *ar, struct wmEvent *event, float co[2]);
+void ED_image_point_pos(struct SpaceImage *sima, struct ARegion *ar, float x, float y, float *xr, float *yr);
+void ED_image_point_pos__reverse(struct SpaceImage *sima, struct ARegion *ar, const float co[2], float r_co[2]);
int ED_space_image_show_render(struct SpaceImage *sima);
int ED_space_image_show_paint(struct SpaceImage *sima);
diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h
index e155f6a9d02..758fe6367bb 100644
--- a/source/blender/editors/include/ED_mask.h
+++ b/source/blender/editors/include/ED_mask.h
@@ -37,6 +37,7 @@ struct MaskLayerShape;
/* mask_edit.c */
void ED_mask_size(const struct bContext *C, int *width, int *height);
+void ED_mask_zoom(const struct bContext *C, float *zoomx, float *zoomy);
void ED_mask_aspect(const struct bContext *C, float *aspx, float *aspy);
void ED_operatortypes_mask(void);
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h
index 2427ed1a333..56f8a455c52 100644
--- a/source/blender/editors/include/ED_uvedit.h
+++ b/source/blender/editors/include/ED_uvedit.h
@@ -85,6 +85,7 @@ void ED_uvedit_live_unwrap(struct Scene *scene, struct Object *obedit);
void ED_unwrap_lscm(struct Scene *scene, struct Object *obedit, const short sel);
/* uvedit_draw.c */
+void draw_image_cursor(struct SpaceImage *sima, struct ARegion *ar);
void draw_uvedit_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene, struct Object *obedit, struct Object *obact);
/* uvedit_buttons.c */
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c
index 6a5e5c03345..0491b164fec 100644
--- a/source/blender/editors/mask/mask_edit.c
+++ b/source/blender/editors/mask/mask_edit.c
@@ -155,8 +155,15 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr
break;
case SPACE_IMAGE:
{
- //SpaceImage *sima = sa->spacedata.first;
- zero_v2(co); /* MASKTODO */
+ int width, height;
+ float frame_size[2];
+ SpaceImage *sima = sa->spacedata.first;
+ ARegion *ar = CTX_wm_region(C);
+ ED_space_image_get_size(sima, &width, &height);
+ frame_size[0] = width;
+ frame_size[1] = height;
+ ED_image_point_pos(sima, ar, x, y, &co[0], &co[1]);
+ BKE_mask_coord_from_frame(co, co, frame_size);
break;
}
default:
@@ -195,8 +202,21 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr,
zero_v2(co); /* MASKTODO */
break;
case SPACE_IMAGE:
- zero_v2(co); /* MASKTODO */
+ {
+ int width, height;
+ float frame_size[2];
+ SpaceImage *sima = sa->spacedata.first;
+ ARegion *ar = CTX_wm_region(C);
+ ED_space_image_get_size(sima, &width, &height);
+ frame_size[0] = width;
+ frame_size[1] = height;
+
+ co[0] = x;
+ co[1] = y;
+ BKE_mask_coord_to_frame(co, co, frame_size);
+ ED_image_point_pos__reverse(sima, ar, co, co);
break;
+ }
default:
/* possible other spaces from which mask editing is available */
BLI_assert(0);
@@ -251,6 +271,41 @@ void ED_mask_size(const bContext *C, int *width, int *height)
}
}
+void ED_mask_zoom(const bContext *C, 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);
+ break;
+ }
+ case SPACE_SEQ:
+ {
+ *zoomx = *zoomy = 1.0f;
+ break;
+ }
+ case SPACE_IMAGE:
+ {
+ SpaceImage *sima = sa->spacedata.first;
+ ARegion *ar = CTX_wm_region(C);
+ ED_space_image_get_zoom(sima, ar, zoomx, zoomy);
+ break;
+ }
+ default:
+ /* possible other spaces from which mask editing is available */
+ BLI_assert(0);
+ *zoomx = *zoomy = 1.0f;
+ break;
+ }
+ }
+ else {
+ BLI_assert(0);
+ *zoomx = *zoomy = 1.0f;
+ }
+}
+
void ED_mask_aspect(const bContext *C, float *aspx, float *aspy)
{
ScrArea *sa = CTX_wm_area(C);
@@ -472,6 +527,8 @@ void ED_keymap_mask(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MASK_OT_shape_key_insert", IKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MASK_OT_shape_key_clear", IKEY, KM_PRESS, KM_ALT, 0);
+ /* for image editor only */
+ WM_keymap_add_item(keymap, "UV_OT_cursor_set", ACTIONMOUSE, KM_PRESS, 0, 0);
transform_keymap_for_space(keyconf, keymap, SPACE_CLIP);
}
diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h
index 70dafc963ec..b4ff4bc5b31 100644
--- a/source/blender/editors/mask/mask_intern.h
+++ b/source/blender/editors/mask/mask_intern.h
@@ -105,6 +105,9 @@ void ED_mask_mouse_pos(const struct bContext *C, struct wmEvent *event, float co
void ED_mask_point_pos(const struct bContext *C, float x, float y, float *xr, float *yr);
void ED_mask_point_pos__reverse(const struct bContext *C, float x, float y, float *xr, float *yr);
+void ED_mask_get_zoom(const bContext *C, float *zoomx, float *zoomy);
+void ED_mask_get_size(const bContext *C, float *zoomx, float *zoomy);
+
/* mask_shapekey.c */
void MASK_OT_shape_key_insert(struct wmOperatorType *ot);
void MASK_OT_shape_key_clear(struct wmOperatorType *ot);
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index c7f917548ce..565beaf34ef 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -592,10 +592,9 @@ static int circle_select_exec(bContext *C, wmOperator *op)
mode = RNA_int_get(op->ptr, "gesture_mode");
- /* TODO - make generic! - this is SpaceClip only! */
/* compute ellipse and position in unified coordinates */
- ED_space_clip_get_size(C, &width, &height);
- ED_space_clip_get_zoom(C, &zoomx, &zoomy);
+ ED_mask_size(C, &width, &height);
+ ED_mask_zoom(C, &zoomx, &zoomy);
width = height = MAX2(width, height);
ellipse[0] = width * zoomx / radius;
@@ -639,7 +638,6 @@ static int circle_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
-/* MASKTODO - image space */
void MASK_OT_select_circle(wmOperatorType *ot)
{
/* identifiers */
diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c
index f80210fe4d7..927f65f239b 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -266,6 +266,34 @@ void ED_image_mouse_pos(SpaceImage *sima, ARegion *ar, wmEvent *event, float co[
co[1] = ((event->mval[1] - sy) / zoomy) / height;
}
+void ED_image_point_pos(SpaceImage *sima, ARegion *ar, float x, float y, float *xr, float *yr)
+{
+ int sx, sy, width, height;
+ float zoomx, zoomy;
+
+ ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
+ ED_space_image_get_size(sima, &width, &height);
+
+ UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
+
+ *xr = ((x - sx) / zoomx) / width;
+ *yr = ((y - sy) / zoomy) / height;
+}
+
+void ED_image_point_pos__reverse(SpaceImage *sima, ARegion *ar, const float co[2], float r_co[2])
+{
+ float zoomx, zoomy;
+ int width, height;
+ int sx, sy;
+
+ UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
+ ED_space_image_get_size(sima, &width, &height);
+ ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
+
+ r_co[0] = (co[0] * width * zoomx) + (float)sx;
+ r_co[1] = (co[1] * height * zoomy) + (float)sy;
+}
+
int ED_space_image_show_render(SpaceImage *sima)
{
return (sima->image && ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE));
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 3c9c46c1c75..55e22a999bc 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -585,6 +585,7 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
SpaceImage *sima = CTX_wm_space_image(C);
Object *obact = CTX_data_active_object(C);
Object *obedit = CTX_data_edit_object(C);
+ Mask *mask = NULL;
Scene *scene = CTX_data_scene(C);
View2D *v2d = &ar->v2d;
//View2DScrollers *scrollers;
@@ -611,6 +612,15 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
draw_uvedit_main(sima, ar, scene, obedit, obact);
+ /* check for mask (delay draw) */
+ if (obedit) {
+ /* pass */
+ }
+ else if (sima->mode == SI_MODE_MASK) {
+ mask = ED_space_image_get_mask(sima);
+ draw_image_cursor(sima, ar);
+ }
+
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
/* Grease Pencil too (in addition to UV's) */
@@ -624,17 +634,16 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
/* draw Grease Pencil - screen space only */
draw_image_grease_pencil((bContext *)C, 0);
- {
- Mask *mask = ED_space_image_get_mask(sima);
- if (mask) {
- int width, height;
- ED_mask_size(C, &width, &height);
- ED_mask_draw_region(mask, ar,
- sima->mask_info.draw_flag, sima->mask_info.draw_type,
- width, height,
- TRUE, FALSE,
- NULL, C);
- }
+ if (mask) {
+ int width, height;
+ ED_mask_size(C, &width, &height);
+ ED_mask_draw_region(mask, ar,
+ sima->mask_info.draw_flag, sima->mask_info.draw_type,
+ width, height,
+ TRUE, FALSE,
+ NULL, C);
+
+ draw_image_cursor(sima, ar);
}
/* scrollers? */
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 55dfbc8a0df..1f78bc6bddf 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -63,7 +63,7 @@
#include "uvedit_intern.h"
-static void drawcursor_sima(SpaceImage *sima, ARegion *ar)
+void draw_image_cursor(SpaceImage *sima, ARegion *ar)
{
float zoomx, zoomy, w, h;
int width, height;
@@ -889,7 +889,7 @@ void draw_uvedit_main(SpaceImage *sima, ARegion *ar, Scene *scene, Object *obedi
draw_uvs_texpaint(sima, scene, obact);
if (show_uvedit && !(toolsettings->use_uv_sculpt))
- drawcursor_sima(sima, ar);
+ draw_image_cursor(sima, ar);
}
}