Revision: 18790
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18790
Author:   ton
Date:     2009-02-02 15:13:14 +0100 (Mon, 02 Feb 2009)

Log Message:
-----------
2.5

Sanitized the 'tweak' event.

Original idea was to have WM event system generating it 
automatically. However, I first tested it via a handler
and operator, to check what kind of configurations would
be useful. It appeared to not work nice, also because
that inserting a tweak operator in a keymap is confusing.

Now 'tweaks' are generated automatically, and can be
catched by keymaps as any event. The current definition
of tweak is:

- if Left/Middle/Rightmouse pressed
    if event wasn't handled by window queue (modal handlers)
       start checking mousepositions

- while mousepositions are checked
   - escape on any event other than mouse
   - on mouse events:
     - add tweak event if mousemove > 10 pixels
     - stop checking for tweak if mousebutton released

- Tweak events have a define indicating mousebutton used
  EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R  

- In keymap definitions you can use _S or _A to map to
  action or select mouse userdef.

- Event value in keymap should be KM_ANY for all tweaks,
  or use one of the eight directions:
  EVT_GESTURE_E, _SE, _S, _SW, _W, _NW, _N, _NE 

- And of course you can add modifier checks in keymaps for it.

- Because tweaks are a result of mouse events, the handlers get
  both to evaluate. That means that RMB-select + tweak will work
  correctly.
  In case you don't want both to be handled, for example the 
  CTRL+LMB 'extrude' and CTRL+LMB-tweak 'lasso select', you will
  need to set the first acting on a EVT_RELEASE, this event only
  gets passed on when tweak fails.

The current system allows all options, configurable, we had in 2.48,
and many more! A diagram of what's possible is on the todo. :)

Also in this commit: lasso select editmesh failed with 'zbuffer 
occluded select'. Also circle-select failed.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/animation/anim_markers.c
    branches/blender2.5/blender/source/blender/editors/mesh/editmesh_mods.c
    branches/blender2.5/blender/source/blender/editors/mesh/mesh_ops.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c
    branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_ops.c
    branches/blender2.5/blender/source/blender/editors/space_node/node_ops.c
    
branches/blender2.5/blender/source/blender/editors/space_sequencer/sequencer_ops.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c
    
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_select.c
    branches/blender2.5/blender/source/blender/editors/uvedit/uvedit_ops.c
    
branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h
    branches/blender2.5/blender/source/blender/windowmanager/WM_types.h
    
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_event_system.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_keymap.c
    
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c
    branches/blender2.5/blender/source/blender/windowmanager/wm.h

Modified: 
branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c     
2009-02-02 11:51:10 UTC (rev 18789)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c     
2009-02-02 14:13:14 UTC (rev 18790)
@@ -3945,11 +3945,13 @@
                win->ghostwin= NULL;
                win->eventstate= NULL;
                win->curswin= NULL;
-               
+               win->tweak= NULL;
+
                win->timers.first= win->timers.last= NULL;
                win->queue.first= win->queue.last= NULL;
                win->handlers.first= win->handlers.last= NULL;
                win->subwindows.first= win->subwindows.last= NULL;
+               win->gesture.first= win->gesture.last= NULL;
 
                win->drawdata= NULL;
                win->drawmethod= -1;

Modified: 
branches/blender2.5/blender/source/blender/editors/animation/anim_markers.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_markers.c 
2009-02-02 11:51:10 UTC (rev 18789)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_markers.c 
2009-02-02 14:13:14 UTC (rev 18790)
@@ -889,7 +889,4 @@
        
        WM_keymap_add_item(keymap, "MARKER_OT_move", GKEY, KM_PRESS, 0, 0);
        
-       /* generates event, needs to be after select to work */
-       WM_keymap_tweak(keymap, SELECTMOUSE, KM_PRESS, 0, 0);
-       
 }

Modified: 
branches/blender2.5/blender/source/blender/editors/mesh/editmesh_mods.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/mesh/editmesh_mods.c     
2009-02-02 11:51:10 UTC (rev 18789)
+++ branches/blender2.5/blender/source/blender/editors/mesh/editmesh_mods.c     
2009-02-02 14:13:14 UTC (rev 18790)
@@ -247,10 +247,9 @@
        }
        else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & 
V3D_ZBUF_SELECT)==0) return 0;
 
-       if(em_vertoffs==0) return 0;
-       
        buf= view3d_read_backbuf(vc, xmin, ymin, xmax, ymax);
        if(buf==NULL) return 0;
+       if(em_vertoffs==0) return 0;
 
        dr = buf->rect;
 
@@ -260,6 +259,7 @@
        glColor3ub(0, 0, 0);
        
        /* yah, opengl doesn't do concave... tsk! */
+       ED_region_pixelspace(vc->ar);
        draw_triangulated(mcords, tot); 
        
        glBegin(GL_LINE_LOOP);  /* for zero sized masks, lines */
@@ -301,11 +301,11 @@
                else return 0;
        }
        else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & 
V3D_ZBUF_SELECT)==0) return 0;
-       if(em_vertoffs==0) return 0;
        
        xmin= xs-rads; xmax= xs+rads;
        ymin= ys-rads; ymax= ys+rads;
        buf= view3d_read_backbuf(vc, xmin, ymin, xmax, ymax);
+       if(em_vertoffs==0) return 0;
        if(buf==NULL) return 0;
 
        dr = buf->rect;

Modified: branches/blender2.5/blender/source/blender/editors/mesh/mesh_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/mesh/mesh_ops.c  
2009-02-02 11:51:10 UTC (rev 18789)
+++ branches/blender2.5/blender/source/blender/editors/mesh/mesh_ops.c  
2009-02-02 14:13:14 UTC (rev 18790)
@@ -206,9 +206,6 @@
        
        WM_keymap_add_item(keymap, "MESH_OT_selection_type", TABKEY, KM_PRESS, 
KM_CTRL, 0);
        
-       
-       /* transform keymap already defined, so no tweaks for select */
-       
        /* hide */
        WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, 0, 0);
        RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, 
KM_PRESS, KM_SHIFT, 0)->ptr, "invert", 1);
@@ -236,7 +233,8 @@
        WM_keymap_add_item(keymap, "MESH_OT_add_duplicate", DKEY, KM_PRESS, 
KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "OBJECT_OT_mesh_add", AKEY, KM_PRESS, 
KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "MESH_OT_separate", PKEY, KM_PRESS, 
KM_SHIFT, 0);
-       WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", LEFTMOUSE, 
KM_PRESS, KM_CTRL, 0);
+                                               /* use KM_RELEASE because same 
key is used for tweaks */
+       WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", LEFTMOUSE, 
KM_RELEASE, KM_CTRL, 0);
        
        WM_keymap_add_item(keymap, "MESH_OT_delete", XKEY, KM_PRESS, 0, 0);
        

Modified: 
branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c    
    2009-02-02 11:51:10 UTC (rev 18789)
+++ 
branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c    
    2009-02-02 14:13:14 UTC (rev 18790)
@@ -139,9 +139,6 @@
        WM_keymap_add_item(keymap, "ACT_OT_set_previewrange", PKEY, KM_PRESS, 
KM_CTRL|KM_ALT, 0);
        WM_keymap_add_item(keymap, "ACT_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
        
-       /* generates event, needs to be after select to work */
-       WM_keymap_tweak(keymap, SELECTMOUSE, KM_PRESS, 0, 0);
-               
        /* transform system */
        transform_keymap_for_space(wm, keymap, SPACE_ACTION);
 }

Modified: branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_ops.c      
2009-02-02 11:51:10 UTC (rev 18789)
+++ branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_ops.c      
2009-02-02 14:13:14 UTC (rev 18790)
@@ -186,9 +186,6 @@
        //WM_keymap_add_item(keymap, "GRAPHEDIT_OT_set_previewrange", PKEY, 
KM_PRESS, KM_CTRL|KM_ALT, 0);
        //WM_keymap_add_item(keymap, "GRAPHEDIT_OT_view_all", HOMEKEY, 
KM_PRESS, 0, 0);
        
-       /* generates event, needs to be after select to work */
-       WM_keymap_tweak(keymap, SELECTMOUSE, KM_PRESS, 0, 0);
-
        /* transform system */
        transform_keymap_for_space(wm, keymap, SPACE_IPO);
 }

Modified: 
branches/blender2.5/blender/source/blender/editors/space_node/node_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_node/node_ops.c    
2009-02-02 11:51:10 UTC (rev 18789)
+++ branches/blender2.5/blender/source/blender/editors/space_node/node_ops.c    
2009-02-02 14:13:14 UTC (rev 18790)
@@ -73,9 +73,5 @@
        WM_keymap_add_item(keymap, "NODE_OT_border_select", BKEY, KM_PRESS, 0, 
0);
        WM_keymap_add_item(keymap, "NODE_OT_delete_selection", XKEY, KM_PRESS, 
0, 0);
        
-       /* generates event, needs to be after select to work */
-       WM_keymap_tweak(keymap, ACTIONMOUSE, KM_PRESS, 0, 0);
-       WM_keymap_tweak(keymap, SELECTMOUSE, KM_PRESS, 0, 0);
-       
        transform_keymap_for_space(wm, keymap, SPACE_NODE);
 }

Modified: 
branches/blender2.5/blender/source/blender/editors/space_sequencer/sequencer_ops.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_sequencer/sequencer_ops.c
  2009-02-02 11:51:10 UTC (rev 18789)
+++ 
branches/blender2.5/blender/source/blender/editors/space_sequencer/sequencer_ops.c
  2009-02-02 14:13:14 UTC (rev 18790)
@@ -155,8 +155,6 @@
        
        WM_keymap_verify_item(keymap, "ANIM_OT_change_frame", LEFTMOUSE, 
KM_PRESS, 0, 0);
 
-       WM_keymap_tweak(keymap, SELECTMOUSE, KM_PRESS, 0, 0);
-
        transform_keymap_for_space(wm, keymap, SPACE_SEQ);
 }
 

Modified: 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c    
    2009-02-02 11:51:10 UTC (rev 18789)
+++ 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c    
    2009-02-02 14:13:14 UTC (rev 18790)
@@ -183,10 +183,5 @@
 
        transform_keymap_for_space(wm, keymap, SPACE_VIEW3D);
 
-       /* generates event, in end to make select work */
-       WM_keymap_tweak(keymap, SELECTMOUSE, KM_PRESS, 0, 0);
-       /* tweak event for border, lasso, etc */
-       WM_keymap_tweak(keymap, ACTIONMOUSE, KM_PRESS, KM_CTRL, 0);
-
 }
 

Modified: 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_select.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_select.c 
    2009-02-02 11:51:10 UTC (rev 18789)
+++ 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_select.c 
    2009-02-02 14:13:14 UTC (rev 18790)
@@ -703,6 +703,8 @@
        RNA_END;
        
        if(i>1) {
+               view3d_operator_needs_opengl(C);
+               
                /* setup view context for argument to callbacks */
                view3d_set_viewcontext(C, &vc);
                
@@ -1754,6 +1756,8 @@
                ViewContext vc;
                short mval[2], selecting;
                
+               view3d_operator_needs_opengl(C);
+               
                view3d_set_viewcontext(C, &vc);
                mval[0]= x;
                mval[1]= y;

Modified: branches/blender2.5/blender/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/uvedit/uvedit_ops.c      
2009-02-02 11:51:10 UTC (rev 18789)
+++ branches/blender2.5/blender/source/blender/editors/uvedit/uvedit_ops.c      
2009-02-02 14:13:14 UTC (rev 18790)
@@ -2568,9 +2568,6 @@
        // XXX not working?
        RNA_boolean_set(WM_keymap_add_item(keymap, "UV_OT_loop_select", 
SELECTMOUSE, KM_PRESS, KM_SHIFT, KM_ALT)->ptr, "extend", 1);
 
-       /* generates event, needs to be after select to work */
-       WM_keymap_tweak(keymap, SELECTMOUSE, KM_PRESS, 0, 0);
-
        WM_keymap_add_item(keymap, "UV_OT_select_linked", LKEY, KM_PRESS, 
KM_CTRL, 0);
        WM_keymap_add_item(keymap, "UV_OT_unlink_selection", LKEY, KM_PRESS, 
KM_ALT, 0);
        WM_keymap_add_item(keymap, "UV_OT_de_select_all", AKEY, KM_PRESS, 0, 0);

Modified: 
branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h
===================================================================
--- 
branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h   
    2009-02-02 11:51:10 UTC (rev 18789)
+++ 
branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h   
    2009-02-02 14:13:14 UTC (rev 18790)
@@ -38,6 +38,7 @@
 struct wmWindow;
 
 struct wmEvent;
+struct wmGesture;
 struct wmOperatorType;
 struct wmOperator;
 
@@ -102,6 +103,8 @@
        
        struct wmSubWindow *curswin;    /* internal for wm_subwindow.c only */
 
+       struct wmGesture *tweak;        /* internal for wm_operators.c */
+       
        int drawmethod, drawfail;       /* internal for wm_draw.c only */
        void *drawdata;                         /* internal for wm_draw.c only 
*/
        
@@ -168,7 +171,7 @@
        short shift, ctrl, alt, oskey;  /* oskey is apple or windowskey, value 
denotes order of pressed */
        short keymodifier;                              /* rawkey modifier */
        
-       short is_tweak;                                 /* internal only, to 
handle tweak failure events properly */
+       short pad;
 } wmKeymapItem;
 
 #define KMAP_MAX_NAME  64

Modified: branches/blender2.5/blender/source/blender/windowmanager/WM_types.h

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to