Cleanup: add missing includes
[blender.git] / source / blender / windowmanager / WM_keymap.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  * The Original Code is Copyright (C) 2007 Blender Foundation.
17  * All rights reserved.
18  */
19
20 #pragma once
21
22 /** \file
23  * \ingroup wm
24  */
25
26 /* dna-savable wmStructs here */
27 #include "BLI_utildefines.h"
28 #include "DNA_windowmanager_types.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 struct EnumPropertyItem;
35
36 /* Key Configuration */
37
38 void WM_keyconfig_init(struct bContext *C);
39 void WM_keyconfig_reload(struct bContext *C);
40
41 wmKeyConfig *WM_keyconfig_new(struct wmWindowManager *wm, const char *idname, bool user_defined);
42 wmKeyConfig *WM_keyconfig_new_user(struct wmWindowManager *wm, const char *idname);
43 bool WM_keyconfig_remove(struct wmWindowManager *wm, struct wmKeyConfig *keyconf);
44 void WM_keyconfig_clear(struct wmKeyConfig *keyconf);
45 void WM_keyconfig_free(struct wmKeyConfig *keyconf);
46
47 void WM_keyconfig_set_active(struct wmWindowManager *wm, const char *idname);
48
49 void WM_keyconfig_update(struct wmWindowManager *wm);
50 void WM_keyconfig_update_tag(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
51 void WM_keyconfig_update_operatortype(void);
52
53 /* Keymap */
54
55 void WM_keymap_clear(struct wmKeyMap *keymap);
56
57 wmKeyMapItem *WM_keymap_add_item(
58     struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier);
59 wmKeyMapItem *WM_keymap_add_item_copy(struct wmKeyMap *keymap, wmKeyMapItem *kmi_src);
60
61 bool WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
62 int WM_keymap_item_to_string(const wmKeyMapItem *kmi,
63                              const bool compact,
64                              char *result,
65                              const int result_len);
66
67 wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid);
68 wmKeyMap *WM_keymap_list_find_spaceid_or_empty(ListBase *lb,
69                                                const char *idname,
70                                                int spaceid,
71                                                int regionid);
72 wmKeyMap *WM_keymap_ensure(struct wmKeyConfig *keyconf,
73                            const char *idname,
74                            int spaceid,
75                            int regionid);
76 wmKeyMap *WM_keymap_find_all(struct wmWindowManager *wm,
77                              const char *idname,
78                              int spaceid,
79                              int regionid);
80 wmKeyMap *WM_keymap_find_all_spaceid_or_empty(struct wmWindowManager *wm,
81                                               const char *idname,
82                                               int spaceid,
83                                               int regionid);
84 wmKeyMap *WM_keymap_active(const struct wmWindowManager *wm, struct wmKeyMap *keymap);
85 bool WM_keymap_remove(struct wmKeyConfig *keyconfig, struct wmKeyMap *keymap);
86 bool WM_keymap_poll(struct bContext *C, struct wmKeyMap *keymap);
87
88 wmKeyMapItem *WM_keymap_item_find_id(struct wmKeyMap *keymap, int id);
89 bool WM_keymap_item_compare(const struct wmKeyMapItem *k1, const struct wmKeyMapItem *k2);
90
91 /* keymap_utils.c */
92
93 /** Wrappers for #WM_keymap_add_item */
94 wmKeyMapItem *WM_keymap_add_menu(
95     struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier);
96 wmKeyMapItem *WM_keymap_add_menu_pie(
97     struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier);
98 wmKeyMapItem *WM_keymap_add_panel(
99     struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier);
100 wmKeyMapItem *WM_keymap_add_tool(
101     struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier);
102
103 void WM_keymap_add_context_enum_set_items(wmKeyMap *keymap,
104                                           const struct EnumPropertyItem *items,
105                                           const char *data_path,
106                                           int type_start,
107                                           int val,
108                                           int modifier,
109                                           int keymodifier);
110
111 wmKeyMap *WM_keymap_guess_from_context(const struct bContext *C);
112 wmKeyMap *WM_keymap_guess_opname(const struct bContext *C, const char *opname);
113
114 bool WM_keymap_uses_event_modifier(const wmKeyMap *keymap, const int event_modifier);
115
116 void WM_keymap_fix_linking(void);
117
118 /* Modal Keymap */
119
120 int WM_modalkeymap_items_to_string(const struct wmKeyMap *km,
121                                    const int propvalue,
122                                    const bool compact,
123                                    char *result,
124                                    const int result_len);
125 int WM_modalkeymap_operator_items_to_string(struct wmOperatorType *ot,
126                                             const int propvalue,
127                                             const bool compact,
128                                             char *result,
129                                             const int result_len);
130 char *WM_modalkeymap_operator_items_to_string_buf(struct wmOperatorType *ot,
131                                                   const int propvalue,
132                                                   const bool compact,
133                                                   const int max_len,
134                                                   int *r_available_len,
135                                                   char **r_result);
136
137 wmKeyMap *WM_modalkeymap_ensure(struct wmKeyConfig *keyconf,
138                                 const char *idname,
139                                 const struct EnumPropertyItem *items);
140 wmKeyMap *WM_modalkeymap_find(struct wmKeyConfig *keyconf, const char *idname);
141 wmKeyMapItem *WM_modalkeymap_add_item(
142     struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value);
143 wmKeyMapItem *WM_modalkeymap_add_item_str(
144     struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value);
145 const wmKeyMapItem *WM_modalkeymap_find_propvalue(const wmKeyMap *km, const int propvalue);
146 void WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname);
147
148 /* Keymap Editor */
149
150 void WM_keymap_restore_to_default(struct wmKeyMap *keymap, struct wmWindowManager *wm);
151 void WM_keymap_item_properties_reset(struct wmKeyMapItem *kmi, struct IDProperty *properties);
152 void WM_keymap_item_restore_to_default(wmWindowManager *wm,
153                                        struct wmKeyMap *keymap,
154                                        struct wmKeyMapItem *kmi);
155 int WM_keymap_item_map_type_get(const struct wmKeyMapItem *kmi);
156
157 /* Key Event */
158
159 const char *WM_key_event_string(const short type, const bool compact);
160 int WM_keymap_item_raw_to_string(const short shift,
161                                  const short ctrl,
162                                  const short alt,
163                                  const short oskey,
164                                  const short keymodifier,
165                                  const short val,
166                                  const short type,
167                                  const bool compact,
168                                  char *result,
169                                  const int result_len);
170 wmKeyMapItem *WM_key_event_operator(const struct bContext *C,
171                                     const char *opname,
172                                     int opcontext,
173                                     struct IDProperty *properties,
174                                     const short include_mask,
175                                     const short exclude_mask,
176                                     struct wmKeyMap **r_keymap);
177 char *WM_key_event_operator_string(const struct bContext *C,
178                                    const char *opname,
179                                    int opcontext,
180                                    struct IDProperty *properties,
181                                    const bool is_strict,
182                                    char *result,
183                                    const int result_len);
184
185 wmKeyMapItem *WM_key_event_operator_from_keymap(struct wmKeyMap *keymap,
186                                                 const char *opname,
187                                                 struct IDProperty *properties,
188                                                 const short include_mask,
189                                                 const short exclude_mask);
190
191 const char *WM_bool_as_string(bool test);
192
193 #ifdef __cplusplus
194 }
195 #endif