]> O.S.I.I.S - jp/crow.git/commitdiff
DebugLogAnalyzer StickyMouse bug
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 10 Apr 2021 00:13:37 +0000 (02:13 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 10 Apr 2021 00:13:37 +0000 (02:13 +0200)
Crow/src/Interface.cs
Samples/DebugLogAnalyzer/src/DebugInterface.cs
Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs
Samples/DebugLogAnalyzer/src/Extensions.cs
Samples/DebugLogAnalyzer/ui/main.crow

index 38a0764fd31d9554a0d4055894d15a73168a3b02..cd82dee61ed2aa5cd424b9cc7c52f73631993674 100644 (file)
@@ -1365,7 +1365,9 @@ namespace Crow
                                        HoverWidget = value;
             }
         }
-               
+               public virtual void ForceMousePosition () {
+                       Glfw3.SetCursorPosition (hWin, MousePosition.X, MousePosition.Y);
+               }
 
                /// <summary>Processes mouse move events from the root container, this function
                /// should be called by the host on mouse move event to forward events to crow interfaces</summary>
@@ -1386,7 +1388,7 @@ namespace Crow
                                                stickedWidget = null;
                                                stickyMouseDelta = default;
                                        } else {
-                                               Glfw3.SetCursorPosition (hWin, MousePosition.X, MousePosition.Y);
+                                               ForceMousePosition ();
                                                DbgLogger.EndEvent (DbgEvtType.MouseMove);
                                                return true;
                                        }
index 8300abb20d3ac4ff59fa850e1fbe57dcbb440094..26a1eddfec73db0c1983382ebc34476046e5a778 100644 (file)
@@ -32,6 +32,7 @@ namespace Crow
                string source;
                Action delRegisterForRepaint;//call RegisterForRepaint in the container widget (DebugInterfaceWidget)
                Action<Exception> delSetCurrentException;
+               Func<object> delGetScreenCoordinate;
 
                void interfaceThread () {
                        while (!Terminate) {
@@ -68,6 +69,7 @@ namespace Crow
                        Type t = w.GetType();
                        delRegisterForRepaint = (Action)Delegate.CreateDelegate(typeof(Action), w, t.GetMethod("RegisterForRepaint"));
                        delSetCurrentException = (Action<Exception>)Delegate.CreateDelegate(typeof(Action<Exception>), w, t.GetProperty("CurrentException").GetSetMethod());
+                       delGetScreenCoordinate = (Func<object>)Delegate.CreateDelegate(typeof(Func<object>), w, t.GetMethod("GetScreenCoordinates"));
                }
                public void ResetDirtyState () {
                        IsDirty = false;
@@ -109,6 +111,11 @@ namespace Crow
                                        g.RegisterForLayouting (LayoutingType.All);
                                RegisterClip (clientRectangle);
                        }                               
-               }                               
+               }
+               public override void ForceMousePosition()
+               {
+                       Point p = (Point)delGetScreenCoordinate();
+                       Glfw.Glfw3.SetCursorPosition (WindowHandle, p.X + MousePosition.X, p.Y + MousePosition.Y);
+               }
        }
 }
\ No newline at end of file
index ee30d5ed0c1e96167da3eee9ecdd385c9e16a16a..5432b05eaf6eac76017462d15eac70b02b6676fa 100644 (file)
@@ -140,16 +140,19 @@ namespace Crow
 
                public bool CrowDebuggerOK => initialized;
                public bool CrowDebuggerNOK => !initialized;
-               void notifyCrowDebuggerState () {
+               public string CrowDebuggerErrorMessage = "";
+               void notifyCrowDebuggerState (string errorMsg = null) {
                        NotifyValueChanged("CrowDebuggerOK", CrowDebuggerOK);
                        NotifyValueChanged("CrowDebuggerNOK", CrowDebuggerNOK);
+                       CrowDebuggerErrorMessage = errorMsg;
+                       NotifyValueChanged("CrowDebuggerErrorMessage", CrowDebuggerErrorMessage);
                }
 
                void tryStartDebugInterface () {
                        if (initialized)
                                return;
                        if (!File.Exists (crowDbgAssemblyLocation))     {
-                               notifyCrowDebuggerState();
+                               notifyCrowDebuggerState($"Crow.dll for debugging file not found");
                                return;
                        }
                        
@@ -161,7 +164,7 @@ namespace Crow
 
                                Type debuggerType = crowAssembly.GetType("Crow.DbgLogger");
                                if (!(bool)debuggerType.GetField("IsEnabled").GetValue(null)) {
-                                       notifyCrowDebuggerState();
+                                       notifyCrowDebuggerState("Crow.dll must be compiled with CrowDebugLogEnabled='True'");
                                        return;
                                }                               
 
@@ -201,6 +204,7 @@ namespace Crow
                                dbgIfaceType.GetMethod("Run").Invoke (dbgIFace, null);
 
                                initialized = true;
+                               notifyCrowDebuggerState();
                                                                                
                                //Console.WriteLine($"DbgIFace: LoadCtx:{AssemblyLoadContext.GetLoadContext (dbgIFace.GetType().Assembly).Name})");
                        //}
@@ -298,5 +302,7 @@ namespace Crow
                                dla.Events = events;
                        }
                }
+
+               public virtual object GetScreenCoordinates () => ScreenCoordinates(Slot).TopLeft;
        }
 }
\ No newline at end of file
index 6086384c5d2a1b8314490122e6e50e7f1b53c10f..58047aaa5f58cc674920125dd04061265b563a73 100644 (file)
@@ -7,7 +7,8 @@ namespace DebugLogAnalyzer {
 
                public static CommandGroup GetCommands (this System.IO.DirectoryInfo di) =>
                        new CommandGroup(
-                               new Command ("Set as root", ()=> {Program.CurrentProgramInstance.CurrentDir = di.FullName;}));          
+                               new Command ("Set as root", ()=> {Program.CurrentProgramInstance.CurrentDir = di.FullName;})                            
+                       );              
                public static CommandGroup GetCommands (this System.IO.FileInfo fi) =>
                        new CommandGroup(
                                new Command ("Delete", (sender0) => {
index 24a50a2fa67a0510598f21db0a81c784611ce901..913220db1f2c3b18824cfd57e72a1f01178dbf04 100644 (file)
@@ -67,7 +67,9 @@
                                        <Widget Width="5" Height="5" Background="SeaGreen" IsVisible="{../../../../dbgIfaceWidget.HasFocus}"/>
                                        <Widget Width="5" Height="5" Background="Yellow" IsVisible="{../../../../dbgIfaceWidget.IsHover}"/>
                                        <TextBox Text="{²CrowDbgAssemblyLocation}" Margin="2"/>
-                               </HorizontalStack>                              
+                               </HorizontalStack>
+                               <Label Background="Red" Foreground="White" Margin="5" Width="Stretched" Text="{../../../dbgIfaceWidget.CrowDebuggerErrorMessage}"
+                                       IsVisible="{../../../dbgIfaceWidget.CrowDebuggerNOK}"/>
                                <CheckBox Name="cbFile" Caption="Record to file" IsChecked="{²DebugLogToFile}" Background="Onyx"/>
                                <HorizontalStack Height="Fit" Width="Stretched" IsEnabled="{../cbFile.IsChecked}" Background="Onyx" Margin="5">
                                        <Label Text="Debug log output file:" Fit="true"/>