[Bf-blender-cvs] [177b53f] workspaces: Store a workspace in each window
Julian Eisel
noreply at git.blender.org
Fri Dec 2 11:42:51 CET 2016
Commit: 177b53fe86e4795248996de5f717e26416ce998a
Author: Julian Eisel
Date: Thu Dec 1 23:29:00 2016 +0100
Branches: workspaces
https://developer.blender.org/rB177b53fe86e4795248996de5f717e26416ce998a
Store a workspace in each window
Some details need to be figured out still (Windows should probably be able to share an active workspace).
===================================================================
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/editors/screen/screen_edit.c
M source/blender/editors/screen/screen_ops.c
M source/blender/makesdna/DNA_windowmanager_types.h
M source/blender/makesrna/intern/rna_wm.c
M source/blender/windowmanager/intern/wm.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 283b0ea..90981f1 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -27,6 +27,8 @@
struct WorkSpace;
+struct WorkSpace *BKE_workspace_add(Main *bmain, const char *name);
+struct WorkSpace *BKE_workspace_duplicate(Main *bmain, const struct WorkSpace *from);
void BKE_workspace_free(struct WorkSpace *ws);
#endif /* __BKE_WORKSPACE_H__ */
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 27a67c5..5893443 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -22,10 +22,27 @@
* \ingroup bke
*/
+#include "BLI_utildefines.h"
+
+#include "BKE_library.h"
+#include "BKE_main.h"
#include "BKE_workspace.h"
#include "DNA_screen_types.h"
+
+WorkSpace *BKE_workspace_add(Main *bmain, const char *name)
+{
+ WorkSpace *new_ws = BKE_libblock_alloc(bmain, ID_WS, name);
+ return new_ws;
+}
+
+WorkSpace *BKE_workspace_duplicate(Main *bmain, const WorkSpace *from)
+{
+ WorkSpace *new_ws = BKE_libblock_alloc(bmain, ID_WS, from->id.name + 2);
+ return new_ws;
+}
+
void BKE_workspace_free(WorkSpace *ws)
{
(void)ws;
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 3fa3f03..ed7270f 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1396,4 +1396,17 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
+
+ {
+ if (!DNA_struct_find(fd->filesdna, "WorkSpace")) {
+ BLI_assert(BLI_listbase_is_empty(&main->workspaces));
+
+ /* Add default workspace */
+ for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) {
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ win->workspace = BKE_libblock_alloc(main, ID_WS, "Default");
+ }
+ }
+ }
+ }
}
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 1f30923..f0c2243 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -1266,7 +1266,9 @@ void ED_screens_initialize(wmWindowManager *wm)
wmWindow *win;
for (win = wm->windows.first; win; win = win->next) {
-
+ if (win->workspace == NULL) {
+ win->workspace = G.main->workspaces.first;
+ }
if (win->screen == NULL)
win->screen = G.main->screen.first;
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 681b595..813551a 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -62,6 +62,7 @@
#include "BKE_editmesh.h"
#include "BKE_sound.h"
#include "BKE_mask.h"
+#include "BKE_workspace.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -1010,7 +1011,8 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
*newwin->stereo3d_format = *win->stereo3d_format;
-
+
+ newwin->workspace = win->workspace;
/* allocs new screen and adds to newly created window, using window size */
newsc = ED_screen_add(newwin, CTX_data_scene(C), sc->id.name + 2);
newwin->screen = newsc;
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 14400c8..a720689 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -177,9 +177,10 @@ typedef struct wmWindow {
void *ghostwin; /* don't want to include ghost.h stuff */
- struct bScreen *screen; /* active screen */
- struct bScreen *newscreen; /* temporary when switching */
- char screenname[64]; /* MAX_ID_NAME for matching window with active screen after file read */
+ struct WorkSpace *workspace; /* active workspace */
+ struct bScreen *screen; /* active screen */
+ struct bScreen *newscreen; /* temporary when switching */
+ char screenname[64]; /* MAX_ID_NAME for matching window with active screen after file read */
short posx, posy, sizex, sizey; /* window coords */
short windowstate; /* borderless, full */
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 35c9c9b..b250593 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -1909,6 +1909,14 @@ static void rna_def_window(BlenderRNA *brna)
rna_def_window_stereo3d(brna);
+ prop = RNA_def_property(srna, "workspace", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NEVER_NULL);
+ RNA_def_property_struct_type(prop, "WorkSpace");
+ RNA_def_property_ui_text(prop, "Workspace", "Active workspace showing in the window");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+// RNA_def_property_update(prop, 0, NULL); /* TODO own notifier? */
+
prop = RNA_def_property(srna, "screen", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "Screen");
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index b76a1f1..fe76b18 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -420,6 +420,7 @@ void wm_add_default(bContext *C)
CTX_wm_manager_set(C, wm);
win = wm_window_new(C);
+ win->workspace = G.main->workspaces.last;
win->screen = screen;
screen->winid = win->winid;
BLI_strncpy(win->screenname, screen->id.name + 2, sizeof(win->screenname));
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index e271225..cb609da 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -55,6 +55,7 @@
#include "BKE_library.h"
#include "BKE_global.h"
#include "BKE_main.h"
+#include "BKE_workspace.h"
#include "RNA_access.h"
@@ -257,6 +258,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src)
/* duplicate assigns to window */
win_dst->screen = ED_screen_duplicate(win_dst, win_src->screen);
+ win_dst->workspace = BKE_workspace_duplicate(CTX_data_main(C), win_src->workspace);
BLI_strncpy(win_dst->screenname, win_dst->screen->id.name + 2, sizeof(win_dst->screenname));
win_dst->screen->winid = win_dst->winid;
@@ -653,7 +655,10 @@ wmWindow *WM_window_open_temp(bContext *C, const rcti *rect_init, int type)
wm_window_set_size(win, win->sizex, win->sizey);
wm_window_raise(win);
}
-
+
+ if (win->workspace == NULL) {
+ win->workspace = BKE_workspace_add(CTX_data_main(C), "Temp");
+ }
if (win->screen == NULL) {
/* add new screen */
win->screen = ED_screen_add(win, scene, "temp");
More information about the Bf-blender-cvs
mailing list