Replace old Timelines and Logic Editors with new Dopesheet (Timeline mode)
authorJulian Eisel <eiseljulian@gmail.com>
Sun, 22 Apr 2018 21:57:19 +0000 (23:57 +0200)
committerJulian Eisel <eiseljulian@gmail.com>
Sun, 22 Apr 2018 22:12:26 +0000 (00:12 +0200)
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).

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

index 19f260fb3a77ef2c7320198b857688857feb7c7f..e8c96cb7d1b650fa90a4fc80bc2f3da5d1871841 100644 (file)
@@ -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;
        }
 
index ff4a0351a7bd752a32ef04b7c36998d2b4774780..661b7b53260bfa529a63ea7b93b4c5f2b7c95edf 100644 (file)
@@ -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)
index 1d0fbf36912052409b4477341cc25b12d8e876ea..73a9beb7ab5e014ee9bd424de7249d6e94a32c12 100644 (file)
@@ -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 */