]> O.S.I.I.S - jp/crow.git/commitdiff
lock on ext method search, IList<widget> in dbg log
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 2 Jul 2021 12:59:09 +0000 (14:59 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 2 Jul 2021 12:59:09 +0000 (14:59 +0200)
Crow/src/IML/CompilerServices.cs
Crow/src/Mono.Cairo/Context.cs
Crow/src/Widgets/Widget.cs
CrowDbgShared/CrowDbgShared.csproj [deleted file]
CrowDbgShared/src/SharedDelegates.cs [deleted file]
Samples/DebugLogAnalyzer/src/DbgLogViewer.cs
Samples/DebugLogAnalyzer/src/DebugInterface.cs
Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs
Samples/DebugLogAnalyzer/ui/dbg.style
Samples/DebugLogAnalyzer/ui/main.crow

index 32bb258fc9338283b2aa115f9ad1c13e8bfee9f5..e5d426d112356590ca8e9e351fe58fd5202af7f5 100644 (file)
@@ -387,26 +387,28 @@ namespace Crow.IML
                internal static MethodInfo SearchExtMethod (Type t, string methodName)
                {
                        string key = t.Name + "." + methodName;
-                       if (knownExtMethods.ContainsKey (key))
-                               return knownExtMethods [key];
-
-                       //System.Diagnostics.Console.WriteLine ($"*** search extension method: {t};{methodName} => key={key}");
-
-                       MethodInfo mi = null;
-                       if (!TryGetExtensionMethods (Assembly.GetEntryAssembly (), t, methodName, out mi)) {
-                               if (!TryGetExtensionMethods (t.Module.Assembly, t, methodName, out mi)) {
-                                       foreach (Assembly a in Interface.crowAssemblies) {
-                                               if (TryGetExtensionMethods (a, t, methodName, out mi))
-                                                       break;
+                       lock (knownExtMethods) {
+                               if (knownExtMethods.ContainsKey (key))
+                                       return knownExtMethods [key];
+
+                               //System.Diagnostics.Console.WriteLine ($"*** search extension method: {t};{methodName} => key={key}");
+
+                               MethodInfo mi = null;
+                               if (!TryGetExtensionMethods (Assembly.GetEntryAssembly (), t, methodName, out mi)) {
+                                       if (!TryGetExtensionMethods (t.Module.Assembly, t, methodName, out mi)) {
+                                               foreach (Assembly a in Interface.crowAssemblies) {
+                                                       if (TryGetExtensionMethods (a, t, methodName, out mi))
+                                                               break;
+                                               }
+                                               if (mi == null)
+                                                       TryGetExtensionMethods (Assembly.GetExecutingAssembly (), t, methodName, out mi);//crow Assembly
                                        }
-                                       if (mi == null)
-                                               TryGetExtensionMethods (Assembly.GetExecutingAssembly (), t, methodName, out mi);//crow Assembly
                                }
-                       }
 
-                       //add key even if mi is null to prevent searching again and again for propertyless bindings
-                       knownExtMethods.Add (key, mi);
-                       return mi;
+                               //add key even if mi is null to prevent searching again and again for propertyless bindings
+                               knownExtMethods.Add (key, mi);
+                               return mi;
+                       }
                }
 
                public static bool TryGetExtensionMethods (Assembly assembly, Type extendedType, string methodName, out MethodInfo foundMI)
index eb855157904970815a386bec9d5b4f9b05ed70e1..5ed2bbd412667b39e56d99705207c1f18af8af76 100644 (file)
@@ -210,7 +210,7 @@ namespace Crow.Cairo {
                        }
                }
 
-               public void SetDash (double [] dashes, double offset)
+               public void SetDash (double [] dashes, double offset = 0)
                {
                        NativeMethods.cairo_set_dash (handle, dashes, dashes.Length, offset);
                }
index 42f5da83d03e0b4bbd2538e514dfb4e476e20733..7255ca455ec8cd69cbee22373036047f3bbd40cd 100644 (file)
@@ -1556,6 +1556,13 @@ namespace Crow
                /// query a repaint, if control is cached, cache will not be updated and simply repainted.
                /// if not cached, repaint will trigger the onDraw method.
                /// </summary>
+               /// <remark>
+               /// This could be usefull in widget with complex drawing, that need some markers on top: the main part
+               /// of the drawing could take place in the onDraw method, and the markers (single line, rectangle, ...)
+               /// could be drawn in the Paint method. Such widget must have 'CacheEnabled=true' and to simply update the
+               /// markers without a full redraw, just call 'RegisterForRepaint'.
+               /// 
+               /// </remark>
                public void RegisterForRepaint () {
                        if (RegisteredLayoutings == LayoutingType.None && !IsDirty)
                                IFace.EnqueueForRepaint (this);
diff --git a/CrowDbgShared/CrowDbgShared.csproj b/CrowDbgShared/CrowDbgShared.csproj
deleted file mode 100644 (file)
index 0ae4978..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">  
-       <PropertyGroup>
-               <OutputType>Library</OutputType>
-               <TargetFrameworks>netstandard2.1</TargetFrameworks>
-               <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
-       </PropertyGroup>
-       <ItemGroup>
-               <PackageReference Include="glfw-sharp" Version="$(GlfwSharpVersion)" />
-       </ItemGroup>
-       <ItemGroup>
-               <Compile Include="src\**\*.cs"/>
-       </ItemGroup>
-</Project>
diff --git a/CrowDbgShared/src/SharedDelegates.cs b/CrowDbgShared/src/SharedDelegates.cs
deleted file mode 100644 (file)
index aee1ef1..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2013-2021  Bruyère Jean-Philippe jp_bruyere@hotmail.com
-//
-// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
-
-using System;
-using System.IO;
-using System.Diagnostics;
-using System.Collections.Generic;
-using System.Linq;
-using Glfw;
-
-namespace CrowDbgShared
-{
-       public delegate void InterfaceResizeDelegate(int a, int b);
-       public delegate bool InterfaceMouseMoveDelegate(int a, int b);
-       public delegate bool InterfaceMouseButtonDelegate(MouseButton button);
-       public delegate void VoidDelegate();
-       public delegate IntPtr IntPtrGetterDelegate();
-}
-
index 89cf3e0ca32821d6ee0a05e7b97b4de4a5e66165..2ac0326f9849c5697e4097508017f9f5311a412b 100644 (file)
@@ -47,8 +47,8 @@ namespace Crow
                DbgWidgetRecord curWidget, hoverWidget;
                DbgEvent curEvent, hoverEvent;
 
-               List<DbgEvent> events = new List<DbgEvent> ();
-               List<DbgWidgetRecord> widgets = new List<DbgWidgetRecord> ();
+               IList<DbgEvent> events = new List<DbgEvent> ();
+               IList<DbgWidgetRecord> widgets = new List<DbgWidgetRecord> ();
                
 
                public DbgEvtType Filter {
@@ -61,7 +61,7 @@ namespace Crow
                                RegisterForGraphicUpdate();
                        }
                }
-               public List<DbgEvent> Events {
+               public IList<DbgEvent> Events {
                        get => events;
                        set {
                                if (events == value)
@@ -91,7 +91,7 @@ namespace Crow
                                RegisterForGraphicUpdate ();
                        }
                }
-               public List<DbgWidgetRecord> Widgets {
+               public IList<DbgWidgetRecord> Widgets {
                        get => widgets;
                        set {
                                if (widgets == value)
@@ -159,6 +159,7 @@ namespace Crow
                                        return;
                                hoverEvent = value;
                                NotifyValueChanged (nameof (HoverEvent), hoverEvent);
+                               RegisterForRepaint ();
                        }
                }
 
@@ -201,8 +202,20 @@ namespace Crow
                                updateMargins ();
                        }
                }
-
-               void drawEvents (Context ctx, List<DbgEvent> evts)
+               RectangleD getWidgetEvtBounds (DbgEvent evt, ref Rectangle cb, double penY) {
+                       double x = xScale * (evt.begin - minTicks - ScrollX);
+                       double w = Math.Max (Math.Max (2.0, 2.0 * xScale), (double)(evt.end - evt.begin) * xScale);
+                       if (x < 0.0) {
+                               w += x;
+                               x = 0.0;
+                       }
+                       x += leftMargin + cb.Left;
+                       double rightDiff = x + w - cb.Right;
+                       if (rightDiff > 0)
+                               w -= rightDiff;
+                       return new RectangleD(x, penY, w, fe.Height);
+               }
+               void drawEvents (Context ctx, IList<DbgEvent> evts)
                {
                        if (evts == null || evts.Count == 0)
                                return;
@@ -224,26 +237,8 @@ namespace Crow
                                                        penY += (lIdx) * fe.Height; 
                                                
                                                        ctx.SetSource (evt.Color);
-
-                                                       double x = xScale * (evt.begin - minTicks - ScrollX);
-                                                       double w = Math.Max (Math.Max (2.0, 2.0 * xScale), (double)(evt.end - evt.begin) * xScale);
-                                                       if (x < 0.0) {
-                                                               w += x;
-                                                               x = 0.0;
-                                                       }
-                                                       x += leftMargin + cb.Left;
-                                                       double rightDiff = x + w - cb.Right;
-                                                       if (rightDiff > 0)
-                                                               w -= rightDiff;
-                                                       RectangleD r = new RectangleD(x, penY, w, fe.Height);
-                                                       ctx.Rectangle (r);
+                                                       ctx.Rectangle (getWidgetEvtBounds (evt, ref cb, penY));
                                                        ctx.Fill ();
-                                                       /*if (evt == CurrentEvent) {
-                                                               r.Inflate(2,2);
-                                                               ctx.SetSource(Colors.White);
-                                                               ctx.Rectangle(r);
-                                                               ctx.Stroke();
-                                                       }*/
                                                }
                                        } else if (evt.type.HasFlag (DbgEvtType.IFace)) {
                                                double x = xScale * (evt.begin - minTicks - ScrollX);
@@ -400,6 +395,12 @@ namespace Crow
                                ctx.SetSource (0.1, 0.1, 0.1, 0.4);
                                ctx.Rectangle (ContextCoordinates (r));
                                ctx.Fill ();
+
+                               if (hoverEvent is DbgWidgetEvent wevt) {
+                                       ctx.SetSource (1.0,1.0,1.0,0.7);
+                                       ctx.SetDash (new double[] {1, 2});
+                                       ctx.Rectangle ((Rectangle)getWidgetEvtBounds (wevt, ref cb, y).Inflated (1), 1);
+                               }
                        }
 
                        if (currentLine >= ScrollY && currentLine < scrollY + visibleLines) {
@@ -439,6 +440,8 @@ namespace Crow
                        ctx.SetSource (Colors.Black);
                        ctx.ShowText (str);
 
+
+
                }
                public override void OnLayoutChanges (LayoutingType layoutType)
                {
@@ -477,7 +480,7 @@ namespace Crow
                                if (lastLine >= 0 && hoverLine >= 0)
                                        ScrollY += lastLine - hoverLine;
                                updateMouseLocalPos (e.Position);
-                       } else {
+                       } else if (widgets != null) {
                                HoverWidget = (hoverLine < 0 || hoverLine >= widgets.Count) ? null : widgets [hoverLine];
                                //HoverEvent = hoverWidget?.Events.FirstOrDefault (ev => ev.begin <= hoverTick && ev.end >= hoverTick);
                                double tickPerPixel = (double)visibleTicks / ClientRectangle.Width;
index 64de2163832c4a000a5d7378c3366be0a5ce7bff..4f6a84aaa306fb48b125569b709e64311dc1a6ff 100644 (file)
@@ -13,7 +13,7 @@ namespace Crow
                static DebugInterface() {
                        DbgLogger.IncludeEvents = DbgEvtType.None;
                        DbgLogger.DiscardEvents = DbgEvtType.None;
-                       DbgLogger.ConsoleOutput = true;
+                       DbgLogger.ConsoleOutput = false;
                }
                public DebugInterface (IntPtr hWin) : base (hWin)
                {
index 38d94f3d391e1d6b9472d41b92ffaa3d6def5d88..a1bb8156b85a0dbb5a15db3ea638fbb69a128f8b 100644 (file)
@@ -120,15 +120,6 @@ namespace Crow
                                NotifyValueChangedAuto (discardedEvents);
                        }
                }
-               public bool DebugLogToFile {
-                       get => initialized ? !(bool)fiDbg_ConsoleOutput.GetValue (dbgIFace) : false;
-                       set {
-                               if (!initialized || DebugLogToFile == value)
-                                       return;                         
-                               fiDbg_ConsoleOutput.SetValue (dbgIFace, !value);
-                               NotifyValueChangedAuto (DebugLogToFile);
-                       }
-               }
                public string DebugLogFilePath {
                        get => Configuration.Global.Get<string> ("DebugLogFilePath");
                        set {
index 33a5e9f4d76f374d0750940087b5daa1ba5c7e0d..ee2b14c19fc913601527fd34eeb4b94ecc8ae666 100644 (file)
@@ -17,6 +17,7 @@ DbgLogViewer {
        MouseWheelSpeed="3";
        Font="mono, 8";
        Background="Onyx";
+       CacheEnabled = "true";  
 }
 DbgEventView {
        Height="Fit";
@@ -29,4 +30,8 @@ labWidgetRecordList {
        Margin="0";
        Width="24";
        TextAlignment="Right";
+}
+
+DbgEventWidget {
+       CacheEnabled = "true";
 }
\ No newline at end of file
index 28433b11686e47467c578c3a62ca3fe28030a3fc..d6ed60543e542546f441b9d2156df9a691f97cde 100644 (file)
                                </HorizontalStack>
                                <Label Background="Red" Foreground="White" Margin="5" Width="Stretched" Text="{../../../dbgIfaceWidget.CrowDebuggerErrorMessage}"
                                        IsVisible="{../../../dbgIfaceWidget.CrowDebuggerNOK}"/>
-                               <HorizontalStack Height="Fit" Width="Stretched" IsEnabled="{../cbFile.IsChecked}" Background="Onyx" Margin="5">
+                               <HorizontalStack Height="Fit" Width="Stretched" Background="Onyx" Margin="5">
                                        <Label Text="Debug log output file:" Fit="true"/>
                                        <TextBox Text="{²../../../../dbgIfaceWidget.DebugLogFilePath}"  />
                                </HorizontalStack>
-                               <CheckBox Name="cbFile" Caption="Record to file" IsChecked="{²../../../dbgIfaceWidget.DebugLogToFile}" Background="Onyx"/>
                                <EnumSelector RadioButtonStyle="CheckBox2" Template="#Dbg.EnumSelector.template"
                                                Background="Grey"
                                                Caption="Recorded Events" EnumValue="{²RecordedEvents}" BitFieldExcludeMask="255" />                                   
                                        Recording="{²DebugLogRecording}"
                                        IMLSource="{Source}"
                                        CurrentException="{²CurrentException}"
-                                       DiscardedEvents="{DiscardedEvents}" RecordedEvents="{RecordedEvents}" DebugLogToFile="{DebugLogToFile}"/>
+                                       DiscardedEvents="{DiscardedEvents}" RecordedEvents="{RecordedEvents}"/>
                        <Splitter/>
                        <!--<TabView>-->
                                <VerticalStack Name="Editor" Spacing="0">