Refactor: Add function to query editable Graph Editor curves
No functional changes intended. This patch extracts functionality to get all `bAnimListElem` that are editable in the Graph Editor into a separate function so it can be re-used by other operators. This makes it easy to ensure the same data is retrieved and filter flags can't go out of sync. Extracted from #135913 Part of: #135794 Pull Request: https://projects.blender.org/blender/blender/pulls/137142
This commit is contained in:
committed by
Christoph Lendenfeld
parent
6faef7b149
commit
145af8d45b
@@ -22,9 +22,11 @@ set(SRC
|
||||
graph_slider_ops.cc
|
||||
graph_utils.cc
|
||||
graph_view.cc
|
||||
graph_query.cc
|
||||
space_graph.cc
|
||||
|
||||
graph_intern.hh
|
||||
ED_space_graph.hh
|
||||
)
|
||||
|
||||
set(LIB
|
||||
|
||||
21
source/blender/editors/space_graph/ED_space_graph.hh
Normal file
21
source/blender/editors/space_graph/ED_space_graph.hh
Normal file
@@ -0,0 +1,21 @@
|
||||
/* SPDX-FileCopyrightText: 2025 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
struct bAnimContext;
|
||||
struct ListBase;
|
||||
|
||||
namespace blender::ed::graph {
|
||||
|
||||
/**
|
||||
* Return all bAnimListElem for which the keyframes are visible in the
|
||||
* GUI. This excludes FCurves that are drawn as curves but whose keyframes are NOT shown.
|
||||
* All entries of the list will be of type ANIMTYPE_FCURVE.
|
||||
*
|
||||
* The listbase will have to be freed by the caller with ANIM_animdata_freelist;
|
||||
*/
|
||||
ListBase get_editable_fcurves(bAnimContext &ac);
|
||||
|
||||
} // namespace blender::ed::graph
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "ED_keyframing.hh"
|
||||
#include "ED_markers.hh"
|
||||
#include "ED_screen.hh"
|
||||
#include "ED_space_graph.hh"
|
||||
#include "ED_transform.hh"
|
||||
|
||||
#include "WM_api.hh"
|
||||
@@ -2274,15 +2275,11 @@ static wmOperatorStatus keyframe_jump_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
ListBase anim_data = {nullptr, nullptr};
|
||||
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
|
||||
ANIMFILTER_NODUPLIS);
|
||||
if (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) {
|
||||
filter |= ANIMFILTER_SEL;
|
||||
}
|
||||
ListBase anim_data = blender::ed::graph::get_editable_fcurves(ac);
|
||||
|
||||
ANIM_animdata_filter(
|
||||
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
|
||||
if (BLI_listbase_is_empty(&anim_data)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
float closest_frame = next ? FLT_MAX : -FLT_MAX;
|
||||
bool found = false;
|
||||
@@ -2323,7 +2320,7 @@ static wmOperatorStatus keyframe_jump_exec(bContext *C, wmOperator *op)
|
||||
DEG_id_tag_update(&scene->id, ID_RECALC_FRAME_CHANGE);
|
||||
|
||||
/* Set notifier that things have changed. */
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
||||
24
source/blender/editors/space_graph/graph_query.cc
Normal file
24
source/blender/editors/space_graph/graph_query.cc
Normal file
@@ -0,0 +1,24 @@
|
||||
/* SPDX-FileCopyrightText: 2025 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#include "ED_anim_api.hh"
|
||||
#include "ED_space_graph.hh"
|
||||
|
||||
namespace blender::ed::graph {
|
||||
|
||||
ListBase get_editable_fcurves(bAnimContext &ac)
|
||||
{
|
||||
ListBase anim_data = {nullptr, nullptr};
|
||||
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE |
|
||||
ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS);
|
||||
if (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) {
|
||||
filter |= ANIMFILTER_SEL;
|
||||
}
|
||||
|
||||
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
|
||||
return anim_data;
|
||||
}
|
||||
|
||||
} // namespace blender::ed::graph
|
||||
Reference in New Issue
Block a user