From 9fa17cdc9487e3ba92ef467c0c6d5d9941530de1 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Sat, 30 Jan 2016 09:42:37 +0100 Subject: [PATCH] NUnit try, renaming, debugging and uniformizating --- Crow.csproj | 20 +- Crow.sln | 6 + Crow.userprefs | 26 +- Images/Icons/updown.svg | 33 +- Templates/{Checkbox.goml => CheckBox.goml} | 0 Templates/{Combobox.goml => ComboBox.goml} | 4 +- ...boboxOverlay.goml => ComboBoxOverlay.goml} | 0 Templates/Expandable.goml | 2 +- Templates/{Groupbox.goml => GroupBox.goml} | 2 +- Templates/{Listbox.goml => ListBox.goml} | 0 Templates/MessageBox.goml | 10 +- Templates/Popper.goml | 2 +- Templates/{Scrollbar.goml => ScrollBar.goml} | 0 Templates/Spinner.goml | 2 +- Tests/GOLIBTests.cs | 6 +- Tests/Interfaces/1.crow | 2 + Tests/Interfaces/2.crow | 34 ++ Tests/Interfaces/test1.goml | 1 - Tests/Interfaces/test4.goml | 34 +- Tests/Interfaces/testAll.goml | 4 +- Tests/Interfaces/testCheckbox.goml | 2 +- Tests/Interfaces/testCombobox.goml | 2 +- Tests/Interfaces/testExpandable.goml | 10 +- Tests/Interfaces/testGroupBox.goml | 4 +- Tests/Interfaces/testPopper.goml | 10 +- Tests/Interfaces/testScrollbar.goml | 3 +- Tests/Interfaces/testWindow.goml | 8 +- Tests/Interfaces/test_Listbox.goml | 2 +- Tests/Tests.csproj | 6 + UnitTest/ExpectedOutputs/0.png | Bin 0 -> 937 bytes UnitTest/ExpectedOutputs/1.png | Bin 0 -> 1366 bytes UnitTest/Interfaces/0.crow | 2 + UnitTest/Interfaces/1.crow | 7 + UnitTest/Interfaces/2.crow | 7 + UnitTest/NUnitCrowWindow.cs | 456 ++++++++++++++++++ UnitTest/Test.cs | 64 +++ UnitTest/UnitTest.csproj | 78 +++ UnitTest/packages.config | 4 + src/GraphicObjects/Button.cs | 4 +- .../{Checkbox.cs => CheckBox.cs} | 6 +- .../{Combobox.cs => ComboBox.cs} | 30 +- src/GraphicObjects/Expandable.cs | 12 +- .../{Groupbox.cs => GroupBox.cs} | 18 +- src/GraphicObjects/ListBox.cs | 2 +- src/GraphicObjects/MessageBox.cs | 12 +- src/GraphicObjects/Popper.cs | 21 +- .../{Scrollbar.cs => ScrollBar.cs} | 6 +- src/GraphicObjects/Slider.cs | 1 + src/GraphicObjects/TextBox.cs | 6 +- src/Interface.cs | 7 +- 50 files changed, 811 insertions(+), 167 deletions(-) rename Templates/{Checkbox.goml => CheckBox.goml} (100%) rename Templates/{Combobox.goml => ComboBox.goml} (81%) rename Templates/{ComboboxOverlay.goml => ComboBoxOverlay.goml} (100%) rename Templates/{Groupbox.goml => GroupBox.goml} (85%) rename Templates/{Listbox.goml => ListBox.goml} (100%) rename Templates/{Scrollbar.goml => ScrollBar.goml} (100%) create mode 100755 Tests/Interfaces/1.crow create mode 100755 Tests/Interfaces/2.crow create mode 100644 UnitTest/ExpectedOutputs/0.png create mode 100644 UnitTest/ExpectedOutputs/1.png create mode 100755 UnitTest/Interfaces/0.crow create mode 100755 UnitTest/Interfaces/1.crow create mode 100755 UnitTest/Interfaces/2.crow create mode 100644 UnitTest/NUnitCrowWindow.cs create mode 100644 UnitTest/Test.cs create mode 100644 UnitTest/UnitTest.csproj create mode 100644 UnitTest/packages.config rename src/GraphicObjects/{Checkbox.cs => CheckBox.cs} (89%) rename src/GraphicObjects/{Combobox.cs => ComboBox.cs} (90%) rename src/GraphicObjects/{Groupbox.cs => GroupBox.cs} (76%) rename src/GraphicObjects/{Scrollbar.cs => ScrollBar.cs} (90%) diff --git a/Crow.csproj b/Crow.csproj index 10a3514c..b65f3170 100644 --- a/Crow.csproj +++ b/Crow.csproj @@ -110,13 +110,11 @@ - - @@ -124,11 +122,13 @@ - - + + + + @@ -172,10 +172,8 @@ - - @@ -187,7 +185,6 @@ - @@ -195,9 +192,6 @@ - - - @@ -213,6 +207,12 @@ + + + + + + diff --git a/Crow.sln b/Crow.sln index c396e5dc..17b8e4a7 100644 --- a/Crow.sln +++ b/Crow.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.GOLib", "MonoDe EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Diagram", "..\MonoDevelop.Diagram\MonoDevelop.Diagram.csproj", "{232716B4-D19D-4FD7-B310-94A98FD926F0}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest", "UnitTest\UnitTest.csproj", "{7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Linux_x86 = Debug|Linux_x86 @@ -21,6 +23,10 @@ Global {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Linux_x86.Build.0 = Debug|Any CPU {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.ActiveCfg = Release|Any CPU {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.Build.0 = Release|Any CPU + {7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU + {7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Debug|Linux_x86.Build.0 = Debug|Any CPU + {7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Release|Linux_x86.ActiveCfg = Release|Any CPU + {7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Release|Linux_x86.Build.0 = Release|Any CPU {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.Build.0 = Debug|Any CPU {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.ActiveCfg = Release|Any CPU diff --git a/Crow.userprefs b/Crow.userprefs index 21fdf1d4..b554ec85 100644 --- a/Crow.userprefs +++ b/Crow.userprefs @@ -1,23 +1,15 @@  - + - - - - - - - - - - - - - - - - + + + + + + + + diff --git a/Images/Icons/updown.svg b/Images/Icons/updown.svg index a4d5fcb4..ce045245 100644 --- a/Images/Icons/updown.svg +++ b/Images/Icons/updown.svg @@ -14,7 +14,7 @@ version="1.1" inkscape:version="0.91 r13725" sodipodi:docname="updown.svg"> - - - - - - - - - + inkscape:current-layer="svg2" />--> - \ No newline at end of file diff --git a/Templates/ComboboxOverlay.goml b/Templates/ComboBoxOverlay.goml similarity index 100% rename from Templates/ComboboxOverlay.goml rename to Templates/ComboBoxOverlay.goml diff --git a/Templates/Expandable.goml b/Templates/Expandable.goml index 4e9a8540..740200ca 100755 --- a/Templates/Expandable.goml +++ b/Templates/Expandable.goml @@ -4,7 +4,7 @@ - diff --git a/Templates/Groupbox.goml b/Templates/GroupBox.goml similarity index 85% rename from Templates/Groupbox.goml rename to Templates/GroupBox.goml index 789cd60f..4f6035aa 100755 --- a/Templates/Groupbox.goml +++ b/Templates/GroupBox.goml @@ -5,6 +5,6 @@ - diff --git a/UnitTest/ExpectedOutputs/0.png b/UnitTest/ExpectedOutputs/0.png new file mode 100644 index 0000000000000000000000000000000000000000..acf96fa65b9b82b04689ca1bc7894770c62d8a1d GIT binary patch literal 937 zcmeAS@N?(olHy`uVBq!ia0y~yV4MKL9Be?5hW%z|fD~Jjx4R3&e-K=-cll%n2Ie?V z7srr_Id89SHlfItO{R5GMUeWeDJTkHMyS|sF8YL-G*iCF{$s9{qq@q z9EsZh@tfT;c7_jgSy&oe92h*vrOv%%EdMGjFUCCm#%1QbQ>;u5N(u}rOrz9j5Dc1B zP~^wokhT6L>-C80Dn=7M0R|yPMg_qkKus#HVhG9h*Khd$jEQ0we^md)z3(<##d(VJ gDD}!DkV!mMOn2^a#fPqBp9kW4y85}Sb4q9e0Bne(C;$Ke literal 0 HcmV?d00001 diff --git a/UnitTest/Interfaces/0.crow b/UnitTest/Interfaces/0.crow new file mode 100755 index 00000000..64d6db6d --- /dev/null +++ b/UnitTest/Interfaces/0.crow @@ -0,0 +1,2 @@ + + diff --git a/UnitTest/Interfaces/1.crow b/UnitTest/Interfaces/1.crow new file mode 100755 index 00000000..142d0721 --- /dev/null +++ b/UnitTest/Interfaces/1.crow @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/UnitTest/Interfaces/2.crow b/UnitTest/Interfaces/2.crow new file mode 100755 index 00000000..dcccba04 --- /dev/null +++ b/UnitTest/Interfaces/2.crow @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/UnitTest/NUnitCrowWindow.cs b/UnitTest/NUnitCrowWindow.cs new file mode 100644 index 00000000..0c73b8e7 --- /dev/null +++ b/UnitTest/NUnitCrowWindow.cs @@ -0,0 +1,456 @@ +#define MONO_CAIRO_DEBUG_DISPOSE + + +using System; +using System.Runtime.InteropServices; +using OpenTK; +using OpenTK.Graphics.OpenGL; +using OpenTK.Input; + +using System.Diagnostics; + +//using GGL; +using System.Threading; +using System.Collections.Generic; +using System.Linq; +using Cairo; + + +namespace Crow +{ + class NUnitCrowWindow : IValueChange, ILayoutable, IGOLibHost + { + #region IValueChange implementation + public event EventHandler ValueChanged; + public virtual void NotifyValueChanged(string MemberName, object _value) + { + ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value)); + } + #endregion + + public Rectangle ClientRectangle = new Rectangle(0,0,800,600); + public List GraphicObjects = new List(); + public Color Background = Color.Transparent; + + Rectangles _redrawClip = new Rectangles();//should find another way to access it from child + List _gobjsToRedraw = new List(); + + #region IGOLibHost implementation + public Rectangles redrawClip { + get { + return _redrawClip; + } + set { + _redrawClip = value; + } + } + + public List gobjsToRedraw { + get { + return _gobjsToRedraw; + } + set { + _gobjsToRedraw = value; + } + } + public void AddWidget(GraphicObject g) + { + g.Parent = this; + GraphicObjects.Insert (0, g); + + g.RegisterForLayouting ((int)LayoutingType.Sizing); + } + public void DeleteWidget(GraphicObject g) + { + g.Visible = false;//trick to ensure clip is added to refresh zone + g.ClearBinding(); + GraphicObjects.Remove (g); + } + public void PutOnTop(GraphicObject g) + { + if (GraphicObjects.IndexOf(g) > 0) + { + GraphicObjects.Remove(g); + GraphicObjects.Insert(0, g); + g.registerClipRect (); + } + } + public void Quit () + { + } + + #region focus + GraphicObject _activeWidget; //button is pressed on widget + GraphicObject _hoverWidget; //mouse is over + GraphicObject _focusedWidget; //has keyboard (or other perif) focus + + public GraphicObject activeWidget + { + get { return _activeWidget; } + set + { + if (_activeWidget == value) + return; + _activeWidget = value; + } + } + public GraphicObject hoverWidget + { + get { return _hoverWidget; } + set { _hoverWidget = value; } + } + public GraphicObject FocusedWidget { + get { return _focusedWidget; } + set { + if (_focusedWidget == value) + return; + if (_focusedWidget != null) + _focusedWidget.onUnfocused (this, null); + _focusedWidget = value; + if (_focusedWidget != null) + _focusedWidget.onFocused (this, null); + } + } + #endregion + + #endregion + + #region Events + //those events are raised only if mouse isn't in a graphic object + public event EventHandler MouseWheelChanged; + public event EventHandler MouseButtonUp; + public event EventHandler MouseButtonDown; + public event EventHandler MouseClick; + public event EventHandler MouseMove; + #endregion + + #region graphic contexte + Context ctx; + public Surface surf; + string testId; + #endregion + + #region update + public Stopwatch updateTime = new Stopwatch (); + public Stopwatch layoutTime = new Stopwatch (); + public Stopwatch guTime = new Stopwatch (); + public Stopwatch drawingTime = new Stopwatch (); + + public void Update () + { + guTime.Reset (); + updateTime.Restart (); + layoutTime.Restart (); + + ctx = new Context(surf); + + GraphicObject[] invGOList = new GraphicObject[GraphicObjects.Count]; + GraphicObjects.CopyTo (invGOList,0); + invGOList = invGOList.Reverse ().ToArray (); + + //Debug.WriteLine ("======= Layouting queue start ======="); + lock (Interface.LayoutingQueue) { + while (Interface.LayoutingQueue.Count > 0) { + // Stopwatch lqiProcTime = new Stopwatch (); + // lqiProcTime.Start (); + LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue (); + lqi.ProcessLayouting (); + // lqiProcTime.Stop (); + // if (lqiProcTime.ElapsedMilliseconds > 10) { + // Debug.WriteLine("lqi {2}: {0} ticks \t, {1} ms", + // updateTime.ElapsedTicks, + // updateTime.ElapsedMilliseconds, lqi.ToString()); + // } + } + } + + //final redraw clips should be added only when layout is completed among parents, + //that's why it take place in a second pass + GraphicObject[] gotr = new GraphicObject[gobjsToRedraw.Count]; + gobjsToRedraw.CopyTo (gotr); + gobjsToRedraw.Clear (); + foreach (GraphicObject p in gotr) { + p.registerClipRect (); + } + + layoutTime.Stop (); + guTime.Start (); + + lock (redrawClip) { + if (redrawClip.count > 0) { + // #if DEBUG_CLIP_RECTANGLE + // redrawClip.stroke (ctx, new Color(1.0,0,0,0.3)); + // #endif + redrawClip.clearAndClip (ctx);//rajouté après, tester si utile + + //Link.draw (ctx); + foreach (GraphicObject p in invGOList) { + if (p.Visible) { + drawingTime.Start (); + + ctx.Save (); + if (redrawClip.count > 0) { + Rectangles clip = redrawClip.intersectingRects (p.Slot); + + if (clip.count > 0) + p.Paint (ref ctx, clip); + } + ctx.Restore (); + + drawingTime.Stop (); + } + } + ctx.ResetClip (); + // #if DEBUG_CLIP_RECTANGLE + // redrawClip.stroke (ctx, Color.Red.AdjustAlpha(0.1)); + // #endif + redrawClip.Reset (); + } + } + guTime.Stop (); + updateTime.Stop (); + ctx.Dispose (); + Console.WriteLine("{3} => layout:{0,8} t\tdraw:{1,8} t\tupdate:{2,8} t", + layoutTime.ElapsedTicks, + guTime.ElapsedTicks, + updateTime.ElapsedTicks, + testId); +// Console.WriteLine("{3} => layout:{0}ms\tdraw{1}ms\tupdate:{2}ms", +// layoutTime.ElapsedMilliseconds, +// guTime.ElapsedMilliseconds, +// updateTime.ElapsedMilliseconds, +// testId); + surf.WriteToPng (@"ExpectedOutputs/" + testId + ".png"); + surf.WriteToPng (@"tmp.png"); + } + #endregion + + #region loading + public GraphicObject LoadTest (string id) + { + testId = id; + GraphicObject tmp = Interface.Load ("Interfaces/" + testId + ".crow", this); + AddWidget (tmp); + return tmp; + } + /// Remove all Graphic objects from top container + public void ClearInterface() + { + int i = 0; + while (GraphicObjects.Count>0) { + GraphicObject g = GraphicObjects [i]; + g.Visible = false; + g.ClearBinding (); + GraphicObjects.RemoveAt (0); + } + } + #endregion + + public NUnitCrowWindow (int width, int height) + { + ClientRectangle.Width = width; + ClientRectangle.Height = height; + + surf = new ImageSurface(Format.Argb32, ClientRectangle.Width, ClientRectangle.Height); + } + + int frameCpt = 0; + int idx = 0; + + + #region FPS + int _fps = 0; + + public int fps { + get { return _fps; } + set { + if (_fps == value) + return; + + _fps = value; + + if (_fps > fpsMax) { + fpsMax = _fps; + ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMax", fpsMax)); + } else if (_fps < fpsMin) { + fpsMin = _fps; + ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMin", fpsMin)); + } + + ValueChanged.Raise(this, new ValueChangeEventArgs ("fps", _fps)); + ValueChanged.Raise (this, new ValueChangeEventArgs ("update", + this.updateTime.ElapsedMilliseconds.ToString () + " ms")); + } + } + + public int fpsMin = int.MaxValue; + public int fpsMax = 0; + + void resetFps () + { + fpsMin = int.MaxValue; + fpsMax = 0; + _fps = 0; + } + //public string update = ""; + #endregion + + + #region Mouse Handling + void Mouse_Move(object sender, MouseMoveEventArgs e) + { + if (_activeWidget != null) { + //first, ensure object is still in the graphic tree + if (_activeWidget.TopContainer == null) { + activeWidget = null; + } else { + + //send move evt even if mouse move outside bounds + _activeWidget.onMouseMove (_activeWidget, e); + return; + } + } + + if (_hoverWidget != null) { + //first, ensure object is still in the graphic tree + if (_hoverWidget.TopContainer == null) { + hoverWidget = null; + } else { + //check topmost graphicobject first + GraphicObject tmp = _hoverWidget; + GraphicObject topc = null; + while (tmp is GraphicObject) { + topc = tmp; + tmp = tmp.Parent as GraphicObject; + } + int idxhw = GraphicObjects.IndexOf (topc); + if (idxhw != 0) { + int i = 0; + while (i < idxhw) { + if (GraphicObjects [i].MouseIsIn (e.Position)) { + _hoverWidget.onMouseLeave (this, e); + GraphicObjects [i].checkHoverWidget (e); + return; + } + i++; + } + } + + + if (_hoverWidget.MouseIsIn (e.Position)) { + _hoverWidget.checkHoverWidget (e); + return; + } else { + _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); + return; + } else + _hoverWidget.onMouseLeave (this, e); + } + } + } + } + + //top level graphic obj's parsing + for (int i = 0; i < GraphicObjects.Count; i++) { + GraphicObject g = GraphicObjects[i]; + if (g.MouseIsIn (e.Position)) { + g.checkHoverWidget (e); + PutOnTop (g); + return; + } + } + _hoverWidget = null; + MouseMove.Raise (this, e); + } + void Mouse_ButtonUp(object sender, MouseButtonEventArgs e) + { + if (_activeWidget == null) { + MouseButtonUp.Raise (this, e); + return; + } + + _activeWidget.onMouseButtonUp (this, e); + _activeWidget = null; + } + void Mouse_ButtonDown(object sender, MouseButtonEventArgs e) + { + if (_hoverWidget == null) { + MouseButtonDown.Raise (this, e); + return; + } + + GraphicObject g = _hoverWidget; + while (!g.Focusable) { + g = g.Parent as GraphicObject; + if (g == null) { + return; + } + } + + _activeWidget = g; + _activeWidget.onMouseButtonDown (this, e); + } + + void Mouse_WheelChanged(object sender, MouseWheelEventArgs e) + { + if (_hoverWidget == null) { + MouseWheelChanged.Raise (this, e); + return; + } + _hoverWidget.onMouseWheel (this, e); + } + #endregion + + #region keyboard Handling + void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e) + { + if (_focusedWidget == null) + return; + _focusedWidget.onKeyDown (sender, e); + } + #endregion + + #region ILayoutable implementation + + public void RegisterForLayouting (int layoutType) { throw new NotImplementedException (); } + public void UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); } + public Rectangle ContextCoordinates (Rectangle r) + { + return r; + } + public Rectangle ScreenCoordinates (Rectangle r) + { + return r; + } + + public ILayoutable Parent { + get { + return null; + } + set { + throw new NotImplementedException (); + } + } + Rectangle ILayoutable.ClientRectangle { + get { return new Size(this.ClientRectangle.Size.Width,this.ClientRectangle.Size.Height); } + } + public IGOLibHost TopContainer { + get { return this; } + } + + public Rectangle getSlot () + { + return ClientRectangle; + } + public Rectangle getBounds ()//redundant but fill ILayoutable implementation + { + return ClientRectangle; + } + #endregion + } +} \ No newline at end of file diff --git a/UnitTest/Test.cs b/UnitTest/Test.cs new file mode 100644 index 00000000..11555696 --- /dev/null +++ b/UnitTest/Test.cs @@ -0,0 +1,64 @@ +// +// Test.cs +// +// Author: +// Jean-Philippe Bruyère +// +// Copyright (c) 2016 jp +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using NUnit.Framework; +using System; +using Crow; +using System.IO; + +namespace UnitTest +{ + [TestFixture ()] + public class Test + { + NUnitCrowWindow win; + + [SetUp] + public void Init() + { + win = new NUnitCrowWindow (400,400); + } + + [Test ()] + [Category("Alignment")] + public void GraphicObject () + { + string[] tests = new string[] { "0","1" }; + + foreach (string s in tests) { + win.LoadTest (s); + win.Update (); + win.Update (); + byte[] model = File.ReadAllBytes("ExpectedOutputs/" + s + ".png"); + byte[] result = File.ReadAllBytes(@"tmp.png"); + + CollectionAssert.AreEqual (model, result); + + win.ClearInterface (); + } + } + + void testAlignment(GraphicObject g){ + g.HorizontalAlignment = HorizontalAlignment.Left; + + } + } +} + diff --git a/UnitTest/UnitTest.csproj b/UnitTest/UnitTest.csproj new file mode 100644 index 00000000..ddd53b61 --- /dev/null +++ b/UnitTest/UnitTest.csproj @@ -0,0 +1,78 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {7BAE4448-E8F4-48B3-BB11-FA78E7F4506B} + Library + UnitTest + UnitTest + v4.5 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + full + true + bin\Release + prompt + 4 + false + + + + + + ..\..\opentk\Binaries\OpenTK\Release\OpenTK.dll + + + + + + nunit + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + {C2980F9B-4798-4C05-99E2-E174810F7C7B} + Crow + + + + + + + \ No newline at end of file diff --git a/UnitTest/packages.config b/UnitTest/packages.config new file mode 100644 index 00000000..b183023e --- /dev/null +++ b/UnitTest/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/GraphicObjects/Button.cs b/src/GraphicObjects/Button.cs index c598c3e3..5d3e81ca 100644 --- a/src/GraphicObjects/Button.cs +++ b/src/GraphicObjects/Button.cs @@ -26,12 +26,12 @@ namespace Crow #endregion #region GraphicObject Overrides - [XmlAttributeAttribute()][DefaultValue(60)] + [XmlAttributeAttribute()][DefaultValue(50)] public override int Width { get { return base.Width; } set { base.Width = value; } } - [XmlAttributeAttribute()][DefaultValue(30)] + [XmlAttributeAttribute()][DefaultValue(20)] public override int Height { get { return base.Height; } set { base.Height = value; } diff --git a/src/GraphicObjects/Checkbox.cs b/src/GraphicObjects/CheckBox.cs similarity index 89% rename from src/GraphicObjects/Checkbox.cs rename to src/GraphicObjects/CheckBox.cs index 36181602..a08f9fdb 100644 --- a/src/GraphicObjects/Checkbox.cs +++ b/src/GraphicObjects/CheckBox.cs @@ -16,15 +16,15 @@ using System.ComponentModel; namespace Crow { - [DefaultTemplate("#Crow.Templates.Checkbox.goml")] - public class Checkbox : TemplatedControl + [DefaultTemplate("#Crow.Templates.CheckBox.goml")] + public class CheckBox : TemplatedControl { string caption; string image; bool isChecked; #region CTOR - public Checkbox() : base() + public CheckBox() : base() { } #endregion diff --git a/src/GraphicObjects/Combobox.cs b/src/GraphicObjects/ComboBox.cs similarity index 90% rename from src/GraphicObjects/Combobox.cs rename to src/GraphicObjects/ComboBox.cs index 473c10ff..5d9c8e97 100644 --- a/src/GraphicObjects/Combobox.cs +++ b/src/GraphicObjects/ComboBox.cs @@ -20,16 +20,16 @@ using System.Threading; namespace Crow { - [DefaultTemplate("#Crow.Templates.Combobox.goml")] - [DefaultOverlayTemplate("#Crow.Templates.ComboboxOverlay.goml")] - public class Combobox : TemplatedContainer + [DefaultTemplate("#Crow.Templates.ComboBox.goml")] + [DefaultOverlayTemplate("#Crow.Templates.ComboBoxOverlay.goml")] + public class ComboBox : TemplatedContainer { #region CTOR - public Combobox() : base(){ } + public ComboBox() : base(){ } #endregion bool _isPopped; - string text; + string caption; GraphicObject _overlay; Group _list; IList data; @@ -77,7 +77,7 @@ namespace Crow _itemTemplate = value; } } - [XmlAttributeAttribute][DefaultValue("#Crow.Templates.ComboboxOverlay.goml")] + [XmlAttributeAttribute][DefaultValue("#Crow.Templates.ComboBoxOverlay.goml")] public string OverlayTemplate { get { return _overlayTemplate; } set { @@ -109,9 +109,9 @@ namespace Crow SelectedItemChanged.Raise (this, new SelectionChangeEventArgs(_selectedItem)); if (SelectedItem == null) - Text = ""; + Caption = ""; else - Text = _selectedItem.ToString (); + Caption = _selectedItem.ToString (); } } public object SelectedItem{ @@ -125,9 +125,9 @@ namespace Crow SelectedItemChanged.Raise (this, new SelectionChangeEventArgs(_selectedItem)); if (SelectedItem == null) - Text = ""; + Caption = ""; else - Text = _selectedItem.ToString (); + Caption = _selectedItem.ToString (); } get { return _selectedItem; } @@ -243,13 +243,13 @@ namespace Crow } } [XmlAttributeAttribute()][DefaultValue("Combobox")] - public string Text { - get { return text; } + public string Caption { + get { return caption; } set { - if (text == value) + if (caption == value) return; - text = value; - NotifyValueChanged ("Text", text); + caption = value; + NotifyValueChanged ("Caption", caption); } } [XmlAttributeAttribute()][DefaultValue(false)] diff --git a/src/GraphicObjects/Expandable.cs b/src/GraphicObjects/Expandable.cs index 172406c2..f1e2bdeb 100644 --- a/src/GraphicObjects/Expandable.cs +++ b/src/GraphicObjects/Expandable.cs @@ -22,7 +22,7 @@ namespace Crow public class Expandable : TemplatedContainer { bool _isExpanded; - string title; + string caption; string image; Container _contentContainer; @@ -62,13 +62,13 @@ namespace Crow } [XmlAttributeAttribute()][DefaultValue("Expandable")] - public string Title { - get { return title; } + public string Caption { + get { return caption; } set { - if (title == value) + if (caption == value) return; - title = value; - NotifyValueChanged ("Title", title); + caption = value; + NotifyValueChanged ("Caption", caption); } } [XmlAttributeAttribute()][DefaultValue("#Crow.Images.Icons.expandable.svg")] diff --git a/src/GraphicObjects/Groupbox.cs b/src/GraphicObjects/GroupBox.cs similarity index 76% rename from src/GraphicObjects/Groupbox.cs rename to src/GraphicObjects/GroupBox.cs index e1f33d84..81bac117 100644 --- a/src/GraphicObjects/Groupbox.cs +++ b/src/GraphicObjects/GroupBox.cs @@ -18,14 +18,14 @@ using System.IO; namespace Crow { - [DefaultTemplate("#Crow.Templates.Groupbox.goml")] - public class Groupbox : TemplatedContainer + [DefaultTemplate("#Crow.Templates.GroupBox.goml")] + public class GroupBox : TemplatedContainer { - string title; + string caption; Container _contentContainer; #region CTOR - public Groupbox() : base(){} + public GroupBox() : base(){} #endregion #region Template overrides @@ -55,13 +55,13 @@ namespace Crow #endregion [XmlAttributeAttribute()][DefaultValue("Groupbox")] - public string Title { - get { return title; } + public string Caption { + get { return caption; } set { - if (title == value) + if (caption == value) return; - title = value; - NotifyValueChanged ("Title", title); + caption = value; + NotifyValueChanged ("Caption", caption); } } } diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs index 8d9880ad..a0ab540e 100644 --- a/src/GraphicObjects/ListBox.cs +++ b/src/GraphicObjects/ListBox.cs @@ -31,7 +31,7 @@ using System.Threading; namespace Crow { - [DefaultTemplate("#Crow.Templates.Listbox.goml")] + [DefaultTemplate("#Crow.Templates.ListBox.goml")] //[DefaultTemplate("#Crow.Templates.ItemTemplate.goml")] public class ListBox : TemplatedControl//, IXmlSerializable { diff --git a/src/GraphicObjects/MessageBox.cs b/src/GraphicObjects/MessageBox.cs index 40f48e4a..18c4afb3 100644 --- a/src/GraphicObjects/MessageBox.cs +++ b/src/GraphicObjects/MessageBox.cs @@ -54,16 +54,16 @@ namespace Crow } } #region GraphicObject overrides - [XmlAttributeAttribute][DefaultValue(350)] + [XmlAttributeAttribute][DefaultValue(250)] public override int Width { get { return base.Width; } set { base.Width = value; } } - [XmlAttributeAttribute][DefaultValue(150)] - public override int Height { - get { return base.Height; } - set { base.Height = value; } - } +// [XmlAttributeAttribute][DefaultValue(80)] +// public override int Height { +// get { return base.Height; } +// set { base.Height = value; } +// } [XmlAttributeAttribute()][DefaultValue(true)] public override bool Focusable { diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index 5842faf8..15a209ce 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -27,7 +27,7 @@ namespace Crow } #endregion bool _isPopped; - string title; + string caption; string image; GraphicObject _content; @@ -66,15 +66,16 @@ namespace Crow if (tc == null) return; Rectangle r = this.ScreenCoordinates (this.Slot); - if (e.LayoutType == LayoutingType.Width) { + if (((int)e.LayoutType & (int)LayoutingType.Width) > 0) { if (Content.Slot.Width < tc.ClientRectangle.Width) { if (r.Left + Content.Slot.Width > tc.ClientRectangle.Right) Content.Left = tc.ClientRectangle.Right - Content.Slot.Width; else Content.Left = r.Left; - }else + } else Content.Left = 0; - }else if (e.LayoutType == LayoutingType.Height) { + } + if (((int)e.LayoutType & (int)LayoutingType.Height) > 0) { if (Content.Slot.Height < tc.ClientRectangle.Height) { if (r.Bottom + Content.Slot.Height > tc.ClientRectangle.Bottom) Content.Top = r.Top - Content.Slot.Height; @@ -116,13 +117,13 @@ namespace Crow } [XmlAttributeAttribute()][DefaultValue("Popper")] - public string Title { - get { return title; } + public string Caption { + get { return caption; } set { - if (title == value) + if (caption == value) return; - title = value; - NotifyValueChanged ("Title", title); + caption = value; + NotifyValueChanged ("Caption", caption); } } [XmlAttributeAttribute()][DefaultValue("#Crow.Images.Icons.expandable.svg")] @@ -165,6 +166,7 @@ namespace Crow if (Content.Parent == null) tc.AddWidget (Content); tc.PutOnTop (Content); + _content_LayoutChanged (this, new LayoutChangeEventArgs (LayoutingType.Sizing)); } Pop.Raise (this, e); } @@ -182,6 +184,5 @@ namespace Crow IsPopped = !IsPopped; base.onMouseClick (sender, e); } - } } diff --git a/src/GraphicObjects/Scrollbar.cs b/src/GraphicObjects/ScrollBar.cs similarity index 90% rename from src/GraphicObjects/Scrollbar.cs rename to src/GraphicObjects/ScrollBar.cs index f68bdb77..905efc55 100644 --- a/src/GraphicObjects/Scrollbar.cs +++ b/src/GraphicObjects/ScrollBar.cs @@ -16,8 +16,8 @@ using System.ComponentModel; namespace Crow { - [DefaultTemplate("#Crow.Templates.Scrollbar.goml")] - public class Scrollbar : TemplatedControl, IValueChange + [DefaultTemplate("#Crow.Templates.ScrollBar.goml")] + public class ScrollBar : TemplatedControl, IValueChange { #region IValueChange implementation public event EventHandler ValueChanged; @@ -28,7 +28,7 @@ namespace Crow double _maximumScroll; double _scroll; - public Scrollbar() : base() + public ScrollBar() : base() { } diff --git a/src/GraphicObjects/Slider.cs b/src/GraphicObjects/Slider.cs index 97bc177f..7b44a93e 100644 --- a/src/GraphicObjects/Slider.cs +++ b/src/GraphicObjects/Slider.cs @@ -154,6 +154,7 @@ namespace Crow cursor.TopLeft = new Point ((int)(p1.X - r.Width / 2), r.Top + (int)(Value * unity)); } + cursor.Inflate (-1); } #region mouse handling diff --git a/src/GraphicObjects/TextBox.cs b/src/GraphicObjects/TextBox.cs index 097ecaa1..9fca2fea 100644 --- a/src/GraphicObjects/TextBox.cs +++ b/src/GraphicObjects/TextBox.cs @@ -12,16 +12,16 @@ using System.Runtime.InteropServices; namespace Crow { - public class TextBoxWidget : Label + public class TextBox : Label { #region CTOR - public TextBoxWidget(string _initialValue) + public TextBox(string _initialValue) : base(_initialValue) { } - public TextBoxWidget() + public TextBox() { } #endregion diff --git a/src/Interface.cs b/src/Interface.cs index c1713838..b6e5b3f1 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -112,8 +112,11 @@ namespace Crow if (path.StartsWith ("#")) { string resId = path.Substring (1); - stream = System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceStream (resId); - if (stream == null)//try to find ressource in golib assembly + //try/catch added to prevent nunit error + try { + stream = System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceStream (resId); + } catch (Exception ex) {} + if (stream == null)//try to find ressource in Crow assembly stream = System.Reflection.Assembly.GetExecutingAssembly ().GetManifestResourceStream (resId); if (stream == null) throw new Exception ("Resource not found: " + path); -- 2.47.3