dont use tface hide or select anymore, since maintaining 2 sets of hide/select data...
[blender.git] / source / blender / src / drawimage.c
index fc4d528e45e798bf0c76e2264fa7813dca143d1b..188f48bcdca1adb96d2255590b02a4b291b20eb7 100644 (file)
@@ -290,6 +290,7 @@ ImBuf *imagewindow_get_ibuf(SpaceImage *sima)
 void image_changed(SpaceImage *sima, int dotile)
 {
        MTFace *tface;
+       MFace *mface;
        Mesh *me;
        int a;
 
@@ -312,9 +313,10 @@ void image_changed(SpaceImage *sima, int dotile)
                        if(me && me->mtface) {
                                
                                tface= me->mtface;
+                               mface = me->mface;
                                a= me->totface;
                                while(a--) {
-                                       if(tface->flag & TF_SELECT) {
+                                       if(mface->flag & ME_FACE_SEL) {
                                                
                                                if(dotile==2) {
                                                        tface->mode &= ~TF_TILES;
@@ -335,6 +337,7 @@ void image_changed(SpaceImage *sima, int dotile)
                                                }
                                        }
                                        tface++;
+                                       mface++;
                                }
 
                                object_uvs_changed(OBACT);
@@ -426,7 +429,7 @@ void draw_tfaces(void)
 
                                        glColor3ub(112, 112, 112);
                                        while(a--) {
-                                               if(!(tface->flag & TF_HIDE) && (tface->flag & TF_SELECT)) {
+                                               if(!(mface->flag & ME_HIDE) && (mface->flag & ME_FACE_SEL)) {
                                                        glBegin(GL_LINE_LOOP);
                                                        glVertex2fv(tface->uv[0]);
                                                        glVertex2fv(tface->uv[1]);
@@ -453,7 +456,7 @@ void draw_tfaces(void)
                                mface= me->mface;
                                a= me->totface;                 
                                while(a--) {
-                                       if(tface->flag & TF_SELECT) {
+                                       if(mface->flag & ME_FACE_SEL) {
                                                if(!(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) &&
                                                   (!mface->v4 || tface->flag & TF_SEL4))
                                                        glColor4ubv((GLubyte *)col2);
@@ -478,7 +481,7 @@ void draw_tfaces(void)
                        mface= me->mface;
                        a= me->totface;
                        while(a--) {
-                               if(tface->flag & TF_SELECT) {
+                               if(mface->flag & ME_FACE_SEL) {
                                        if(tface->flag & TF_ACTIVE){
                                                activetface= tface; 
                                                activemface= mface; 
@@ -565,7 +568,7 @@ void draw_tfaces(void)
                        mface= me->mface;
                        a= me->totface;
                        while(a--) {
-                               if(tface->flag & TF_SELECT) {
+                               if(mface->flag & ME_FACE_SEL) {
                                        
                                        if(tface->flag & TF_SEL1); else bglVertex2fv(tface->uv[0]);
                                        if(tface->flag & TF_SEL2); else bglVertex2fv(tface->uv[1]);
@@ -589,7 +592,7 @@ void draw_tfaces(void)
                        mface= me->mface;
                        a= me->totface;
                        while(a--) {
-                               if(tface->flag & TF_SELECT) {
+                               if(mface->flag & ME_FACE_SEL) {
                                        
                                        if(tface->unwrap & TF_PIN1) bglVertex2fv(tface->uv[0]);
                                        if(tface->unwrap & TF_PIN2) bglVertex2fv(tface->uv[1]);
@@ -612,7 +615,7 @@ void draw_tfaces(void)
                        mface= me->mface;
                        a= me->totface;
                        while(a--) {
-                               if(tface->flag & TF_SELECT) {
+                               if(mface->flag & ME_FACE_SEL) {
                                        
                                        if(tface->flag & TF_SEL1) bglVertex2fv(tface->uv[0]);
                                        if(tface->flag & TF_SEL2) bglVertex2fv(tface->uv[1]);
@@ -763,7 +766,7 @@ void image_editvertex_buts(uiBlock *block)
                MFace *mf= &((MFace*) me->mface)[i];
                MTFace *tf= &((MTFace*) me->mtface)[i];
                
-               if (!(tf->flag & TF_SELECT))
+               if (!(mf->flag & ME_FACE_SEL))
                        continue;
                
                if (tf->flag & TF_SEL1) {
@@ -835,7 +838,7 @@ void image_editvertex_buts(uiBlock *block)
                        MFace *mf= &((MFace*) me->mface)[i];
                        MTFace *tf= &((MTFace*) me->mtface)[i];
                
-                       if (!(tf->flag & TF_SELECT))
+                       if (!(mf->flag & ME_FACE_SEL))
                                continue;
                
                        if (tf->flag & TF_SEL1) {
@@ -1120,6 +1123,9 @@ static int image_curves_active(ScrArea *sa)
        return 0;
 }
 
+/* 0: disable preview 
+   otherwise refresh preview
+*/
 void image_preview_event(int event)
 {
        int exec= 0;
@@ -1129,24 +1135,35 @@ void image_preview_event(int event)
                G.scene->r.scemode &= ~R_COMP_CROP;
                exec= 1;
        }
-       else if(event==2 || (G.scene->r.scemode & R_COMP_CROP)==0) {
+       else {
                if(image_preview_active(curarea, NULL, NULL)) {
                        G.scene->r.scemode |= R_COMP_CROP;
                        exec= 1;
                }
+               else
+                       G.scene->r.scemode &= ~R_COMP_CROP;
        }
        
-       if(exec) {
-               ScrArea *sa;
+       if(exec && G.scene->nodetree) {
+               /* should work when no node editor in screen..., so we execute right away */
                
                ntreeCompositTagGenerators(G.scene->nodetree);
-       
-               for(sa=G.curscreen->areabase.first; sa; sa= sa->next) {
-                       if(sa->spacetype==SPACE_NODE) {
-                               addqueue(sa->win, UI_BUT_EVENT, B_NODE_TREE_EXEC);
-                               break;
-                       }
-               }
+
+               G.afbreek= 0;
+               G.scene->nodetree->timecursor= set_timecursor;
+               G.scene->nodetree->test_break= blender_test_break;
+               
+               BIF_store_spare();
+               
+               ntreeCompositExecTree(G.scene->nodetree, &G.scene->r, 1);       /* 1 is do_previews */
+               
+               G.scene->nodetree->timecursor= NULL;
+               G.scene->nodetree->test_break= NULL;
+               
+               scrarea_do_windraw(curarea);
+               waitcursor(0);
+               
+               allqueue(REDRAWNODE, 1);
        }       
 }
 
@@ -1165,11 +1182,7 @@ static void preview_cb(struct ScrArea *sa, struct uiBlock *block)
                winy*= (G.scene->r.border.ymax - G.scene->r.border.ymin);
        }
        
-       /* while dragging we don't update the rects */
-       if(block->panel->flag & PNL_SELECT)
-               return;
-       if(get_mbut() & M_MOUSE)
-               return;
+       /* while dragging we need to update the rects, otherwise it doesn't end with correct one */
 
        BLI_init_rctf(&dispf, 15.0f, (block->maxx - block->minx)-15.0f, 15.0f, (block->maxy - block->miny)-15.0f);
        ui_graphics_to_window_rct(sa->win, &dispf, disprect);
@@ -1196,8 +1209,7 @@ static void preview_cb(struct ScrArea *sa, struct uiBlock *block)
        CLAMP(disprect->ymin, 0, winy);
        CLAMP(disprect->ymax, 0, winy);
 //     printf("drawrct %d %d %d %d\n", disprect->xmin, disprect->ymin,disprect->xmax, disprect->ymax);
-       
-       image_preview_event(1);
+
 }
 
 static int is_preview_allowed(ScrArea *cur)
@@ -1963,7 +1975,7 @@ void image_home(void)
        scrarea_queue_winredraw(curarea);
 }
 
-void image_viewcentre(void)
+void image_viewcenter(void)
 {
        ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
        float size, min[2], max[2], d[2], xim=256.0f, yim=256.0f;