From 6cbe9f9d2a604cdbb74f46f3710ea3dc60a87e55 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bruyère Date: Sun, 27 Aug 2017 06:51:36 +0200 Subject: first step in implementing a dispose mechanism for graphic objects --- src/Interface.cs | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'src/Interface.cs') diff --git a/src/Interface.cs b/src/Interface.cs index adcb2830..baa46667 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -593,15 +593,40 @@ namespace Crow public void DeleteWidget(GraphicObject g) { if (_hoverWidget != null) { - if (g.Contains (_hoverWidget)) + if (_hoverWidget.IsInside(g)) HoverWidget = null; } lock (UpdateMutex) { - g.DataSource = null; - g.Visible = false; + RegisterClip (g.ScreenCoordinates (g.LastPaintedSlot)); GraphicTree.Remove (g); + g.Parent = null; + g.Dispose (); } } + /// Remove all Graphic objects from top container + public void ClearInterface() + { + lock (UpdateMutex) { + while (GraphicTree.Count > 0) { + //TODO:parent is not reset to null because object will be added + //to ObjectToRedraw list, and without parent, it fails + GraphicObject g = GraphicTree [0]; + if (_hoverWidget != null) { + if (_hoverWidget.IsInside(g)) + HoverWidget = null; + } + RegisterClip (g.ScreenCoordinates (g.LastPaintedSlot)); + GraphicTree.RemoveAt (0); + g.Dispose (); + } + } + #if DEBUG_LAYOUTING + LQIsTries = new List(); + curLQIsTries = new LQIList(); + LQIs = new List(); + curLQIs = new LQIList(); + #endif + } /// Put widget on top of other root widgets public void PutOnTop(GraphicObject g, bool isOverlay = false) { @@ -626,26 +651,6 @@ namespace Crow EnqueueForRepaint (g); } } - /// Remove all Graphic objects from top container - public void ClearInterface() - { - lock (UpdateMutex) { - while (GraphicTree.Count > 0) { - //TODO:parent is not reset to null because object will be added - //to ObjectToRedraw list, and without parent, it fails - GraphicObject g = GraphicTree [0]; - g.DataSource = null; - g.Visible = false; - GraphicTree.RemoveAt (0); - } - } - #if DEBUG_LAYOUTING - LQIsTries = new List(); - curLQIsTries = new LQIList(); - LQIs = new List(); - curLQIs = new LQIList(); - #endif - } /// Search a Graphic object in the tree named 'nameToFind' public GraphicObject FindByName (string nameToFind) -- cgit v1.3.1-4-g156e