From e1553b533e3aa74bd533cfc3deb244f1fc334106 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Tue, 21 Mar 2017 13:48:50 +0100 Subject: [PATCH] =?utf8?q?Simplify=20z=20ordering=20of=20root=20objects=20?= =?utf8?q?in=20GraphicTree=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20?= =?utf8?q?=20=20src/GraphicObjects/Group.cs=20=09modifi=C3=A9=C2=A0:=20=20?= =?utf8?q?=20=20=20=20=20=20=20src/GraphicObjects/Window.cs=20=09modifi?= =?utf8?q?=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20src/Interface.cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/GraphicObjects/Group.cs | 40 ++++++++++++++++---------------- src/GraphicObjects/Window.cs | 7 +++--- src/Interface.cs | 45 +++++++++++++++++++++++------------- 3 files changed, 52 insertions(+), 40 deletions(-) diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index d00449cb..d4b5b62e 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -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) diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs index e2820528..8a6903f6 100644 --- a/src/GraphicObjects/Window.cs +++ b/src/GraphicObjects/Window.cs @@ -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); } } diff --git a/src/Interface.cs b/src/Interface.cs index b3ff2527..62ac6ce3 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -147,7 +147,6 @@ namespace Crow /// public static Dictionary Instantiators = new Dictionary(); public bool DesignMode = false; - public int TopWindows = 0;//window always on top count public List CrowThreads = new List();//used to monitor thread finished #endregion @@ -550,17 +549,25 @@ namespace Crow #region GraphicTree handling /// Add widget to the Graphic tree of this interface and register it for layouting - 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); } /// Put widget on top of other root widgets - 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) { -- 2.47.3