Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2022-09-28 12:52:22 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2022-09-28 12:52:22 +0300
commit808b03da437043d7bb809a4d0e9e523bbfad95f9 (patch)
tree4a3ef1f74b09328b2e97bf827fa1fc700a9e2e41 /source/blender/editors/space_nla
parent5270ac5ed87fb5f9b5605fdc332f16ea0f7ee59d (diff)
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
Diffstat (limited to 'source/blender/editors/space_nla')
-rw-r--r--source/blender/editors/space_nla/CMakeLists.txt6
-rw-r--r--source/blender/editors/space_nla/space_nla.c32
2 files changed, 37 insertions, 1 deletions
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");