]> O.S.I.I.S - jp/crow.git/commitdiff
clipping basics ok for Group and PrivateContainer, problems with Templates
authorjpbruyere <jp.bruyere@hotmail.com>
Fri, 12 Feb 2016 12:42:46 +0000 (13:42 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Fri, 12 Feb 2016 12:42:46 +0000 (13:42 +0100)
Tests/GOLIBTests.cs
Tests/Interfaces/clip0.crow
Tests/Interfaces/clip1.crow
Tests/Interfaces/clip2.crow
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/TemplatedControl.cs
src/OpenTKGameWindow.cs

index c14277f427c5f03744a1816b1dbcc278511c6bb5..622d1ce70ad36b8a002ea391fa74747d7305cf43 100644 (file)
@@ -37,9 +37,9 @@ namespace test
                int frameCpt = 0;
                int idx = 0;
                string[] testFiles = {
+                       "clip2.crow",
                        "clip0.crow",
                        "clip1.crow",
-                       "clip2.crow",
                        "0.crow",
                        "5.crow",
                        "testCombobox.goml",
index dbe6eb341718e426a8b9fa24f5700a1ef133d9f3..2ebea9ff56447288b0b67f4e9eb1b93c0613f382 100755 (executable)
@@ -1,9 +1,9 @@
 <?xml version="1.0"?>
-<Container Fit="true" Margin="50" Background="LimeGreen" CacheEnabled="true"
+<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="true"
+       <Label HorizontalAlignment="Center" VerticalAlignment="Center" CacheEnabled="false"
                MouseEnter="{Background=DimGray}" Width="100"
                MouseLeave="{Background=BlueCrayola}"
                Margin="10" Text="{drawing}" Background="BlueCrayola"/>
index d5fcf79b2bd1a5d273d2eafe19059726a7146ee9..4aeb7fdeb833a0999763e6bacba655348e83fdfe 100755 (executable)
@@ -1,9 +1,9 @@
 <?xml version="1.0"?>
-<Container Fit="true" Margin="20" Background="SkyBlue" CacheEnabled="true"
+<Container Fit="true" Margin="20" Background="SkyBlue" CacheEnabled="false"
                HorizontalAlignment="Right" VerticalAlignment="Bottom"
                MouseEnter="{Background=LightGray}"
                MouseLeave="{Background=SkyBlue}">
-               <Container Fit="true" Margin="20" Background="Red" CacheEnabled="false"
+               <Container Fit="true" Margin="20" Background="Red" CacheEnabled="true"
                        HorizontalAlignment="Right" VerticalAlignment="Bottom"
                        MouseEnter="{Background=White}"
                        MouseLeave="{Background=Red}">
index 8f6b4656260a50015f5bafe8ea9cdf96e2cfb941..8ab66910c34c8af1e3dac4de2fee3a976c55f4c0 100755 (executable)
@@ -7,7 +7,7 @@
                HorizontalAlignment="Right" VerticalAlignment="Bottom"
                MouseEnter="{Background=Gray}"
                MouseLeave="{Background=LimeGreen}">
-       <Label HorizontalAlignment="Center" VerticalAlignment="Center" CacheEnabled="false"
+       <Label HorizontalAlignment="Center" VerticalAlignment="Center" CacheEnabled="true"
                MouseEnter="{Background=DimGray}" Width="100"
                MouseLeave="{Background=BlueCrayola}"
                Margin="10" Text="{drawing}" Background="BlueCrayola"/>
index 97e4eccf010f8b8ae409efb3dd5fd28af5d764e4..7cb4a723bb8f235d488bee2df1a9d83435b94e9a 100644 (file)
@@ -473,8 +473,8 @@ namespace Crow
                }
                public void RegisterClip(Rectangle clip){                       
                        if (CacheEnabled && bmp != null)
-                               Clipping.AddRectangle (clip);                           
-                       Parent.RegisterClip (clip + Slot.Position + Parent.ClientRectangle.Position);
+                               Clipping.AddRectangle (clip + ClientRectangle.Position);
+                       Parent.RegisterClip (clip + Slot.Position + ClientRectangle.Position);
                }
 //             public virtual void registerClipRect(Rectangle clip)
 //             {
@@ -502,12 +502,6 @@ namespace Crow
                {
                        if (IsQueuedForRedraw)
                                return;
-                       //test if this speed up a lot to cancel clipping for an uncached group
-                       Group p = Parent as Group;
-                       if (p != null) {
-                               if (p.bmp == null)
-                                       return;
-                       }
                        if (HostContainer == null)
                                return;
                        HostContainer.gobjsToRedraw.Add (this);
index efc5240befad957183e20edc4fb8f8d413d2fd64..a2bc4634213207236bd1df95e47c84f89d950b70 100644 (file)
@@ -220,19 +220,20 @@ namespace Crow
                        using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) {
                                Context gr = new Context (cache);
 
-                               //Clipping.clearAndClip (gr);
-                               base.onDraw (gr);
+                               if (Clipping.count > 0) {
+                                       Clipping.clearAndClip (gr);
+                                       base.onDraw (gr);
 
-                               foreach (GraphicObject c in children) {
-                                       if (!c.Visible)
-                                               continue;
-                                       c.Paint (ref gr);                                               
-                               }
-
-                               #if DEBUG_CLIP_RECTANGLE
-                               Clipping.stroke (gr, Color.Amaranth.AdjustAlpha (0.8));
-                               #endif
+                                       foreach (GraphicObject c in children) {
+                                               if (!c.Visible)
+                                                       continue;
+                                               c.Paint (ref gr);                                               
+                                       }
 
+                                       #if DEBUG_CLIP_RECTANGLE
+                                       Clipping.stroke (gr, Color.Amaranth.AdjustAlpha (0.8));
+                                       #endif
+                               }
                                gr.Dispose ();
 
                                ctx.SetSourceSurface (cache, rb.X, rb.Y);
index 4012a7afb9ab0693e380f8e7acea7ca4bf536469..d3a706497210d051a4d049817ac5199e13a71598 100644 (file)
@@ -141,14 +141,18 @@ namespace Crow
                }
                protected override void UpdateCache (Context ctx)
                {
+                       //ctx.Save ();
+
                        Rectangle rb = Slot + Parent.ClientRectangle.Position;
 
                        using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) {
                                Context gr = new Context (cache);
 
-                               //Clipping.clearAndClip (ctx);
 
                                if (Clipping.count > 0) {
+
+                                       Clipping.clearAndClip (gr);
+
                                        if (child != null) {
                                                
                                                base.onDraw (gr);
@@ -163,6 +167,8 @@ namespace Crow
                                ctx.Paint ();
                        }
                        Clipping.Reset();
+
+                       //ctx.Restore ();
                }
 //             public override Rectangle ContextCoordinates (Rectangle r)
 //             {
index 9dacd4665eb54ef8294a31b9ff9a71a65d145ac6..50199f7a75c05cfc1883e48d0a217f4e98aeffaa 100644 (file)
@@ -93,11 +93,6 @@ namespace Crow
                                        NotifyValueChanged ("TemplatedHeight", 0);
                        }
                }
-
-               protected override void loadDefaultValues ()
-               {                       
-                       base.loadDefaultValues ();
-               }
                public override GraphicObject FindByName (string nameToFind)
                {
                        //prevent name searching in template
index 5a2dc7fe1d19d3ce6c19a71c210409b73f1a6618..c46a07f7efe56d1926faa995e9f2f236719ea73e 100644 (file)
@@ -279,8 +279,8 @@ namespace Crow
                        gobjsToRedraw.Clear ();
                        foreach (GraphicObject p in gotr) {
                                p.IsQueuedForRedraw = false;
-                               p.RegisterClip (p.LastPaintedSlot);
-                               p.RegisterClip (p.getSlot());
+                               p.Parent.RegisterClip (p.LastPaintedSlot);
+                               p.Parent.RegisterClip (p.getSlot());
                        }
 
                        #if MEASURE_TIME
@@ -307,9 +307,9 @@ namespace Crow
                                                        ctx.Restore ();
                                                }
 
-                                               #if DEBUG_CLIP_RECTANGLE
-                                               clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5));
-                                               #endif
+//                                             #if DEBUG_CLIP_RECTANGLE
+//                                             clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5));
+//                                             #endif
 
                                                clipping.Reset ();
                                        }