diff options
Diffstat (limited to 'src/GraphicObjects')
| -rw-r--r-- | src/GraphicObjects/Border.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/GenericStack.cs | 10 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 136 | ||||
| -rw-r--r-- | src/GraphicObjects/Grid.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/Group.cs | 8 | ||||
| -rw-r--r-- | src/GraphicObjects/PrivateContainer.cs | 8 | ||||
| -rw-r--r-- | src/GraphicObjects/Shape.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/TabView.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/TemplatedGroup.cs | 17 | ||||
| -rw-r--r-- | src/GraphicObjects/TextRun.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/Wrapper.cs | 7 |
11 files changed, 110 insertions, 90 deletions
diff --git a/src/GraphicObjects/Border.cs b/src/GraphicObjects/Border.cs index adeb32e7..a02c6a3c 100644 --- a/src/GraphicObjects/Border.cs +++ b/src/GraphicObjects/Border.cs @@ -122,7 +122,7 @@ namespace Crow } } - protected override int measureRawSize (LayoutingType lt) + protected override int measureRawSize(LayoutingType lt) { int tmp = base.measureRawSize (lt); return tmp < 0 ? tmp : tmp + 2 * BorderWidth; diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index 64841d4b..7f452cb0 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -78,9 +78,11 @@ namespace Crow else layoutType &= (~LayoutingType.Y); } - protected override int measureRawSize (LayoutingType lt) + protected override int measureRawSize(LayoutingType lt) { + childrenRWLock.EnterReadLock (); int totSpace = Math.Max(0, Spacing * (Children.Count (c => c.Visible) - 1)); + childrenRWLock.ExitReadLock (); if (lt == LayoutingType.Width) { if (Orientation == Orientation.Horizontal) return contentSize.Width + totSpace + 2 * Margin; @@ -92,6 +94,7 @@ namespace Crow public virtual void ComputeChildrenPositions() { int d = 0; + childrenRWLock.EnterReadLock (); if (Orientation == Orientation.Horizontal) { foreach (GraphicObject c in Children) { if (!c.Visible) @@ -107,6 +110,7 @@ namespace Crow d += c.Slot.Height + Spacing; } } + childrenRWLock.ExitReadLock (); IsDirty = true; } GraphicObject stretchedGO = null; @@ -121,9 +125,7 @@ namespace Crow //in the direction of stacking. ComputeChildrenPositions (); - //if no layouting remains in queue for item, registre for redraw - if (RegisteredLayoutings == LayoutingType.None && IsDirty) - IFace.EnqueueForRepaint (this); + EnqueueForRepaint(); return true; } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index f404b5f1..6903b9f9 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -273,7 +273,8 @@ namespace Crow //initialized = true; } #region private fields - LayoutingType registeredLayoutings = LayoutingType.All; + public LayoutingType registeredLayoutings = LayoutingType.None; + public LayoutingType requestedLayoutings = LayoutingType.All; ILayoutable logicalParent; ILayoutable parent; string name; @@ -949,10 +950,10 @@ namespace Crow if (value != null) rootDataLevel = true; - lock (IFace.LayoutMutex) { + //lock (IFace.LayoutMutex) { OnDataSourceChanged (this, dse); NotifyValueChanged ("DataSource", DataSource); - } + //} } get { return rootDataLevel ? dataSource : dataSource == null ? @@ -961,20 +962,20 @@ namespace Crow dataSource; } } - /// <summary> - /// If true, rendering of GraphicObject is clipped inside client rectangle - /// </summary> - [DesignCategory ("Data")][DefaultValue(false)] - public virtual bool RootDataLevel { - get { return rootDataLevel; } - set { - if (rootDataLevel == value) - return; - rootDataLevel = value; - NotifyValueChanged ("RootDataLevel", rootDataLevel); - this.RegisterForRedraw (); - } - } +// /// <summary> +// /// If true, rendering of GraphicObject is clipped inside client rectangle +// /// </summary> +// [DesignCategory ("Data")][DefaultValue(false)] +// public virtual bool RootDataLevel { +// get { return rootDataLevel; } +// set { +// if (rootDataLevel == value) +// return; +// rootDataLevel = value; +// NotifyValueChanged ("RootDataLevel", rootDataLevel); +// this.RegisterForRedraw (); +// } +// } protected virtual void onLogicalParentDataSourceChanged(object sender, DataSourceChangeEventArgs e){ if (localDataSourceIsNull) OnDataSourceChanged (this, e); @@ -1370,19 +1371,24 @@ namespace Crow IsDirty = true; if (Width.IsFit || Height.IsFit) RegisterForLayouting (LayoutingType.Sizing); - else if (RegisteredLayoutings == LayoutingType.None) - IFace.EnqueueForRepaint (this); + else + EnqueueForRepaint (); } /// <summary> query an update of the content, a redraw </summary> - [MethodImpl(MethodImplOptions.AggressiveInlining)] public void RegisterForRedraw () { #if DEBUG_UPDATE Debug.WriteLine (string.Format("RegisterForRedraw (IsDirty set)-> {0}", this.ToString ())); #endif IsDirty = true; - if (RegisteredLayoutings == LayoutingType.None) - IFace.EnqueueForRepaint (this); + EnqueueForRepaint (); + } + protected void EnqueueForRepaint (){ + //if no layouting remains in queue for item, registre for redraw + if (requestedLayoutings != LayoutingType.None) + RegisterForLayouting (LayoutingType.None); + else if (RegisteredLayoutings == LayoutingType.None && IsDirty) + IFace.EnqueueForRepaint (this); } #endregion @@ -1398,47 +1404,57 @@ namespace Crow } public virtual bool ArrangeChildren { get { return false; } } public virtual void RegisterForLayouting(LayoutingType layoutType){ - if (Parent == null) + if (Parent == null || !Monitor.TryEnter(IFace.LayoutMutex)) { + requestedLayoutings |= layoutType; +// if (registeredLayoutings != LayoutingType.None) +// Debugger.Break (); return; - lock (IFace.LayoutMutex) { - //prevent queueing same LayoutingType for this - layoutType &= (~RegisteredLayoutings); + } + layoutType |= requestedLayoutings; + requestedLayoutings = LayoutingType.None; + layoutType &= (~RegisteredLayoutings);//prevent queueing same LayoutingType for this - if (layoutType == LayoutingType.None) - return; - //dont set position for stretched item - if (Width == Measure.Stretched) - layoutType &= (~LayoutingType.X); - if (Height == Measure.Stretched) - layoutType &= (~LayoutingType.Y); + if (layoutType == LayoutingType.None) { + Monitor.Exit (IFace.LayoutMutex); + return; + } + //dont set position for stretched item + if (Width == Measure.Stretched) + layoutType &= (~LayoutingType.X); + if (Height == Measure.Stretched) + layoutType &= (~LayoutingType.Y); - if (!ArrangeChildren) - layoutType &= (~LayoutingType.ArrangeChildren); + if (!ArrangeChildren) + layoutType &= (~LayoutingType.ArrangeChildren); - //apply constraints depending on parent type - if (Parent is GraphicObject) - (Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType); + //apply constraints depending on parent type + if (Parent is GraphicObject) + (Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType); // //prevent queueing same LayoutingType for this // layoutType &= (~RegisteredLayoutings); - if (layoutType == LayoutingType.None) - return; - - //enqueue LQI LayoutingTypes separately - if (layoutType.HasFlag (LayoutingType.Width)) - IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this)); - if (layoutType.HasFlag (LayoutingType.Height)) - IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this)); - if (layoutType.HasFlag (LayoutingType.X)) - IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this)); - if (layoutType.HasFlag (LayoutingType.Y)) - IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this)); - if (layoutType.HasFlag (LayoutingType.ArrangeChildren)) - IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this)); + if (layoutType == LayoutingType.None) { + Monitor.Exit (IFace.LayoutMutex); + return; } + + //enqueue LQI LayoutingTypes separately + if (layoutType.HasFlag (LayoutingType.Width)) + IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this)); + if (layoutType.HasFlag (LayoutingType.Height)) + IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this)); + if (layoutType.HasFlag (LayoutingType.X)) + IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this)); + if (layoutType.HasFlag (LayoutingType.Y)) + IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this)); + if (layoutType.HasFlag (LayoutingType.ArrangeChildren)) + IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this)); + + Monitor.Exit (IFace.LayoutMutex); } + /// <summary> trigger dependant sizing component update </summary> public virtual void OnLayoutChanges(LayoutingType layoutType) { @@ -1608,15 +1624,16 @@ namespace Crow IsDirty = true; +// if (Name == "colIco" && Slot.Height < 5) +// Debugger.Break (); + OnLayoutChanges (layoutType); LastSlots.Height = Slot.Height; break; } - //if no layouting remains in queue for item, registre for redraw - if (this.registeredLayoutings == LayoutingType.None && IsDirty) - IFace.EnqueueForRepaint (this); + EnqueueForRepaint (); return true; } @@ -1913,13 +1930,8 @@ namespace Crow public virtual void onDisable(object sender, EventArgs e){ Disabled.Raise (this, e); } - protected virtual void onParentChanged(object sender, DataSourceChangeEventArgs e) { -// if (e.NewDataSource != null) { -// if (width == Measure.Inherit) -// RegisterForLayouting (LayoutingType.Width); -// if (height == Measure.Inherit) -// RegisterForLayouting (LayoutingType.Height); -// } + protected virtual void onParentChanged(object sender, DataSourceChangeEventArgs e) { + RegisterForLayouting (LayoutingType.None); ParentChanged.Raise (this, e); if (logicalParent == null) diff --git a/src/GraphicObjects/Grid.cs b/src/GraphicObjects/Grid.cs index 4ae906a7..12a19dd7 100644 --- a/src/GraphicObjects/Grid.cs +++ b/src/GraphicObjects/Grid.cs @@ -155,9 +155,7 @@ namespace Crow ComputeChildrenPositions (); - //if no layouting remains in queue for item, registre for redraw - if (RegisteredLayoutings == LayoutingType.None && IsDirty) - IFace.EnqueueForRepaint (this); + EnqueueForRepaint (); return true; } diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index a90947a5..ebf75d64 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -243,14 +243,14 @@ namespace Crow if (largestChild == null) { //if still null, not possible to determine a width //because all children are stretched, force first one to fit - Children [0].Width = Measure.Fit; + //Children [0].Width = Measure.Fit; return -1;//cancel actual sizing to let child computation take place } } else { if (tallestChild == null) searchTallestChild (); if (tallestChild == null) { - Children [0].Height = Measure.Fit; + //Children [0].Height = Measure.Fit; return -1; } } @@ -394,6 +394,7 @@ namespace Crow #endif largestChild = null; contentSize.Width = 0; + childrenRWLock.EnterReadLock (); for (int i = 0; i < Children.Count; i++) { if (!Children [i].Visible) continue; @@ -404,6 +405,7 @@ namespace Crow largestChild = Children [i]; } } + childrenRWLock.ExitReadLock (); } void searchTallestChild(){ #if DEBUG_LAYOUTING @@ -411,6 +413,7 @@ namespace Crow #endif tallestChild = null; contentSize.Height = 0; + childrenRWLock.EnterReadLock (); for (int i = 0; i < Children.Count; i++) { if (!Children [i].Visible) continue; @@ -421,6 +424,7 @@ namespace Crow tallestChild = Children [i]; } } + childrenRWLock.ExitReadLock (); } diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index d6637247..f3f6dbf1 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -68,9 +68,13 @@ namespace Crow contentSize = default(Size); child.LayoutChanged -= OnChildLayoutChanges; this.RegisterForGraphicUpdate (); - } - child = _child as GraphicObject; + GraphicObject tmp = child; + child = null; + tmp.Parent = null; + } + + child = _child; if (child != null) { child.Parent = this; diff --git a/src/GraphicObjects/Shape.cs b/src/GraphicObjects/Shape.cs index a4b3193e..3bc46590 100644 --- a/src/GraphicObjects/Shape.cs +++ b/src/GraphicObjects/Shape.cs @@ -145,7 +145,7 @@ namespace Crow } } } - protected override int measureRawSize (LayoutingType lt) + protected override int measureRawSize(LayoutingType lt) { if ((lt == LayoutingType.Width && contentSize.Width == 0) || (lt == LayoutingType.Height && contentSize.Height == 0)) { using (Surface drawing = new ImageSurface (Format.A1, 1,1)) { diff --git a/src/GraphicObjects/TabView.cs b/src/GraphicObjects/TabView.cs index 304e820d..af3d4af2 100644 --- a/src/GraphicObjects/TabView.cs +++ b/src/GraphicObjects/TabView.cs @@ -237,9 +237,7 @@ namespace Crow curOffset += tabSpace; } - //if no layouting remains in queue for item, registre for redraw - if (RegisteredLayoutings == LayoutingType.None && IsDirty) - IFace.EnqueueForRepaint (this); + EnqueueForRepaint (); return true; } diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs index f7c93763..6067f0ac 100644 --- a/src/GraphicObjects/TemplatedGroup.cs +++ b/src/GraphicObjects/TemplatedGroup.cs @@ -242,12 +242,14 @@ namespace Crow void Ol_ListAdd (object sender, ListChangedEventArg e) { if (this.isPaged) { - throw new NotImplementedException(); + throw new NotImplementedException (); // int p = e.Index / itemPerPage; // int i = e.Index % itemPerPage; // (items.Children [p] as Group).InsertChild (i, e.Element); - } else - loadItem (e.Element, items, dataTest); + } else { + lock(IFace.UpdateMutex) + loadItem (e.Element, items, dataTest); + } } [XmlAttributeAttribute][DefaultValue("SteelBlue")] @@ -445,16 +447,19 @@ namespace Crow iTemp = ItemTemplates ["default"]; } - lock (IFace.LayoutMutex) { - g = iTemp.CreateInstance(); + //lock (IFace.LayoutMutex) { + g = iTemp.CreateInstance (); + #if DESIGN_MODE g.design_isTGItem = true; #endif + + page.AddChild (g); // if (isPaged) g.LogicalParent = this; g.MouseDown += itemClick; - } + //} if (iTemp.Expand != null && g is Expandable) { Expandable e = g as Expandable; diff --git a/src/GraphicObjects/TextRun.cs b/src/GraphicObjects/TextRun.cs index 17e3b770..50e4f47f 100644 --- a/src/GraphicObjects/TextRun.cs +++ b/src/GraphicObjects/TextRun.cs @@ -145,7 +145,7 @@ namespace Crow } #region GraphicObject overrides - protected override int measureRawSize (LayoutingType lt) + protected override int measureRawSize(LayoutingType lt) { if (lines == null) lines = getLines; diff --git a/src/GraphicObjects/Wrapper.cs b/src/GraphicObjects/Wrapper.cs index a7f5f73b..9efb989c 100644 --- a/src/GraphicObjects/Wrapper.cs +++ b/src/GraphicObjects/Wrapper.cs @@ -118,7 +118,7 @@ namespace Crow #endregion #region GraphicObject Overrides - protected override int measureRawSize (LayoutingType lt) + protected override int measureRawSize(LayoutingType lt) { int tmp = 0; //Wrapper can't fit in the opposite direction of the wrapper, this func is called only if Fit @@ -194,7 +194,6 @@ namespace Crow return tmp + tallestChild + 2 * Margin; } } - public override bool UpdateLayout (LayoutingType layoutType) { RegisteredLayoutings &= (~layoutType); @@ -205,9 +204,7 @@ namespace Crow ComputeChildrenPositions (); - //if no layouting remains in queue for item, registre for redraw - if (RegisteredLayoutings == LayoutingType.None && IsDirty) - IFace.EnqueueForRepaint (this); + EnqueueForRepaint (); return true; } |