aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-07-02 14:59:09 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-07-02 14:59:09 +0200
commitfeeb0691af647cad8f7ce7c60fd3ec14591df56a (patch)
tree371912ee8c404ffec110a283c97a252057852c59
parenta4386e4844dbb85b804770d936b2d47c7584d258 (diff)
lock on ext method search, IList<widget> in dbg log
-rw-r--r--Crow/src/IML/CompilerServices.cs32
-rw-r--r--Crow/src/Mono.Cairo/Context.cs2
-rw-r--r--Crow/src/Widgets/Widget.cs7
-rw-r--r--CrowDbgShared/CrowDbgShared.csproj13
-rw-r--r--CrowDbgShared/src/SharedDelegates.cs20
-rw-r--r--Samples/DebugLogAnalyzer/src/DbgLogViewer.cs55
-rw-r--r--Samples/DebugLogAnalyzer/src/DebugInterface.cs2
-rw-r--r--Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs9
-rw-r--r--Samples/DebugLogAnalyzer/ui/dbg.style5
-rw-r--r--Samples/DebugLogAnalyzer/ui/main.crow5
10 files changed, 62 insertions, 88 deletions
diff --git a/Crow/src/IML/CompilerServices.cs b/Crow/src/IML/CompilerServices.cs
index 32bb258f..e5d426d1 100644
--- a/Crow/src/IML/CompilerServices.cs
+++ b/Crow/src/IML/CompilerServices.cs
@@ -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];
+ lock (knownExtMethods) {
+ if (knownExtMethods.ContainsKey (key))
+ return knownExtMethods [key];
- //System.Diagnostics.Console.WriteLine ($"*** search extension method: {t};{methodName} => key={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;
+ 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)
diff --git a/Crow/src/Mono.Cairo/Context.cs b/Crow/src/Mono.Cairo/Context.cs
index eb855157..5ed2bbd4 100644
--- a/Crow/src/Mono.Cairo/Context.cs
+++ b/Crow/src/Mono.Cairo/Context.cs
@@ -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);
}
diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs
index 42f5da83..7255ca45 100644
--- a/Crow/src/Widgets/Widget.cs
+++ b/Crow/src/Widgets/Widget.cs
@@ -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
index 0ae49780..00000000
--- a/CrowDbgShared/CrowDbgShared.csproj
+++ /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
index aee1ef1e..00000000
--- a/CrowDbgShared/src/SharedDelegates.cs
+++ /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();
-}
-
diff --git a/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs b/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs
index 89cf3e0c..2ac0326f 100644
--- a/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs
+++ b/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs
@@ -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;
diff --git a/Samples/DebugLogAnalyzer/src/DebugInterface.cs b/Samples/DebugLogAnalyzer/src/DebugInterface.cs
index 64de2163..4f6a84aa 100644
--- a/Samples/DebugLogAnalyzer/src/DebugInterface.cs
+++ b/Samples/DebugLogAnalyzer/src/DebugInterface.cs
@@ -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)
{
diff --git a/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs b/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs
index 38d94f3d..a1bb8156 100644
--- a/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs
+++ b/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs
@@ -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 {
diff --git a/Samples/DebugLogAnalyzer/ui/dbg.style b/Samples/DebugLogAnalyzer/ui/dbg.style
index 33a5e9f4..ee2b14c1 100644
--- a/Samples/DebugLogAnalyzer/ui/dbg.style
+++ b/Samples/DebugLogAnalyzer/ui/dbg.style
@@ -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
diff --git a/Samples/DebugLogAnalyzer/ui/main.crow b/Samples/DebugLogAnalyzer/ui/main.crow
index 28433b11..d6ed6054 100644
--- a/Samples/DebugLogAnalyzer/ui/main.crow
+++ b/Samples/DebugLogAnalyzer/ui/main.crow
@@ -70,11 +70,10 @@
</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" />
@@ -110,7 +109,7 @@
Recording="{²DebugLogRecording}"
IMLSource="{Source}"
CurrentException="{²CurrentException}"
- DiscardedEvents="{DiscardedEvents}" RecordedEvents="{RecordedEvents}" DebugLogToFile="{DebugLogToFile}"/>
+ DiscardedEvents="{DiscardedEvents}" RecordedEvents="{RecordedEvents}"/>
<Splitter/>
<!--<TabView>-->
<VerticalStack Name="Editor" Spacing="0">