Cleanup: disable debug code
[blender.git] / source / blender / windowmanager / WM_toolsystem.h
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 #ifndef __WM_TOOLSYSTEM_H__
17 #define __WM_TOOLSYSTEM_H__
18
19 /** \file
20  * \ingroup wm
21  */
22
23 /* dna-savable wmStructs here */
24 #include "BLI_compiler_attrs.h"
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 struct IDProperty;
31 struct Main;
32 struct PointerRNA;
33 struct ScrArea;
34 struct StructRNA;
35 struct WorkSpace;
36 struct bContext;
37 struct bToolRef_Runtime;
38 struct wmMsgSubscribeKey;
39 struct wmMsgSubscribeValue;
40 struct wmOperatorType;
41
42 /* wm_toolsystem.c  */
43
44 #define WM_TOOLSYSTEM_SPACE_MASK \
45   ((1 << SPACE_IMAGE) | (1 << SPACE_NODE) | (1 << SPACE_VIEW3D) | (1 << SPACE_SEQ))
46 /* Values that define a categoey of active tool. */
47 typedef struct bToolKey {
48   int space_type;
49   int mode;
50 } bToolKey;
51
52 struct bToolRef *WM_toolsystem_ref_from_context(struct bContext *C);
53 struct bToolRef *WM_toolsystem_ref_find(struct WorkSpace *workspace, const bToolKey *tkey);
54 bool WM_toolsystem_ref_ensure(struct WorkSpace *workspace,
55                               const bToolKey *tkey,
56                               struct bToolRef **r_tref);
57
58 struct bToolRef *WM_toolsystem_ref_set_by_id_ex(struct bContext *C,
59                                                 struct WorkSpace *workspace,
60                                                 const bToolKey *tkey,
61                                                 const char *name,
62                                                 bool cycle);
63 struct bToolRef *WM_toolsystem_ref_set_by_id(struct bContext *C, const char *name);
64
65 struct bToolRef_Runtime *WM_toolsystem_runtime_from_context(struct bContext *C);
66 struct bToolRef_Runtime *WM_toolsystem_runtime_find(struct WorkSpace *workspace,
67                                                     const bToolKey *tkey);
68
69 void WM_toolsystem_unlink(struct bContext *C, struct WorkSpace *workspace, const bToolKey *tkey);
70 void WM_toolsystem_refresh(struct bContext *C, struct WorkSpace *workspace, const bToolKey *tkey);
71 void WM_toolsystem_reinit(struct bContext *C, struct WorkSpace *workspace, const bToolKey *tkey);
72
73 void WM_toolsystem_unlink_all(struct bContext *C, struct WorkSpace *workspace);
74 void WM_toolsystem_refresh_all(struct bContext *C, struct WorkSpace *workspace);
75 void WM_toolsystem_reinit_all(struct bContext *C, struct wmWindow *win);
76
77 void WM_toolsystem_ref_set_from_runtime(struct bContext *C,
78                                         struct WorkSpace *workspace,
79                                         struct bToolRef *tref,
80                                         const struct bToolRef_Runtime *tool,
81                                         const char *idname);
82
83 void WM_toolsystem_ref_sync_from_context(struct Main *bmain,
84                                          struct WorkSpace *workspace,
85                                          struct bToolRef *tref);
86
87 void WM_toolsystem_init(struct bContext *C);
88
89 int WM_toolsystem_mode_from_spacetype(struct ViewLayer *view_layer,
90                                       struct ScrArea *area,
91                                       int space_type);
92 bool WM_toolsystem_key_from_context(struct ViewLayer *view_layer,
93                                     struct ScrArea *area,
94                                     bToolKey *tkey);
95
96 void WM_toolsystem_update_from_context_view3d(struct bContext *C);
97 void WM_toolsystem_update_from_context(struct bContext *C,
98                                        struct WorkSpace *workspace,
99                                        struct ViewLayer *view_layer,
100                                        struct ScrArea *area);
101
102 bool WM_toolsystem_active_tool_is_brush(const struct bContext *C);
103
104 void WM_toolsystem_do_msg_notify_tag_refresh(struct bContext *C,
105                                              struct wmMsgSubscribeKey *msg_key,
106                                              struct wmMsgSubscribeValue *msg_val);
107
108 struct IDProperty *WM_toolsystem_ref_properties_ensure_idprops(struct bToolRef *tref);
109 void WM_toolsystem_ref_properties_ensure_ex(struct bToolRef *tref,
110                                             const char *idname,
111                                             struct StructRNA *type,
112                                             struct PointerRNA *r_ptr);
113
114 #define WM_toolsystem_ref_properties_ensure_from_operator(tref, ot, r_ptr) \
115   WM_toolsystem_ref_properties_ensure_ex(tref, (ot)->idname, (ot)->srna, r_ptr)
116 #define WM_toolsystem_ref_properties_ensure_from_gizmo_group(tref, gzgroup, r_ptr) \
117   WM_toolsystem_ref_properties_ensure_ex(tref, (gzgroup)->idname, (gzgroup)->srna, r_ptr)
118
119 bool WM_toolsystem_ref_properties_get_ex(struct bToolRef *tref,
120                                          const char *idname,
121                                          struct StructRNA *type,
122                                          struct PointerRNA *r_ptr);
123 #define WM_toolsystem_ref_properties_get_from_operator(tref, ot, r_ptr) \
124   WM_toolsystem_ref_properties_get_ex(tref, (ot)->idname, (ot)->srna, r_ptr)
125 #define WM_toolsystem_ref_properties_get_from_gizmo_group(tref, gzgroup, r_ptr) \
126   WM_toolsystem_ref_properties_get_ex(tref, (gzgroup)->idname, (gzgroup)->srna, r_ptr)
127
128 void WM_toolsystem_ref_properties_init_for_keymap(struct bToolRef *tref,
129                                                   struct PointerRNA *dst_ptr,
130                                                   struct PointerRNA *src_ptr,
131                                                   struct wmOperatorType *ot);
132
133 void WM_toolsystem_refresh_active(struct bContext *C);
134
135 void WM_toolsystem_refresh_screen_area(struct WorkSpace *workspace,
136                                        struct ViewLayer *view_layer,
137                                        struct ScrArea *area);
138 void WM_toolsystem_refresh_screen_all(struct Main *bmain);
139
140 #ifdef __cplusplus
141 }
142 #endif
143
144 #endif /* __WM_TOOLSYSTEM_API_H__ */