Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / space_action / action_edit.c
index 285e9af..b3c1c53 100644 (file)
@@ -384,12 +384,22 @@ static int actkeys_viewall(bContext *C, const bool only_sel)
        if (only_sel && (found == false))
                return OPERATOR_CANCELLED;
 
-       v2d->cur.xmin = min;
-       v2d->cur.xmax = max;
+       if (fabsf(max - min) < 1.0f) {
+               /* Exception - center the single keyfrme */
+               float xwidth = BLI_rctf_size_x(&v2d->cur);
 
-       extra = 0.1f * BLI_rctf_size_x(&v2d->cur);
-       v2d->cur.xmin -= extra;
-       v2d->cur.xmax += extra;
+               v2d->cur.xmin = min - xwidth / 2.0f;
+               v2d->cur.xmax = max + xwidth / 2.0f;
+       }
+       else {
+               /* Normal case - stretch the two keyframes out to fill the space, with extra spacing */
+               v2d->cur.xmin = min;
+               v2d->cur.xmax = max;
+
+               extra = 0.125f * BLI_rctf_size_x(&v2d->cur);
+               v2d->cur.xmin -= extra;
+               v2d->cur.xmax += extra;
+       }
 
        /* set vertical range */
        if (only_sel == false) {
@@ -673,6 +683,7 @@ static void insert_action_keys(bAnimContext *ac, short mode)
        bAnimListElem *ale;
        int filter;
 
+       struct Depsgraph *depsgraph = ac->depsgraph;
        ReportList *reports = ac->reports;
        Scene *scene = ac->scene;
        ToolSettings *ts = scene->toolsettings;
@@ -707,7 +718,7 @@ static void insert_action_keys(bAnimContext *ac, short mode)
                 *                       (TODO: add the full-blown PointerRNA relative parsing case here...)
                 */
                if (ale->id && !ale->owner) {
-                       insert_keyframe(reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag);
+                       insert_keyframe(depsgraph, reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag);
                }
                else {
                        const float curval = evaluate_fcurve(fcu, cfra);