diff options
author | Ton Roosendaal <ton@blender.org> | 2009-01-30 21:18:41 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-01-30 21:18:41 +0300 |
commit | 480be71514a010549b62c302e2bb1216c4339b0c (patch) | |
tree | 4bad708e39a5eed6945d96a149dd8e92e30a19d1 /source/blender/windowmanager | |
parent | 128c8167afa003984b7446ad53915c79f872fdbf (diff) |
2.5
- Edit mesh: Add ctrl+click add vertex or extrude.
I've made it not move the 3d cursor in that case.
Also found out tweak events conflicted with existing
keymap definitions; on tweak failure (= no mousemove)
it now passes on the mouse event as 'mouse down' for
the remaining keymaps to check.
These then actually respond to mouse-up instead of down...
The location in the keymaps where tweaks get generated
remains important. Examples:
1 - 'select' mouse-handler, operator return pass-through
2 - tweak handler checks, and makes tweak event
3 - grabber responds to tweak event
1 - ctrl+mouse tweak handler checks, makes tweak event,
or passes event on
2 - if tweak event, it runs lasso
3 - else when passed on, ctrl+click extrude happens
In the first case, select works on mouse-down, immediate.
In the second case, extrude happens on mouse-release, even
though the keymap defined mouse-press.
This will make designing nice balanced keymaps still not
simple; especially because you can't tell operators to
pass on the key... although we can add the convention that
select-mouse operators always pass on to enable tweaks.
Still a good reason to wait with custom keymaps
when this is fully settled!
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 14 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 7 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 28 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 9 |
5 files changed, 30 insertions, 33 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 940fd762f10..4e04eabe09a 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -71,12 +71,11 @@ void *WM_paint_cursor_activate(struct wmWindowManager *wm, int (*poll)(struct b void WM_paint_cursor_end(struct wmWindowManager *wm, void *handle); /* keymap */ -wmKeymapItem *WM_keymap_set_item (ListBase *lb, char *idname, short type, - short val, int modifier, short keymodifier); wmKeymapItem *WM_keymap_verify_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier); -wmKeymapItem *WM_keymap_add_item (ListBase *lb, char *idname, short type, +wmKeymapItem *WM_keymap_add_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier); +wmKeymapItem *WM_keymap_tweak (ListBase *lb, short type, short val, int modifier, short keymodifier); ListBase *WM_keymap_listbase (struct wmWindowManager *wm, const char *nameid, int spaceid, int regionid); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index a9c31261aca..2b53121baf2 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -61,13 +61,13 @@ enum { typedef struct wmEvent { struct wmEvent *next, *prev; - short type; /* event code itself (short, is also in keymap) */ - short val; /* press, release, scrollvalue */ - short x, y; /* mouse pointer position */ - short prevx, prevy; /* previous mouse pointer position */ - short unicode; /* future, ghost? */ - char ascii; /* from ghost */ - char pad1; + short type; /* event code itself (short, is also in keymap) */ + short val; /* press, release, scrollvalue */ + short x, y; /* mouse pointer position */ + short prevx, prevy; /* previous mouse pointer position */ + short unicode; /* future, ghost? */ + char ascii; /* from ghost */ + char no_tweak; /* set on tweak failure, to allow other events to try it */ /* modifier states */ short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 81efe5f8860..7df47ce3462 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -515,6 +515,9 @@ static int wm_eventmatch(wmEvent *winevent, wmKeymapItem *kmi) if(kmi->keymodifier) if(winevent->keymodifier!=kmi->keymodifier) return 0; + /* happens on tweak failure */ + if(kmi->is_tweak) + if(winevent->no_tweak) return 0; return 1; } @@ -545,7 +548,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand retval= ot->modal(C, op, event); - /* putting back screen context */ + /* putting back screen context, reval can pass trough after modal failures! */ if((retval & OPERATOR_PASS_THROUGH) || wm_event_always_pass(event)) { CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); @@ -581,7 +584,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand MEM_freeN(handler); /* prevent silly errors from operator users */ - retval &= ~OPERATOR_PASS_THROUGH; + //retval &= ~OPERATOR_PASS_THROUGH; } } diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 46a5c45a30d..14cdf919ff9 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -111,25 +111,6 @@ wmKeymapItem *WM_keymap_verify_item(ListBase *lb, char *idname, short type, shor return kmi; } -/* if item was added, then replace */ -wmKeymapItem *WM_keymap_set_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier) -{ - wmKeymapItem *kmi; - - for(kmi= lb->first; kmi; kmi= kmi->next) - if(strncmp(kmi->idname, idname, OP_MAX_TYPENAME)==0) - break; - if(kmi==NULL) { - kmi= MEM_callocN(sizeof(wmKeymapItem), "keymap entry"); - - BLI_addtail(lb, kmi); - BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME); - } - keymap_event_set(kmi, type, val, modifier, keymodifier); - keymap_properties_set(kmi); - return kmi; -} - /* always add item */ wmKeymapItem *WM_keymap_add_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier) { @@ -143,6 +124,15 @@ wmKeymapItem *WM_keymap_add_item(ListBase *lb, char *idname, short type, short v return kmi; } +/* enables tweak for mouse/modifier combo + on tweak fail, it passes on event with 'val=1', so other keymap items can test */ +wmKeymapItem *WM_keymap_tweak(ListBase *lb, short type, short val, int modifier, short keymodifier) +{ + wmKeymapItem *km= WM_keymap_add_item(lb, "WM_OT_tweak_gesture", type, val, modifier, keymodifier); + km->is_tweak= 1; +} + + /* ****************** storage in WM ************ */ /* name id's are for storing general or multiple keymaps, diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 827c7572788..9d59e71981e 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -764,9 +764,14 @@ static int tweak_gesture_modal(bContext *C, wmOperator *op, wmEvent *event) case RIGHTMOUSE: case MIDDLEMOUSE: if(gesture->event_type==event->type) { - wm_gesture_evaluate(C, gesture); wm_gesture_end(C, op); - return OPERATOR_FINISHED; + + /* when tweak fails we should give the other keymap entries a chance + * those then won't react to km_press, but km_release + * it sets hidden event value where tweak maps fail on, to prevent loops */ + event->val= 1; + event->no_tweak= 1; + return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; } break; } |