]> O.S.I.I.S - jp/crow.git/commitdiff
debug log view
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 24 Nov 2018 12:09:19 +0000 (13:09 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 24 Nov 2018 12:09:19 +0000 (13:09 +0100)
Tests/BasicTests.cs
Tests/test.style
Tests/ui/dbgLog.crow
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/ScrollingObject.cs
src/debug/DbgLogViewer.cs

index 732edbc3bd2b09b63b6657a5d5e33257f32fa623..4f9fd128f09b515439c687b67609945873614e6d 100644 (file)
@@ -24,7 +24,7 @@ namespace tests
                                //app.AddWidget (@"Interfaces/Divers/colorPicker.crow").DataSource = app;
                                //app.AddWidget ("Interfaces/Divers/perfMeasures.crow").DataSource = app;
                                app.AddWidget ("#Tests.ui.dbgLog.crow").DataSource = app;
-
+               
                                while (true) {
                                        #if MEASURE_TIME
                                        foreach (PerformanceMeasure m in app.PerfMeasures)
index 434f80423de9a1d2d894a32078b7a73f8a26b346..14acbbdfdcfc0d50c8f43495b36d7f5d97618959 100644 (file)
@@ -33,8 +33,8 @@ labPerfVal{
        Width = "50%";
 }
 DbgLogViewer{
-       Background = "WhiteSmoke";
+       Background = "Onyx";
        Font = "mono, 8";
-       Foreground = "Jet";
+       Foreground = "LightGrey";
        Focusable = "true";
 }
index 09cc2eb2d02c629627785691e73ecf14024c69a2..d0735082b892a7782632502bd87d8e1c23a5776c 100755 (executable)
@@ -7,7 +7,7 @@
                <Label Text="{../../view.ScrollX}"/>
        </HorizontalStack>
        <HorizontalStack>
-               <DbgLogViewer Name="view" LogFile="debug.log" MouseWheelSpeed="10"/>
+               <DbgLogViewer Margin="0" Name="view" LogFile="debug.log" MouseWheelSpeed="10"/>
                <ScrollBar Name="scrollbar1" Orientation="Vertical"
                        Value="{²../view.ScrollY}"     Maximum="{../view.MaxScrollY}" 
                        CursorSize="{../view.ChildHeightRatio}"
index a55682b11f412375e7b2e58d9329dee81db062dd..686dcb7f744b971ade0f5023f02fa94456d2f4a8 100644 (file)
@@ -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
index 43343c597a4133666baf66ce6ee33a0152ed49eb..ea7fd291adb0cbc74435ed7993078cc99f429c0f 100644 (file)
@@ -91,7 +91,7 @@ namespace Crow
                                if (newS == scrollY)
                                        return;
 
-                               scrollY = value;
+                               scrollY = newS;
 
                                NotifyValueChanged ("ScrollY", scrollY);
                                RegisterForGraphicUpdate ();
index b020df4b802841e2585b0151d45b4f3838c7203c..eca502fb41dbaf17e3a7063ba1b4b7415e507804 100644 (file)
@@ -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)