int frameCpt = 0;
int idx = 0;
string[] testFiles = {
- "clip1.crow",
"clip0.crow",
+ "clip1.crow",
"0.crow",
"5.crow",
"testCombobox.goml",
<?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="true"
+ <Container Fit="true" Margin="20" Background="Red" CacheEnabled="false"
HorizontalAlignment="Right" VerticalAlignment="Bottom"
MouseEnter="{Background=White}"
MouseLeave="{Background=Red}">
- <Container Fit="true" Margin="20" Background="Yellow" CacheEnabled="true"
+ <Container Fit="true" Margin="20" Background="Yellow" CacheEnabled="false"
HorizontalAlignment="Right" VerticalAlignment="Bottom"
MouseEnter="{Background=Blue}"
MouseLeave="{Background=Yellow}">
- <Container Margin="50" Background="LimeGreen" CacheEnabled="false"
+ <Container Width="200" Height="200" Margin="0" Background="LimeGreen" CacheEnabled="false"
HorizontalAlignment="Right" VerticalAlignment="Bottom"
MouseEnter="{Background=Gray}"
MouseLeave="{Background=LimeGreen}">
- <Label HorizontalAlignment="Center" VerticalAlignment="Center" CacheEnabled="true"
+ <Label Left="30" HorizontalAlignment="Center" VerticalAlignment="Center" CacheEnabled="false"
MouseEnter="{Background=DimGray}"
MouseLeave="{Background=BlueCrayola}"
Margin="1" Text="{drawing}" Background="BlueCrayola"/>
get { return Parent == null ? null : Parent.HostContainer; }
}
public virtual Rectangle ContextCoordinates(Rectangle r){
- return
+ GraphicObject go = Parent as GraphicObject;
+ if (go == null)
+ return r + Parent.ClientRectangle.Position;
+ return go.CacheEnabled ?
+ r + Parent.ClientRectangle.Position :
Parent.ContextCoordinates (r);
}
public virtual Rectangle ScreenCoordinates (Rectangle r){
}
/// <summary>
- /// Interfal drawing context creation on a cached surface limited to slot size
+ /// Internal drawing context creation on a cached surface limited to slot size
/// this trigger the effective drawing routine </summary>
- protected virtual void UpdateGraphic ()
+ protected virtual void RecreateCache ()
{
int stride = 4 * Slot.Width;
draw.Flush ();
}
}
+ protected virtual void UpdateCache(Context ctx){
+ Rectangle rb = Slot + Parent.ClientRectangle.Position;
+ using (ImageSurface cache = 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 ();
+ // }
+ // }
+ ctx.SetSourceSurface (cache, rb.X, rb.Y);
+ ctx.Paint ();
+ }
+ }
/// <summary> Chained painting routine on the parent context of the actual cached version
/// of the widget </summary>
public virtual void Paint (ref Context ctx)
LastPaintedSlot = Slot;
- Rectangle rb = Parent.ContextCoordinates (Slot);
-
if (cacheEnabled) {
if (Slot.Width > Interface.MaxCacheSize || Slot.Height > Interface.MaxCacheSize)
cacheEnabled = false;
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 ();
-// }
-// }
- ctx.SetSourceSurface (source, rb.X, rb.Y);
- ctx.Paint ();
- }
- return;
- }
- ctx.Save ();
+ RecreateCache ();
- Clipping.clearAndClip (ctx);
- ctx.Translate (rb.X, rb.Y);
- onDraw (ctx);
- ctx.Restore ();
+ UpdateCache (ctx);
+ } else {
+ Rectangle rb = Slot + Parent.ClientRectangle.Position;
+ ctx.Save ();
+
+ Clipping.clearAndClip (ctx);
+ ctx.Translate (rb.X, rb.Y);
+
+ onDraw (ctx);
+
+ ctx.Restore ();
+ }
}
#endregion
break;
}
}
-
- public override Rectangle ContextCoordinates (Rectangle r)
+ protected override void onDraw (Context gr)
{
- return
- Parent.ContextCoordinates(r) + Slot.Position + ClientRectangle.Position;
+ base.onDraw (gr);
+ if (child != null)
+ child.Paint (ref gr);
}
- public override void Paint(ref Cairo.Context ctx)
+ protected override void UpdateCache (Context ctx)
{
- if (!Visible)//check if necessary??
- return;
-
- ctx.Save();
+ Rectangle rb = Slot + Parent.ClientRectangle.Position;
- base.Paint(ref ctx);
+ using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) {
+ Context gr = new Context (cache);
- //clip to client zone
- CairoHelpers.CairoRectangle (ctx, Parent.ContextCoordinates(ClientRectangle + Slot.Position), CornerRadius);
- ctx.Clip();
+ child.Clipping.clearAndClip (gr);
+ base.onDraw (gr);
- if (child != null)
- child.Paint(ref ctx);
+ if (Clipping.count > 0) {
+ if (child != null) {
+ child.Paint (ref gr);
+ }
+ }
+
+ gr.Dispose ();
- ctx.Restore();
+ ctx.SetSourceSurface (cache, rb.X, rb.Y);
+ ctx.Paint ();
+ }
}
+// 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