diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-11-24 13:09:19 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-11-24 13:09:19 +0100 |
| commit | f30bf0d4cc96f160b29a89216326030f083ee509 (patch) | |
| tree | af74eaefc24f9abfeed1b8f311b6e0a9c87156ed /src | |
| parent | 98eada369aa50115e677a1b337662fee9f0ca011 (diff) | |
debug log view
Diffstat (limited to 'src')
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 21 | ||||
| -rw-r--r-- | src/GraphicObjects/ScrollingObject.cs | 2 | ||||
| -rw-r--r-- | src/debug/DbgLogViewer.cs | 79 |
3 files changed, 85 insertions, 17 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index a55682b1..686dcb7f 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -1336,7 +1336,7 @@ namespace Crow /// </summary> public virtual void ClippingRegistration(){ #if DEBUG_LOG - DebugLog.AddEvent(DbgEvtType.GOClippingRegistration, this); + DbgEvent dbgEvt = DebugLog.AddEvent(DbgEvtType.GOClippingRegistration, this); #endif parentRWLock.EnterReadLock (); if (parent != null) { @@ -1344,6 +1344,9 @@ namespace Crow Parent.RegisterClip (Slot); } parentRWLock.ExitReadLock (); + #if DEBUG_LOG + dbgEvt.end = DebugLog.chrono.ElapsedTicks; + #endif } /// <summary> /// Add clip rectangle to this.clipping and propagate up to root @@ -1351,7 +1354,7 @@ namespace Crow /// <param name="clip">Clip rectangle</param> public virtual void RegisterClip(Rectangle clip){ #if DEBUG_LOG - DebugLog.AddEvent(DbgEvtType.GORegisterClip, this); + DbgEvent dbgEvt = DebugLog.AddEvent(DbgEvtType.GORegisterClip, this); #endif Rectangle r = clip + ClientRectangle.Position; if (CacheEnabled && !IsDirty) @@ -1362,6 +1365,9 @@ namespace Crow if (p?.IsDirty == true && p?.CacheEnabled == true) return; Parent.RegisterClip (r + Slot.Position); + #if DEBUG_LOG + dbgEvt.end = DebugLog.chrono.ElapsedTicks; + #endif } /// <summary> Full update, taking care of sizing policy </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -1610,7 +1616,7 @@ namespace Crow protected virtual void onDraw(Context gr) { #if DEBUG_LOG - DebugLog.AddEvent(DbgEvtType.GODraw, this); + DbgEvent dbgEvt = DebugLog.AddEvent(DbgEvtType.GODraw, this); #endif Rectangle rBack = new Rectangle (Slot.Size); @@ -1618,6 +1624,10 @@ namespace Crow Background.SetAsSource (gr, rBack); CairoHelpers.CairoRectangle (gr, rBack, cornerRadius); gr.Fill (); + + #if DEBUG_LOG + dbgEvt.end = DebugLog.chrono.ElapsedTicks; + #endif } /// <summary> @@ -1626,7 +1636,7 @@ namespace Crow protected virtual void RecreateCache () { #if DEBUG_LOG - DebugLog.AddEvent(DbgEvtType.GORecreateCache, this); + DbgEvent dbgEvt = DebugLog.AddEvent(DbgEvtType.GORecreateCache, this); #endif IsDirty = false; bmp?.Dispose (); @@ -1636,6 +1646,9 @@ namespace Crow onDraw (gr); } bmp.Flush (); + #if DEBUG_LOG + dbgEvt.end = DebugLog.chrono.ElapsedTicks; + #endif } protected virtual void UpdateCache(Context ctx){ #if DEBUG_LOG diff --git a/src/GraphicObjects/ScrollingObject.cs b/src/GraphicObjects/ScrollingObject.cs index 43343c59..ea7fd291 100644 --- a/src/GraphicObjects/ScrollingObject.cs +++ b/src/GraphicObjects/ScrollingObject.cs @@ -91,7 +91,7 @@ namespace Crow if (newS == scrollY) return; - scrollY = value; + scrollY = newS; NotifyValueChanged ("ScrollY", scrollY); RegisterForGraphicUpdate (); diff --git a/src/debug/DbgLogViewer.cs b/src/debug/DbgLogViewer.cs index b020df4b..eca502fb 100644 --- a/src/debug/DbgLogViewer.cs +++ b/src/debug/DbgLogViewer.cs @@ -81,6 +81,11 @@ namespace Crow { base.onDraw (gr); + gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight); + gr.SetFontSize (Font.Size); + gr.FontOptions = Interface.FontRenderingOptions; + gr.Antialias = Interface.Antialias; + if (!loaded) { if (!File.Exists (logFile)) return; @@ -108,41 +113,57 @@ namespace Crow maxTicks = events [events.Count - 1].begin; } else minTicks = maxTicks = 0; + MaxScrollY = Math.Max(0, objs.Count - (int)Math.Ceiling((double)ClientRectangle.Height / lineHeight)); } Rectangle r = ClientRectangle; - Foreground.SetAsSource (gr); + gr.LineWidth = 1.0; leftMargin = 0.0; foreach (DbgGo g in objs) { if (g.yIndex == 0) continue; - double penX = r.X + g.xLevel * 5.0, penY = (g.yIndex - ScrollY) * lineHeight - gr.FontExtents.Descent; - gr.MoveTo (penX, penY); + double penX = r.X + g.xLevel * 5.0; Cairo.TextExtents te = gr.TextExtents (g.name); if (te.Width + penX > leftMargin) leftMargin = te.Width + penX; + double penY = (g.yIndex - ScrollY) * lineHeight + r.Top; + if (penY < r.Top || penY > r.Bottom + lineHeight) + continue; + + Foreground.SetAsSource (gr); + gr.MoveTo (penX, penY - gr.FontExtents.Descent); gr.ShowText (g.name); + gr.SetSourceColor (Crow.Color.Jet); + gr.MoveTo (r.X, penY - 0.5); + gr.LineTo (r.Right, penY - 0.5); + gr.Stroke (); } leftMargin += 2.5; r.Left += (int)leftMargin; - gr.LineWidth = 1.0; gr.MoveTo (leftMargin, r.Top); gr.LineTo (leftMargin, r.Bottom); + Foreground.SetAsSource (gr); gr.Stroke (); MaxScrollX = (int)(maxTicks - minTicks) - r.Width; + gr.SetFontSize (8); + + gr.Save (); + gr.Rectangle (r); + gr.Clip (); + foreach (DbgEvent evt in events) { double x = (int)((double)(evt.begin - minTicks - ScrollX) * xScale) ; x += (double)r.Left + 0.5; - double w = Math.Max (Math.Max(4.0, 10.0 * xScale), (double)(evt.end - evt.begin) * xScale); + double w = Math.Max (Math.Max(2.0, 2.0 * xScale), (double)(evt.end - evt.begin) * xScale); - if (x < r.Left || x > r.Right) + if (x + w < r.Left || x > r.Right) continue; if (evt.type.HasFlag (DbgEvtType.GraphicObject)) { @@ -168,15 +189,43 @@ namespace Crow gr.SetSourceColor (Crow.Color.Blue); break; } + }else gr.SetSourceColor (Crow.Color.Bisque); + }else if (evt.type == DbgEvtType.GOInitialization) gr.SetSourceColor (Crow.Color.Cyan); + else if (evt.type == DbgEvtType.GOClippingRegistration) + gr.SetSourceColor (Crow.Color.BlueViolet); + else if (evt.type == DbgEvtType.GORegisterClip) + gr.SetSourceColor (Crow.Color.Orange); + else if (evt.type == DbgEvtType.GODraw) + gr.SetSourceColor (Crow.Color.Pink); + else if (evt.type == DbgEvtType.GORecreateCache) + gr.SetSourceColor (Crow.Color.YellowGreen); gr.Rectangle (x, y, w, lineHeight); gr.Fill (); + + if (evt.type.HasFlag (DbgEvtType.GOLayouting)) { + gr.SetSourceColor (Crow.Color.Black); + switch (data.layout) { + case LayoutingType.Height: + gr.MoveTo (x + w * 0.5, y + 1); + gr.LineTo (x + w * 0.5, y + lineHeight - 2); + gr.Stroke (); + break; + case LayoutingType.Width: + gr.MoveTo (x + 0.5, y + lineHeight * 0.5); + gr.LineTo (x + w - 1.0, y + lineHeight * 0.5); + gr.Stroke (); + break; + default: + break; + } + } } else { - gr.SetSourceColor (Crow.Color.Black); + gr.SetSourceColor (Crow.Color.Yellow); gr.MoveTo (x, r.Top); gr.LineTo (x, r.Bottom); gr.Stroke (); @@ -185,11 +234,11 @@ namespace Crow gr.Rectangle (x, r.Top, te.Width, lineHeight); gr.Fill (); gr.MoveTo (x, r.Top + gr.FontExtents.Ascent); - gr.SetSourceColor (Crow.Color.White); + gr.SetSourceColor (Crow.Color.Jet); gr.ShowText (s); } } - + gr.Restore (); } public override void Paint (ref Cairo.Context ctx) { @@ -201,6 +250,11 @@ namespace Crow ctx.SetSourceColor (Color.CornflowerBlue); ctx.Fill(); + ctx.SelectFontFace (Font.Name, Font.Slant, Font.Wheight); + ctx.SetFontSize (Font.Size); + ctx.FontOptions = Interface.FontRenderingOptions; + ctx.Antialias = Interface.Antialias; + ctx.MoveTo (cb.X, cb.Y + lineHeight); ctx.ShowText (currentTick.ToString ()); @@ -217,10 +271,11 @@ namespace Crow cb.X = (int)selEndX; cb.Width = (int)(selStartX - selEndX); } - ctx.Operator = Cairo.Operator.Multiply; + ctx.Operator = Cairo.Operator.Add; cb.Width = Math.Max (1, cb.Width); ctx.Rectangle (cb); - ctx.SetSourceColor (Color.LightYellow); + //ctx.SetSourceColor (Color.LightYellow); + ctx.SetSourceColor (Color.Jet); ctx.Fill(); ctx.Operator = Cairo.Operator.Over; @@ -230,7 +285,7 @@ namespace Crow base.OnLayoutChanges (layoutType); switch (layoutType) { case LayoutingType.Width: - RegisterForLayouting (LayoutingType.X); + break; case LayoutingType.Height: if (!loaded) |