diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-09-28 12:52:22 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-09-28 12:52:22 +0300 |
commit | 808b03da437043d7bb809a4d0e9e523bbfad95f9 (patch) | |
tree | 4a3ef1f74b09328b2e97bf827fa1fc700a9e2e41 /source/blender/editors/space_graph | |
parent | 5270ac5ed87fb5f9b5605fdc332f16ea0f7ee59d (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_graph')
-rw-r--r-- | source/blender/editors/space_graph/CMakeLists.txt | 6 | ||||
-rw-r--r-- | source/blender/editors/space_graph/space_graph.c | 41 |
2 files changed, 46 insertions, 1 deletions
diff --git a/source/blender/editors/space_graph/CMakeLists.txt b/source/blender/editors/space_graph/CMakeLists.txt index 39878debc39..f67434b0f6d 100644 --- a/source/blender/editors/space_graph/CMakeLists.txt +++ b/source/blender/editors/space_graph/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 ) @@ -50,5 +54,5 @@ endif() blender_add_lib(bf_editor_space_graph "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") -# RNA_prototypes.h +# RNA_prototypes.h dna_type_offsets.h add_dependencies(bf_editor_space_graph bf_rna) diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 75c1e958e32..fa2029db835 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -45,6 +45,8 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "BLO_read_write.h" + #include "graph_intern.h" /* own include */ /* ******************** default callbacks for ipo space ***************** */ @@ -804,6 +806,42 @@ static void graph_space_subtype_item_extend(bContext *UNUSED(C), RNA_enum_items_add(item, totitem, rna_enum_space_graph_mode_items); } +static void graph_blend_read_data(BlendDataReader *reader, SpaceLink *sl) +{ + SpaceGraph *sipo = (SpaceGraph *)sl; + + BLO_read_data_address(reader, &sipo->ads); + memset(&sipo->runtime, 0x0, sizeof(sipo->runtime)); +} + +static void graph_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl) +{ + SpaceGraph *sipo = (SpaceGraph *)sl; + bDopeSheet *ads = sipo->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 graph_blend_write(BlendWriter *writer, SpaceLink *sl) +{ + SpaceGraph *sipo = (SpaceGraph *)sl; + ListBase tmpGhosts = sipo->runtime.ghost_curves; + + /* temporarily disable ghost curves when saving */ + BLI_listbase_clear(&sipo->runtime.ghost_curves); + + BLO_write_struct(writer, SpaceGraph, sl); + if (sipo->ads) { + BLO_write_struct(writer, bDopeSheet, sipo->ads); + } + + /* reenable ghost curves */ + sipo->runtime.ghost_curves = tmpGhosts; +} + void ED_spacetype_ipo(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype ipo"); @@ -824,6 +862,9 @@ void ED_spacetype_ipo(void) st->space_subtype_item_extend = graph_space_subtype_item_extend; st->space_subtype_get = graph_space_subtype_get; st->space_subtype_set = graph_space_subtype_set; + st->blend_read_data = graph_blend_read_data; + st->blend_read_lib = graph_blend_read_lib; + st->blend_write = graph_blend_write; /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); |