Fix #139572: Grease Pencil: Support pasting strokes into multiple frames

When multi-frame editing is enabled, users would expect to be able to
paste strokes into multiple selected frames. This PR supports this by
using `retrieve_editable_drawings` instead of `get_editable_drawing_at`
to achieve such feature.

Pull Request: https://projects.blender.org/blender/blender/pulls/139573
This commit is contained in:
YimingWu 2025-06-02 16:44:25 +02:00 committed by YimingWu
parent 0034b6cf3e
commit 48f49deaa8

View File

@ -2711,12 +2711,13 @@ static wmOperatorStatus grease_pencil_paste_strokes_exec(bContext *C, wmOperator
return OPERATOR_CANCELLED;
}
bke::greasepencil::Drawing *target_drawing = grease_pencil.get_editable_drawing_at(
*active_layer, scene.r.cfra);
BLI_assert(target_drawing != nullptr);
paste_all_strokes_from_clipboard(
*bmain, *object, object_to_layer, keep_world_transform, paste_on_back, *target_drawing);
Vector<MutableDrawingInfo> drawing_infos =
ed::greasepencil::retrieve_editable_drawings_from_layer(
scene, grease_pencil, *active_layer);
for (const MutableDrawingInfo info : drawing_infos) {
paste_all_strokes_from_clipboard(
*bmain, *object, object_to_layer, keep_world_transform, paste_on_back, info.drawing);
}
if (inserted_keyframe) {
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, nullptr);
@ -2776,18 +2777,19 @@ static wmOperatorStatus grease_pencil_paste_strokes_exec(bContext *C, wmOperator
return OPERATOR_CANCELLED;
}
bke::greasepencil::Drawing *target_drawing = grease_pencil.get_editable_drawing_at(
paste_layer, scene.r.cfra);
BLI_assert(target_drawing != nullptr);
clipboard_paste_strokes_ex(*bmain,
*object,
curves_to_paste,
object_to_paste_layer,
clipboard.object_to_world,
keep_world_transform,
paste_on_back,
*target_drawing);
Vector<MutableDrawingInfo> drawing_infos =
ed::greasepencil::retrieve_editable_drawings_from_layer(
scene, grease_pencil, paste_layer);
for (const MutableDrawingInfo info : drawing_infos) {
clipboard_paste_strokes_ex(*bmain,
*object,
curves_to_paste,
object_to_paste_layer,
clipboard.object_to_world,
keep_world_transform,
paste_on_back,
info.drawing);
}
if (inserted_keyframe) {
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, nullptr);