diff options
author | Ton Roosendaal <ton@blender.org> | 2009-07-21 15:03:07 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-07-21 15:03:07 +0400 |
commit | ed921058573dca5277f062e992ad0db0393071fe (patch) | |
tree | 75a86f6b33c38242cd1e116e37206555383ed376 /source/blender/windowmanager/wm_event_types.h | |
parent | 0865bf295947e5cd0b59429edf084f738321aef0 (diff) |
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
Diffstat (limited to 'source/blender/windowmanager/wm_event_types.h')
-rw-r--r-- | source/blender/windowmanager/wm_event_types.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 39c267b132c..6f64cdbde32 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -238,7 +238,11 @@ #define EVT_FILESELECT_EXEC 3 #define EVT_FILESELECT_CANCEL 4 +/* event->type */ #define EVT_BUT_OPEN 0x5021 +#define EVT_MODAL_MAP 0x5022 + + #endif /* WM_EVENT_TYPES_H */ |