From d7e95270d351ed643d001a0d5ca297dc74331919 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Wed, 11 Jan 2017 07:57:27 +0100 Subject: [PATCH] ProcessMouseMove method copied, work in progress saved for branch switching --- CrowIDE/src/ImlVisualEditor.cs | 82 ++++++++++++++++++++++++++++- src/GraphicObjects/GraphicObject.cs | 2 +- src/Interface.cs | 4 +- 3 files changed, 83 insertions(+), 5 deletions(-) diff --git a/CrowIDE/src/ImlVisualEditor.cs b/CrowIDE/src/ImlVisualEditor.cs index 0307cd45..e3975cfe 100644 --- a/CrowIDE/src/ImlVisualEditor.cs +++ b/CrowIDE/src/ImlVisualEditor.cs @@ -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; + } } } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 25332832..18745fa1 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -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) diff --git a/src/Interface.cs b/src/Interface.cs index 542cf2dd..88e71b67 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -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; } -- 2.47.3