From: jpbruyere Date: Sat, 6 Feb 2016 07:01:25 +0000 (+0100) Subject: use LayoutingType Enum everywhere instead of casting to (int) X-Git-Tag: 0.3~42^2~12 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=6577bc6e136c7440117bd7bb49cb4a4fd3fbcfa3;p=jp%2Fcrow.git use LayoutingType Enum everywhere instead of casting to (int) --- diff --git a/MonoDevelop.GOLib/src/GOLibGtkHost.cs b/MonoDevelop.GOLib/src/GOLibGtkHost.cs index f9e7e599..905d9d26 100644 --- a/MonoDevelop.GOLib/src/GOLibGtkHost.cs +++ b/MonoDevelop.GOLib/src/GOLibGtkHost.cs @@ -170,7 +170,7 @@ namespace MonoDevelop.GOLib g.Parent = this; GraphicObjects.Insert (0, g); - g.RegisterForLayouting ((int)LayoutingType.Sizing); + g.RegisterForLayouting (LayoutingType.Sizing); } public void DeleteWidget(GraphicObject g) { @@ -262,7 +262,7 @@ namespace MonoDevelop.GOLib Crow.Size newSize = this.ClientRectangle.Size; if (lastSize != newSize) { foreach (GraphicObject g in GraphicObjects) - g.RegisterForLayouting ((int)LayoutingType.All); + g.RegisterForLayouting (LayoutingType.All); lastSize = newSize; } diff --git a/UnitTest/NUnitCrowWindow.cs b/UnitTest/NUnitCrowWindow.cs index 1325dcaf..40f79480 100644 --- a/UnitTest/NUnitCrowWindow.cs +++ b/UnitTest/NUnitCrowWindow.cs @@ -58,7 +58,7 @@ namespace Crow g.Parent = this; GraphicObjects.Insert (0, g); - g.RegisterForLayouting ((int)LayoutingType.Sizing); + g.RegisterForLayouting (LayoutingType.Sizing); } public void DeleteWidget(GraphicObject g) { diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index e2bdcf7a..7bdb3b56 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -31,13 +31,13 @@ namespace Crow public override T addChild (T child) { T tmp = base.addChild (child); - this.RegisterForLayouting ((int)LayoutingType.PositionChildren); + this.RegisterForLayouting (LayoutingType.PositionChildren); return tmp; } public override void removeChild (GraphicObject child) { base.removeChild (child); - this.RegisterForLayouting ((int)LayoutingType.PositionChildren); + this.RegisterForLayouting (LayoutingType.PositionChildren); } #region Public Properties @@ -96,13 +96,13 @@ namespace Crow foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) { c.Slot.X = d; d += c.Slot.Width + Spacing; - c.RegisterForLayouting ((int)LayoutingType.Y); + c.RegisterForLayouting (LayoutingType.Y); } } else { foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) { c.Slot.Y = d; d += c.Slot.Height + Spacing; - c.RegisterForLayouting ((int)LayoutingType.X); + c.RegisterForLayouting (LayoutingType.X); } } bmp = null; @@ -177,9 +177,9 @@ namespace Crow if (Orientation == Orientation.Horizontal){ if(layoutType == LayoutingType.Width) - this.RegisterForLayouting ((int)LayoutingType.PositionChildren); + this.RegisterForLayouting (LayoutingType.PositionChildren); }else if (layoutType == LayoutingType.Height) - this.RegisterForLayouting ((int)LayoutingType.PositionChildren); + this.RegisterForLayouting (LayoutingType.PositionChildren); } public override void OnChildLayoutChanges (object sender, LayoutChangeEventArgs arg) { @@ -194,15 +194,15 @@ namespace Crow case LayoutingType.Width: if (Orientation == Orientation.Horizontal) { if (this.Bounds.Width < 0) - this.RegisterForLayouting ((int)LayoutingType.Width); - this.RegisterForLayouting ((int)LayoutingType.PositionChildren); + this.RegisterForLayouting (LayoutingType.Width); + this.RegisterForLayouting (LayoutingType.PositionChildren); } break; case LayoutingType.Height: if (Orientation == Orientation.Vertical) { if (this.Bounds.Height < 0) - this.RegisterForLayouting ((int)LayoutingType.Height); - this.RegisterForLayouting ((int)LayoutingType.PositionChildren); + this.RegisterForLayouting (LayoutingType.Height); + this.RegisterForLayouting (LayoutingType.PositionChildren); } break; } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 97afaa7e..19002a5d 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -219,7 +219,7 @@ namespace Crow Bounds.X = value; NotifyValueChanged ("Left", Bounds.X); - this.RegisterForLayouting ((int)LayoutingType.X); + this.RegisterForLayouting (LayoutingType.X); } } [XmlAttributeAttribute()][DefaultValue(0)] @@ -231,7 +231,7 @@ namespace Crow Bounds.Y = value; NotifyValueChanged ("Top", Bounds.Y); - this.RegisterForLayouting ((int)LayoutingType.Y); + this.RegisterForLayouting (LayoutingType.Y); } } [XmlAttributeAttribute()][DefaultValue(0)] @@ -243,7 +243,7 @@ namespace Crow Bounds.Width = value; NotifyValueChanged ("Width", Bounds.Width); - this.RegisterForLayouting ((int)LayoutingType.Width); + this.RegisterForLayouting (LayoutingType.Width); } } [XmlAttributeAttribute()][DefaultValue(0)] @@ -255,7 +255,7 @@ namespace Crow Bounds.Height = value; NotifyValueChanged ("Height", Bounds.Height); - this.RegisterForLayouting ((int)LayoutingType.Height); + this.RegisterForLayouting (LayoutingType.Height); } } [XmlAttributeAttribute()][DefaultValue(false)] @@ -371,7 +371,7 @@ namespace Crow if (this.Contains (HostContainer.hoverWidget)) HostContainer.hoverWidget = null; if (Parent is GenericStack) - Parent.RegisterForLayouting ((int)LayoutingType.Sizing | (int)LayoutingType.PositionChildren); + Parent.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.PositionChildren); NotifyValueChanged ("Visible", _isVisible); } @@ -511,7 +511,7 @@ namespace Crow } public LayoutingType RegisteredLayoutings = 0; - public virtual void RegisterForLayouting(int layoutType){ + public virtual void RegisterForLayouting(LayoutingType layoutType){ if (RegisteredLayoutings == LayoutingType.None) Interface.RegisteredGOForLayouting.Enqueue (this); RegisteredLayoutings |= (LayoutingType)layoutType; @@ -573,11 +573,11 @@ namespace Crow switch (layoutType) { case LayoutingType.Width: if (Width != 0 && Parent.getBounds().Width >=0) //update position in parent - this.RegisterForLayouting ((int)LayoutingType.X); + this.RegisterForLayouting (LayoutingType.X); break; case LayoutingType.Height: if (Height != 0 && Parent.getBounds().Height >=0) //update position in parent - this.RegisterForLayouting ((int)LayoutingType.Y); + this.RegisterForLayouting (LayoutingType.Y); break; } LayoutChanged.Raise (this, new LayoutChangeEventArgs (layoutType)); diff --git a/src/GraphicObjects/Grid.cs b/src/GraphicObjects/Grid.cs index 571fdc0f..171abd61 100644 --- a/src/GraphicObjects/Grid.cs +++ b/src/GraphicObjects/Grid.cs @@ -32,13 +32,13 @@ namespace Crow public override T addChild (T child) { T tmp = base.addChild (child); - this.RegisterForLayouting ((int)LayoutingType.PositionChildren); + this.RegisterForLayouting (LayoutingType.PositionChildren); return tmp; } public override void removeChild (GraphicObject child) { base.removeChild (child); - this.RegisterForLayouting ((int)LayoutingType.PositionChildren); + this.RegisterForLayouting (LayoutingType.PositionChildren); } #region Public Properties @@ -59,7 +59,7 @@ namespace Crow _columnCount = value; NotifyValueChanged ("ColumnCount", ColumnCount); - this.RegisterForLayouting ((int)LayoutingType.PositionChildren); + this.RegisterForLayouting (LayoutingType.PositionChildren); } } [XmlAttributeAttribute()][DefaultValue(1)] @@ -73,7 +73,7 @@ namespace Crow _rowCount = value; NotifyValueChanged ("RowCount", RowCount); - this.RegisterForLayouting ((int)LayoutingType.PositionChildren); + this.RegisterForLayouting (LayoutingType.PositionChildren); } } public virtual int CaseWidth { diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index a9870c78..e8632fea 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -50,7 +50,7 @@ namespace Crow GraphicObject g = child as GraphicObject; Children.Add(g); g.Parent = this as GraphicObject; - g.RegisterForLayouting ((int)LayoutingType.Sizing); + g.RegisterForLayouting (LayoutingType.Sizing); g.LayoutChanged += OnChildLayoutChanges; return (T)child; } @@ -60,7 +60,7 @@ namespace Crow child.ClearBinding (); child.Parent = null; Children.Remove(child); - this.RegisterForLayouting ((int)LayoutingType.Sizing); + this.RegisterForLayouting (LayoutingType.Sizing); } public virtual void ClearChildren() { @@ -73,7 +73,7 @@ namespace Crow Children.RemoveAt(cpt-1); cpt = children.Count; } - this.RegisterForLayouting ((int)LayoutingType.Sizing); + this.RegisterForLayouting (LayoutingType.Sizing); ChildrenCleared.Raise (this, new EventArgs ()); } public void putWidgetOnTop(GraphicObject w) @@ -147,17 +147,17 @@ namespace Crow case LayoutingType.Width: foreach (GraphicObject c in Children.Where(ch => ch.Visible)) { if (c.getBounds ().Width == 0) - c.RegisterForLayouting ((int)LayoutingType.Width); + c.RegisterForLayouting (LayoutingType.Width); else - c.RegisterForLayouting ((int)LayoutingType.X); + c.RegisterForLayouting (LayoutingType.X); } break; case LayoutingType.Height: foreach (GraphicObject c in Children.Where(ch => ch.Visible)) { if (c.getBounds ().Height == 0) - c.RegisterForLayouting ((int)LayoutingType.Height); + c.RegisterForLayouting (LayoutingType.Height); else - c.RegisterForLayouting ((int)LayoutingType.Y); + c.RegisterForLayouting (LayoutingType.Y); } break; } @@ -175,7 +175,7 @@ namespace Crow maxChildrenWidth = g.Slot.Width; largestChild = g; if (this.Bounds.Width < 0) - this.RegisterForLayouting ((int)LayoutingType.Width); + this.RegisterForLayouting (LayoutingType.Width); } else if (g == largestChild) { //search for the new largest child largestChild = null; @@ -187,7 +187,7 @@ namespace Crow } } if (this.Bounds.Width < 0) - this.RegisterForLayouting ((int)LayoutingType.Width); + this.RegisterForLayouting (LayoutingType.Width); } break; case LayoutingType.Height: @@ -195,7 +195,7 @@ namespace Crow maxChildrenHeight = g.Slot.Height; tallestChild = g; if (this.Bounds.Height < 0) - this.RegisterForLayouting ((int)LayoutingType.Height); + this.RegisterForLayouting (LayoutingType.Height); } else if (g == tallestChild) { //search for the new tallest child tallestChild = null; @@ -207,7 +207,7 @@ namespace Crow } } if (this.Bounds.Height < 0) - this.RegisterForLayouting ((int)LayoutingType.Height); + this.RegisterForLayouting (LayoutingType.Height); } break; } diff --git a/src/GraphicObjects/ILayoutable.cs b/src/GraphicObjects/ILayoutable.cs index 7bb30bce..01d62365 100644 --- a/src/GraphicObjects/ILayoutable.cs +++ b/src/GraphicObjects/ILayoutable.cs @@ -14,7 +14,7 @@ namespace Crow IGOLibHost HostContainer { get; } List> RegisteredLQINodes { get; } - void RegisterForLayouting(int layoutType); + void RegisterForLayouting(LayoutingType layoutType); void UpdateLayout(LayoutingType layoutType); diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs index d8d214c7..08e7211a 100644 --- a/src/GraphicObjects/Label.cs +++ b/src/GraphicObjects/Label.cs @@ -105,7 +105,7 @@ namespace Crow lines = getLines; this.registerForGraphicUpdate (); - this.RegisterForLayouting ((int)LayoutingType.Sizing); + this.RegisterForLayouting (LayoutingType.Sizing); NotifyValueChanged ("Text", _text); } } diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index a7e1290c..d213fd6d 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -66,7 +66,7 @@ namespace Crow if (tc == null) return; Rectangle r = this.ScreenCoordinates (this.Slot); - if (((int)e.LayoutType & (int)LayoutingType.Width) > 0) { + if (e.LayoutType.HasFlag(LayoutingType.Width)) { if (Content.Slot.Width < tc.ClientRectangle.Width) { if (r.Left + Content.Slot.Width > tc.ClientRectangle.Right) Content.Left = tc.ClientRectangle.Right - Content.Slot.Width; @@ -75,7 +75,7 @@ namespace Crow } else Content.Left = 0; } - if (((int)e.LayoutType & (int)LayoutingType.Height) > 0) { + if (e.LayoutType.HasFlag(LayoutingType.Height)) { if (Content.Slot.Height < tc.ClientRectangle.Height) { if (r.Bottom + Content.Slot.Height > tc.ClientRectangle.Bottom) Content.Top = r.Top - Content.Slot.Height; diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index 9b312c14..b7651d76 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -53,7 +53,7 @@ namespace Crow if (child != null) { child.LayoutChanged -= OnChildLayoutChanges; - this.RegisterForLayouting ((int)LayoutingType.Sizing); + this.RegisterForLayouting (LayoutingType.Sizing); child.Parent = null; } @@ -62,7 +62,7 @@ namespace Crow if (child != null) { child.Parent = this; child.LayoutChanged += OnChildLayoutChanges; - child.RegisterForLayouting ((int)LayoutingType.Sizing); + child.RegisterForLayouting (LayoutingType.Sizing); } return (T)_child; @@ -104,17 +104,17 @@ namespace Crow case LayoutingType.Width: if (child != null) { if (child.getBounds ().Width == 0) - child.RegisterForLayouting ((int)LayoutingType.Width); + child.RegisterForLayouting (LayoutingType.Width); else - child.RegisterForLayouting ((int)LayoutingType.X); + child.RegisterForLayouting (LayoutingType.X); } break; case LayoutingType.Height: if (child != null) { if (child.getBounds ().Height == 0) - child.RegisterForLayouting ((int)LayoutingType.Height); + child.RegisterForLayouting (LayoutingType.Height); else - child.RegisterForLayouting ((int)LayoutingType.Y); + child.RegisterForLayouting (LayoutingType.Y); } break; } @@ -129,11 +129,11 @@ namespace Crow break; case LayoutingType.Width: if (this.Bounds.Width < 0) - this.RegisterForLayouting ((int)LayoutingType.Width); + this.RegisterForLayouting (LayoutingType.Width); break; case LayoutingType.Height: if (this.Bounds.Height < 0) - this.RegisterForLayouting ((int)LayoutingType.Height); + this.RegisterForLayouting (LayoutingType.Height); break; } } diff --git a/src/GraphicObjects/Slider.cs b/src/GraphicObjects/Slider.cs index 495683d2..a9bb5b8e 100644 --- a/src/GraphicObjects/Slider.cs +++ b/src/GraphicObjects/Slider.cs @@ -58,7 +58,7 @@ namespace Crow if (_cursorSize == value) return; _cursorSize = value; - RegisterForLayouting ((int)LayoutingType.Sizing); + RegisterForLayouting (LayoutingType.Sizing); registerForGraphicUpdate (); NotifyValueChanged ("CursorSize", _cursorSize); } @@ -72,7 +72,7 @@ namespace Crow return; _orientation = value; - RegisterForLayouting ((int)LayoutingType.All); + RegisterForLayouting (LayoutingType.All); NotifyValueChanged ("Orientation", _orientation); } } diff --git a/src/GraphicObjects/TextBox.cs b/src/GraphicObjects/TextBox.cs index 143d148f..91122523 100644 --- a/src/GraphicObjects/TextBox.cs +++ b/src/GraphicObjects/TextBox.cs @@ -199,9 +199,9 @@ namespace Crow break; } if (Width < 0) - RegisterForLayouting ((int)LayoutingType.Width); + RegisterForLayouting (LayoutingType.Width); if (Height < 0) - RegisterForLayouting ((int)LayoutingType.Height); + RegisterForLayouting (LayoutingType.Height); registerForGraphicUpdate(); } #endregion diff --git a/src/GraphicObjects/TextRun.cs b/src/GraphicObjects/TextRun.cs index bee580b3..76dde9a8 100644 --- a/src/GraphicObjects/TextRun.cs +++ b/src/GraphicObjects/TextRun.cs @@ -60,7 +60,7 @@ namespace Crow return; registerForGraphicUpdate(); - this.RegisterForLayouting ((int)LayoutingType.Sizing); + this.RegisterForLayouting (LayoutingType.Sizing); _text = value; diff --git a/src/LayoutingQueueItem.cs b/src/LayoutingQueueItem.cs index 7153429b..8fbd95ca 100644 --- a/src/LayoutingQueueItem.cs +++ b/src/LayoutingQueueItem.cs @@ -24,7 +24,7 @@ using System.Collections.Generic; namespace Crow { - public enum LayoutingType + public enum LayoutingType : byte { None = 0x00, X = 0x01, diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs index 23d3e814..bb5b67e6 100644 --- a/src/OpenTKGameWindow.cs +++ b/src/OpenTKGameWindow.cs @@ -76,7 +76,7 @@ namespace Crow g.Parent = this; GraphicObjects.Insert (0, g); - g.RegisterForLayouting ((int)LayoutingType.Sizing); + g.RegisterForLayouting (LayoutingType.Sizing); } public void DeleteWidget(GraphicObject g) { @@ -408,7 +408,7 @@ namespace Crow base.OnResize (e); createContext (); foreach (GraphicObject g in GraphicObjects) { - g.RegisterForLayouting ((int)LayoutingType.All); + g.RegisterForLayouting (LayoutingType.All); //g.registerForGraphicUpdate(); } } @@ -554,7 +554,7 @@ namespace Crow //TODO:uneeded list, should be removed public List> RegisteredLQINodes { get; } = new List>(); - public void RegisterForLayouting (int layoutType) { throw new NotImplementedException (); } + public void RegisterForLayouting (LayoutingType layoutType) { throw new NotImplementedException (); } public void UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); } public Rectangle ContextCoordinates (Rectangle r) {