]> O.S.I.I.S - jp/crow.git/commitdiff
debug mouse focus
authorjpbruyere <jp.bruyere@hotmail.com>
Tue, 30 Aug 2016 11:18:21 +0000 (13:18 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Thu, 1 Sep 2016 10:44:39 +0000 (12:44 +0200)
Default.style
Templates/MenuItem.template
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/TemplatedGroup.cs
src/Interface.cs

index 9ddac6a9ecaafe013b3acbbb8f5c3ce59650cb69..f79ded376ba6b52d714df26e0f1b84c6c2f2e896 100644 (file)
@@ -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;
index d0a44f7fbbafb386d78c407a89e9e248a6dd89a0..4d96405bbb5bb0784a79fa6b47fff609f4c27673 100644 (file)
@@ -1,15 +1,24 @@
 <?xml version="1.0"?>
 <Popper Caption="{./Caption}"  Background="{./Background}" PopDirection="{./PopDirection}"
        Foreground = "{./Foreground}" CanPop="{./HasChildren}" MouseClick="./onMI_Click"
-       Unpop = "{Foreground=LightGray;Background=Transparent}">
+       Unpop = "{Foreground=LightGray;Background=Transparent}"
+       Pop = "{Background = Mantis;Foreground=Jet}"
+       >
        <Template>
-               <Label Text="{./Caption}"
-                       MinimumSize = "120,0"
-                       Margin="3" TextAlignment="Left"
-                       Height="{./HeightPolicy}" Width="{./WidthPolicy}"
-                       Font="{./Font}"
-                       Background="{./Background}"
-                       Foreground="{./Foreground}"/>
+               <Border Name="border1"
+                               MouseEnter="{Foreground=vgradient|0:White|0.2:Gray|0.9:Gray|1:Black}"
+                               MouseLeave="{Foreground=Transparent}"
+                               MouseDown="{Foreground=vgradient|0:Black|0.05:Gray|0.85:Gray|1:White}"
+                               MouseUp="{Foreground=vgradient|0:White|0.2:Gray|0.9:Gray|1:Black}"
+                               Height="{./HeightPolicy}" Width="{./WidthPolicy}"
+                               MinimumSize = "60,0"
+                               Foreground="Transparent"
+                               Background="{./Background}">
+                       <Label Text="{./Caption}"
+                               Foreground="{./Foreground}"
+                               Margin="3" HorizontalAlignment="Left"
+                               Font="{./Font}" />
+               </Border>
        </Template>
        <Border Foreground="DimGray" Fit="true">
                <VerticalStack Name="ItemsContainer" Margin="2" Fit="true" Background="Onyx"/>
index 28e45d305cb621332782bbb93d9cbea2f9fdeba4..f5b19bb07add54829c31a80d018b000ea67bed54 100644 (file)
@@ -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)
                /// </summary>
                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");
 
index 704b59af24e0b888e445dd25b9a7b8db9570e9b8..f7f849c063856fd66a883aa6c8338cbc9a8ca146 100644 (file)
@@ -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)
                {
index 5ad638b41ce1fcccd9b60077ac31b889eb491da5..73f44a6aec5bd0a397f888c55840ec46de6ff268 100644 (file)
@@ -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;