From 808b03da437043d7bb809a4d0e9e523bbfad95f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Wed, 28 Sep 2022 11:52:22 +0200 Subject: Cleanup: decentralize .blend I/O for space types This adds callbacks to `SpaceType` to make each editor responsible to manage their own .blend I/O, and moves relevant code from `screen.c` to the editors files. Differential Revision: D11069 --- source/blender/editors/space_nla/CMakeLists.txt | 6 ++++- source/blender/editors/space_nla/space_nla.c | 32 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/CMakeLists.txt b/source/blender/editors/space_nla/CMakeLists.txt index e6995085dbe..5df0ebb3b28 100644 --- a/source/blender/editors/space_nla/CMakeLists.txt +++ b/source/blender/editors/space_nla/CMakeLists.txt @@ -4,6 +4,7 @@ set(INC ../include ../../blenkernel ../../blenlib + ../../blenloader ../../blentranslation ../../depsgraph ../../gpu @@ -11,6 +12,9 @@ set(INC ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + + # dna_type_offsets.h + ${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern # RNA_prototypes.h ${CMAKE_BINARY_DIR}/source/blender/makesrna ) @@ -36,5 +40,5 @@ set(LIB blender_add_lib(bf_editor_space_nla "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") -# RNA_prototypes.h +# RNA_prototypes.h dna_type_offsets.h add_dependencies(bf_editor_space_nla bf_rna) diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index e658ddef513..12f8915764b 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -36,6 +36,8 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "BLO_read_write.h" + #include "nla_intern.h" /* own include */ /* ******************** default callbacks for nla space ***************** */ @@ -562,6 +564,33 @@ static void nla_id_remap(ScrArea *UNUSED(area), BKE_id_remapper_apply(mappings, (ID **)&snla->ads->source, ID_REMAP_APPLY_DEFAULT); } +static void nla_blend_read_data(BlendDataReader *reader, SpaceLink *sl) +{ + SpaceNla *snla = (SpaceNla *)sl; + BLO_read_data_address(reader, &snla->ads); +} + +static void nla_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl) +{ + SpaceNla *snla = (SpaceNla *)sl; + bDopeSheet *ads = snla->ads; + + if (ads) { + BLO_read_id_address(reader, parent_id->lib, &ads->source); + BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp); + } +} + +static void nla_blend_write(BlendWriter *writer, SpaceLink *sl) +{ + SpaceNla *snla = (SpaceNla *)sl; + + BLO_write_struct(writer, SpaceNla, snla); + if (snla->ads) { + BLO_write_struct(writer, bDopeSheet, snla->ads); + } +} + void ED_spacetype_nla(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype nla"); @@ -578,6 +607,9 @@ void ED_spacetype_nla(void) st->listener = nla_listener; st->keymap = nla_keymap; st->id_remap = nla_id_remap; + st->blend_read_data = nla_blend_read_data; + st->blend_read_lib = nla_blend_read_lib; + st->blend_write = nla_blend_write; /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype nla region"); -- cgit v1.2.3