[Bf-blender-cvs] [5afda4b7fb] temp-workspace-multi-window: Multi-Window support: Store screen-types per workspace
Julian Eisel
noreply at git.blender.org
Fri Feb 24 00:33:39 CET 2017
Commit: 5afda4b7fbfea02ceb27f1a8156b6a058abf59dc
Author: Julian Eisel
Date: Tue Feb 14 21:02:36 2017 +0100
Branches: temp-workspace-multi-window
https://developer.blender.org/rB5afda4b7fbfea02ceb27f1a8156b6a058abf59dc
Multi-Window support: Store screen-types per workspace
===================================================================
M source/blender/blenkernel/BKE_workspace.h
M source/blender/blenkernel/intern/workspace.c
M source/blender/makesdna/dna_workspace_types.h
M source/blender/makesrna/RNA_access.h
M source/blender/makesrna/intern/rna_workspace.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h
index 8cd884e193..5bb1689f41 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -36,6 +36,7 @@ struct WorkSpace;
typedef struct WorkSpace WorkSpace;
typedef struct WorkSpaceLayout WorkSpaceLayout;
+typedef struct WorkSpaceLayoutType WorkSpaceLayoutType;
/**
* Plan is to store the object-mode per workspace, not per object anymore.
@@ -100,6 +101,8 @@ 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;
+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();
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 37d4538cd0..4d4e643e78 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -65,6 +65,7 @@ WorkSpace *BKE_workspace_add(Main *bmain, const char *name)
void BKE_workspace_free(WorkSpace *ws)
{
+ BLI_freelistN(&ws->layout_types);
BLI_freelistN(&ws->layouts);
}
@@ -85,19 +86,29 @@ void BKE_workspace_remove(WorkSpace *workspace, Main *bmain)
*/
WorkSpaceLayout *BKE_workspace_layout_add(WorkSpace *workspace, 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));
layout->screen = screen;
BLI_addhead(&workspace->layouts, layout);
+ layout_type->name = screen->id.name + 2;
+ BLI_addhead(&workspace->layout_types, layout_type);
+
return layout;
}
void BKE_workspace_layout_remove(WorkSpace *workspace, WorkSpaceLayout *layout, Main *bmain)
{
- BKE_libblock_free(bmain, BKE_workspace_layout_screen_get(layout));
+ 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);
+ BKE_libblock_free(bmain, screen);
BLI_freelinkN(&workspace->layouts, layout);
+ BLI_freelinkN(&workspace->layout_types, layout_type);
}
@@ -246,6 +257,16 @@ ListBase *BKE_workspace_layouts_get(WorkSpace *workspace)
return &workspace->layouts;
}
+ListBase *BKE_workspace_layout_types_get(WorkSpace *workspace)
+{
+ return &workspace->layout_types;
+}
+
+const char *BKE_workspace_layout_type_name_get(WorkSpaceLayoutType *layout_type)
+{
+ return layout_type->name;
+}
+
WorkSpace *BKE_workspace_next_get(const WorkSpace *workspace)
{
return workspace->id.next;
diff --git a/source/blender/makesdna/dna_workspace_types.h b/source/blender/makesdna/dna_workspace_types.h
index 956b0ef0b8..1eef392a13 100644
--- a/source/blender/makesdna/dna_workspace_types.h
+++ b/source/blender/makesdna/dna_workspace_types.h
@@ -46,9 +46,15 @@ typedef struct WorkSpaceLayout {
struct bScreen *screen;
} WorkSpaceLayout;
+typedef struct WorkSpaceLayoutType {
+ struct WorkSpaceLayoutType *next, *prev;
+ const char *name;
+} WorkSpaceLayoutType;
+
typedef struct WorkSpace {
ID id;
+ ListBase layout_types;
ListBase layouts;
struct WorkSpaceLayout *act_layout;
struct WorkSpaceLayout *new_layout; /* temporary when switching screens */
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 9cda8c0883..9e0ee40233 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -710,6 +710,7 @@ extern StructRNA RNA_WipeSequence;
extern StructRNA RNA_WireframeModifier;
extern StructRNA RNA_WoodTexture;
extern StructRNA RNA_WorkSpace;
+extern StructRNA RNA_WorkSpaceLayoutType;
extern StructRNA RNA_World;
extern StructRNA RNA_WorldAmbientOcclusion;
extern StructRNA RNA_WorldLighting;
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index 287edf1d2b..aa82f9992c 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -114,10 +114,46 @@ static void rna_workspace_object_mode_set(PointerRNA *ptr, int value)
BKE_workspace_object_mode_set(workspace, value);
}
+void rna_workspace_layout_types_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ WorkSpace *workspace = ptr->data;
+ rna_iterator_listbase_begin(iter, BKE_workspace_layout_types_get(workspace), NULL);
+}
+
+static void rna_workspace_layout_type_name_get(PointerRNA *ptr, char *value)
+{
+ WorkSpaceLayoutType *layout_type = ptr->data;
+ const char *name = BKE_workspace_layout_type_name_get(layout_type);
+ BLI_strncpy(value, name, strlen(name) + 1);
+}
+
+static int rna_workspace_layout_type_name_length(PointerRNA *ptr)
+{
+ WorkSpaceLayoutType *layout_type = ptr->data;
+ return strlen(BKE_workspace_layout_type_name_get(layout_type));
+}
+
#endif /* USE_WORKSPACE_MODE */
#else /* RNA_RUNTIME */
+static void rna_def_workspace_layout_type(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "WorkSpaceLayoutType", NULL);
+ RNA_def_struct_sdna(srna, "WorkSpaceLayoutType");
+ RNA_def_struct_ui_text(srna, "Layout Type", "");
+ RNA_def_struct_ui_icon(srna, ICON_NONE);
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_funcs(prop, "rna_workspace_layout_type_name_get", "rna_workspace_layout_type_name_length",
+ NULL);
+ RNA_def_property_ui_text(prop, "Name", "Workspace screen-layout name");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+}
+
static void rna_def_workspace(BlenderRNA *brna)
{
StructRNA *srna;
@@ -144,6 +180,13 @@ 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_types", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_struct_type(prop, "WorkSpaceLayoutType");
+ RNA_def_property_collection_funcs(prop, "rna_workspace_layout_types_begin", NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop, "Layout Types", "The different screen-layout types that can be visible "
+ "in the workspace");
+
#ifdef USE_WORKSPACE_MODE
prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_object_mode_items);
@@ -155,6 +198,7 @@ static void rna_def_workspace(BlenderRNA *brna)
void RNA_def_workspace(BlenderRNA *brna)
{
rna_def_workspace(brna);
+ rna_def_workspace_layout_type(brna);
}
#endif /* RNA_RUNTIME */
More information about the Bf-blender-cvs
mailing list