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-25 14:39:54 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-07-25 14:39:54 +0400
commitc3a8894f57fc7560e54a344a4a16ed5b3886a688 (patch)
treed6e97a61a1a7994dfdf24215a8284453006e8d53
parent93f359604ce38166a188382b62ac1ba160790bc6 (diff)
wip mask/image commit, mostly internal function & added some TODO's
-rw-r--r--source/blender/editors/include/ED_clip.h2
-rw-r--r--source/blender/editors/include/ED_image.h8
-rw-r--r--source/blender/editors/mask/mask_edit.c153
-rw-r--r--source/blender/editors/mask/mask_ops.c30
-rw-r--r--source/blender/editors/mask/mask_select.c2
-rw-r--r--source/blender/editors/space_image/image_edit.c52
6 files changed, 205 insertions, 42 deletions
diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h
index 2670fb5b042..8949eb8442d 100644
--- a/source/blender/editors/include/ED_clip.h
+++ b/source/blender/editors/include/ED_clip.h
@@ -65,7 +65,7 @@ struct ImBuf *ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2]
void ED_clip_update_frame(const struct Main *mainp, int cfra);
int ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, int fit);
-void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[2]);
+void ED_clip_point_undistorted_pos(struct SpaceClip *sc, const float co[2], float r_co[2]);
void ED_clip_point_stable_pos(const struct bContext *C, float x, float y, float *xr, float *yr);
void ED_clip_point_stable_pos__reverse(const struct bContext *C, const float co[2], float r_co[2]);
void ED_clip_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]);
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index 915d93c7430..c07d6e699a8 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -42,7 +42,9 @@ struct ARegion;
/* image_edit.c, exported for transform */
struct Image *ED_space_image(struct SpaceImage *sima);
-void ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
+void ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
+struct Mask *ED_space_image_get_mask(struct SpaceImage *sima);
+void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask);
struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **lock_r);
void ED_space_image_release_buffer(struct SpaceImage *sima, void *lock);
@@ -65,6 +67,10 @@ int ED_space_image_show_paint(struct SpaceImage *sima);
int ED_space_image_show_uvedit(struct SpaceImage *sima, struct Object *obedit);
int ED_space_image_show_uvshadow(struct SpaceImage *sima, struct Object *obedit);
+int ED_space_image_check_show_maskedit(struct SpaceImage *sima);
+int ED_space_image_maskedit_poll(struct bContext *C);
+int ED_space_image_maskedit_mask_poll(struct bContext *C);
+
/* UI level image (texture) updating... render calls own stuff (too) */
void ED_image_update_frame(const struct Main *mainp, int cfra);
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c
index a739d88dbd4..5837a8eaa83 100644
--- a/source/blender/editors/mask/mask_edit.c
+++ b/source/blender/editors/mask/mask_edit.c
@@ -63,6 +63,8 @@ int ED_maskedit_poll(bContext *C)
return ED_space_clip_maskedit_poll(C);
case SPACE_SEQ:
return ED_space_sequencer_maskedit_poll(C);
+ case SPACE_IMAGE:
+ return ED_space_image_maskedit_poll(C);
}
}
return FALSE;
@@ -77,6 +79,8 @@ int ED_maskedit_mask_poll(bContext *C)
return ED_space_clip_maskedit_mask_poll(C);
case SPACE_SEQ:
return ED_space_sequencer_maskedit_mask_poll(C);
+ case SPACE_IMAGE:
+ return ED_space_sequencer_maskedit_mask_poll(C);
}
}
return FALSE;
@@ -86,14 +90,31 @@ int ED_maskedit_mask_poll(bContext *C)
void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2])
{
- SpaceClip *sc = CTX_wm_space_clip(C);
-
- if (sc) {
- ED_clip_mouse_pos(C, event, co);
- BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
+ 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);
+ BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
+ break;
+ }
+ case SPACE_SEQ:
+ zero_v2(co); /* MASKTODO */
+ break;
+ case SPACE_IMAGE:
+ zero_v2(co); /* MASKTODO */
+ break;
+ default:
+ /* possible other spaces from which mask editing is available */
+ BLI_assert(0);
+ zero_v2(co);
+ break;
+ }
}
else {
- /* possible other spaces from which mask editing is available */
+ BLI_assert(0);
zero_v2(co);
}
}
@@ -102,15 +123,33 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2])
* output: xr/yr - mask point space */
void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr)
{
- SpaceClip *sc = CTX_wm_space_clip(C);
+ ScrArea *sa = CTX_wm_area(C);
float co[2];
- if (sc) {
- ED_clip_point_stable_pos(C, x, y, &co[0], &co[1]);
- BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
+ if (sa) {
+ switch (sa->spacetype) {
+ case SPACE_CLIP:
+ {
+ SpaceClip *sc = sa->spacedata.first;
+ ED_clip_point_stable_pos(C, x, y, &co[0], &co[1]);
+ BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
+ break;
+ }
+ case SPACE_SEQ:
+ zero_v2(co); /* MASKTODO */
+ break;
+ case SPACE_IMAGE:
+ zero_v2(co); /* MASKTODO */
+ break;
+ default:
+ /* possible other spaces from which mask editing is available */
+ BLI_assert(0);
+ zero_v2(co);
+ break;
+ }
}
else {
- /* possible other spaces from which mask editing is available */
+ BLI_assert(0);
zero_v2(co);
}
@@ -120,19 +159,35 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr
void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, float *yr)
{
- SpaceClip *sc = CTX_wm_space_clip(C);
- ARegion *ar = CTX_wm_region(C);
-
+ ScrArea *sa = CTX_wm_area(C);
float co[2];
- if (sc && ar) {
- 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);
+ if (sa) {
+ switch (sa->spacetype) {
+ case SPACE_CLIP:
+ {
+ SpaceClip *sc = sa->spacedata.first;
+ 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);
+ break;
+ }
+ case SPACE_SEQ:
+ zero_v2(co); /* MASKTODO */
+ break;
+ case SPACE_IMAGE:
+ zero_v2(co); /* MASKTODO */
+ break;
+ default:
+ /* possible other spaces from which mask editing is available */
+ BLI_assert(0);
+ zero_v2(co);
+ break;
+ }
}
else {
- /* possible other spaces from which mask editing is available */
+ BLI_assert(0);
zero_v2(co);
}
@@ -148,40 +203,68 @@ void ED_mask_size(const bContext *C, int *width, int *height)
case SPACE_CLIP:
{
ED_space_clip_get_size(C, width, height);
- return;
+ 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;
- return;
+ break;
}
case SPACE_IMAGE:
{
SpaceImage *sima = sa->spacedata.first;
ED_space_image_size(sima, width, height);
- return;
+ break;
}
+ default:
+ /* possible other spaces from which mask editing is available */
+ BLI_assert(0);
+ *width = 0;
+ *height = 0;
+ break;
}
}
-
- /* possible other spaces from which mask editing is available */
- *width = 0;
- *height = 0;
+ else {
+ BLI_assert(0);
+ *width = 0;
+ *height = 0;
+ }
}
void ED_mask_aspect(const bContext *C, float *aspx, float *aspy)
{
- SpaceClip *sc = CTX_wm_space_clip(C);
-
- if (sc) {
- ED_space_clip_get_aspect(sc, aspx, aspy);
+ ScrArea *sa = CTX_wm_area(C);
+ if (sa && sa->spacedata.first) {
+ switch (sa->spacetype) {
+ case SPACE_CLIP:
+ {
+ SpaceClip *sc = sa->spacedata.first;
+ ED_space_clip_get_aspect(sc, aspx, aspy);
+ break;
+ }
+ case SPACE_SEQ:
+ {
+ *aspx = *aspy = 1.0f; /* MASKTODO - render aspect? */
+ break;
+ }
+ case SPACE_IMAGE:
+ {
+ // SpaceImage *sima = sa->spacedata.first;
+ *aspx = *aspy = 1.0f; /* MASKTODO - image aspect? */
+ break;
+ }
+ default:
+ /* possible other spaces from which mask editing is available */
+ BLI_assert(0);
+ *aspx = *aspy = 1.0f;
+ break;
+ }
}
else {
- /* possible other spaces from which mask editing is available */
- *aspx = 1.0f;
- *aspy = 1.0f;
+ BLI_assert(0);
+ *aspx = *aspy = 1.0f;
}
}
@@ -189,6 +272,8 @@ void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley)
{
SpaceClip *sc = CTX_wm_space_clip(C);
+ /* MASKTODO */
+
if (sc) {
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 c8246fd53bc..99c46c38bfc 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -45,10 +45,11 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "ED_screen.h"
-#include "ED_mask.h"
#include "ED_clip.h"
+#include "ED_image.h"
#include "ED_keyframing.h"
+#include "ED_mask.h"
+#include "ED_screen.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -255,7 +256,7 @@ int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[
static int mask_new_exec(bContext *C, wmOperator *op)
{
- SpaceClip *sc = CTX_wm_space_clip(C);
+ ScrArea *sa = CTX_wm_area(C);
Mask *mask;
char name[MAX_ID_NAME - 2];
@@ -263,8 +264,27 @@ static int mask_new_exec(bContext *C, wmOperator *op)
mask = BKE_mask_new(name);
- if (sc)
- ED_space_clip_set_mask(C, sc, mask);
+ if (sa && sa->spacedata.first) {
+ switch (sa->spacetype) {
+ case SPACE_CLIP:
+ {
+ SpaceClip *sc = sa->spacedata.first;
+ ED_space_clip_set_mask(C, sc, mask);
+ break;
+ }
+ case SPACE_SEQ:
+ {
+ /* do nothing */
+ break;
+ }
+ case SPACE_IMAGE:
+ {
+ SpaceImage *sima = sa->spacedata.first;
+ ED_space_image_set_mask(C, sima, mask);
+ break;
+ }
+ }
+ }
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index a2a7a07d089..c7f917548ce 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -539,6 +539,7 @@ static int clip_lasso_select_exec(bContext *C, wmOperator *op)
return OPERATOR_PASS_THROUGH;
}
+/* MASKTODO - image space */
void MASK_OT_select_lasso(wmOperatorType *ot)
{
/* identifiers */
@@ -638,6 +639,7 @@ 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 725c76d8bb6..1c488fe4ac7 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -28,13 +28,15 @@
* \ingroup spimage
*/
+#include "DNA_mask_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_math.h"
-#include "BKE_image.h"
+#include "BKE_context.h"
#include "BKE_global.h"
+#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_tessmesh.h"
@@ -79,6 +81,20 @@ void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *i
WM_main_add_notifier(NC_SPACE | ND_SPACE_IMAGE, NULL);
}
+Mask *ED_space_image_get_mask(SpaceImage *sima)
+{
+ return sima->mask_info.mask;
+}
+
+void ED_space_image_set_mask(bContext *C, SpaceImage *sima, Mask *mask)
+{
+ sima->mask_info.mask = mask;
+
+ if (C) {
+ WM_event_add_notifier(C, NC_MASK | NA_SELECTED, mask);
+ }
+}
+
ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r)
{
ImBuf *ibuf;
@@ -279,6 +295,40 @@ int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit)
return 0;
}
+/* matches clip function */
+int ED_space_image_check_show_maskedit(SpaceImage *sima)
+{
+ /* MASKTODO - whem we have a mask edit option */
+ (void)sima;
+ return TRUE;
+}
+
+int ED_space_image_maskedit_poll(bContext *C)
+{
+ SpaceImage *sima = CTX_wm_space_image(C);
+
+ if (sima && sima->image) {
+ return ED_space_image_check_show_maskedit(sima);
+ }
+
+ return FALSE;
+}
+
+int ED_space_image_maskedit_mask_poll(bContext *C)
+{
+ if (ED_space_image_maskedit_poll(C)) {
+ Image *ima = CTX_data_edit_image(C);
+
+ if (ima) {
+ SpaceImage *sima = CTX_wm_space_image(C);
+
+ return sima->mask_info.mask != NULL;
+ }
+ }
+
+ return FALSE;
+}
+
/******************** TODO ********************/
/* XXX notifier? */