diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-03-05 20:41:26 +0100 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-03-05 20:41:26 +0100 |
| commit | 63e3afd99db6ec60e28c12c49c8d0ae9b5d7bd7b (patch) | |
| tree | 8fe8d583cc08b795304d8e918f04611747c8885e /src/GraphicObjects | |
| parent | 3d9e22120b40a0a4eb470bc6ceb3de8879f74c8d (diff) | |
remove double buffered LayoutingQueue,use dirtyBmp for gl rendering
Diffstat (limited to 'src/GraphicObjects')
| -rw-r--r-- | src/GraphicObjects/GenericStack.cs | 24 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 90 | ||||
| -rw-r--r-- | src/GraphicObjects/Grid.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/Group.cs | 16 | ||||
| -rw-r--r-- | src/GraphicObjects/ILayoutable.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/PrivateContainer.cs | 12 | ||||
| -rw-r--r-- | src/GraphicObjects/TabView.cs | 8 |
7 files changed, 77 insertions, 81 deletions
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index 897343b3..6dec8453 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -62,7 +62,7 @@ namespace Crow foreach (GraphicObject c in Children) { if (!c.Visible) continue; - if (c.QueuedLayoutings.HasFlag (LayoutingType.Width)) + if (c.RegisteredLayoutings.HasFlag (LayoutingType.Width)) return -1; tmp += c.Slot.Width + Spacing; } @@ -77,7 +77,7 @@ namespace Crow foreach (GraphicObject c in Children) { if (!c.Visible) continue; - if (c.QueuedLayoutings.HasFlag (LayoutingType.Height)) + if (c.RegisteredLayoutings.HasFlag (LayoutingType.Height)) return -1; tmp += c.Slot.Height + Spacing; } @@ -99,7 +99,7 @@ namespace Crow continue; c.Slot.X = d; d += c.Slot.Width + Spacing; - c.EnqueueForLayouting (LayoutingType.Y); + c.RegisterForLayouting (LayoutingType.Y); } } else { foreach (GraphicObject c in Children) { @@ -107,7 +107,7 @@ namespace Crow continue; c.Slot.Y = d; d += c.Slot.Height + Spacing; - c.EnqueueForLayouting (LayoutingType.X); + c.RegisterForLayouting (LayoutingType.X); } } bmp = null; @@ -115,7 +115,7 @@ namespace Crow public override bool UpdateLayout (LayoutingType layoutType) { - QueuedLayoutings &= (~layoutType); + RegisteredLayoutings &= (~layoutType); if (layoutType == LayoutingType.ArrangeChildren) { //allow 1 child to have size to 0 if stack has fixed or streched size policy, @@ -130,7 +130,7 @@ namespace Crow if (!Children [i].Visible) continue; //requeue Positionning if child is not layouted - if (Children [i].QueuedLayoutings.HasFlag (LayoutingType.Width)) + if (Children [i].RegisteredLayoutings.HasFlag (LayoutingType.Width)) return false; cptChildren++; if (Children [i].Width == 0) { @@ -169,7 +169,7 @@ namespace Crow for (int i = 0; i < Children.Count; i++) { if (!Children [i].Visible) continue; - if (Children [i].QueuedLayoutings.HasFlag (LayoutingType.Height)) + if (Children [i].RegisteredLayoutings.HasFlag (LayoutingType.Height)) return false; cptChildren++; if (Children [i].Height == 0) { @@ -205,7 +205,7 @@ namespace Crow ComputeChildrenPositions (); //if no layouting remains in queue for item, registre for redraw - if (QueuedLayoutings == LayoutingType.None && bmp==null) + if (RegisteredLayoutings == LayoutingType.None && bmp==null) this.AddToRedrawList (); return true; @@ -223,15 +223,15 @@ namespace Crow case LayoutingType.Width: if (Orientation == Orientation.Horizontal) { if (this.Bounds.Width < 0) - this.EnqueueForLayouting (LayoutingType.Width); - this.EnqueueForLayouting (LayoutingType.ArrangeChildren); + this.RegisterForLayouting (LayoutingType.Width); + this.RegisterForLayouting (LayoutingType.ArrangeChildren); } break; case LayoutingType.Height: if (Orientation == Orientation.Vertical) { if (this.Bounds.Height < 0) - this.EnqueueForLayouting (LayoutingType.Height); - this.EnqueueForLayouting (LayoutingType.ArrangeChildren); + this.RegisterForLayouting (LayoutingType.Height); + this.RegisterForLayouting (LayoutingType.ArrangeChildren); } break; } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 1909b07d..dd83c948 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -57,7 +57,7 @@ namespace Crow #endregion #region private fields - LayoutingType queuedLayoutings = LayoutingType.None; + LayoutingType registeredLayoutings = LayoutingType.None; ILayoutable logicalParent; ILayoutable _parent; string _name = "unamed"; @@ -101,13 +101,12 @@ namespace Crow /// IDEA is to add a ScreenCoordinates function that use only lastPaintedSlots /// </summary> public Rectangle LastPaintedSlot; - public LayoutingType RegisteredLayoutings = LayoutingType.None; public object Tag; public byte[] bmp; #endregion #region ILayoutable - [XmlIgnore]public LayoutingType QueuedLayoutings { get { return queuedLayoutings; } set { queuedLayoutings = value; } } + [XmlIgnore]public LayoutingType RegisteredLayoutings { get { return registeredLayoutings; } set { registeredLayoutings = value; } } //TODO: it would save the recurent cost of a cast in event bubbling if parent type was GraphicObject // or we could add to the interface the mouse events /// <summary> @@ -637,10 +636,6 @@ namespace Crow { Interface.RegisterForGraphicUpdate (this); } - public void RegisterForLayouting(LayoutingType lt) - { - Interface.RegisterForLayouting (this, lt); - } internal bool IsInRedrawList = false; /// <summary> /// Add clipping region in redraw list of interface, dont update cached object content @@ -664,43 +659,44 @@ namespace Crow } public virtual bool ArrangeChildren { get { return false; } } - public virtual void EnqueueForLayouting(LayoutingType layoutType){ + public virtual void RegisterForLayouting(LayoutingType layoutType){ if (Parent == null) return; - //dont set position for stretched item - if (Width == 0) - layoutType &= (~LayoutingType.X); - if (Height == 0) - layoutType &= (~LayoutingType.Y); - - if (!ArrangeChildren) - layoutType &= (~LayoutingType.ArrangeChildren); + lock (Interface.CurrentInterface.LayoutingQueue) { + //dont set position for stretched item + if (Width == 0) + layoutType &= (~LayoutingType.X); + if (Height == 0) + layoutType &= (~LayoutingType.Y); - //apply constraints depending on parent type - if (Parent is GraphicObject) - (Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType); + if (!ArrangeChildren) + layoutType &= (~LayoutingType.ArrangeChildren); - //prevent queueing same LayoutingType for this - layoutType &= (~QueuedLayoutings); + //apply constraints depending on parent type + if (Parent is GraphicObject) + (Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType); - if (layoutType == LayoutingType.None) - return; + //prevent queueing same LayoutingType for this + layoutType &= (~RegisteredLayoutings); - #if DEBUG_LAYOUTING - Debug.WriteLine ("REGLayout => {1}->{0}", layoutType, this.ToString()); - #endif + if (layoutType == LayoutingType.None) + return; - //enqueue LQI LayoutingTypes separately - if (layoutType.HasFlag (LayoutingType.Width)) - Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this)); - if (layoutType.HasFlag (LayoutingType.Height)) - Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this)); - if (layoutType.HasFlag (LayoutingType.X)) - Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this)); - if (layoutType.HasFlag (LayoutingType.Y)) - Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this)); - if (layoutType.HasFlag (LayoutingType.ArrangeChildren)) - Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this)); + #if DEBUG_LAYOUTING + Debug.WriteLine ("REGLayout => {1}->{0}", layoutType, this.ToString()); + #endif + //enqueue LQI LayoutingTypes separately + if (layoutType.HasFlag (LayoutingType.Width)) + Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this)); + if (layoutType.HasFlag (LayoutingType.Height)) + Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this)); + if (layoutType.HasFlag (LayoutingType.X)) + Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this)); + if (layoutType.HasFlag (LayoutingType.Y)) + Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this)); + if (layoutType.HasFlag (LayoutingType.ArrangeChildren)) + Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this)); + } } /// <summary> trigger dependant sizing component update </summary> @@ -712,10 +708,10 @@ namespace Crow switch (layoutType) { case LayoutingType.Width: - EnqueueForLayouting (LayoutingType.X); + RegisterForLayouting (LayoutingType.X); break; case LayoutingType.Height: - EnqueueForLayouting (LayoutingType.Y); + RegisterForLayouting (LayoutingType.Y); break; } LayoutChanged.Raise (this, new LayoutingEventArgs (layoutType)); @@ -728,14 +724,14 @@ namespace Crow public virtual bool UpdateLayout (LayoutingType layoutType) { //unset bit, it would be reset if LQI is re-queued - queuedLayoutings &= (~layoutType); + registeredLayoutings &= (~layoutType); switch (layoutType) { case LayoutingType.X: if (Bounds.X == 0) { - if (Parent.QueuedLayoutings.HasFlag (LayoutingType.Width) || - QueuedLayoutings.HasFlag (LayoutingType.Width)) + if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width) || + RegisteredLayoutings.HasFlag (LayoutingType.Width)) return false; switch (HorizontalAlignment) { @@ -764,8 +760,8 @@ namespace Crow case LayoutingType.Y: if (Bounds.Y == 0) { - if (Parent.QueuedLayoutings.HasFlag (LayoutingType.Height) || - QueuedLayoutings.HasFlag (LayoutingType.Height)) + if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height) || + RegisteredLayoutings.HasFlag (LayoutingType.Height)) return false; switch (VerticalAlignment) { @@ -796,7 +792,7 @@ namespace Crow Slot.Width = Width; else if (Width < 0) { Slot.Width = measureRawSize (LayoutingType.Width); - }else if (Parent.QueuedLayoutings.HasFlag (LayoutingType.Width)) + }else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width)) return false; else Slot.Width = Parent.ClientRectangle.Width; @@ -821,7 +817,7 @@ namespace Crow Slot.Height = Height; else if (Height < 0){ Slot.Height = measureRawSize (LayoutingType.Height); - }else if (Parent.QueuedLayoutings.HasFlag (LayoutingType.Height)) + }else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height)) return false; else Slot.Height = Parent.ClientRectangle.Height; @@ -844,7 +840,7 @@ namespace Crow } //if no layouting remains in queue for item, registre for redraw - if (this.queuedLayoutings == LayoutingType.None && bmp == null) + if (this.registeredLayoutings == LayoutingType.None && bmp == null) this.AddToRedrawList (); return true; diff --git a/src/GraphicObjects/Grid.cs b/src/GraphicObjects/Grid.cs index e13690a7..a16deb8c 100644 --- a/src/GraphicObjects/Grid.cs +++ b/src/GraphicObjects/Grid.cs @@ -128,14 +128,14 @@ namespace Crow public override bool UpdateLayout (LayoutingType layoutType) { - QueuedLayoutings &= (~layoutType); + RegisteredLayoutings &= (~layoutType); if (layoutType == LayoutingType.ArrangeChildren) { ComputeChildrenPositions (); //if no layouting remains in queue for item, registre for redraw - if (QueuedLayoutings == LayoutingType.None && bmp==null) + if (RegisteredLayoutings == LayoutingType.None && bmp==null) this.AddToRedrawList (); return true; diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 3b2c1380..869ec113 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -162,14 +162,14 @@ namespace Crow foreach (GraphicObject c in Children) { if (!c.Visible) continue; - c.EnqueueForLayouting (LayoutingType.X | LayoutingType.Width); + c.RegisterForLayouting (LayoutingType.X | LayoutingType.Width); } break; case LayoutingType.Height: foreach (GraphicObject c in Children) { if (!c.Visible) continue; - c.EnqueueForLayouting (LayoutingType.Y | LayoutingType.Height); } + c.RegisterForLayouting (LayoutingType.Y | LayoutingType.Height); } break; } } @@ -182,14 +182,14 @@ namespace Crow maxChildrenWidth = g.Slot.Width; largestChild = g; if (this.Bounds.Width < 0) - this.EnqueueForLayouting (LayoutingType.Width); + this.RegisterForLayouting (LayoutingType.Width); } else if (g == largestChild) { largestChild = null; maxChildrenWidth = 0; if (this.Bounds.Width < 0) - this.EnqueueForLayouting (LayoutingType.Width); + this.RegisterForLayouting (LayoutingType.Width); } break; case LayoutingType.Height: @@ -197,14 +197,14 @@ namespace Crow maxChildrenHeight = g.Slot.Height; tallestChild = g; if (this.Bounds.Height < 0) - this.EnqueueForLayouting (LayoutingType.Height); + this.RegisterForLayouting (LayoutingType.Height); } else if (g == tallestChild) { tallestChild = null; maxChildrenHeight = 0; if (this.Bounds.Height < 0) - this.EnqueueForLayouting (LayoutingType.Height); + this.RegisterForLayouting (LayoutingType.Height); } break; } @@ -226,7 +226,7 @@ namespace Crow for (int i = 0; i < Children.Count; i++) { if (!Children [i].Visible) continue; - if (children [i].QueuedLayoutings.HasFlag (LayoutingType.Width)) + if (children [i].RegisteredLayoutings.HasFlag (LayoutingType.Width)) continue; if (Children [i].Slot.Width > maxChildrenWidth) { maxChildrenWidth = Children [i].Slot.Width; @@ -243,7 +243,7 @@ namespace Crow for (int i = 0; i < Children.Count; i++) { if (!Children [i].Visible) continue; - if (children [i].QueuedLayoutings.HasFlag (LayoutingType.Height)) + if (children [i].RegisteredLayoutings.HasFlag (LayoutingType.Height)) continue; if (Children [i].Slot.Height > maxChildrenHeight) { maxChildrenHeight = Children [i].Slot.Height; diff --git a/src/GraphicObjects/ILayoutable.cs b/src/GraphicObjects/ILayoutable.cs index 77f9409b..a8df3ae0 100644 --- a/src/GraphicObjects/ILayoutable.cs +++ b/src/GraphicObjects/ILayoutable.cs @@ -18,8 +18,8 @@ namespace Crow Rectangle getBounds(); bool ArrangeChildren { get; } - LayoutingType QueuedLayoutings { get; set; } - void EnqueueForLayouting(LayoutingType layoutType); + 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 1aa39633..3a3d9067 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -95,10 +95,10 @@ namespace Crow if (child == null) return base.measureRawSize (lt); if (lt == LayoutingType.Width) - return child.QueuedLayoutings.HasFlag(LayoutingType.Width) ? + return child.RegisteredLayoutings.HasFlag(LayoutingType.Width) ? -1 : child.Slot.Size.Width + 2 * Margin; else - return child.QueuedLayoutings.HasFlag(LayoutingType.Height) ? + return child.RegisteredLayoutings.HasFlag(LayoutingType.Height) ? -1 : child.Slot.Size.Height + 2 * Margin; } public override bool UpdateLayout (LayoutingType layoutType) @@ -127,13 +127,13 @@ namespace Crow case LayoutingType.Width: if (child != null) { if (child.Visible) - child.EnqueueForLayouting (LayoutingType.X | LayoutingType.Width); + child.RegisterForLayouting (LayoutingType.X | LayoutingType.Width); } break; case LayoutingType.Height: if (child != null) { if (child.Visible) - child.EnqueueForLayouting (LayoutingType.Y | LayoutingType.Height); + child.RegisterForLayouting (LayoutingType.Y | LayoutingType.Height); } break; } @@ -148,11 +148,11 @@ namespace Crow break; case LayoutingType.Width: if (this.Bounds.Width < 0) - this.EnqueueForLayouting (LayoutingType.Width); + this.RegisterForLayouting (LayoutingType.Width); break; case LayoutingType.Height: if (this.Bounds.Height < 0) - this.EnqueueForLayouting (LayoutingType.Height); + this.RegisterForLayouting (LayoutingType.Height); break; } } diff --git a/src/GraphicObjects/TabView.cs b/src/GraphicObjects/TabView.cs index 7ae5e3d3..2700043a 100644 --- a/src/GraphicObjects/TabView.cs +++ b/src/GraphicObjects/TabView.cs @@ -126,7 +126,7 @@ namespace Crow public override bool ArrangeChildren { get { return true; } } public override bool UpdateLayout (LayoutingType layoutType) { - QueuedLayoutings &= (~layoutType); + RegisteredLayoutings &= (~layoutType); if (layoutType == LayoutingType.ArrangeChildren) { int curOffset = Spacing; @@ -136,18 +136,18 @@ namespace Crow TabItem ti = Children [i] as TabItem; ti.TabOffset = curOffset; if (Orientation == Orientation.Horizontal) { - if (ti.TabTitle.QueuedLayoutings.HasFlag (LayoutingType.Width)) + if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Width)) return false; curOffset += ti.TabTitle.Slot.Width + Spacing; } else { - if (ti.TabTitle.QueuedLayoutings.HasFlag (LayoutingType.Height)) + if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Height)) return false; curOffset += ti.TabTitle.Slot.Height + Spacing; } } //if no layouting remains in queue for item, registre for redraw - if (QueuedLayoutings == LayoutingType.None && bmp==null) + if (RegisteredLayoutings == LayoutingType.None && bmp==null) this.AddToRedrawList (); return true; |