From e2d351c9de4ee9c8b04376228f3ab5b9310392c9 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Thu, 4 Aug 2016 15:45:02 +0200 Subject: [PATCH] Set regLayout.ALL to new object to prevent queuing in layout or drawing, set to regLayout.None just before adding parent LayoutingTries moved into LQI --- src/GraphicObjects/GraphicObject.cs | 15 +++++---------- src/GraphicObjects/Group.cs | 1 + src/GraphicObjects/ILayoutable.cs | 2 -- src/GraphicObjects/PrivateContainer.cs | 1 + src/Interface.cs | 5 +++++ src/LayoutingQueueItem.cs | 13 +++++++------ 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 3bdc354d..20173172 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -25,9 +25,6 @@ namespace Crow internal static ulong currentUid = 0; internal ulong uid = 0; - - internal int layoutingTries = 0; - Rectangles clipping = new Rectangles(); public Rectangles Clipping { get { return clipping; }} @@ -62,7 +59,7 @@ namespace Crow #endregion #region private fields - LayoutingType registeredLayoutings = LayoutingType.None; + LayoutingType registeredLayoutings = LayoutingType.All; ILayoutable logicalParent; ILayoutable _parent; string _name = "unamed"; @@ -742,20 +739,18 @@ namespace Crow bmp = null; if (Width == Measure.Fit || Height == Measure.Fit) RegisterForLayouting (LayoutingType.Sizing); - Interface.CurrentInterface.EnqueueForRepaint (this); + else if (RegisteredLayoutings == LayoutingType.None) + Interface.CurrentInterface.EnqueueForRepaint (this); } /// query an update of the content, a redraw [MethodImpl(MethodImplOptions.AggressiveInlining)] public void RegisterForRedraw () { bmp = null; - Interface.CurrentInterface.EnqueueForRepaint (this); + if (RegisteredLayoutings == LayoutingType.None) + Interface.CurrentInterface.EnqueueForRepaint (this); } #region Layouting - [XmlIgnore]public int LayoutingTries { - get { return layoutingTries; } - set { layoutingTries = value; } - } internal Size contentSize; /// return size of content + margins protected virtual int measureRawSize (LayoutingType lt) { diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 3323a9b4..4d851b1a 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -46,6 +46,7 @@ namespace Crow Children.Add(g); g.Parent = this as GraphicObject; g.ResolveBindings (); + g.RegisteredLayoutings = LayoutingType.None; g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren); g.LayoutChanged += OnChildLayoutChanges; return (T)child; diff --git a/src/GraphicObjects/ILayoutable.cs b/src/GraphicObjects/ILayoutable.cs index b48e815a..33153935 100644 --- a/src/GraphicObjects/ILayoutable.cs +++ b/src/GraphicObjects/ILayoutable.cs @@ -5,8 +5,6 @@ namespace Crow { public interface ILayoutable { - /// Unsuccessfull UpdateLayout and requeueing count - int LayoutingTries { get; set; } /// Parent in the graphic tree ILayoutable Parent { get; set; } /// The logical parent (used mainly for bindings) as opposed diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index 14c2a680..93bae7fa 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -63,6 +63,7 @@ namespace Crow child.Parent = this; child.LayoutChanged += OnChildLayoutChanges; contentSize = child.Slot.Size; + child.RegisteredLayoutings = LayoutingType.None; child.RegisterForLayouting (LayoutingType.Sizing); } diff --git a/src/Interface.cs b/src/Interface.cs index 3cfed981..6d532164 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -89,10 +89,13 @@ namespace Crow internal bool XmlLoading = false; public Queue LayoutingQueue = new Queue (); + public Queue ProcessedLayoutingQueue; public Queue DrawingQueue = new Queue(); public string Clipboard;//TODO:use object instead for complex copy paste public void EnqueueForRepaint(GraphicObject g) { +// if (g.RegisteredLayoutings != LayoutingType.None) +// return; lock (DrawingQueue) { if (g.IsQueueForRedraw) return; @@ -405,6 +408,7 @@ namespace Crow lqi.ProcessLayouting (); } } + #if MEASURE_TIME layoutTime.Stop (); #endif @@ -499,6 +503,7 @@ namespace Crow { g.Parent = this; GraphicTree.Insert (0, g); + g.RegisteredLayoutings = LayoutingType.None; g.RegisterForLayouting (LayoutingType.Sizing); } public void DeleteWidget(GraphicObject g) diff --git a/src/LayoutingQueueItem.cs b/src/LayoutingQueueItem.cs index 82673444..8ffb7dbf 100644 --- a/src/LayoutingQueueItem.cs +++ b/src/LayoutingQueueItem.cs @@ -45,6 +45,8 @@ namespace Crow public ILayoutable GraphicObject; /// Bitfield containing the element of the layout to performs (x|y|width|height) public LayoutingType LayoutType; + /// Unsuccessfull UpdateLayout and requeueing count + public int LayoutingTries; #region CTOR public LayoutingQueueItem (LayoutingType _layoutType, ILayoutable _graphicObject) @@ -58,7 +60,7 @@ namespace Crow public void ProcessLayouting() { - if (GraphicObject.Parent == null) { + if (GraphicObject.Parent == null) {//TODO:improve this //cancel layouting for object without parent, maybe some were in queue when //removed from a listbox Debug.WriteLine ("ERROR: processLayouting, no parent for: " + this.ToString ()); @@ -71,14 +73,13 @@ namespace Crow #if DEBUG_LAYOUTING Debug.WriteLine ("\tRequeuing => " + this.ToString ()); #endif - GraphicObject.LayoutingTries ++; - if (GraphicObject.LayoutingTries < Interface.MaxLayoutingTries) { + LayoutingTries ++; + if (LayoutingTries < Interface.MaxLayoutingTries) { GraphicObject.RegisteredLayoutings |= LayoutType; Interface.CurrentInterface.LayoutingQueue.Enqueue (this); } - } else { - GraphicObject.LayoutingTries = 0; - } + } else + LayoutingTries = 0; } public static implicit operator GraphicObject(LayoutingQueueItem queueItem) -- 2.47.3