[Bf-blender-cvs] [fca739e] workspaces: Remove workspaces/screen-layouts from default startup.blend except of "Default" one
Julian Eisel
noreply at git.blender.org
Sat Dec 31 17:54:40 CET 2016
Commit: fca739e7317ca60a226b44e7f505c1953d237977
Author: Julian Eisel
Date: Sat Dec 31 17:38:24 2016 +0100
Branches: workspaces
https://developer.blender.org/rBfca739e7317ca60a226b44e7f505c1953d237977
Remove workspaces/screen-layouts from default startup.blend except of "Default" one
This means in the default startup.blend, there's only going to be one workspace and one screen-layout, both called "Default" (will be renamed to "General" though). Idea is that users will have the option add a pre-configured workspace from a menu. This avoids cluttering screen space with workspaces the user won't use even.
For compatibility, screen-layouts from old files are still converted to workspaces, this only affects the default startup.blend.
===================================================================
M source/blender/blenkernel/BKE_workspace.h
M source/blender/blenkernel/intern/workspace.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/versioning_270.c
M source/blender/blenloader/intern/versioning_defaults.c
M source/blender/blenloader/intern/writefile.c
M source/blender/editors/screen/workspace_edit.c
M source/blender/editors/screen/workspace_layout_edit.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h
index 400bf29..48591d8 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -39,6 +39,7 @@ typedef struct WorkSpaceLayout WorkSpaceLayout;
WorkSpace *BKE_workspace_add(Main *bmain, const char *name);
void BKE_workspace_free(WorkSpace *ws);
+void BKE_workspace_remove(WorkSpace *workspace, Main *bmain);
struct WorkSpaceLayout *BKE_workspace_layout_add(WorkSpace *workspace, struct bScreen *screen) ATTR_NONNULL();
void BKE_workspace_layout_remove(WorkSpace *workspace, WorkSpaceLayout *layout, Main *bmain) ATTR_NONNULL();
@@ -47,16 +48,21 @@ void BKE_workspace_layout_remove(WorkSpace *workspace, WorkSpaceLayout *layout,
/* -------------------------------------------------------------------- */
/* General Utils */
-#define BKE_workspace_iter(_workspace, _start_workspace) \
- for (WorkSpace *_workspace = _start_workspace; _workspace; _workspace = BKE_workspace_next_get(_workspace))
+#define BKE_workspace_iter_begin(_workspace, _start_workspace) \
+ for (WorkSpace *_workspace = _start_workspace, *_workspace##_next; _workspace; _workspace = _workspace##_next) { \
+ _workspace##_next = BKE_workspace_next_get(_workspace); /* support removing workspace from list */
+#define BKE_workspace_iter_end } (void)0
WorkSpaceLayout *BKE_workspace_layout_find(const WorkSpace *ws, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
WorkSpaceLayout *BKE_workspace_layout_find_exec(const WorkSpace *ws, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-#define BKE_workspace_layout_iter(_layout, _start_layout) \
- for (WorkSpaceLayout *_layout = _start_layout; _layout; _layout = BKE_workspace_layout_next_get(_layout))
-#define BKE_workspace_layout_iter_backwards(_layout, _start_layout) \
- for (WorkSpaceLayout *_layout = _start_layout; _layout; _layout = BKE_workspace_layout_prev_get(_layout))
+#define BKE_workspace_layout_iter_begin(_layout, _start_layout) \
+ for (WorkSpaceLayout *_layout = _start_layout, *_layout##_next; _layout; _layout = _layout##_next) { \
+ _layout##_next = BKE_workspace_layout_next_get(_layout); /* support removing layout from list */
+#define BKE_workspace_layout_iter_backwards_begin(_layout, _start_layout) \
+ for (WorkSpaceLayout *_layout = _start_layout, *_layout##_prev; _layout; _layout = _layout##_prev) {\
+ _layout##_prev = BKE_workspace_layout_prev_get(_layout); /* support removing layout from list */
+#define BKE_workspace_layout_iter_end } (void)0
WorkSpaceLayout *BKE_workspace_layout_iter_circular(const WorkSpace *workspace, WorkSpaceLayout *start,
bool (*callback)(const WorkSpaceLayout *layout, void *arg),
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index ea99842..5564e3a 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -55,6 +55,17 @@ void BKE_workspace_free(WorkSpace *ws)
BLI_freelistN(&ws->layouts);
}
+void BKE_workspace_remove(WorkSpace *workspace, Main *bmain)
+{
+ BKE_workspace_layout_iter_begin(layout, workspace->layouts.first)
+ {
+ BKE_workspace_layout_remove(workspace, layout, bmain);
+ }
+ BKE_workspace_layout_iter_end;
+
+ BKE_libblock_free(bmain, workspace);
+}
+
/**
* Add a new layout to \a workspace for \a screen.
@@ -73,8 +84,7 @@ WorkSpaceLayout *BKE_workspace_layout_add(WorkSpace *workspace, bScreen *screen)
void BKE_workspace_layout_remove(WorkSpace *workspace, WorkSpaceLayout *layout, Main *bmain)
{
BKE_libblock_free(bmain, BKE_workspace_layout_screen_get(layout));
- BLI_remlink(&workspace->layouts, layout);
- MEM_freeN(layout);
+ BLI_freelinkN(&workspace->layouts, layout);
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 73810b3..9ddc9a6 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2746,19 +2746,23 @@ static void lib_link_workspaces(FileData *fd, Main *bmain)
/* Note the NULL pointer checks for result of newlibadr. This is needed for reading old files from before the
* introduction of workspaces (in do_versioning code we already created workspaces for screens of old file). */
- BKE_workspace_iter(workspace, bmain->workspaces.first) {
+ BKE_workspace_iter_begin(workspace, bmain->workspaces.first)
+ {
ID *id = BKE_workspace_id_get(workspace);
ListBase *layouts = BKE_workspace_layouts_get(workspace);
id_us_ensure_real(id);
- BKE_workspace_layout_iter(layout, layouts->first) {
+ BKE_workspace_layout_iter_begin(layout, layouts->first)
+ {
bScreen *screen = newlibadr(fd, id->lib, BKE_workspace_layout_screen_get(layout));
if (screen) {
BKE_workspace_layout_screen_set(layout, screen);
}
}
+ BKE_workspace_layout_iter_end;
}
+ BKE_workspace_iter_end;
}
static void direct_link_workspace(FileData *fd, WorkSpace *ws)
@@ -6876,19 +6880,21 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main
*/
void blo_lib_link_restore(Main *newmain, wmWindowManager *curwm, Scene *curscene)
{
- wmWindow *win;
-
struct IDNameLib_Map *id_map = BKE_main_idmap_create(newmain);
- BKE_workspace_iter(workspace, newmain->workspaces.first) {
+ BKE_workspace_iter_begin(workspace, newmain->workspaces.first)
+ {
ListBase *layouts = BKE_workspace_layouts_get(workspace);
- BKE_workspace_layout_iter(layout, layouts->first) {
+ BKE_workspace_layout_iter_begin(layout, layouts->first)
+ {
lib_link_workspace_layout_restore(id_map, newmain, layout);
}
+ BKE_workspace_layout_iter_end;
}
+ BKE_workspace_iter_end;
- for (win = curwm->windows.first; win; win = win->next) {
+ for (wmWindow *win = curwm->windows.first; win; win = win->next) {
Scene *oldscene = win->scene;
WorkSpace *workspace = restore_pointer_by_name(id_map, (ID *)win->workspace, USER_REAL);
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index bf9dfbf..0f87f21 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -201,6 +201,8 @@ static void do_version_bones_super_bbone(ListBase *lb)
*
* Adds a workspace for each screen of the old file and adds the needed workspace-layout to wrap the screen.
* Rest of the conversion is done in #do_version_workspaces_after_lib_link.
+ *
+ * Note that some of the created workspaces might be deleted again in case of reading the default startup.blend.
*/
static void do_version_workspaces_before_lib_link(Main *main)
{
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 99d9e14..54d4ad7 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -43,6 +43,7 @@
#include "BKE_brush.h"
#include "BKE_library.h"
#include "BKE_main.h"
+#include "BKE_workspace.h"
#include "BLO_readfile.h"
@@ -71,6 +72,24 @@ void BLO_update_defaults_userpref_blend(void)
}
/**
+ * New workspace design: Remove all screens except of "Default" one.
+ * For compatibility, a new workspace has been created for each screen of old files,
+ * we only want one workspace and one screen in the default startup file however.
+ */
+static void update_defaults_startup_workspaces(Main *bmain)
+{
+ BKE_workspace_iter_begin(workspace, bmain->workspaces.first)
+ {
+ if (STREQ(BKE_workspace_name_get(workspace), "Default")) {
+ }
+ else {
+ BKE_workspace_remove(workspace, bmain);
+ }
+ }
+ BKE_workspace_iter_end;
+}
+
+/**
* 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)
@@ -166,20 +185,18 @@ void BLO_update_defaults_startup_blend(Main *bmain)
linestyle->chain_count = 10;
}
- for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
- ScrArea *area;
- for (area = screen->areabase.first; area; area = area->next) {
- SpaceLink *space_link;
- ARegion *ar;
+ update_defaults_startup_workspaces(bmain);
- for (space_link = area->spacedata.first; space_link; space_link = space_link->next) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ for (SpaceLink *space_link = area->spacedata.first; space_link; space_link = space_link->next) {
if (space_link->spacetype == SPACE_CLIP) {
SpaceClip *space_clip = (SpaceClip *) space_link;
space_clip->flag &= ~SC_MANUAL_CALIBRATION;
}
}
- for (ar = area->regionbase.first; ar; ar = ar->next) {
+ for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
/* Remove all stored panels, we want to use defaults (order, open/closed) as defined by UI code here! */
BLI_freelistN(&ar->panels);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 5802b1d..4f0f15f 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -3904,11 +3904,13 @@ static void write_cachefiles(WriteData *wd, ListBase *idbase)
static void write_workspaces(WriteData *wd, ListBase *idbase)
{
- BKE_workspace_iter(workspace, idbase->first) {
+ BKE_workspace_iter_begin(workspace, idbase->first)
+ {
ListBase *layouts = BKE_workspace_layouts_get(workspace);
writestruct(wd, ID_WS, WorkSpace, 1, workspace);
writelist(wd, DATA, WorkSpaceLayout, layouts);
}
+ BKE_workspace_iter_end;
}
/* Keep it last of write_foodata functions. */
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index ef5375f..b1bcc03 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -86,7 +86,8 @@ WorkSpace *ED_worksp
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list