diff options
Diffstat (limited to 'src/GraphicObjects')
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 68 | ||||
| -rw-r--r-- | src/GraphicObjects/Group.cs | 65 | ||||
| -rw-r--r-- | src/GraphicObjects/ILayoutable.cs | 1 | ||||
| -rw-r--r-- | src/GraphicObjects/PrivateContainer.cs | 9 | ||||
| -rw-r--r-- | src/GraphicObjects/Scroller.cs | 8 | ||||
| -rw-r--r-- | src/GraphicObjects/Window.cs | 2 |
6 files changed, 69 insertions, 84 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 14516dba..699d39a9 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -31,6 +31,9 @@ namespace Crow internal List<Binding> Bindings = new List<Binding> (); internal int layoutingTries = 0; + Rectangles _clipping = new Rectangles(); + public Rectangles Clipping { get { return _clipping; }} + #region IValueChange implementation public event EventHandler<ValueChangeEventArgs> ValueChanged; public virtual void NotifyValueChanged(string MemberName, object _value) @@ -121,15 +124,7 @@ namespace Crow [XmlIgnore]public ILayoutable Parent { get { return _parent; } set { -// if (_parent == value) -// return; -// if (_parent != null) -// ClearBinding (); -// _parent = value; -// -// if (DataSource != null) -// ResolveBindings (); } } @@ -150,20 +145,14 @@ namespace Crow } public virtual Rectangle ContextCoordinates(Rectangle r){ return - Parent.ContextCoordinates (r);// + ClientRectangle.Position; + Parent.ContextCoordinates (r); } public virtual Rectangle ScreenCoordinates (Rectangle r){ return Parent.ScreenCoordinates(r) + Parent.getSlot().Position + Parent.ClientRectangle.Position; } - public virtual Rectangle getSlot() - { - return Slot; - } - public virtual Rectangle getBounds() - { - return Bounds; - } + public virtual Rectangle getSlot() => Slot; + public virtual Rectangle getBounds() => Bounds; #endregion #region EVENT HANDLERS @@ -478,14 +467,22 @@ namespace Crow public virtual bool Contains(GraphicObject goToFind){ return false; } - - public virtual void registerClipRect() - { - HostContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot)); + public void RegisterClip(Rectangle clip){ + Rectangle r = Slot + Parent.ClientRectangle; + if (CacheEnabled && bmp != null) + Clipping.AddRectangle (r); + Parent.RegisterClip (r); + } +// public virtual void registerClipRect(Rectangle clip) +// { +// Rectangle tmp = ContextCoordinates (clip); +// if (CacheEnabled) { +// } + //HostContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot)); //this clipping should take only last painted slots on each level in ancestor tree which //is not the case for now. - HostContainer.redrawClip.AddRectangle (ScreenCoordinates(LastPaintedSlot)); - } + //HostContainer.redrawClip.AddRectangle (ScreenCoordinates(LastPaintedSlot)); + //} /// <summary> /// Clear chached object and add clipping region in redraw list of interface /// </summary> @@ -754,7 +751,7 @@ namespace Crow } /// <summary> Chained painting routine on the parent context of the actual cached version /// of the widget </summary> - public virtual void Paint (ref Context ctx, Rectangles clip = null) + public virtual void Paint (ref Context ctx) { if (!Visible) return; @@ -771,24 +768,25 @@ namespace Crow 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 (); - } - } +// //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 (); + + Clipping.clearAndClip (ctx); ctx.Translate (rb.X, rb.Y); onDraw (ctx); ctx.Restore (); diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 9d9abbc6..33fe006d 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -217,53 +217,42 @@ namespace Crow } } - public override void Paint(ref Context ctx, Rectangles clip = null) + public override void Paint(ref Context ctx) { if ( !Visible ) return; - if (bmp == null) - UpdateGraphic (); - else { - if (clip != null) - clip.Rebase (this); - else { - clip = new Rectangles (); - //TODO:added lately slot to empty clip, - //should rework this precise case causing expandable not - //to show image changes - clip.AddRectangle (ContextCoordinates (Slot.Size)); - } - - if (!DrawingIsValid || clip != null) {//false when 1 child has changed - //child having their content changed has to be repainted - //and those with slot intersecting clip rectangle have also to be repainted + if (CacheEnabled) { + if (bmp == null) + RecreateCache (); + } - using (ImageSurface cache = - new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, Slot.Width * 4)) { - Context gr = new Context (cache); - clip.clearAndClip (gr); + if (Clipping.count > 0) { + using (ImageSurface cache = + new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, Slot.Width * 4)) { + Context gr = new Context (cache); - Rectangle rBack = Slot.Size; - Background.SetAsSource (gr, rBack); - CairoHelpers.CairoRectangle(gr, rBack, CornerRadius); - gr.Fill (); + Clipping.clearAndClip (gr); + Rectangle rBack = Slot.Size; + Background.SetAsSource (gr, rBack); + CairoHelpers.CairoRectangle (gr, rBack, CornerRadius); + gr.Fill (); - #if DEBUG_CLIP_RECTANGLE - clip.stroke (gr, Color.Amaranth.AdjustAlpha (0.8)); - #endif - foreach (GraphicObject c in children.Where(ch=>ch.Visible)) { - Rectangles childClip = clip.intersectingRects (ContextCoordinates(c.Slot)); - if (!c.DrawingIsValid || childClip.count > 0) - c.Paint (ref gr, childClip);//, localClip); - } - - gr.Dispose (); + foreach (GraphicObject c in children) { + if (!c.Visible) + continue; + Rectangles childClip = Clipping.intersectingRects (ContextCoordinates (c.Slot)); + if (childClip.count > 0) + c.Paint (ref ctx); } + #if DEBUG_CLIP_RECTANGLE + Clipping.stroke (gr, Color.Amaranth.AdjustAlpha (0.8)); + #endif + + gr.Dispose (); } - } - - base.Paint (ref ctx, clip); + } + base.Paint (ref ctx); } #endregion diff --git a/src/GraphicObjects/ILayoutable.cs b/src/GraphicObjects/ILayoutable.cs index 54e54f03..bbf1b4a6 100644 --- a/src/GraphicObjects/ILayoutable.cs +++ b/src/GraphicObjects/ILayoutable.cs @@ -21,6 +21,7 @@ namespace Crow LayoutingType RegisteredLayoutings { get; set; } void RegisterForLayouting(LayoutingType layoutType); + void RegisterClip(Rectangle clip); bool UpdateLayout(LayoutingType layoutType); diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index 9f787eac..63f4f02a 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -139,24 +139,21 @@ namespace Crow return Parent.ContextCoordinates(r) + Slot.Position + ClientRectangle.Position; } - public override void Paint(ref Cairo.Context ctx, Rectangles clip = null) + public override void Paint(ref Cairo.Context ctx) { if (!Visible)//check if necessary?? return; ctx.Save(); - if (clip != null) - clip.clip(ctx); - - base.Paint(ref ctx, clip); + 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, clip); + child.Paint(ref ctx); ctx.Restore(); } diff --git a/src/GraphicObjects/Scroller.cs b/src/GraphicObjects/Scroller.cs index 3ac8d66c..599f951f 100644 --- a/src/GraphicObjects/Scroller.cs +++ b/src/GraphicObjects/Scroller.cs @@ -188,10 +188,10 @@ namespace Crow return base.ScreenCoordinates (r) - new Point((int)ScrollX,(int)ScrollY); } - public override void registerClipRect () - { - HostContainer.redrawClip.AddRectangle (base.ScreenCoordinates(Slot)); - } +// public override void registerClipRect () +// { +// HostContainer.redrawClip.AddRectangle (base.ScreenCoordinates(Slot)); +// } } diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs index d98d296c..726f858a 100644 --- a/src/GraphicObjects/Window.cs +++ b/src/GraphicObjects/Window.cs @@ -89,7 +89,7 @@ namespace Crow if (!HasFocus) return; - otkgw.redrawClip.AddRectangle (this.ScreenCoordinates(this.Slot)); + //otkgw.redrawClip.AddRectangle (this.ScreenCoordinates(this.Slot)); int currentLeft = this.Left; int currentTop = this.Top; |