Revision: 3955
          http://vexi.svn.sourceforge.net/vexi/?rev=3955&view=rev
Author:   clrg
Date:     2010-10-30 00:19:12 +0000 (Sat, 30 Oct 2010)

Log Message:
-----------
Sync Move/Enter/Leave fix with vexi3_old_build

Modified Paths:
--------------
    trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp

Added Paths:
-----------
    trunk/org.vexi-core.main/src/test/java/test/core/box/events/lib/
    
trunk/org.vexi-core.main/src/test/java/test/core/box/events/lib/moveBlocked_template.t
    trunk/org.vexi-core.main/src/test/java/test/core/box/events/moveBlocked.t

Modified: trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp
===================================================================
--- trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp 2010-10-29 
23:57:25 UTC (rev 3954)
+++ trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp 2010-10-30 
00:19:12 UTC (rev 3955)
@@ -242,9 +242,9 @@
     private static final int SHRINK = HSHRINK | VSHRINK;
     
     private static final int TILE_IMAGE              = 0x00000010;
-    private static final int MOUSEINSIDE             = 0x00000020;
-    private static final int CURSOR                  = 0x00000040;
-    //private static final int UNUSED                = 0x00000080;
+    private static final int CURSOR                  = 0x00000020;
+    private static final int MOUSEINSIDE             = 0x00000040;
+    private static final int MOUSEINSIDE_BLOCKED     = 0x00000080;
 
     private static final int CONSTRAIN               = 0x00000100;
     private static final int CONSTRAIN_DESCENDENT    = 0x00000200;
@@ -1373,8 +1373,14 @@
         // they may throw an exception which would leave this box
         // in an inconsistent state (!mouse.inside but no Leave)
         clear(MOUSEINSIDE);
-        if (test(LEAVE_TRAP)) {
-            justTriggerTraps(SC_Leave, JSU.T);
+        // only fire Leave if not previously blocked; Leave event
+        // should always come only once Enter has been triggered
+        if (test(MOUSEINSIDE_BLOCKED)) {
+            clear(MOUSEINSIDE_BLOCKED);
+        } else {
+            if (test(LEAVE_TRAP)) {
+                justTriggerTraps(SC_Leave, JSU.T);
+            }
         }
     }
 
@@ -1401,12 +1407,19 @@
         int i;
         boolean interrupted = false;
         
-        // absolute layout - allows for interruption by overlaying siblings
         if (!test(PACK)) {
+            // absolute layout - allows for interruption by overlaying siblings
             for (Box b = getChild(i=treeSize()-1); b != null; b = 
getChild(--i)) {
+                if (!b.test(DISPLAY)) {
+                    continue;
+                }
+                if (interrupted) {
+                    b.propagateLeave();
+                    continue;
+                }
                 int b_mx = mousex-getXInParent(b);
                 int b_my = mousey-getYInParent(b);
-                if (!interrupted && b.inside(b_mx, b_my)) {
+                if (b.inside(b_mx, b_my)) {
                     if (b.propagateMove(b_mx, b_my)) {
                         interrupted = true;
                     }
@@ -1414,13 +1427,21 @@
                     b.propagateLeave();
                 }
             }
-        
-        // packed layout - siblings can not interrupt each other
         } else {
-            for (Box b = getChild(i=0); b != null; b = getChild(++i)) {
-                int b_mx = mousex-b.x;
-                int b_my = mousey-b.y;
+            // packed layout - interrupted still applies, plus packedhit 
shortcut
+            boolean packedhit = false;
+            for (Box b = getChild(i=treeSize()-1); b != null; b = 
getChild(--i)) {
+                if (!b.test(DISPLAY)) {
+                    continue;
+                }
+                if (packedhit) {
+                    b.propagateLeave();
+                    continue;
+                }
+                int b_mx = mousex-getXInParent(b);
+                int b_my = mousey-getYInParent(b);
                 if (b.inside(b_mx, b_my)) {
+                    packedhit = true;
                     if (b.propagateMove(b_mx, b_my)) {
                         interrupted = true;
                     }
@@ -1434,10 +1455,18 @@
         // Enter on this box - invoking Leave if necessary
         if (interrupted) {
             if (test(MOUSEINSIDE)) {
-                clear(MOUSEINSIDE);
-                if (test(LEAVE_TRAP)) {
-                    justTriggerTraps(SC_Leave, JSU.T);
+                if (!test(MOUSEINSIDE_BLOCKED)) {
+                    // mouse previously inside, now blocked so invoke Leave
+                    set(MOUSEINSIDE_BLOCKED);
+                    if (test(LEAVE_TRAP)) {
+                        justTriggerTraps(SC_Leave, JSU.T);
+                    }
                 }
+            } else {
+                // mouse not previously inside, Enter not yet triggered, so
+                // do not invoke Leave
+                set(MOUSEINSIDE);
+                set(MOUSEINSIDE_BLOCKED);
             }
             // propagate cascade prevention 
             return true;
@@ -1484,7 +1513,7 @@
             if (inside(s_mx, s_my)) {
                 propagateEvent(event, _event, value, s_mx, s_my);
             } else if (forceOnRoot) {
-                if (Interpreter.CASCADE_PREVENTED == justTriggerTraps(_event, 
value)) {
+                if (Interpreter.CASCADE_PREVENTED != justTriggerTraps(_event, 
value)) {
                     justTriggerTraps(event, value);
                 }
             }
@@ -1563,7 +1592,7 @@
              * placed upon it will not be fired.</p> 
              * 
              * @type(Boolean) */
-            case "inside": return JSU.B(test(MOUSEINSIDE) && isVisible());
+            case "inside": return JSU.B(test(MOUSEINSIDE) && 
!test(MOUSEINSIDE_BLOCKED) && isVisible());
             
             /* <p><em>Read only</em></span> property representing the mouse's 
current x-position/y-position
              * relative to the owning box.</p>

Added: 
trunk/org.vexi-core.main/src/test/java/test/core/box/events/lib/moveBlocked_template.t
===================================================================
--- 
trunk/org.vexi-core.main/src/test/java/test/core/box/events/lib/moveBlocked_template.t
                              (rev 0)
+++ 
trunk/org.vexi-core.main/src/test/java/test/core/box/events/lib/moveBlocked_template.t
      2010-10-30 00:19:12 UTC (rev 3955)
@@ -0,0 +1,30 @@
+<vexi xmlns:ui="vexi://ui">
+    <!--
+        Move/Enter/Leave test
+        
+        The blocking trap on Move should not interfere
+        with the Enter/Leave events in the topmost box
+        whilst blocking those directly beneath it
+    -->
+    
+    <ui:box width="300" height="300">
+        <ui:box layout="layer" shrink="true">
+            <ui:box width="100" height="100" fill="red">
+                thisbox.inside = false;
+                Enter ++= function(v) { inside = true; cascade = v; }
+                Leave ++= function(v) { inside = false; cascade = v; }
+                Move ++= function(v) { return; }
+            </ui:box>
+            thisbox.enterhit = false;
+            thisbox.leavehit = false;
+            // these should never fire because thisbox will be
+            // the same size as the blocking box it contains
+            Enter ++= function(v) { enterhit = true; cascade = v; }
+            Leave ++= function(v) { leavehit = true; cascade = v; }
+        </ui:box>
+        thisbox.inside = false;
+        Enter ++= function(v) { inside = true; cascade = v; }
+        Leave ++= function(v) { inside = false; cascade = v; }
+        //vexi.ui.frame = thisbox;
+    </ui:box>
+</vexi>

Added: trunk/org.vexi-core.main/src/test/java/test/core/box/events/moveBlocked.t
===================================================================
--- trunk/org.vexi-core.main/src/test/java/test/core/box/events/moveBlocked.t   
                        (rev 0)
+++ trunk/org.vexi-core.main/src/test/java/test/core/box/events/moveBlocked.t   
2010-10-30 00:19:12 UTC (rev 3955)
@@ -0,0 +1,44 @@
+<vexi xmlns:ui="vexi://ui">
+    <!--
+        Move/Enter/Leave test
+        
+        The blocking trap on Move should not interfere
+        with the Enter/Leave events in the topmost box
+        whilst blocking those directly beneath it
+    -->
+    
+    var test = new vexi..lib.moveBlocked_template();
+    test.forcereflow();
+    test.visible ++= function() { return true; }
+    assert(test[0].width == 100);
+    assert(test[0].height == 100);
+    
+    test.sendEvent("Move", 5, 5);
+    //assert(test.mouse.inside);
+    assert(test.inside);
+    assert(test[0].enterhit == false);
+    assert(test[0].leavehit == false);
+    
+    test.sendEvent("Move", 150, 150);
+    //assert(test.mouse.inside == false);
+    assert(test.inside == false);
+    assert(test[0].enterhit == false);
+    assert(test[0].leavehit == false);
+    //assert(test[0][0].mouse.inside);
+    assert(test[0][0].inside);
+    
+    <ui:box width="300" height="300">
+        <ui:box layout="layer" shrink="true">
+            <ui:box width="100" height="100" fill="red">
+                Enter ++= function(v) { vexi.trace("Enter"); cascade = v; }
+                Leave ++= function(v) { vexi.trace("Leave"); cascade = v; }
+                Move ++= function(v) { return; }
+            </ui:box>
+            thisbox.enterhit = false;
+            thisbox.leavehit = false;
+            Enter ++= function(v) { vexi.trace("Enter blocked"); enterhit = 
true; cascade = v; }
+            Leave ++= function(v) { vexi.trace("Leave blocked"); leavehit = 
true; cascade = v; }
+        </ui:box>
+        //vexi.ui.frame = thisbox;
+    </ui:box>
+</vexi>


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to