Revision: 18356
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18356
Author:   theeth
Date:     2009-01-06 03:27:07 +0100 (Tue, 06 Jan 2009)

Log Message:
-----------
2.5

Transform Numeric Input: Inverse

Press "/" to toggle inverse value (1/N).
Makes it easy to scale down by specific values (you can just type S / 7 to 
scale down by 7, for example).
This doesn't give full fraction input (X/Y).

Suggestion from a talk with Gwenouille on ba.org

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/transform/transform.h
    
branches/blender2.5/blender/source/blender/editors/transform/transform_numinput.c

Modified: 
branches/blender2.5/blender/source/blender/editors/transform/transform.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform.h    
2009-01-06 01:37:12 UTC (rev 18355)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform.h    
2009-01-06 02:27:07 UTC (rev 18356)
@@ -62,8 +62,9 @@
     short  idx;
     short  idx_max;
     short  flag;        /* Different flags to indicate different behaviors     
                           */
-    float  val[3];       /* Direct value of the input                          
                            */
-    int  ctrl[3];      /* Control to indicate what to do with the numbers that 
are typed                 */
+    char   inv[3];      /* If the value is inverted or not                     
                           */
+    float  val[3];      /* Direct value of the input                           
                           */
+    int    ctrl[3];     /* Control to indicate what to do with the numbers 
that are typed                 */
 } NumInput ;
 
 /*

Modified: 
branches/blender2.5/blender/source/blender/editors/transform/transform_numinput.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/transform/transform_numinput.c
   2009-01-06 01:37:12 UTC (rev 18355)
+++ 
branches/blender2.5/blender/source/blender/editors/transform/transform_numinput.c
   2009-01-06 02:27:07 UTC (rev 18356)
@@ -46,6 +46,9 @@
        n->flag         =
        n->idx          =
        n->idx_max      =
+       n->inv[0]   =
+       n->inv[1]   =
+       n->inv[2]   =
        n->ctrl[0]      = 
        n->ctrl[1]      = 
        n->ctrl[2]      = 0;
@@ -58,6 +61,7 @@
 void outputNumInput(NumInput *n, char *str)
 {
        char cur;
+       char inv[] = "1/";
        short i, j;
 
        for (j=0; j<=n->idx_max; j++) {
@@ -72,35 +76,40 @@
                else
                        cur = '|';
 
+               if (n->inv[i])
+                       inv[0] = '1';
+               else
+                       inv[0] = 0;
+
                if( n->val[i] > 1e10 || n->val[i] < -1e10 )
-                       sprintf(&str[j*20], "%.4e%c", n->val[i], cur);
+                       sprintf(&str[j*20], "%s%.4e%c", inv, n->val[i], cur);
                else
                        switch (n->ctrl[i]) {
                        case 0:
-                               sprintf(&str[j*20], "NONE%c", cur);
+                               sprintf(&str[j*20], "%sNONE%c", inv, cur);
                                break;
                        case 1:
                        case -1:
-                               sprintf(&str[j*20], "%.0f%c", n->val[i], cur);
+                               sprintf(&str[j*20], "%s%.0f%c", inv, n->val[i], 
cur);
                                break;
                        case 10:
                        case -10:
-                               sprintf(&str[j*20], "%.f.%c", n->val[i], cur);
+                               sprintf(&str[j*20], "%s%.f.%c", inv, n->val[i], 
cur);
                                break;
                        case 100:
                        case -100:
-                               sprintf(&str[j*20], "%.1f%c", n->val[i], cur);
+                               sprintf(&str[j*20], "%s%.1f%c", inv, n->val[i], 
cur);
                                break;
                        case 1000:
                        case -1000:
-                               sprintf(&str[j*20], "%.2f%c", n->val[i], cur);
+                               sprintf(&str[j*20], "%s%.2f%c", inv, n->val[i], 
cur);
                                break;
                        case 10000:
                        case -10000:
-                               sprintf(&str[j*20], "%.3f%c", n->val[i], cur);
+                               sprintf(&str[j*20], "%s%.3f%c", inv, n->val[i], 
cur);
                                break;
                        default:
-                               sprintf(&str[j*20], "%.4e%c", n->val[i], cur);
+                               sprintf(&str[j*20], "%s%.4e%c", inv, n->val[i], 
cur);
                        }
        }
 }
@@ -139,7 +148,14 @@
                                vec[j] = 0.0001f;
                        }
                        else {
-                               vec[j] = val[i];
+                               if (n->inv[i])
+                               {
+                                       vec[j] = 1.0f / val[i];
+                               }
+                               else
+                               {
+                                       vec[j] = val[i];
+                               }
                        }
                }
        }
@@ -159,10 +175,14 @@
                        n->ctrl[0]              = 
                                n->ctrl[1]      = 
                                n->ctrl[2]      = 0;
+                       n->inv[0]               = 
+                               n->inv[1]       = 
+                               n->inv[2]       = 0;
                }
                else {
                        n->val[idx] = 0.0f;
                        n->ctrl[idx] = 0;
+                       n->inv[idx] = 0;
                }
                break;
        case PERIODKEY:
@@ -194,6 +214,10 @@
                else
                        n->ctrl[idx] = -1;
                break;
+       case PADSLASHKEY:
+       case SLASHKEY:
+               n->inv[idx] = !n->inv[idx];
+               break;
        case TABKEY:
                idx++;
                if (idx > idx_max)


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to