Merging trunk up to r39447.
[blender-staging.git] / source / blender / editors / armature / poseSlide.c
index 69b7fff36074f9534697f17b39b80f034a2fff51..3c15ff52a3067ff466bc1759eeaea6af9eaad7b9 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -93,7 +91,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 +131,7 @@ static int pose_slide_init (bContext *C, wmOperator *op, short mode)
        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 +519,33 @@ static void pose_slide_reset (tPoseSlideOp *pso)
 
 /* ------------------------------------ */
 
+/* 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 +614,9 @@ static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp *
        /* 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 +631,8 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt)
        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 +646,8 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt)
                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 +671,9 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt)
                        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);