From e68f66a334bd37c60416615d8314a62dd9d05740 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Tue, 30 Aug 2016 13:18:21 +0200 Subject: [PATCH] debug mouse focus --- Default.style | 3 +-- Templates/MenuItem.template | 25 +++++++++++++++-------- src/GraphicObjects/GraphicObject.cs | 22 ++++++++++++++------ src/GraphicObjects/TemplatedGroup.cs | 1 - src/Interface.cs | 30 ++++++++++++---------------- 5 files changed, 47 insertions(+), 34 deletions(-) diff --git a/Default.style b/Default.style index 9ddac6a9..f79ded37 100644 --- a/Default.style +++ b/Default.style @@ -25,8 +25,7 @@ MenuItem { Height = Fit; Width = Fit; Background = Transparent; - MouseEnter = {Background = Mantis;Foreground=Jet;} - MouseLeave = {Background=Transparent;Foreground=LightGray;}; + Foreground = LightGray; } MessageBox { Width=200; diff --git a/Templates/MenuItem.template b/Templates/MenuItem.template index d0a44f7f..4d96405b 100644 --- a/Templates/MenuItem.template +++ b/Templates/MenuItem.template @@ -1,15 +1,24 @@  + Unpop = "{Foreground=LightGray;Background=Transparent}" + Pop = "{Background = Mantis;Foreground=Jet}" + > diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 28e45d30..f5b19bb0 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -116,7 +116,7 @@ namespace Crow /// This size is computed on each child' layout changes. /// In stacking widget, it is used to compute the remaining space for the stretched /// widget inside the stack, which is never added to the contentSize, instead, its size - /// is deducted from (parent.ClientRectangle - contentSize) + /// is deducted from (parent.ClientRectangle - contentSize) /// internal Size contentSize; #endregion @@ -600,7 +600,7 @@ namespace Crow if (string.IsNullOrEmpty (styleKey)) styleKey = thisType.FullName; - + //Reflexion being very slow compared to dyn method or delegates, //I compile the initial values coded in the CustomAttribs of the class, //all other instance of this type would not longer use reflexion to init properly @@ -1140,12 +1140,11 @@ namespace Crow if (Interface.clickTimer.ElapsedMilliseconds > 0 && Interface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick) { Interface.clickTimer.Reset (); - Debug.WriteLine ("double click"); onMouseDoubleClick (this, e); return; } else Interface.clickTimer.Restart (); - + GraphicObject p = Parent as GraphicObject; if (p != null) p.onMouseClick(sender,e); @@ -1160,7 +1159,7 @@ namespace Crow public virtual void onMouseWheel(object sender, MouseWheelEventArgs e){ GraphicObject p = Parent as GraphicObject; if (p != null) - p.onMouseWheel(this,e); + p.onMouseWheel(sender,e); MouseWheelChanged.Raise (this, e); } @@ -1177,6 +1176,17 @@ namespace Crow Debug.WriteLine("MouseLeave => " + this.ToString()); #endif MouseLeave.Raise (this, e); + + GraphicObject p = Parent as GraphicObject; + CurrentInterface.HoverWidget = p; + + if (p == null) + return; + + if (p.MouseIsIn (e.Position)&&e!=null) + p.checkHoverWidget (e); + else + p.onMouseLeave (sender, e); } #endregion @@ -1356,7 +1366,7 @@ namespace Crow } public virtual void ReadXml (System.Xml.XmlReader reader) { - if (reader.HasAttributes) { + if (reader.HasAttributes) { style = reader.GetAttribute ("Style"); diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs index 704b59af..f7f849c0 100644 --- a/src/GraphicObjects/TemplatedGroup.cs +++ b/src/GraphicObjects/TemplatedGroup.cs @@ -39,7 +39,6 @@ namespace Crow public virtual void AddItem(GraphicObject g){ items.AddChild (g); NotifyValueChanged ("HasChildren", true); - //g.LogicalParent = this; } public virtual void RemoveItem(GraphicObject g) { diff --git a/src/Interface.cs b/src/Interface.cs index 5ad638b4..73f44a6a 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -572,7 +572,8 @@ namespace Crow int i = 0; while (i < idxhw) { if (GraphicTree [i].MouseIsIn (e.Position)) { - HoverWidget.onMouseLeave (HoverWidget, e); + //set evtarg to null to force mouseLeave without checking mouse pos + HoverWidget.onMouseLeave (HoverWidget, null); GraphicTree [i].checkHoverWidget (e); return true; } @@ -586,26 +587,21 @@ namespace Crow return true; } else { HoverWidget.onMouseLeave (HoverWidget, e); - //seek upward from last focused graph obj's - while (HoverWidget.Parent as GraphicObject != null) { - HoverWidget = HoverWidget.Parent as GraphicObject; - if (HoverWidget.MouseIsIn (e.Position)) { - HoverWidget.checkHoverWidget (e); - return true; - } else - HoverWidget.onMouseLeave (HoverWidget, e); - } + if (HoverWidget != null) + return true; } } //top level graphic obj's parsing - for (int i = 0; i < GraphicTree.Count; i++) { - GraphicObject g = GraphicTree[i]; - if (g.MouseIsIn (e.Position)) { - g.checkHoverWidget (e); - if (g is Window) - PutOnTop (g); - return true; + lock (GraphicTree) { + for (int i = 0; i < GraphicTree.Count; i++) { + GraphicObject g = GraphicTree [i]; + if (g.MouseIsIn (e.Position)) { + g.checkHoverWidget (e); + if (g is Window) + PutOnTop (g); + return true; + } } } HoverWidget = null; -- 2.47.3