]> O.S.I.I.S - jp/crow.git/commitdiff
add active,focused and hover checks when go is removed from screen, triggger mouse... 40/head
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 21 Mar 2018 08:54:13 +0000 (09:54 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 21 Mar 2018 08:54:13 +0000 (09:54 +0100)
src/GraphicObjects/GraphicObject.cs

index f404b5f1b71e8abf77b29802220f37014452c4b9..bc955368194a78cd5b9eef983216a730d65e4fcb 100644 (file)
@@ -154,6 +154,7 @@ namespace Crow
                        GC.SuppressFinalize(this);  
                }  
                ~GraphicObject(){
+                       Debug.WriteLine(this.ToString() + " not disposed by user");
                        Dispose(false);
                }
                protected virtual void Dispose(bool disposing){
@@ -171,18 +172,8 @@ namespace Crow
                                throw new Exception("Trying to dispose an object queued for Redraw: " + this.ToString());
                                #endif
 
-                               if (IFace.HoverWidget != null) {
-                                       if (IFace.HoverWidget.IsOrIsInside(this))
-                                               IFace.HoverWidget = null;
-                               }
-                               if (IFace.ActiveWidget != null) {
-                                       if (IFace.ActiveWidget.IsOrIsInside (this))
-                                               IFace.ActiveWidget = null;
-                               }
-                               if (IFace.FocusedWidget != null) {
-                                       if (IFace.FocusedWidget.IsOrIsInside (this))
-                                               IFace.FocusedWidget = null;
-                               }
+                               unshownPostActions ();
+
                                if (!localDataSourceIsNull)
                                        DataSource = null;
 
@@ -869,8 +860,8 @@ namespace Crow
 
                                RegisterForLayouting (LayoutingType.Sizing);
 
-                               //trigger a mouse to handle possible hover changes
-                               //CurrentInterface.ProcessMouseMove (CurrentInterface.Mouse.X, CurrentInterface.Mouse.Y);
+                               if (!isVisible)
+                                       unshownPostActions ();
 
                                NotifyValueChanged ("Visible", isVisible);
                        }
@@ -1442,17 +1433,6 @@ namespace Crow
                /// <summary> trigger dependant sizing component update </summary>
                public virtual void OnLayoutChanges(LayoutingType  layoutType)
                {
-                       #if DEBUG_LAYOUTING
-                       IFace.currentLQI.Slot = LastSlots;
-                       IFace.currentLQI.NewSlot = Slot;
-                       Debug.WriteLine ("\t\t{0} => {1}",LastSlots,Slot);
-                       #endif
-//                     #if DESIGN_MODE
-//                     if (IFace.GetType().Name == "DesignInterface"){
-//                             Debug.WriteLine ("\t\t{2}: {0} => {1}",LastSlots,Slot,this.name);
-//                     }
-//                     #endif
-
                        switch (layoutType) {
                        case LayoutingType.Width:
                                RegisterForLayouting (LayoutingType.X);
@@ -1956,5 +1936,24 @@ namespace Crow
                        return Name == "unamed" ? tmp + "." + this.GetType ().Name : tmp + "." + Name;
                        #endif
                }
+               /// <summary>
+               /// Checks to handle when widget is removed from the visible graphic tree
+               /// </summary>
+               void unshownPostActions () {
+                       if (IFace.ActiveWidget != null) {
+                               if (IFace.ActiveWidget.IsOrIsInside (this))
+                                       IFace.ActiveWidget = null;
+                       }
+                       if (IFace.FocusedWidget != null) {
+                               if (IFace.FocusedWidget.IsOrIsInside (this))
+                                       IFace.FocusedWidget = null;
+                       }                                       
+                       if (IFace.HoverWidget != null) {
+                               if (IFace.HoverWidget.IsOrIsInside (this)) {
+                                       IFace.HoverWidget = null;
+                                       IFace.ProcessMouseMove (IFace.Mouse.X, IFace.Mouse.Y);
+                               }
+                       }
+               }
        }
 }