From: Jean-Philippe Bruyère Date: Thu, 15 Apr 2021 13:18:19 +0000 (+0200) Subject: debug ObservableList, new Table widget X-Git-Tag: v0.9.5-beta~24 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=b0ceb4f3b5f812d9577a8a1caa8e07e304c50432;p=jp%2Fcrow.git debug ObservableList, new Table widget --- diff --git a/Crow/Default.style b/Crow/Default.style index f482eb0b..64406362 100644 --- a/Crow/Default.style +++ b/Crow/Default.style @@ -293,6 +293,10 @@ ColorPicker { Height="Fit"; MinimumSize="200,100"; } +Table { + Spacing="1"; + Foreground="Grey"; +} TableRow { Width="Stretched"; } diff --git a/Crow/src/DebugUtils/DebugLogger.cs b/Crow/src/DebugUtils/DebugLogger.cs index 3a65ad55..058921aa 100644 --- a/Crow/src/DebugUtils/DebugLogger.cs +++ b/Crow/src/DebugUtils/DebugLogger.cs @@ -225,8 +225,8 @@ namespace Crow /// Iface. public static void Save(Interface iface, string dbgLogFilePath = "debug.log") { #if DEBUG_LOG - using (Stream stream = new FileStream (dbgLogFilePath, FileMode.Create, FileAccess.Write)) - Save (iface, stream); + using (Stream stream = new FileStream (dbgLogFilePath, FileMode.Create, FileAccess.Write)) + Save (iface, stream); Console.WriteLine ($"Crow Debug Log saved to: {System.IO.Path.GetFullPath(dbgLogFilePath)}"); #endif } @@ -254,11 +254,9 @@ namespace Crow if (startingWidgetsIndex >= 0) writer.WriteLine ("[Events]"); saveEventList (writer, events); + startedEvents.Clear (); + events.Clear (); } - if (startedEvents.Count > 0) - Console.WriteLine ($"[DebugLogger]Warning: Started events not null when events saved!"); - startedEvents.Clear (); - events.Clear (); chrono.Start(); } } diff --git a/Crow/src/ObservableList.cs b/Crow/src/ObservableList.cs index 8cb64806..b67e27b6 100644 --- a/Crow/src/ObservableList.cs +++ b/Crow/src/ObservableList.cs @@ -56,6 +56,11 @@ namespace Crow ListAdd.Raise (this, new ListChangedEventArg (this.Count - 1, elem)); SelectedIndex = this.Count - 1; } + public new void Insert (int index, T elem) { + base.Insert (index, elem); + ListAdd.Raise (this, new ListChangedEventArg (index, elem)); + SelectedIndex = index; + } public new void Remove (T elem) { int idx = IndexOf (elem); if (idx < 0) diff --git a/Crow/src/Widgets/Group.cs b/Crow/src/Widgets/Group.cs index 4ce70c4a..55cc6353 100644 --- a/Crow/src/Widgets/Group.cs +++ b/Crow/src/Widgets/Group.cs @@ -184,7 +184,7 @@ namespace Crow { DbgLogger.StartEvent (DbgEvtType.GOSearchLargestChild, this); - //childrenRWLock.EnterReadLock (); + childrenRWLock.EnterReadLock (); largestChild = null; contentSize.Width = 0; @@ -206,7 +206,7 @@ namespace Crow if (largestChild == null && !forceMeasure) searchLargestChild (true); - //childrenRWLock.ExitReadLock (); + childrenRWLock.ExitReadLock (); DbgLogger.EndEvent (DbgEvtType.GOSearchLargestChild); } @@ -214,7 +214,7 @@ namespace Crow { DbgLogger.StartEvent (DbgEvtType.GOSearchTallestChild, this); - //childrenRWLock.EnterReadLock (); + childrenRWLock.EnterReadLock (); tallestChild = null; contentSize.Height = 0; @@ -236,7 +236,7 @@ namespace Crow if (tallestChild == null && !forceMeasure) searchTallestChild (true); - //childrenRWLock.ExitReadLock (); + childrenRWLock.ExitReadLock (); DbgLogger.EndEvent (DbgEvtType.GOSearchTallestChild); } diff --git a/Crow/src/Widgets/GroupBase.cs b/Crow/src/Widgets/GroupBase.cs index 0ef24bda..33f26001 100644 --- a/Crow/src/Widgets/GroupBase.cs +++ b/Crow/src/Widgets/GroupBase.cs @@ -118,13 +118,17 @@ namespace Crow public override void OnDataSourceChanged (object sender, DataSourceChangeEventArgs e) { base.OnDataSourceChanged (this, e); - - childrenRWLock.EnterReadLock (); - foreach (Widget g in Children) { - if (g.localDataSourceIsNull & g.localLogicalParentIsNull) - g.OnDataSourceChanged (g, e); + try { + childrenRWLock.EnterReadLock (); + foreach (Widget g in Children) { + if (g.localDataSourceIsNull & g.localLogicalParentIsNull) + g.OnDataSourceChanged (g, e); + } + childrenRWLock.ExitReadLock (); + } catch (Exception) { + childrenRWLock.ExitReadLock (); + throw; } - childrenRWLock.ExitReadLock (); } public void putWidgetOnTop(Widget w) @@ -213,12 +217,20 @@ namespace Crow gr.Clip (); } - childrenRWLock.EnterReadLock (); + try + { + childrenRWLock.EnterReadLock (); - for (int i = 0; i < Children.Count; i++) - Children[i].Paint (gr); + for (int i = 0; i < Children.Count; i++) + Children[i].Paint (gr); - childrenRWLock.ExitReadLock (); + childrenRWLock.ExitReadLock (); + } + catch (System.Exception) + { + childrenRWLock.ExitReadLock (); + throw; + } if (ClipToClientRect) gr.Restore (); diff --git a/Crow/src/Widgets/Table.cs b/Crow/src/Widgets/Table.cs index 5ddd1af8..27cfb963 100644 --- a/Crow/src/Widgets/Table.cs +++ b/Crow/src/Widgets/Table.cs @@ -88,9 +88,18 @@ namespace Crow public override void InsertChild (int idx, Widget g) { g.Width = Measure.Stretched; g.Margin = RowsMargin; - base.InsertChild (idx, g); + base.InsertChild (idx, g); + if (HeaderRow == null || idx == 0) + return; + TableRow row = g as TableRow; + for (int i = 0; i < HeaderRow.Children.Count; i++) { + if (row.Children.Count <= i) + continue; + setRowCellWidth (row.Children[i], HeaderRow.Children[i].Slot.Width); + row.Children[i].Slot.X = HeaderRow.Children[i].Slot.X; + } } - [DefaultValue (2)] + [DefaultValue (1)] public int ColumnSpacing { get => columnSpacing; set { @@ -228,7 +237,6 @@ namespace Crow if (row.Children.Count <= cIdx) continue; row.Children[cIdx].Slot.X = g.Slot.X; - row.RegisterForRedraw(); } childrenRWLock.ExitReadLock (); RegisterForRedraw (); @@ -236,8 +244,7 @@ namespace Crow } protected void setRowCellWidth (Widget w, int newW) { if (newW == w.Slot.Width) - return; - + return; w.Slot.Width = newW; w.IsDirty = true; w.OnLayoutChanges (LayoutingType.Width); diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index 9f3f4781..c38f373b 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -158,9 +158,9 @@ namespace Crow if (!localDataSourceIsNull) DataSource = null; - parentRWLock.EnterWriteLock (); + //parentRWLock.EnterWriteLock (); parent = null; - parentRWLock.ExitWriteLock (); + //parentRWLock.ExitWriteLock (); } else { DbgLogger.AddEvent (DbgEvtType.DisposedByGC, this); } diff --git a/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs b/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs index c6920ca5..2dba0601 100644 --- a/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs +++ b/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs @@ -47,7 +47,9 @@ namespace Crow public CommandGroup LoggerCommands => new CommandGroup( new Command("Get logs", () => getLog ()), - new Command("Reset logs", () => delResetDebugger ()) + new Command("Reset logs", () => delResetDebugger ()), + new Command("Save to file", () => saveLogToDebugLogFilePath ()), + new Command("Load from file", () => loadLogFromDebugLogFilePath ()) ); public string IMLSource { get => imlSource; @@ -128,7 +130,42 @@ namespace Crow NotifyValueChangedAuto (DebugLogToFile); } } + public string DebugLogFilePath { + get => Configuration.Global.Get ("DebugLogFilePath"); + set { + if (DebugLogFilePath == value) + return; + Configuration.Global.Set ("DebugLogFilePath", value); + NotifyValueChangedAuto (value); + } + } + int firstWidgetIndexToSave, lastWidgetIndexToSave; + public int FirstWidgetIndexToSave { + get => firstWidgetIndexToSave; + set { + if (firstWidgetIndexToSave == value) + return; + if (value > lastWidgetIndexToSave) + firstWidgetIndexToSave = lastWidgetIndexToSave; + else + firstWidgetIndexToSave = value; + NotifyValueChangedAuto (firstWidgetIndexToSave); + } + } + public int LastWidgetIndexToSave { + get => lastWidgetIndexToSave; + set { + if (lastWidgetIndexToSave == value) + return; + if (lastWidgetIndexToSave > widgets.Count) + lastWidgetIndexToSave = widgets.Count; + else + lastWidgetIndexToSave = value; + + NotifyValueChangedAuto (lastWidgetIndexToSave); + } + } protected override void onInitialized(object sender, EventArgs e) { @@ -373,8 +410,6 @@ namespace Crow widgets = new List(); events = new List(); miSave.Invoke(null, new object[] {dbgIFace, stream, firstWidgetIndexToGet, true}); - //debuggerType.GetMethod("Save", new Type[] {dbgIfaceType, typeof(string)}).Invoke(null, new object[] {dbgIFace, "debug.log"}); - //delSaveDebugLog(dbgIFace, "debug.log"); stream.Seek(0, SeekOrigin.Begin); DbgLogger.Load (stream, events, widgets); @@ -401,6 +436,12 @@ namespace Crow foreach (DbgEvent e in evt.Events) updateWidgetEvents (widgets, e); } + void saveLogToDebugLogFilePath () { + + } + void loadLogFromDebugLogFilePath () { + + } public virtual object GetScreenCoordinates () => ScreenCoordinates(Slot).TopLeft; } diff --git a/Samples/DebugLogAnalyzer/src/Program.cs b/Samples/DebugLogAnalyzer/src/Program.cs index a2711dda..9c2e7117 100644 --- a/Samples/DebugLogAnalyzer/src/Program.cs +++ b/Samples/DebugLogAnalyzer/src/Program.cs @@ -125,10 +125,6 @@ namespace DebugLogAnalyzer } - - - - public string CrowDbgAssemblyLocation { get => Configuration.Global.Get("CrowDbgAssemblyLocation"); set { @@ -156,35 +152,6 @@ namespace DebugLogAnalyzer NotifyValueChanged (nameof (Widgets), widgets); } } - /*IEnumerable widgetEvents (DbgWidgetRecord wr, DbgEvent evt) { - if (evt is DbgWidgetEvent we && we.InstanceIndex == wr.InstanceIndex) - yield return we; - if (evt.Events != null) { - foreach (DbgEvent e in evt.Events) - foreach (DbgWidgetEvent ye in widgetEvents (wr, e)) - yield return ye; - } - } - IEnumerable currentWidgetEvents; - - public IEnumerable CurrentWidgetEvents { - get => currentWidgetEvents; - set { - currentWidgetEvents = value; - NotifyValueChanged (currentWidgetEvents); - curWidget.Events = new List (currentWidgetEvents); - } - } - IEnumerable getCurrentWidgetEvents () { - if (CurrentWidget == null) - yield return null; - else { - foreach (DbgEvent evt in Events) - foreach (DbgWidgetEvent dwe in widgetEvents (CurrentWidget, evt)) - yield return dwe; - } - }*/ - public DbgEvent CurrentEvent { get => curEvent; @@ -277,7 +244,7 @@ namespace DebugLogAnalyzer NotifyValueChanged(DebugLogToFile); } } - public string DebugLogFilePath { + /*public string DebugLogFilePath { get => Configuration.Global.Get (nameof (DebugLogFilePath)); set { if (CurrentFile == value) @@ -285,7 +252,7 @@ namespace DebugLogAnalyzer Configuration.Global.Set (nameof (DebugLogFilePath), value); NotifyValueChanged (DebugLogFilePath); } - } + }*/ public bool DebugLogRecording { get => debugLogRecording; set { diff --git a/Samples/DebugLogAnalyzer/ui/main.crow b/Samples/DebugLogAnalyzer/ui/main.crow index 22d0920d..16973e11 100644 --- a/Samples/DebugLogAnalyzer/ui/main.crow +++ b/Samples/DebugLogAnalyzer/ui/main.crow @@ -1,8 +1,8 @@ - - + + @@ -60,8 +60,7 @@ - - + - + + + + + + + + \ No newline at end of file diff --git a/Samples/common/ui/Interfaces/Experimental/table2.crow b/Samples/common/ui/Interfaces/Experimental/table2.crow index 5416897c..4aa3eebb 100644 --- a/Samples/common/ui/Interfaces/Experimental/table2.crow +++ b/Samples/common/ui/Interfaces/Experimental/table2.crow @@ -1,18 +1,20 @@ - - - - - - - -
\ No newline at end of file + + + + + + +
+
\ No newline at end of file