]> O.S.I.I.S - jp/crow.git/commitdiff
use LayoutingType Enum everywhere instead of casting to (int)
authorjpbruyere <jp.bruyere@hotmail.com>
Sat, 6 Feb 2016 07:01:25 +0000 (08:01 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Sat, 6 Feb 2016 07:01:25 +0000 (08:01 +0100)
15 files changed:
MonoDevelop.GOLib/src/GOLibGtkHost.cs
UnitTest/NUnitCrowWindow.cs
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Grid.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/ILayoutable.cs
src/GraphicObjects/Label.cs
src/GraphicObjects/Popper.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/Slider.cs
src/GraphicObjects/TextBox.cs
src/GraphicObjects/TextRun.cs
src/LayoutingQueueItem.cs
src/OpenTKGameWindow.cs

index f9e7e599e9f1e17a90f4567e5ae9f9e528b16f8f..905d9d2633b34072bb2e1602363250ce06d986e2 100644 (file)
@@ -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;
                        }
 
index 1325dcafa35adce2b8c8d6b4bc59e8a6db5d55d1..40f79480d8d412b946a7a2e53b23ba37fc38fa6a 100644 (file)
@@ -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)
                {
index e2bdcf7ac935f106f18b6d8c324c9d8557b7d278..7bdb3b56fc2f2fd49582d40d3bb0b785bf3badde 100644 (file)
@@ -31,13 +31,13 @@ namespace Crow
                public override T addChild<T> (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;
                        }
index 97afaa7e0a79f739dc709c867481a3ac65d4b974..19002a5d380c32d4add9267b5d3753e94c8128a3 100644 (file)
@@ -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));
index 571fdc0fd42cb31a38b2105ab407e26a287acf2f..171abd61c8851283377436654fcb71c7d8b50306 100644 (file)
@@ -32,13 +32,13 @@ namespace Crow
                public override T addChild<T> (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 {
index a9870c7842bdea71a0295e34aaf30d5cc6e9ec89..e8632feac1ac41c7020f64c378e1fc5117b310b1 100644 (file)
@@ -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;
                        }
index 7bb30bce9a6319751efc0b5d962d0bf1eb92e67b..01d62365757f6f64f584d9226f8077dd9059e9c8 100644 (file)
@@ -14,7 +14,7 @@ namespace Crow
                IGOLibHost HostContainer { get; }
 
                List<LinkedListNode<LayoutingQueueItem>> RegisteredLQINodes { get; }
-               void RegisterForLayouting(int layoutType);
+               void RegisterForLayouting(LayoutingType layoutType);
                void UpdateLayout(LayoutingType layoutType);
 
 
index d8d214c75948bb1ea9aeeab6dc9cb756986cf0cb..08e7211acd6d8ed2876cfca0589a53c0b3b71445 100644 (file)
@@ -105,7 +105,7 @@ namespace Crow
                                lines = getLines;
 
                                this.registerForGraphicUpdate ();
-                               this.RegisterForLayouting ((int)LayoutingType.Sizing);
+                               this.RegisterForLayouting (LayoutingType.Sizing);
                                NotifyValueChanged ("Text", _text);
             }
         }
index a7e1290c7821e2bb163e92ebcf93a57e1d0ac5d3..d213fd6dad42f693f9e33d537940a6af19f5dee3 100644 (file)
@@ -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;
index 9b312c14c163b9ee8ca5ccf52e7fa7e213287ad3..b7651d766b64106d8feebe01a188612fc28f815d 100644 (file)
@@ -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;
                        }
                }
index 495683d2fa1732319450fca09f8234e0b412cd36..a9bb5b8efd8dff5505f3bf9114e642bd28864050 100644 (file)
@@ -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);
                        }
                }
index 143d148f8e1a3dfb9c7e5095bde768ace8efe5d1..911225239833aa7280dddc677395f0e8134025e0 100644 (file)
@@ -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
index bee580b38aab25d5fa62364a638592fabcef2fb2..76dde9a8443642db562b01f9ee05450a3d5b3457 100644 (file)
@@ -60,7 +60,7 @@ namespace Crow
                     return;
                                                        
                 registerForGraphicUpdate();
-                               this.RegisterForLayouting ((int)LayoutingType.Sizing);
+                               this.RegisterForLayouting (LayoutingType.Sizing);
 
 
                 _text = value;
index 7153429b2a2d560416a7904c9d8d594243ebd68c..8fbd95caf2cedee67820f87bddb63ad840a25353 100644 (file)
@@ -24,7 +24,7 @@ using System.Collections.Generic;
 
 namespace Crow
 {
-       public enum LayoutingType
+       public enum LayoutingType : byte
        {
                None = 0x00,
                X = 0x01,
index 23d3e81466281c4dd2fb891e04058cd4477b1983..bb5b67e632649b52e4e0d017da588b29355c9b1b 100644 (file)
@@ -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<LinkedListNode<LayoutingQueueItem>> RegisteredLQINodes { get; } = new List<LinkedListNode<LayoutingQueueItem>>();
-               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)
                {