[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27030] trunk/blender/source/blender/ editors: Split numinput from transform (reusable in other operator).

Martin Poirier theeth at yahoo.com
Sat Feb 20 21:29:10 CET 2010


Revision: 27030
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27030
Author:   theeth
Date:     2010-02-20 21:29:09 +0100 (Sat, 20 Feb 2010)

Log Message:
-----------
Split numinput from transform (reusable in other operator).

Use in marker move operator.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/anim_markers.c
    trunk/blender/source/blender/editors/transform/transform.c
    trunk/blender/source/blender/editors/transform/transform.h

Added Paths:
-----------
    trunk/blender/source/blender/editors/include/ED_numinput.h
    trunk/blender/source/blender/editors/util/numinput.c

Removed Paths:
-------------
    trunk/blender/source/blender/editors/transform/transform_numinput.c

Modified: trunk/blender/source/blender/editors/animation/anim_markers.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_markers.c	2010-02-20 19:49:04 UTC (rev 27029)
+++ trunk/blender/source/blender/editors/animation/anim_markers.c	2010-02-20 20:29:09 UTC (rev 27030)
@@ -67,6 +67,7 @@
 #include "ED_screen.h"
 #include "ED_types.h"
 #include "ED_util.h"
+#include "ED_numinput.h"
 
 /* ************* Marker API **************** */
 
@@ -407,6 +408,7 @@
 	ListBase *markers;
 	int event_type;		/* store invoke-event, to verify */
 	int *oldframe, evtx, firstx;
+	NumInput num;
 } MarkerMove;
 
 /* copy selection to temp buffer */
@@ -430,6 +432,10 @@
 	mm->slink= CTX_wm_space_data(C);
 	mm->markers= markers;
 	mm->oldframe= MEM_callocN(totmark*sizeof(int), "MarkerMove oldframe");
+
+	initNumInput(&mm->num);
+	mm->num.idx_max = 0; /* one axis */
+	mm->num.flag |= NUM_NO_FRACTION;
 	
 	for (a=0, marker= markers->first; marker; marker= marker->next) {
 		if (marker->flag & SELECT) {
@@ -518,6 +524,8 @@
 			ed_marker_move_cancel(C, op);
 			return OPERATOR_CANCELLED;
 		
+		case RETKEY:
+		case PADENTER:
 		case LEFTMOUSE:
 		case MIDDLEMOUSE:
 		case RIGHTMOUSE:
@@ -529,6 +537,9 @@
 			
 			break;
 		case MOUSEMOVE:
+			if(hasNumInput(&mm->num))
+				break;
+
 			dx= v2d->mask.xmax-v2d->mask.xmin;
 			dx= (v2d->cur.xmax-v2d->cur.xmin)/dx;
 			
@@ -602,6 +613,26 @@
 			}
 	}
 
+	if(evt->val==KM_PRESS) {
+		float vec[3];
+		char str_tx[256];
+
+		if (handleNumInput(&mm->num, evt, 1.0))
+		{
+			applyNumInput(&mm->num, vec);
+			outputNumInput(&mm->num, str_tx);
+
+			RNA_int_set(op->ptr, "frames", vec[0]);
+			ed_marker_move_apply(C, op);
+			// ed_marker_header_update(C, op, str, (int)vec[0]);
+			// strcat(str, str_tx);
+			sprintf(str, "Marker offset %s", str_tx);
+			ED_area_headerprint(CTX_wm_area(C), str);
+
+			WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL);
+		}
+	}
+
 	return OPERATOR_RUNNING_MODAL;
 }
 

Added: trunk/blender/source/blender/editors/include/ED_numinput.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_numinput.h	                        (rev 0)
+++ trunk/blender/source/blender/editors/include/ED_numinput.h	2010-02-20 20:29:09 UTC (rev 27030)
@@ -0,0 +1,56 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef ED_NUMINPUT_H
+#define ED_NUMINPUT_H
+
+
+typedef struct NumInput {
+    short  idx;
+    short  idx_max;
+    short  flag;        /* Different flags to indicate different behaviors                                */
+    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 ;
+
+/* NUMINPUT FLAGS */
+#define NUM_NULL_ONE		2
+#define NUM_NO_NEGATIVE		4
+#define	NUM_NO_ZERO			8
+#define NUM_NO_FRACTION		16
+#define	NUM_AFFECT_ALL		32
+
+/*********************** NumInput ********************************/
+
+void initNumInput(NumInput *n);
+void outputNumInput(NumInput *n, char *str);
+short hasNumInput(NumInput *n);
+void applyNumInput(NumInput *n, float *vec);
+char handleNumInput(NumInput *n, struct wmEvent *event, float increment);
+
+#define NUM_MODAL_INCREMENT_UP   18
+#define NUM_MODAL_INCREMENT_DOWN 19
+
+#endif


Property changes on: trunk/blender/source/blender/editors/include/ED_numinput.h
___________________________________________________________________
Name: svn:keywords
   + Date Id Revision
Name: svn:eol-style
   + native

Modified: trunk/blender/source/blender/editors/transform/transform.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.c	2010-02-20 19:49:04 UTC (rev 27029)
+++ trunk/blender/source/blender/editors/transform/transform.c	2010-02-20 20:29:09 UTC (rev 27030)
@@ -496,8 +496,8 @@
 	{TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Remove Constraints", ""},
 	{TFM_MODAL_ADD_SNAP, "ADD_SNAP", 0, "Add Snap Point", ""},
 	{TFM_MODAL_REMOVE_SNAP, "REMOVE_SNAP", 0, "Remove Last Snap Point", ""},
-	{TFM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""},
-	{TFM_MODAL_INCREMENT_DOWN, "INCREMENT_DOWN", 0, "Numinput Increment Down", ""},
+	{NUM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""},
+	{NUM_MODAL_INCREMENT_DOWN, "INCREMENT_DOWN", 0, "Numinput Increment Down", ""},
 	{0, NULL, 0, NULL, NULL}};
 	
 	wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Transform Modal Map");
@@ -525,8 +525,8 @@
 	WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, 0, 0, TFM_MODAL_ADD_SNAP);
 	WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, KM_ALT, 0, TFM_MODAL_REMOVE_SNAP);
 
-	WM_modalkeymap_add_item(keymap, UPARROWKEY, KM_PRESS, 0, 0, TFM_MODAL_INCREMENT_UP);
-	WM_modalkeymap_add_item(keymap, DOWNARROWKEY, KM_PRESS, 0, 0, TFM_MODAL_INCREMENT_DOWN);
+	WM_modalkeymap_add_item(keymap, UPARROWKEY, KM_PRESS, 0, 0, NUM_MODAL_INCREMENT_UP);
+	WM_modalkeymap_add_item(keymap, DOWNARROWKEY, KM_PRESS, 0, 0, NUM_MODAL_INCREMENT_DOWN);
 
 	return keymap;
 }

Modified: trunk/blender/source/blender/editors/transform/transform.h
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.h	2010-02-20 19:49:04 UTC (rev 27029)
+++ trunk/blender/source/blender/editors/transform/transform.h	2010-02-20 20:29:09 UTC (rev 27030)
@@ -31,6 +31,7 @@
 #define TRANSFORM_H
 
 #include "ED_transform.h"
+#include "ED_numinput.h"
 
 #include "DNA_listBase.h"
 
@@ -68,14 +69,6 @@
 	float	factor[3];
 } NDofInput;
 
-typedef struct NumInput {
-    short  idx;
-    short  idx_max;
-    short  flag;        /* Different flags to indicate different behaviors                                */
-    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 ;
 
 /*
 	The ctrl value has different meaning:
@@ -334,13 +327,6 @@
 
 /* ******************** Macros & Prototypes *********************** */
 
-/* NUMINPUT FLAGS */
-#define NUM_NULL_ONE		2
-#define NUM_NO_NEGATIVE		4
-#define	NUM_NO_ZERO			8
-#define NUM_NO_FRACTION		16
-#define	NUM_AFFECT_ALL		32
-
 /* NDOFINPUT FLAGS */
 #define NDOF_INIT			1
 
@@ -678,17 +664,6 @@
 
 void getViewVector(TransInfo *t, float coord[3], float vec[3]);
 
-/*********************** NumInput ********************************/
-
-void initNumInput(NumInput *n);
-void outputNumInput(NumInput *n, char *str);
-short hasNumInput(NumInput *n);
-void applyNumInput(NumInput *n, float *vec);
-char handleNumInput(NumInput *n, struct wmEvent *event, float increment);
-
-#define TFM_MODAL_INCREMENT_UP   18
-#define TFM_MODAL_INCREMENT_DOWN 19
-
 /*********************** NDofInput ********************************/
 
 void initNDofInput(NDofInput *n);
@@ -733,5 +708,3 @@
 void freeSlideVerts(TransInfo *t);
 
 #endif
-
-

Deleted: trunk/blender/source/blender/editors/transform/transform_numinput.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_numinput.c	2010-02-20 19:49:04 UTC (rev 27029)
+++ trunk/blender/source/blender/editors/transform/transform_numinput.c	2010-02-20 20:29:09 UTC (rev 27030)
@@ -1,299 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Jonathan Smith
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include <math.h>			/* fabs */
-#include <stdio.h>			/* for sprintf		*/
-
-#include "BKE_global.h"		/* for G			*/
-#include "BKE_utildefines.h"	/* ABS */
-
-#include "WM_types.h"
-#include "DNA_windowmanager_types.h"
-
-#include "transform.h"
-
-/* ************************** Functions *************************** */
-
-/* ************************** NUMINPUT **************************** */
-
-void initNumInput(NumInput *n)
-{
-	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;
-
-	n->val[0]		= 
-	n->val[1]	= 
-	n->val[2]	= 0.0f;
-}
-
-void outputNumInput(NumInput *n, char *str)
-{
-	char cur;
-	char inv[] = "1/";
-	short i, j;
-
-	for (j=0; j<=n->idx_max; j++) {
-		/* if AFFECTALL and no number typed and cursor not on number, use first number */
-		if (n->flag & NUM_AFFECT_ALL && n->idx != j && n->ctrl[j] == 0)
-			i = 0;
-		else
-			i = j;
-
-		if (n->idx != i)
-			cur = ' ';
-		else
-			cur = '|';
-

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list