From: Jean-Philippe Bruyère Date: Sat, 3 Feb 2018 05:38:35 +0000 (+0100) Subject: :book: use own compiled opentk and remove nuget config X-Git-Tag: v0.9.5-beta~188 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=15abb01100d6c25a4a404538850881bad1ce86ea;p=jp%2Fcrow.git :book: use own compiled opentk and remove nuget config --- diff --git a/.nuget/NuGet.config b/.nuget/NuGet.config deleted file mode 100644 index 97241036..00000000 --- a/.nuget/NuGet.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/.nuget/packages.config b/.nuget/packages.config deleted file mode 100644 index 16ef9b11..00000000 --- a/.nuget/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/Crow.csproj b/Crow.csproj index 4edb707b..3a8228ef 100644 --- a/Crow.csproj +++ b/Crow.csproj @@ -136,7 +136,6 @@ - @@ -213,6 +212,10 @@ + + + + @@ -365,6 +368,9 @@ + + Crow.DockingView.template + diff --git a/Crow.dll.config b/Crow.dll.config index ef7562ac..6341771d 100644 --- a/Crow.dll.config +++ b/Crow.dll.config @@ -6,6 +6,7 @@ + diff --git a/Images/Icons/expandable.svg b/Images/Icons/expandable.svg index f8ceb322..134d02e8 100644 --- a/Images/Icons/expandable.svg +++ b/Images/Icons/expandable.svg @@ -1,61 +1,11 @@ - - - - - - - image/svg+xml - - - - - - - - - - - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index f057bc1d..b83b6e28 100755 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -35,9 +35,9 @@ using System.Runtime.CompilerServices; [assembly: AssemblyConfiguration ("")] [assembly: AssemblyCompany ("Grand Tetra Software")] [assembly: AssemblyProduct ("Crow")] -[assembly: AssemblyCopyright ("Copyright (c) 2016 - Jean-Philippe Bruyère ")] +[assembly: AssemblyCopyright ("Copyright (c) 2018 - Jean-Philippe Bruyère ")] [assembly: AssemblyTrademark ("")] -[assembly: AssemblyCulture ("en-US")] +[assembly: AssemblyCulture ("")] // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". // The form "{Major}.{Minor}.*" will automatically update the build and revision, diff --git a/README.md b/README.md index 31893653..8d0bc2af 100644 --- a/README.md +++ b/README.md @@ -36,26 +36,32 @@ for easy c# code linking.

-You can visit the [Wiki](https://github.com/jpbruyere/Crow/wiki) or the [Project Site](https://jpbruyere.github.io/Crow/) -for documentation and tutorials. +For **documentation** and **tutorials** visit the [Wiki](https://github.com/jpbruyere/Crow/wiki) +or the [Project Site](https://jpbruyere.github.io/Crow/). Please report bugs and issues on [GitHub](https://github.com/jpbruyere/Crow/issues) ## Getting Start + ### Requirements -- [mono > 4.5](http://www.mono-project.com/) +- [mono > 4.5](http://www.mono-project.com/download/) - [Cairo Graphic Library](https://cairographics.org/) >= 1.10 - [rsvg library](https://developer.gnome.org/rsvg/) for svg rendering - [nuget](https://www.nuget.org/). + ### Building from source + _[Git](https://git-scm.com) has to be installed._ + ```bash git clone https://github.com/jpbruyere/Crow.git # Download source code from github cd Crow # Enter the source directory nuget restore Crow.sln # Restore nuget packages xbuild /p:Configuration=Release Crow.sln # Build with Mono ``` + ### Using nuget + * add [Crow.OpenTK NuGet package](https://www.nuget.org/packages/Crow.OpenTK/) to your project. * Derive **CrowWindow** class. * Load some widget in the **OnLoad** override with `CrowWindow.Load` . diff --git a/Templates/DirectoryView.template b/Templates/DirectoryView.template index bf3a6f46..148a7570 100755 --- a/Templates/DirectoryView.template +++ b/Templates/DirectoryView.template @@ -21,7 +21,7 @@ MouseEnter="{Foreground=DimGray}" MouseLeave="{Foreground=Transparent}"> - - - diff --git a/Tests/BasicTests.cs b/Tests/BasicTests.cs index 6adabf6c..9d8764f4 100644 --- a/Tests/BasicTests.cs +++ b/Tests/BasicTests.cs @@ -39,7 +39,7 @@ namespace Tests class BasicTests : CrowWindow { public BasicTests () - : base(800, 600,"test: press to toogle test files") + : base(1280, 800,"test: press to toogle test files") { } @@ -141,7 +141,7 @@ namespace Tests //testFiles = new string [] { @"Interfaces/Unsorted/testFileDialog.crow" }; //testFiles = new string [] { @"Interfaces/Divers/colorPicker.crow" }; - testFiles = new string [] { @"Interfaces/TemplatedContainer/testTabView.crow" }; + testFiles = new string [] { @"Interfaces/Divers/welcome.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 (); @@ -246,10 +246,13 @@ namespace Tests [STAThread] static void Main () { + TextWriterTraceListener listener = new TextWriterTraceListener ("listen.txt"); + Debug.Listeners.Add (listener); Console.WriteLine ("starting example"); BasicTests win = new BasicTests (); win.VSync = OpenTK.VSyncMode.Adaptive; win.Run (30); + listener.Dispose (); } protected override void OnUpdateFrame (OpenTK.FrameEventArgs e) { diff --git a/Tests/CrowWindow.cs b/Tests/CrowWindow.cs index 5e26c0df..9ef77483 100644 --- a/Tests/CrowWindow.cs +++ b/Tests/CrowWindow.cs @@ -185,13 +185,13 @@ namespace Crow #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; - public event EventHandler KeyboardKeyDown; - public event EventHandler KeyboardKeyUp; + public event EventHandler CrowMouseWheel; + public event EventHandler CrowMouseUp; + public event EventHandler CrowMouseDown; + public event EventHandler CrowMouseClick; + public event EventHandler CrowMouseMove; + public event EventHandler CrowKeyDown; + public event EventHandler CrowKeyUp; #endregion @@ -244,12 +244,13 @@ namespace Crow base.OnLoad(e); this.KeyPress += new EventHandler(OpenTKGameWindow_KeyPress); - Keyboard.KeyDown += new EventHandler(Keyboard_KeyDown); - Keyboard.KeyUp += new EventHandler(Keyboard_KeyUp); - Mouse.WheelChanged += new EventHandler(GL_Mouse_WheelChanged); - Mouse.ButtonDown += new EventHandler(GL_Mouse_ButtonDown); - Mouse.ButtonUp += new EventHandler(GL_Mouse_ButtonUp); - Mouse.Move += new EventHandler(GL_Mouse_Move); + KeyDown += new EventHandler(Keyboard_KeyDown); + KeyUp += new EventHandler(Keyboard_KeyUp); + + MouseWheel += new EventHandler(GL_Mouse_WheelChanged); + MouseDown += new EventHandler(GL_Mouse_ButtonDown); + MouseUp += new EventHandler(GL_Mouse_ButtonUp); + MouseMove += new EventHandler(GL_Mouse_Move); #if DEBUG Console.WriteLine("\n\n*************************************"); @@ -331,7 +332,7 @@ namespace Crow return; } if (focusedIdx < 0) - MouseMove.Raise (sender, otk_e); + CrowMouseMove.Raise (sender, otk_e); } protected virtual void GL_Mouse_ButtonUp(object sender, OpenTK.Input.MouseButtonEventArgs otk_e) { @@ -340,7 +341,7 @@ namespace Crow if (ifaceControl [focusedIdx].ProcessMouseButtonUp ((int)otk_e.Button)) return; } - MouseButtonUp.Raise (sender, otk_e); + CrowMouseUp.Raise (sender, otk_e); } protected virtual void GL_Mouse_ButtonDown(object sender, OpenTK.Input.MouseButtonEventArgs otk_e) { @@ -349,7 +350,7 @@ namespace Crow if (ifaceControl [focusedIdx].ProcessMouseButtonDown ((int)otk_e.Button)) return; } - MouseButtonDown.Raise (sender, otk_e); + CrowMouseDown.Raise (sender, otk_e); } protected virtual void GL_Mouse_WheelChanged(object sender, OpenTK.Input.MouseWheelEventArgs otk_e) { @@ -357,7 +358,7 @@ namespace Crow if (ifaceControl [focusedIdx].ProcessMouseWheelChanged (otk_e.DeltaPrecise)) return; } - MouseWheelChanged.Raise (sender, otk_e); + CrowMouseWheel.Raise (sender, otk_e); } protected virtual void Keyboard_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs otk_e) @@ -366,7 +367,7 @@ namespace Crow if (ifaceControl [focusedIdx].ProcessKeyDown((int)otk_e.Key)) return; } - KeyboardKeyDown.Raise (this, otk_e); + CrowKeyDown.Raise (this, otk_e); } protected virtual void Keyboard_KeyUp(object sender, OpenTK.Input.KeyboardKeyEventArgs otk_e) { @@ -374,7 +375,7 @@ namespace Crow if (ifaceControl [focusedIdx].ProcessKeyUp((int)otk_e.Key)) return; } - KeyboardKeyUp.Raise (this, otk_e); + CrowKeyUp.Raise (this, otk_e); } protected virtual void OpenTKGameWindow_KeyPress (object sender, OpenTK.KeyPressEventArgs e) { diff --git a/Tests/Hello3D.cs b/Tests/Hello3D.cs index c14a586e..48b95c5c 100644 --- a/Tests/Hello3D.cs +++ b/Tests/Hello3D.cs @@ -66,7 +66,7 @@ namespace Tests void initGL(){ GL.Enable (EnableCap.CullFace); GL.Enable (EnableCap.Blend); - GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); + GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); cube = vaoMesh.CreateCube (); texture = new Texture ("image/textest.png"); @@ -76,8 +76,8 @@ namespace Tests { base.OnLoad (e); - MouseMove += HelloCube_MouseMove; - MouseWheelChanged += Hello3D_MouseWheelChanged; + CrowMouseMove += HelloCube_MouseMove; + CrowMouseWheel += Hello3D_MouseWheelChanged; iface3D = Add3DInterface (800, 800, Matrix4.CreateScale (6f) * @@ -140,8 +140,8 @@ namespace Tests void Hello3D_MouseWheelChanged (object sender, OpenTK.Input.MouseWheelEventArgs e) { float speed = ZoomSpeed; - if (Keyboard[OpenTK.Input.Key.ControlLeft]) - speed *= 20.0f; + //if (Keyboard[OpenTK.Input.Key.ControlLeft]) + // speed *= 20.0f; eyeDist -= e.Delta * speed; if (eyeDist < zNear) diff --git a/Tests/HelloCube.cs b/Tests/HelloCube.cs index d44a9bff..c616acb3 100644 --- a/Tests/HelloCube.cs +++ b/Tests/HelloCube.cs @@ -52,7 +52,7 @@ namespace Tests void initGL(){ GL.Enable (EnableCap.CullFace); GL.Enable (EnableCap.Blend); - GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); + GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); cube = vaoMesh.CreateCube (); texture = new Texture ("image/textest.png"); diff --git a/Tests/OpenGL/Shader.cs b/Tests/OpenGL/Shader.cs index 6ae99b89..f91a982c 100644 --- a/Tests/OpenGL/Shader.cs +++ b/Tests/OpenGL/Shader.cs @@ -51,7 +51,7 @@ namespace Crow GeomSourcePath; #region Sources protected string _vertSource = @" - #version 330 + #version 300 es precision lowp float; uniform mat4 mvp; @@ -68,7 +68,7 @@ namespace Crow }"; protected string _fragSource = @" - #version 330 + #version 300 es precision lowp float; uniform sampler2D tex; diff --git a/Tests/Showcase.cs b/Tests/Showcase.cs index 67ef5eef..95df6a27 100644 --- a/Tests/Showcase.cs +++ b/Tests/Showcase.cs @@ -56,6 +56,7 @@ namespace Tests { base.OnLoad (e); + this.CrowKeyDown += Showcase_CrowKeyDown; GraphicObject g = Load ("#Tests.ui.showcase.crow"); g.DataSource = this; crowContainer = g.FindByName ("CrowContainer") as Container; @@ -65,6 +66,14 @@ namespace Tests hideError (); } + void Showcase_CrowKeyDown (object sender, OpenTK.Input.KeyboardKeyEventArgs e) + { + if (e.Key == OpenTK.Input.Key.Escape) { + Quit (null, null); + return; + } + } + void Dv_SelectedItemChanged (object sender, SelectionChangeEventArgs e) { FileSystemInfo fi = e.NewValue as FileSystemInfo; diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 38152f0b..2994acba 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -45,7 +45,7 @@ - $(SolutionDir)packages\OpenTK.2.0.0\lib\net20\OpenTK.dll + $(SolutionDir)libs\OpenTK.dll
@@ -195,14 +195,12 @@ PreserveNewest - PreserveNewest PreserveNewest - PreserveNewest diff --git a/libs/OpenTK.dll b/libs/OpenTK.dll new file mode 100644 index 00000000..370a45e3 Binary files /dev/null and b/libs/OpenTK.dll differ diff --git a/libs/OpenTK.dll.config b/libs/OpenTK.dll.config new file mode 100644 index 00000000..7098d39e --- /dev/null +++ b/libs/OpenTK.dll.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/BubblingMouseButtonEventArgs.cs b/src/BubblingMouseButtonEventArgs.cs index 0c8afd26..74939620 100644 --- a/src/BubblingMouseButtonEventArgs.cs +++ b/src/BubblingMouseButtonEventArgs.cs @@ -28,12 +28,13 @@ using System; namespace Crow { + /// + /// Store focused widget while bubbling mouse down event to the top + /// public class BubblingMouseButtonEventArg: MouseButtonEventArgs { public GraphicObject Focused; - public BubblingMouseButtonEventArg(MouseButtonEventArgs mbe) : base(mbe){ - - } + public BubblingMouseButtonEventArg(MouseButtonEventArgs mbe) : base(mbe){} } } diff --git a/src/Colors.cs b/src/Colors.cs index 7317516d..e62abb75 100644 --- a/src/Colors.cs +++ b/src/Colors.cs @@ -63,6 +63,9 @@ namespace Crow } #endregion + /// + /// color names dictionary + /// public static Dictionary ColorDic = new Dictionary(); internal string Name; @@ -154,7 +157,9 @@ namespace Crow } #endregion - + /// + /// compute the hue of the color + /// public double Hue { get { double min = Math.Min (R, Math.Min (G, B)); //Min. value of RGB @@ -185,11 +190,18 @@ namespace Crow return h; } } + /// + /// compute the saturation of the color + /// public double Saturation { get { return Math.Max (R, Math.Max (G, B)); //Max. value of RGB } } + /// + /// compute the RGB intensity of the color + /// + /// The value. public double Value { get { double min = Math.Min (R, Math.Min (G, B)); //Min. value of RGB @@ -203,6 +215,11 @@ namespace Crow { get { return new float[]{ (float)R, (float)G, (float)B, (float)A }; } } + /// + /// return a copy of the color with the alpha component modified + /// + /// new modified color + /// normalized alpha component public Color AdjustAlpha(double _A) { return new Color (this.R, this.G, this.B, _A); diff --git a/src/Command.cs b/src/Command.cs index b3f31ff0..ba95acc9 100644 --- a/src/Command.cs +++ b/src/Command.cs @@ -30,6 +30,9 @@ using System.ComponentModel; namespace Crow { + /// + /// helper class to bind in one step icon, caption, action, and validity tests to a controls + /// public class Command : IValueChange { #region IValueChange implementation @@ -41,6 +44,10 @@ namespace Crow #endregion #region CTOR + /// + /// Initializes a new instance of Command with the action pass as argument. + /// + /// action to excecute when command is triggered public Command (Action _executeAction) { execute = _executeAction; @@ -54,6 +61,9 @@ namespace Crow bool canExecute = true; #region Public properties + /// + /// if true, action defined in this command may be executed, + /// [XmlAttributeAttribute][DefaultValue(true)] public virtual bool CanExecute { get { return canExecute; } @@ -64,6 +74,9 @@ namespace Crow NotifyValueChanged ("CanExecute", canExecute); } } + /// + /// label to display in the bound control + /// [XmlAttributeAttribute][DefaultValue("Unamed Command")] public virtual string Caption { get { return caption; } @@ -75,6 +88,9 @@ namespace Crow } } + /// + /// Icon to display in the bound control + /// [XmlAttributeAttribute] public Picture Icon { get { return icon; } @@ -87,6 +103,9 @@ namespace Crow } #endregion + /// + /// trigger the execution of the command + /// public void Execute(){ if (execute != null && CanExecute) execute (); diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs index 000562d7..cb8b75b5 100644 --- a/src/CompilerServices/CompilerServices.cs +++ b/src/CompilerServices/CompilerServices.cs @@ -35,7 +35,7 @@ using System.Xml; using Crow.IML; -namespace Crow +namespace Crow.IML { public static class CompilerServices { diff --git a/src/Configuration.cs b/src/Configuration.cs index 8f89dbfc..39c3c9cb 100644 --- a/src/Configuration.cs +++ b/src/Configuration.cs @@ -32,6 +32,9 @@ using System.Threading; namespace Crow { + /// + /// single element of configuration + /// public class ConfigItem { Type type; internal object curVal; @@ -59,8 +62,26 @@ namespace Crow } } /// - /// Application wide Configuration utility + /// Application wide Configuration store utility + /// + /// configuration files are automatically stored in **_user/.config/appname/app.config_** on close and every minutes + /// if some items have changed. + /// New items are automaticaly added on first use. Configuration class expose one templated Get and one Templated Set, so + /// creating, storing and retrieving config items is simple as: + /// + /// ```csharp\n + /// //storing\n + /// Configuration.Set ("Option1", 42);\n + /// //loading\n + /// int op1 = Configuration.Get ("Option1");\n + /// ```\n /// + /// + /// **.config** file are simple text files with per line, a key/value pair of the form `option=value`. Keys have to be unique + /// in the application scope. + /// + /// When running the application for the first time, some default options may be necessary. Their can be defined + /// in a special embedded resource text file with the key '**appname.default.config**' public static class Configuration { volatile static bool isDirty = false; @@ -118,10 +139,19 @@ namespace Crow Thread.Sleep (1000); } } + /// + /// retrive the value of the configuration key given in parameter + /// + /// option name public static T Get(string key) { return !items.ContainsKey (key) ? default(T) : items [key].GetValue (); } + /// + /// store the value of the configuration key given in parameter + /// + /// option name + /// value for that option public static void Set(string key, T value) { if (!items.ContainsKey (key)) { diff --git a/src/Fill/Fill.cs b/src/Fill/Fill.cs index 06f248cc..d0a14f60 100644 --- a/src/Fill/Fill.cs +++ b/src/Fill/Fill.cs @@ -29,8 +29,16 @@ using System.Collections.Generic; namespace Crow { + /// + /// base class for drawing content to paint on backend + /// public abstract class Fill { + /// + /// set content of fill as source for drawing operations on the backend context + /// + /// backend context + /// drawing operation bounding box public abstract void SetAsSource (Cairo.Context ctx, Rectangle bounds = default(Rectangle)); public static object Parse (string s){ if (string.IsNullOrEmpty (s)) diff --git a/src/GraphicObjects/Button.cs b/src/GraphicObjects/Button.cs index f8697f91..5967d94e 100644 --- a/src/GraphicObjects/Button.cs +++ b/src/GraphicObjects/Button.cs @@ -38,6 +38,9 @@ using System.ComponentModel; namespace Crow { + /// + /// templated button control + /// public class Button : TemplatedContainer { #region CTOR diff --git a/src/GraphicObjects/CheckBox.cs b/src/GraphicObjects/CheckBox.cs index 3a63ba2c..8ff06a30 100644 --- a/src/GraphicObjects/CheckBox.cs +++ b/src/GraphicObjects/CheckBox.cs @@ -30,6 +30,9 @@ using System.Xml.Serialization; namespace Crow { + /// + /// templated checkbox control + /// public class CheckBox : TemplatedControl { #region CTOR diff --git a/src/GraphicObjects/ColorPicker.cs b/src/GraphicObjects/ColorPicker.cs index b47e8ffc..b6165c05 100644 --- a/src/GraphicObjects/ColorPicker.cs +++ b/src/GraphicObjects/ColorPicker.cs @@ -30,6 +30,9 @@ using System.ComponentModel; namespace Crow { + /// + /// templated color selector control + /// public class ColorPicker : TemplatedControl { #region CTOR diff --git a/src/GraphicObjects/ColorSelector.cs b/src/GraphicObjects/ColorSelector.cs index 4dfc68f6..cb33d502 100644 --- a/src/GraphicObjects/ColorSelector.cs +++ b/src/GraphicObjects/ColorSelector.cs @@ -30,6 +30,9 @@ using System.ComponentModel; namespace Crow { + /// + /// simple squarred rgb color selector + /// public class ColorSelector : GraphicObject { #region CTOR diff --git a/src/GraphicObjects/ComboBox.cs b/src/GraphicObjects/ComboBox.cs index 85a04608..fbb4b953 100644 --- a/src/GraphicObjects/ComboBox.cs +++ b/src/GraphicObjects/ComboBox.cs @@ -29,6 +29,9 @@ using System.Xml.Serialization; namespace Crow { + /// + /// templated control for selecting value in a pop up list + /// public class ComboBox : ListBox { #region CTOR diff --git a/src/GraphicObjects/Container.cs b/src/GraphicObjects/Container.cs index c7dfd78b..05d63012 100644 --- a/src/GraphicObjects/Container.cs +++ b/src/GraphicObjects/Container.cs @@ -33,6 +33,9 @@ using System.Threading; namespace Crow { + /// + /// simple container accepting one child + /// public class Container : PrivateContainer { #region CTOR diff --git a/src/GraphicObjects/DirectoryView.cs b/src/GraphicObjects/DirectoryView.cs index ab5d4aba..9b876d91 100644 --- a/src/GraphicObjects/DirectoryView.cs +++ b/src/GraphicObjects/DirectoryView.cs @@ -31,6 +31,9 @@ using System.IO; namespace Crow { + /// + /// templated directory viewer + /// public class DirectoryView : TemplatedControl { #region CTOR diff --git a/src/GraphicObjects/FileDialog.cs b/src/GraphicObjects/FileDialog.cs index 550e2eaf..76a5a9ee 100644 --- a/src/GraphicObjects/FileDialog.cs +++ b/src/GraphicObjects/FileDialog.cs @@ -35,6 +35,9 @@ using System.Text.RegularExpressions; namespace Crow { + /// + /// templated control for selecting files + /// public class FileDialog: Window { #region CTOR diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index e52485ac..f65447b1 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -31,6 +31,9 @@ using System; namespace Crow { + /// + /// group container that stacked its children horizontally or vertically + /// public class GenericStack : Group { #region CTOR diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index feea7520..2523810e 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -32,9 +32,8 @@ using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using Cairo; -using System.Linq; using System.Diagnostics; -using System.IO; +using Crow.IML; namespace Crow { @@ -188,6 +187,10 @@ namespace Crow protected object dataSource; string style; object tag; + bool isDragged; + bool allowDrag; + bool allowDrop; + #endregion #region public fields @@ -308,6 +311,8 @@ namespace Crow public event EventHandler Enabled; /// Occurs when the enabled state this object is set to false public event EventHandler Disabled; + public event EventHandler Dragged; + public event EventHandler Dropped; /// Occurs when one part of the rendering slot changed public event EventHandler LayoutChanged; /// Occurs when DataSource changed @@ -1008,6 +1013,77 @@ namespace Crow return false; } + #region Drag&Drop + [XmlAttributeAttribute][DefaultValue(false)] + public virtual bool AllowDrag { + get { return allowDrag; } + set { + if (allowDrag == value) + return; + allowDrag = value; + NotifyValueChanged ("AllowDrag", allowDrag); + } + } + [XmlAttributeAttribute][DefaultValue(false)] + public virtual bool AllowDrop { + get { return allowDrop; } + set { + if (allowDrop == value) + return; + allowDrop = value; + NotifyValueChanged ("AllowDrop", allowDrop); + } + } + +// public List AllowedDroppedTypes; +// public void AddAllowedDroppedType (Type newType){ +// if (AllowedDroppedTypes == null) +// AllowedDroppedTypes = new List (); +// AllowedDroppedTypes.Add (newType); +// NotifyValueChanged ("AllowDrop", AllowDrop); +// } +// [XmlIgnore]public virtual bool AllowDrop { +// get { return AllowedDroppedTypes?.Count>0; } +// } + [XmlIgnore]public virtual bool IsDragged { + get { return isDragged; } + set { + if (isDragged == value) + return; + isDragged = value; + + if (isDragged) { + CurrentInterface.HoverWidget = null; + onStartDrag (this, null); + } + + NotifyValueChanged ("IsDrag", IsDragged); + } + } + /// + /// start dragging + /// + protected virtual void onStartDrag (object sender, EventArgs e){ + Debug.WriteLine("DRAG => " + this.ToString()); + Dragged.Raise (this, null); + } + /// + /// Occured when dragging ends without dropping + /// + protected virtual void onEndDrag (object sender, EventArgs e){ + IsDragged = false; + Debug.WriteLine("END DRAG => " + this.ToString()); + } + /// + /// Dragging end with a dropping + /// + protected virtual void onDrop (object sender, EventArgs e){ + IsDragged = false; + Debug.WriteLine("DROPPED => " + this.ToString()); + Dropped.Raise (this, null); + } + #endregion + #region Queuing /// /// Register old and new slot for clipping @@ -1299,7 +1375,7 @@ namespace Crow #region Rendering /// This is the common overridable drawing routine to create new widget - protected virtual void onDraw(Context gr) + protected virtual void onDraw(Cairo.Context gr) { #if DEBUG_UPDATE Debug.WriteLine (string.Format("OnDraw -> {0}", this.ToString ())); @@ -1324,13 +1400,13 @@ namespace Crow if (bmp != null) bmp.Dispose (); bmp = new ImageSurface (Format.Argb32, Slot.Width, Slot.Height); - using (Context gr = new Context (bmp)) { + using (Cairo.Context gr = new Cairo.Context (bmp)) { gr.Antialias = Interface.Antialias; onDraw (gr); } bmp.Flush (); } - protected virtual void UpdateCache(Context ctx){ + protected virtual void UpdateCache(Cairo.Context ctx){ #if DEBUG_UPDATE Debug.WriteLine (string.Format("UpdateCache -> {0}", this.ToString ())); #endif @@ -1349,7 +1425,7 @@ namespace Crow } /// Chained painting routine on the parent context of the actual cached version /// of the widget - public virtual void Paint (ref Context ctx) + public virtual void Paint (ref Cairo.Context ctx) { #if DEBUG_UPDATE Debug.WriteLine (string.Format("Paint -> {0}", this.ToString ())); @@ -1385,7 +1461,7 @@ namespace Crow LastPaintedSlot = Slot; } } - void paintDisabled(Context gr, Rectangle rb){ + void paintDisabled(Cairo.Context gr, Rectangle rb){ gr.Operator = Operator.Xor; gr.SetSourceRGBA (0.6, 0.6, 0.6, 0.3); gr.Rectangle (rb); @@ -1410,7 +1486,7 @@ namespace Crow public virtual bool MouseIsIn(Point m) { try { - if (!(Visible & isEnabled)) + if (!(Visible & isEnabled)||IsDragged) return false; if (ScreenCoordinates (Slot).ContainsOrIsEqual (m)) { Scroller scr = Parent as Scroller; @@ -1437,6 +1513,9 @@ namespace Crow } public virtual void onMouseMove(object sender, MouseMoveEventArgs e) { + if (AllowDrag & !IsDragged & IsActive) + IsDragged = true; + //bubble event to the top GraphicObject p = Parent as GraphicObject; if (p != null) @@ -1468,6 +1547,18 @@ namespace Crow MouseDown.Raise (this, e); } public virtual void onMouseUp(object sender, MouseButtonEventArgs e){ + if (IsDragged){ + bool dropOK = false; + if (CurrentInterface.HoverWidget!=null) { + if (CurrentInterface.HoverWidget.AllowDrop) + dropOK = true; + } + if (dropOK) + onDrop (this, null); + else + onEndDrag (this, null); + } + //bubble event to the top GraphicObject p = Parent as GraphicObject; if (p != null) diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 551db889..2cfa3774 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -70,7 +70,7 @@ namespace Crow g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren); g.LayoutChanged += OnChildLayoutChanges; } - public virtual void RemoveChild(GraphicObject child) + public virtual void RemoveChild(GraphicObject child) { child.LayoutChanged -= OnChildLayoutChanges; //check if HoverWidget is removed from Tree @@ -87,7 +87,7 @@ namespace Crow searchLargestChild (); if (child == tallestChild && Height == Measure.Fit) searchTallestChild (); - + this.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren); } public virtual void ClearChildren() @@ -107,26 +107,26 @@ namespace Crow ChildrenCleared.Raise (this, new EventArgs ()); } -// public void putWidgetOnTop(GraphicObject w) -// { -// if (Children.Contains(w)) -// { -// lock (children) { -// Children.Remove (w); -// Children.Add (w); -// } -// } -// } -// public void putWidgetOnBottom(GraphicObject w) -// { -// if (Children.Contains(w)) -// { -// lock (children) { -// Children.Remove (w); -// Children.Insert (0, w); -// } -// } -// } + public void putWidgetOnTop(GraphicObject w) + { + if (Children.Contains(w)) + { + lock (children) { + Children.Remove (w); + Children.Add (w); + } + } + } + public void putWidgetOnBottom(GraphicObject w) + { + if (Children.Contains(w)) + { + lock (children) { + Children.Remove (w); + Children.Insert (0, w); + } + } + } #region GraphicObject overrides public override void OnDataSourceChanged (object sender, DataSourceChangeEventArgs e) @@ -185,7 +185,7 @@ namespace Crow } return base.measureRawSize (lt); } - + public override void OnLayoutChanges (LayoutingType layoutType) { base.OnLayoutChanges (layoutType); @@ -345,7 +345,7 @@ namespace Crow } } - + #region Mouse handling public override void checkHoverWidget (MouseMoveEventArgs e) { diff --git a/src/GraphicObjects/GroupBox.cs b/src/GraphicObjects/GroupBox.cs index d843f993..e5a170ae 100644 --- a/src/GraphicObjects/GroupBox.cs +++ b/src/GraphicObjects/GroupBox.cs @@ -30,6 +30,9 @@ using System.ComponentModel; namespace Crow { + /// + /// templated container accepting one child + /// public class GroupBox : TemplatedContainer { #region CTOR diff --git a/src/GraphicObjects/HorizontalStack.cs b/src/GraphicObjects/HorizontalStack.cs index 13ed4cb5..74e46e9c 100644 --- a/src/GraphicObjects/HorizontalStack.cs +++ b/src/GraphicObjects/HorizontalStack.cs @@ -32,6 +32,9 @@ using System.Xml.Serialization; namespace Crow { + /// + /// group control stacking its children horizontally + /// public class HorizontalStack : GenericStack { #region CTOR diff --git a/src/GraphicObjects/Image.cs b/src/GraphicObjects/Image.cs index 3ec49d37..622fa714 100644 --- a/src/GraphicObjects/Image.cs +++ b/src/GraphicObjects/Image.cs @@ -140,7 +140,7 @@ namespace Crow else pic = new BmpPicture (); - pic.LoadImage (path); + pic.Load (path); pic.Scaled = scaled; pic.KeepProportions = keepProps; diff --git a/src/GraphicObjects/MenuItem.cs b/src/GraphicObjects/MenuItem.cs index 5565ace3..cd2a54a8 100644 --- a/src/GraphicObjects/MenuItem.cs +++ b/src/GraphicObjects/MenuItem.cs @@ -156,7 +156,7 @@ namespace Crow } public override bool MouseIsIn (Point m) { - return IsEnabled ? base.MouseIsIn (m) || child.MouseIsIn (m) : false; + return IsEnabled && !IsDragged ? base.MouseIsIn (m) || child.MouseIsIn (m) : false; } public override void onMouseEnter (object sender, MouseMoveEventArgs e) { diff --git a/src/GraphicObjects/SaturationValueSelector.cs b/src/GraphicObjects/SaturationValueSelector.cs index fb3cbf48..8d726685 100644 --- a/src/GraphicObjects/SaturationValueSelector.cs +++ b/src/GraphicObjects/SaturationValueSelector.cs @@ -89,6 +89,7 @@ namespace Crow grad.SetAsSource (gr, r); CairoHelpers.CairoRectangle (gr, r, CornerRadius); gr.Fill(); + } public override void Paint (ref Context ctx) diff --git a/src/GraphicObjects/ScrollBar.cs b/src/GraphicObjects/ScrollBar.cs index 75a3b2db..586ebbbe 100644 --- a/src/GraphicObjects/ScrollBar.cs +++ b/src/GraphicObjects/ScrollBar.cs @@ -30,8 +30,13 @@ using System.ComponentModel; namespace Crow { + /// + /// templeted numeric control + /// public class ScrollBar : NumericControl { + //TODO:could be replaced by a template for a Slider + Orientation _orientation; #region CTOR diff --git a/src/GraphicObjects/Scroller.cs b/src/GraphicObjects/Scroller.cs index 7f7bd5de..b68335f6 100644 --- a/src/GraphicObjects/Scroller.cs +++ b/src/GraphicObjects/Scroller.cs @@ -32,6 +32,9 @@ using Cairo; namespace Crow { + /// + /// scrolling surface, to be contained in a smaller container in which it will be scrolled + /// public class Scroller : Container { #region CTOR diff --git a/src/GraphicObjects/ScrollingObject.cs b/src/GraphicObjects/ScrollingObject.cs index 3d8c942c..7e61c392 100644 --- a/src/GraphicObjects/ScrollingObject.cs +++ b/src/GraphicObjects/ScrollingObject.cs @@ -33,6 +33,9 @@ using Cairo; namespace Crow { + /// + /// generic class to build scrolling control in both directions + /// public class ScrollingObject : GraphicObject { #region CTOR diff --git a/src/GraphicObjects/Slider.cs b/src/GraphicObjects/Slider.cs index bf43f2fa..bc879a96 100644 --- a/src/GraphicObjects/Slider.cs +++ b/src/GraphicObjects/Slider.cs @@ -32,6 +32,10 @@ using System.Diagnostics; namespace Crow { + /// + /// templated numeric control to select a value + /// by slidding a cursor + /// public class Slider : NumericControl { #region CTOR diff --git a/src/GraphicObjects/Spinner.cs b/src/GraphicObjects/Spinner.cs index c29a2b27..69924a03 100644 --- a/src/GraphicObjects/Spinner.cs +++ b/src/GraphicObjects/Spinner.cs @@ -28,6 +28,10 @@ using System; namespace Crow { + /// + /// templated control for selecting a numeric value by clicking on + /// up and down buttons + /// public class Spinner : NumericControl { #region CTOR diff --git a/src/GraphicObjects/Splitter.cs b/src/GraphicObjects/Splitter.cs index dab3937b..1258012e 100644 --- a/src/GraphicObjects/Splitter.cs +++ b/src/GraphicObjects/Splitter.cs @@ -30,6 +30,10 @@ using System.ComponentModel; namespace Crow { + /// + /// control to add between children of a Stack to allow them to be resized + /// with the pointer + /// public class Splitter : GraphicObject { #region CTOR diff --git a/src/GraphicObjects/TabItem.cs b/src/GraphicObjects/TabItem.cs index afafb0f1..2fdc3802 100644 --- a/src/GraphicObjects/TabItem.cs +++ b/src/GraphicObjects/TabItem.cs @@ -140,7 +140,7 @@ namespace Crow #region Mouse Handling public override bool MouseIsIn (Point m) { - if (!Visible) + if (!(Visible & IsEnabled) || IsDragged) return false; bool mouseIsInTitle = TabTitle.ScreenCoordinates (TabTitle.Slot).ContainsOrIsEqual (m); diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs index dda03119..aaeb77f6 100644 --- a/src/GraphicObjects/TemplatedGroup.cs +++ b/src/GraphicObjects/TemplatedGroup.cs @@ -33,6 +33,7 @@ using System.ComponentModel; using System.Collections; using System.Threading; using System.Linq; +using Crow.IML; namespace Crow { diff --git a/src/GraphicObjects/VerticalStack.cs b/src/GraphicObjects/VerticalStack.cs index 23271624..d0122373 100644 --- a/src/GraphicObjects/VerticalStack.cs +++ b/src/GraphicObjects/VerticalStack.cs @@ -31,6 +31,9 @@ using System.Text; namespace Crow { + /// + /// group control stacking its children vertically + /// public class VerticalStack : GenericStack { public VerticalStack() : base(){} diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs index 336784e2..d1f34374 100644 --- a/src/GraphicObjects/Window.cs +++ b/src/GraphicObjects/Window.cs @@ -33,7 +33,7 @@ namespace Crow { public class Window : TemplatedContainer { - enum Direction + protected enum Direction { None, N, @@ -49,7 +49,7 @@ namespace Crow string _icon; bool _resizable; bool _movable; - bool hoverBorder = false; + protected bool hoverBorder = false; bool alwaysOnTop = false; Rectangle savedBounds; @@ -369,13 +369,13 @@ namespace Crow Minimize.Raise (sender, e); } - protected void onBorderMouseLeave (object sender, MouseMoveEventArgs e) + protected virtual void onBorderMouseLeave (object sender, MouseMoveEventArgs e) { hoverBorder = false; currentDirection = Direction.None; CurrentInterface.MouseCursor = XCursor.Default; } - protected void onBorderMouseEnter (object sender, MouseMoveEventArgs e) + protected virtual void onBorderMouseEnter (object sender, MouseMoveEventArgs e) { hoverBorder = true; } diff --git a/src/GraphicObjects/Wrapper.cs b/src/GraphicObjects/Wrapper.cs index 81dce154..cfa1736f 100644 --- a/src/GraphicObjects/Wrapper.cs +++ b/src/GraphicObjects/Wrapper.cs @@ -28,6 +28,10 @@ using System; namespace Crow { + /// + /// group control that arrange its children in a direction and jump to + /// the next line or row when no room is left + /// public class Wrapper : GenericStack { #region CTOR diff --git a/src/IML/BindingMember.cs b/src/IML/BindingMember.cs index ddeccbd9..7aaa851c 100644 --- a/src/IML/BindingMember.cs +++ b/src/IML/BindingMember.cs @@ -27,14 +27,16 @@ using System; using System.Reflection.Emit; -namespace Crow +namespace Crow.IML { /// - /// Expression token, a variable, a string constant or a parsable constant (having a static Parse method) - /// '../' => 1 level up in graphic tree - /// './' or '/' => template root level - /// '.Name1.Name2' current level properties - /// 'name.prop' named descendant in graphic tree, search with 'FindByName' method of GraphicObject + /// Binding expression parser. + /// + /// Valid tokens in binding expression: + /// - '../' => 1 level up in graphic tree + /// - './' or '/' => template root level + /// - '.Name1.Name2' current level properties + /// - 'name.prop' named descendant in graphic tree, search with 'FindByName' method of GraphicObject /// public class BindingMember { @@ -71,7 +73,14 @@ namespace Crow public bool IsSingleName { get { return LevelsUp == 0 && Tokens.Length == 1; }} #region CTOR + /// + /// Initializes a new instance of BindingMember. + /// public BindingMember (){} + /// + /// Initializes a new instance of BindingMember by parsing the string passed as argument + /// + /// binding expression public BindingMember (string expression){ if (string.IsNullOrEmpty (expression)) return; @@ -104,6 +113,11 @@ namespace Crow } #endregion + /// + /// Emits the MSIL instructions to get the target of the binding expression + /// + /// current MSIL generator + /// cancel branching in MSIL if something go wrong public void emitGetTarget(ILGenerator il, System.Reflection.Emit.Label cancel){ if (IsTemplateBinding) { @@ -145,6 +159,11 @@ namespace Crow il.Emit (OpCodes.Brfalse, cancel); } } + /// + /// Emit the MSIL instructions to get the target property of the binding expression + /// + /// current MSIL generator + /// cancel branching in MSIL if something go wrong public void emitGetProperty(ILGenerator il, System.Reflection.Emit.Label cancel) { System.Reflection.Emit.Label miOK = il.DefineLabel (); il.Emit (OpCodes.Dup);//duplicate instance @@ -157,6 +176,10 @@ namespace Crow il.MarkLabel (miOK); il.Emit (OpCodes.Call, CompilerServices.miGetValWithRefx); } + /// + /// Emit the MSIL instructions to set the target property of the binding expression + /// + /// current MSIL generator public void emitSetProperty(ILGenerator il) { il.Emit (OpCodes.Ldstr, Tokens [Tokens.Length -1]);//load member name il.Emit (OpCodes.Call, CompilerServices.miSetValWithRefx); diff --git a/src/Instantiator.cs b/src/Instantiator.cs index ed3a4f07..a1012e2b 100644 --- a/src/Instantiator.cs +++ b/src/Instantiator.cs @@ -137,7 +137,7 @@ namespace Crow /// Parses IML and build a dynamic method that will be used to instanciate one or multiple occurence of the IML file or fragment /// void parseIML (XmlTextReader reader) { - Context ctx = new Context (findRootType (reader)); + IMLContext ctx = new IMLContext (findRootType (reader)); ctx.nodesStack.Push (new Node (ctx.RootType)); emitLoader (reader, ctx); @@ -175,7 +175,7 @@ namespace Crow throw new Exception ("IML parsing error: undefined root type (" + root + ")"); return t; } - void emitLoader (XmlTextReader reader, Context ctx) + void emitLoader (XmlTextReader reader, IMLContext ctx) { string tmpXml = reader.ReadOuterXml (); @@ -192,7 +192,7 @@ namespace Crow /// /// Loading Context /// xml fragment - void emitTemplateLoad (Context ctx, string tmpXml) { + void emitTemplateLoad (IMLContext ctx, string tmpXml) { //if its a template, first read template elements using (XmlTextReader reader = new XmlTextReader (tmpXml, XmlNodeType.Element, null)) { List itemTemplateIds = new List (); @@ -278,7 +278,7 @@ namespace Crow /// /// parsing context /// xml fragment - void emitGOLoad (Context ctx, string tmpXml) { + void emitGOLoad (IMLContext ctx, string tmpXml) { using (XmlTextReader reader = new XmlTextReader (tmpXml, XmlNodeType.Element, null)) { reader.Read (); @@ -340,7 +340,7 @@ namespace Crow /// /// Parse child node an generate corresponding msil /// - void readChildren (XmlTextReader reader, Context ctx, int startingIdx = 0) + void readChildren (XmlTextReader reader, IMLContext ctx, int startingIdx = 0) { bool endTagReached = false; int nodeIdx = startingIdx; @@ -392,7 +392,7 @@ namespace Crow } #endregion - void readPropertyBinding (Context ctx, string sourceMember, string expression) + void readPropertyBinding (IMLContext ctx, string sourceMember, string expression) { NodeAddress sourceNA = ctx.CurrentNodeAddress; BindingDefinition bindingDef = sourceNA.GetBindingDef (sourceMember, expression); @@ -439,7 +439,7 @@ namespace Crow /// Compile events expression in IML attributes, and store the result in the instanciator /// Those handlers will be bound when instatiing /// - void compileAndStoreDynHandler (Context ctx, EventInfo sourceEvent, string expression) + void compileAndStoreDynHandler (IMLContext ctx, EventInfo sourceEvent, string expression) { //store event handler dynamic method in instanciator int dmIdx = cachedDelegates.Count; @@ -447,7 +447,7 @@ namespace Crow ctx.emitCachedDelegateHandlerAddition(dmIdx, sourceEvent); } /// Emits handler method bindings - void emitHandlerBinding (Context ctx, EventInfo sourceEvent, string expression){ + void emitHandlerBinding (IMLContext ctx, EventInfo sourceEvent, string expression){ NodeAddress currentNode = ctx.CurrentNodeAddress; BindingDefinition bindingDef = currentNode.GetBindingDef (sourceEvent.Name, expression); @@ -526,7 +526,7 @@ namespace Crow /// those delegates uses grtree functions to set destination value so they don't /// need to be bound to destination instance as in the ancient system. /// - void emitBindingDelegates(Context ctx){ + void emitBindingDelegates(IMLContext ctx){ foreach (KeyValuePair>> bindings in ctx.Bindings ) { if (bindings.Key.Count == 0)//template binding emitTemplateBindings (ctx, bindings.Value); @@ -534,7 +534,7 @@ namespace Crow emitPropertyBindings (ctx, bindings.Key, bindings.Value); } } - void emitPropertyBindings(Context ctx, NodeAddress origine, Dictionary> bindings){ + void emitPropertyBindings(IMLContext ctx, NodeAddress origine, Dictionary> bindings){ Type origineNodeType = origine.NodeType; //value changed dyn method @@ -634,7 +634,7 @@ namespace Crow #endif } - void emitTemplateBindings(Context ctx, Dictionary> bindings){ + void emitTemplateBindings(IMLContext ctx, Dictionary> bindings){ //value changed dyn method DynamicMethod dm = new DynamicMethod ("dyn_tmpValueChanged", typeof (void), CompilerServices.argsValueChange, true); @@ -786,7 +786,7 @@ namespace Crow /// /// create the valuechanged handler, the datasourcechanged handler and emit event handling /// - void emitDataSourceBindings(Context ctx, BindingDefinition bindingDef){ + void emitDataSourceBindings(IMLContext ctx, BindingDefinition bindingDef){ DynamicMethod dm = null; ILGenerator il = null; int dmVC = 0; diff --git a/src/Interface.cs b/src/Interface.cs index 7d691152..15c6de35 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -749,7 +749,8 @@ namespace Crow //TODO, ensure object is still in the graphic tree //send move evt even if mouse move outside bounds ActiveWidget.onMouseMove (this, e); - return true; + if (!ActiveWidget.IsDragged)//if active is dragged, process mouse move as it was not visible. + return true; } if (HoverWidget != null) { diff --git a/src/ItemTemplate.cs b/src/ItemTemplate.cs index fc7d9063..d866bc19 100644 --- a/src/ItemTemplate.cs +++ b/src/ItemTemplate.cs @@ -34,6 +34,7 @@ using System.Xml; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using Crow.IML; namespace Crow {