Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-01-26 13:29:49 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-01-26 13:29:49 +0400
commitdc4e37c7642da007ebc73f7528426e921b3f96fa (patch)
tree5e4b7d47af832f1c0884ba19e1eac935c27124ca /source/blender/editors/space_clip
parent1f996cb95ad3b6e97dba7e4392fe81f84e0263c6 (diff)
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.
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c24
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c116
-rw-r--r--source/blender/editors/space_clip/clip_intern.h2
-rw-r--r--source/blender/editors/space_clip/space_clip.c8
4 files changed, 147 insertions, 3 deletions
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index e913ae77f05..6fabe802ff0 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -47,6 +47,7 @@
#include "ED_clip.h"
#include "BIF_gl.h"
+#include "BIF_glutil.h"
#include "WM_types.h"
@@ -120,6 +121,26 @@ static void draw_graph_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
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 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene)
draw_frame_curves(sc);
}
+ /* frame range */
+ draw_graph_sfra_efra(scene, v2d);
+
/* current frame */
draw_graph_cfra(sc, ar, scene);
}
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index 8be5e520b1f..7652e59a9a8 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -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 @@ void CLIP_OT_graph_select(wmOperatorType *ot)
/* 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 @@ void CLIP_OT_graph_delete_knot(wmOperatorType *ot)
/* 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;
+}
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h
index 3f7456e90dc..3f273b5cd90 100644
--- a/source/blender/editors/space_clip/clip_intern.h
+++ b/source/blender/editors/space_clip/clip_intern.h
@@ -58,6 +58,8 @@ void clip_draw_graph(struct SpaceClip *sc, struct ARegion *ar, struct Scene *sce
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);
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 04871156412..25617c3cf5d 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -78,7 +78,7 @@ static void init_preview_region(const bContext *C, ARegion *ar)
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 @@ static void clip_operatortypes(void)
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 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
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);
}