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.
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.
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.
16 * The Original Code is Copyright (C) 2007 Blender Foundation.
17 * All rights reserved.
24 #ifndef __WM_EVENT_SYSTEM_H__
25 #define __WM_EVENT_SYSTEM_H__
27 /* return value of handler-operator call */
28 #define WM_HANDLER_CONTINUE 0
29 #define WM_HANDLER_BREAK 1
30 #define WM_HANDLER_HANDLED 2
31 #define WM_HANDLER_MODAL 4 /* MODAL|BREAK means unhandled */
36 /* wmKeyMap is in DNA_windowmanager.h, it's saveable */
38 /** Custom types for handlers, for signaling, freeing */
39 enum eWM_EventHandlerType {
40 WM_HANDLER_TYPE_GIZMO = 1,
43 WM_HANDLER_TYPE_DROPBOX,
44 WM_HANDLER_TYPE_KEYMAP,
47 typedef struct wmEventHandler {
48 struct wmEventHandler *next, *prev;
50 enum eWM_EventHandlerType type;
51 char flag; /* WM_HANDLER_BLOCKING, ... */
53 /** Optional local and windowspace bb. */
54 const rcti *bblocal, *bbwin;
57 /** Run after the keymap item runs. */
58 struct wmEventHandler_KeymapPost {
59 void (*post_fn)(wmKeyMap *keymap, wmKeyMapItem *kmi, void *user_data);
63 /** Support for a getter function that looks up the keymap each access. */
64 struct wmEventHandler_KeymapDynamic {
65 wmEventHandler_KeymapDynamicFn *keymap_fn;
69 /** #WM_HANDLER_TYPE_KEYMAP */
70 typedef struct wmEventHandler_Keymap {
73 /** Pointer to builtin/custom keymaps (never NULL). */
76 struct wmEventHandler_KeymapPost post;
77 struct wmEventHandler_KeymapDynamic dynamic;
79 struct bToolRef *keymap_tool;
80 } wmEventHandler_Keymap;
82 /** #WM_HANDLER_TYPE_GIZMO */
83 typedef struct wmEventHandler_Gizmo {
86 /** Gizmo handler (never NULL). */
87 struct wmGizmoMap *gizmo_map;
88 } wmEventHandler_Gizmo;
90 /** #WM_HANDLER_TYPE_UI */
91 typedef struct wmEventHandler_UI {
94 wmUIHandlerFunc handle_fn; /* callback receiving events */
95 wmUIHandlerRemoveFunc remove_fn; /* callback when handler is removed */
96 void *user_data; /* user data pointer */
98 /** Store context for this handler for derived/modal handlers. */
100 struct ScrArea *area;
101 struct ARegion *region;
102 struct ARegion *menu;
106 /** #WM_HANDLER_TYPE_OP */
107 typedef struct wmEventHandler_Op {
110 /** Operator can be NULL. */
113 /** Hack, special case for file-select. */
116 /** Store context for this handler for derived/modal handlers. */
118 struct ScrArea *area;
119 struct ARegion *region;
124 /** #WM_HANDLER_TYPE_DROPBOX */
125 typedef struct wmEventHandler_Dropbox {
130 } wmEventHandler_Dropbox;
132 /* wm_event_system.c */
133 void wm_event_free_all (wmWindow *win);
134 void wm_event_free (wmEvent *event);
135 void wm_event_free_handler (wmEventHandler *handler);
137 /* goes over entire hierarchy: events -> window -> screen -> area -> region */
138 void wm_event_do_handlers (bContext *C);
140 void wm_event_add_ghostevent (wmWindowManager *wm, wmWindow *win, int type, int time, void *customdata);
142 void wm_event_do_depsgraph(bContext *C);
143 void wm_event_do_refresh_wm_and_depsgraph(bContext *C);
144 void wm_event_do_notifiers(bContext *C);
146 float wm_pressure_curve(float raw_pressure);
151 void wm_dropbox_free(void);
152 void wm_drags_check_ops(bContext *C, const wmEvent *event);
153 void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect);
155 #endif /* __WM_EVENT_SYSTEM_H__ */