2 * ***** BEGIN GPL LICENSE BLOCK *****
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.
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.
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.
18 * The Original Code is Copyright (C) 2007 Blender Foundation.
19 * All rights reserved.
21 * Contributor(s): Blender Foundation
23 * ***** END GPL LICENSE BLOCK *****
26 #ifndef __WM_KEYMAP_H__
27 #define __WM_KEYMAP_H__
29 /** \file blender/windowmanager/WM_keymap.h
33 /* dna-savable wmStructs here */
34 #include "DNA_windowmanager_types.h"
35 #include "BLI_utildefines.h"
41 struct EnumPropertyItem;
43 /* Key Configuration */
45 wmKeyConfig *WM_keyconfig_new (struct wmWindowManager *wm, const char *idname);
46 wmKeyConfig *WM_keyconfig_new_user(struct wmWindowManager *wm, const char *idname);
47 bool WM_keyconfig_remove (struct wmWindowManager *wm, struct wmKeyConfig *keyconf);
48 void WM_keyconfig_free (struct wmKeyConfig *keyconf);
50 void WM_keyconfig_set_active(struct wmWindowManager *wm, const char *idname);
52 void WM_keyconfig_update(struct wmWindowManager *wm);
53 void WM_keyconfig_update_tag(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
54 void WM_keyconfig_update_operatortype(void);
58 void WM_keymap_init (struct bContext *C);
59 void WM_keymap_free (struct wmKeyMap *keymap);
61 wmKeyMapItem *WM_keymap_verify_item(struct wmKeyMap *keymap, const char *idname, int type,
62 int val, int modifier, int keymodifier);
63 wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, const char *idname, int type,
64 int val, int modifier, int keymodifier);
65 wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, const char *idname, int type,
66 int val, int modifier, int keymodifier);
67 wmKeyMapItem *WM_keymap_add_menu_pie(struct wmKeyMap *keymap, const char *idname, int type,
68 int val, int modifier, int keymodifier);
69 wmKeyMapItem *WM_keymap_add_tool(struct wmKeyMap *keymap, const char *idname, int type,
70 int val, int modifier, int keymodifier);
72 bool WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
73 int WM_keymap_item_to_string(wmKeyMapItem *kmi, const bool compact, char *result, const int result_len);
75 wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid);
76 wmKeyMap *WM_keymap_find(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid);
77 wmKeyMap *WM_keymap_find_all(const struct bContext *C, const char *idname, int spaceid, int regionid);
78 wmKeyMap *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap);
79 wmKeyMap *WM_keymap_guess_opname(const struct bContext *C, const char *opname);
80 bool WM_keymap_remove(struct wmKeyConfig *keyconfig, struct wmKeyMap *keymap);
81 bool WM_keymap_poll(struct bContext *C, struct wmKeyMap *keymap);
83 wmKeyMapItem *WM_keymap_item_find_id(struct wmKeyMap *keymap, int id);
84 int WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2);
88 int WM_modalkeymap_items_to_string(
89 struct wmKeyMap *km, const int propvalue, const bool compact,
90 char *result, const int result_len);
91 int WM_modalkeymap_operator_items_to_string(
92 struct wmOperatorType *ot, const int propvalue, const bool compact,
93 char *result, const int result_len);
94 char *WM_modalkeymap_operator_items_to_string_buf(
95 struct wmOperatorType *ot, const int propvalue, const bool compact,
96 const int max_len, int *r_available_len, char **r_result);
98 wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, const char *idname, const struct EnumPropertyItem *items);
99 wmKeyMap *WM_modalkeymap_get(struct wmKeyConfig *keyconf, const char *idname);
100 wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value);
101 wmKeyMapItem *WM_modalkeymap_add_item_str(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value);
102 wmKeyMapItem *WM_modalkeymap_find_propvalue(wmKeyMap *km, const int propvalue);
103 void WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname);
107 void WM_keymap_restore_to_default(struct wmKeyMap *keymap, struct bContext *C);
108 void WM_keymap_properties_reset(struct wmKeyMapItem *kmi, struct IDProperty *properties);
109 void WM_keymap_restore_item_to_default(struct bContext *C, struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
110 int WM_keymap_map_type_get(struct wmKeyMapItem *kmi);
114 const char *WM_key_event_string(const short type, const bool compact);
115 int WM_keymap_item_raw_to_string(
116 const short shift, const short ctrl, const short alt, const short oskey, const short keymodifier,
117 const short val, const short type, const bool compact,
118 char *result, const int result_len);
119 wmKeyMapItem *WM_key_event_operator(
120 const struct bContext *C, const char *opname, int opcontext,
121 struct IDProperty *properties, const bool is_hotkey,
122 struct wmKeyMap **r_keymap);
123 char *WM_key_event_operator_string(
124 const struct bContext *C, const char *opname, int opcontext,
125 struct IDProperty *properties, const bool is_strict,
126 char *result, const int result_len);
128 const char *WM_bool_as_string(bool test);
134 #endif /* __WM_KEYMAP_H__ */