From: jpbruyere Date: Fri, 12 Feb 2016 16:47:36 +0000 (+0100) Subject: Merge branch 'NewClipping' X-Git-Tag: 0.3~6 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=970a3f7239d5e57eb011295cda9eee015bbe97f4;p=jp%2Fcrow.git Merge branch 'NewClipping' --- 970a3f7239d5e57eb011295cda9eee015bbe97f4 diff --cc Tests/Interfaces/clip4.crow index 00000000,6d85a7e1..69fc7f12 mode 000000,100755..100755 --- a/Tests/Interfaces/clip4.crow +++ b/Tests/Interfaces/clip4.crow @@@ -1,0 -1,58 +1,58 @@@ +  - - - ++ ++ ++ + + + + diff --cc src/GraphicObjects/PrivateContainer.cs index 9f787eac,546d0958..77bf655f --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@@ -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