Revision: 55052
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55052
Author:   nazgul
Date:     2013-03-05 12:41:17 +0000 (Tue, 05 Mar 2013)
Log Message:
-----------
View All operator for motion tracking dopesheet.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_clip/clip_dopesheet_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_dopesheet_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_dopesheet_ops.c        
2013-03-05 11:19:21 UTC (rev 55051)
+++ trunk/blender/source/blender/editors/space_clip/clip_dopesheet_ops.c        
2013-03-05 12:41:17 UTC (rev 55052)
@@ -59,12 +59,11 @@
 
 #include "clip_intern.h"       // own include
 
-#if 0
-static int ED_space_clip_dopesheet_poll(bContext *C)
+static int space_clip_dopesheet_poll(bContext *C)
 {
-       SpaceClip *sc = CTX_wm_space_clip(C);
+       if (ED_space_clip_tracking_poll(C)) {
+               SpaceClip *sc = CTX_wm_space_clip(C);
 
-       if (sc && sc->clip) {
                if (sc->view == SC_VIEW_DOPESHEET) {
                        ARegion *ar = CTX_wm_region(C);
 
@@ -74,7 +73,6 @@
 
        return FALSE;
 }
-#endif
 
 /********************** select channel operator *********************/
 
@@ -161,3 +159,54 @@
        RNA_def_boolean(ot->srna, "extend", 0,
                        "Extend", "Extend selection rather than clearing the 
existing selection");
 }
+
+/********************** View All operator *********************/
+
+static int dopesheet_view_all_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       SpaceClip *sc = CTX_wm_space_clip(C);
+       ARegion *ar = CTX_wm_region(C);
+       View2D *v2d = &ar->v2d;
+       MovieClip *clip = ED_space_clip_get_clip(sc);
+       MovieTracking *tracking = &clip->tracking;
+       MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
+       MovieTrackingDopesheetChannel *channel;
+       int frame_min = INT_MAX, frame_max = INT_MIN;
+
+       for (channel = dopesheet->channels.first; channel; channel = 
channel->next) {
+               frame_min = min_ii(frame_min, channel->segments[0]);
+               frame_max = max_ii(frame_max, 
channel->segments[channel->tot_segment]);
+       }
+
+       if (frame_min < frame_max) {
+               float extra;
+
+               v2d->cur.xmin = frame_min;
+               v2d->cur.xmax = frame_max;
+
+               /* we need an extra "buffer" factor on either side so that the 
endpoints are visible */
+               extra = 0.01f * BLI_rctf_size_x(&v2d->cur);
+               v2d->cur.xmin -= extra;
+               v2d->cur.xmax += extra;
+
+               ED_region_tag_redraw(ar);
+       }
+
+
+       return OPERATOR_FINISHED;
+}
+
+void CLIP_OT_dopesheet_view_all(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "View All";
+       ot->description = "Reset viewable area to show full keyframe range";
+       ot->idname = "CLIP_OT_dopesheet_view_all";
+
+       /* api callbacks */
+       ot->exec = dopesheet_view_all_exec;
+       ot->poll = space_clip_dopesheet_poll;
+
+       /* flags */
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}

Modified: trunk/blender/source/blender/editors/space_clip/clip_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_intern.h       
2013-03-05 11:19:21 UTC (rev 55051)
+++ trunk/blender/source/blender/editors/space_clip/clip_intern.h       
2013-03-05 12:41:17 UTC (rev 55052)
@@ -67,6 +67,7 @@
 
 /* clip_dopesheet_ops.c */
 void CLIP_OT_dopesheet_select_channel(struct wmOperatorType *ot);
+void CLIP_OT_dopesheet_view_all(struct wmOperatorType *ot);
 
 /* clip_draw.c */
 void clip_draw_main(const struct bContext *C, struct SpaceClip *sc, struct 
ARegion *ar);

Modified: trunk/blender/source/blender/editors/space_clip/space_clip.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/space_clip.c        
2013-03-05 11:19:21 UTC (rev 55051)
+++ trunk/blender/source/blender/editors/space_clip/space_clip.c        
2013-03-05 12:41:17 UTC (rev 55052)
@@ -534,6 +534,7 @@
        /* ** clip_dopesheet_ops.c  ** */
 
        WM_operatortype_append(CLIP_OT_dopesheet_select_channel);
+       WM_operatortype_append(CLIP_OT_dopesheet_view_all);
 }
 
 static void clip_keymap(struct wmKeyConfig *keyconf)
@@ -768,6 +769,8 @@
 
        kmi = WM_keymap_add_item(keymap, "CLIP_OT_dopesheet_select_channel", 
ACTIONMOUSE, KM_PRESS, 0, 0);
        RNA_boolean_set(kmi->ptr, "extend", TRUE);  /* toggle */
+
+       WM_keymap_add_item(keymap, "CLIP_OT_dopesheet_view_all", HOMEKEY, 
KM_PRESS, 0, 0);
 }
 
 const char *clip_context_dir[] = {"edit_movieclip", "edit_mask", NULL};
@@ -1191,6 +1194,9 @@
 
        keymap = WM_keymap_find(wm->defaultconf, "Clip Graph Editor", 
SPACE_CLIP, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, 
&ar->winrct);
+
+       keymap = WM_keymap_find(wm->defaultconf, "Clip Dopesheet Editor", 
SPACE_CLIP, 0);
+       WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, 
&ar->winrct);
 }
 
 static void graph_area_draw(const bContext *C, ARegion *ar)

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to