From: Jean-Philippe Bruyère Date: Tue, 28 Jan 2020 06:24:29 +0000 (+0100) Subject: unit test with iFace updates (layouting/clipping/drawing), chmod clean X-Git-Tag: v0.9.5-beta~135 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=90015b93cd8d06f35d211ce65e2c9000e5fb4336;p=jp%2Fcrow.git unit test with iFace updates (layouting/clipping/drawing), chmod clean --- diff --git a/.gitignore b/.gitignore index d68b5a50..bff27cf1 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ packages src/GraphicObjects/Panel.cs src/GraphicObjects/VerticalWrappingWidget.cs src/GraphicObjects/HorizontalWrappingWidget.cs +TestResult.xml diff --git a/Crow.ControlsLib/Templates/AnalogMeter0.goml b/Crow.ControlsLib/Templates/AnalogMeter0.goml old mode 100755 new mode 100644 diff --git a/Crow.ControlsLib/Templates/Checkbox2.goml b/Crow.ControlsLib/Templates/Checkbox2.goml old mode 100755 new mode 100644 diff --git a/Crow.ControlsLib/Templates/DockingView.template b/Crow.ControlsLib/Templates/DockingView.template old mode 100755 new mode 100644 diff --git a/Crow.ControlsLib/Templates/ListBox.template b/Crow.ControlsLib/Templates/ListBox.template old mode 100755 new mode 100644 diff --git a/Crow.ControlsLib/Templates/Popper.template b/Crow.ControlsLib/Templates/Popper.template old mode 100755 new mode 100644 diff --git a/Crow.ControlsLib/Templates/RadioButton.template b/Crow.ControlsLib/Templates/RadioButton.template old mode 100755 new mode 100644 diff --git a/Crow.ControlsLib/Templates/ScrollBar.template b/Crow.ControlsLib/Templates/ScrollBar.template old mode 100755 new mode 100644 diff --git a/Crow.ControlsLib/Templates/Slider.template b/Crow.ControlsLib/Templates/Slider.template old mode 100755 new mode 100644 diff --git a/Crow.ControlsLib/Templates/Spinner (copier).goml b/Crow.ControlsLib/Templates/Spinner (copier).goml old mode 100755 new mode 100644 diff --git a/Crow.ControlsLib/Templates/Spinner.template b/Crow.ControlsLib/Templates/Spinner.template old mode 100755 new mode 100644 diff --git a/Crow.ControlsLib/Templates/ToolWindow.template b/Crow.ControlsLib/Templates/ToolWindow.template old mode 100755 new mode 100644 diff --git a/Crow.ControlsLib/Templates/Window.template b/Crow.ControlsLib/Templates/Window.template old mode 100755 new mode 100644 diff --git a/Crow.ControlsLib/Templates/imgItemTemplate.goml b/Crow.ControlsLib/Templates/imgItemTemplate.goml old mode 100755 new mode 100644 diff --git a/Crow.ControlsLib/Templates/tmpDirItem.goml b/Crow.ControlsLib/Templates/tmpDirItem.goml old mode 100755 new mode 100644 diff --git a/Crow.ControlsLib/Templates/treeList.crow b/Crow.ControlsLib/Templates/treeList.crow old mode 100755 new mode 100644 diff --git a/Crow.sln b/Crow.sln index df89d910..428cd52f 100644 --- a/Crow.sln +++ b/Crow.sln @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrowIDE", "CrowIDE\CrowIDE. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "unitTests", "unitTests\unitTests.csproj", "{0CC6DFAB-2E4A-4786-976C-89053D5EA6A2}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicTests", "Samples\BasicTests\BasicTests.csproj", "{7AEB6DD5-916E-4415-84E1-78EC6E5881CE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -39,6 +41,11 @@ Global {1E5C7065-28F9-4A1A-A2FB-DB5E03A63CB3}.Release|Any CPU.ActiveCfg = Release|Any CPU {0CC6DFAB-2E4A-4786-976C-89053D5EA6A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0CC6DFAB-2E4A-4786-976C-89053D5EA6A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0CC6DFAB-2E4A-4786-976C-89053D5EA6A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7AEB6DD5-916E-4415-84E1-78EC6E5881CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7AEB6DD5-916E-4415-84E1-78EC6E5881CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7AEB6DD5-916E-4415-84E1-78EC6E5881CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7AEB6DD5-916E-4415-84E1-78EC6E5881CE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution Policies = $0 @@ -82,5 +89,6 @@ Global {F535A8AB-CD93-49AB-B1B0-FFF9AE51ED6A} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6} {56329D48-D382-4850-93DE-59C453894E8A} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6} {91F1CE07-EECE-4F1D-A3EE-7239B563654A} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6} + {7AEB6DD5-916E-4415-84E1-78EC6E5881CE} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6} EndGlobalSection EndGlobal diff --git a/Crow/Crow.csproj b/Crow/Crow.csproj index 85b4ae96..36349716 100644 --- a/Crow/Crow.csproj +++ b/Crow/Crow.csproj @@ -1,8 +1,8 @@ - netstandard2.0 - + + net472 0.8.0 $(ReleaseVersion) @@ -20,7 +20,9 @@ https://opensource.org/licenses/MIT crow.png Copyright 2013-2019 - + + This release should solve most of ms dotnet exception, the win32 backend is + still untested. Next beta will have a glfw backend. True @@ -37,12 +39,13 @@ full - DEBUG;TRACE;_DEBUG_DISPOSE;_DEBUG_BINDING;DESIGN_MODE;_DEBUG_CLIP_RECTANGLE;_DEBUG_FOCUS;_DEBUG_DRAGNDROP + DEBUG;TRACE;_DEBUG_DISPOSE;_DEBUG_BINDING;DESIGN_MODE;_DEBUG_CLIP_RECTANGLE;_DEBUG_FOCUS;_DEBUG_DRAGNDROP;_DEBUG_LOG true + diff --git a/Crow/Icons/IconAlerte.svg b/Crow/Icons/IconAlerte.svg old mode 100755 new mode 100644 diff --git a/Crow/Images/Icons/buttonB.svg b/Crow/Images/Icons/buttonB.svg old mode 100755 new mode 100644 diff --git a/Crow/Images/meter.svg b/Crow/Images/meter.svg old mode 100755 new mode 100644 diff --git a/Crow/Templates/ArrowBut.template b/Crow/Templates/ArrowBut.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/Button.template b/Crow/Templates/Button.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/CheckBox.template b/Crow/Templates/CheckBox.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/ColorPicker.template b/Crow/Templates/ColorPicker.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/ColorPicker2.template b/Crow/Templates/ColorPicker2.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/ComboBox.template b/Crow/Templates/ComboBox.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/DefaultItem.template b/Crow/Templates/DefaultItem.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/DirectoryView.template b/Crow/Templates/DirectoryView.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/DockWindow.template b/Crow/Templates/DockWindow.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/EnumSelector.template b/Crow/Templates/EnumSelector.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/Expandable.template b/Crow/Templates/Expandable.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/GroupBox.template b/Crow/Templates/GroupBox.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/HScrollBar.template b/Crow/Templates/HScrollBar.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/ListBox.template b/Crow/Templates/ListBox.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/Popper.template b/Crow/Templates/Popper.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/RadioButton.template b/Crow/Templates/RadioButton.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/ScrollBar.template b/Crow/Templates/ScrollBar.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/Slider.template b/Crow/Templates/Slider.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/Spinner.template b/Crow/Templates/Spinner.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/ToolWindow.template b/Crow/Templates/ToolWindow.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/Window.template b/Crow/Templates/Window.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/imgItem.template b/Crow/Templates/imgItem.template old mode 100755 new mode 100644 diff --git a/Crow/Templates/treeList.template b/Crow/Templates/treeList.template old mode 100755 new mode 100644 diff --git a/Crow/src/Enums.cs b/Crow/src/Enums.cs index ea163608..4c55d451 100644 --- a/Crow/src/Enums.cs +++ b/Crow/src/Enums.cs @@ -86,12 +86,20 @@ namespace Crow SW, SE, } + /// + /// Cursor shape use in Sliders + /// public enum CursorType { + /// Only Background of cursor will be drawm, you may use a bmp, svg, or shape as background for custom shape. + None, Rectangle, Circle, Pentagone } + /// + /// Color component used in color widgets + /// public enum ColorComponent { Red, diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index 9a94d703..d201a714 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -83,17 +83,19 @@ namespace Crow FontRenderingOptions.HintStyle = HintStyle.Full; FontRenderingOptions.SubpixelOrder = SubpixelOrder.Default; } - - public Interface(int width=800, int height=600, IBackend _backend = null){ + public Interface(int width=800, int height=600, IBackend _backend = null, bool startUIThread = true) { CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; CurrentInterface = this; clientRectangle = new Rectangle (0, 0, width, height); backend = _backend; - Thread t = new Thread (InterfaceThread) { - IsBackground = true - }; - t.Start (); + if (startUIThread) { + Thread t = new Thread (InterfaceThread) { + IsBackground = true + }; + t.Start (); + } + #if MEASURE_TIME PerfMeasures.Add (updateMeasure); PerfMeasures.Add (drawingMeasure); @@ -404,7 +406,7 @@ namespace Crow if (path.StartsWith ("#", StringComparison.Ordinal)) { string resId = path.Substring (1); - stream = Assembly.GetEntryAssembly ().GetManifestResourceStream (resId); + stream = Assembly.GetEntryAssembly ()?.GetManifestResourceStream (resId); if (stream != null) return stream; string assemblyName = resId.Split ('.') [0]; @@ -474,13 +476,11 @@ namespace Crow /// path of the iml file to load public Widget Load (string path) { - Monitor.Enter (UpdateMutex); - - Widget tmp = CreateInstance (path); - AddWidget (tmp); - - Monitor.Exit (UpdateMutex); - return tmp; + lock (UpdateMutex) { + Widget tmp = CreateInstance (path); + AddWidget (tmp); + return tmp; + } } /// /// Create an instance of a GraphicObject linked to this interface but not added to the GraphicTree @@ -489,11 +489,11 @@ namespace Crow /// path of the iml file to load public virtual Widget CreateInstance (string path) { - //try { + try { return GetInstantiator (path).CreateInstance (); - //} catch (Exception ex) { - // throw new Exception ("Error loading <" + path + ">:", ex); - //} + } catch (Exception ex) { + throw new Exception ("Error loading <" + path + ">:", ex); + } } /// /// Create an instance of a GraphicObject linked to this interface but not added to the GraphicTree @@ -1148,25 +1148,36 @@ namespace Crow return true; } - public virtual void OnKeyPress (char c) + public virtual bool OnKeyPress (char c) { - _focusedWidget?.onKeyPress (_focusedWidget, new KeyPressEventArgs (c)); + if (_focusedWidget == null) + return false; + _focusedWidget.onKeyPress (_focusedWidget, new KeyPressEventArgs (c)); + return true; } - public virtual void OnKeyUp (Key key) + public virtual bool OnKeyUp (Key key) { - _focusedWidget?.onKeyUp (_focusedWidget, new KeyEventArgs (key, false)); + if (_focusedWidget == null) + return false; + _focusedWidget.onKeyUp (_focusedWidget, new KeyEventArgs (key, false)); + return true; + + // if (keyboardRepeatThread != null) { // keyboardRepeatOn = false; // keyboardRepeatThread.Abort(); // keyboardRepeatThread.Join (); // } } - public virtual void OnKeyDown (Key key) + public virtual bool OnKeyDown (Key key) { //Keyboard.SetKeyState((Crow.Key)Key,true); lastKeyDownEvt = new KeyEventArgs (key, true); - _focusedWidget?.onKeyDown (_focusedWidget, new KeyEventArgs (key, false)); + if (_focusedWidget == null) + return false; + _focusedWidget.onKeyDown (_focusedWidget, new KeyEventArgs (key, false)); + return true; // keyboardRepeatThread = new Thread (keyboardRepeatThreadFunc); // keyboardRepeatThread.IsBackground = true; diff --git a/Crow/src/LayoutingQueueItem.cs b/Crow/src/LayoutingQueueItem.cs index 98c04ecc..23556d2b 100644 --- a/Crow/src/LayoutingQueueItem.cs +++ b/Crow/src/LayoutingQueueItem.cs @@ -1,28 +1,6 @@ -// -// LayoutingQueueItem.cs +// Copyright (c) 2013-2020 Jean-Philippe Bruyère // -// Author: -// Jean-Philippe Bruyère -// -// Copyright (c) 2013-2017 Jean-Philippe Bruyère -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; using System.Diagnostics; @@ -67,8 +45,8 @@ namespace Crow Deleted, } public Result result; - public GraphicObject graphicObject { - get { return Layoutable as GraphicObject; } + public Widget graphicObject { + get { return Layoutable as Widget; } } public string Name { get { return graphicObject.Name; } @@ -94,8 +72,8 @@ namespace Crow LayoutingTries = 0; DiscardCount = 0; #if DEBUG_LOG - Slot = Rectangle.Empty; - NewSlot = Rectangle.Empty; + Slot = Rectangle.Zero; + NewSlot = Rectangle.Zero; result = Result.Register; DebugLog.AddEvent (DbgEvtType.GORegisterLayouting, this); #endif diff --git a/Crow/src/Widgets/PrivateContainer.cs b/Crow/src/Widgets/PrivateContainer.cs index 9f2dbdc5..fc5cb348 100644 --- a/Crow/src/Widgets/PrivateContainer.cs +++ b/Crow/src/Widgets/PrivateContainer.cs @@ -36,7 +36,7 @@ namespace Crow #endif protected Widget child; #if DEBUG_LOG - internal GraphicObject getTemplateRoot { + internal Widget getTemplateRoot { get { return child; } } #endif diff --git a/Crow/src/Widgets/Slider.cs b/Crow/src/Widgets/Slider.cs index c4caadb7..54ad33fa 100644 --- a/Crow/src/Widgets/Slider.cs +++ b/Crow/src/Widgets/Slider.cs @@ -3,6 +3,7 @@ // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using Crow.Cairo; +using System; using System.ComponentModel; namespace Crow @@ -37,6 +38,7 @@ namespace Crow int _cursorSize; Fill _cursorColor; Orientation _orientation; + CursorType cursorType; bool holdCursor = false; #endregion @@ -78,20 +80,19 @@ namespace Crow NotifyValueChanged ("Orientation", _orientation); } } + [DefaultValue (CursorType.Rectangle)] + public CursorType CursorType { + get => cursorType; + set { + if (cursorType == value) + return; + cursorType = value; + NotifyValueChanged ("CursorType", cursorType); + RegisterForRedraw (); + } + } #endregion - //[DefaultValue(10.0)] - //public override double Maximum { - // get { return base.Maximum; } - // set { - // if (value == base.Maximum) - // return; - // base.Maximum = value; - // LargeIncrement = base.Maximum / 10.0; - // SmallIncrement = LargeIncrement / 5.0; - // } - //} - #region GraphicObject Overrides protected override void onDraw (Context gr) { @@ -141,14 +142,26 @@ namespace Crow } protected virtual void DrawCursor(Context gr, Rectangle _cursor) { - CairoHelpers.CairoRectangle (gr, _cursor, CornerRadius); - Foreground.SetAsSource(gr, _cursor); - gr.StrokePreserve(); - CursorColor.SetAsSource(gr, _cursor); + if (cursorType != CursorType.None) { + switch (CursorType) { + case CursorType.Rectangle: + CairoHelpers.CairoRectangle (gr, _cursor, CornerRadius); + break; + case CursorType.Circle: + gr.Arc (_cursor.CenterD, 0.5 * _cursorSize, 0, Math.PI * 2.0); + break; + case CursorType.Pentagone: + break; + } + Foreground.SetAsSource (gr, _cursor); + gr.StrokePreserve (); + } + + CursorColor.SetAsSource(gr, _cursor); gr.Fill(); } - void computeCursorPosition() + void computeCursorPosition () { Rectangle r = ClientRectangle; PointD p1; @@ -229,5 +242,5 @@ namespace Crow base.onMouseMove (sender, e); } #endregion - } + } } diff --git a/Crow/src/Widgets/TemplatedControl.cs b/Crow/src/Widgets/TemplatedControl.cs index 962337de..32796c8a 100644 --- a/Crow/src/Widgets/TemplatedControl.cs +++ b/Crow/src/Widgets/TemplatedControl.cs @@ -118,7 +118,7 @@ namespace Crow if (!IFace.DefaultTemplates.ContainsKey (mdTok)) { string defTmpId = this.GetType ().FullName + ".template"; - Stream s = Assembly.GetEntryAssembly ().GetManifestResourceStream (defTmpId); + Stream s = Assembly.GetEntryAssembly ()?.GetManifestResourceStream (defTmpId); if (s == null) s = Assembly.GetAssembly (this.GetType ()).GetManifestResourceStream (defTmpId); if (s == null) diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index fee189b7..0ca6598b 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -176,7 +176,7 @@ namespace Crow #endregion #if DEBUG_LOG - internal static List GraphicObjects = new List(); + internal static List GraphicObjects = new List(); #endif //internal bool isPopup = false; diff --git a/Crow/src/backends/xlib/X11Keyboard.cs b/Crow/src/backends/xlib/X11Keyboard.cs index c73a2ee2..ebb24ddc 100644 --- a/Crow/src/backends/xlib/X11Keyboard.cs +++ b/Crow/src/backends/xlib/X11Keyboard.cs @@ -1,28 +1,7 @@ -// -// XCBKeyboard.cs +// Copyright (c) 2013-2020 Jean-Philippe Bruyère // -// Author: -// Jean-Philippe Bruyère -// -// Copyright (c) 2013-2017 Jean-Philippe Bruyère -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + using System; using System.Runtime.InteropServices; diff --git a/Crow/src/backends/xlib/XLibBackend.cs b/Crow/src/backends/xlib/XLibBackend.cs index 544296a3..6b11d3db 100644 --- a/Crow/src/backends/xlib/XLibBackend.cs +++ b/Crow/src/backends/xlib/XLibBackend.cs @@ -1,28 +1,7 @@ -// -// XLibBackend.cs +// Copyright (c) 2020 Jean-Philippe Bruyère // -// Author: -// Jean-Philippe Bruyère -// -// Copyright (c) 2013-2017 Jean-Philippe Bruyère -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + using System; using System.Diagnostics; using System.Runtime.InteropServices; diff --git a/Crow/src/debug/DbgEventTypeColors.cs b/Crow/src/debug/DbgEventTypeColors.cs index 1936704e..fdcfbd94 100644 --- a/Crow/src/debug/DbgEventTypeColors.cs +++ b/Crow/src/debug/DbgEventTypeColors.cs @@ -30,7 +30,7 @@ using System.Linq; namespace Crow { #if DEBUG_LOG - public class DbgEventTypeColors : GraphicObject + public class DbgEventTypeColors : Widget { protected override void onDraw (Context gr) { diff --git a/Crow/src/debug/DebugLogger.cs b/Crow/src/debug/DebugLogger.cs index f1eaf9c8..bfe1948f 100644 --- a/Crow/src/debug/DebugLogger.cs +++ b/Crow/src/debug/DebugLogger.cs @@ -91,15 +91,15 @@ namespace Crow public override string ToString () { - GraphicObject go = data as GraphicObject; + Widget go = data as Widget; if (go != null) - return string.Format ("{0};{1};{2};{3}", begin, end, type, GraphicObject.GraphicObjects.IndexOf(go).ToString()); + return string.Format ("{0};{1};{2};{3}", begin, end, type, Widget.GraphicObjects.IndexOf(go).ToString()); if (!(data is LayoutingQueueItem)) return string.Format ("{0};{1};{2}", begin, end, type); LayoutingQueueItem lqi = (LayoutingQueueItem)data; if (type == DbgEvtType.GOProcessLayouting) - return string.Format ("{0};{1};{2};{3};{4};{5}", begin, end, type, GraphicObject.GraphicObjects.IndexOf(lqi.graphicObject).ToString(), lqi.LayoutType.ToString(), lqi.result.ToString()); - return string.Format ("{0};{1};{2};{3};{4}", begin, end, type, GraphicObject.GraphicObjects.IndexOf(lqi.graphicObject).ToString(), lqi.LayoutType.ToString()); + return string.Format ("{0};{1};{2};{3};{4};{5}", begin, end, type, Widget.GraphicObjects.IndexOf(lqi.graphicObject).ToString(), lqi.LayoutType.ToString(), lqi.result.ToString()); + return string.Format ("{0};{1};{2};{3};{4}", begin, end, type, Widget.GraphicObjects.IndexOf(lqi.graphicObject).ToString(), lqi.LayoutType.ToString()); } } @@ -127,7 +127,7 @@ namespace Crow static int y, level; - static void parseTree (GraphicObject go) { + static void parseTree (Widget go) { if (go == null) return; @@ -137,7 +137,7 @@ namespace Crow Group gr = go as Group; if (gr != null) { - foreach (GraphicObject g in gr.Children) { + foreach (Widget g in gr.Children) { parseTree (g); } } else { @@ -152,15 +152,15 @@ namespace Crow y = 1; level = 0; - foreach (GraphicObject go in iface.GraphicTree) + foreach (Widget go in iface.GraphicTree) parseTree (go); using (StreamWriter s = new StreamWriter("debug.log")){ s.WriteLine ("[GraphicObjects]"); - lock (GraphicObject.GraphicObjects) { - GraphicObject.GraphicObjects = GraphicObject.GraphicObjects.OrderBy (o => o.yIndex).ToList(); - for (int i = 0; i < GraphicObject.GraphicObjects.Count; i++) { - GraphicObject g = GraphicObject.GraphicObjects [i]; + lock (Widget.GraphicObjects) { + Widget.GraphicObjects = Widget.GraphicObjects.OrderBy (o => o.yIndex).ToList(); + for (int i = 0; i < Widget.GraphicObjects.Count; i++) { + Widget g = Widget.GraphicObjects [i]; s.WriteLine ("{0};{1};{2};{3}", i, g.GetType ().Name, g.yIndex, g.xLevel); } } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs old mode 100755 new mode 100644 diff --git a/Samples/BasicTests/BasicTests.cs b/Samples/BasicTests/BasicTests.cs new file mode 100644 index 00000000..1360b652 --- /dev/null +++ b/Samples/BasicTests/BasicTests.cs @@ -0,0 +1,220 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using Crow; + +namespace tests +{ + public class BasicTests : Interface + { + [STAThread] + static void Main () + { + using (BasicTests app = new BasicTests ()) { + app.Run (); + } + } + + protected override void Startup () + { + Commands = new List (new Crow.Command [] { + new Crow.Command(new Action(() => command1())) { Caption = "command1"}, + new Crow.Command(new Action(() => command2())) { Caption = "command2"}, + new Crow.Command(new Action(() => command3())) { Caption = "command3"}, + new Crow.Command(new Action(() => command4())) { Caption = "command4"}, + }); + + // += KeyboardKeyDown1; + + //testFiles = new string [] { @"Interfaces/Experimental/testDock.crow" }; + testFiles = new string [] { @"Interfaces/Divers/welcome.crow" }; + //testFiles = new string [] { @"Interfaces/Divers/testSlider.crow" }; + //testFiles = new string [] { @"Interfaces/Divers/colorPicker.crow" }; + testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.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/TemplatedControl", "*.crow")).ToArray (); + testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedContainer", "*.crow")).ToArray (); + testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedGroup", "*.crow")).ToArray (); + testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Splitter", "*.crow")).ToArray (); + testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Wrapper", "*.crow")).ToArray (); + testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Divers", "*.crow")).ToArray (); + testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/DragAndDrop", "*.crow")).ToArray (); + //testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Experimental", "*.crow")).ToArray (); + + Load (testFiles [idx]).DataSource = this; + } + + int idx = 0; + string [] testFiles; + + public Version CrowVersion { + get { + return System.Reflection.Assembly.GetAssembly (typeof (Widget)).GetName ().Version; + } + } + + public override bool OnKeyDown (Key key) + { + try { + switch (key) { + case Key.Escape: + Quit (); + break; + case Key.F2: + idx--; + break; + case Key.F3: + idx++; + break; + case Key.F1: + TestList.Add ("new string"); + NotifyValueChanged ("TestList", TestList); + break; + case Key.F4: + Load ("Interfaces/TemplatedContainer/testWindow.goml").DataSource = this; + return false; + case Key.F5: + Load ("Interfaces/Divers/testFileDialog.crow").DataSource = this; + return false; + case Key.F6: + Load ("Interfaces/Divers/0.crow").DataSource = this; + return false; + case Key.F7: + Load ("Interfaces/Divers/perfMeasures.crow").DataSource = this; + return false; + default: + return base.OnKeyDown (key); + } + + ClearInterface (); + + if (idx == testFiles.Length) + idx = 0; + else if (idx < 0) + idx = testFiles.Length - 1; + + Console.WriteLine ($"Loading {testFiles [idx]}."); + + Load (testFiles [idx]).DataSource = this; + } catch (Exception ex) { + (LoadIMLFragment ($"