[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39240] branches/soc-2011-pepper/source/ blender/editors/armature/poseSlide.c: Gianmichele request: Pose Sliding tools show percentage indicator in

Joshua Leung aligorith at gmail.com
Wed Aug 10 02:46:21 CEST 2011


Revision: 39240
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39240
Author:   aligorith
Date:     2011-08-10 00:46:20 +0000 (Wed, 10 Aug 2011)
Log Message:
-----------
Gianmichele request: Pose Sliding tools show percentage indicator in
header

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/editors/armature/poseSlide.c

Modified: branches/soc-2011-pepper/source/blender/editors/armature/poseSlide.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/armature/poseSlide.c	2011-08-09 23:06:59 UTC (rev 39239)
+++ branches/soc-2011-pepper/source/blender/editors/armature/poseSlide.c	2011-08-10 00:46:20 UTC (rev 39240)
@@ -93,7 +93,8 @@
 /* Temporary data shared between these operators */
 typedef struct tPoseSlideOp {
 	Scene *scene;		/* current scene */
-	ARegion *ar;		/* region that we're operating in (needed for  */
+	ScrArea *sa;		/* area that we're operating in (needed for modal()) */
+	ARegion *ar;		/* region that we're operating in (needed for modal()) */
 	Object *ob;			/* active object that Pose Info comes from */
 	bArmature *arm;		/* armature for pose */
 	
@@ -132,6 +133,7 @@
 	pso->scene= CTX_data_scene(C);
 	pso->ob= ED_object_pose_armature(CTX_data_active_object(C));
 	pso->arm= (pso->ob)? pso->ob->data : NULL;
+	pso->sa= CTX_wm_area(C); /* only really needed when doing modal() */
 	pso->ar= CTX_wm_region(C); /* only really needed when doing modal() */
 	
 	pso->cframe= pso->scene->r.cfra;
@@ -519,6 +521,33 @@
 
 /* ------------------------------------ */
 
+/* draw percentage indicator in header */
+static void pose_slide_draw_status (bContext *C, tPoseSlideOp *pso)
+{
+	char statusStr[32];
+	char mode[32];
+	
+	switch (pso->mode) {
+		case POSESLIDE_PUSH:
+			strcpy(mode, "Push Pose");
+			break;
+		case POSESLIDE_RELAX:
+			strcpy(mode, "Relax Pose");
+			break;
+		case POSESLIDE_BREAKDOWN:
+			strcpy(mode, "Breakdown");
+			break;
+		
+		default:
+			// unknown
+			strcpy(mode, "Sliding-Tool");
+			break;
+	}
+	
+	sprintf(statusStr, "%s: %d %%", mode, (int)(pso->percentage*100.0f));
+	ED_area_headerprint(pso->sa, statusStr);
+}
+
 /* common code for invoke() methods */
 static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp *pso)
 {
@@ -587,6 +616,9 @@
 	/* set cursor to indicate modal */
 	WM_cursor_modal(win, BC_EW_SCROLLCURSOR);
 	
+	/* header print */
+	pose_slide_draw_status(C, pso);
+	
 	/* add a modal handler for this operator */
 	WM_event_add_modal_handler(C, op);
 	return OPERATOR_RUNNING_MODAL;
@@ -601,7 +633,8 @@
 	switch (evt->type) {
 		case LEFTMOUSE:	/* confirm */
 		{
-			/* return to normal cursor */
+			/* return to normal cursor and header status */
+			ED_area_headerprint(pso->sa, NULL);
 			WM_cursor_restore(win);
 			
 			/* insert keyframes as required... */
@@ -615,7 +648,8 @@
 		case ESCKEY:	/* cancel */
 		case RIGHTMOUSE: 
 		{
-			/* return to normal cursor */
+			/* return to normal cursor and header status */
+			ED_area_headerprint(pso->sa, NULL);
 			WM_cursor_restore(win);
 			
 			/* reset transforms back to original state */
@@ -639,6 +673,9 @@
 			pso->percentage= (evt->x - pso->ar->winrct.xmin) / ((float)pso->ar->winx);
 			RNA_float_set(op->ptr, "percentage", pso->percentage);
 			
+			/* update percentage indicator in header */
+			pose_slide_draw_status(C, pso);
+			
 			/* reset transforms (to avoid accumulation errors) */
 			pose_slide_reset(pso);
 			




More information about the Bf-blender-cvs mailing list