From 7d84ba29057264497818c4c315bec7547cc9afac Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Mon, 1 Aug 2016 12:45:27 +0200 Subject: [PATCH] =?utf8?q?Improve=20update=20queuing=20=09modifi=C3=A9?= =?utf8?q?=C2=A0:=20=20=20=20=20=20=20=20=20src/GraphicObjects/GenericStac?= =?utf8?q?k.cs=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20src/Grap?= =?utf8?q?hicObjects/GraphicObject.cs=20=09modifi=C3=A9=C2=A0:=20=20=20=20?= =?utf8?q?=20=20=20=20=20src/GraphicObjects/Group.cs=20=09modifi=C3=A9?= =?utf8?q?=C2=A0:=20=20=20=20=20=20=20=20=20src/GraphicObjects/Label.cs=20?= =?utf8?q?=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20src/GraphicObje?= =?utf8?q?cts/ListBox.cs=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20?= =?utf8?q?=20src/GraphicObjects/TabView.cs=20=09modifi=C3=A9=C2=A0:=20=20?= =?utf8?q?=20=20=20=20=20=20=20src/Interface.cs=20=09modifi=C3=A9=C2=A0:?= =?utf8?q?=20=20=20=20=20=20=20=20=20src/StyleReader.cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit tests updates modifié : Tests/BasicTests.cs modifié : Tests/Interfaces/Divers/testWindow.goml modifié : Tests/Interfaces/Divers/welcome.crow modifié : Tests/Interfaces/Expandable/0.crow renommé : Tests/Interfaces/Nouveau dossier/test4.1.crow -> Tests/Interfaces/Unsorted/test4.1.crow renommé : Tests/Interfaces/Nouveau dossier/test4.crow -> Tests/Interfaces/Unsorted/test4.crow renommé : Tests/Interfaces/Nouveau dossier/test6.crow -> Tests/Interfaces/Unsorted/test6.crow renommé : Tests/Interfaces/Nouveau dossier/testColorList.crow -> Tests/Interfaces/Unsorted/testColorList.crow renommé : Tests/Interfaces/Nouveau dossier/testDirViewer.crow -> Tests/Interfaces/Unsorted/testDirViewer.crow renommé : Tests/Interfaces/Nouveau dossier/testFileDialog.goml -> Tests/Interfaces/Unsorted/testFileDialog.goml renommé : Tests/Interfaces/Nouveau dossier/testImage.crow -> Tests/Interfaces/Unsorted/testImage.crow renommé : Tests/Interfaces/Nouveau dossier/testLabel.crow -> Tests/Interfaces/Unsorted/testLabel.crow renommé : Tests/Interfaces/Nouveau dossier/testMsgBox.crow -> Tests/Interfaces/Unsorted/testMsgBox.crow renommé : Tests/Interfaces/Nouveau dossier/testOutOfClipUpdate.crow -> Tests/Interfaces/Unsorted/testOutOfClipUpdate.crow renommé : Tests/Interfaces/Nouveau dossier/testRadioButton2.crow -> Tests/Interfaces/Unsorted/testRadioButton2.crow renommé : Tests/Interfaces/Nouveau dossier/testTabView.crow -> Tests/Interfaces/Unsorted/testTabView.crow renommé : Tests/Interfaces/Nouveau dossier/testTreeView.crow -> Tests/Interfaces/Unsorted/testTreeView.crow renommé : Tests/Interfaces/Nouveau dossier/testTypeViewer.goml -> Tests/Interfaces/Unsorted/testTypeViewer.goml modifié : Tests/Tests.csproj --- Tests/BasicTests.cs | 30 +-- Tests/Interfaces/Divers/testWindow.goml | 2 +- Tests/Interfaces/Divers/welcome.crow | 2 +- Tests/Interfaces/Expandable/0.crow | 12 +- .../test4.1.crow | 0 .../{Nouveau dossier => Unsorted}/test4.crow | 0 .../{Nouveau dossier => Unsorted}/test6.crow | 0 .../testColorList.crow | 0 .../testDirViewer.crow | 0 .../testFileDialog.goml | 0 .../testImage.crow | 0 .../testLabel.crow | 0 .../testMsgBox.crow | 0 .../testOutOfClipUpdate.crow | 0 .../testRadioButton2.crow | 0 .../testTabView.crow | 0 .../testTreeView.crow | 0 .../testTypeViewer.goml | 0 Tests/Tests.csproj | 185 ++++-------------- Tests/ui/test.style | 3 + src/GraphicObjects/GenericStack.cs | 39 ++-- src/GraphicObjects/GraphicObject.cs | 48 +++-- src/GraphicObjects/Group.cs | 4 +- src/GraphicObjects/Label.cs | 14 +- src/GraphicObjects/ListBox.cs | 2 +- src/GraphicObjects/TabView.cs | 4 +- src/Interface.cs | 152 ++++++-------- src/StyleReader.cs | 9 +- 28 files changed, 199 insertions(+), 307 deletions(-) rename Tests/Interfaces/{Nouveau dossier => Unsorted}/test4.1.crow (100%) rename Tests/Interfaces/{Nouveau dossier => Unsorted}/test4.crow (100%) rename Tests/Interfaces/{Nouveau dossier => Unsorted}/test6.crow (100%) rename Tests/Interfaces/{Nouveau dossier => Unsorted}/testColorList.crow (100%) rename Tests/Interfaces/{Nouveau dossier => Unsorted}/testDirViewer.crow (100%) rename Tests/Interfaces/{Nouveau dossier => Unsorted}/testFileDialog.goml (100%) rename Tests/Interfaces/{Nouveau dossier => Unsorted}/testImage.crow (100%) rename Tests/Interfaces/{Nouveau dossier => Unsorted}/testLabel.crow (100%) rename Tests/Interfaces/{Nouveau dossier => Unsorted}/testMsgBox.crow (100%) rename Tests/Interfaces/{Nouveau dossier => Unsorted}/testOutOfClipUpdate.crow (100%) rename Tests/Interfaces/{Nouveau dossier => Unsorted}/testRadioButton2.crow (100%) rename Tests/Interfaces/{Nouveau dossier => Unsorted}/testTabView.crow (100%) rename Tests/Interfaces/{Nouveau dossier => Unsorted}/testTreeView.crow (100%) rename Tests/Interfaces/{Nouveau dossier => Unsorted}/testTypeViewer.goml (100%) create mode 100644 Tests/ui/test.style diff --git a/Tests/BasicTests.cs b/Tests/BasicTests.cs index 1382d739..58258634 100644 --- a/Tests/BasicTests.cs +++ b/Tests/BasicTests.cs @@ -10,7 +10,7 @@ namespace Tests class BasicTests : OpenTKGameWindow { public BasicTests () - : base(800, 600,"test: press spacebar to toogle test files") + : base(800, 600,"test: press to toogle test files") { } @@ -76,40 +76,42 @@ namespace Tests { base.OnLoad (e); - KeyboardKeyDown += GOLIBTests_KeyboardKeyDown1; + this.KeyDown += KeyboardKeyDown1; testFiles = new string [] { @"Interfaces/Divers/welcome.crow" }; - testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray (); + testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Unsorted", "*.crow")).ToArray (); + //testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray (); //testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/basicTests", "*.crow")).ToArray (); - testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Container", "*.crow")).ToArray (); - testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Group", "*.crow")).ToArray (); - testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Stack", "*.crow")).ToArray (); - testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Splitter", "*.crow")).ToArray (); + //testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Container", "*.crow")).ToArray (); + //testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Group", "*.crow")).ToArray (); + //testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Stack", "*.crow")).ToArray (); + //testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Splitter", "*.crow")).ToArray (); testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Expandable", "*.crow")).ToArray (); testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Divers", "*.crow")).ToArray (); - this.Title = testFiles [idx] + ". Press key to switch example."; + this.Title = testFiles [idx] + ". Press to switch example."; CrowInterface.LoadInterface(testFiles[idx]).DataSource = this; } - void GOLIBTests_KeyboardKeyDown1 (object sender, OpenTK.Input.KeyboardKeyEventArgs e) + void KeyboardKeyDown1 (object sender, OpenTK.Input.KeyboardKeyEventArgs e) { if (e.Key == OpenTK.Input.Key.Escape) { Quit (null, null); return; - } else if (e.Key == OpenTK.Input.Key.L) { + } else if (e.Key == OpenTK.Input.Key.F1) { TestList.Add ("new string"); NotifyValueChanged ("TestList", TestList); return; - } else if (e.Key == OpenTK.Input.Key.W) { - GraphicObject w = CrowInterface.LoadInterface("Interfaces/testWindow.goml"); + } else if (e.Key == OpenTK.Input.Key.F2) { + GraphicObject w = CrowInterface.LoadInterface ("Interfaces/Divers/testWindow.goml"); w.DataSource = this; return; - } + } else if (e.Key != OpenTK.Input.Key.F3) + return; CrowInterface.ClearInterface (); idx++; if (idx == testFiles.Length) idx = 0; - this.Title = testFiles [idx] + ". Press key to cycle examples."; + this.Title = testFiles [idx] + ". Press to cycle examples."; GraphicObject obj = CrowInterface.LoadInterface(testFiles[idx]); obj.DataSource = this; } diff --git a/Tests/Interfaces/Divers/testWindow.goml b/Tests/Interfaces/Divers/testWindow.goml index 9e184dff..09db6193 100755 --- a/Tests/Interfaces/Divers/testWindow.goml +++ b/Tests/Interfaces/Divers/testWindow.goml @@ -16,7 +16,7 @@ - diff --git a/Tests/Interfaces/Divers/welcome.crow b/Tests/Interfaces/Divers/welcome.crow index 504413a1..8a98b380 100644 --- a/Tests/Interfaces/Divers/welcome.crow +++ b/Tests/Interfaces/Divers/welcome.crow @@ -1,5 +1,5 @@  - \ No newline at end of file diff --git a/Tests/Interfaces/Expandable/0.crow b/Tests/Interfaces/Expandable/0.crow index d243e67e..0c37d335 100755 --- a/Tests/Interfaces/Expandable/0.crow +++ b/Tests/Interfaces/Expandable/0.crow @@ -1,11 +1,11 @@  - - - - - - + + + + + + diff --git a/Tests/Interfaces/Nouveau dossier/test4.1.crow b/Tests/Interfaces/Unsorted/test4.1.crow similarity index 100% rename from Tests/Interfaces/Nouveau dossier/test4.1.crow rename to Tests/Interfaces/Unsorted/test4.1.crow diff --git a/Tests/Interfaces/Nouveau dossier/test4.crow b/Tests/Interfaces/Unsorted/test4.crow similarity index 100% rename from Tests/Interfaces/Nouveau dossier/test4.crow rename to Tests/Interfaces/Unsorted/test4.crow diff --git a/Tests/Interfaces/Nouveau dossier/test6.crow b/Tests/Interfaces/Unsorted/test6.crow similarity index 100% rename from Tests/Interfaces/Nouveau dossier/test6.crow rename to Tests/Interfaces/Unsorted/test6.crow diff --git a/Tests/Interfaces/Nouveau dossier/testColorList.crow b/Tests/Interfaces/Unsorted/testColorList.crow similarity index 100% rename from Tests/Interfaces/Nouveau dossier/testColorList.crow rename to Tests/Interfaces/Unsorted/testColorList.crow diff --git a/Tests/Interfaces/Nouveau dossier/testDirViewer.crow b/Tests/Interfaces/Unsorted/testDirViewer.crow similarity index 100% rename from Tests/Interfaces/Nouveau dossier/testDirViewer.crow rename to Tests/Interfaces/Unsorted/testDirViewer.crow diff --git a/Tests/Interfaces/Nouveau dossier/testFileDialog.goml b/Tests/Interfaces/Unsorted/testFileDialog.goml similarity index 100% rename from Tests/Interfaces/Nouveau dossier/testFileDialog.goml rename to Tests/Interfaces/Unsorted/testFileDialog.goml diff --git a/Tests/Interfaces/Nouveau dossier/testImage.crow b/Tests/Interfaces/Unsorted/testImage.crow similarity index 100% rename from Tests/Interfaces/Nouveau dossier/testImage.crow rename to Tests/Interfaces/Unsorted/testImage.crow diff --git a/Tests/Interfaces/Nouveau dossier/testLabel.crow b/Tests/Interfaces/Unsorted/testLabel.crow similarity index 100% rename from Tests/Interfaces/Nouveau dossier/testLabel.crow rename to Tests/Interfaces/Unsorted/testLabel.crow diff --git a/Tests/Interfaces/Nouveau dossier/testMsgBox.crow b/Tests/Interfaces/Unsorted/testMsgBox.crow similarity index 100% rename from Tests/Interfaces/Nouveau dossier/testMsgBox.crow rename to Tests/Interfaces/Unsorted/testMsgBox.crow diff --git a/Tests/Interfaces/Nouveau dossier/testOutOfClipUpdate.crow b/Tests/Interfaces/Unsorted/testOutOfClipUpdate.crow similarity index 100% rename from Tests/Interfaces/Nouveau dossier/testOutOfClipUpdate.crow rename to Tests/Interfaces/Unsorted/testOutOfClipUpdate.crow diff --git a/Tests/Interfaces/Nouveau dossier/testRadioButton2.crow b/Tests/Interfaces/Unsorted/testRadioButton2.crow similarity index 100% rename from Tests/Interfaces/Nouveau dossier/testRadioButton2.crow rename to Tests/Interfaces/Unsorted/testRadioButton2.crow diff --git a/Tests/Interfaces/Nouveau dossier/testTabView.crow b/Tests/Interfaces/Unsorted/testTabView.crow similarity index 100% rename from Tests/Interfaces/Nouveau dossier/testTabView.crow rename to Tests/Interfaces/Unsorted/testTabView.crow diff --git a/Tests/Interfaces/Nouveau dossier/testTreeView.crow b/Tests/Interfaces/Unsorted/testTreeView.crow similarity index 100% rename from Tests/Interfaces/Nouveau dossier/testTreeView.crow rename to Tests/Interfaces/Unsorted/testTreeView.crow diff --git a/Tests/Interfaces/Nouveau dossier/testTypeViewer.goml b/Tests/Interfaces/Unsorted/testTypeViewer.goml similarity index 100% rename from Tests/Interfaces/Nouveau dossier/testTypeViewer.goml rename to Tests/Interfaces/Unsorted/testTypeViewer.goml diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 3554e9c9..61868849 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -8,17 +8,18 @@ Exe Tests Tests - Tests.HelloCube + Tests.BasicTests v4.5 AnyCPU 0.4 $(SolutionDir)build/$(Configuration) $(SolutionDir)build/obj/$(Configuration) - + - + + false true @@ -51,6 +52,7 @@ $(SolutionDir)packages\GtkSharp.3.1.3\lib\net45\glib-sharp.dll + glib-sharp-3.0 $(SolutionDir)packages\OpenTK.Next.1.2.2336.6514-pre\lib\net20\OpenTK.dll @@ -59,247 +61,177 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - Tests.Interfaces.test7.goml @@ -307,165 +239,122 @@ PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - PreserveNewest - - + PreserveNewest - - + PreserveNewest - - + PreserveNewest - - + PreserveNewest - - + PreserveNewest - - + + PreserveNewest - - + PreserveNewest - - + + PreserveNewest - - + PreserveNewest - - + PreserveNewest - - + PreserveNewest - - + PreserveNewest - - + PreserveNewest - - + PreserveNewest - - + PreserveNewest - - + PreserveNewest - - + PreserveNewest - - + PreserveNewest - - + PreserveNewest - - - - - + PreserveNewest - - + PreserveNewest - - - - @@ -475,9 +364,9 @@ - + diff --git a/Tests/ui/test.style b/Tests/ui/test.style new file mode 100644 index 00000000..fe85d912 --- /dev/null +++ b/Tests/ui/test.style @@ -0,0 +1,3 @@ +BlueLabel { + Background = Blue; +} diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index 3ec29fb5..c0cd7747 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -1,6 +1,7 @@ using System.ComponentModel; using System.Diagnostics; using System.Xml.Serialization; +using System; namespace Crow { @@ -126,15 +127,22 @@ namespace Crow contentSize.Width += go.Slot.Width - go.LastSlots.Width; if (stretchedGO != null) { - stretchedGO.Slot.Width = this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1); - stretchedGO.bmp = null; + int newW = Math.Max ( + this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1), + stretchedGO.MinimumSize.Width); + if (stretchedGO.MaximumSize.Width > 0) + newW = Math.Min (newW, stretchedGO.MaximumSize.Width); + if (newW != stretchedGO.Slot.Width) { + stretchedGO.Slot.Width = newW; + stretchedGO.bmp = null; #if DEBUG_LAYOUTING Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString()); #endif - stretchedGO.LayoutChanged -= OnChildLayoutChanges; - stretchedGO.OnLayoutChanges (LayoutingType.Width); - stretchedGO.LayoutChanged += OnChildLayoutChanges; - stretchedGO.LastSlots.Width = stretchedGO.Slot.Width; + stretchedGO.LayoutChanged -= OnChildLayoutChanges; + stretchedGO.OnLayoutChanges (LayoutingType.Width); + stretchedGO.LayoutChanged += OnChildLayoutChanges; + stretchedGO.LastSlots.Width = stretchedGO.Slot.Width; + } } if (Width == Measure.Fit) @@ -158,15 +166,22 @@ namespace Crow contentSize.Height += go.Slot.Height - go.LastSlots.Height; if (stretchedGO != null) { - stretchedGO.Slot.Height = this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count -1); - stretchedGO.bmp = null; + int newH = Math.Max ( + this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1), + stretchedGO.MinimumSize.Height); + if (stretchedGO.MaximumSize.Height > 0) + newH = Math.Min (newH, stretchedGO.MaximumSize.Height); + if (newH != stretchedGO.Slot.Height) { + stretchedGO.Slot.Height = newH; + stretchedGO.bmp = null; #if DEBUG_LAYOUTING Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString()); #endif - stretchedGO.LayoutChanged -= OnChildLayoutChanges; - stretchedGO.OnLayoutChanges (LayoutingType.Height); - stretchedGO.LayoutChanged += OnChildLayoutChanges; - stretchedGO.LastSlots.Height = stretchedGO.Slot.Height; + stretchedGO.LayoutChanged -= OnChildLayoutChanges; + stretchedGO.OnLayoutChanges (LayoutingType.Height); + stretchedGO.LayoutChanged += OnChildLayoutChanges; + stretchedGO.LastSlots.Height = stretchedGO.Slot.Height; + } } if (Height == Measure.Fit) diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 8c91824d..669fa83d 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -342,7 +342,7 @@ namespace Crow return; _background = value; NotifyValueChanged ("Background", _background); - RegisterForGraphicUpdate (); + RegisterForRedraw (); } } [XmlAttributeAttribute()][DefaultValue("White")] @@ -353,7 +353,7 @@ namespace Crow return; _foreground = value; NotifyValueChanged ("Foreground", _foreground); - RegisterForGraphicUpdate (); + RegisterForRedraw (); } } [XmlAttributeAttribute()][DefaultValue("sans,10")] @@ -375,7 +375,7 @@ namespace Crow return; _cornerRadius = value; NotifyValueChanged ("CornerRadius", _cornerRadius); - RegisterForGraphicUpdate (); + RegisterForRedraw (); } } [XmlAttributeAttribute()][DefaultValue(0)] @@ -402,8 +402,8 @@ namespace Crow return; //ensure main win doesn't keep hidden childrens ref - if (!_isVisible && this.Contains (Interface.CurrentInterface.hoverWidget)) - Interface.CurrentInterface.hoverWidget = null; + if (!_isVisible && this.Contains (Interface.CurrentInterface.HoverWidget)) + Interface.CurrentInterface.HoverWidget = null; if (Parent is GraphicObject) (Parent as GraphicObject).RegisterForLayouting (LayoutingType.Sizing); @@ -516,17 +516,17 @@ namespace Crow // those files being placed in a Styles folder string styleKey = Style; if (!string.IsNullOrEmpty (Style)) { - if (Interface.CurrentInterface.Styling.ContainsKey (Style)) { - styling.Add (Interface.CurrentInterface.Styling [Style]); + if (Interface.Styling.ContainsKey (Style)) { + styling.Add (Interface.Styling [Style]); } } - if (Interface.CurrentInterface.Styling.ContainsKey (thisType.FullName)) { - styling.Add (Interface.CurrentInterface.Styling [thisType.FullName]); + if (Interface.Styling.ContainsKey (thisType.FullName)) { + styling.Add (Interface.Styling [thisType.FullName]); if (string.IsNullOrEmpty (styleKey)) styleKey = thisType.FullName; } - if (Interface.CurrentInterface.Styling.ContainsKey (thisType.Name)) { - styling.Add (Interface.CurrentInterface.Styling [thisType.Name]); + if (Interface.Styling.ContainsKey (thisType.Name)) { + styling.Add (Interface.Styling [thisType.Name]); if (string.IsNullOrEmpty (styleKey)) styleKey = thisType.Name; } @@ -701,15 +701,23 @@ namespace Crow if (Parent != null) Parent.RegisterClip (clip + Slot.Position + ClientRectangle.Position); } - public bool IsQueueForGraphicUpdate = false; - /// - /// Clear chached object and add clipping region in redraw list of interface - /// + public bool IsQueueForRedraw = false; + /// Full update, taking care of sizing policy + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void RegisterForGraphicUpdate () { - Interface.RegisterForGraphicUpdate (this); + bmp = null; + if (Width == Measure.Fit || Height == Measure.Fit) + RegisterForLayouting (LayoutingType.Sizing); + Interface.CurrentInterface.EnqueueForRepaint (this); + } + /// query an update of the content, a redraw + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void RegisterForRedraw () + { + bmp = null; + Interface.CurrentInterface.EnqueueForRepaint (this); } - #region Layouting [XmlIgnore]public int LayoutingTries { get { return layoutingTries; } @@ -930,7 +938,7 @@ namespace Crow //if no layouting remains in queue for item, registre for redraw if (this.registeredLayoutings == LayoutingType.None && bmp == null) - RegisterForGraphicUpdate (); + Interface.CurrentInterface.EnqueueForRepaint (this); return true; } @@ -1044,8 +1052,8 @@ namespace Crow } public virtual void checkHoverWidget(MouseMoveEventArgs e) { - if (Interface.CurrentInterface.hoverWidget != this) { - Interface.CurrentInterface.hoverWidget = this; + if (Interface.CurrentInterface.HoverWidget != this) { + Interface.CurrentInterface.HoverWidget = this; onMouseEnter (this, e); } diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 2b440ac1..48f835ac 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -290,8 +290,8 @@ namespace Crow #region Mouse handling public override void checkHoverWidget (MouseMoveEventArgs e) { - if (Interface.CurrentInterface.hoverWidget != this) { - Interface.CurrentInterface.hoverWidget = this; + if (Interface.CurrentInterface.HoverWidget != this) { + Interface.CurrentInterface.HoverWidget = this; onMouseEnter (this, e); } for (int i = Children.Count - 1; i >= 0; i--) { diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs index 505bd69e..6b90b149 100644 --- a/src/GraphicObjects/Label.cs +++ b/src/GraphicObjects/Label.cs @@ -79,7 +79,7 @@ namespace Crow return; selColor = value; NotifyValueChanged ("SelectionBackground", selColor); - RegisterForGraphicUpdate (); + RegisterForRedraw (); } } [XmlAttributeAttribute][DefaultValue("White")] @@ -90,7 +90,7 @@ namespace Crow return; selFontColor = value; NotifyValueChanged ("SelectionForeground", selFontColor); - RegisterForGraphicUpdate (); + RegisterForRedraw (); } } [XmlAttributeAttribute][DefaultValue(Alignment.Left)] @@ -101,8 +101,7 @@ namespace Crow if (value == _textAlignment) return; _textAlignment = value; - RegisterForGraphicUpdate (); - RegisterForGraphicUpdate (); + RegisterForRedraw (); NotifyValueChanged ("TextAlignment", _textAlignment); } } @@ -113,7 +112,7 @@ namespace Crow if (horizontalStretch == value) return; horizontalStretch = value; - RegisterForGraphicUpdate (); + RegisterForRedraw (); NotifyValueChanged ("HorizontalStretch", horizontalStretch); } } @@ -124,8 +123,8 @@ namespace Crow if (verticalStretch == value) return; verticalStretch = value; + RegisterForRedraw (); NotifyValueChanged ("VerticalStretch", verticalStretch); - } } [XmlAttributeAttribute][DefaultValue("label")] @@ -147,9 +146,8 @@ namespace Crow lines = getLines; - this.RegisterForGraphicUpdate (); - this.RegisterForLayouting (LayoutingType.Sizing); NotifyValueChanged ("Text", _text); + this.RegisterForGraphicUpdate (); } } [XmlAttributeAttribute][DefaultValue(false)] diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs index 34834b8d..79efac33 100644 --- a/src/GraphicObjects/ListBox.cs +++ b/src/GraphicObjects/ListBox.cs @@ -141,7 +141,7 @@ namespace Crow using (Stream stream = Interface.GetStreamFromPath (ItemTemplate)) stream.CopyTo (templateStream); } - templateBaseType = Interface.GetTopContainerOfGOMLStream (templateStream); + templateBaseType = Interface.GetTopContainerOfXMLStream (templateStream); } lock (Interface.CurrentInterface.UpdateMutex) { diff --git a/src/GraphicObjects/TabView.cs b/src/GraphicObjects/TabView.cs index 5afcdaad..d5a07e58 100644 --- a/src/GraphicObjects/TabView.cs +++ b/src/GraphicObjects/TabView.cs @@ -183,8 +183,8 @@ namespace Crow #region Mouse handling public override void checkHoverWidget (MouseMoveEventArgs e) { - if (Interface.CurrentInterface.hoverWidget != this) { - Interface.CurrentInterface.hoverWidget = this; + if (Interface.CurrentInterface.HoverWidget != this) { + Interface.CurrentInterface.HoverWidget = this; onMouseEnter (this, e); } diff --git a/src/Interface.cs b/src/Interface.cs index dee5e146..07797a10 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -44,7 +44,8 @@ namespace Crow { #region CTOR static Interface(){ - Interface.LoadCursors (); + LoadCursors (); + LoadStyling (); FontRenderingOptions = new FontOptions (); FontRenderingOptions.Antialias = Antialias.Subpixel; @@ -54,12 +55,10 @@ namespace Crow } public Interface(){ Interface.CurrentInterface = this; - LoadStyling (); } #endregion #region Static and constants - internal bool XmlLoading = false; /// keep ressource path for debug msg internal static string CurrentGOMLPath = ""; //used in templatedControl @@ -87,32 +86,53 @@ namespace Crow public static FontOptions FontRenderingOptions; #endregion + internal bool XmlLoading = false; + public Queue LayoutingQueue = new Queue (); - public Queue GraphicUpdateQueue = new Queue(); - public Dictionary> Styling; - public string Clipboard; - public static void RegisterForGraphicUpdate(GraphicObject g) + public Queue DrawingQueue = new Queue(); + public string Clipboard;//TODO:use object instead for complex copy paste + public void EnqueueForRepaint(GraphicObject g) { - lock (CurrentInterface.GraphicUpdateQueue) { - if (g.IsQueueForGraphicUpdate) - return; - if (CurrentInterface == null) + lock (DrawingQueue) { + if (g.IsQueueForRedraw) return; - CurrentInterface.GraphicUpdateQueue.Enqueue (g); - g.IsQueueForGraphicUpdate = true; + DrawingQueue.Enqueue (g); + g.IsQueueForRedraw = true; } } - #region default values loading helpers + #region default values and style loading /// Default values of properties from GraphicObjects are retrieve from XML Attributes. /// The reflexion process used to retrieve those values being very slow, it is compiled in MSIL /// and injected as a dynamic method referenced in the DefaultValuesLoader Dictionnary. /// The compilation is done on the first object instancing, and is also done for custom widgets public delegate void loadDefaultInvoker(object instance); public static Dictionary DefaultValuesLoader = new Dictionary(); - #endregion + public static Dictionary> Styling; + /// parse all styling data's and build global Styling Dictionary + static void LoadStyling() { + System.Globalization.CultureInfo savedCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; + + Styling = new Dictionary> (); - public static void LoadCursors(){ + //fetch styling info in this order, if member styling is alreadey referenced in previous + //assembly, it's ignored. + loadStylingFromAssembly (Assembly.GetEntryAssembly ()); + loadStylingFromAssembly (Assembly.GetExecutingAssembly ()); + + Thread.CurrentThread.CurrentCulture = savedCulture; + } + /// Search for .style resources in assembly + static void loadStylingFromAssembly (Assembly assembly) { + foreach (string s in assembly + .GetManifestResourceNames () + .Where (r => r.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) { + new StyleReader (assembly, s) + .Dispose (); + } + } + static void LoadCursors(){ //Load cursors XCursor.Cross = XCursorFile.Load("#Crow.Images.Icons.Cursors.cross").Cursors[0]; XCursor.Default = XCursorFile.Load("#Crow.Images.Icons.Cursors.arrow").Cursors[0]; @@ -123,6 +143,8 @@ namespace Crow XCursor.H = XCursorFile.Load("#Crow.Images.Icons.Cursors.sb_h_double_arrow").Cursors[0]; XCursor.V = XCursorFile.Load("#Crow.Images.Icons.Cursors.sb_v_double_arrow").Cursors[0]; } + #endregion + #region Load/Save public static Stream GetStreamFromPath (string path) @@ -151,7 +173,7 @@ namespace Crow /// Pre-read first node to set GraphicObject class for loading /// and reset stream position to 0 /// - public static Type GetTopContainerOfGOMLStream (Stream stream) + public static Type GetTopContainerOfXMLStream (Stream stream) { string root = "Object"; stream.Seek (0, SeekOrigin.Begin); @@ -198,7 +220,7 @@ namespace Crow CurrentGOMLPath = path; GraphicObject tmp = null; using (Stream stream = GetStreamFromPath (path)) { - tmp = Load(stream, GetTopContainerOfGOMLStream(stream), hostClass); + tmp = Load(stream, GetTopContainerOfXMLStream(stream), hostClass); } Interface.XmlLoaderCount --; @@ -249,30 +271,6 @@ namespace Crow return tmp; } } - - public void LoadStyling() { - System.Globalization.CultureInfo savedCulture = Thread.CurrentThread.CurrentCulture; - Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; - - Styling = new Dictionary> (); - - //fetch styling info in this order, if member styling is alreadey referenced in previous - //assembly, it's ignored. - loadStylingFromAssembly (Assembly.GetEntryAssembly ()); - loadStylingFromAssembly (Assembly.GetExecutingAssembly ()); - - Thread.CurrentThread.CurrentCulture = savedCulture; - } - - void loadStylingFromAssembly (Assembly assembly) { - foreach (string s in assembly - .GetManifestResourceNames () - .Where (r => r.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) { - - StyleReader sr = new StyleReader (assembly, s); - sr.Dispose (); - } - } #endregion #if MEASURE_TIME @@ -283,12 +281,10 @@ namespace Crow #endif public List GraphicTree = new List(); - public Color Background = Color.Transparent; - internal static Interface currentWindow; public static Interface CurrentInterface; - Rectangles _redrawClip = new Rectangles();//should find another way to access it from child + Rectangles _redrawClip = new Rectangles(); Context ctx; Surface surf; @@ -330,7 +326,7 @@ namespace Crow #endif } } - public GraphicObject hoverWidget + public GraphicObject HoverWidget { get { return _hoverWidget; } set { @@ -380,24 +376,6 @@ namespace Crow processDrawing (); Monitor.Exit (UpdateMutex); - - // if (ToolTip.isVisible) { - // ToolTip.panel.processkLayouting(); - // if (ToolTip.panel.layoutIsValid) - // ToolTip.panel.Paint(ref ctx); - // } - // Debug.WriteLine("INTERFACE: layouting: {0} ticks \t graphical update {1} ticks \t drawing {2} ticks", - // layoutTime.ElapsedTicks, - // guTime.ElapsedTicks, - // drawingTime.ElapsedTicks); - // Debug.WriteLine("INTERFACE: layouting: {0} ms \t graphical update {1} ms \t drawing {2} ms", - // layoutTime.ElapsedMilliseconds, - // guTime.ElapsedMilliseconds, - // drawingTime.ElapsedMilliseconds); - - // Debug.WriteLine("UPDATE: {0} ticks \t, {1} ms", - // updateTime.ElapsedTicks, - // updateTime.ElapsedMilliseconds); } void processLayouting(){ #if MEASURE_TIME @@ -419,16 +397,16 @@ namespace Crow #if MEASURE_TIME clippingTime.Restart (); #endif - lock (CurrentInterface.GraphicUpdateQueue) { - while (CurrentInterface.GraphicUpdateQueue.Count > 0) { - GraphicObject g = CurrentInterface.GraphicUpdateQueue.Dequeue (); - g.bmp = null; - g.IsQueueForGraphicUpdate = false; + lock (CurrentInterface.DrawingQueue) { + while (CurrentInterface.DrawingQueue.Count > 0) { + GraphicObject g = CurrentInterface.DrawingQueue.Dequeue (); + g.IsQueueForRedraw = false; try { if (g.Parent == null) continue; g.Parent.RegisterClip (g.LastPaintedSlot); - g.Parent.RegisterClip (g.getSlot ()); + if (g.getSlot () != g.LastPaintedSlot) + g.Parent.RegisterClip (g.getSlot ()); } catch (Exception ex) { Debug.WriteLine ("Error Register Clip: " + ex.ToString ()); } @@ -519,7 +497,7 @@ namespace Crow { GraphicTree.Remove(g); GraphicTree.Insert(0, g); - //g.registerClipRect (); + EnqueueForRepaint (g); } } /// Remove all Graphic objects from top container @@ -596,10 +574,10 @@ namespace Crow return true; } - if (hoverWidget != null) { + if (HoverWidget != null) { //TODO, ensure object is still in the graphic tree //check topmost graphicobject first - GraphicObject tmp = hoverWidget; + GraphicObject tmp = HoverWidget; GraphicObject topc = null; while (tmp is GraphicObject) { topc = tmp; @@ -610,7 +588,7 @@ namespace Crow int i = 0; while (i < idxhw) { if (GraphicTree [i].MouseIsIn (e.Position)) { - hoverWidget.onMouseLeave (this, e); + HoverWidget.onMouseLeave (this, e); GraphicTree [i].checkHoverWidget (e); return true; } @@ -619,19 +597,19 @@ namespace Crow } - if (hoverWidget.MouseIsIn (e.Position)) { - hoverWidget.checkHoverWidget (e); + if (HoverWidget.MouseIsIn (e.Position)) { + HoverWidget.checkHoverWidget (e); return true; } else { - hoverWidget.onMouseLeave (this, e); + HoverWidget.onMouseLeave (this, e); //seek upward from last focused graph obj's - while (hoverWidget.Parent as GraphicObject != null) { - hoverWidget = hoverWidget.Parent as GraphicObject; - if (hoverWidget.MouseIsIn (e.Position)) { - hoverWidget.checkHoverWidget (e); + while (HoverWidget.Parent as GraphicObject != null) { + HoverWidget = HoverWidget.Parent as GraphicObject; + if (HoverWidget.MouseIsIn (e.Position)) { + HoverWidget.checkHoverWidget (e); return true; } else - hoverWidget.onMouseLeave (this, e); + HoverWidget.onMouseLeave (this, e); } } } @@ -645,7 +623,7 @@ namespace Crow return true; } } - hoverWidget = null; + HoverWidget = null; return false; } public bool ProcessMouseButtonUp(int button) @@ -671,10 +649,10 @@ namespace Crow Mouse.EnableBit (button); MouseButtonEventArgs e = new MouseButtonEventArgs () { Mouse = Mouse }; - if (hoverWidget == null) + if (HoverWidget == null) return false; - hoverWidget.onMouseDown(hoverWidget,new BubblingMouseButtonEventArg(e)); + HoverWidget.onMouseDown(HoverWidget,new BubblingMouseButtonEventArg(e)); if (FocusedWidget == null) return true; @@ -690,9 +668,9 @@ namespace Crow Mouse.SetScrollRelative (0, delta); MouseWheelEventArgs e = new MouseWheelEventArgs () { Mouse = Mouse, DeltaPrecise = delta }; - if (hoverWidget == null) + if (HoverWidget == null) return false; - hoverWidget.onMouseWheel (this, e); + HoverWidget.onMouseWheel (this, e); return true; } diff --git a/src/StyleReader.cs b/src/StyleReader.cs index 11174e29..92b24e2d 100644 --- a/src/StyleReader.cs +++ b/src/StyleReader.cs @@ -34,7 +34,6 @@ namespace Crow public StyleReader (Assembly assembly, string resId) : base(assembly.GetManifestResourceStream (resId)) { - Interface iface = Interface.CurrentInterface; string styleKey = resId.Substring (0, resId.Length - 6); string token = ""; List targetsClasses = new List (); @@ -105,11 +104,11 @@ namespace Crow string expression = token.Trim (); foreach (string tc in targetsClasses) { - if (!iface.Styling.ContainsKey (tc)) - iface.Styling [tc] = new Dictionary (); - else if (iface.Styling [tc].ContainsKey (currentProperty)) + if (!Interface.Styling.ContainsKey (tc)) + Interface.Styling [tc] = new Dictionary (); + else if (Interface.Styling [tc].ContainsKey (currentProperty)) continue; - iface.Styling [tc] [currentProperty] = expression; + Interface.Styling [tc] [currentProperty] = expression; } token = ""; } -- 2.47.3