</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug</OutputPath>
- <DefineConstants>DEBUG_LAYOUTING0;TRACE;DEBUG;__linux__;MEASURE_TIME;DEBUG_LOAD_TIME0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
+ <DefineConstants>DEBUG_LAYOUTING0;TRACE;DEBUG;__linux__;MEASURE_TIME;DEBUG_LOAD_TIME0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE</DefineConstants>
</PropertyGroup>
<!-- <PropertyGroup Condition=" '$(Platform)' == 'Linux_x86' ">
<DefineConstants>__linux__</DefineConstants>
int frameCpt = 0;
int idx = 0;
string[] testFiles = {
+ "clip1.crow",
+ "clip0.crow",
"0.crow",
"5.crow",
"testCombobox.goml",
--- /dev/null
+<?xml version="1.0"?>
+<Container Fit="true" Margin="50" Background="LimeGreen" CacheEnabled="false"
+ HorizontalAlignment="Right" VerticalAlignment="Bottom"
+ MouseEnter="{Background=Gray}"
+ MouseLeave="{Background=LimeGreen}">
+ <Label HorizontalAlignment="Center" VerticalAlignment="Center" CacheEnabled="false"
+ MouseEnter="{Background=DimGray}" Width="100"
+ MouseLeave="{Background=BlueCrayola}"
+ Margin="10" Text="{drawing}" Background="BlueCrayola"/>
+ </Container>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<Container Fit="true" Margin="20" Background="SkyBlue" CacheEnabled="true"
+ HorizontalAlignment="Right" VerticalAlignment="Bottom"
+ MouseEnter="{Background=LightGray}"
+ MouseLeave="{Background=SkyBlue}">
+ <Container Fit="true" Margin="20" Background="Red" CacheEnabled="true"
+ HorizontalAlignment="Right" VerticalAlignment="Bottom"
+ MouseEnter="{Background=White}"
+ MouseLeave="{Background=Red}">
+ <Container Fit="true" Margin="20" Background="Yellow" CacheEnabled="true"
+ HorizontalAlignment="Right" VerticalAlignment="Bottom"
+ MouseEnter="{Background=Blue}"
+ MouseLeave="{Background=Yellow}">
+ <Container Margin="50" Background="LimeGreen" CacheEnabled="false"
+ HorizontalAlignment="Right" VerticalAlignment="Bottom"
+ MouseEnter="{Background=Gray}"
+ MouseLeave="{Background=LimeGreen}">
+ <Label HorizontalAlignment="Center" VerticalAlignment="Center" CacheEnabled="true"
+ MouseEnter="{Background=DimGray}"
+ MouseLeave="{Background=BlueCrayola}"
+ Margin="1" Text="{drawing}" Background="BlueCrayola"/>
+ </Container>
+ </Container>
+ </Container>
+ </Container>
\ No newline at end of file
<None Include="Interfaces\testStacks.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="Interfaces\clip0.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\clip1.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
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)
[XmlIgnore]public ILayoutable Parent {
get { return _parent; }
set {
-// if (_parent == value)
-// return;
-// if (_parent != null)
-// ClearBinding ();
-//
_parent = value;
-//
-// if (DataSource != null)
-// ResolveBindings ();
}
}
}
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
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>
}
/// <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;
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 ();
}
}
- 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
LayoutingType RegisteredLayoutings { get; set; }
void RegisterForLayouting(LayoutingType layoutType);
+ void RegisterClip(Rectangle clip);
bool UpdateLayout(LayoutingType layoutType);
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();
}
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));
+// }
}
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;
{
GraphicObjects.Remove(g);
GraphicObjects.Insert(0, g);
- g.registerClipRect ();
+ //g.registerClipRect ();
}
}
public void Quit ()
gobjsToRedraw.Clear ();
foreach (GraphicObject p in gotr) {
p.IsQueuedForRedraw = false;
- p.registerClipRect ();
+ p.RegisterClip (p.LastPaintedSlot);
+ p.RegisterClip (p.getSlot());
}
#if MEASURE_TIME
updateTime.Stop ();
drawingTime.Start ();
#endif
-
+ Debug.WriteLine (redrawClip.ToString ());
lock (redrawClip) {
if (redrawClip.count > 0) {
#if DEBUG_CLIP_RECTANGLE
//Link.draw (ctx);
foreach (GraphicObject p in invGOList) {
- if (p.Visible) {
+ if (!p.Visible)
+ continue;
+
+ ctx.Save ();
+
+ Rectangles clip = redrawClip.intersectingRects (p.Slot);
- ctx.Save ();
- if (redrawClip.count > 0) {
- Rectangles clip = redrawClip.intersectingRects (p.Slot);
+ if (clip.count > 0)
+ p.Paint (ref ctx);
+
+ ctx.Restore ();
- if (clip.count > 0)
- p.Paint (ref ctx, clip);
- }
- ctx.Restore ();
- }
}
ctx.ResetClip ();
#if DEBUG_CLIP_RECTANGLE
#endregion
#region ILayoutable implementation
+ public void RegisterClip(Rectangle r){
+ redrawClip.AddRectangle (r);
+ }
public int LayoutingTries {
get { throw new NotImplementedException (); }
set { throw new NotImplementedException (); }
}
public void RegisterForLayouting (LayoutingType layoutType) { throw new NotImplementedException (); }
public bool UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); }
- public Rectangle ContextCoordinates (Rectangle r)
- {
- return r;
- }
+ public Rectangle ContextCoordinates (Rectangle r) => r;
public Rectangle ScreenCoordinates (Rectangle r) => r;
public ILayoutable Parent {
get { return null; }
set { throw new NotImplementedException (); }
}
-
public ILayoutable LogicalParent {
get { return null; }
set { throw new NotImplementedException (); }
public IGOLibHost HostContainer {
get { return this; }
}
-
- public Rectangle getSlot ()
- {
- return ClientRectangle;
- }
- public Rectangle getBounds ()//redundant but fill ILayoutable implementation
- {
- return ClientRectangle;
- }
+ public Rectangle getSlot () => ClientRectangle;
+ public Rectangle getBounds () => ClientRectangle;
#endregion
}
}
\ No newline at end of file
}
public void clearAndClip(Context ctx)
{
+ if (list.Count == 0)
+ return;
foreach (Rectangle r in list)
ctx.Rectangle(r);