[Bf-blender-cvs] [79108007f3] temp-workspace-multi-window: Work towards completely moving workspace data to window level
Julian Eisel
noreply at git.blender.org
Wed Mar 8 14:59:12 CET 2017
Commit: 79108007f3db29aa16f9c8b45f350473cfa3309c
Author: Julian Eisel
Date: Wed Mar 8 14:57:17 2017 +0100
Branches: temp-workspace-multi-window
https://developer.blender.org/rB79108007f3db29aa16f9c8b45f350473cfa3309c
Work towards completely moving workspace data to window level
Stuff is starting to work out!
===================================================================
M release/scripts/startup/bl_ui/space_info.py
M source/blender/blenkernel/BKE_context.h
M source/blender/blenkernel/BKE_workspace.h
M source/blender/blenkernel/intern/context.c
M source/blender/blenkernel/intern/workspace.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/versioning_280.c
M source/blender/editors/include/ED_screen.h
M source/blender/editors/workspace/screen_edit.c
M source/blender/editors/workspace/screen_ops.c
M source/blender/editors/workspace/workspace_edit.c
M source/blender/editors/workspace/workspace_layout_edit.c
M source/blender/makesdna/dna_workspace_types.h
M source/blender/makesrna/intern/rna_wm.c
M source/blender/makesrna/intern/rna_workspace.c
M source/blender/windowmanager/intern/wm_event_system.c
M source/blender/windowmanager/intern/wm_window.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py
index b0caf400ee..1741e1dc3a 100644
--- a/release/scripts/startup/bl_ui/space_info.py
+++ b/release/scripts/startup/bl_ui/space_info.py
@@ -45,7 +45,7 @@ class INFO_HT_header(Header):
layout.separator()
else:
layout.template_ID(window, "workspace", new="workspace.workspace_new", unlink="workspace.workspace_delete")
- layout.template_ID_preview(workspace, "screen", workspace, "screens", new="screen.new", unlink="screen.delete", rows=2, cols=6)
+ layout.template_ID_preview(window, "screen", workspace, "screens", new="screen.new", unlink="screen.delete", rows=2, cols=6)
if hasattr(workspace, 'object_mode'):
act_mode_item = bpy.types.Object.bl_rna.properties['mode'].enum_items[workspace.object_mode]
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index 77469f11d9..0f433ae186 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -174,7 +174,6 @@ struct SpaceClip *CTX_wm_space_clip(const bContext *C);
void CTX_wm_manager_set(bContext *C, struct wmWindowManager *wm);
void CTX_wm_window_set(bContext *C, struct wmWindow *win);
-void CTX_wm_workspace_set(bContext *C, struct WorkSpace *ws);
void CTX_wm_screen_set(bContext *C, struct bScreen *screen); /* to be removed */
void CTX_wm_area_set(bContext *C, struct ScrArea *sa);
void CTX_wm_region_set(bContext *C, struct ARegion *region);
diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h
index 3b06bd6ab0..660fa69ecb 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -60,9 +60,10 @@ void BKE_workspace_remove(WorkSpace *workspace, struct Main *bmain);
WorkSpaceLayout *BKE_workspace_layout_add_from_type(WorkSpace *workspace, WorkSpaceLayoutType *type,
struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+void BKE_workspace_layout_remove(WorkSpace *workspace, WorkSpaceLayout *layout, struct Main *bmain) ATTR_NONNULL();
WorkSpaceLayoutType *BKE_workspace_layout_type_add(WorkSpace *workspace, const char *name,
struct ScreenLayoutData layout_blueprint) ATTR_NONNULL();
-void BKE_workspace_layout_remove(WorkSpace *workspace, WorkSpaceLayout *layout, struct Main *bmain) ATTR_NONNULL();
+void BKE_workspace_layout_type_remove(WorkSpace *workspace, WorkSpaceLayoutType *layout_type, struct Main *bmain) ATTR_NONNULL();
WorkSpaceHook *BKE_workspace_hook_new(void) ATTR_WARN_UNUSED_RESULT;
void BKE_workspace_hook_delete(struct Main *bmain, WorkSpaceHook *hook) ATTR_NONNULL();
@@ -75,12 +76,15 @@ void BKE_workspace_hook_delete(struct Main *bmain, WorkSpaceHook *hook) ATTR_NON
_workspace##_next = BKE_workspace_next_get(_workspace); /* support removing workspace from list */
#define BKE_workspace_iter_end } (void)0
-void BKE_workspace_change_prepare(struct Main *bmain, WorkSpaceHook *workspace_hook, WorkSpace *workspace_new) ATTR_NONNULL();
+WorkSpaceLayout *BKE_workspace_change_prepare(
+ struct Main *bmain, WorkSpaceHook *workspace_hook, WorkSpace *workspace_new) ATTR_NONNULL();
void BKE_workspaces_transform_orientation_remove(const struct ListBase *workspaces,
const struct TransformOrientation *orientation) ATTR_NONNULL();
WorkSpaceLayout *BKE_workspace_layout_find(const WorkSpaceHook *hook, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+WorkSpaceLayout *BKE_workspace_layout_find_from_type(const WorkSpaceHook *hook, const WorkSpaceLayoutType *type) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+struct bScreen *BKE_workspace_layout_screen_find_from_type(const WorkSpaceHook *hook, const WorkSpaceLayoutType *type) 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) { \
@@ -103,7 +107,6 @@ WorkSpaceLayout *BKE_workspace_layout_iter_circular(const WorkSpace *workspace,
#define BKE_workspace_layout_type_iter_end } (void)0
-
/* -------------------------------------------------------------------- */
/* Getters/Setters */
@@ -114,8 +117,10 @@ struct ID *BKE_workspace_id_get(WorkSpace *workspace) GETTER_ATTRS;
const char *BKE_workspace_name_get(const WorkSpace *workspace) GETTER_ATTRS;
WorkSpaceLayout *BKE_workspace_active_layout_get(const struct WorkSpace *ws) GETTER_ATTRS;
void BKE_workspace_active_layout_set(WorkSpace *ws, WorkSpaceLayout *layout) SETTER_ATTRS;
+WorkSpaceLayout *BKE_workspace_hook_active_layout_get(const WorkSpaceHook *hook) GETTER_ATTRS;
+void BKE_workspace_hook_active_layout_set(WorkSpaceHook *hook, WorkSpaceLayout *layout) SETTER_ATTRS;
struct bScreen *BKE_workspace_active_screen_get(const WorkSpace *ws) GETTER_ATTRS;
-void BKE_workspace_active_screen_set(const WorkSpaceHook *hook, struct bScreen *screen) SETTER_ATTRS;
+void BKE_workspace_active_screen_set(WorkSpaceHook *hook, struct bScreen *screen) SETTER_ATTRS;
struct bScreen *BKE_workspace_hook_active_screen_get(const WorkSpaceHook *hook) GETTER_ATTRS;
enum ObjectMode BKE_workspace_object_mode_get(const WorkSpace *workspace) GETTER_ATTRS;
#ifdef USE_WORKSPACE_MODE
@@ -126,13 +131,15 @@ void BKE_workspace_render_layer_set(WorkSpace *workspace, struct S
struct ListBase *BKE_workspace_layouts_get(WorkSpace *workspace) GETTER_ATTRS;
WorkSpaceLayoutType *BKE_workspace_active_layout_type_get(const WorkSpace *workspace) GETTER_ATTRS;
void BKE_workspace_active_layout_type_set(WorkSpace *workspace, WorkSpaceLayoutType *layout_type) SETTER_ATTRS;
+WorkSpaceLayoutType *BKE_workspace_layout_type_get(const WorkSpaceLayout *layout) GETTER_ATTRS;
struct ListBase *BKE_workspace_layout_types_get(WorkSpace *workspace) GETTER_ATTRS;
const char *BKE_workspace_layout_type_name_get(const WorkSpaceLayoutType *layout_type) GETTER_ATTRS;
struct ScreenLayoutData BKE_workspace_layout_type_blueprint_get(WorkSpaceLayoutType *type) GETTER_ATTRS;
struct ListBase *BKE_workspace_layout_type_vertbase_get(WorkSpaceLayoutType *type) GETTER_ATTRS;
WorkSpaceLayoutType *BKE_workspace_layout_type_next_get(WorkSpaceLayoutType *layout_type) GETTER_ATTRS;
-WorkSpaceLayout *BKE_workspace_new_layout_get(const WorkSpace *workspace) GETTER_ATTRS;
-void BKE_workspace_new_layout_set(WorkSpace *workspace, WorkSpaceLayout *layout) SETTER_ATTRS;
+WorkSpaceLayoutType *BKE_workspace_layout_type_prev_get(WorkSpaceLayoutType *layout_type) GETTER_ATTRS;
+WorkSpaceLayout *BKE_workspace_new_layout_get(const WorkSpaceHook *hook) GETTER_ATTRS;
+void BKE_workspace_new_layout_set(WorkSpaceHook *hook, WorkSpaceLayout *layout) SETTER_ATTRS;
WorkSpace *BKE_workspace_next_get(const WorkSpace *workspace) GETTER_ATTRS;
WorkSpace *BKE_workspace_prev_get(const WorkSpace *workspace) GETTER_ATTRS;
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index e48d379775..6329838b84 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -843,14 +843,6 @@ void CTX_wm_window_set(bContext *C, wmWindow *win)
C->wm.region = NULL;
}
-void CTX_wm_workspace_set(bContext *C, WorkSpace *ws)
-{
- C->wm.workspace = ws;
- C->wm.screen = (C->wm.workspace) ? BKE_workspace_active_screen_get(C->wm.workspace) : NULL;
- C->wm.area = NULL;
- C->wm.region = NULL;
-}
-
void CTX_wm_screen_set(bContext *C, bScreen *screen)
{
C->wm.screen = screen;
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 9d59023de6..28b7a28cb4 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -45,20 +45,20 @@
bool workspaces_is_screen_used(const Main *bmain, bScreen *screen);
+ListBase hooks_all = {};
-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)
+/* -------------------------------------------------------------------- */
+
+/**
+ * Remove the layout instance \a layout and the screen it represents, doesn't modify other layout instances or types.
+ */
+static void workspace_layout_remove(WorkSpaceHook *hook, 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);
+ BLI_freelinkN(&hook->layouts, layout);
}
@@ -86,14 +86,9 @@ void BKE_workspace_free(WorkSpace *ws)
void BKE_workspace_remove(WorkSpace *workspace, Main *bmain)
{
- BKE_workspace_layout_iter_begin(layout, workspace->layouts.first)
- {
- 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_remove(workspace, layout_type, bmain);
}
BKE_workspace_layout_type_iter_end;
@@ -126,16 +121,38 @@ WorkSpaceLayoutType *BKE_workspace_layout_type_add(
return layout_type;
}
+/**
+ * Remove \a layout_type and all instances of it.
+ */
+void BKE_workspace_layout_type_remove(WorkSpace *workspace, WorkSpaceLayoutType *layout_type, Main *bmain)
+{
+ for (WorkSpaceHook *hook = hooks_all.first; hook; hook = hook->next) {
+ for (WorkSpaceLayout *layout = hook->layouts.first, *layout_next; layout; layout = layout_next) {
+ layout_next = layout->next;
+
+ if (layout->type == layout_type) {
+ workspace_layout_remove(hook, layout, bmain);
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list