From: jpbruyere Date: Mon, 8 Feb 2016 08:12:54 +0000 (+0100) Subject: ensure Groups use Children property (overridable) instead of children field X-Git-Tag: 0.3~36 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=b915ff1d6d8fdefb5482b7faa3d68734a14047eb;p=jp%2Fcrow.git ensure Groups use Children property (overridable) instead of children field --- diff --git a/Crow.userprefs b/Crow.userprefs deleted file mode 100644 index 142cd315..00000000 --- a/Crow.userprefs +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tests/GOLIBTest_4.cs b/Tests/GOLIBTest_4.cs index ec47b48c..8fbfe4ec 100644 --- a/Tests/GOLIBTest_4.cs +++ b/Tests/GOLIBTest_4.cs @@ -146,9 +146,9 @@ namespace test b.MouseLeave += delegate(object sender, MouseMoveEventArgs ee) { (sender as Border).Foreground = Color.Transparent; }; - s.addChild (b); + s.AddChild (b); - s.addChild ( + s.AddChild ( new Label (col.ToString ()){ Bounds=new Rectangle(0,0,-1,-1), } @@ -179,7 +179,7 @@ namespace test void onButClick(object send, MouseButtonEventArgs e) { Color col = Color.ColorDic.ToArray () [i]; - HorizontalStack s = colors.addChild (new HorizontalStack () { Fit = true}); + HorizontalStack s = colors.AddChild (new HorizontalStack () { Fit = true}); s.HorizontalAlignment = HorizontalAlignment.Left; Border b = new Border () { Bounds = new Size (32, 20), @@ -195,9 +195,9 @@ namespace test b.MouseLeave += delegate(object sender, MouseMoveEventArgs ee) { (sender as Border).Foreground = Color.Transparent; }; - s.addChild (b); + s.AddChild (b); - s.addChild ( + s.AddChild ( new Label (col.ToString ()){ Bounds=new Rectangle(0,0,-1,-1), } @@ -214,7 +214,7 @@ namespace test lock (mutex) { if (loadedCols.Count > 50 || allColsLoaded) { while (loadedCols.Count > 0) { - colors.addChild (loadedCols[0]); + colors.AddChild (loadedCols[0]); loadedCols.RemoveAt (0); } } diff --git a/Tests/GOLIBTests.cs b/Tests/GOLIBTests.cs index 31761743..2b2aabd6 100644 --- a/Tests/GOLIBTests.cs +++ b/Tests/GOLIBTests.cs @@ -39,11 +39,11 @@ namespace test string[] testFiles = { "0.crow", "testExpandable.goml", + "4.crow", + "testColorList.crow", "5.crow", "testSpinner.goml", "testScrollbar.goml", - "4.crow", - "testColorList.crow", "testGroupBox.goml", "testGrid.goml", "test_Listbox.goml", @@ -163,9 +163,12 @@ namespace test fps = (int)RenderFrequency; - if (frameCpt > 200) { + if (frameCpt > 50) { resetFps (); frameCpt = 0; + GC.Collect(); + GC.WaitForPendingFinalizers(); + NotifyValueChanged("memory", GC.GetTotalMemory (false).ToString()); } frameCpt++; } diff --git a/src/GraphicObjects/ComboBox.cs b/src/GraphicObjects/ComboBox.cs index aee7da9b..c071cb5e 100644 --- a/src/GraphicObjects/ComboBox.cs +++ b/src/GraphicObjects/ComboBox.cs @@ -173,7 +173,7 @@ namespace Crow if (!threadedLoadingFinished && pendingChildrenAddition.Count < 50) return; while (pendingChildrenAddition.Count > 0) { - _list.addChild (pendingChildrenAddition.Dequeue ()); + _list.AddChild (pendingChildrenAddition.Dequeue ()); } } } diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index d2338362..665ba65d 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -28,15 +28,15 @@ namespace Crow Orientation _orientation; #endregion - public override T addChild (T child) + public override T AddChild (T child) { - T tmp = base.addChild (child); + T tmp = base.AddChild (child); this.RegisterForLayouting (LayoutingType.PositionChildren); return tmp; } - public override void removeChild (GraphicObject child) + public override void RemoveChild (GraphicObject child) { - base.removeChild (child); + base.RemoveChild (child); this.RegisterForLayouting (LayoutingType.PositionChildren); } diff --git a/src/GraphicObjects/Grid.cs b/src/GraphicObjects/Grid.cs index fc3d8988..c242899f 100644 --- a/src/GraphicObjects/Grid.cs +++ b/src/GraphicObjects/Grid.cs @@ -29,15 +29,15 @@ namespace Crow int _rowCount; #endregion - public override T addChild (T child) + public override T AddChild (T child) { - T tmp = base.addChild (child); + T tmp = base.AddChild (child); this.RegisterForLayouting (LayoutingType.PositionChildren); return tmp; } - public override void removeChild (GraphicObject child) + public override void RemoveChild (GraphicObject child) { - base.removeChild (child); + base.RemoveChild (child); this.RegisterForLayouting (LayoutingType.PositionChildren); } diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 8737b866..9d9abbc6 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -42,21 +42,21 @@ namespace Crow } - public virtual T addChild(T child) + public virtual T AddChild(T child) { GraphicObject g = child as GraphicObject; - Children.Add(g); + children.Add(g); g.Parent = this as GraphicObject; g.RegisterForLayouting (LayoutingType.Sizing); g.LayoutChanged += OnChildLayoutChanges; return (T)child; } - public virtual void removeChild(GraphicObject child) + public virtual void RemoveChild(GraphicObject child) { child.LayoutChanged -= OnChildLayoutChanges; child.ClearBinding (); child.Parent = null; - Children.Remove(child); + children.Remove(child); this.RegisterForLayouting (LayoutingType.Sizing); } public virtual void ClearChildren() @@ -66,25 +66,25 @@ namespace Crow g.LayoutChanged -= OnChildLayoutChanges; g.ClearBinding (); g.Parent = null; - Children.RemoveAt(children.Count-1); + children.RemoveAt(children.Count-1); } this.RegisterForLayouting (LayoutingType.Sizing); ChildrenCleared.Raise (this, new EventArgs ()); } public void putWidgetOnTop(GraphicObject w) { - if (Children.Contains(w)) + if (children.Contains(w)) { - Children.Remove(w); - Children.Add(w); + children.Remove(w); + children.Add(w); } } public void putWidgetOnBottom(GraphicObject w) { - if (Children.Contains(w)) + if (children.Contains(w)) { - Children.Remove(w); - Children.Insert(0, w); + children.Remove(w); + children.Insert(0, w); } } @@ -93,7 +93,7 @@ namespace Crow get { if (!base.DrawingIsValid) return false; - foreach (GraphicObject g in Children) { + foreach (GraphicObject g in children) { if (!g.DrawingIsValid) return false; } @@ -103,7 +103,7 @@ namespace Crow public override void ResolveBindings () { base.ResolveBindings (); - foreach (GraphicObject w in Children) + foreach (GraphicObject w in children) w.ResolveBindings (); } public override GraphicObject FindByName (string nameToFind) @@ -111,7 +111,7 @@ namespace Crow if (Name == nameToFind) return this; - foreach (GraphicObject w in Children) { + foreach (GraphicObject w in children) { GraphicObject r = w.FindByName (nameToFind); if (r != null) return r; @@ -120,7 +120,7 @@ namespace Crow } public override bool Contains (GraphicObject goToFind) { - foreach (GraphicObject w in Children) { + foreach (GraphicObject w in children) { if (w == goToFind) return true; if (w.Contains (goToFind)) @@ -140,14 +140,14 @@ namespace Crow //position smaller objects in group when group size is fit switch (layoutType) { case LayoutingType.Width: - foreach (GraphicObject c in Children) { + foreach (GraphicObject c in children) { if (!c.Visible) continue; c.RegisterForLayouting (LayoutingType.X | LayoutingType.Width); } break; case LayoutingType.Height: - foreach (GraphicObject c in Children) { + foreach (GraphicObject c in children) { if (!c.Visible) continue; c.RegisterForLayouting (LayoutingType.Y | LayoutingType.Height); } @@ -212,7 +212,7 @@ namespace Crow { base.onDraw (gr); - foreach (GraphicObject g in Children) { + foreach (GraphicObject g in children) { g.Paint (ref gr); } } @@ -252,7 +252,7 @@ namespace Crow #if DEBUG_CLIP_RECTANGLE clip.stroke (gr, Color.Amaranth.AdjustAlpha (0.8)); #endif - foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) { + 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); @@ -275,7 +275,7 @@ namespace Crow HostContainer.hoverWidget = this; onMouseEnter (this, e); } - foreach (GraphicObject g in Children) + foreach (GraphicObject g in children) { if (g.MouseIsIn(e.Position)) { @@ -313,7 +313,7 @@ namespace Crow throw new Exception ("Crow." + subTree.Name + " type not found"); GraphicObject go = (GraphicObject)Activator.CreateInstance(t); (go as IXmlSerializable).ReadXml(subTree); - addChild(go); + AddChild(go); } } } @@ -321,7 +321,7 @@ namespace Crow { base.WriteXml(writer); - foreach (GraphicObject go in Children) + foreach (GraphicObject go in children) { writer.WriteStartElement(go.GetType().Name); (go as IXmlSerializable).WriteXml(writer); diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs index dfa248cf..3822275e 100644 --- a/src/GraphicObjects/ListBox.cs +++ b/src/GraphicObjects/ListBox.cs @@ -101,7 +101,7 @@ namespace Crow ms.Seek(0,SeekOrigin.Begin); GraphicObject g = Interface.Load (ms, t); g.MouseClick += itemClick; - _list.addChild (g); + _list.AddChild (g); g.DataSource = item; } diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs index 12099e48..2083346c 100644 --- a/src/OpenTKGameWindow.cs +++ b/src/OpenTKGameWindow.cs @@ -249,76 +249,76 @@ namespace Crow updateTime.Restart (); #endif - surf = new ImageSurface(bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height,ClientRectangle.Width*4); - ctx = new Context(surf); + using (surf = new ImageSurface (bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height, ClientRectangle.Width * 4)) { + using (ctx = new Context (surf)){ - GraphicObject[] invGOList = new GraphicObject[GraphicObjects.Count]; - GraphicObjects.CopyTo (invGOList,0); - invGOList = invGOList.Reverse ().ToArray (); + GraphicObject[] invGOList = new GraphicObject[GraphicObjects.Count]; + GraphicObjects.CopyTo (invGOList, 0); + invGOList = invGOList.Reverse ().ToArray (); - #if MEASURE_TIME - layoutTime.Start (); - #endif - //Debug.WriteLine ("======= Layouting queue start ======="); - - while (Interface.LayoutingQueue.Count > 0) { - LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue (); - lqi.ProcessLayouting (); - } - - #if MEASURE_TIME - layoutTime.Stop (); - #endif - - //Debug.WriteLine ("otd:" + gobjsToRedraw.Count.ToString () + "-"); - //final redraw clips should be added only when layout is completed among parents, - //that's why it take place in a second pass - GraphicObject[] gotr = new GraphicObject[gobjsToRedraw.Count]; - gobjsToRedraw.CopyTo (gotr); - gobjsToRedraw.Clear (); - foreach (GraphicObject p in gotr) { - p.registerClipRect (); - } + #if MEASURE_TIME + layoutTime.Start (); + #endif + //Debug.WriteLine ("======= Layouting queue start ======="); - #if MEASURE_TIME - updateTime.Stop (); - drawingTime.Start (); - #endif + while (Interface.LayoutingQueue.Count > 0) { + LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue (); + lqi.ProcessLayouting (); + } - lock (redrawClip) { - if (redrawClip.count > 0) { - #if DEBUG_CLIP_RECTANGLE - redrawClip.stroke (ctx, new Color(1.0,0,0,0.3)); + #if MEASURE_TIME + layoutTime.Stop (); #endif - redrawClip.clearAndClip (ctx); - //Link.draw (ctx); - foreach (GraphicObject p in invGOList) { - if (p.Visible) { + //Debug.WriteLine ("otd:" + gobjsToRedraw.Count.ToString () + "-"); + //final redraw clips should be added only when layout is completed among parents, + //that's why it take place in a second pass + GraphicObject[] gotr = new GraphicObject[gobjsToRedraw.Count]; + gobjsToRedraw.CopyTo (gotr); + gobjsToRedraw.Clear (); + foreach (GraphicObject p in gotr) { + p.registerClipRect (); + } - ctx.Save (); - if (redrawClip.count > 0) { - Rectangles clip = redrawClip.intersectingRects (p.Slot); + #if MEASURE_TIME + updateTime.Stop (); + drawingTime.Start (); + #endif - if (clip.count > 0) - p.Paint (ref ctx, clip); + lock (redrawClip) { + if (redrawClip.count > 0) { + #if DEBUG_CLIP_RECTANGLE + redrawClip.stroke (ctx, new Color(1.0,0,0,0.3)); + #endif + redrawClip.clearAndClip (ctx); + + //Link.draw (ctx); + foreach (GraphicObject p in invGOList) { + if (p.Visible) { + + ctx.Save (); + if (redrawClip.count > 0) { + Rectangles clip = redrawClip.intersectingRects (p.Slot); + + if (clip.count > 0) + p.Paint (ref ctx, clip); + } + ctx.Restore (); + } } - ctx.Restore (); + ctx.ResetClip (); + #if DEBUG_CLIP_RECTANGLE + redrawClip.stroke (ctx, Color.Red.AdjustAlpha(0.1)); + #endif + redrawClip.Reset (); } } - ctx.ResetClip (); - #if DEBUG_CLIP_RECTANGLE - redrawClip.stroke (ctx, Color.Red.AdjustAlpha(0.1)); + #if MEASURE_TIME + drawingTime.Stop (); #endif - redrawClip.Reset (); + //surf.WriteToPng (@"/mnt/data/test.png"); } } - #if MEASURE_TIME - drawingTime.Stop (); - #endif - //surf.WriteToPng (@"/mnt/data/test.png"); - ctx.Dispose (); - surf.Dispose (); // if (ToolTip.isVisible) { // ToolTip.panel.processkLayouting(); // if (ToolTip.panel.layoutIsValid)