[Bf-blender-cvs] [8c250c9b737] workspaces: General cleanup of workspace files (naming, function ordering, etc)

Julian Eisel noreply at git.blender.org
Sat Apr 8 17:43:06 CEST 2017


Commit: 8c250c9b7379752046de6cf35c86d9015f4c5f60
Author: Julian Eisel
Date:   Sat Apr 8 17:23:14 2017 +0200
Branches: workspaces
https://developer.blender.org/rB8c250c9b7379752046de6cf35c86d9015f4c5f60

General cleanup of workspace files (naming, function ordering, etc)

===================================================================

M	source/blender/blenkernel/BKE_workspace.h
M	source/blender/blenkernel/intern/workspace.c
M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/screen/workspace_edit.c
M	source/blender/editors/screen/workspace_layout_edit.c
M	source/blender/makesrna/intern/rna_screen.c
M	source/blender/windowmanager/intern/wm_event_system.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 c66952096d2..77d4af49257 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -52,16 +52,19 @@ typedef struct WorkSpaceLayout WorkSpaceLayout;
 /* Create, delete, init */
 
 WorkSpace *BKE_workspace_add(struct Main *bmain, const char *name);
-void BKE_workspace_free(WorkSpace *ws);
+void BKE_workspace_free(WorkSpace *workspace);
 void BKE_workspace_remove(WorkSpace *workspace, struct Main *bmain);
 
 WorkSpaceInstanceHook *BKE_workspace_instance_hook_create(const struct Main *bmain);
 void BKE_workspace_instance_hook_free(WorkSpaceInstanceHook *hook, const struct Main *bmain);
 
 struct WorkSpaceLayout *BKE_workspace_layout_add(
-        WorkSpace *workspace, struct bScreen *screen, const char *name) ATTR_NONNULL();
+        WorkSpace *workspace,
+        struct bScreen *screen,
+        const char *name) ATTR_NONNULL();
 void BKE_workspace_layout_remove(
-        WorkSpace *workspace, WorkSpaceLayout *layout, struct Main *bmain) ATTR_NONNULL();
+        WorkSpace *workspace, WorkSpaceLayout *layout,
+        struct Main *bmain) ATTR_NONNULL();
 
 
 /* -------------------------------------------------------------------- */
@@ -77,9 +80,7 @@ void BKE_workspaces_transform_orientation_remove(
         const struct TransformOrientation *orientation) ATTR_NONNULL();
 
 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;
+        const WorkSpace *workspace, const struct bScreen *screen) 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) { \
@@ -98,19 +99,18 @@ WorkSpaceLayout *BKE_workspace_layout_iter_circular(
 /* -------------------------------------------------------------------- */
 /* Getters/Setters */
 
-WorkSpace *BKE_workspace_temp_store_get(WorkSpaceInstanceHook *hook) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-void       BKE_workspace_temp_store_set(WorkSpaceInstanceHook *hook, WorkSpace *workspace) ATTR_NONNULL(1);
 WorkSpace *BKE_workspace_active_get(WorkSpaceInstanceHook *hook) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 void       BKE_workspace_active_set(WorkSpaceInstanceHook *hook, WorkSpace *workspace) 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_from_workspace(
-        const WorkSpaceInstanceHook *hook, const WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+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;
+WorkSpace *BKE_workspace_temp_store_get(WorkSpaceInstanceHook *hook) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+void       BKE_workspace_temp_store_set(WorkSpaceInstanceHook *hook, WorkSpace *workspace) ATTR_NONNULL(1);
 WorkSpaceLayout *BKE_workspace_active_layout_get(const WorkSpaceInstanceHook *hook) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-void             BKE_workspace_active_layout_set(
-        WorkSpaceInstanceHook *hook, WorkSpaceLayout *layout) ATTR_NONNULL(1);
-void BKE_workspace_active_layout_set_for_workspace(
-        WorkSpaceInstanceHook *hook, WorkSpace *workspace, WorkSpaceLayout *layout) ATTR_NONNULL(1);
+void             BKE_workspace_active_layout_set(WorkSpaceInstanceHook *hook, WorkSpaceLayout *layout) ATTR_NONNULL(1);
+WorkSpaceLayout *BKE_workspace_temp_layout_store_get(const WorkSpaceInstanceHook *hook) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+void             BKE_workspace_temp_layout_store_set(WorkSpaceInstanceHook *hook, WorkSpaceLayout *layout) ATTR_NONNULL(1);
 struct bScreen *BKE_workspace_active_screen_get(const WorkSpaceInstanceHook *hook) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 void            BKE_workspace_active_screen_set(
         WorkSpaceInstanceHook *hook, struct WorkSpace *workspace, struct bScreen *screen) ATTR_NONNULL(1);
@@ -121,11 +121,6 @@ void            BKE_workspace_object_mode_set(WorkSpace *workspace, const enum O
 struct SceneLayer *BKE_workspace_render_layer_get(const WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 void               BKE_workspace_render_layer_set(WorkSpace *workspace, struct SceneLayer *layer) ATTR_NONNULL(1);
 struct ListBase *BKE_workspace_layouts_get(WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-WorkSpaceLayout *BKE_workspace_temp_layout_store_get(const WorkSpaceInstanceHook *hook) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-void             BKE_workspace_temp_layout_store_set(WorkSpaceInstanceHook *hook, 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;
 
 const char *BKE_workspace_layout_name_get(const WorkSpaceLayout *layout) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 void        BKE_workspace_layout_name_set(WorkSpace *workspace, WorkSpaceLayout *layout, const char *new_name) ATTR_NONNULL();
@@ -134,9 +129,16 @@ void            BKE_workspace_layout_screen_set(WorkSpaceLayout *layout, struct
 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;
 
+WorkSpaceLayout *BKE_workspace_hook_layout_for_workspace_get(
+        const WorkSpaceInstanceHook *hook, const WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+void             BKE_workspace_hook_layout_for_workspace_set(
+        WorkSpaceInstanceHook *hook, WorkSpace *workspace, WorkSpaceLayout *layout) ATTR_NONNULL(1);
 struct ListBase *BKE_workspace_hook_layout_relations_get(WorkSpace *workspace) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+
 struct WorkSpaceDataRelation *BKE_workspace_relation_next_get(const struct WorkSpaceDataRelation *relation) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-void BKE_workspace_relation_data_get(const struct WorkSpaceDataRelation *relation, void **parent, void **data) ATTR_NONNULL();
+void BKE_workspace_relation_data_get(
+        const struct WorkSpaceDataRelation *relation,
+        void **parent, void **data) ATTR_NONNULL();
 void BKE_workspace_relation_data_set(struct WorkSpaceDataRelation *relation, void *parent, void *data) ATTR_NONNULL();
 
 /* -------------------------------------------------------------------- */
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index feffc672701..3c3e7aefe5d 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -45,18 +45,43 @@
 #include "MEM_guardedalloc.h"
 
 
-bool workspaces_is_screen_used(const Main *bmain, bScreen *screen);
-
 /* -------------------------------------------------------------------- */
 /* Internal utils */
 
-static void workspace_name_set(WorkSpace *workspace, WorkSpaceLayout *layout, const char *new_name)
+/**
+ * Only to be called by #BKE_libblock_alloc_notest! Always use BKE_workspace_add to add a new workspace.
+ */
+WorkSpace *workspace_alloc(void)
+{
+	return MEM_callocN(sizeof(WorkSpace), __func__);
+}
+
+static void workspace_layout_name_set(
+        WorkSpace *workspace, WorkSpaceLayout *layout, const char *new_name)
 {
 	BLI_strncpy(layout->name, new_name, sizeof(layout->name));
 	BLI_uniquename(&workspace->layouts, layout, "Layout", '.', offsetof(WorkSpaceLayout, name), sizeof(layout->name));
 }
 
-static void workspace_relation_add(ListBase *relation_list, void *parent, void *data)
+/**
+ * This should only be used directly when it is to be expected that there isn't
+ * a layout within \a workspace that wraps \a screen. Usually - especially outside
+ * of BKE_workspace - #BKE_workspace_layout_find should be used!
+ */
+static WorkSpaceLayout *workspace_layout_find_exec(
+        const WorkSpace *workspace, const bScreen *screen)
+{
+	for (WorkSpaceLayout *layout = workspace->layouts.first; layout; layout = layout->next) {
+		if (layout->screen == screen) {
+			return layout;
+		}
+	}
+
+	return NULL;
+}
+
+static void workspace_relation_add(
+        ListBase *relation_list, void *parent, void *data)
 {
 	WorkSpaceDataRelation *relation = MEM_mallocN(sizeof(*relation), __func__);
 	relation->parent = parent;
@@ -64,13 +89,15 @@ static void workspace_relation_add(ListBase *relation_list, void *parent, void *
 	/* add to head, if we switch back to it soon we find it faster. */
 	BLI_addhead(relation_list, relation);
 }
-static void workspace_relation_remove(ListBase *relation_list, WorkSpaceDataRelation *relation)
+static void workspace_relation_remove(
+        ListBase *relation_list, WorkSpaceDataRelation *relation)
 {
 	BLI_remlink(relation_list, relation);
 	MEM_freeN(relation);
 }
 
-static void workspace_ensure_updated_relation(ListBase *relation_list, void *parent, void *data)
+static void workspace_relation_ensure_updated(
+        ListBase *relation_list, void *parent, void *data)
 {
 	for (WorkSpaceDataRelation *relation = relation_list->first; relation; relation = relation->next) {
 		if (relation->parent == parent) {
@@ -86,7 +113,8 @@ static void workspace_ensure_updated_relation(ListBase *relation_list, void *par
 	workspace_relation_add(relation_list, parent, data);
 }
 
-static void *workspace_relation_get_data_matching_parent(const ListBase *relation_list, const void *parent)
+static void *workspace_relation_get_data_matching_parent(
+        const ListBase *relation_list, const void *parent)
 {
 	for (WorkSpaceDataRelation *relation = relation_list->first; relation; relation = relation->next) {
 		if (rel

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list