]> O.S.I.I.S - jp/crow.git/commitdiff
ProcessMouseMove method copied, work in progress saved for branch switching
authorjpbruyere <jp.bruyere@hotmail.com>
Wed, 11 Jan 2017 06:57:27 +0000 (07:57 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Wed, 11 Jan 2017 06:57:27 +0000 (07:57 +0100)
CrowIDE/src/ImlVisualEditor.cs
src/GraphicObjects/GraphicObject.cs
src/Interface.cs

index 0307cd45d7b14469ce9fdf502ec330beb8001fcb..e3975cfe40f003425d73f2a55dfc5e66daa4d163 100644 (file)
@@ -167,7 +167,7 @@ namespace CrowIDE
                                                RegisterForRedraw ();
                                }
 
-                               Thread.Sleep (5);
+                               Thread.Sleep (2);
                        }
                }
 
@@ -187,7 +187,7 @@ namespace CrowIDE
                        base.onMouseMove (sender, e);
                        GraphicObject oldHW = imlVE.HoverWidget;
                        Rectangle scr = this.ScreenCoordinates (this.getSlot ());
-                       imlVE.ProcessMouseMove (e.X - scr.X, e.Y - scr.Y);
+                       ProcessMouseMove (e.X - scr.X, e.Y - scr.Y);
                        if (oldHW == imlVE.HoverWidget)
                                return;
                        RegisterForRedraw ();
@@ -250,5 +250,83 @@ namespace CrowIDE
 
                }
                #endregion
+
+               public bool ProcessMouseMove(int x, int y)
+               {
+                       int deltaX = x - imlVE.Mouse.X;
+                       int deltaY = y - imlVE.Mouse.Y;
+                       imlVE.Mouse.X = x;
+                       imlVE.Mouse.Y = y;
+                       MouseMoveEventArgs e = new MouseMoveEventArgs (x, y, deltaX, deltaY);
+                       e.Mouse = imlVE.Mouse;
+
+                       if (imlVE.activeWidget != null) {
+                               //TODO, ensure object is still in the graphic tree
+                               //send move evt even if mouse move outside bounds
+                               imlVE.activeWidget.onMouseMove (this, e);
+                               return true;
+                       }
+
+                       if (imlVE.HoverWidget != null) {
+                               //TODO, ensure object is still in the graphic tree
+                               //check topmost graphicobject first
+                               GraphicObject tmp = imlVE.HoverWidget;
+                               GraphicObject topc = null;
+                               while (tmp is GraphicObject) {
+                                       topc = tmp;
+                                       tmp = tmp.LogicalParent as GraphicObject;
+                               }
+                               int idxhw = imlVE.GraphicTree.IndexOf (topc);
+                               if (idxhw != 0) {
+                                       int i = 0;
+                                       while (i < idxhw) {
+                                               if (imlVE.GraphicTree [i].LogicalParent == imlVE.GraphicTree [i].Parent) {
+                                                       if (imlVE.GraphicTree [i].MouseIsIn (e.Position)) {
+                                                               while (imlVE.HoverWidget != null) {
+                                                                       imlVE.HoverWidget.onMouseLeave (imlVE.HoverWidget, e);
+                                                                       imlVE.HoverWidget = imlVE.HoverWidget.LogicalParent as GraphicObject;
+                                                               }
+
+                                                               imlVE.GraphicTree [i].checkHoverWidget (e);
+                                                               return true;
+                                                       }
+                                               }
+                                               i++;
+                                       }
+                               }
+
+
+                               if (imlVE.HoverWidget.MouseIsIn (e.Position)) {
+                                       imlVE.HoverWidget.checkHoverWidget (e);
+                                       return true;
+                               } else {
+                                       imlVE.HoverWidget.onMouseLeave (imlVE.HoverWidget, e);
+                                       //seek upward from last focused graph obj's
+                                       while (imlVE.HoverWidget.LogicalParent as GraphicObject != null) {
+                                               imlVE.HoverWidget = imlVE.HoverWidget.LogicalParent as GraphicObject;
+                                               if (imlVE.HoverWidget.MouseIsIn (e.Position)) {
+                                                       imlVE.HoverWidget.checkHoverWidget (e);
+                                                       return true;
+                                               } else
+                                                       imlVE.HoverWidget.onMouseLeave (imlVE.HoverWidget, e);
+                                       }
+                               }
+                       }
+
+                       //top level graphic obj's parsing
+                       lock (imlVE.GraphicTree) {
+                               for (int i = 0; i < imlVE.GraphicTree.Count; i++) {
+                                       GraphicObject g = imlVE.GraphicTree [i];
+                                       if (g.MouseIsIn (e.Position)) {
+                                               g.checkHoverWidget (e);
+                                               if (g is Window)
+                                                       imlVE.PutOnTop (g);
+                                               return true;
+                                       }
+                               }
+                       }
+                       imlVE.HoverWidget = null;
+                       return false;
+               }
        }
 }
index 253328327c0c830be7c7666a330583dc9c3daf77..18745fa135e32fe95094e1bea263f56379c3017a 100644 (file)
@@ -1172,7 +1172,7 @@ namespace Crow
                        if (p != null)
                                p.onMouseMove(sender,e);
 
-                       MouseMove.Raise (sender, e);
+                       MouseMove.Raise (this, e);
                }
                public virtual void onMouseDown(object sender, MouseButtonEventArgs e){
                        if (CurrentInterface.eligibleForDoubleClick == this && CurrentInterface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick)
index 542cf2dd7af090acdc113ac5a6c7aa49f2fd6508..88e71b672e04d674b1e1419f58f27abf565c0c07 100644 (file)
@@ -568,10 +568,10 @@ namespace Crow
                        MouseMoveEventArgs e = new MouseMoveEventArgs (x, y, deltaX, deltaY);
                        e.Mouse = Mouse;
 
-                       if (_activeWidget != null) {
+                       if (activeWidget != null) {
                                //TODO, ensure object is still in the graphic tree
                                //send move evt even if mouse move outside bounds
-                               _activeWidget.onMouseMove (this, e);
+                               activeWidget.onMouseMove (this, e);
                                return true;
                        }