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