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:
authorJoshua Leung <aligorith@gmail.com>2011-03-17 13:02:37 +0300
committerJoshua Leung <aligorith@gmail.com>2011-03-17 13:02:37 +0300
commite3842d1ca4dd2fdc58b8d7819a8a02a688753146 (patch)
treeb196019c622710a5277b4a7218af06afdb0bccec /source/blender/editors/space_action
parent58c8dca7a60ba369eca95c99da2c3885e3b401c2 (diff)
Bugfix [#26505] zoom in selected keys on graph editor
Not really a "bug", but it was on my todo anyways. Based on patch [#26508] by Campbell, with a few modifications including extending this to the Action/DopeSheet editor too.
Diffstat (limited to 'source/blender/editors/space_action')
-rw-r--r--source/blender/editors/space_action/action_edit.c41
-rw-r--r--source/blender/editors/space_action/action_intern.h1
-rw-r--r--source/blender/editors/space_action/action_ops.c2
3 files changed, 38 insertions, 6 deletions
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 27148a87471..0a98178a890 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -227,7 +227,7 @@ void ACTION_OT_markers_make_local (wmOperatorType *ot)
/* *************************** Calculate Range ************************** */
/* Get the min/max keyframes*/
-static void get_keyframe_extents (bAnimContext *ac, float *min, float *max)
+static void get_keyframe_extents (bAnimContext *ac, float *min, float *max, const short onlySel)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
@@ -249,8 +249,8 @@ static void get_keyframe_extents (bAnimContext *ac, float *min, float *max)
FCurve *fcu= (FCurve *)ale->key_data;
float tmin, tmax;
- /* get range and apply necessary scaling before */
- calc_fcurve_range(fcu, &tmin, &tmax);
+ /* get range and apply necessary scaling before processing */
+ calc_fcurve_range(fcu, &tmin, &tmax, onlySel);
if (adt) {
tmin= BKE_nla_tweakedit_remap(adt, tmin, NLATIME_CONVERT_MAP);
@@ -295,7 +295,7 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
scene= ac.scene;
/* set the range directly */
- get_keyframe_extents(&ac, &min, &max);
+ get_keyframe_extents(&ac, &min, &max, FALSE);
scene->r.flag |= SCER_PRV_RANGE;
scene->r.psfra= (int)floor(min + 0.5f);
scene->r.pefra= (int)floor(max + 0.5f);
@@ -324,7 +324,7 @@ void ACTION_OT_previewrange_set (wmOperatorType *ot)
/* ****************** View-All Operator ****************** */
-static int actkeys_viewall_exec(bContext *C, wmOperator *UNUSED(op))
+static int actkeys_viewall(bContext *C, const short onlySel)
{
bAnimContext ac;
View2D *v2d;
@@ -336,7 +336,7 @@ static int actkeys_viewall_exec(bContext *C, wmOperator *UNUSED(op))
v2d= &ac.ar->v2d;
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
- get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax);
+ get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel);
extra= 0.1f * (v2d->cur.xmax - v2d->cur.xmin);
v2d->cur.xmin -= extra;
@@ -354,6 +354,20 @@ static int actkeys_viewall_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
+
+/* ......... */
+
+static int actkeys_viewall_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ /* whole range */
+ return actkeys_viewall(C, FALSE);
+}
+
+static int actkeys_viewsel_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ /* only selected */
+ return actkeys_viewall(C, TRUE);
+}
void ACTION_OT_view_all (wmOperatorType *ot)
{
@@ -370,6 +384,21 @@ void ACTION_OT_view_all (wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+void ACTION_OT_view_selected (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "View Selected";
+ ot->idname= "ACTION_OT_view_selected";
+ ot->description= "Reset viewable area to show selected keyframes range";
+
+ /* api callbacks */
+ ot->exec= actkeys_viewsel_exec;
+ ot->poll= ED_operator_action_active;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/* ************************************************************************** */
/* GENERAL STUFF */
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index e80b82fcf79..512b6e329dd 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -87,6 +87,7 @@ enum {
void ACTION_OT_previewrange_set(struct wmOperatorType *ot);
void ACTION_OT_view_all(struct wmOperatorType *ot);
+void ACTION_OT_view_selected(struct wmOperatorType *ot);
void ACTION_OT_copy(struct wmOperatorType *ot);
void ACTION_OT_paste(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index 6c3258e8639..b6fbc34550f 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -84,6 +84,7 @@ void action_operatortypes(void)
WM_operatortype_append(ACTION_OT_previewrange_set);
WM_operatortype_append(ACTION_OT_view_all);
+ WM_operatortype_append(ACTION_OT_view_selected);
WM_operatortype_append(ACTION_OT_markers_make_local);
}
@@ -181,6 +182,7 @@ static void action_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap)
/* auto-set range */
WM_keymap_add_item(keymap, "ACTION_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
WM_keymap_add_item(keymap, "ACTION_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "ACTION_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
/* animation module */
/* channels list