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 bToolRef;
32 struct Main;
33 struct Scene;
34 struct TransformOrientation;
35 struct ViewLayer;
36
37 /* -------------------------------------------------------------------- */
38 /* Create, delete, init */
39
40 struct WorkSpace *BKE_workspace_add(struct Main *bmain, const char *name);
41 void BKE_workspace_free(struct WorkSpace *workspace);
42 void BKE_workspace_remove(struct Main *bmain, struct WorkSpace *workspace);
43
44 struct WorkSpaceInstanceHook *BKE_workspace_instance_hook_create(const struct Main *bmain);
45 void BKE_workspace_instance_hook_free(const struct Main *bmain, struct WorkSpaceInstanceHook *hook);
46
47 struct WorkSpaceLayout *BKE_workspace_layout_add(
48         struct Main *bmain,
49         struct WorkSpace *workspace,
50         struct bScreen *screen,
51         const char *name) ATTR_NONNULL();
52 void BKE_workspace_layout_remove(
53         struct Main *bmain,
54         struct WorkSpace *workspace, struct WorkSpaceLayout *layout) ATTR_NONNULL();
55
56 void BKE_workspace_relations_free(
57         ListBase *relation_list);
58
59
60 /* -------------------------------------------------------------------- */
61 /* General Utils */
62
63 struct WorkSpaceLayout *BKE_workspace_layout_find(
64         const struct WorkSpace *workspace, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
65 struct WorkSpaceLayout *BKE_workspace_layout_find_global(
66         const struct Main *bmain, const struct bScreen *screen,
67         struct WorkSpace **r_workspace) ATTR_NONNULL(1, 2);
68
69 struct WorkSpaceLayout *BKE_workspace_layout_iter_circular(
70         const struct WorkSpace *workspace, struct WorkSpaceLayout *start,
71         bool (*callback)(const struct WorkSpaceLayout *layout, void *arg),
72         void *arg, const bool iter_backward);
73
74 void BKE_workspace_tool_remove(
75         struct WorkSpace *workspace, struct bToolRef *tref) ATTR_NONNULL(1, 2);
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 ListBase *BKE_workspace_layouts_get(struct WorkSpace *workspace) GETTER_ATTRS;
92
93 const char *BKE_workspace_layout_name_get(const struct WorkSpaceLayout *layout) GETTER_ATTRS;
94 void        BKE_workspace_layout_name_set(
95         struct WorkSpace *workspace, struct WorkSpaceLayout *layout, const char *new_name) ATTR_NONNULL();
96 struct bScreen *BKE_workspace_layout_screen_get(const struct WorkSpaceLayout *layout) GETTER_ATTRS;
97 void            BKE_workspace_layout_screen_set(struct WorkSpaceLayout *layout, struct bScreen *screen) SETTER_ATTRS;
98
99 struct WorkSpaceLayout *BKE_workspace_hook_layout_for_workspace_get(
100         const struct WorkSpaceInstanceHook *hook, const struct WorkSpace *workspace) GETTER_ATTRS;
101 void             BKE_workspace_hook_layout_for_workspace_set(
102         struct WorkSpaceInstanceHook *hook, struct WorkSpace *workspace, struct WorkSpaceLayout *layout) ATTR_NONNULL();
103
104 bool BKE_workspace_owner_id_check(
105         const struct WorkSpace *workspace, const char *owner_id) ATTR_NONNULL();
106
107 #undef GETTER_ATTRS
108 #undef SETTER_ATTRS
109
110 #endif /* __BKE_WORKSPACE_H__ */