Merge branch 'master' into blender2.8
[blender.git] / source / blender / blenkernel / BKE_workspace.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * ***** END GPL LICENSE BLOCK *****
19  */
20
21 /** \file BKE_workspace.h
22  *  \ingroup bke
23  */
24
25 #ifndef __BKE_WORKSPACE_H__
26 #define __BKE_WORKSPACE_H__
27
28 #include "BLI_compiler_attrs.h"
29
30 struct bScreen;
31 struct Main;
32 struct Scene;
33 struct TransformOrientation;
34 struct ViewLayer;
35
36 /* -------------------------------------------------------------------- */
37 /* Create, delete, init */
38
39 struct WorkSpace *BKE_workspace_add(struct Main *bmain, const char *name);
40 void BKE_workspace_free(struct WorkSpace *workspace);
41 void BKE_workspace_remove(struct Main *bmain, struct WorkSpace *workspace);
42
43 struct WorkSpaceInstanceHook *BKE_workspace_instance_hook_create(const struct Main *bmain);
44 void BKE_workspace_instance_hook_free(const struct Main *bmain, struct WorkSpaceInstanceHook *hook);
45
46 struct WorkSpaceLayout *BKE_workspace_layout_add(
47         struct WorkSpace *workspace,
48         struct bScreen *screen,
49         const char *name) ATTR_NONNULL();
50 void BKE_workspace_layout_remove(
51         struct Main *bmain,
52         struct WorkSpace *workspace, struct WorkSpaceLayout *layout) ATTR_NONNULL();
53
54 void BKE_workspace_relations_free(
55         ListBase *relation_list);
56
57
58 /* -------------------------------------------------------------------- */
59 /* General Utils */
60
61 void BKE_workspace_view_layer_remove_references(
62         const struct Main *bmain,
63         const struct ViewLayer *view_layer) ATTR_NONNULL();
64
65 struct WorkSpaceLayout *BKE_workspace_layout_find(
66         const struct WorkSpace *workspace, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
67 struct WorkSpaceLayout *BKE_workspace_layout_find_global(
68         const struct Main *bmain, const struct bScreen *screen,
69         struct WorkSpace **r_workspace) ATTR_NONNULL(1, 2);
70
71 struct WorkSpaceLayout *BKE_workspace_layout_iter_circular(
72         const struct WorkSpace *workspace, struct WorkSpaceLayout *start,
73         bool (*callback)(const struct WorkSpaceLayout *layout, void *arg),
74         void *arg, const bool iter_backward);
75
76
77 /* -------------------------------------------------------------------- */
78 /* Getters/Setters */
79
80 #define GETTER_ATTRS ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
81 #define SETTER_ATTRS ATTR_NONNULL(1)
82
83 struct WorkSpace *BKE_workspace_active_get(struct WorkSpaceInstanceHook *hook) GETTER_ATTRS;
84 void       BKE_workspace_active_set(struct WorkSpaceInstanceHook *hook, struct WorkSpace *workspace) SETTER_ATTRS;
85 struct WorkSpaceLayout *BKE_workspace_active_layout_get(const struct WorkSpaceInstanceHook *hook) GETTER_ATTRS;
86 void             BKE_workspace_active_layout_set(struct WorkSpaceInstanceHook *hook, struct WorkSpaceLayout *layout) SETTER_ATTRS;
87 struct bScreen *BKE_workspace_active_screen_get(const struct WorkSpaceInstanceHook *hook) GETTER_ATTRS;
88 void            BKE_workspace_active_screen_set(
89         struct WorkSpaceInstanceHook *hook, struct WorkSpace *workspace, struct bScreen *screen) SETTER_ATTRS;
90
91 struct Base *BKE_workspace_active_base_get(const struct WorkSpace *workspace, const struct Scene *scene);
92 struct ViewLayer *BKE_workspace_view_layer_get(
93         const struct WorkSpace *workspace,
94         const struct Scene *scene) GETTER_ATTRS;
95 void BKE_workspace_view_layer_set(
96         struct WorkSpace *workspace,
97         struct ViewLayer *layer,
98         struct Scene *scene) SETTER_ATTRS;
99 struct ListBase *BKE_workspace_layouts_get(struct WorkSpace *workspace) GETTER_ATTRS;
100
101 const char *BKE_workspace_layout_name_get(const struct WorkSpaceLayout *layout) GETTER_ATTRS;
102 void        BKE_workspace_layout_name_set(
103         struct WorkSpace *workspace, struct WorkSpaceLayout *layout, const char *new_name) ATTR_NONNULL();
104 struct bScreen *BKE_workspace_layout_screen_get(const struct WorkSpaceLayout *layout) GETTER_ATTRS;
105 void            BKE_workspace_layout_screen_set(struct WorkSpaceLayout *layout, struct bScreen *screen) SETTER_ATTRS;
106
107 struct WorkSpaceLayout *BKE_workspace_hook_layout_for_workspace_get(
108         const struct WorkSpaceInstanceHook *hook, const struct WorkSpace *workspace) GETTER_ATTRS;
109 void             BKE_workspace_hook_layout_for_workspace_set(
110         struct WorkSpaceInstanceHook *hook, struct WorkSpace *workspace, struct WorkSpaceLayout *layout) ATTR_NONNULL();
111
112 /* Update / evaluate */
113 void BKE_workspace_update_tagged(struct Main *bmain,
114                                  struct WorkSpace *workspace,
115                                  struct Scene *scene);
116
117 bool BKE_workspace_owner_id_check(
118         const struct WorkSpace *workspace, const char *owner_id) ATTR_NONNULL();
119
120 #undef GETTER_ATTRS
121 #undef SETTER_ATTRS
122
123 #endif /* __BKE_WORKSPACE_H__ */