2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2008 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2011-02-27 20:29:51 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup spgraph
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
|
|
|
|
2024-09-02 12:43:53 +02:00
|
|
|
#include "ED_keyframes_edit.hh"
|
|
|
|
|
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
struct ARegion;
|
2009-05-19 17:13:33 +00:00
|
|
|
struct ARegionType;
|
2019-02-16 10:16:16 +11:00
|
|
|
struct SpaceGraph;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct bAnimContext;
|
|
|
|
|
struct bAnimListElem;
|
|
|
|
|
struct bContext;
|
Animato/2.5 - Graph Editor (i.e. the new 'IPO Editor')
This commit brings back the drawing code for the 'Graph Editor'. I've decided to call it this, as currently it can show either F-Curves for Animation stored in Actions, or F-Curves for Drivers.
Currently, it shows all curves, since some of the necessary filtering code (i.e. for limiting curve visibility) hasn't been put in place yet. At least this serves as good proof that we can have F-Curves from multiple sources at least.
It should be noted that the code still has to be modified to work with some of the new Animato features, such as F-Curve Modifiers (cycles are an example of one of the features that use this). Also, a nicer way to set the colours of the curves needs to be investigated.
Notes:
* Fixed a few bugs in RNA User-Preferences wrapping
* The keyframe drawing uses the new-style drawing for handles from AnimSys2. There's a minor bug that sometimes occurs, where a distorted handle gets drawn at the origin of the grid on the first run. Hints anyone?
* Removed most of the old data from SpaceIpo struct, as the new code uses that. Maybe later, the directories/files at least should get renamed.
* Removed ancient hack for NVidia/TNT drivers. It is probably no longer needed, but could be restored if someone needs it.
2009-01-26 11:33:16 +00:00
|
|
|
|
2008-12-12 18:47:12 +00:00
|
|
|
/* internal exports only */
|
2008-01-01 18:29:19 +00:00
|
|
|
|
2009-01-27 05:04:23 +00:00
|
|
|
/* ***************************************** */
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `graph_draw.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Left hand part.
|
|
|
|
|
*/
|
2024-03-26 20:48:05 -04:00
|
|
|
void graph_draw_channel_names(bContext *C,
|
|
|
|
|
bAnimContext *ac,
|
|
|
|
|
ARegion *region,
|
2024-08-15 20:02:06 +10:00
|
|
|
const ListBase /*bAnimListElem*/ &anim_data);
|
2009-04-08 01:07:46 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
2023-07-31 11:50:54 +10:00
|
|
|
* This is called twice from `space_graph.cc`, #graph_main_region_draw()
|
2021-12-09 00:55:11 +11:00
|
|
|
* Unselected then selected F-Curves are drawn so that they do not occlude each other.
|
|
|
|
|
*/
|
2024-03-26 20:48:05 -04:00
|
|
|
void graph_draw_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, short sel);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Draw the 'ghost' F-Curves (i.e. snapshots of the curve)
|
|
|
|
|
* \note unit mapping has already been applied to the values, so do not try and apply again.
|
|
|
|
|
*/
|
2024-03-26 20:48:05 -04:00
|
|
|
void graph_draw_ghost_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region);
|
2008-01-01 18:29:19 +00:00
|
|
|
|
2009-01-27 05:04:23 +00:00
|
|
|
/* ***************************************** */
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `graph_select.cc` */
|
2009-01-27 05:04:23 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Deselects keyframes in the Graph Editor
|
|
|
|
|
* - This is called by the deselect all operator, as well as other ones!
|
|
|
|
|
*
|
|
|
|
|
* - test: check if select or deselect all
|
|
|
|
|
* - sel: how to select keyframes
|
|
|
|
|
* 0 = deselect
|
|
|
|
|
* 1 = select
|
|
|
|
|
* 2 = invert
|
|
|
|
|
* - do_channels: whether to affect selection status of channels
|
|
|
|
|
*/
|
2024-09-02 12:43:53 +02:00
|
|
|
void deselect_graph_keys(bAnimContext *ac, bool test, eEditKeyframes_Select sel, bool do_channels);
|
2024-03-26 20:48:05 -04:00
|
|
|
|
|
|
|
|
void GRAPH_OT_select_all(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_select_box(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_select_lasso(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_select_circle(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_select_column(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_select_linked(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_select_more(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_select_less(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_select_leftright(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_select_key_handles(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_clickselect(wmOperatorType *ot);
|
2009-01-27 05:04:23 +00:00
|
|
|
|
|
|
|
|
/* defines for left-right select tool */
|
2013-03-22 05:46:39 +00:00
|
|
|
enum eGraphKeys_LeftRightSelect_Mode {
|
2012-05-08 20:18:33 +00:00
|
|
|
GRAPHKEYS_LRSEL_TEST = 0,
|
2009-01-27 05:04:23 +00:00
|
|
|
GRAPHKEYS_LRSEL_LEFT,
|
2019-02-03 14:01:45 +11:00
|
|
|
GRAPHKEYS_LRSEL_RIGHT,
|
2013-03-22 05:46:39 +00:00
|
|
|
};
|
2009-01-27 05:04:23 +00:00
|
|
|
|
2023-09-21 15:05:30 +02:00
|
|
|
/* Defines for key/handles selection. */
|
|
|
|
|
enum eGraphKey_SelectKeyHandles_Action {
|
|
|
|
|
GRAPHKEYS_KEYHANDLESSEL_SELECT = 0,
|
|
|
|
|
GRAPHKEYS_KEYHANDLESSEL_DESELECT,
|
|
|
|
|
/* Leave the selection status as-is. */
|
|
|
|
|
GRAPHKEYS_KEYHANDLESSEL_KEEP,
|
|
|
|
|
};
|
|
|
|
|
|
2009-01-27 05:04:23 +00:00
|
|
|
/* defines for column-select mode */
|
2013-03-22 05:46:39 +00:00
|
|
|
enum eGraphKeys_ColumnSelect_Mode {
|
2012-05-08 20:18:33 +00:00
|
|
|
GRAPHKEYS_COLUMNSEL_KEYS = 0,
|
2009-01-27 05:04:23 +00:00
|
|
|
GRAPHKEYS_COLUMNSEL_CFRA,
|
|
|
|
|
GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN,
|
|
|
|
|
GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN,
|
2013-03-22 05:46:39 +00:00
|
|
|
};
|
2009-01-27 05:04:23 +00:00
|
|
|
|
|
|
|
|
/* ***************************************** */
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `graph_edit.cc` */
|
2009-01-27 05:04:23 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Get the min/max keyframes.
|
|
|
|
|
* \note it should return total bound-box, filter for selection only can be argument.
|
|
|
|
|
*/
|
2024-03-26 20:48:05 -04:00
|
|
|
void get_graph_keyframe_extents(bAnimContext *ac,
|
2018-06-04 09:31:30 +02:00
|
|
|
float *xmin,
|
|
|
|
|
float *xmax,
|
|
|
|
|
float *ymin,
|
|
|
|
|
float *ymax,
|
2022-01-06 11:37:31 +01:00
|
|
|
bool do_sel_only,
|
|
|
|
|
bool include_handles);
|
2009-07-02 18:12:46 +00:00
|
|
|
|
2024-03-26 20:48:05 -04:00
|
|
|
void GRAPH_OT_previewrange_set(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_view_all(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_view_selected(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_view_frame(wmOperatorType *ot);
|
|
|
|
|
|
|
|
|
|
void GRAPH_OT_click_insert(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_keyframe_insert(wmOperatorType *ot);
|
|
|
|
|
|
|
|
|
|
void GRAPH_OT_copy(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_paste(wmOperatorType *ot);
|
|
|
|
|
|
|
|
|
|
void GRAPH_OT_duplicate(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_delete(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_clean(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_blend_to_neighbor(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_breakdown(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_ease(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_blend_offset(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_blend_to_ease(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_match_slope(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_shear(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_scale_average(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_push_pull(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_time_offset(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_scale_from_neighbor(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_decimate(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_blend_to_default(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_butterworth_smooth(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_gaussian_smooth(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_bake_keys(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_keys_to_samples(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_samples_to_keys(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_sound_to_samples(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_smooth(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_euler_filter(wmOperatorType *ot);
|
|
|
|
|
|
|
|
|
|
void GRAPH_OT_handle_type(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_interpolation_type(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_extrapolation_type(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_easing_type(wmOperatorType *ot);
|
|
|
|
|
|
|
|
|
|
void GRAPH_OT_frame_jump(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_keyframe_jump(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_snap_cursor_value(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_snap(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_equalize_handles(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_mirror(wmOperatorType *ot);
|
2009-01-28 06:32:47 +00:00
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
/* defines for snap keyframes
|
2023-08-05 02:57:52 +02:00
|
|
|
* NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.hh)
|
2009-01-28 06:32:47 +00:00
|
|
|
*/
|
2013-03-22 05:46:39 +00:00
|
|
|
enum eGraphKeys_Snap_Mode {
|
2009-01-28 06:32:47 +00:00
|
|
|
GRAPHKEYS_SNAP_CFRA = 1,
|
|
|
|
|
GRAPHKEYS_SNAP_NEAREST_FRAME,
|
|
|
|
|
GRAPHKEYS_SNAP_NEAREST_SECOND,
|
2012-10-21 05:46:41 +00:00
|
|
|
GRAPHKEYS_SNAP_NEAREST_MARKER,
|
2009-01-28 06:32:47 +00:00
|
|
|
GRAPHKEYS_SNAP_HORIZONTAL,
|
2009-10-20 12:04:56 +00:00
|
|
|
GRAPHKEYS_SNAP_VALUE,
|
2013-03-22 05:46:39 +00:00
|
|
|
};
|
2009-01-28 06:32:47 +00:00
|
|
|
|
2022-01-25 11:40:46 +01:00
|
|
|
/* Defines for equalize keyframe handles.
|
2023-08-05 02:57:52 +02:00
|
|
|
* NOTE: Keep in sync with eEditKeyframes_Equalize (in ED_keyframes_edit.hh).
|
2022-01-25 11:40:46 +01:00
|
|
|
*/
|
|
|
|
|
enum eGraphKeys_Equalize_Mode {
|
|
|
|
|
GRAPHKEYS_EQUALIZE_LEFT = 1,
|
|
|
|
|
GRAPHKEYS_EQUALIZE_RIGHT,
|
|
|
|
|
GRAPHKEYS_EQUALIZE_BOTH,
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
/* defines for mirror keyframes
|
2023-08-05 02:57:52 +02:00
|
|
|
* NOTE: keep in sync with eEditKeyframes_Mirror (in ED_keyframes_edit.hh)
|
2009-01-28 06:32:47 +00:00
|
|
|
*/
|
2013-03-22 05:46:39 +00:00
|
|
|
enum eGraphKeys_Mirror_Mode {
|
2009-01-28 06:32:47 +00:00
|
|
|
GRAPHKEYS_MIRROR_CFRA = 1,
|
|
|
|
|
GRAPHKEYS_MIRROR_YAXIS,
|
|
|
|
|
GRAPHKEYS_MIRROR_XAXIS,
|
|
|
|
|
GRAPHKEYS_MIRROR_MARKER,
|
2009-10-22 09:07:19 +00:00
|
|
|
GRAPHKEYS_MIRROR_VALUE,
|
2013-03-22 05:46:39 +00:00
|
|
|
};
|
2009-01-28 06:32:47 +00:00
|
|
|
|
2009-03-15 10:39:02 +00:00
|
|
|
/* ----------- */
|
|
|
|
|
|
2024-03-26 20:48:05 -04:00
|
|
|
void GRAPH_OT_fmodifier_add(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_fmodifier_copy(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_fmodifier_paste(wmOperatorType *ot);
|
2009-03-15 10:39:02 +00:00
|
|
|
|
2009-04-08 01:07:46 +00:00
|
|
|
/* ----------- */
|
|
|
|
|
|
2024-03-26 20:48:05 -04:00
|
|
|
void GRAPH_OT_driver_variables_copy(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_driver_variables_paste(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_driver_delete_invalid(wmOperatorType *ot);
|
2016-04-15 20:04:07 +12:00
|
|
|
|
|
|
|
|
/* ----------- */
|
|
|
|
|
|
2024-03-26 20:48:05 -04:00
|
|
|
void GRAPH_OT_ghost_curves_create(wmOperatorType *ot);
|
|
|
|
|
void GRAPH_OT_ghost_curves_clear(wmOperatorType *ot);
|
2009-04-08 01:07:46 +00:00
|
|
|
|
2009-01-27 05:04:23 +00:00
|
|
|
/* ***************************************** */
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `graph_buttons.cc` */
|
2010-04-05 11:47:55 +00:00
|
|
|
|
2024-03-26 20:48:05 -04:00
|
|
|
void graph_buttons_register(ARegionType *art);
|
2009-02-20 19:11:35 +00:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
/* ***************************************** */
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `graph_utils.cc` */
|
2009-07-02 01:01:18 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Find 'active' F-Curve.
|
|
|
|
|
* It must be editable, since that's the purpose of these buttons (subject to change).
|
|
|
|
|
* We return the 'wrapper' since it contains valuable context info (about hierarchy),
|
|
|
|
|
* which will need to be freed when the caller is done with it.
|
|
|
|
|
*
|
|
|
|
|
* \note curve-visible flag isn't included,
|
|
|
|
|
* otherwise selecting a curve via list to edit is too cumbersome.
|
|
|
|
|
*/
|
2024-03-26 20:48:05 -04:00
|
|
|
bAnimListElem *get_active_fcurve_channel(bAnimContext *ac);
|
2009-03-15 10:39:02 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Check if there are any visible keyframes (for selection tools).
|
|
|
|
|
*/
|
2024-03-26 20:48:05 -04:00
|
|
|
bool graphop_visible_keyframes_poll(bContext *C);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Check if there are any visible + editable keyframes (for editing tools).
|
|
|
|
|
*/
|
2024-03-26 20:48:05 -04:00
|
|
|
bool graphop_editable_keyframes_poll(bContext *C);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Has active F-Curve that's editable.
|
|
|
|
|
*/
|
2024-03-26 20:48:05 -04:00
|
|
|
bool graphop_active_fcurve_poll(bContext *C);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Has active F-Curve in the context that's editable.
|
|
|
|
|
*/
|
2024-03-26 20:48:05 -04:00
|
|
|
bool graphop_active_editable_fcurve_ctx_poll(bContext *C);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Has selected F-Curve that's editable.
|
|
|
|
|
*/
|
2024-03-26 20:48:05 -04:00
|
|
|
bool graphop_selected_fcurve_poll(bContext *C);
|
2009-07-02 01:01:18 +00:00
|
|
|
|
2009-02-20 19:11:35 +00:00
|
|
|
/* ***************************************** */
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `graph_ops.cc` */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2024-03-26 20:48:05 -04:00
|
|
|
void graphedit_keymap(wmKeyConfig *keyconf);
|
|
|
|
|
void graphedit_operatortypes();
|