diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-07-19 03:35:12 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-07-19 03:35:12 +0200 |
| commit | b24beece9ed58b2700dd5d2d56fa45e446567ab0 (patch) | |
| tree | 8930bbda0c8b8a216718fe986eb3ef5c9635ef75 /src | |
| parent | 762161320ddf4bcad8b201cc9170f617f4ec2bed (diff) | |
lots of unordered changes, I commited all in a devel branch, which will be the programming branch
Diffstat (limited to 'src')
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 98 | ||||
| -rw-r--r-- | src/GraphicObjects/HorizontalStack.cs | 3 | ||||
| -rw-r--r-- | src/GraphicObjects/Popper.cs | 11 | ||||
| -rw-r--r-- | src/GraphicObjects/Slider.cs | 19 | ||||
| -rw-r--r-- | src/GraphicObjects/TabItem.cs | 16 | ||||
| -rw-r--r-- | src/GraphicObjects/VerticalStack.cs | 4 | ||||
| -rw-r--r-- | src/Interface.cs | 21 | ||||
| -rw-r--r-- | src/LayoutingQueueItem.cs | 13 | ||||
| -rw-r--r-- | src/Measure.cs | 31 |
9 files changed, 126 insertions, 90 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 9bd31763..59b4be18 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -261,13 +261,23 @@ namespace Crow this.RegisterForLayouting (LayoutingType.Height); } } + /// <summary> + /// Used for binding on dimensions, this property will never hold fixed size, but instead only + /// Fit or Stretched + /// </summary> [XmlIgnore]public virtual Measure WidthPolicy { get { return Width.Units == Unit.Percent || Width.IsFixed ? Measure.Stretched : Measure.Fit; } } + /// <summary> + /// Used for binding on dimensions, this property will never hold fixed size, but instead only + /// Fit or Stretched + /// </summary> [XmlIgnore]public virtual Measure HeightPolicy { get { return Height.Units == Unit.Percent || Height.IsFixed ? Measure.Stretched : Measure.Fit; } } - + /// <summary> + /// When set to True, the <see cref="T:Crow.GraphicObject"/>'s width and height will be set to Fit. + /// </summary> [XmlAttributeAttribute()][DefaultValue(false)] public virtual bool Fit { get { return Width == Measure.Fit && Height == Measure.Fit ? true : false; } @@ -729,8 +739,9 @@ namespace Crow LayoutChanged.Raise (this, new LayoutingEventArgs (layoutType)); } - /// <summary> Update layout component, this is where the computation of alignement - /// and size take place </summary> + /// <summary> Update layout component only one at a time, this is where the computation of alignement + /// and size take place. + /// The redrawing will only be triggered if final slot size has changed </summary> /// <returns><c>true</c>, if layouting was possible, <c>false</c> if conditions were not /// met and LQI has to be re-queued</returns> public virtual bool UpdateLayout (LayoutingType layoutType) @@ -759,6 +770,15 @@ namespace Crow } } else Slot.X = Left; + + if (LastSlots.X == Slot.X) + break; + + bmp = null; + + OnLayoutChanges (layoutType); + + LastSlots.X = Slot.X; break; case LayoutingType.Y: if (Top == 0) { @@ -780,6 +800,15 @@ namespace Crow } } else Slot.Y = Top; + + if (LastSlots.Y == Slot.Y) + break; + + bmp = null; + + OnLayoutChanges (layoutType); + + LastSlots.Y = Slot.Y; break; case LayoutingType.Width: if (Visible) { @@ -807,6 +836,15 @@ namespace Crow } } else Slot.Width = 0; + + if (LastSlots.Width == Slot.Width) + break; + + bmp = null; + + OnLayoutChanges (layoutType); + + LastSlots.Width = Slot.Width; break; case LayoutingType.Height: if (Visible) { @@ -834,51 +872,7 @@ namespace Crow } } else Slot.Height = 0; - break; - } - - updateSlot (layoutType); - - //if no layouting remains in queue for item, registre for redraw - if (this.registeredLayoutings == LayoutingType.None && bmp == null) - this.AddToRedrawList (); - - return true; - } - protected void updateSlot(LayoutingType layoutType) - { - switch (layoutType) { - case LayoutingType.X: - if (LastSlots.X == Slot.X) - break; - - bmp = null; - - OnLayoutChanges (layoutType); - - LastSlots.X = Slot.X; - break; - case LayoutingType.Y: - if (LastSlots.Y == Slot.Y) - break; - - bmp = null; - - OnLayoutChanges (layoutType); - - LastSlots.Y = Slot.Y; - break; - case LayoutingType.Width: - if (LastSlots.Width == Slot.Width) - break; - - bmp = null; - - OnLayoutChanges (layoutType); - - LastSlots.Width = Slot.Width; - break; - case LayoutingType.Height: + if (LastSlots.Height == Slot.Height) break; @@ -886,9 +880,15 @@ namespace Crow OnLayoutChanges (layoutType); - LastSlots.Height = Slot.Height; + LastSlots.Height = Slot.Height; break; } + + //if no layouting remains in queue for item, registre for redraw + if (this.registeredLayoutings == LayoutingType.None && bmp == null) + this.AddToRedrawList (); + + return true; } #endregion diff --git a/src/GraphicObjects/HorizontalStack.cs b/src/GraphicObjects/HorizontalStack.cs index 30fded86..ae48f997 100644 --- a/src/GraphicObjects/HorizontalStack.cs +++ b/src/GraphicObjects/HorizontalStack.cs @@ -10,8 +10,7 @@ namespace Crow { public HorizontalStack() : base() - { - Orientation = Crow.Orientation.Horizontal; + { } [XmlIgnore] diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index 4fd84554..5e5541fe 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -89,6 +89,17 @@ namespace Crow } } + public override void OnLayoutChanges (LayoutingType layoutType) + { + base.OnLayoutChanges (layoutType); + + if (_content == null) + return; + + if (layoutType == LayoutingType.Width) + _content.MinimumSize = new Size (this.Slot.Width, _content.MinimumSize.Height); + } + #region GraphicObject overrides public override void ClearBinding () { diff --git a/src/GraphicObjects/Slider.cs b/src/GraphicObjects/Slider.cs index 26720b1d..3b2cebf4 100644 --- a/src/GraphicObjects/Slider.cs +++ b/src/GraphicObjects/Slider.cs @@ -9,6 +9,7 @@ using System.Diagnostics; namespace Crow { + [DefaultStyle ("#Crow.Styles.Slider.style")] public class Slider : NumericControl { #region CTOR @@ -77,6 +78,7 @@ namespace Crow } } #endregion + [XmlAttributeAttribute()][DefaultValue(10.0)] public override double Maximum { get { return base.Maximum; } @@ -90,23 +92,6 @@ namespace Crow } #region GraphicObject Overrides - [XmlAttributeAttribute()][DefaultValue("vgradient|0:Black|0,1:Gray|0,9:Gray|1:LightGray")] - public override Fill Background { - get { return base.Background; } - set { base.Background = value; } - } - [XmlAttributeAttribute()][DefaultValue("Gray")] - public override Fill Foreground { - get { return base.Foreground; } - set { base.Foreground = value; } - } - [XmlAttributeAttribute()][DefaultValue(true)] - public override bool Focusable - { - get { return base.Focusable; } - set { base.Focusable = value; } - } - protected override void onDraw (Context gr) { base.onDraw (gr); diff --git a/src/GraphicObjects/TabItem.cs b/src/GraphicObjects/TabItem.cs index 9fd8180d..38d56c5d 100644 --- a/src/GraphicObjects/TabItem.cs +++ b/src/GraphicObjects/TabItem.cs @@ -25,6 +25,7 @@ using System.Diagnostics; namespace Crow { + [DefaultStyle ("#Crow.Styles.TabItem.style")] [DefaultTemplate("#Crow.Templates.TabItem.crow")] public class TabItem : TemplatedContainer { @@ -66,21 +67,6 @@ namespace Crow internal GraphicObject TabTitle { get { return _tabTitle; }} #endregion - #region GraphicObject overrides - [XmlAttributeAttribute()][DefaultValue(true)] - public override bool Focusable - { - get { return base.Focusable; } - set { base.Focusable = value; } - } - //prevent caching, because drawing order is different depending on selected tab - [XmlAttributeAttribute()][DefaultValue(false)] - public override bool CacheEnabled { - get {return false;} - set { } - } - #endregion - [XmlAttributeAttribute()][DefaultValue(0)] public virtual int TabOffset { get { return tabOffset; } diff --git a/src/GraphicObjects/VerticalStack.cs b/src/GraphicObjects/VerticalStack.cs index afd26429..e3d5e588 100644 --- a/src/GraphicObjects/VerticalStack.cs +++ b/src/GraphicObjects/VerticalStack.cs @@ -10,14 +10,12 @@ namespace Crow public VerticalStack() : base() { - Orientation = Crow.Orientation.Vertical; } [System.Xml.Serialization.XmlIgnore] public override Orientation Orientation { - get { return Orientation.Vertical; } - //set { } + get { return Orientation.Vertical; } } diff --git a/src/Interface.cs b/src/Interface.cs index d0c385e7..b8426e6f 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -30,6 +30,15 @@ using Cairo; namespace Crow { + /// <summary> + /// The Interface Class is the top container of the application. + /// It provides the Dirty bitmap and zone of the interface to be drawn on screen + /// + /// The Interface contains : + /// - rendering and layouting queues and logic. + /// - helpers to load XML interfaces files + /// - global constants and variables of CROW + /// </summary> public class Interface : ILayoutable { #region CTOR @@ -58,6 +67,7 @@ namespace Crow public static int TabSize = 4; public static string LineBreak = "\r\n"; + //TODO: shold be declared in graphicObject public static bool FocusOnHover = false; /// <summary> Time to wait in millisecond before starting repeat loop</summary> public static int DeviceRepeatDelay = 600; @@ -68,11 +78,18 @@ namespace Crow public static bool DesignerMode = false; /// <summary> Threshold to catch borders for sizing </summary> public static int BorderThreshold = 5; + /// <summary> Disable caching for a widget if this threshold is reached </summary> public const int MaxCacheSize = 2048; + /// <summary> Above this count, the layouting is discard for the widget and it + /// will not be rendered on screen </summary> public const int MaxLayoutingTries = 50; + /// <summary> Global font rendering settings for Cairo </summary> public static FontOptions FontRenderingOptions; #endregion + /// <summary> + /// The layouting queue contains layouting commands + /// </summary> public Queue<LayoutingQueueItem> LayoutingQueue; public Queue<GraphicObject> GraphicUpdateQueue = new Queue<GraphicObject>(); public string Clipboard; @@ -98,6 +115,10 @@ namespace Crow } #region default values loading helpers + /// Default values of properties from GraphicObjects are retrieve from XML Attributes. + /// The reflexion process used to retrieve those values being very slow, it is compiled in MSIL + /// and injected as a dynamic method referenced in the DefaultValuesLoader Dictionnary. + /// The compilation is done on the first object instancing, and is also done for custom widgets public delegate void loadDefaultInvoker(object instance); public static Dictionary<String, loadDefaultInvoker> DefaultValuesLoader = new Dictionary<string, loadDefaultInvoker>(); #endregion diff --git a/src/LayoutingQueueItem.cs b/src/LayoutingQueueItem.cs index 933fc57c..82673444 100644 --- a/src/LayoutingQueueItem.cs +++ b/src/LayoutingQueueItem.cs @@ -36,19 +36,26 @@ namespace Crow ArrangeChildren = 0x10, All = 0xFF } - + /// <summary> + /// Element class of the LayoutingQueue + /// </summary> public class LayoutingQueueItem - { + { + /// <summary> Instance of widget to be layouted</summary> public ILayoutable GraphicObject; + /// <summary> Bitfield containing the element of the layout to performs (x|y|width|height)</summary> public LayoutingType LayoutType; + #region CTOR public LayoutingQueueItem (LayoutingType _layoutType, ILayoutable _graphicObject) { LayoutType = _layoutType; GraphicObject = _graphicObject; GraphicObject.RegisteredLayoutings |= LayoutType; } - + #endregion + + public void ProcessLayouting() { if (GraphicObject.Parent == null) { diff --git a/src/Measure.cs b/src/Measure.cs index 64e5cc98..19e8f548 100644 --- a/src/Measure.cs +++ b/src/Measure.cs @@ -22,22 +22,47 @@ using System; namespace Crow { + /// <summary> + /// Measurement unit + /// </summary> public enum Unit { Pixel, Percent } + /// <summary> + /// Measure class allow proportional sizes as well as stretched and fit on content. + /// </summary> public struct Measure { + /// <summary> + /// Integer value of the measure + /// </summary> public int Value; + /// <summary> + /// Measurement unit + /// </summary> public Unit Units; + /// <summary> + /// Fit on content, this special measure is defined as a fixed integer set to -1 pixel + /// </summary> public static Measure Fit = new Measure(-1); - //TODO:implement stretching as 100%, not 0% + /// <summary> + /// Stretched into parent client area. This special measure is defined as a proportional cote + /// set to 100 Percents + /// </summary> public static Measure Stretched = new Measure(100, Unit.Percent); + #region CTOR public Measure (int _value, Unit _units = Unit.Pixel) { Value = _value; Units = _units; } + #endregion + + /// <summary> + /// True is size is fixed in pixels, this means not proportional, stretched nor fit. + /// </summary> public bool IsFixed { get { return Value > 0 && Units == Unit.Pixel; }} + #region Operators public static implicit operator int(Measure m){ return m.Value; @@ -59,6 +84,8 @@ namespace Crow return !(m1.Value == m2.Value && m1.Units == m2.Units); } #endregion + + #region Object overrides public override int GetHashCode () { return Value.GetHashCode (); @@ -75,6 +102,8 @@ namespace Crow Units == Unit.Percent ? Value == 100 ? "Stretched" : Value.ToString () + "%" : Value.ToString (); } + #endregion + public static Measure Parse(string s){ if (string.IsNullOrEmpty (s)) return Measure.Stretched; |