Animation: Move Graph Editor settings to User Preferences #104532

Merged
Christoph Lendenfeld merged 14 commits from ChrisLend/blender:user_pref_only_selected_keys into main 2023-03-09 14:15:36 +01:00
12 changed files with 54 additions and 50 deletions
Showing only changes of commit 1cf11c75f7 - Show all commits

@ -1 +1 @@
Subproject commit d887a4ea6b2a9d64b926034d4e78ecf7a48ca979
Subproject commit 9958ddb879934718cc2b379b556f0bc3b861bee5

View File

@ -116,8 +116,7 @@ class GRAPH_MT_view(Menu):
layout.prop(st, "show_handles")
layout.prop(st, "use_only_selected_curves_handles")
layout.prop(st, "use_only_selected_keyframe_handles")
# layout.prop(st, "use_only_selected_keyframe_handles")
layout.prop(st, "show_seconds")
layout.prop(st, "show_locked_time")

View File

@ -559,6 +559,8 @@ class USERPREF_PT_animation_fcurves(AnimationPanel, CenterAlignMixIn, Panel):
flow.prop(edit, "keyframe_new_handle_type", text="Default Handles")
flow.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
flow.prop(edit, "use_anim_channel_group_colors")
flow.prop(edit, "show_only_selected_curve_keyframes")
flow.prop(edit, "show_only_selected_keyframe_handles")
# -----------------------------------------------------------------------------

View File

@ -284,7 +284,7 @@ static bool graphedit_get_context(bAnimContext *ac, SpaceGraph *sipo)
ac->ads = sipo->ads;
/* set settings for Graph Editor - "Selected = Editable" */
if (sipo->flag & SIPO_SELCUVERTSONLY) {
if (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) {
sipo->ads->filterflag |= ADS_FILTER_SELEDIT;
}
else {

View File

@ -428,7 +428,7 @@ static void draw_fcurve_handles(SpaceGraph *sipo, FCurve *fcu)
/* if only selected keyframes can get their handles shown,
* check that keyframe is selected
*/
if (sipo->flag & SIPO_SELVHANDLESONLY) {
if (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_KEY_HANDLES) {
if (BEZT_ISSEL_ANY(bezt) == 0) {
continue;
}
@ -1117,7 +1117,8 @@ static void draw_fcurve(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, bAn
* - If the option to only show controls if the F-Curve is selected is enabled,
* we must obey this.
*/
if (!(sipo->flag & SIPO_SELCUVERTSONLY) || (fcu->flag & FCURVE_SELECTED)) {
if (!(U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) ||
(fcu->flag & FCURVE_SELECTED)) {
if (!BKE_fcurve_are_keyframes_usable(fcu) && !(fcu->fpt && fcu->totvert)) {
/* only draw controls if this is the active modifier */
if ((fcu->flag & FCURVE_ACTIVE) && (fcm)) {
@ -1151,7 +1152,10 @@ static void draw_fcurve(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, bAn
draw_fcurve_handles(sipo, fcu);
}
draw_fcurve_vertices(region, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY));
draw_fcurve_vertices(region,
fcu,
do_handles,
(U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_KEY_HANDLES));
}
else {
/* samples: only draw two indicators at either end as indicators */

View File

@ -83,7 +83,7 @@ static bool fcurve_handle_sel_check(SpaceGraph *sipo, BezTriple *bezt)
if (sipo->flag & SIPO_NOHANDLES) {
return false;
}
if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZT_ISSEL_ANY(bezt) == 0) {
if ((U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_KEY_HANDLES) && BEZT_ISSEL_ANY(bezt) == 0) {
return false;
}
return true;
@ -174,8 +174,9 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY);
if (sipo->flag &
SIPO_SELCUVERTSONLY) { /* FIXME: this should really be check for by the filtering code... */
if (U.animation_flag &
USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) { /* FIXME: this should really be check for by the
filtering code... */
filter |= ANIMFILTER_SEL;
}
mapping_flag |= ANIM_get_normalization_flags(ac);
@ -338,7 +339,6 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel
bAnimListElem *ale;
int filter;
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
KeyframeEditData ked = {{NULL}};
KeyframeEditFunc test_cb, sel_cb;
@ -376,7 +376,7 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel
if (do_channels) {
/* Only change selection of channel when the visibility of keyframes
* doesn't depend on this. */
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
if ((U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) == 0) {
/* deactivate the F-Curve, and deselect if deselecting keyframes.
* otherwise select the F-Curve too since we've selected all the keyframes
*/
@ -498,11 +498,11 @@ static rctf initialize_box_select_coords(const bAnimContext *ac, const rctf *rec
return rectf;
}
static int initialize_animdata_selection_filter(const SpaceGraph *sipo)
static int initialize_animdata_selection_filter(void)
{
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
if (sipo->flag & SIPO_SELCUVERTSONLY) {
if (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) {
filter |= ANIMFILTER_FOREDIT | ANIMFILTER_SELEDIT;
}
return filter;
@ -515,8 +515,7 @@ static ListBase initialize_box_select_anim_data(const int filter, bAnimContext *
return anim_data;
}
static void initialize_box_select_key_editing_data(const SpaceGraph *sipo,
const bool incl_handles,
static void initialize_box_select_key_editing_data(const bool incl_handles,
const short mode,
bAnimContext *ac,
void *data,
@ -543,7 +542,7 @@ static void initialize_box_select_key_editing_data(const SpaceGraph *sipo,
break;
}
if (sipo->flag & SIPO_SELVHANDLESONLY) {
if (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_KEY_HANDLES) {
r_ked->iterflags |= KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE;
}
@ -576,14 +575,13 @@ static bool box_select_graphkeys(bAnimContext *ac,
void *data)
{
const rctf rectf = initialize_box_select_coords(ac, rectf_view);
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
const int filter = initialize_animdata_selection_filter(sipo);
const int filter = initialize_animdata_selection_filter();
ListBase anim_data = initialize_box_select_anim_data(filter, ac);
rctf scaled_rectf;
KeyframeEditData ked;
int mapping_flag;
initialize_box_select_key_editing_data(
sipo, incl_handles, mode, ac, data, &scaled_rectf, &ked, &mapping_flag);
incl_handles, mode, ac, data, &scaled_rectf, &ked, &mapping_flag);
/* Get beztriple editing/validation functions. */
const KeyframeEditFunc select_cb = ANIM_editkeyframes_select(selectmode);
@ -635,7 +633,7 @@ static bool box_select_graphkeys(bAnimContext *ac,
any_key_selection_changed = true;
/* Only change selection of channel when the visibility of keyframes
* doesn't depend on this. */
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
if ((U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) == 0) {
/* select the curve too now that curve will be touched */
if (selectmode == SELECT_ADD) {
fcu->flag |= FCURVE_SELECTED;
@ -735,14 +733,13 @@ static void box_select_graphcurves(bAnimContext *ac,
const bool incl_handles,
void *data)
{
const SpaceGraph *sipo = (SpaceGraph *)ac->sl;
const int filter = initialize_animdata_selection_filter(sipo);
const int filter = initialize_animdata_selection_filter();
ListBase anim_data = initialize_box_select_anim_data(filter, ac);
rctf scaled_rectf;
KeyframeEditData ked;
int mapping_flag;
initialize_box_select_key_editing_data(
sipo, incl_handles, mode, ac, data, &scaled_rectf, &ked, &mapping_flag);
incl_handles, mode, ac, data, &scaled_rectf, &ked, &mapping_flag);
FCurve *last_selected_curve = NULL;
@ -955,7 +952,8 @@ static int graphkeys_lassoselect_exec(bContext *C, wmOperator *op)
{
SpaceGraph *sipo = (SpaceGraph *)ac.sl;
if (selectmode == SELECT_ADD) {
incl_handles = ((sipo->flag & SIPO_SELVHANDLESONLY) || (sipo->flag & SIPO_NOHANDLES)) == 0;
incl_handles = ((U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_KEY_HANDLES) ||
(sipo->flag & SIPO_NOHANDLES)) == 0;
}
else {
incl_handles = (sipo->flag & SIPO_NOHANDLES) == 0;
@ -1051,7 +1049,8 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op)
{
SpaceGraph *sipo = (SpaceGraph *)ac.sl;
if (selectmode == SELECT_ADD) {
incl_handles = ((sipo->flag & SIPO_SELVHANDLESONLY) || (sipo->flag & SIPO_NOHANDLES)) == 0;
incl_handles = ((U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_KEY_HANDLES) ||
(sipo->flag & SIPO_NOHANDLES)) == 0;
}
else {
incl_handles = (sipo->flag & SIPO_NOHANDLES) == 0;
@ -1709,7 +1708,7 @@ static int mouse_graph_keys(bAnimContext *ac,
/* Deselect other channels too, but only do this if selection of channel
* when the visibility of keyframes doesn't depend on this. */
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
if ((U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) == 0) {
ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
}
}
@ -1782,7 +1781,7 @@ static int mouse_graph_keys(bAnimContext *ac,
}
/* only change selection of channel when the visibility of keyframes doesn't depend on this */
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
if ((U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) == 0) {
/* select or deselect curve? */
if (bezt) {
/* take selection status from item that got hit, to prevent flip/flop on channel
@ -1808,8 +1807,8 @@ static int mouse_graph_keys(bAnimContext *ac,
}
/* Set active F-Curve when something was actually selected (so not on a deselect), except when
* dragging the selected keys. Needs to be called with (sipo->flag & SIPO_SELCUVERTSONLY),
* otherwise the active flag won't be set T26452. */
* dragging the selected keys. Needs to be called with (U.animation_flag &
* USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS), otherwise the active flag won't be set T26452. */
if (!run_modal && (nvi->fcu->flag & FCURVE_SELECTED) && something_was_selected) {
/* NOTE: Sync the filter flags with findnearest_fcurve_vert. */
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |

View File

@ -49,7 +49,6 @@ void get_graph_keyframe_extents(bAnimContext *ac,
const bool include_handles)
{
Scene *scene = ac->scene;
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
@ -58,7 +57,7 @@ void get_graph_keyframe_extents(bAnimContext *ac,
/* Get data to filter, from Dopesheet. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
if (sipo->flag & SIPO_SELCUVERTSONLY) {
if (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) {
filter |= ANIMFILTER_SEL;
}

View File

@ -68,7 +68,7 @@ static SpaceLink *graph_create(const ScrArea *UNUSED(area), const Scene *scene)
/* settings for making it easier by default to just see what you're interested in tweaking */
sipo->ads->filterflag |= ADS_FILTER_ONLYSEL;
sipo->flag |= SIPO_SELVHANDLESONLY | SIPO_SHOW_MARKERS;
sipo->flag |= SIPO_SHOW_MARKERS;
/* header */
region = MEM_callocN(sizeof(ARegion), "header for graphedit");

View File

@ -484,8 +484,6 @@ typedef enum eGraphEdit_Flag {
/* SIPO_NODRAWCFRANUM = (1 << 3), DEPRECATED */
/* show timing in seconds instead of frames */
SIPO_DRAWTIME = (1 << 4),
/* only show keyframes for selected F-Curves */
SIPO_SELCUVERTSONLY = (1 << 5),
/* draw names of F-Curves beside the respective curves */
/* NOTE: currently not used */
/* SIPO_DRAWNAMES = (1 << 6), */ /* UNUSED */
@ -493,8 +491,6 @@ typedef enum eGraphEdit_Flag {
SIPO_SLIDERS = (1 << 7),
/* don't show the horizontal component of the cursor */
SIPO_NODRAWCURSOR = (1 << 8),
/* only show handles of selected keyframes */
SIPO_SELVHANDLESONLY = (1 << 9),
/* don't perform realtime updates */
SIPO_NOREALTIMEUPDATES = (1 << 11),
/* don't draw curves with AA ("beauty-draw") for performance */

View File

@ -1213,6 +1213,8 @@ typedef enum eAutokey_Flag {
*/
typedef enum eUserpref_Anim_Flags {
USER_ANIM_SHOW_CHANNEL_GROUP_COLORS = (1 << 0),
USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS = (1 << 1),
USER_ANIM_ONLY_SHOW_SELECTED_KEY_HANDLES = (1 << 2),
} eUserpref_Anim_Flags;
/** #UserDef.transopts */

View File

@ -6297,19 +6297,6 @@ static void rna_def_space_graph(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Handles", "Show handles of Bezier control points");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
prop = RNA_def_property(srna, "use_only_selected_curves_handles", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_SELCUVERTSONLY);
RNA_def_property_ui_text(prop,
"Only Selected Curve Keyframes",
"Only keyframes of selected F-Curves are visible and editable");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
prop = RNA_def_property(srna, "use_only_selected_keyframe_handles", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_SELVHANDLESONLY);
RNA_def_property_ui_text(
prop, "Only Selected Keyframes Handles", "Only show and edit handles of selected keyframes");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
prop = RNA_def_property(srna, "use_beauty_drawing", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_BEAUTYDRAW_OFF);
RNA_def_property_ui_text(prop,

View File

@ -5132,6 +5132,22 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
"background of the Graph Editor");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
/* FCurve keyframe visibility. */
prop = RNA_def_property(srna, "show_only_selected_curve_keyframes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(
prop, NULL, "animation_flag", USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS);
RNA_def_property_ui_text(prop,
"Only Show Selected F-Curve Keyframes",
"Only keyframes of selected F-Curves are visible and editable");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
prop = RNA_def_property(srna, "show_only_selected_keyframe_handles", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "animation_flag", USER_ANIM_ONLY_SHOW_SELECTED_KEY_HANDLES);
RNA_def_property_ui_text(prop,
"Only Show Selected Keyframes Handles",
"Only show and edit handles of selected keyframes");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
/* grease pencil */
prop = RNA_def_property(srna, "grease_pencil_manhattan_distance", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "gp_manhattandist");