2D Cursor in UV window
authorCampbell Barton <ideasman42@gmail.com>
Fri, 14 Sep 2007 16:12:17 +0000 (16:12 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 14 Sep 2007 16:12:17 +0000 (16:12 +0000)
this can be placed by the moused and used for transforming around.

still need numeric location input but no room left in the image panel.

source/blender/include/BIF_editsima.h
source/blender/include/transform.h
source/blender/makesdna/DNA_view2d_types.h
source/blender/src/drawimage.c
source/blender/src/editsima.c
source/blender/src/header_image.c
source/blender/src/space.c
source/blender/src/transform_conversions.c
source/blender/src/transform_generics.c

index ba5dfe3149f625128fbc62a9d8081eb37033f8a9..42678c14c8131d24062ac19607c6d74fd9109375 100644 (file)
@@ -49,6 +49,7 @@ int minmax_tface_uv(float *min, float *max);
 void transform_width_height_tface_uv(int *width, int *height);
 void transform_aspect_ratio_tface_uv(float *aspx, float *aspy);
 
+void mouseco_to_cursor_sima(void);
 void borderselect_sima(short whichuvs);
 void mouseco_to_curtile(void);
 void mouse_select_sima(void);
index d343720b7814b211180c9893461ea79073e4eaef..a06356e6531a7262913d2706a851b74009c7f294 100644 (file)
@@ -422,6 +422,7 @@ void calculateCenterBound(TransInfo *t);
 void calculateCenterMedian(TransInfo *t);
 void calculateCenterCursor(TransInfo *t);
 
+void calculateCenterCursor2D(TransInfo *t);
 void calculatePropRatio(TransInfo *t);
 
 void getViewVector(float coord[3], float vec[3]);
index cfd6f682e715adab8fbd5a0c729d198595bd3a6e..3ed82ddc7932c5e7aed9d61cf15d2520b647aab1 100644 (file)
@@ -45,6 +45,10 @@ typedef struct View2D {
        short keepaspect, keepzoom;
        short oldwinx, oldwiny;
        int flag;
+       
+       float cursor[2]; /* only used in the UV view for now*/
+       short around;
+       char pad[6];
 } View2D;
 
 /* v2d->keepzoom */
index 462c7a6d878962e701d2536ff2bf56ffca2003e1..ae11bf1f80014d82b9236aab7dc43a0fbca11cc7 100644 (file)
@@ -367,218 +367,262 @@ void uvco_to_areaco_noclip(float *vec, int *mval)
        mval[1]= y;
 }
 
+static void drawcursor_sima(void)
+{
+       int wi, hi;
+       float w, h;
+       
+       transform_width_height_tface_uv(&wi, &hi);
+       w = (((float)wi)/256.0f)*G.sima->zoom;
+       h = (((float)hi)/256.0f)*G.sima->zoom;
+       
+       cpack(0xFFFFFF);
+       glTranslatef(G.v2d->cursor[0], G.v2d->cursor[1], 0.0f);  
+       fdrawline(-0.05/w, 0, 0, 0.05/h);
+       fdrawline(0, 0.05/h, 0.05/w, 0);
+       fdrawline(0.05/w, 0, 0, -0.05/h);
+       fdrawline(0, -0.05/h, -0.05/w, 0);
+       
+       setlinestyle(4);
+       cpack(0xFF);
+       fdrawline(-0.05/w, 0, 0, 0.05/h);
+       fdrawline(0, 0.05/h, 0.05/w, 0);
+       fdrawline(0.05/w, 0, 0, -0.05/h);
+       fdrawline(0, -0.05/h, -0.05/w, 0);
+       
+       
+       setlinestyle(0);
+       cpack(0x0);
+       fdrawline(-0.020/w, 0, -0.1/w, 0);
+       fdrawline(0.1/w, 0, .020/w, 0);
+       fdrawline(0, -0.020/h, 0, -0.1/h);
+       fdrawline(0, 0.1/h, 0, 0.020/h);
+       
+       setlinestyle(1);
+       cpack(0xFFFFFF);
+       fdrawline(-0.020/w, 0, -0.1/w, 0);
+       fdrawline(0.1/w, 0, .020/w, 0);
+       fdrawline(0, -0.020/h, 0, -0.1/h);
+       fdrawline(0, 0.1/h, 0, 0.020/h);
+       
+       glTranslatef(-G.v2d->cursor[0], -G.v2d->cursor[1], 0.0f);
+       setlinestyle(0);
+}
+
 void draw_tfaces(void)
 {
        MTFace *tface,*activetface = NULL;
        EditMesh *em = G.editMesh;
        EditFace *efa;
        
-       /*int a;*/
        char col1[4], col2[4];
        float pointsize= BIF_GetThemeValuef(TH_VERTEX_SIZE);
        
-       if (G.obedit) {
-               if (CustomData_has_layer(&em->fdata, CD_MTFACE)) {
-                       calc_image_view(G.sima, 'f');   /* float */
-                       myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
-                       glLoadIdentity();
-                       
-                       /* draw shadow mesh */
-                       if ((G.sima->flag & SI_DRAWSHADOW) && (G.obedit==OBACT)) { /* TODO - editmesh */
-                               DerivedMesh *dm;
+       if (!G.obedit || !CustomData_has_layer(&em->fdata, CD_MTFACE))
+               return;
+       
+       
+       calc_image_view(G.sima, 'f');   /* float */
+       myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
+       glLoadIdentity();
+       
+       /* draw shadow mesh */
+       if ((G.sima->flag & SI_DRAWSHADOW) && (G.obedit==OBACT)) { /* TODO - editmesh */
+               DerivedMesh *dm;
 
-                               /* draw final mesh with modifiers applied */
-                               /* should test - editmesh_get_derived_cage_and_final */
-                               dm = editmesh_get_derived_base();
+               /* draw final mesh with modifiers applied */
+               /* should test - editmesh_get_derived_cage_and_final */
+               dm = editmesh_get_derived_base();
 
-                               glColor3ub(112, 112, 112);
-                               if (dm->drawUVEdges) dm->drawUVEdges(dm);
+               glColor3ub(112, 112, 112);
+               if (dm->drawUVEdges) dm->drawUVEdges(dm);
 
-                               dm->release(dm);
-                       }
-                       else if((G.sima->flag & SI_DRAWTOOL) || (G.obedit==OBACT)) {
-                               /* draw mesh without modifiers applied */
-
-                               if (G.obedit) {         
-                                       glColor3ub(112, 112, 112);
-                                       for (efa= em->faces.first; efa; efa= efa->next) {
-                                               /*if(!(mface->flag & ME_HIDE) && (mface->flag & ME_FACE_SEL)) {*/
-                                               if(!(efa->flag & ME_HIDE) && (efa->f & SELECT)) {
-                                                       tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-                                                       glBegin(GL_LINE_LOOP);
-                                                       glVertex2fv(tface->uv[0]);
-                                                       glVertex2fv(tface->uv[1]);
-                                                       glVertex2fv(tface->uv[2]);
-                                                       if(efa->v4) glVertex2fv(tface->uv[3]);
-                                                       glEnd();
-                                               }                                       
-                                       }
-                               }
-                       }
+               dm->release(dm);
+       }
+       else if((G.sima->flag & SI_DRAWTOOL) || (G.obedit==OBACT)) {
+               /* draw mesh without modifiers applied */
 
-                       if((G.sima->flag & SI_DRAWTOOL) || !(G.obedit==OBACT))
-                               return; /* only draw shadow mesh */
-                       
-                       /* draw transparent faces */
-                       if(G.f & G_DRAWFACES) {
-                               BIF_GetThemeColor4ubv(TH_FACE, col1);
-                               BIF_GetThemeColor4ubv(TH_FACE_SELECT, col2);
-                               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-                               glEnable(GL_BLEND);
-                               
-                               for (efa= em->faces.first; efa; efa= efa->next) {
-                                       if(efa->f & SELECT) {
-                                               tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-                                               if(!(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) &&
-                                                  (!efa->v4 || tface->flag & TF_SEL4))
-                                                       glColor4ubv((GLubyte *)col2);
-                                               else
-                                                       glColor4ubv((GLubyte *)col1);
-                                                       
-                                               glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
-                                                       glVertex2fv(tface->uv[0]);
-                                                       glVertex2fv(tface->uv[1]);
-                                                       glVertex2fv(tface->uv[2]);
-                                                       if(efa->v4) glVertex2fv(tface->uv[3]);
-                                               glEnd();
-                                       }
-                               }
-                               glDisable(GL_BLEND);
-                       }
-                       
+               if (G.obedit) {         
+                       glColor3ub(112, 112, 112);
                        for (efa= em->faces.first; efa; efa= efa->next) {
-                               if (efa->f & SELECT) {
+                               /*if(!(mface->flag & ME_HIDE) && (mface->flag & ME_FACE_SEL)) {*/
+                               if(!(efa->flag & ME_HIDE) && (efa->f & SELECT)) {
                                        tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-                                       
-                                       cpack(0x0);
-                                       glBegin(GL_LINE_LOOP);
-                                               glVertex2fv(tface->uv[0]);
-                                               glVertex2fv(tface->uv[1]);
-                                               glVertex2fv(tface->uv[2]);
-                                               if(efa->v4) glVertex2fv(tface->uv[3]);
-                                       glEnd();
-                               
-                                       setlinestyle(2);
-                                       cpack(0xFFFFFF);
-                                       glBegin(GL_LINE_STRIP);
-                                               glVertex2fv(tface->uv[0]);
-                                               glVertex2fv(tface->uv[1]);
-                                       glEnd();
-
-                                       glBegin(GL_LINE_STRIP);
-                                               glVertex2fv(tface->uv[0]);
-                                               if(efa->v4) glVertex2fv(tface->uv[3]);
-                                               else glVertex2fv(tface->uv[2]);
-                                       glEnd();
-       
-                                       glBegin(GL_LINE_STRIP);
-                                               glVertex2fv(tface->uv[1]);
-                                               glVertex2fv(tface->uv[2]);
-                                               if(efa->v4) glVertex2fv(tface->uv[3]);
-                                       glEnd();
-                                       setlinestyle(0);
-                               }
-                       }
-
-                       /* draw active face edges */
-                       /*if (activetface){*/
-                               /* colors: R=u G=v */
-                       activetface = get_active_mtface(&efa, NULL);
-                       if (activetface) {
-                               setlinestyle(2);
-                               tface=activetface; 
-                               /*mface=activemface;*/ 
-
-                               cpack(0x0);
-                               glBegin(GL_LINE_LOOP);
-                               glVertex2fv(tface->uv[0]);
+                                       glBegin(GL_LINE_LOOP);
+                                       glVertex2fv(tface->uv[0]);
                                        glVertex2fv(tface->uv[1]);
                                        glVertex2fv(tface->uv[2]);
                                        if(efa->v4) glVertex2fv(tface->uv[3]);
-                               glEnd();
-                                       
-                               cpack(0xFF00);
-                               glBegin(GL_LINE_STRIP);
-                                       glVertex2fv(tface->uv[0]);
-                                       glVertex2fv(tface->uv[1]);
-                               glEnd();
+                                       glEnd();
+                               }                                       
+                       }
+               }
+       }
 
-                               cpack(0xFF);
-                               glBegin(GL_LINE_STRIP);
+       if((G.sima->flag & SI_DRAWTOOL) || !(G.obedit==OBACT))
+               return; /* only draw shadow mesh */
+       
+       /* draw transparent faces */
+       if(G.f & G_DRAWFACES) {
+               BIF_GetThemeColor4ubv(TH_FACE, col1);
+               BIF_GetThemeColor4ubv(TH_FACE_SELECT, col2);
+               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+               glEnable(GL_BLEND);
+               
+               for (efa= em->faces.first; efa; efa= efa->next) {
+                       if(efa->f & SELECT) {
+                               tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+                               if(!(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) &&
+                                  (!efa->v4 || tface->flag & TF_SEL4))
+                                       glColor4ubv((GLubyte *)col2);
+                               else
+                                       glColor4ubv((GLubyte *)col1);
+                                       
+                               glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
                                        glVertex2fv(tface->uv[0]);
-                                       if(efa->v4) glVertex2fv(tface->uv[3]);
-                                       else glVertex2fv(tface->uv[2]);
-                               glEnd();
-
-                               cpack(0xFFFFFF);
-                               glBegin(GL_LINE_STRIP);
                                        glVertex2fv(tface->uv[1]);
                                        glVertex2fv(tface->uv[2]);
                                        if(efa->v4) glVertex2fv(tface->uv[3]);
                                glEnd();
-                               
-                               setlinestyle(0);
                        }
+               }
+               glDisable(GL_BLEND);
+       }
+       
+       for (efa= em->faces.first; efa; efa= efa->next) {
+               if (efa->f & SELECT) {
+                       tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+                       
+                       cpack(0x0);
+                       glBegin(GL_LINE_LOOP);
+                               glVertex2fv(tface->uv[0]);
+                               glVertex2fv(tface->uv[1]);
+                               glVertex2fv(tface->uv[2]);
+                               if(efa->v4) glVertex2fv(tface->uv[3]);
+                       glEnd();
+               
+                       setlinestyle(2);
+                       cpack(0xFFFFFF);
+                       glBegin(GL_LINE_STRIP);
+                               glVertex2fv(tface->uv[0]);
+                               glVertex2fv(tface->uv[1]);
+                       glEnd();
 
-            /* unselected uv's */
-                       BIF_ThemeColor(TH_VERTEX);
-                       glPointSize(pointsize);
+                       glBegin(GL_LINE_STRIP);
+                               glVertex2fv(tface->uv[0]);
+                               if(efa->v4) glVertex2fv(tface->uv[3]);
+                               else glVertex2fv(tface->uv[2]);
+                       glEnd();
+
+                       glBegin(GL_LINE_STRIP);
+                               glVertex2fv(tface->uv[1]);
+                               glVertex2fv(tface->uv[2]);
+                               if(efa->v4) glVertex2fv(tface->uv[3]);
+                       glEnd();
+                       setlinestyle(0);
+               }
+       }
 
-                       bglBegin(GL_POINTS);
-                       for (efa= em->faces.first; efa; efa= efa->next) {
-                               if (efa->f & SELECT) {
-                                       tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-                                       if(tface->flag & TF_SEL1); else bglVertex2fv(tface->uv[0]);
-                                       if(tface->flag & TF_SEL2); else bglVertex2fv(tface->uv[1]);
-                                       if(tface->flag & TF_SEL3); else bglVertex2fv(tface->uv[2]);
-                                       if(efa->v4) {
-                                               if(tface->flag & TF_SEL4); else bglVertex2fv(tface->uv[3]);
-                                       }
-                               }
-                       }
-                       bglEnd();
+       /* draw active face edges */
+       /*if (activetface){*/
+               /* colors: R=u G=v */
+       activetface = get_active_mtface(&efa, NULL);
+       if (activetface) {
+               setlinestyle(2);
+               tface=activetface; 
+               /*mface=activemface;*/ 
+
+               cpack(0x0);
+               glBegin(GL_LINE_LOOP);
+               glVertex2fv(tface->uv[0]);
+                       glVertex2fv(tface->uv[1]);
+                       glVertex2fv(tface->uv[2]);
+                       if(efa->v4) glVertex2fv(tface->uv[3]);
+               glEnd();
+                       
+               cpack(0xFF00);
+               glBegin(GL_LINE_STRIP);
+                       glVertex2fv(tface->uv[0]);
+                       glVertex2fv(tface->uv[1]);
+               glEnd();
+
+               cpack(0xFF);
+               glBegin(GL_LINE_STRIP);
+                       glVertex2fv(tface->uv[0]);
+                       if(efa->v4) glVertex2fv(tface->uv[3]);
+                       else glVertex2fv(tface->uv[2]);
+               glEnd();
+
+               cpack(0xFFFFFF);
+               glBegin(GL_LINE_STRIP);
+                       glVertex2fv(tface->uv[1]);
+                       glVertex2fv(tface->uv[2]);
+                       if(efa->v4) glVertex2fv(tface->uv[3]);
+               glEnd();
+               
+               setlinestyle(0);
+       }
 
-                       /* pinned uv's */
-                       /* give odd pointsizes odd pin pointsizes */
-               glPointSize(pointsize*2 + (((int)pointsize % 2)? (-1): 0));
-                       cpack(0xFF);
+    /* unselected uv's */
+       BIF_ThemeColor(TH_VERTEX);
+       glPointSize(pointsize);
 
-                       bglBegin(GL_POINTS);
-                       for (efa= em->faces.first; efa; efa= efa->next) {
-                               if (efa->f & SELECT) {
-                                       tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-                                       if(tface->unwrap & TF_PIN1) bglVertex2fv(tface->uv[0]);
-                                       if(tface->unwrap & TF_PIN2) bglVertex2fv(tface->uv[1]);
-                                       if(tface->unwrap & TF_PIN3) bglVertex2fv(tface->uv[2]);
-                                       if(efa->v4) {
-                                               if(tface->unwrap & TF_PIN4) bglVertex2fv(tface->uv[3]);
-                                       }
-                               }
+       bglBegin(GL_POINTS);
+       for (efa= em->faces.first; efa; efa= efa->next) {
+               if (efa->f & SELECT) {
+                       tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+                       if(tface->flag & TF_SEL1); else bglVertex2fv(tface->uv[0]);
+                       if(tface->flag & TF_SEL2); else bglVertex2fv(tface->uv[1]);
+                       if(tface->flag & TF_SEL3); else bglVertex2fv(tface->uv[2]);
+                       if(efa->v4) {
+                               if(tface->flag & TF_SEL4); else bglVertex2fv(tface->uv[3]);
                        }
-                       bglEnd();
+               }
+       }
+       bglEnd();
 
-                       /* selected uv's */
-                       BIF_ThemeColor(TH_VERTEX_SELECT);
-               glPointSize(pointsize);
+       /* pinned uv's */
+       /* give odd pointsizes odd pin pointsizes */
+    glPointSize(pointsize*2 + (((int)pointsize % 2)? (-1): 0));
+       cpack(0xFF);
 
-                       bglBegin(GL_POINTS);
-                       for (efa= em->faces.first; efa; efa= efa->next) {
-                               if (efa->f & SELECT) {
-                                       tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-                                       if(tface->flag & TF_SEL1) bglVertex2fv(tface->uv[0]);
-                                       if(tface->flag & TF_SEL2) bglVertex2fv(tface->uv[1]);
-                                       if(tface->flag & TF_SEL3) bglVertex2fv(tface->uv[2]);
-                                       if(efa->v4) {
-                                               if(tface->flag & TF_SEL4) bglVertex2fv(tface->uv[3]);
-                                       }
-                               }
+       bglBegin(GL_POINTS);
+       for (efa= em->faces.first; efa; efa= efa->next) {
+               if (efa->f & SELECT) {
+                       tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+                       if(tface->unwrap & TF_PIN1) bglVertex2fv(tface->uv[0]);
+                       if(tface->unwrap & TF_PIN2) bglVertex2fv(tface->uv[1]);
+                       if(tface->unwrap & TF_PIN3) bglVertex2fv(tface->uv[2]);
+                       if(efa->v4) {
+                               if(tface->unwrap & TF_PIN4) bglVertex2fv(tface->uv[3]);
                        }
-                       bglEnd();
+               }
+       }
+       bglEnd();
+
+       /* selected uv's */
+       BIF_ThemeColor(TH_VERTEX_SELECT);
+    glPointSize(pointsize);
 
-                       glPointSize(1.0);
+       bglBegin(GL_POINTS);
+       for (efa= em->faces.first; efa; efa= efa->next) {
+               if (efa->f & SELECT) {
+                       tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+                       if(tface->flag & TF_SEL1) bglVertex2fv(tface->uv[0]);
+                       if(tface->flag & TF_SEL2) bglVertex2fv(tface->uv[1]);
+                       if(tface->flag & TF_SEL3) bglVertex2fv(tface->uv[2]);
+                       if(efa->v4) {
+                               if(tface->flag & TF_SEL4) bglVertex2fv(tface->uv[3]);
+                       }
                }
        }
+       bglEnd();
+
+       
+       /* Draw the cursor here, this should be in its own function really but it relys on the previous calls to set the view matrix */
+       drawcursor_sima();
        
+       glPointSize(1.0);
 }
 
 static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty, short endx, short endy)
@@ -1717,8 +1761,9 @@ void drawimagespace(ScrArea *sa, void *spacedata)
                        
                        glPixelZoom(1.0, 1.0);
                        
-                       if(show_viewer==0) 
+                       if(show_viewer==0) 
                                draw_tfaces();
+                       }
                }
 
                glPixelZoom(1.0, 1.0);
index ed5a1c73cb9f1ba86666ab2956b3b21d5f803183..9ec9dc73a4d86bc3a3f4879d4ee2e098f2f23769 100644 (file)
@@ -895,6 +895,15 @@ void mouseco_to_curtile(void)
        }
 }
 
+/* Could be used for other 2D views also */
+void mouseco_to_cursor_sima(void)
+{
+       short mval[2];
+       getmouseco_areawin(mval);
+       areamouseco_to_ipoco(G.v2d, mval, &G.v2d->cursor[0], &G.v2d->cursor[1]);
+       scrarea_queue_winredraw(curarea);
+}
+
 void stitch_uv_tface(int mode)
 {
        MTFace *tf;
index 649ce1438f99350bc099e143318cc7a4c481838f..dc18e8f60a41e816a7b3585290066aa083523f25 100644 (file)
@@ -1083,6 +1083,18 @@ static uiBlock *image_uvsmenu(void *arg_unused)
        return block;
 }
 
+static char *around_pup(void)
+{
+       static char string[512];
+       char *str = string;
+
+       str += sprintf(str, "%s", "Pivot: %t"); 
+       str += sprintf(str, "%s", "|Bounding Box Center %x0"); 
+       str += sprintf(str, "%s", "|Median Point %x3");
+       str += sprintf(str, "%s", "|2D Cursor %x1");
+       return string;
+}
+
 void image_buttons(void)
 {
        Image *ima;
@@ -1158,6 +1170,13 @@ void image_buttons(void)
 
        xco= std_libbuttons(block, xco, 0, 0, NULL, B_SIMABROWSE, ID_IM, 0, (ID *)ima, 0, &(G.sima->imanr), 0, 0, B_IMAGEDELETE, 0, 0);
 
+       /* UV EditMode buttons */
+       if (EM_texFaceCheck()) {
+               xco+=10;
+               uiDefIconTextButS(block, ICONTEXTROW,B_AROUND, ICON_ROTATE, around_pup(), xco,0,XIC+10,YIC, &(G.v2d->around), 0, 3.0, 0, 0, "Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period) ");
+               xco+= XIC+15;
+       }
+       
        if (ima) {
                RenderResult *rr= BKE_image_get_renderresult(ima);
                
index 2845b3340bbcbb651cd144751ef7c723dc41b905..8e8c4f4c40017f48f2b76c59d9b3c4783d5d92cc 100644 (file)
@@ -4788,10 +4788,13 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        else
                                                sima_sample_color();
                                }
-                               else if(EM_texFaceCheck())
-                                       gesture();
-                               else 
+                               else if(EM_texFaceCheck()) {
+                                       if (!gesture()) {
+                                               mouseco_to_cursor_sima();
+                                       }
+                               } else { 
                                        sima_sample_color();
+                               }
                                break;
                        case RIGHTMOUSE:
                                if(EM_texFaceCheck())
@@ -4908,8 +4911,30 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                if(G.qual==0)
                                        image_viewcenter();
                                break;
+                               
+                       case COMMAKEY:
+                               if(G.qual==LR_SHIFTKEY) {
+                                       G.v2d->around= V3D_CENTROID;
+                               } else if(G.qual==0) {
+                                       G.v2d->around= V3D_CENTER;
+                               }
+                               
+                               scrarea_queue_headredraw(curarea);
+                               scrarea_queue_winredraw(curarea);
+                               break;
+                               
+                       case PERIODKEY:
+                               if(G.qual==LR_CTRLKEY) {
+                                       G.v2d->around= V3D_LOCAL;
+                               }       else if(G.qual==0) {
+                                       G.v2d->around= V3D_CURSOR;
+                               }
+                               
+                               scrarea_queue_headredraw(curarea);
+                               scrarea_queue_winredraw(curarea);
+                               break;
                }
-       }       
+       }
 
 
        /* least intrusive nonumpad hack, only for plus/minus */
index 00df69ee631f3bf51aee0f1322460269f06336e3..2fdf68951b85a82fbfbf6e21861e4faee0005112 100644 (file)
@@ -1857,12 +1857,6 @@ static void createTransUVs(TransInfo *t)
        if(is_uv_tface_editing_allowed()==0) return;
 
        /* count */
-       /*
-       tf= me->mtface;
-       mf= me->mface;
-       for(a=me->totface; a>0; a--, tf++, mf++) {
-               if(mf->v3 && mf->flag & ME_FACE_SEL) {
-       */
        for (efa= em->faces.first; efa; efa= efa->next) {
                if (efa->f & SELECT) {
                        tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
@@ -1889,12 +1883,6 @@ static void createTransUVs(TransInfo *t)
 
        td= t->data;
        td2d= t->data2d;
-       /*
-       tf= me->mtface;
-       mf= me->mface;
-       for(a=me->totface; a>0; a--, tf++, mf++) {
-               if(mf->v3 && mf->flag & ME_FACE_SEL) {
-               */
        for (efa= em->faces.first; efa; efa= efa->next) {
                if (efa->f & SELECT) {
                        tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
index 33ced3b292c5a0ed47b91843ca461f5faad1e043..8e92fdda38abea9c42bf33f7da47dbf088b2faf3 100644 (file)
@@ -464,6 +464,8 @@ void initTrans (TransInfo *t)
        if(t->spacetype==SPACE_VIEW3D) {
                if(G.vd->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN;
                t->around = G.vd->around;
+       } else if(t->spacetype==SPACE_IMAGE) {
+               t->around = G.v2d->around;
        }
        else
                t->around = V3D_CENTER;
@@ -654,6 +656,19 @@ void calculateCenterCursor(TransInfo *t)
        calculateCenter2D(t);
 }
 
+void calculateCenterCursor2D(TransInfo *t)
+{
+       float aspx=1.0, aspy=1.0;
+       
+       if(t->spacetype==SPACE_IMAGE) /* only space supported right now but may change */
+               transform_aspect_ratio_tface_uv(&aspx, &aspy);
+       if (G.v2d) {
+               t->center[0] = G.v2d->cursor[0] * aspx; 
+               t->center[1] = G.v2d->cursor[1] * aspy; 
+       }
+       calculateCenter2D(t);
+}
+
 void calculateCenterMedian(TransInfo *t)
 {
        float partial[3] = {0.0f, 0.0f, 0.0f};
@@ -717,7 +732,10 @@ void calculateCenter(TransInfo *t)
                calculateCenterMedian(t);
                break;
        case V3D_CURSOR:
-               calculateCenterCursor(t);
+               if(t->spacetype==SPACE_IMAGE)
+                       calculateCenterCursor2D(t);
+               else
+                       calculateCenterCursor(t);
                break;
        case V3D_LOCAL:
                /* Individual element center uses median center for helpline and such */