[Bf-blender-cvs] [bdc209f] workspaces: Make WorkSpace and WorkSpaceLayout local DNA structs
Julian Eisel
noreply at git.blender.org
Fri Dec 9 14:01:13 CET 2016
Commit: bdc209faa9fd172fc83d5f7ea36cb806fcd7c2c5
Author: Julian Eisel
Date: Fri Dec 9 13:52:08 2016 +0100
Branches: workspaces
https://developer.blender.org/rBbdc209faa9fd172fc83d5f7ea36cb806fcd7c2c5
Make WorkSpace and WorkSpaceLayout local DNA structs
Wanted to try this to avoid having (almost) global scope of DNA structs, instead, everything should be handled through BKE_workspace API.
===================================================================
M source/blender/blenkernel/BKE_workspace.h
M source/blender/blenkernel/intern/library.c
M source/blender/blenkernel/intern/workspace.c
A source/blender/blenkernel/intern/workspace_dna.h
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/versioning_270.c
M source/blender/blenloader/intern/writefile.c
M source/blender/editors/include/ED_screen.h
M source/blender/editors/screen/workspace_edit.c
M source/blender/editors/screen/workspace_layout_edit.c
M source/blender/makesdna/DNA_screen_types.h
M source/blender/makesdna/intern/makesdna.c
M source/blender/makesrna/intern/rna_workspace.c
M source/blender/windowmanager/intern/wm_files.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h
index c84ef4f..400bf29 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -30,34 +30,59 @@
struct bScreen;
struct WorkSpace;
+typedef struct WorkSpace WorkSpace;
+typedef struct WorkSpaceLayout WorkSpaceLayout;
+
/* -------------------------------------------------------------------- */
/* Create, delete, init */
-struct WorkSpace *BKE_workspace_add(Main *bmain, const char *name);
-void BKE_workspace_free(struct WorkSpace *ws);
+WorkSpace *BKE_workspace_add(Main *bmain, const char *name);
+void BKE_workspace_free(WorkSpace *ws);
-struct WorkSpaceLayout *BKE_workspace_layout_add(struct WorkSpace *workspace, struct bScreen *screen) ATTR_NONNULL();
-void BKE_workspace_layout_remove(struct WorkSpace *workspace, struct WorkSpaceLayout *layout, Main *bmain) ATTR_NONNULL();
+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();
/* -------------------------------------------------------------------- */
/* General Utils */
-struct WorkSpaceLayout *BKE_workspace_layout_find(
- const struct WorkSpace *ws, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-struct WorkSpaceLayout *BKE_workspace_layout_find_exec(
- const struct WorkSpace *ws, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+#define BKE_workspace_iter(_workspace, _start_workspace) \
+ for (WorkSpace *_workspace = _start_workspace; _workspace; _workspace = BKE_workspace_next_get(_workspace))
+
+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))
+
+WorkSpaceLayout *BKE_workspace_layout_iter_circular(const WorkSpace *workspace, WorkSpaceLayout *start,
+ bool (*callback)(const WorkSpaceLayout *layout, void *arg),
+ void *arg, const bool iter_backward);
/* -------------------------------------------------------------------- */
/* Getters/Setters */
-struct WorkSpaceLayout *BKE_workspace_active_layout_get(const struct WorkSpace *ws) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-void BKE_workspace_active_layout_set(struct WorkSpace *ws, struct WorkSpaceLayout *layout) ATTR_NONNULL(1);
+struct ID *BKE_workspace_id_get(WorkSpace *workspace);
+const char *BKE_workspace_name_get(const WorkSpace *workspace);
+WorkSpaceLayout *BKE_workspace_active_layout_get(const struct WorkSpace *ws) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+void BKE_workspace_active_layout_set(WorkSpace *ws, WorkSpaceLayout *layout) ATTR_NONNULL(1);
struct bScreen *BKE_workspace_active_screen_get(const struct WorkSpace *ws) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-void BKE_workspace_active_screen_set(struct WorkSpace *ws, struct bScreen *screen) ATTR_NONNULL(1);
+void BKE_workspace_active_screen_set(WorkSpace *ws, struct bScreen *screen) ATTR_NONNULL(1);
+ListBase *BKE_workspace_layouts_get(WorkSpace *workspace) 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);
+
+WorkSpace *BKE_workspace_next_get(const WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+WorkSpace *BKE_workspace_prev_get(const WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+
+struct bScreen *BKE_workspace_layout_screen_get(const WorkSpaceLayout *layout) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+void BKE_workspace_layout_screen_set(WorkSpaceLayout *layout, struct bScreen *screen) ATTR_NONNULL(1);
-struct bScreen *BKE_workspace_layout_screen_get(const struct WorkSpaceLayout *layout) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+WorkSpaceLayout *BKE_workspace_layout_next_get(const WorkSpaceLayout *layout) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+WorkSpaceLayout *BKE_workspace_layout_prev_get(const WorkSpaceLayout *layout) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
#endif /* __BKE_WORKSPACE_H__ */
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index abb737c..87aea5c 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -130,6 +130,10 @@
#include "atomic_ops.h"
+/* local DNA files */
+#include "workspace_dna.h"
+
+
/* GS reads the memory pointed at in a specific ordering.
* only use this definition, makes little and big endian systems
* work fine, in conjunction with MAKE_ID */
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 74291e8..ea99842 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -35,6 +35,8 @@
#include "MEM_guardedalloc.h"
+#include "workspace_dna.h"
+
static bool workspaces_is_screen_used(const Main *bmain, bScreen *screen);
@@ -122,17 +124,64 @@ WorkSpaceLayout *BKE_workspace_layout_find(const WorkSpace *ws, const bScreen *s
return NULL;
}
+WorkSpaceLayout *BKE_workspace_layout_iter_circular(const WorkSpace *workspace, WorkSpaceLayout *start,
+ bool (*callback)(const WorkSpaceLayout *layout, void *arg),
+ void *arg, const bool iter_backward)
+{
+ WorkSpaceLayout *iter_layout;
+
+ if (iter_backward) {
+ BLI_LISTBASE_CIRCULAR_BACKWARD_BEGIN(&workspace->layouts, iter_layout, start)
+ {
+ if (!callback(iter_layout, arg)) {
+ return iter_layout;
+ }
+ }
+ BLI_LISTBASE_CIRCULAR_BACKWARD_END(&workspace->layouts, iter_layout, start);
+ }
+ else {
+ BLI_LISTBASE_CIRCULAR_FORWARD_BEGIN(&workspace->layouts, iter_layout, start)
+ {
+ if (!callback(iter_layout, arg)) {
+ return iter_layout;
+ }
+ }
+ BLI_LISTBASE_CIRCULAR_FORWARD_END(&workspace->layouts, iter_layout, start)
+ }
+
+ return NULL;
+}
+
/* -------------------------------------------------------------------- */
/* Getters/Setters */
-WorkSpaceLayout *BKE_workspace_active_layout_get(const WorkSpace *ws)
+ID *BKE_workspace_id_get(WorkSpace *workspace)
{
- return ws->act_layout;
+ return &workspace->id;
}
-void BKE_workspace_active_layout_set(WorkSpace *ws, WorkSpaceLayout *layout)
+
+const char *BKE_workspace_name_get(const WorkSpace *workspace)
{
- ws->act_layout = layout;
+ return workspace->id.name + 2;
+}
+
+WorkSpaceLayout *BKE_workspace_active_layout_get(const WorkSpace *workspace)
+{
+ return workspace->act_layout;
+}
+void BKE_workspace_active_layout_set(WorkSpace *workspace, WorkSpaceLayout *layout)
+{
+ workspace->act_layout = layout;
+}
+
+WorkSpaceLayout *BKE_workspace_new_layout_get(const WorkSpace *workspace)
+{
+ return workspace->new_layout;
+}
+void BKE_workspace_new_layout_set(WorkSpace *workspace, WorkSpaceLayout *layout)
+{
+ workspace->new_layout = layout;
}
bScreen *BKE_workspace_active_screen_get(const WorkSpace *ws)
@@ -145,8 +194,35 @@ void BKE_workspace_active_screen_set(WorkSpace *ws, bScreen *screen)
ws->act_layout = BKE_workspace_layout_find(ws, screen);
}
+ListBase *BKE_workspace_layouts_get(WorkSpace *workspace)
+{
+ return &workspace->layouts;
+}
+
+WorkSpace *BKE_workspace_next_get(const WorkSpace *workspace)
+{
+ return workspace->id.next;
+}
+WorkSpace *BKE_workspace_prev_get(const WorkSpace *workspace)
+{
+ return workspace->id.prev;
+}
+
bScreen *BKE_workspace_layout_screen_get(const WorkSpaceLayout *layout)
{
return layout->screen;
}
+void BKE_workspace_layout_screen_set(WorkSpaceLayout *layout, bScreen *screen)
+{
+ layout->screen = screen;
+}
+
+WorkSpaceLayout *BKE_workspace_layout_next_get(const WorkSpaceLayout *layout)
+{
+ return layout->next;
+}
+WorkSpaceLayout *BKE_workspace_layout_prev_get(const WorkSpaceLayout *layout)
+{
+ return layout->prev;
+}
diff --git a/source/blender/blenkernel/intern/workspace_dna.h b/source/blender/blenkernel/intern/workspace_dna.h
new file mode 100644
index 0000000..97cbffc
--- /dev/null
+++ b/source/blender/blenkernel/intern/workspace_dna.h
@@ -0,0 +1,48 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/workspace_dna.h
+ * \ingroup bke
+ *
+ * Local header with WorkSpace DNA types. makesdna.c includes this.
+ */
+
+#ifndef __WORKSPACE_DNA_H__
+#define __WORKSPACE_DNA_H__
+
+/**
+ * Layouts are basically bScreens. We use this struct to wrap a reference to a screen so that we can store it in
+ * a ListBase within a workspace. Usually you shouldn't have to deal with it, only with bScree
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list