fullscreen mask editing now works in the image space over a viewer node.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 3 Aug 2012 20:56:04 +0000 (20:56 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 3 Aug 2012 20:56:04 +0000 (20:56 +0000)
release/scripts/startup/bl_ui/space_image.py
source/blender/editors/include/ED_node.h
source/blender/editors/space_image/space_image.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_intern.h
source/blender/editors/space_node/space_node.c
source/blender/editors/transform/transform_conversions.c

index 7752eb9771af520dbe2289b1a60460781237d1b0..af39ce3437a8af8b2b931036018661fdc9f5788d 100644 (file)
@@ -430,7 +430,7 @@ class IMAGE_HT_header(Header):
             if ima.type == 'COMPOSITE' and ima.source in {'MOVIE', 'SEQUENCE'}:
                 row.operator("image.play_composite", icon='PLAY')
 
-        if show_uvedit or mode == 'PAINT':
+        if show_uvedit or show_maskedit or mode == 'PAINT':
             layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED')
 
 
index ca468a15771fca84ff43d5f36944b87103e2d18f..b6a1fd0f979d851fd8cbc783be738247367c3a18 100644 (file)
@@ -41,6 +41,7 @@ struct bNodeTree;
 struct bNode;
 struct bNodeTree;
 struct ScrArea;
+struct Scene;
 struct View2D;
 
 typedef enum {
@@ -73,6 +74,8 @@ int  ED_node_select_check(ListBase *lb);
 void ED_node_post_apply_transform(struct bContext *C, struct bNodeTree *ntree);
 void ED_node_set_active(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node);
 
+void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, struct Scene *scene_owner);
+
 /* node ops.c */
 void ED_operatormacros_node(void);
 
index f97813d3dd3d4fa6735faabf2d5e41ccb6a1e3b6..0007ef2ef7710c46ec8530d1aab3ac931c6538ab 100644 (file)
 #include "BKE_screen.h"
 #include "BKE_tessmesh.h"
 #include "BKE_sequencer.h"
+#include "BKE_node.h"
 
 #include "IMB_imbuf_types.h"
 
 #include "ED_image.h"
 #include "ED_mask.h"
 #include "ED_mesh.h"
+#include "ED_node.h"
 #include "ED_space_api.h"
 #include "ED_screen.h"
 #include "ED_uvedit.h"
@@ -341,11 +343,14 @@ static void image_dropboxes(void)
        WM_dropbox_add(lb, "IMAGE_OT_open", image_drop_poll, image_drop_copy);
 }
 
-
-static void image_refresh(const bContext *C, ScrArea *UNUSED(sa))
+/**
+ * \note take care not to get into feedback loop here,
+ *       calling composite job causes viewer to refresh.
+ */
+static void image_refresh(const bContext *C, ScrArea *sa)
 {
        Scene *scene = CTX_data_scene(C);
-       SpaceImage *sima = CTX_wm_space_image(C);
+       SpaceImage *sima = sa->spacedata.first;
        Object *obedit = CTX_data_edit_object(C);
        Image *ima;
 
@@ -354,7 +359,17 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa))
        BKE_image_user_check_frame_calc(&sima->iuser, scene->r.cfra, 0);
        
        /* check if we have to set the image from the editmesh */
-       if (ima && (ima->source == IMA_SRC_VIEWER || sima->pin)) ;
+       if (ima && (ima->source == IMA_SRC_VIEWER && sima->mode == SI_MODE_MASK)) {
+               if (sima->lock) {
+                       Mask *mask = ED_space_image_get_mask(sima);
+                       if (mask) {
+                               ED_node_composite_job(C, scene->nodetree, scene);
+                       }
+               }
+       }
+       else if (ima && (ima->source == IMA_SRC_VIEWER || sima->pin)) {
+               /* pass */
+       }
        else if (obedit && obedit->type == OB_MESH) {
                Mesh *me = (Mesh *)obedit->data;
                struct BMEditMesh *em = me->edit_btmesh;
@@ -396,6 +411,9 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa))
 static void image_listener(ScrArea *sa, wmNotifier *wmn)
 {
        SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
+
+       /* grr, prevent feedback loop */
+       const int show_mask = (sima->image && (sima->image->source == IMA_SRC_VIEWER && sima->mode == SI_MODE_MASK));
        
        /* context changes */
        switch (wmn->category) {
@@ -404,15 +422,16 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
                                case ND_FRAME:
                                        image_scopes_tag_refresh(sa);
                                        ED_area_tag_refresh(sa);
-                                       ED_area_tag_redraw(sa);                                 
+                                       ED_area_tag_redraw(sa);
                                        break;
                                case ND_MODE:
                                case ND_RENDER_RESULT:
                                case ND_COMPO_RESULT:
                                        if (ED_space_image_show_render(sima))
                                                image_scopes_tag_refresh(sa);
-                                       ED_area_tag_refresh(sa);
-                                       ED_area_tag_redraw(sa);                                 
+                                       if (!show_mask)
+                                               ED_area_tag_refresh(sa);
+                                       ED_area_tag_redraw(sa);
                                        break;
                        }
                        break;
@@ -436,9 +455,13 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
                        if (sima->mode == SI_MODE_MASK) {
                                switch (wmn->data) {
                                        case ND_SELECT:
+                                               ED_area_tag_redraw(sa);
+                                               break;
                                        case ND_DATA:
                                        case ND_DRAW:
+                                               /* causes node-recalc */
                                                ED_area_tag_redraw(sa);
+                                               ED_area_tag_refresh(sa);
                                                break;
                                }
                                switch (wmn->action) {
@@ -446,7 +469,9 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
                                                ED_area_tag_redraw(sa);
                                                break;
                                        case NA_EDITED:
+                                               /* causes node-recalc */
                                                ED_area_tag_redraw(sa);
+                                               ED_area_tag_refresh(sa);
                                                break;
                                }
                        }
index d32303b27d1eb8f7f1268ec07a9e2b31d5766a48..fe10a52b77d99f0e8685fc1a7e787a653d48e8b3 100644 (file)
@@ -163,26 +163,31 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog
 
 }
 
-void snode_composite_job(const bContext *C, ScrArea *sa)
+/**
+ * \param sa_owner is the owner of the job,
+ * we don't use it for anything else currently so could also be a void pointer,
+ * but for now keep it an 'Scene' for consistency.
+ *
+ * \note only call from spaces `refresh` callbacks, not direct! - use with care.
+ */
+void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene *scene_owner)
 {
-       SpaceNode *snode = sa->spacedata.first;
        wmJob *steve;
        CompoJob *cj;
 
-       steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Compositing", WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS);
+       steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene_owner, "Compositing", WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS);
        cj = MEM_callocN(sizeof(CompoJob), "compo job");
-       
+
        /* customdata for preview thread */
        cj->scene = CTX_data_scene(C);
-       cj->ntree = snode->nodetree;
-       
+       cj->ntree = nodetree;
+
        /* setup job */
        WM_jobs_customdata(steve, cj, compo_freejob);
        WM_jobs_timer(steve, 0.1, NC_SCENE, NC_SCENE | ND_COMPO_RESULT);
        WM_jobs_callbacks(steve, compo_startjob, compo_initjob, compo_updatejob, NULL);
-       
+
        WM_jobs_start(CTX_wm_manager(C), steve);
-       
 }
 
 /* ***************************************** */
index d91c158aaf3f95761a61738a30dfd7fb8df85bfe..16a319248264d238bdf6bc5d55affef9896a5911 100644 (file)
@@ -169,7 +169,7 @@ void snode_notify(bContext *C, SpaceNode *snode);
 void snode_dag_update(bContext *C, SpaceNode *snode);
 void snode_set_context(SpaceNode *snode, Scene *scene);
 void snode_make_group_editable(SpaceNode *snode, bNode *gnode);
-void snode_composite_job(const struct bContext *C, ScrArea *sa);
+
 bNode *node_tree_get_editgroup(bNodeTree *ntree);
 void snode_update(struct SpaceNode *snode, struct bNode *node);
 bNode *editnode_get_active(bNodeTree *ntree);
index af301bce94209f879b265a78ad8cb36304ebe1e9..a79bfe39257e460f7721f4ebc1cc5fb47c5573ba 100644 (file)
@@ -46,7 +46,7 @@
 
 #include "ED_render.h"
 #include "ED_screen.h"
-
+#include "ED_node.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -289,8 +289,9 @@ static void node_area_refresh(const struct bContext *C, ScrArea *sa)
                                        snode->recalc = 0;
                                        node_render_changed_exec((struct bContext *)C, NULL);
                                }
-                               else
-                                       snode_composite_job(C, sa);
+                               else {
+                                       ED_node_composite_job(C, snode->nodetree, scene);
+                               }
                        }
                }
                else if (snode->treetype == NTREE_TEXTURE) {
index 02101b9d02dfd3cd7e1348972e20e919eeca68bc..00cde33e79941ac9b5617b95d62c1543017b48be 100644 (file)
@@ -4983,8 +4983,9 @@ static void special_aftertrans_update__mask(bContext *C, TransInfo *t)
        if (t->scene->nodetree) {
                /* tracks can be used for stabilization nodes,
                 * flush update for such nodes */
-               nodeUpdateID(t->scene->nodetree, &mask->id);
-               WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL);
+               //if (nodeUpdateID(t->scene->nodetree, &mask->id)) {
+                       WM_event_add_notifier(C, NC_MASK | ND_DATA, &mask->id);
+               //}
        }
 
        /* TODO - dont key all masks... */