diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-09-12 12:28:49 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-09-18 20:38:20 +0300 |
commit | 1c815e0826518adc69bc3888e18f52991e8774f7 (patch) | |
tree | e82f0ee122f9fa56be40e015069836b3d33dd73d /source | |
parent | 84f21c170dda9e503de440c20bc2753002987901 (diff) |
Workspaces: move 2D Animation, VFX and Video workspaces into own templates.
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
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/blendfile.c | 2 | ||||
-rw-r--r-- | source/blender/blenloader/BLO_readfile.h | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_defaults.c | 117 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 7 |
4 files changed, 40 insertions, 88 deletions
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index abefff5e72b..6fc11e367b5 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -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 { diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index c9deb628888..ef02e7d7034 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -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); diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index abbc8f4c4a4..d783d1d54f4 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -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"); } } } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 7883b2aded6..336004a516b 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -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) { |