Fix for FCurve keyframe editing left handle from button failing if not selected

This commit is contained in:
Campbell Barton 2014-05-14 13:26:36 +10:00
parent dc03a5ebe3
commit a756499c62

@ -47,6 +47,7 @@
#include "BLF_translation.h" #include "BLF_translation.h"
#include "BKE_context.h" #include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_depsgraph.h" #include "BKE_depsgraph.h"
#include "BKE_fcurve.h" #include "BKE_fcurve.h"
#include "BKE_main.h" #include "BKE_main.h"
@ -226,15 +227,13 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT
} }
/* update callback for active keyframe properties - base updates stuff */ /* update callback for active keyframe properties - base updates stuff */
static void graphedit_activekey_update_cb(bContext *C, void *fcu_ptr, void *UNUSED(bezt_ptr)) static void graphedit_activekey_update_cb(bContext *UNUSED(C), void *fcu_ptr, void *UNUSED(bezt_ptr))
{ {
SpaceIpo *sipo = CTX_wm_space_graph(C);
const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
FCurve *fcu = (FCurve *)fcu_ptr; FCurve *fcu = (FCurve *)fcu_ptr;
/* make sure F-Curve and its handles are still valid after this editing */ /* make sure F-Curve and its handles are still valid after this editing */
sort_time_fcurve(fcu); sort_time_fcurve(fcu);
testhandles_fcurve(fcu, use_handle); calchandles_fcurve(fcu);
} }
/* update callback for active keyframe properties - handle-editing wrapper */ /* update callback for active keyframe properties - handle-editing wrapper */
@ -250,6 +249,9 @@ static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bez
bezt->h1 = HD_ALIGN; bezt->h1 = HD_ALIGN;
bezt->h2 = HD_ALIGN; bezt->h2 = HD_ALIGN;
} }
else {
BKE_nurb_bezt_handle_test(bezt, true);
}
/* now call standard updates */ /* now call standard updates */
graphedit_activekey_update_cb(C, fcu_ptr, bezt_ptr); graphedit_activekey_update_cb(C, fcu_ptr, bezt_ptr);
@ -259,6 +261,24 @@ static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bez
* NOTE: we cannot just do graphedit_activekey_handles_cb() due to "order of computation" * NOTE: we cannot just do graphedit_activekey_handles_cb() due to "order of computation"
* weirdness (see calchandleNurb_intern() and T39911) * weirdness (see calchandleNurb_intern() and T39911)
*/ */
static void graphedit_activekey_left_handle_coord_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
{
BezTriple *bezt = (BezTriple *)bezt_ptr;
const char f1 = bezt->f1;
const char f3 = bezt->f3;
bezt->f1 |= SELECT;
bezt->f3 &= ~SELECT;
/* perform normal updates NOW */
graphedit_activekey_handles_cb(C, fcu_ptr, bezt_ptr);
/* restore selection state so that no-one notices this hack */
bezt->f1 = f1;
bezt->f3 = f3;
}
static void graphedit_activekey_right_handle_coord_cb(bContext *C, void *fcu_ptr, void *bezt_ptr) static void graphedit_activekey_right_handle_coord_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
{ {
BezTriple *bezt = (BezTriple *)bezt_ptr; BezTriple *bezt = (BezTriple *)bezt_ptr;
@ -270,8 +290,8 @@ static void graphedit_activekey_right_handle_coord_cb(bContext *C, void *fcu_ptr
/* temporarily make it so that only the right handle is selected, so that updates go correctly /* temporarily make it so that only the right handle is selected, so that updates go correctly
* (i.e. it now acts as if we've just transforming the vert when it is selected by itself) * (i.e. it now acts as if we've just transforming the vert when it is selected by itself)
*/ */
bezt->f1 = 0; bezt->f1 &= ~SELECT;
bezt->f3 = 1; bezt->f3 |= SELECT;
/* perform normal updates NOW */ /* perform normal updates NOW */
graphedit_activekey_handles_cb(C, fcu_ptr, bezt_ptr); graphedit_activekey_handles_cb(C, fcu_ptr, bezt_ptr);
@ -362,11 +382,11 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
but = uiDefButR(block, NUM, B_REDR, "X:", 0, 0, UI_UNIT_X, UI_UNIT_Y, but = uiDefButR(block, NUM, B_REDR, "X:", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL); &bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); uiButSetFunc(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt);
but = uiDefButR(block, NUM, B_REDR, "Y:", 0, 0, UI_UNIT_X, UI_UNIT_Y, but = uiDefButR(block, NUM, B_REDR, "Y:", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL); &bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); uiButSetFunc(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt);
uiButSetUnitType(but, unit); uiButSetUnitType(but, unit);
/* XXX: with label? */ /* XXX: with label? */