aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-02-08 17:22:23 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-02-08 17:22:23 +0100
commita5eec67305d20d7112743f649e2a327ba717ceec (patch)
tree6f2c6402e64e0d9d5cae161a5ac08b63be56ad9f /src/GraphicObjects
parentd810ad18dc2a1908211b6967d666c915140f24c9 (diff)
MaxLayoutingTries; CachingEnabled in GraphicObject + MaxCacheSize
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/GraphicObject.cs57
-rw-r--r--src/GraphicObjects/ILayoutable.cs1
2 files changed, 44 insertions, 14 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 43b9a725..27f1fe5d 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -29,6 +29,7 @@ namespace Crow
#endif
internal List<Binding> Bindings = new List<Binding> ();
+ internal int layoutingTries = 0;
#region IValueChange implementation
public event EventHandler<ValueChangeEventArgs> ValueChanged;
@@ -80,6 +81,7 @@ namespace Crow
HorizontalAlignment _horizontalAlignment = HorizontalAlignment.Center;
Size _maximumSize = "0;0";
Size _minimumSize = "0;0";
+ bool cacheEnabled = false;
#endregion
#region public fields
@@ -178,6 +180,16 @@ namespace Crow
#endregion
#region public properties
+ [XmlAttributeAttribute()][DefaultValue(true)]
+ public virtual bool CacheEnabled {
+ get { return cacheEnabled; }
+ set {
+ if (cacheEnabled == value)
+ return;
+ cacheEnabled = value;
+ NotifyValueChanged ("CacheEnabled", cacheEnabled);
+ }
+ }
[XmlAttributeAttribute()][DefaultValue("unamed")]
public virtual string Name {
get { return _name; }
@@ -499,6 +511,11 @@ namespace Crow
}
#region Layouting
+ public int LayoutingTries {
+ get { return layoutingTries; }
+ set { layoutingTries = value; }
+ }
+
/// <summary> return size of content + margins </summary>
protected virtual Size measureRawSize () {
return Bounds.Size;
@@ -740,25 +757,37 @@ namespace Crow
if (!Visible)
return;
- if (bmp == null)
- UpdateGraphic ();
+ Rectangle rb = Parent.ContextCoordinates (Slot);
+
+ if (cacheEnabled) {
+ if (Slot.Width > Interface.MaxCacheSize || Slot.Height > Interface.MaxCacheSize)
+ cacheEnabled = false;
+ }
- Rectangle rb = Parent.ContextCoordinates(Slot);
+ 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 ();
+ 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 ();
}
- ctx.SetSourceSurface (source, rb.X, rb.Y);
- ctx.Paint ();
+ return;
}
+ ctx.Save ();
+ ctx.Translate (rb.X, rb.Y);
+ onDraw (ctx);
+ ctx.Restore ();
}
#endregion
diff --git a/src/GraphicObjects/ILayoutable.cs b/src/GraphicObjects/ILayoutable.cs
index b9a97b0e..edddedd7 100644
--- a/src/GraphicObjects/ILayoutable.cs
+++ b/src/GraphicObjects/ILayoutable.cs
@@ -5,6 +5,7 @@ namespace Crow
{
public interface ILayoutable
{
+ int LayoutingTries { get; set; }
ILayoutable Parent { get; set; }
Rectangle ClientRectangle { get; }