Commit: c394624b9fb84683bb0726a0c25209031205d054
Author: Julian Eisel
Date: Sun Feb 19 13:45:49 2017 +0100
Branches: temp-workspace-multi-window
https://developer.blender.org/rBc394624b9fb84683bb0726a0c25209031205d054
Initial steps to remove layout entities from workspace level
===================================================================
M source/blender/blenkernel/BKE_workspace.h
M source/blender/blenkernel/intern/library_query.c
M source/blender/blenkernel/intern/workspace.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/writefile.c
M source/blender/editors/workspace/workspace_edit.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_workspace.h
b/source/blender/blenkernel/BKE_workspace.h
index 2555a74d1f..547c55bc85 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -74,7 +74,6 @@ void BKE_workspaces_transform_orientation_remove(const struct
ListBase *workspac
const struct
TransformOrientation *orientation) ATTR_NONNULL();
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_begin(_layout, _start_layout) \
for (WorkSpaceLayout *_layout = _start_layout, *_layout##_next;
_layout; _layout = _layout##_next) { \
diff --git a/source/blender/blenkernel/intern/library_query.c
b/source/blender/blenkernel/intern/library_query.c
index 52cf29fe92..18b6079919 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -918,6 +918,16 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id,
LibraryIDLinkCallback call
CALLBACK_INVOKE(win->scene,
IDWALK_CB_USER_ONE);
+ BKE_workspace_layout_iter_begin(layout,
win->workspace_layouts.first)
+ {
+ bScreen *screen =
BKE_workspace_layout_screen_get(layout);
+
+ CALLBACK_INVOKE(screen,
IDWALK_CB_NOP);
+ /* allow callback to set a
different screen */
+
BKE_workspace_layout_screen_set(layout, screen);
+ }
+ BKE_workspace_layout_iter_end;
+
CALLBACK_INVOKE_ID(workspace,
IDWALK_CB_NOP);
/* allow callback to set a different
workspace */
win->workspace = (WorkSpace *)workspace;
diff --git a/source/blender/blenkernel/intern/workspace.c
b/source/blender/blenkernel/intern/workspace.c
index 7de053d76f..c16b3bc3b6 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -46,6 +46,22 @@
bool workspaces_is_screen_used(const Main *bmain, bScreen *screen);
+static void workspace_layout_type_remove(WorkSpace *workspace,
WorkSpaceLayoutType *layout_type)
+{
+ BLI_assert(BLI_findindex(&workspace->layout_types, layout_type) >= 0);
+ BLI_freelinkN(&workspace->layout_types, layout_type);
+}
+
+static void workspace_layout_remove(WorkSpace *workspace, WorkSpaceLayout
*layout, Main *bmain)
+{
+ bScreen *screen = BKE_workspace_layout_screen_get(layout);
+
+ BLI_assert(BLI_findindex(&workspace->layouts, layout) >= 0);
+ BKE_libblock_free(bmain, screen);
+ BLI_freelinkN(&workspace->layouts, layout);
+}
+
+
/* -------------------------------------------------------------------- */
/* Create, delete, init */
@@ -73,9 +89,14 @@ void BKE_workspace_remove(WorkSpace *workspace, Main *bmain)
{
BKE_workspace_layout_iter_begin(layout, workspace->layouts.first)
{
- BKE_workspace_layout_remove(workspace, layout, bmain);
+ workspace_layout_remove(workspace, layout, bmain);
}
BKE_workspace_layout_iter_end;
+ BKE_workspace_layout_type_iter_begin(layout_type,
workspace->layout_types.first)
+ {
+ workspace_layout_type_remove(workspace, layout_type);
+ }
+ BKE_workspace_layout_type_iter_end;
BKE_libblock_free(bmain, workspace);
}
@@ -116,13 +137,8 @@ WorkSpaceLayout *BKE_workspace_layout_add(WorkSpace
*workspace, bScreen *screen)
void BKE_workspace_layout_remove(WorkSpace *workspace, WorkSpaceLayout
*layout, Main *bmain)
{
WorkSpaceLayoutType *layout_type = layout->type;
- bScreen *screen = BKE_workspace_layout_screen_get(layout);
-
- BLI_assert(BLI_findindex(&workspace->layouts, layout) >= 0);
- BLI_assert(BLI_findindex(&workspace->layout_types, layout_type) >= 0);
- BKE_libblock_free(bmain, screen);
- BLI_freelinkN(&workspace->layouts, layout);
- BLI_freelinkN(&workspace->layout_types, layout_type);
+ workspace_layout_remove(workspace, layout, bmain);
+ workspace_layout_type_remove(workspace, layout_type);
}
@@ -143,40 +159,40 @@ void BKE_workspaces_transform_orientation_remove(const
ListBase *workspaces, con
}
/**
- * Checks if \a screen is already used within any workspace. A screen should
never be assigned to multiple
- * WorkSpaceLayouts, but that should be ensured outside of the BKE_workspace
module and without such checks.
- * Hence, this should only be used as assert check before assigining a screen
to a workflow.
+ * This should only be used directly when it is to be expected that there isn't
+ * a layout within \a workspace that wraps \a screen. Usually - especially
outside
+ * of BKE_workspace - #BKE_workspace_layout_find should be used!
*/
-bool workspaces_is_screen_used(const Main *bmain, bScreen *screen)
+static WorkSpaceLayout *workspace_layout_find(const WorkSpace *ws, const
bScreen *screen)
{
- for (WorkSpace *workspace = bmain->workspaces.first; workspace;
workspace = workspace->id.next) {
- if (BKE_workspace_layout_find_exec(workspace, screen)) {
- return true;
+ for (WorkSpaceLayout *layout = ws->layouts.first; layout; layout =
layout->next) {
+ if (layout->screen == screen) {
+ return layout;
}
}
- return false;
+ return NULL;
}
/**
- * This should only be used directly when it is to be expected that there isn't
- * a layout within \a workspace that wraps \a screen. Usually - especially
outside
- * of BKE_workspace - #BKE_workspace_layout_find should be used!
+ * Checks if \a screen is already used within any workspace. A screen should
never be assigned to multiple
+ * WorkSpaceLayouts, but that should be ensured outside of the BKE_workspace
module and without such checks.
+ * Hence, this should only be used as assert check before assigining a screen
to a workflow.
*/
-WorkSpaceLayout *BKE_workspace_layout_find_exec(const WorkSpace *ws, const
bScreen *screen)
+bool workspaces_is_screen_used(const Main *bmain, bScreen *screen)
{
- for (WorkSpaceLayout *layout = ws->layouts.first; layout; layout =
layout->next) {
- if (layout->screen == screen) {
- return layout;
+ for (WorkSpace *workspace = bmain->workspaces.first; workspace;
workspace = workspace->id.next) {
+ if (workspace_layout_find(workspace, screen)) {
+ return true;
}
}
- return NULL;
+ return false;
}
WorkSpaceLayout *BKE_workspace_layout_find(const WorkSpace *ws, const bScreen
*screen)
{
- WorkSpaceLayout *layout = BKE_workspace_layout_find_exec(ws, screen);
+ WorkSpaceLayout *layout = workspace_layout_find(ws, screen);
if (layout) {
return layout;
}
diff --git a/source/blender/blenloader/intern/readfile.c
b/source/blender/blenloader/intern/readfile.c
index eb3f55492b..d813ad0f96 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2772,6 +2772,18 @@ static void lib_link_workspaces(FileData *fd, Main
*bmain)
BKE_workspace_iter_end;
}
+static void lib_link_workspace_layouts(FileData *fd, const void *lib, ListBase
*layouts)
+{
+ BKE_workspace_layout_iter_begin(layout, layouts->first)
+ {
+ bScreen *screen = newlibadr(fd, lib,
BKE_workspace_layout_screen_get(layout));
+ if (screen) {
+ BKE_workspace_layout_screen_set(layout, screen);
+ }
+ }
+ BKE_workspace_layout_iter_end;
+}
+
static void direct_link_workspace(FileData *fd, WorkSpace *ws)
{
WorkSpaceLayout *act_layout = BKE_workspace_active_layout_get(ws);
@@ -6348,6 +6360,7 @@ static void direct_link_windowmanager(FileData *fd,
wmWindowManager *wm)
if (win->stereo3d_format) {
win->stereo3d_format->display_mode =
S3D_DISPLAY_ANAGLYPH;
}
+ link_list(fd, &win->workspace_layouts);
}
BLI_listbase_clear(&wm->timers);
@@ -6381,6 +6394,7 @@ static void lib_link_windowmanager(FileData *fd, Main
*main)
for (win = wm->windows.first; win; win = win->next) {
win->scene = newlibadr(fd, wm->id.lib,
win->scene);
win->workspace = newlibadr(fd, wm->id.lib,
win->workspace);
+ lib_link_workspace_layouts(fd, wm->id.lib,
&win->workspace_layouts);
/* deprecated, but needed for versioning (will
be NULL'ed then) */
win->screen = newlibadr(fd, NULL, win->screen);
}
@@ -7028,21 +7042,15 @@ void blo_lib_link_restore(Main *newmain,
wmWindowManager *curwm, Scene *curscene
{
struct IDNameLib_Map *id_map = BKE_main_idmap_create(newmain);
- BKE_workspace_iter_begin(workspace, newmain->workspaces.first)
- {
- ListBase *layouts = BKE_workspace_layouts_get(workspace);
+ 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);
- BKE_workspace_layout_iter_begin(layout, layouts->first)
+ BKE_workspace_layout_iter_begin(layout,
win->workspace_layouts.first)
{
lib_link_workspace_layout_restore(id_map, newmain,
layout);
}
BKE_workspace_layout_iter_end;
- }
- BKE_workspace_iter_end;
-
- 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);
win->scene = restore_pointer_by_name(id_map, (ID *)win->scene,
USER_REAL);
if (win->scene == NULL) {
@@ -9877,6 +9885,17 @@ static void expand_gpencil(FileData *fd, Main *mainvar,
bGPdata *gpd)
expand_animdata(fd, mainvar, gpd->adt);
}
+static void expand_windowmanager(FileData *fd, Main *mainvar, wmWindowManager
*wm)
+{
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ BKE_workspace_layout_iter_begin(layout,
win->workspace_layouts.first)
+ {
+ expand_doit(fd, mainvar,
BKE_workspace_layout_screen_get(layout));
+ }
+ BKE_workspace_layout_iter_end;
+ }
+}
+
static void expand_workspace(FileData *fd, Main *mainvar, WorkSpace *workspace)
{
ListBase *layouts = BKE_workspace_layouts_get(workspace);
@@ -10000,6 +10019,9 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
case ID_CF:
expand_cachefile(fd, mainvar,
(CacheFile *)id);
break;
+ case ID_WM:
+ expand_windowmanager(fd,
mainvar, (wmWindowManager *)id);
+ break;
case ID_WS:
expand_workspace(fd, mainvar,
(WorkSpace *)id);
break;
diff --git a/sourc
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs