From: jpbruyere Date: Mon, 21 Mar 2016 07:53:31 +0000 (+0100) Subject: remove Bounds rectangle as private field for dims X-Git-Tag: v0.4~70^2~3 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=0b005fefe69b67bf335c3c00944bbac73e8b4831;p=jp%2Fcrow.git remove Bounds rectangle as private field for dims --- diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index 362143fa..925f908a 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -221,14 +221,14 @@ namespace Crow switch (arg.LayoutType) { case LayoutingType.Width: if (Orientation == Orientation.Horizontal) { - if (this.Bounds.Width < 0) + if (Width < 0) this.RegisterForLayouting (LayoutingType.Width); this.RegisterForLayouting (LayoutingType.ArrangeChildren); } break; case LayoutingType.Height: if (Orientation == Orientation.Vertical) { - if (this.Bounds.Height < 0) + if (Height < 0) this.RegisterForLayouting (LayoutingType.Height); this.RegisterForLayouting (LayoutingType.ArrangeChildren); } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 81ec72a6..7b58f652 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -60,7 +60,10 @@ namespace Crow return; loadDefaultValues (); - Bounds = _bounds; + Left = _bounds.Left; + Top = _bounds.Top; + Width = _bounds.Width; + Height = _bounds.Height; } #endregion @@ -92,7 +95,7 @@ namespace Crow /// /// Original size and position 0=Stretched; -1=Fit /// - public Rectangle Bounds; + int _width, _height, _left, _top; /// /// Current size and position computed during layouting pass /// @@ -151,7 +154,6 @@ namespace Crow Parent.ScreenCoordinates(r) + Parent.getSlot().Position + Parent.ClientRectangle.Position; } public virtual Rectangle getSlot() => Slot; - public virtual Rectangle getBounds() => Bounds; #endregion #region EVENT HANDLERS @@ -215,37 +217,37 @@ namespace Crow } [XmlAttributeAttribute()][DefaultValue(0)] public virtual int Left { - get { return Bounds.X; } + get { return _left; } set { - if (Bounds.X == value) + if (_left == value) return; - Bounds.X = value; - NotifyValueChanged ("Left", Bounds.X); + _left = value; + NotifyValueChanged ("Left", _left); this.RegisterForLayouting (LayoutingType.X); } } [XmlAttributeAttribute()][DefaultValue(0)] public virtual int Top { - get { return Bounds.Y; } + get { return _top; } set { - if (Bounds.Y == value) + if (_top == value) return; - Bounds.Y = value; - NotifyValueChanged ("Top", Bounds.Y); + _top = value; + NotifyValueChanged ("Top", _top); this.RegisterForLayouting (LayoutingType.Y); } } [XmlAttributeAttribute()][DefaultValue(0)] public virtual int Width { - get { return Bounds.Width; } + get { return _width; } set { - if (Bounds.Width == value) + if (_width == value) return; - Bounds.Width = value; - NotifyValueChanged ("Width", Bounds.Width); + _width = value; + NotifyValueChanged ("Width", _width); NotifyValueChanged ("WidthPolicy", WidthPolicy); this.RegisterForLayouting (LayoutingType.Width); @@ -253,13 +255,13 @@ namespace Crow } [XmlAttributeAttribute()][DefaultValue(0)] public virtual int Height { - get { return Bounds.Height; } + get { return _height; } set { - if (Bounds.Height == value) + if (_height == value) return; - Bounds.Height = value; - NotifyValueChanged ("Height", Bounds.Height); + _height = value; + NotifyValueChanged ("Height", _height); NotifyValueChanged ("HeightPolicy", HeightPolicy); this.RegisterForLayouting (LayoutingType.Height); @@ -662,7 +664,7 @@ namespace Crow } /// return size of content + margins protected virtual int measureRawSize (LayoutingType lt) { - return lt == LayoutingType.Width ? Bounds.Size.Width : Bounds.Size.Height; + return lt == LayoutingType.Width ? Width : Height; } /// By default in groups, LayoutingType.ArrangeChildren is reset public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){ @@ -738,7 +740,7 @@ namespace Crow switch (layoutType) { case LayoutingType.X: - if (Bounds.X == 0) { + if (Left == 0) { if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width) || RegisteredLayoutings.HasFlag (LayoutingType.Width)) @@ -756,7 +758,7 @@ namespace Crow break; } } else - Slot.X = Bounds.X; + Slot.X = Left; if (LastSlots.X == Slot.X) break; @@ -768,7 +770,7 @@ namespace Crow LastSlots.X = Slot.X; break; case LayoutingType.Y: - if (Bounds.Y == 0) { + if (Top == 0) { if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height) || RegisteredLayoutings.HasFlag (LayoutingType.Height)) @@ -786,7 +788,7 @@ namespace Crow break; } }else - Slot.Y = Bounds.Y; + Slot.Y = Top; if (LastSlots.Y == Slot.Y) break; diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 7ea37161..47795b06 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -178,14 +178,14 @@ namespace Crow if (g.Slot.Width > maxChildrenWidth) { maxChildrenWidth = g.Slot.Width; largestChild = g; - if (this.Bounds.Width < 0) + if (Width < 0) this.RegisterForLayouting (LayoutingType.Width); } else if (g == largestChild) { largestChild = null; maxChildrenWidth = 0; - if (this.Bounds.Width < 0) + if (Width < 0) this.RegisterForLayouting (LayoutingType.Width); } break; @@ -193,14 +193,14 @@ namespace Crow if (g.Slot.Height > maxChildrenHeight) { maxChildrenHeight = g.Slot.Height; tallestChild = g; - if (this.Bounds.Height < 0) + if (Height < 0) this.RegisterForLayouting (LayoutingType.Height); } else if (g == tallestChild) { tallestChild = null; maxChildrenHeight = 0; - if (this.Bounds.Height < 0) + if (Height < 0) this.RegisterForLayouting (LayoutingType.Height); } break; diff --git a/src/GraphicObjects/ILayoutable.cs b/src/GraphicObjects/ILayoutable.cs index a8df3ae0..b48e815a 100644 --- a/src/GraphicObjects/ILayoutable.cs +++ b/src/GraphicObjects/ILayoutable.cs @@ -15,7 +15,6 @@ namespace Crow Rectangle ClientRectangle { get; } Rectangle getSlot(); - Rectangle getBounds(); bool ArrangeChildren { get; } LayoutingType RegisteredLayoutings { get; set; } diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs index 6d0bf471..c28f090c 100644 --- a/src/GraphicObjects/Label.cs +++ b/src/GraphicObjects/Label.cs @@ -397,7 +397,7 @@ namespace Crow Rectangle cb = ClientRectangle; //ignore text alignment if size to content = true - if (Bounds.Size < 0) + if (Width < 0 || Height < 0) { rText.X = cb.X; rText.Y = cb.Y; diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index a399567c..f3385a88 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -144,11 +144,11 @@ namespace Crow case LayoutingType.Y: break; case LayoutingType.Width: - if (this.Bounds.Width < 0) + if (Width < 0) this.RegisterForLayouting (LayoutingType.Width); break; case LayoutingType.Height: - if (this.Bounds.Height < 0) + if (Height < 0) this.RegisterForLayouting (LayoutingType.Height); break; } diff --git a/src/GraphicObjects/TextRun.cs b/src/GraphicObjects/TextRun.cs index 15f024af..021d5654 100644 --- a/src/GraphicObjects/TextRun.cs +++ b/src/GraphicObjects/TextRun.cs @@ -206,7 +206,7 @@ namespace Crow //ignore text alignment if size to content = true //or if text size is larger than client bounds - if (Bounds.Size < 0 || rText.Width > cb.Width) + if (Width < 0 || Height < 0 || rText.Width > cb.Width) { rText.X = cb.X; rText.Y = cb.Y; diff --git a/src/Interface.cs b/src/Interface.cs index 41199fcc..939fc560 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -729,7 +729,6 @@ namespace Crow get { return this; } } public Rectangle getSlot () => ClientRectangle; - public Rectangle getBounds () => ClientRectangle; #endregion } }