diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-02-03 06:38:35 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-02-03 06:38:35 +0100 |
| commit | c686be8c88d33ff397e24c2b7d6e2d2240b2f64b (patch) | |
| tree | 7ab4e3c3f8bfb058f91d6859098504538fffaf10 /src | |
| parent | 11e428d0a8933bca79f0b674d5b10590be60dbbd (diff) | |
:book: use own compiled opentk and remove nuget config
Diffstat (limited to 'src')
37 files changed, 320 insertions, 64 deletions
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 { + /// <summary> + /// Store focused widget while bubbling mouse down event to the top + /// </summary> 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 + /// <summary> + /// color names dictionary + /// </summary> public static Dictionary<string, Color> ColorDic = new Dictionary<string, Color>(); internal string Name; @@ -154,7 +157,9 @@ namespace Crow } #endregion - + /// <summary> + /// compute the hue of the color + /// </summary> 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; } } + /// <summary> + /// compute the saturation of the color + /// </summary> public double Saturation { get { return Math.Max (R, Math.Max (G, B)); //Max. value of RGB } } + /// <summary> + /// compute the RGB intensity of the color + /// </summary> + /// <value>The value.</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 }; } } + /// <summary> + /// return a copy of the color with the alpha component modified + /// </summary> + /// <returns>new modified color</returns> + /// <param name="_A">normalized alpha component</param> 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 { + /// <summary> + /// helper class to bind in one step icon, caption, action, and validity tests to a controls + /// </summary> public class Command : IValueChange { #region IValueChange implementation @@ -41,6 +44,10 @@ namespace Crow #endregion #region CTOR + /// <summary> + /// Initializes a new instance of Command with the action pass as argument. + /// </summary> + /// <param name="_executeAction">action to excecute when command is triggered</param> public Command (Action _executeAction) { execute = _executeAction; @@ -54,6 +61,9 @@ namespace Crow bool canExecute = true; #region Public properties + /// <summary> + /// if true, action defined in this command may be executed, + /// </summary> [XmlAttributeAttribute][DefaultValue(true)] public virtual bool CanExecute { get { return canExecute; } @@ -64,6 +74,9 @@ namespace Crow NotifyValueChanged ("CanExecute", canExecute); } } + /// <summary> + /// label to display in the bound control + /// </summary> [XmlAttributeAttribute][DefaultValue("Unamed Command")] public virtual string Caption { get { return caption; } @@ -75,6 +88,9 @@ namespace Crow } } + /// <summary> + /// Icon to display in the bound control + /// </summary> [XmlAttributeAttribute] public Picture Icon { get { return icon; } @@ -87,6 +103,9 @@ namespace Crow } #endregion + /// <summary> + /// trigger the execution of the command + /// </summary> 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 { + /// <summary> + /// single element of configuration + /// </summary> public class ConfigItem { Type type; internal object curVal; @@ -59,8 +62,26 @@ namespace Crow } } /// <summary> - /// 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<int> ("Option1");\n + /// ```\n /// </summary> + /// + /// **.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); } } + /// <summary> + /// retrive the value of the configuration key given in parameter + /// </summary> + /// <param name="key">option name</param> public static T Get<T>(string key) { return !items.ContainsKey (key) ? default(T) : items [key].GetValue<T> (); } + /// <summary> + /// store the value of the configuration key given in parameter + /// </summary> + /// <param name="key">option name</param> + /// <param name="value">value for that option</param> public static void Set<T>(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 { + /// <summary> + /// base class for drawing content to paint on backend + /// </summary> public abstract class Fill { + /// <summary> + /// set content of fill as source for drawing operations on the backend context + /// </summary> + /// <param name="ctx">backend context</param> + /// <param name="bounds">drawing operation bounding box</param> 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 { + /// <summary> + /// templated button control + /// </summary> 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 { + /// <summary> + /// templated checkbox control + /// </summary> 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 { + /// <summary> + /// templated color selector control + /// </summary> 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 { + /// <summary> + /// simple squarred rgb color selector + /// </summary> 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 { + /// <summary> + /// templated control for selecting value in a pop up list + /// </summary> 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 { + /// <summary> + /// simple container accepting one child + /// </summary> 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 { + /// <summary> + /// templated directory viewer + /// </summary> 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 { + /// <summary> + /// templated control for selecting files + /// </summary> 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 { + /// <summary> + /// group container that stacked its children horizontally or vertically + /// </summary> 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; /// <summary>Occurs when the enabled state this object is set to false</summary> public event EventHandler Disabled; + public event EventHandler Dragged; + public event EventHandler Dropped; /// <summary>Occurs when one part of the rendering slot changed</summary> public event EventHandler<LayoutingEventArgs> LayoutChanged; /// <summary>Occurs when DataSource changed</summary> @@ -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<Type> AllowedDroppedTypes; +// public void AddAllowedDroppedType (Type newType){ +// if (AllowedDroppedTypes == null) +// AllowedDroppedTypes = new List<Type> (); +// 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); + } + } + /// <summary> + /// start dragging + /// </summary> + protected virtual void onStartDrag (object sender, EventArgs e){ + Debug.WriteLine("DRAG => " + this.ToString()); + Dragged.Raise (this, null); + } + /// <summary> + /// Occured when dragging ends without dropping + /// </summary> + protected virtual void onEndDrag (object sender, EventArgs e){ + IsDragged = false; + Debug.WriteLine("END DRAG => " + this.ToString()); + } + /// <summary> + /// Dragging end with a dropping + /// </summary> + protected virtual void onDrop (object sender, EventArgs e){ + IsDragged = false; + Debug.WriteLine("DROPPED => " + this.ToString()); + Dropped.Raise (this, null); + } + #endregion + #region Queuing /// <summary> /// Register old and new slot for clipping @@ -1299,7 +1375,7 @@ namespace Crow #region Rendering /// <summary> This is the common overridable drawing routine to create new widget </summary> - 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 } /// <summary> Chained painting routine on the parent context of the actual cached version /// of the widget </summary> - 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 { + /// <summary> + /// templated container accepting one child + /// </summary> 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 { + /// <summary> + /// group control stacking its children horizontally + /// </summary> 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 { + /// <summary> + /// templeted numeric control + /// </summary> 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 { + /// <summary> + /// scrolling surface, to be contained in a smaller container in which it will be scrolled + /// </summary> 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 { + /// <summary> + /// generic class to build scrolling control in both directions + /// </summary> 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 { + /// <summary> + /// templated numeric control to select a value + /// by slidding a cursor + /// </summary> 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 { + /// <summary> + /// templated control for selecting a numeric value by clicking on + /// up and down buttons + /// </summary> 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 { + /// <summary> + /// control to add between children of a Stack to allow them to be resized + /// with the pointer + /// </summary> 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 { + /// <summary> + /// group control stacking its children vertically + /// </summary> 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 { + /// <summary> + /// group control that arrange its children in a direction and jump to + /// the next line or row when no room is left + /// </summary> 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 { /// <summary> - /// 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 /// </summary> public class BindingMember { @@ -71,7 +73,14 @@ namespace Crow public bool IsSingleName { get { return LevelsUp == 0 && Tokens.Length == 1; }} #region CTOR + /// <summary> + /// Initializes a new instance of BindingMember. + /// </summary> public BindingMember (){} + /// <summary> + /// Initializes a new instance of BindingMember by parsing the string passed as argument + /// </summary> + /// <param name="expression">binding expression</param> public BindingMember (string expression){ if (string.IsNullOrEmpty (expression)) return; @@ -104,6 +113,11 @@ namespace Crow } #endregion + /// <summary> + /// Emits the MSIL instructions to get the target of the binding expression + /// </summary> + /// <param name="il">current MSIL generator</param> + /// <param name="cancel">cancel branching in MSIL if something go wrong</param> public void emitGetTarget(ILGenerator il, System.Reflection.Emit.Label cancel){ if (IsTemplateBinding) { @@ -145,6 +159,11 @@ namespace Crow il.Emit (OpCodes.Brfalse, cancel); } } + /// <summary> + /// Emit the MSIL instructions to get the target property of the binding expression + /// </summary> + /// <param name="il">current MSIL generator</param> + /// <param name="cancel">cancel branching in MSIL if something go wrong</param> 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); } + /// <summary> + /// Emit the MSIL instructions to set the target property of the binding expression + /// </summary> + /// <param name="il">current MSIL generator</param> 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 /// </summary> 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 /// </summary> /// <param name="ctx">Loading Context</param> /// <param name="tmpXml">xml fragment</param> - 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<string[]> itemTemplateIds = new List<string[]> (); @@ -278,7 +278,7 @@ namespace Crow /// </summary> /// <param name="ctx">parsing context</param> /// <param name="tmpXml">xml fragment</param> - 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 /// <summary> /// Parse child node an generate corresponding msil /// </summary> - 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 /// </summary> - 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); } /// <summary> Emits handler method bindings </summary> - 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. /// </summary> - void emitBindingDelegates(Context ctx){ + void emitBindingDelegates(IMLContext ctx){ foreach (KeyValuePair<NodeAddress,Dictionary<string, List<MemberAddress>>> 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<string, List<MemberAddress>> bindings){ + void emitPropertyBindings(IMLContext ctx, NodeAddress origine, Dictionary<string, List<MemberAddress>> bindings){ Type origineNodeType = origine.NodeType; //value changed dyn method @@ -634,7 +634,7 @@ namespace Crow #endif } - void emitTemplateBindings(Context ctx, Dictionary<string, List<MemberAddress>> bindings){ + void emitTemplateBindings(IMLContext ctx, Dictionary<string, List<MemberAddress>> bindings){ //value changed dyn method DynamicMethod dm = new DynamicMethod ("dyn_tmpValueChanged", typeof (void), CompilerServices.argsValueChange, true); @@ -786,7 +786,7 @@ namespace Crow /// <summary> /// create the valuechanged handler, the datasourcechanged handler and emit event handling /// </summary> - 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 { |