[Bf-blender-cvs] [675c4a0108] temp-workspace-multi-window: Multi-Window support: Store layout instances per window
Julian Eisel
noreply at git.blender.org
Fri Feb 24 00:33:41 CET 2017
Commit: 675c4a0108109efca604d486f9b20aad456bc6ea
Author: Julian Eisel
Date: Thu Feb 16 19:27:30 2017 +0100
Branches: temp-workspace-multi-window
https://developer.blender.org/rB675c4a0108109efca604d486f9b20aad456bc6ea
Multi-Window support: Store layout instances per window
===================================================================
M source/blender/blenkernel/BKE_workspace.h
M source/blender/blenkernel/intern/workspace.c
M source/blender/blenloader/intern/versioning_270.c
M source/blender/makesdna/DNA_windowmanager_types.h
M source/blender/makesdna/dna_workspace_types.h
M source/blender/makesrna/intern/rna_workspace.c
M source/blender/windowmanager/intern/wm_window.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h
index 5bb1689f41..d6cbe43efc 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -56,7 +56,9 @@ WorkSpace *BKE_workspace_add(struct Main *bmain, const char *name);
void BKE_workspace_free(WorkSpace *ws);
void BKE_workspace_remove(WorkSpace *workspace, struct Main *bmain);
-struct WorkSpaceLayout *BKE_workspace_layout_add(WorkSpace *workspace, struct bScreen *screen) ATTR_NONNULL();
+WorkSpaceLayout *BKE_workspace_layout_add_from_type(WorkSpace *workspace, WorkSpaceLayoutType *type, struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+WorkSpaceLayoutType *BKE_workspace_layout_type_add(WorkSpace *workspace, struct bScreen *screen) ATTR_NONNULL();
+WorkSpaceLayout *BKE_workspace_layout_add(WorkSpace *workspace, struct bScreen *screen) ATTR_NONNULL();
void BKE_workspace_layout_remove(WorkSpace *workspace, WorkSpaceLayout *layout, struct Main *bmain) ATTR_NONNULL();
@@ -101,8 +103,10 @@ enum ObjectMode BKE_workspace_object_mode_get(const WorkSpace *workspace) ATTR_N
void BKE_workspace_object_mode_set(WorkSpace *workspace, const enum ObjectMode mode) ATTR_NONNULL();
#endif
struct ListBase *BKE_workspace_layouts_get(WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+WorkSpaceLayoutType *BKE_workspace_active_layout_type_get(WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
struct ListBase *BKE_workspace_layout_types_get(WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
const char *BKE_workspace_layout_type_name_get(WorkSpaceLayoutType *layout_type) ATTR_NONNULL();
+WorkSpaceLayoutType *BKE_workspace_layout_type_next_get(WorkSpaceLayoutType *layout_type) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
WorkSpaceLayout *BKE_workspace_new_layout_get(const WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
void BKE_workspace_new_layout_set(WorkSpace *workspace, WorkSpaceLayout *layout) ATTR_NONNULL(1);
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 4d4e643e78..7de053d76f 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -81,31 +81,45 @@ void BKE_workspace_remove(WorkSpace *workspace, Main *bmain)
}
-/**
- * Add a new layout to \a workspace for \a screen.
- */
-WorkSpaceLayout *BKE_workspace_layout_add(WorkSpace *workspace, bScreen *screen)
+WorkSpaceLayout *BKE_workspace_layout_add_from_type(WorkSpace *workspace, WorkSpaceLayoutType *type, bScreen *screen)
{
- WorkSpaceLayoutType *layout_type = MEM_mallocN(sizeof(*layout_type), "WorkSpaceLayoutType");
WorkSpaceLayout *layout = MEM_mallocN(sizeof(*layout), __func__);
- BLI_assert(!workspaces_is_screen_used(G.main, screen));
+// BLI_assert(!workspaces_is_screen_used(G.main, screen));
+
+ layout->type = type;
layout->screen = screen;
BLI_addhead(&workspace->layouts, layout);
+ return layout;
+}
+
+WorkSpaceLayoutType *BKE_workspace_layout_type_add(WorkSpace *workspace, bScreen *screen)
+{
+ WorkSpaceLayoutType *layout_type = MEM_mallocN(sizeof(*layout_type), __func__);
+
layout_type->name = screen->id.name + 2;
BLI_addhead(&workspace->layout_types, layout_type);
- return layout;
+ return layout_type;
+}
+
+/**
+ * Add a new layout to \a workspace for \a screen.
+ */
+WorkSpaceLayout *BKE_workspace_layout_add(WorkSpace *workspace, bScreen *screen)
+{
+ WorkSpaceLayoutType *layout_type = BKE_workspace_layout_type_add(workspace, screen);
+ return BKE_workspace_layout_add_from_type(workspace, layout_type, 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);
- WorkSpaceLayoutType *layout_type = BLI_findptr(&workspace->layout_types, screen->id.name + 2,
- offsetof(WorkSpaceLayoutType, name));
- BLI_assert(layout_type);
+ 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);
@@ -220,6 +234,7 @@ WorkSpaceLayout *BKE_workspace_active_layout_get(const WorkSpace *workspace)
void BKE_workspace_active_layout_set(WorkSpace *workspace, WorkSpaceLayout *layout)
{
workspace->act_layout = layout;
+ workspace->act_layout_type = layout->type;
}
WorkSpaceLayout *BKE_workspace_new_layout_get(const WorkSpace *workspace)
@@ -237,8 +252,10 @@ bScreen *BKE_workspace_active_screen_get(const WorkSpace *ws)
}
void BKE_workspace_active_screen_set(WorkSpace *ws, bScreen *screen)
{
+ WorkSpaceLayout *layout = BKE_workspace_layout_find(ws, screen);
/* we need to find the WorkspaceLayout that wraps this screen */
- ws->act_layout = BKE_workspace_layout_find(ws, screen);
+ ws->act_layout = layout;
+ ws->act_layout_type = layout->type;
}
#ifdef USE_WORKSPACE_MODE
@@ -257,6 +274,11 @@ ListBase *BKE_workspace_layouts_get(WorkSpace *workspace)
return &workspace->layouts;
}
+WorkSpaceLayoutType *BKE_workspace_active_layout_type_get(WorkSpace *workspace)
+{
+ return workspace->act_layout_type;
+}
+
ListBase *BKE_workspace_layout_types_get(WorkSpace *workspace)
{
return &workspace->layout_types;
@@ -267,6 +289,11 @@ const char *BKE_workspace_layout_type_name_get(WorkSpaceLayoutType *layout_type)
return layout_type->name;
}
+WorkSpaceLayoutType *BKE_workspace_layout_type_next_get(WorkSpaceLayoutType *layout_type)
+{
+ return layout_type->next;
+}
+
WorkSpace *BKE_workspace_next_get(const WorkSpace *workspace)
{
return workspace->id.next;
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 136cb8fdaa..de41530aa3 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -285,8 +285,13 @@ static void do_version_workspaces_after_lib_link(Main *main)
for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) {
for (wmWindow *win = wm->windows.first; win; win = win->next) {
bScreen *screen = win->screen;
+ WorkSpace *workspace = BLI_findstring(&main->workspaces, screen->id.name + 2, offsetof(ID, name) + 2);
+ ListBase *layout_types = BKE_workspace_layout_types_get(workspace);
+ WorkSpaceLayout *layout = BKE_workspace_layout_add_from_type(workspace, layout_types->first, screen);
- win->workspace = BLI_findstring(&main->workspaces, screen->id.name + 2, offsetof(ID, name) + 2);
+ BLI_assert(BLI_listbase_count(layout_types) == 1);
+ BLI_addhead(&win->workspace_layouts, layout);
+ BKE_workspace_active_layout_set(workspace, layout); /* TODO */
win->scene = screen->scene;
/* Deprecated from now on! */
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 0fb6a6d9b0..36ec0b709b 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -182,6 +182,9 @@ typedef struct wmWindow {
struct WorkSpace *workspace; /* active workspace */
struct WorkSpace *new_workspace; /* temporary when switching */
+ /* To support opening a workspace in multiple windows while keeping the individual layouts independent, each
+ * window stores a list of layouts that is synced with a list of layout-type definitions from the workspace */
+ ListBase workspace_layouts; /* WorkSpaceLayout */
struct bScreen *screen DNA_DEPRECATED;
char screenname[64]; /* MAX_ID_NAME for matching window with active screen after file read */
diff --git a/source/blender/makesdna/dna_workspace_types.h b/source/blender/makesdna/dna_workspace_types.h
index 1eef392a13..3164d276d6 100644
--- a/source/blender/makesdna/dna_workspace_types.h
+++ b/source/blender/makesdna/dna_workspace_types.h
@@ -43,6 +43,7 @@
typedef struct WorkSpaceLayout {
struct WorkSpaceLayout *next, *prev;
+ struct WorkSpaceLayoutType *type;
struct bScreen *screen;
} WorkSpaceLayout;
@@ -56,6 +57,7 @@ typedef struct WorkSpace {
ListBase layout_types;
ListBase layouts;
+ struct WorkSpaceLayoutType *act_layout_type;
struct WorkSpaceLayout *act_layout;
struct WorkSpaceLayout *new_layout; /* temporary when switching screens */
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index aa82f9992c..c68a66f06e 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -114,6 +114,20 @@ static void rna_workspace_object_mode_set(PointerRNA *ptr, int value)
BKE_workspace_object_mode_set(workspace, value);
}
+PointerRNA rna_workspace_layout_type_get(PointerRNA *ptr)
+{
+ WorkSpaceLayoutType *layout_type = BKE_workspace_active_layout_type_get(ptr->data);
+ return rna_pointer_inherit_refine(ptr, &RNA_WorkSpaceLayoutType, layout_type);
+}
+
+static void rna_workspace_layout_type_set(PointerRNA *ptr, PointerRNA value)
+{
+ WorkSpace *workspace = ptr->data;
+ WorkSpaceLayoutType *layout_type = value.data;
+ UNUSED_VARS(workspace, layout_type);
+ /* TODO */
+}
+
void rna_workspace_layout_types_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
WorkSpace *workspace = ptr->data;
@@ -180,6 +194,14 @@ static void rna_def_workspace(BlenderRNA *brna)
"rna_workspace_screens_item_get", NULL, NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Screens", "Screen layouts of a workspace");
+ prop = RNA_def_property(srna, "layout_type", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "act_layout_type");
+ RNA_def_property_struct_type(prop, "WorkSpaceLayoutType");
+ RNA_def_property_ui_text(prop, "Layout", "Active screen-layout type showing in the workspace");
+ RNA_def_property_pointer_funcs(prop, "rna_workspace_layout_type_get", "rna_workspace_layout_type_set",
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list