]> O.S.I.I.S - jp/crow.git/commitdiff
Simplify z ordering of root objects in GraphicTree
authorjpbruyere <jp.bruyere@hotmail.com>
Tue, 21 Mar 2017 12:48:50 +0000 (13:48 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Tue, 21 Mar 2017 12:48:50 +0000 (13:48 +0100)
modifié :         src/GraphicObjects/Group.cs
modifié :         src/GraphicObjects/Window.cs
modifié :         src/Interface.cs

src/GraphicObjects/Group.cs
src/GraphicObjects/Window.cs
src/Interface.cs

index d00449cbf57c726997958d0ac3126f533d525ba4..d4b5b62ef5112dbb278fe4c9710f497bb17d40aa 100644 (file)
@@ -102,26 +102,26 @@ namespace Crow
                        ChildrenCleared.Raise (this, new EventArgs ());
                }
 
-               public void putWidgetOnTop(GraphicObject w)
-               {
-                       if (Children.Contains(w))
-                       {
-                               lock (children) {
-                                       Children.Remove (w);
-                                       Children.Add (w);
-                               }
-                       }
-               }
-               public void putWidgetOnBottom(GraphicObject w)
-               {
-                       if (Children.Contains(w))
-                       {
-                               lock (children) {
-                                       Children.Remove (w);
-                                       Children.Insert (0, w);
-                               }
-                       }
-               }
+//             public void putWidgetOnTop(GraphicObject w)
+//             {
+//                     if (Children.Contains(w))
+//                     {
+//                             lock (children) {
+//                                     Children.Remove (w);
+//                                     Children.Add (w);
+//                             }
+//                     }
+//             }
+//             public void putWidgetOnBottom(GraphicObject w)
+//             {
+//                     if (Children.Contains(w))
+//                     {
+//                             lock (children) {
+//                                     Children.Remove (w);
+//                                     Children.Insert (0, w);
+//                             }
+//                     }
+//             }
 
                #region GraphicObject overrides
                public override void OnDataSourceChanged (object sender, DataSourceChangeEventArgs e)
index e282052831e406ef5cbc853d937aedfe8f7bb71d..8a6903f601c41ee14f386617be8a0b5bfb654a74 100644 (file)
@@ -150,11 +150,10 @@ namespace Crow
                                if (alwaysOnTop == value)
                                        return;
                                alwaysOnTop = value;
-                               if (alwaysOnTop) {
+
+                               if (alwaysOnTop && Parent != null)
                                        CurrentInterface.PutOnTop (this);
-                                       CurrentInterface.TopWindows++;
-                               }else
-                                       CurrentInterface.TopWindows--;
+
                                NotifyValueChanged ("AlwaysOnTop", alwaysOnTop);
                        }
                }
index b3ff2527e9e61ededc87cc5d64a73615362c16cd..62ac6ce3589c0e552715b2170e92e60170bf1a56 100644 (file)
@@ -147,7 +147,6 @@ namespace Crow
                /// </summary>
                public static Dictionary<String, Instantiator> Instantiators = new Dictionary<string, Instantiator>();
                public bool DesignMode = false;
-               public int TopWindows = 0;//window always on top count
                public List<CrowThread> CrowThreads = new List<CrowThread>();//used to monitor thread finished
                #endregion
 
@@ -550,17 +549,25 @@ namespace Crow
 
                #region GraphicTree handling
                /// <summary>Add widget to the Graphic tree of this interface and register it for layouting</summary>
-               public void AddWidget(GraphicObject g, bool topMost = false)
+               public void AddWidget(GraphicObject g, bool isOverlay = false)
                {
                        g.Parent = this;
-                       int ptr = TopWindows;
-                       if (g is Window) {
-                               if ((g as Window).AlwaysOnTop)
-                                       ptr = 0;
-                       } else if (topMost)
-                               ptr = 0;
+                       int ptr = 0;
+                       Window newW = g as Window;
+                       if (newW != null) {
+                               while (ptr < GraphicTree.Count) {
+                                       Window w = GraphicTree [ptr] as Window;
+                                       if (w != null) {
+                                               if (newW.AlwaysOnTop || !w.AlwaysOnTop)
+                                                       break;
+                                       }
+                                       ptr++;
+                               }
+                       }
+
                        lock (UpdateMutex)
-                               GraphicTree.Insert (ptr, g);                    
+                               GraphicTree.Insert (ptr, g);
+
                        g.RegisteredLayoutings = LayoutingType.None;
                        g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
                }
@@ -572,14 +579,20 @@ namespace Crow
                                GraphicTree.Remove (g);
                }
                /// <summary> Put widget on top of other root widgets</summary>
-               public void PutOnTop(GraphicObject g, bool topMost = false)
+               public void PutOnTop(GraphicObject g, bool isOverlay = false)
                {
-                       int ptr = TopWindows;
-                       if (g is Window) {
-                               if ((g as Window).AlwaysOnTop)
-                                       ptr = 0;
-                       } else if (topMost)
-                               ptr = 0;
+                       int ptr = 0;
+                       Window newW = g as Window;
+                       if (newW != null) {
+                               while (ptr < GraphicTree.Count) {
+                                       Window w = GraphicTree [ptr] as Window;
+                                       if (w != null) {
+                                               if (newW.AlwaysOnTop || !w.AlwaysOnTop)
+                                                       break;
+                                       }
+                                       ptr++;
+                               }
+                       }
                        if (GraphicTree.IndexOf(g) > ptr)
                        {
                                lock (UpdateMutex) {