Workspaces: move 2D Animation, VFX and Video workspaces into own templates.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 12 Sep 2018 09:28:49 +0000 (11:28 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 18 Sep 2018 17:38:20 +0000 (19:38 +0200)
These can now be acessed from the File > New, Ctrl+N, or the splash screen.
Since these are application templates, users can save a separate startup.blend
for each. User preferences are shared between these templates though.

This also fixes some issues in the default startup.blend (triangulated cube..).

Differential Revision: https://developer.blender.org/D3690

release/datafiles/startup.blend
release/scripts/startup/bl_app_templates_system/2D_Animation/startup.blend [new file with mode: 0644]
release/scripts/startup/bl_app_templates_system/VFX/startup.blend [new file with mode: 0644]
release/scripts/startup/bl_app_templates_system/Video_Editing/startup.blend [new file with mode: 0644]
source/blender/blenkernel/intern/blendfile.c
source/blender/blenloader/BLO_readfile.h
source/blender/blenloader/intern/versioning_defaults.c
source/blender/windowmanager/intern/wm_files.c

index 945747384718ddbbd08edcbfc22deaff6a7b38c2..8caec075138449519d326a988049172d789a8d42 100644 (file)
Binary files a/release/datafiles/startup.blend and b/release/datafiles/startup.blend differ
diff --git a/release/scripts/startup/bl_app_templates_system/2D_Animation/startup.blend b/release/scripts/startup/bl_app_templates_system/2D_Animation/startup.blend
new file mode 100644 (file)
index 0000000..8f04057
Binary files /dev/null and b/release/scripts/startup/bl_app_templates_system/2D_Animation/startup.blend differ
diff --git a/release/scripts/startup/bl_app_templates_system/VFX/startup.blend b/release/scripts/startup/bl_app_templates_system/VFX/startup.blend
new file mode 100644 (file)
index 0000000..c2cef4e
Binary files /dev/null and b/release/scripts/startup/bl_app_templates_system/VFX/startup.blend differ
diff --git a/release/scripts/startup/bl_app_templates_system/Video_Editing/startup.blend b/release/scripts/startup/bl_app_templates_system/Video_Editing/startup.blend
new file mode 100644 (file)
index 0000000..84c3c66
Binary files /dev/null and b/release/scripts/startup/bl_app_templates_system/Video_Editing/startup.blend differ
index abefff5e72b9f77b37c4a0b725632f426de5a632..6fc11e367b55336d4f944a9cb08b5712e96190dd 100644 (file)
@@ -417,7 +417,7 @@ bool BKE_blendfile_read_from_memory(
        bfd = BLO_read_from_memory(filebuf, filelength, reports, skip_flags);
        if (bfd) {
                if (update_defaults)
-                       BLO_update_defaults_startup_blend(bfd->main);
+                       BLO_update_defaults_startup_blend(bfd->main, NULL);
                setup_app_data(C, bfd, "<memory2>", reports);
        }
        else {
index c9deb6288886f7517920537c54d8f8f2f64ca094..ef02e7d7034e840dc4d520b7fbc7a3c81a34787a 100644 (file)
@@ -156,7 +156,7 @@ void BLO_expand_main(void *fdhandle, struct Main *mainvar);
 
 /* Update defaults in startup.blend & userprefs.blend, without having to save and embed it */
 void BLO_update_defaults_userpref_blend(void);
-void BLO_update_defaults_startup_blend(struct Main *mainvar);
+void BLO_update_defaults_startup_blend(struct Main *mainvar, const char *app_template);
 
 /* Version patch user preferences. */
 void BLO_version_defaults_userpref_blend(struct Main *mainvar, struct UserDef *userdef);
index abbc8f4c4a4e076e626f9ff804849b1f2fb89dc1..d783d1d54f48ddaf7bcba24bb51b26420e619a8b 100644 (file)
@@ -74,54 +74,9 @@ void BLO_update_defaults_userpref_blend(void)
 /**
  * Update defaults in startup.blend, without having to save and embed the file.
  * This function can be emptied each time the startup.blend is updated. */
-void BLO_update_defaults_startup_blend(Main *bmain)
+void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
 {
-       for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
-               const char *name = workspace->id.name + 2;
-
-               if (STREQ(name, "Modeling")) {
-                       workspace->order = 0;
-               }
-               else if (STREQ(name, "Sculpting")) {
-                       workspace->object_mode = OB_MODE_SCULPT;
-                       workspace->order = 1;
-               }
-               else if (STREQ(name, "UV Editing")) {
-                       workspace->object_mode = OB_MODE_EDIT;
-                       workspace->order = 2;
-               }
-               else if (STREQ(name, "Texture Paint")) {
-                       workspace->object_mode = OB_MODE_TEXTURE_PAINT;
-                       workspace->order = 3;
-               }
-               else if (STREQ(name, "Shading")) {
-                       workspace->order = 4;
-               }
-               else if (STREQ(name, "3D Animation")) {
-                       workspace->object_mode = OB_MODE_POSE;
-                       workspace->order = 5;
-               }
-               else if (STREQ(name, "Rendering")) {
-                       workspace->order = 6;
-               }
-               else if (STREQ(name, "Compositing")) {
-                       workspace->order = 7;
-               }
-               else if (STREQ(name, "2D Animation")) {
-                       workspace->object_mode = OB_MODE_GPENCIL_PAINT;
-                       workspace->order = 8;
-               }
-               else if (STREQ(name, "Video Editing")) {
-                       workspace->order = 9;
-               }
-               else if (STREQ(name, "Motion Tracking")) {
-                       workspace->order = 10;
-               }
-               else if (STREQ(name, "Scripting")) {
-                       workspace->order = 11;
-               }
-       }
-
+       /* For all startup.blend files. */
        for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
                for (ScrArea *area = screen->areabase.first; area; area = area->next) {
                        for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
@@ -134,53 +89,43 @@ void BLO_update_defaults_startup_blend(Main *bmain)
                                        ar->v2d.flag &= ~V2D_IS_INITIALISED;
                                }
                        }
-
-                       if (area->spacetype == SPACE_FILE) {
-                               SpaceFile *sfile = area->spacedata.first;
-
-                               if (sfile->params) {
-                                       if (STREQ(screen->id.name, "SRDefault.003")) {
-                                               /* Shading. */
-                                               sfile->params->filter = FILE_TYPE_FOLDER |
-                                                                       FILE_TYPE_IMAGE;
-                                       }
-                                       else {
-                                               /* Video Editing. */
-                                               sfile->params->filter = FILE_TYPE_FOLDER |
-                                                                       FILE_TYPE_IMAGE |
-                                                                       FILE_TYPE_MOVIE |
-                                                                       FILE_TYPE_SOUND;
-                                       }
-                               }
-                       }
                }
        }
 
-       for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
-               BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
+       /* For 2D animation template. */
+       if (app_template && STREQ(app_template, "2D Animation")) {
+               for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
+                       const char *name = workspace->id.name + 2;
 
-               scene->r.cfra = 1.0f;
-
-               /* Don't enable compositing nodes. */
-               if (scene->nodetree) {
-                       ntreeFreeTree(scene->nodetree);
-                       MEM_freeN(scene->nodetree);
-                       scene->nodetree = NULL;
-                       scene->use_nodes = false;
+                       if (STREQ(name, "Drawing")) {
+                               workspace->object_mode = OB_MODE_GPENCIL_PAINT;
+                       }
                }
+       }
 
-               /* Select only cube by default. */
-               for (ViewLayer *layer = scene->view_layers.first; layer; layer = layer->next) {
-                       for (Base *base = layer->object_bases.first; base; base = base->next) {
-                               if (STREQ(base->object->id.name + 2, "Cube")) {
-                                       base->flag |= BASE_SELECTED;
-                               }
-                               else {
-                                       base->flag &= ~BASE_SELECTED;
-                               }
+       /* For all builtin templates shipped with Blender. */
+       bool builtin_template = !app_template ||
+                               STREQ(app_template, "2D_Animation") ||
+                               STREQ(app_template, "VFX") ||
+                               STREQ(app_template, "Video_Editing");
+
+       if (builtin_template) {
+               for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+                       BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
+
+                       scene->r.cfra = 1.0f;
+                       scene->r.displaymode = R_OUTPUT_WINDOW;
+
+                       /* Don't enable compositing nodes. */
+                       if (scene->nodetree) {
+                               ntreeFreeTree(scene->nodetree);
+                               MEM_freeN(scene->nodetree);
+                               scene->nodetree = NULL;
+                               scene->use_nodes = false;
                        }
 
-                       BKE_layer_collection_sync(scene, layer);
+                       /* Rename render layers. */
+                       BKE_view_layer_rename(bmain, scene, scene->view_layers.first, "View Layer");
                }
        }
 }
index 7883b2aded6ffd5c8c6f4615fa61953052da414c..336004a516b2dea0f5c96418427b3b6aebcdfd8f 100644 (file)
@@ -809,6 +809,7 @@ int wm_homefile_read(
        }
 
        const char *app_template = NULL;
+       bool update_defaults = false;
 
        if (filepath_startup_override != NULL) {
                /* pass */
@@ -844,6 +845,9 @@ int wm_homefile_read(
 
                if (filepath_startup[0] == '\0') {
                        BLI_path_join(filepath_startup, sizeof(filepath_startup), app_template_system, BLENDER_STARTUP_FILE, NULL);
+
+                       /* Update defaults only for system templates. */
+                       update_defaults = true;
                }
        }
 
@@ -856,6 +860,9 @@ int wm_homefile_read(
                                printf("\nNote: No (valid) '%s' found, fall back to built-in default.\n\n", filepath_startup);
                        success = false;
                }
+               if (success && update_defaults) {
+                       BLO_update_defaults_startup_blend(CTX_data_main(C), app_template);
+               }
        }
 
        if (success == false && filepath_startup_override && reports) {