]> O.S.I.I.S - jp/crow.git/commitdiff
temp save to make test in master
authorjpbruyere <jp.bruyere@hotmail.com>
Thu, 11 Feb 2016 16:01:00 +0000 (17:01 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Fri, 12 Feb 2016 09:33:24 +0000 (10:33 +0100)
13 files changed:
Crow.csproj
Tests/GOLIBTests.cs
Tests/Interfaces/clip0.crow [new file with mode: 0755]
Tests/Interfaces/clip1.crow [new file with mode: 0755]
Tests/Tests.csproj
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/ILayoutable.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/Scroller.cs
src/GraphicObjects/Window.cs
src/OpenTKGameWindow.cs
src/Rectangles.cs

index 64eab6c955c6428242e3b09a8c79217470e21580..9ae272309ac2f41f15f2f061c2714ab3c413616e 100644 (file)
@@ -46,7 +46,7 @@
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <OutputPath>bin\Debug</OutputPath>
-    <DefineConstants>DEBUG_LAYOUTING0;TRACE;DEBUG;__linux__;MEASURE_TIME;DEBUG_LOAD_TIME0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
+    <DefineConstants>DEBUG_LAYOUTING0;TRACE;DEBUG;__linux__;MEASURE_TIME;DEBUG_LOAD_TIME0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE</DefineConstants>
   </PropertyGroup>
   <!--  <PropertyGroup Condition=" '$(Platform)' == 'Linux_x86' ">
     <DefineConstants>__linux__</DefineConstants>
index fbf76ea2d99eac6bd093727382cd6b8aece2ab70..45bf6392410649230cd2b8dace4d1d21854ba652 100644 (file)
@@ -37,6 +37,8 @@ namespace test
                int frameCpt = 0;
                int idx = 0;
                string[] testFiles = {
+                       "clip1.crow",
+                       "clip0.crow",
                        "0.crow",
                        "5.crow",
                        "testCombobox.goml",
diff --git a/Tests/Interfaces/clip0.crow b/Tests/Interfaces/clip0.crow
new file mode 100755 (executable)
index 0000000..2ebea9f
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<Container Fit="true" Margin="50" Background="LimeGreen" CacheEnabled="false"
+               HorizontalAlignment="Right" VerticalAlignment="Bottom"
+               MouseEnter="{Background=Gray}"
+               MouseLeave="{Background=LimeGreen}">
+       <Label HorizontalAlignment="Center" VerticalAlignment="Center" CacheEnabled="false"
+               MouseEnter="{Background=DimGray}" Width="100"
+               MouseLeave="{Background=BlueCrayola}"
+               Margin="10" Text="{drawing}" Background="BlueCrayola"/>
+ </Container>
\ No newline at end of file
diff --git a/Tests/Interfaces/clip1.crow b/Tests/Interfaces/clip1.crow
new file mode 100755 (executable)
index 0000000..a4f42b1
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<Container Fit="true" Margin="20" Background="SkyBlue" CacheEnabled="true"
+               HorizontalAlignment="Right" VerticalAlignment="Bottom"
+               MouseEnter="{Background=LightGray}"
+               MouseLeave="{Background=SkyBlue}">
+               <Container Fit="true" Margin="20" Background="Red" CacheEnabled="true"
+                       HorizontalAlignment="Right" VerticalAlignment="Bottom"
+                       MouseEnter="{Background=White}"
+                       MouseLeave="{Background=Red}">
+                       <Container Fit="true" Margin="20" Background="Yellow" CacheEnabled="true"
+                               HorizontalAlignment="Right" VerticalAlignment="Bottom"
+                               MouseEnter="{Background=Blue}"
+                               MouseLeave="{Background=Yellow}">
+                               <Container Margin="50" Background="LimeGreen" CacheEnabled="false"
+                                               HorizontalAlignment="Right" VerticalAlignment="Bottom"
+                                               MouseEnter="{Background=Gray}"
+                                               MouseLeave="{Background=LimeGreen}">
+                                       <Label  HorizontalAlignment="Center" VerticalAlignment="Center" CacheEnabled="true"
+                                               MouseEnter="{Background=DimGray}"
+                                               MouseLeave="{Background=BlueCrayola}" 
+                                               Margin="1" Text="{drawing}" Background="BlueCrayola"/>
+                               </Container>
+                       </Container>
+               </Container>
+ </Container>
\ No newline at end of file
index cbb628a75c6e7b0c9f012cd0a20fc4a5bf60f931..0fe3ffa14b25a9810a37a207cf4bb4e6538bcc20 100644 (file)
     <None Include="Interfaces\testStacks.crow">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="Interfaces\clip0.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Interfaces\clip1.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Interfaces\" />
index 14516dba43606a5dfc240f8fe76ecbcbedd601c9..699d39a9c5d9b8e870d40c529b497e4c4622a589 100644 (file)
@@ -31,6 +31,9 @@ namespace Crow
                internal List<Binding> Bindings = new List<Binding> ();
                internal int layoutingTries = 0;
 
+               Rectangles _clipping = new Rectangles();
+               public Rectangles Clipping { get { return _clipping; }}
+
                #region IValueChange implementation
                public event EventHandler<ValueChangeEventArgs> ValueChanged;
                public virtual void NotifyValueChanged(string MemberName, object _value)
@@ -121,15 +124,7 @@ namespace Crow
                [XmlIgnore]public ILayoutable Parent { 
                        get { return _parent; }
                        set {
-//                             if (_parent == value)
-//                                     return;
-//                             if (_parent != null)
-//                                     ClearBinding ();
-//                             
                                _parent = value;
-//
-//                             if (DataSource != null)
-//                                     ResolveBindings ();
                        }
                }
 
@@ -150,20 +145,14 @@ namespace Crow
                }
                public virtual Rectangle ContextCoordinates(Rectangle r){
                        return
-                               Parent.ContextCoordinates (r);// + ClientRectangle.Position;
+                               Parent.ContextCoordinates (r);
                }                       
                public virtual Rectangle ScreenCoordinates (Rectangle r){
                        return 
                                Parent.ScreenCoordinates(r) + Parent.getSlot().Position + Parent.ClientRectangle.Position;
                }
-               public virtual Rectangle getSlot()
-               {
-                       return Slot;
-               }
-               public virtual Rectangle getBounds()
-               {
-                       return Bounds;
-               }
+               public virtual Rectangle getSlot() => Slot;
+               public virtual Rectangle getBounds() => Bounds;
                #endregion
 
                #region EVENT HANDLERS
@@ -478,14 +467,22 @@ namespace Crow
                public virtual bool Contains(GraphicObject goToFind){
                        return false;
                }
-
-               public virtual void registerClipRect()
-               {
-                       HostContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot));
+               public void RegisterClip(Rectangle clip){
+                       Rectangle r = Slot + Parent.ClientRectangle;
+                       if (CacheEnabled && bmp != null)
+                               Clipping.AddRectangle (r);                              
+                       Parent.RegisterClip (r);
+               }
+//             public virtual void registerClipRect(Rectangle clip)
+//             {
+//                     Rectangle tmp = ContextCoordinates (clip);
+//                     if (CacheEnabled) {
+//                     }
+                       //HostContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot));
                        //this clipping should take only last painted slots on each level in ancestor tree which
                        //is not the case for now.
-                       HostContainer.redrawClip.AddRectangle (ScreenCoordinates(LastPaintedSlot));
-               }
+                       //HostContainer.redrawClip.AddRectangle (ScreenCoordinates(LastPaintedSlot));
+               //}
                /// <summary>
                /// Clear chached object and add clipping region in redraw list of interface
                /// </summary>
@@ -754,7 +751,7 @@ namespace Crow
                }
                /// <summary> Chained painting routine on the parent context of the actual cached version
                /// of the widget </summary>
-               public virtual void Paint (ref Context ctx, Rectangles clip = null)
+               public virtual void Paint (ref Context ctx)
                {
                        if (!Visible)
                                return;
@@ -771,24 +768,25 @@ namespace Crow
                        if (cacheEnabled) {
                                if (bmp == null)
                                        UpdateGraphic ();
-
                                using (ImageSurface source = new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) {
-                                       //TODO:improve equality test for basic color and Fill
-                                       if (this.Background is SolidColor) {
-                                               if ((this.Background as SolidColor).Equals (Color.Clear)) {
-                                                       ctx.Save ();
-                                                       ctx.Operator = Operator.Clear;
-                                                       ctx.Rectangle (rb);
-                                                       ctx.Fill ();
-                                                       ctx.Restore ();
-                                               }
-                                       }
+//                                     //TODO:improve equality test for basic color and Fill
+//                                     if (this.Background is SolidColor) {
+//                                             if ((this.Background as SolidColor).Equals (Color.Clear)) {
+//                                                     ctx.Save ();
+//                                                     ctx.Operator = Operator.Clear;
+//                                                     ctx.Rectangle (rb);
+//                                                     ctx.Fill ();
+//                                                     ctx.Restore ();
+//                                             }
+//                                     }
                                        ctx.SetSourceSurface (source, rb.X, rb.Y);
                                        ctx.Paint ();
                                }
                                return;
                        }
                        ctx.Save ();
+
+                       Clipping.clearAndClip (ctx);
                        ctx.Translate (rb.X, rb.Y);
                        onDraw (ctx);
                        ctx.Restore ();
index 9d9abbc671c22979b265eed5a826710060b5b736..33fe006dd581e5006d8e5ceea8c5504ddd756de1 100644 (file)
@@ -217,53 +217,42 @@ namespace Crow
                        }
                }
 
-               public override void Paint(ref Context ctx, Rectangles clip = null)
+               public override void Paint(ref Context ctx)
                {
                        if ( !Visible )
                                return;
 
-                       if (bmp == null)
-                               UpdateGraphic ();
-                       else {
-                               if (clip != null)
-                                       clip.Rebase (this);                                                                     
-                               else {
-                                       clip = new Rectangles ();
-                                       //TODO:added lately slot to empty clip,
-                                       //should rework this precise case causing expandable not
-                                       //to show image changes
-                                       clip.AddRectangle (ContextCoordinates (Slot.Size));
-                               }
-
-                               if (!DrawingIsValid || clip != null) {//false when 1 child has changed
-                                       //child having their content changed has to be repainted
-                                       //and those with slot intersecting clip rectangle have also to be repainted
+                       if (CacheEnabled) {
+                               if (bmp == null)
+                                       RecreateCache ();
+                       }
 
-                                       using (ImageSurface cache =
-                                                     new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, Slot.Width * 4)) {
-                                               Context gr = new Context (cache);
-                                               clip.clearAndClip (gr);
+                       if (Clipping.count > 0) {
+                               using (ImageSurface cache =
+                                              new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, Slot.Width * 4)) {
+                                       Context gr = new Context (cache);
 
-                                               Rectangle rBack = Slot.Size;
-                                               Background.SetAsSource (gr, rBack);
-                                               CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
-                                               gr.Fill ();
+                                       Clipping.clearAndClip (gr);
+                                       Rectangle rBack = Slot.Size;
+                                       Background.SetAsSource (gr, rBack);
+                                       CairoHelpers.CairoRectangle (gr, rBack, CornerRadius);
+                                       gr.Fill ();
 
-                                               #if DEBUG_CLIP_RECTANGLE
-                                               clip.stroke (gr, Color.Amaranth.AdjustAlpha (0.8));
-                                               #endif
-                                               foreach (GraphicObject c in children.Where(ch=>ch.Visible)) {
-                                                       Rectangles childClip = clip.intersectingRects (ContextCoordinates(c.Slot));
-                                                       if (!c.DrawingIsValid || childClip.count > 0)
-                                                               c.Paint (ref gr, childClip);//, localClip);
-                                               }
-
-                                               gr.Dispose ();
+                                       foreach (GraphicObject c in children) {
+                                               if (!c.Visible)
+                                                       continue;
+                                               Rectangles childClip = Clipping.intersectingRects (ContextCoordinates (c.Slot));
+                                               if (childClip.count > 0)
+                                                       c.Paint (ref ctx);                                              
                                        }
+                                       #if DEBUG_CLIP_RECTANGLE
+                                       Clipping.stroke (gr, Color.Amaranth.AdjustAlpha (0.8));
+                                       #endif
+
+                                       gr.Dispose ();
                                }
-                       }
-                               
-                       base.Paint (ref ctx, clip);
+                       }                               
+                       base.Paint (ref ctx);
                }
                #endregion
 
index 54e54f034291aa25bac322c1bfc7732532cf1c21..bbf1b4a6a9ef989a1bbbc1d0dc11f21ba7444b50 100644 (file)
@@ -21,6 +21,7 @@ namespace Crow
 
                LayoutingType RegisteredLayoutings { get; set; }
                void RegisterForLayouting(LayoutingType layoutType);
+               void RegisterClip(Rectangle clip);
                bool UpdateLayout(LayoutingType layoutType);
 
 
index 9f787eac0a7021b24ec23621f2a0a9eed1a34731..63f4f02ae513697d853479341354e188ee61ac5e 100644 (file)
@@ -139,24 +139,21 @@ namespace Crow
                        return
                                Parent.ContextCoordinates(r) + Slot.Position + ClientRectangle.Position;
                }
-               public override void Paint(ref Cairo.Context ctx, Rectangles clip = null)
+               public override void Paint(ref Cairo.Context ctx)
                {
                        if (!Visible)//check if necessary??
                                return;
 
                        ctx.Save();
 
-                       if (clip != null)
-                               clip.clip(ctx);
-
-                       base.Paint(ref ctx, clip);
+                       base.Paint(ref ctx);
 
                        //clip to client zone
                        CairoHelpers.CairoRectangle (ctx, Parent.ContextCoordinates(ClientRectangle + Slot.Position), CornerRadius);
                        ctx.Clip();
 
                        if (child != null)
-                               child.Paint(ref ctx, clip);
+                               child.Paint(ref ctx);
 
                        ctx.Restore();            
                }
index 3ac8d66c9edb995f82fdd250ff29d6c137ba35a2..599f951fddc40dddc8b691b5248ce0220ecfc146 100644 (file)
@@ -188,10 +188,10 @@ namespace Crow
                        return base.ScreenCoordinates (r) - new Point((int)ScrollX,(int)ScrollY);
                }
 
-               public override void registerClipRect ()
-               {
-                       HostContainer.redrawClip.AddRectangle (base.ScreenCoordinates(Slot));
-               }
+//             public override void registerClipRect ()
+//             {
+//                     HostContainer.redrawClip.AddRectangle (base.ScreenCoordinates(Slot));
+//             }
 
 
     }
index d98d296c3f5c6cdd14ac4ca5f14bf542f01c6e53..726f858a3bc66cb1eb72c79ae24ae5a784d2b289 100644 (file)
@@ -89,7 +89,7 @@ namespace Crow
                                if (!HasFocus)
                                        return;
                                
-                               otkgw.redrawClip.AddRectangle (this.ScreenCoordinates(this.Slot));
+                               //otkgw.redrawClip.AddRectangle (this.ScreenCoordinates(this.Slot));
 
                                int currentLeft = this.Left;
                                int currentTop = this.Top;
index 16362c6c195e4e804478c91bb861efec28a9ef8e..e6fc9681800e0b51e7a582e0c747270067a4e762 100644 (file)
@@ -90,7 +90,7 @@ namespace Crow
                        {
                                GraphicObjects.Remove(g);
                                GraphicObjects.Insert(0, g);
-                               g.registerClipRect ();
+                               //g.registerClipRect ();
                        }
                }
                public void Quit ()
@@ -282,14 +282,15 @@ namespace Crow
                                        gobjsToRedraw.Clear ();
                                        foreach (GraphicObject p in gotr) {
                                                p.IsQueuedForRedraw = false;
-                                               p.registerClipRect ();
+                                               p.RegisterClip (p.LastPaintedSlot);
+                                               p.RegisterClip (p.getSlot());
                                        }
 
                                        #if MEASURE_TIME
                                        updateTime.Stop ();
                                        drawingTime.Start ();
                                        #endif
-
+                                       Debug.WriteLine (redrawClip.ToString ());
                                        lock (redrawClip) {
                                                if (redrawClip.count > 0) {
                                                        #if DEBUG_CLIP_RECTANGLE
@@ -299,17 +300,18 @@ namespace Crow
 
                                                        //Link.draw (ctx);
                                                        foreach (GraphicObject p in invGOList) {
-                                                               if (p.Visible) {
+                                                               if (!p.Visible)
+                                                                       continue;
+
+                                                               ctx.Save ();
+
+                                                               Rectangles clip = redrawClip.intersectingRects (p.Slot);
 
-                                                                       ctx.Save ();
-                                                                       if (redrawClip.count > 0) {
-                                                                               Rectangles clip = redrawClip.intersectingRects (p.Slot);
+                                                               if (clip.count > 0)
+                                                                       p.Paint (ref ctx);
+                                                               
+                                                               ctx.Restore ();
 
-                                                                               if (clip.count > 0)
-                                                                                       p.Paint (ref ctx, clip);
-                                                                       }
-                                                                       ctx.Restore ();
-                                                               }
                                                        }
                                                        ctx.ResetClip ();
                                                        #if DEBUG_CLIP_RECTANGLE
@@ -549,6 +551,9 @@ namespace Crow
         #endregion
 
                #region ILayoutable implementation
+               public void RegisterClip(Rectangle r){
+                       redrawClip.AddRectangle (r);
+               }
                public int LayoutingTries {
                        get { throw new NotImplementedException (); }
                        set { throw new NotImplementedException (); }
@@ -559,17 +564,13 @@ namespace Crow
                }
                public void RegisterForLayouting (LayoutingType layoutType) { throw new NotImplementedException (); }
                public bool UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); }
-               public Rectangle ContextCoordinates (Rectangle r)
-               {
-                       return r;
-               }
+               public Rectangle ContextCoordinates (Rectangle r) => r;
                public Rectangle ScreenCoordinates (Rectangle r) => r;
 
                public ILayoutable Parent {
                        get { return null; }
                        set { throw new NotImplementedException (); }
                }
-
                public ILayoutable LogicalParent {
                        get { return null; }
                        set { throw new NotImplementedException (); }
@@ -581,15 +582,8 @@ namespace Crow
                public IGOLibHost HostContainer {
                        get { return this; }
                }
-
-               public Rectangle getSlot ()
-               {
-                       return ClientRectangle;
-               }
-               public Rectangle getBounds ()//redundant but fill ILayoutable implementation
-               {
-                       return ClientRectangle;
-               }                       
+               public Rectangle getSlot () => ClientRectangle;
+               public Rectangle getBounds () => ClientRectangle;
                #endregion
     }
 }
\ No newline at end of file
index dbb4118bd5876600709058953cfdeb1e03bd3957..c507b2bafe0a91f90bb35310631f483971c584b3 100644 (file)
@@ -147,6 +147,8 @@ namespace Crow
                }
         public void clearAndClip(Context ctx)
         {
+                       if (list.Count == 0)
+                               return;
             foreach (Rectangle r in list)
                 ctx.Rectangle(r);