diff options
author | Sergey Sharybin <sergey@blender.org> | 2020-11-12 11:26:20 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2020-11-12 11:26:20 +0300 |
commit | de6cee4fc1913982b0b2bd786bfd813c935bbe73 (patch) | |
tree | a726c0c63bbd1d6c47c90c32119ce14c8048cddc /source/blender/editors/space_graph/graph_buttons.c | |
parent | e4d432500a0e2f978fe019da43deb843da405032 (diff) | |
parent | 88bb29dea668df8cc46aa7f55895f229748bdbb4 (diff) |
Merge branch 'master' into codesign_error_tracker
Diffstat (limited to 'source/blender/editors/space_graph/graph_buttons.c')
-rw-r--r-- | source/blender/editors/space_graph/graph_buttons.c | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 47f910402fe..9c7c859a05d 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -64,7 +64,7 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "graph_intern.h" // own include +#include "graph_intern.h" /* own include */ /* ******************* graph editor space & buttons ************** */ @@ -161,6 +161,7 @@ static void graph_panel_cursor(const bContext *C, Panel *panel) sub = uiLayoutColumn(col, true); uiItemO(sub, IFACE_("Cursor to Selection"), ICON_NONE, "GRAPH_OT_frame_jump"); + uiItemO(sub, IFACE_("Cursor Value to Selection"), ICON_NONE, "GRAPH_OT_snap_cursor_value"); } /* ******************* active F-Curve ************** */ @@ -235,38 +236,27 @@ static void graph_panel_properties(const bContext *C, Panel *panel) /* ******************* active Keyframe ************** */ /* get 'active' keyframe for panel editing */ -static bool get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezTriple **prevbezt) +static bool get_active_fcurve_keyframe_edit(const FCurve *fcu, + BezTriple **r_bezt, + BezTriple **r_prevbezt) { - BezTriple *b; - int i; - /* zero the pointers */ - *bezt = *prevbezt = NULL; + *r_bezt = *r_prevbezt = NULL; - /* sanity checks */ - if ((fcu->bezt == NULL) || (fcu->totvert == 0)) { + const int active_keyframe_index = BKE_fcurve_active_keyframe_index(fcu); + if (active_keyframe_index == FCURVE_ACTIVE_KEYFRAME_NONE) { return false; } - /* find first selected keyframe for now, and call it the active one - * - this is a reasonable assumption, given that whenever anyone - * wants to edit numerically, there is likely to only be 1 vert selected - */ - for (i = 0, b = fcu->bezt; i < fcu->totvert; i++, b++) { - if (BEZT_ISSEL_ANY(b)) { - /* found - * - 'previous' is either the one before, of the keyframe itself (which is still fine) - * XXX: we can just make this null instead if needed - */ - *prevbezt = (i > 0) ? b - 1 : b; - *bezt = b; - - return true; - } - } + /* The active keyframe should be selected. */ + BLI_assert(BEZT_ISSEL_ANY(&fcu->bezt[active_keyframe_index])); - /* not found */ - return false; + *r_bezt = &fcu->bezt[active_keyframe_index]; + /* Previous is either one before the active, or the point itself if it's the first. */ + const int prev_index = max_ii(active_keyframe_index - 1, 0); + *r_prevbezt = &fcu->bezt[prev_index]; + + return true; } /* update callback for active keyframe properties - base updates stuff */ @@ -319,7 +309,7 @@ static void graphedit_activekey_left_handle_coord_cb(bContext *C, void *fcu_ptr, /* perform normal updates NOW */ graphedit_activekey_handles_cb(C, fcu_ptr, bezt_ptr); - /* restore selection state so that no-one notices this hack */ + /* restore selection state so that no one notices this hack */ bezt->f1 = f1; bezt->f3 = f3; } @@ -341,7 +331,7 @@ static void graphedit_activekey_right_handle_coord_cb(bContext *C, void *fcu_ptr /* perform normal updates NOW */ graphedit_activekey_handles_cb(C, fcu_ptr, bezt_ptr); - /* restore selection state so that no-one notices this hack */ + /* restore selection state so that no one notices this hack */ bezt->f1 = f1; bezt->f3 = f3; } @@ -655,7 +645,7 @@ static void do_graph_region_driver_buttons(bContext *C, void *id_v, int event) } /* default for now */ - WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); // XXX could use better notifier + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); /* XXX could use better notifier */ } /* callback to add a target variable to the active driver */ @@ -733,7 +723,7 @@ static bool graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt)) SpaceGraph *sipo = CTX_wm_space_graph(C); if (sipo->mode != SIPO_MODE_DRIVERS) { - return 0; + return false; } return graph_panel_context(C, NULL, NULL); @@ -1131,7 +1121,7 @@ static void graph_draw_driver_settings_panel(uiLayout *layout, 0.0, 0.0, TIP_("Invalid variable name, click here for details")); - UI_but_func_set(but, driver_dvar_invalid_name_query_cb, dvar, NULL); // XXX: reports? + UI_but_func_set(but, driver_dvar_invalid_name_query_cb, dvar, NULL); /* XXX: reports? */ } /* 1.3) remove button */ @@ -1327,9 +1317,9 @@ static void graph_panel_drivers_popover(const bContext *C, Panel *panel) static void do_graph_region_modifier_buttons(bContext *C, void *UNUSED(arg), int event) { switch (event) { - case B_FMODIFIER_REDRAW: // XXX this should send depsgraph updates too + case B_FMODIFIER_REDRAW: /* XXX this should send depsgraph updates too */ WM_event_add_notifier( - C, NC_ANIMATION, NULL); // XXX need a notifier specially for F-Modifiers + C, NC_ANIMATION, NULL); /* XXX need a notifier specially for F-Modifiers */ break; } } |