Revision: 43714
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43714
Author:   nazgul
Date:     2012-01-26 09:29:49 +0000 (Thu, 26 Jan 2012)
Log Message:
-----------
Tracks curves fixes and improvements:

- Use proper poll functions for tracks curve operators.
- Darken frames outside of scene frame range in curves view.
- Implemented view all operator.
- Implemented jump to current frame operator.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_clip/clip_graph_draw.c
    trunk/blender/source/blender/editors/space_clip/clip_graph_ops.c
    trunk/blender/source/blender/editors/space_clip/clip_intern.h
    trunk/blender/source/blender/editors/space_clip/space_clip.c

Modified: trunk/blender/source/blender/editors/space_clip/clip_graph_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_graph_draw.c   
2012-01-26 08:45:01 UTC (rev 43713)
+++ trunk/blender/source/blender/editors/space_clip/clip_graph_draw.c   
2012-01-26 09:29:49 UTC (rev 43714)
@@ -47,6 +47,7 @@
 #include "ED_clip.h"
 
 #include "BIF_gl.h"
+#include "BIF_glutil.h"
 
 #include "WM_types.h"
 
@@ -120,6 +121,26 @@
        glScalef(xscale, 1.0, 1.0);
 }
 
+static void draw_graph_sfra_efra(Scene *scene, View2D *v2d)
+{
+       UI_view2d_view_ortho(v2d);
+
+       /* currently clip editor supposes that editing clip length is equal to 
scene frame range */
+       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       glEnable(GL_BLEND);
+               glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
+
+               glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, 
v2d->cur.ymax);
+               glRectf((float)EFRA, v2d->cur.ymin, v2d->cur.xmax, 
v2d->cur.ymax);
+       glDisable(GL_BLEND);
+
+       UI_ThemeColorShade(TH_BACK, -60);
+
+       /* thin lines where the actual frames are */
+       fdrawline((float)SFRA, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
+       fdrawline((float)EFRA, v2d->cur.ymin, (float)EFRA, v2d->cur.ymax);
+}
+
 static void tracking_segment_point_cb(void *UNUSED(userdata), 
MovieTrackingTrack *UNUSED(track),
                        MovieTrackingMarker *marker, int UNUSED(coord), float 
val)
 {
@@ -255,6 +276,9 @@
                        draw_frame_curves(sc);
        }
 
+       /* frame range */
+       draw_graph_sfra_efra(scene, v2d);
+
        /* current frame */
        draw_graph_cfra(sc, ar, scene);
 }

Modified: trunk/blender/source/blender/editors/space_clip/clip_graph_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_graph_ops.c    
2012-01-26 08:45:01 UTC (rev 43713)
+++ trunk/blender/source/blender/editors/space_clip/clip_graph_ops.c    
2012-01-26 09:29:49 UTC (rev 43714)
@@ -30,6 +30,7 @@
  */
 
 #include "DNA_object_types.h"  /* SELECT */
+#include "DNA_scene_types.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -58,6 +59,19 @@
 
 /******************** common graph-editing utilities ********************/
 
+static int ED_space_clip_graph_poll(bContext *C)
+{
+       SpaceClip *sc = CTX_wm_space_clip(C);
+
+       if(sc && sc->clip) {
+               ARegion *ar = CTX_wm_region(C);
+
+               return ar->regiontype == RGN_TYPE_PREVIEW;
+       }
+
+       return 0;
+}
+
 typedef struct {
        int action;
 } SelectUserData;
@@ -278,7 +292,7 @@
        /* api callbacks */
        ot->exec= select_exec;
        ot->invoke= select_invoke;
-       ot->poll= ED_space_clip_poll;
+       ot->poll= ED_space_clip_graph_poll;
 
        /* flags */
        ot->flag= OPTYPE_UNDO;
@@ -357,8 +371,106 @@
 
        /* api callbacks */
        ot->exec= delete_knot_exec;
-       ot->poll= ED_space_clip_poll;
+       ot->poll= ED_space_clip_graph_poll;
 
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
+
+/******************** view all operator ********************/
+
+typedef struct {
+       float min, max;
+} ViewAllUserData;
+
+static void view_all_cb(void *userdata, MovieTrackingTrack *UNUSED(track), 
MovieTrackingMarker *UNUSED(marker),
+                        int UNUSED(coord), float val)
+{
+       ViewAllUserData *data = (ViewAllUserData *)userdata;
+
+       if(val < data->min) data->min = val;
+       if(val > data->max) data->max = val;
+}
+
+static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       Scene *scene = CTX_data_scene(C);
+       ARegion *ar = CTX_wm_region(C);
+       SpaceClip *sc = CTX_wm_space_clip(C);
+       View2D *v2d = &ar->v2d;
+       ViewAllUserData userdata;
+       float extra;
+
+       userdata.max = -FLT_MAX;
+       userdata.min = FLT_MAX;
+
+       clip_graph_tracking_values_iterate(sc, &userdata, view_all_cb, NULL, 
NULL);
+
+       /* set extents of view to start/end frames */
+       v2d->cur.xmin = (float)SFRA;
+       v2d->cur.xmax = (float)EFRA;
+
+       if (userdata.min < userdata.max) {
+               v2d->cur.ymin = userdata.min;
+               v2d->cur.ymax = userdata.max;
+       }
+       else {
+               v2d->cur.ymin = -10;
+               v2d->cur.ymax = 10;
+       }
+
+       /* we need an extra "buffer" factor on either side so that the 
endpoints are visible */
+       extra= 0.01f * (v2d->cur.xmax - v2d->cur.xmin);
+       v2d->cur.xmin -= extra;
+       v2d->cur.xmax += extra;
+
+       extra= 0.01f * (v2d->cur.ymax - v2d->cur.ymin);
+       v2d->cur.ymin -= extra;
+       v2d->cur.ymax += extra;
+
+       ED_region_tag_redraw(ar);
+
+       return OPERATOR_FINISHED;
+}
+
+void CLIP_OT_graph_view_all(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "View All";
+       ot->description = "View all curves in editor";
+       ot->idname = "CLIP_OT_graph_view_all";
+
+       /* api callbacks */
+       ot->exec = view_all_exec;
+       ot->poll = ED_space_clip_graph_poll;
+}
+
+/******************** jump to current frame operator ********************/
+
+static int jump_to_current_frame_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       Scene *scene = CTX_data_scene(C);
+       ARegion *ar = CTX_wm_region(C);
+       View2D *v2d = &ar->v2d;
+       float extra = (v2d->cur.xmax - v2d->cur.xmin) / 2.0;
+
+       /* set extents of view to start/end frames */
+       v2d->cur.xmin = (float)CFRA - extra;
+       v2d->cur.xmax = (float)CFRA + extra;
+
+       ED_region_tag_redraw(ar);
+
+       return OPERATOR_FINISHED;
+}
+
+void CLIP_OT_graph_jump_to_current_frame(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "Jump to current frame";
+       ot->description = "Jump to current frame";
+       ot->idname = "CLIP_OT_graph_jump_to_current_frame";
+
+       /* api callbacks */
+       ot->exec = jump_to_current_frame_exec;
+       ot->poll = ED_space_clip_graph_poll;
+}

Modified: trunk/blender/source/blender/editors/space_clip/clip_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_intern.h       
2012-01-26 08:45:01 UTC (rev 43713)
+++ trunk/blender/source/blender/editors/space_clip/clip_intern.h       
2012-01-26 09:29:49 UTC (rev 43714)
@@ -58,6 +58,8 @@
 void CLIP_OT_graph_select(struct wmOperatorType *ot);
 void CLIP_OT_graph_delete_curve(struct wmOperatorType *ot);
 void CLIP_OT_graph_delete_knot(struct wmOperatorType *ot);
+void CLIP_OT_graph_view_all(struct wmOperatorType *ot);
+void CLIP_OT_graph_jump_to_current_frame(struct wmOperatorType *ot);
 
 /* clip_ops.c */
 void CLIP_OT_open(struct wmOperatorType *ot);

Modified: trunk/blender/source/blender/editors/space_clip/space_clip.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/space_clip.c        
2012-01-26 08:45:01 UTC (rev 43713)
+++ trunk/blender/source/blender/editors/space_clip/space_clip.c        
2012-01-26 09:29:49 UTC (rev 43714)
@@ -78,7 +78,7 @@
        ar->flag|= RGN_FLAG_HIDDEN;
 
        ar->v2d.tot.xmin= 0.0f;
-       ar->v2d.tot.ymin= (float)scene->r.sfra - 10.0f;
+       ar->v2d.tot.ymin= -10.0f;
        ar->v2d.tot.xmax= (float)scene->r.efra;
        ar->v2d.tot.ymax= 10.0f;
 
@@ -373,6 +373,8 @@
        WM_operatortype_append(CLIP_OT_graph_select);
        WM_operatortype_append(CLIP_OT_graph_delete_curve);
        WM_operatortype_append(CLIP_OT_graph_delete_knot);
+       WM_operatortype_append(CLIP_OT_graph_view_all);
+       WM_operatortype_append(CLIP_OT_graph_jump_to_current_frame);
 
        /* object tracking */
        WM_operatortype_append(CLIP_OT_tracking_object_new);
@@ -546,6 +548,10 @@
        WM_keymap_add_item(keymap, "CLIP_OT_graph_delete_knot", DELKEY, 
KM_PRESS, KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "CLIP_OT_graph_delete_knot", XKEY, KM_PRESS, 
KM_SHIFT, 0);
 
+       /* view */
+       WM_keymap_add_item(keymap, "CLIP_OT_graph_view_all", HOMEKEY, KM_PRESS, 
0, 0);
+       WM_keymap_add_item(keymap, "CLIP_OT_graph_jump_to_current_frame", 
PADPERIOD, KM_PRESS, 0, 0);
+
        transform_keymap_for_space(keyconf, keymap, SPACE_CLIP);
 }
 

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

Reply via email to