]> O.S.I.I.S - jp/crow.git/commitdiff
Merge branch 'NewClipping'
authorjpbruyere <jp.bruyere@hotmail.com>
Fri, 12 Feb 2016 16:47:36 +0000 (17:47 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Fri, 12 Feb 2016 16:47:36 +0000 (17:47 +0100)
1  2 
Tests/Interfaces/clip4.crow
src/GraphicObjects/PrivateContainer.cs

index 0000000000000000000000000000000000000000,6d85a7e14c879fa9ad1f3ad1fd6391b217e6bf4d..69fc7f12f7130a4a04c056cd30e33f0999793cff
mode 000000,100755..100755
--- /dev/null
@@@ -1,0 -1,58 +1,58 @@@
 -<Border Fit="true" BorderWidth="2">
 -<Scroller CornerRadius="2" CacheEnabled="false" VerticalScrolling="true" Height="200" Width="300" Background="DimGray" Margin="2">
 -      <VerticalStack Margin="10" VerticalAlignment="Top" Fit="true" Background="vgradient|0:BlueCrayola|1:Black">
+ <?xml version="1.0"?>
++<Border Fit="true" BorderWidth="2"  >
++<Scroller CornerRadius="2" VerticalScrolling="true" Height="200" Width="300" Background="DimGray" Margin="2">
++      <VerticalStack Margin="10" VerticalAlignment="Top" Fit="true" Background="vgradient|0:BlueCrayola|1:Black" >
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 1"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 2"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 3"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 4"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 5"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 6"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 7"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 8"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 9"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 10"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 11"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 12"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 13"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 14"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 15"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 16"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 17"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 18"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 19"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 20"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 21"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 22"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 23"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 24"/>
+                <Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 25"/>
+       </VerticalStack>
+ </Scroller>
+ </Border>
+ <!--<VerticalStack Fit="true" Margin="50" Background="LimeGreen" CacheEnabled="false"
+               HorizontalAlignment="Right" VerticalAlignment="Bottom"
+               MouseEnter="{Background=Gray}"
+               MouseLeave="{Background=LimeGreen}">
+               <CheckBox Margin="20" Background="BlueCrayola"/>
+               <CheckBox/>
+               <CheckBox/>
+               <CheckBox/>
+               <CheckBox/>
+               <RadioButton/>
+               <RadioButton/>
+               <RadioButton/>
+               <RadioButton/>
+               <RadioButton/>
+               <CheckBox/>
+       <Label HorizontalAlignment="Center" VerticalAlignment="Center" CacheEnabled="true"
+               MouseEnter="{Background=DimGray}" Width="100"
+               MouseLeave="{Background=BlueCrayola}"
+               Margin="10" Text="{fps}" Background="BlueCrayola"/>
+       <Label HorizontalAlignment="Center" VerticalAlignment="Center" CacheEnabled="true"
+               MouseEnter="{Background=DimGray}" Width="100"
+               MouseLeave="{Background=BlueCrayola}"
+               Margin="10" Text="{drawing}" Background="BlueCrayola"/>
+  </VerticalStack>-->
index 9f787eac0a7021b24ec23621f2a0a9eed1a34731,546d0958d2037e73b28835b63e580809bef32baa..77bf655f55bfb2a4a60c320b39bb0e8433d39abb
@@@ -133,33 -133,77 +133,77 @@@ namespace Cro
                                break;
                        }
                }
-               public override Rectangle ContextCoordinates (Rectangle r)
+               protected override void onDraw (Context gr)
                {
-                       return
-                               Parent.ContextCoordinates(r) + Slot.Position + ClientRectangle.Position;
+                       base.onDraw (gr);
+                       gr.Save ();
+                       //clip to client zone
+                       CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
+                       gr.Clip ();
+                       if (child != null)
+                               child.Paint (ref gr);
+                       gr.Restore ();
                }
-               public override void Paint(ref Cairo.Context ctx, Rectangles clip = null)
+               protected override void UpdateCache (Context ctx)
                {
-                       if (!Visible)//check if necessary??
-                               return;
+                       //ctx.Save ();
  
-                       ctx.Save();
+                       Rectangle rb = Slot + Parent.ClientRectangle.Position;
  
-                       if (clip != null)
-                               clip.clip(ctx);
+                       using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) {
+                               Context gr = new Context (cache);
  
-                       base.Paint(ref ctx, clip);
++                              //clip to client zone
++                              CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
++                              gr.Clip ();
  
-                       //clip to client zone
-                       CairoHelpers.CairoRectangle (ctx, Parent.ContextCoordinates(ClientRectangle + Slot.Position), CornerRadius);
-                       ctx.Clip();
+                               if (Clipping.count > 0) {
+                                       Clipping.clearAndClip (gr);
+                                       if (child != null) {
+                                               
+                                               base.onDraw (gr);
  
-                       if (child != null)
-                               child.Paint(ref ctx, clip);
 -                                              //clip to client zone
 -                                              CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
 -                                              gr.Clip ();
  
-                       ctx.Restore();            
+                                               child.Paint (ref gr);
+                                       }
+                               }
+                                       
+                               gr.Dispose ();
+                               ctx.SetSourceSurface (cache, rb.X, rb.Y);
+                               ctx.Paint ();
+                       }
+                       Clipping.Reset();
+                       //ctx.Restore ();
                }
+ //            public override Rectangle ContextCoordinates (Rectangle r)
+ //            {
+ //                    return
+ //                            Parent.ContextCoordinates(r) + Slot.Position + ClientRectangle.Position;
+ //            }
+ //            public override void Paint(ref Cairo.Context ctx)
+ //            {
+ //                    if (!Visible)//check if necessary??
+ //                            return;
+ //
+ //                    ctx.Save();
+ //
+ //                    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);
+ //
+ //                    ctx.Restore();            
+ //            }
  
                #endregion