[Bf-blender-cvs] [d8c719d8d81] blender2.8: Replace old Timelines and Logic Editors with new Dopesheet (Timeline mode)

Julian Eisel noreply at git.blender.org
Mon Apr 23 00:26:08 CEST 2018


Commit: d8c719d8d8149de2d49a441b7ea6337538a7a1e8
Author: Julian Eisel
Date:   Sun Apr 22 23:57:19 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBd8c719d8d8149de2d49a441b7ea6337538a7a1e8

Replace old Timelines and Logic Editors with new Dopesheet (Timeline mode)

Timelines and Logic Editors are gone. So far they were simply replaced by broken
Info Editors, now they are replaced by Dopesheets in the new Timeline mode.

We reuse ScrArea.butspacetype to temporarily store the space-type identifier of
the deprecated editor (see 9db492de6dd07). That way we can identify it in
versioning code and replace it nicely.
Action editor creation needs a scene to set the scrolling based on frame range.
Active screen-layouts use the active scene of the window they are displayed in.
Inactive screens simply use the first scene in the main data base.
Note that inactive editors don't need version patching, readfile.c converts them
to SPACE_EMPTY already, so users can't activate them.

Files saved since the editors were removed will still be broken.
Workspace config files saved before this will also crash (will update default
one in followup commit).

===================================================================

M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/makesdna/DNA_screen_types.h

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 19f260fb3a7..e8c96cb7d1b 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6402,6 +6402,7 @@ static void direct_link_area(FileData *fd, ScrArea *area)
 	/* if we do not have the spacetype registered we cannot
 	 * free it, so don't allocate any new memory for such spacetypes. */
 	if (!BKE_spacetype_exists(area->spacetype)) {
+		area->butspacetype = area->spacetype; /* Hint for versioning code to replace deprecated space types. */
 		area->spacetype = SPACE_EMPTY;
 	}
 
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index ff4a0351a7b..661b7b53260 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -112,6 +112,31 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
 	}
 }
 
+static void do_version_area_change_space_to_space_action(ScrArea *area, const Scene *scene)
+{
+	SpaceType *stype = BKE_spacetype_from_id(SPACE_ACTION);
+	SpaceAction *saction = (SpaceAction *)stype->new(area, scene);
+	ARegion *region_channels;
+
+	/* Properly free current regions */
+	for (ARegion *region = area->regionbase.first; region; region = region->next) {
+		BKE_area_region_free(area->type, region);
+	}
+	BLI_freelistN(&area->regionbase);
+
+	area->type = stype;
+	area->spacetype = stype->spaceid;
+
+	BLI_addhead(&area->spacedata, saction);
+	area->regionbase = saction->regionbase;
+	BLI_listbase_clear(&saction->regionbase);
+
+	/* Different defaults for timeline */
+	region_channels = BKE_area_find_region_type(area, RGN_TYPE_CHANNELS);
+	region_channels->flag |= RGN_FLAG_HIDDEN;
+	saction->mode = SACTCONT_TIMELINE;
+}
+
 /**
  * \brief After lib-link versioning for new workspace design.
  *
@@ -625,6 +650,40 @@ void do_versions_after_linking_280(Main *main)
 			}
 		}
 	}
+
+	/* SpaceTime & SpaceLogic removal/replacing */
+	if (!MAIN_VERSION_ATLEAST(main, 280, 9)) {
+		const wmWindowManager *wm = main->wm.first;
+		const Scene *scene = main->scene.first;
+
+		/* Action editors need a scene for creation. First, update active
+		 * screens using the active scene of the window they're displayed in.
+		 * Next, update remaining screens using first scene in main listbase. */
+
+		for (wmWindow *win = wm->windows.first; win; win = win->next) {
+			const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
+			for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+				if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) {
+					do_version_area_change_space_to_space_action(area, win->scene);
+
+					/* Don't forget to unset! */
+					area->butspacetype = SPACE_EMPTY;
+				}
+			}
+		}
+
+		for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+			for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+				if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) {
+					/* Areas that were already handled won't be handled again */
+					do_version_area_change_space_to_space_action(area, scene);
+
+					/* Don't forget to unset! */
+					area->butspacetype = SPACE_EMPTY;
+				}
+			}
+		}
+	}
 }
 
 static void do_version_layer_collections_idproperties(ListBase *lb)
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 1d0fbf36912..73a9beb7ab5 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -253,7 +253,8 @@ typedef struct ScrArea {
 
 	char spacetype;     /* eSpace_Type (SPACE_FOO) */
 	/* Temporarily used while switching area type, otherwise this should be
-	 * SPACE_EMPTY. It's been there for ages, name doesn't fit any more. */
+	 * SPACE_EMPTY. Also, versioning uses it to nicely replace deprecated
+	 * editors. It's been there for ages, name doesn't fit any more... */
 	char butspacetype;  /* eSpace_Type (SPACE_FOO) */
 
 	short winx, winy;				/* size */



More information about the Bf-blender-cvs mailing list