Blender Git Commit Log

Git Commits -> Revision ed92105

Revision ed92105 by Ton Roosendaal (master)
July 21, 2009, 11:03 (GMT)
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)



Commit Details:

Full Hash: ed921058573dca5277f062e992ad0db0393071fe
SVN Revision: 21757
Parent Commit: 0865bf2
Lines Changed: +288, -30

9 Modified Paths:

/source/blender/editors/screen/screen_ops.c (+55, -15) (Diff)
/source/blender/editors/transform/transform.c (+118, -1) (Diff)
/source/blender/editors/transform/transform.h (+4, -1) (Diff)
/source/blender/editors/transform/transform_ops.c (+4, -0) (Diff)
/source/blender/makesdna/DNA_windowmanager_types.h (+18, -6) (Diff)
/source/blender/windowmanager/intern/wm_event_system.c (+22, -4) (Diff)
/source/blender/windowmanager/intern/wm_keymap.c (+55, -2) (Diff)
/source/blender/windowmanager/WM_api.h (+8, -1) (Diff)
/source/blender/windowmanager/wm_event_types.h (+4, -0) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021