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/GraphicObjects | |
| parent | 11e428d0a8933bca79f0b674d5b10590be60dbbd (diff) | |
:book: use own compiled opentk and remove nuget config
Diffstat (limited to 'src/GraphicObjects')
27 files changed, 195 insertions, 39 deletions
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 |