diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-04-30 13:03:33 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-04-30 13:03:33 +0200 |
| commit | 02ac8178673249c2d1af60d7b291d8b40419bcd8 (patch) | |
| tree | 672b1242b2d31ed159916ed32b99147279fcc758 /src/GraphicObjects | |
| parent | 8771dccd2369447a50485c7649e8a0851b551958 (diff) | |
glfw backend, group measure on change only
Diffstat (limited to 'src/GraphicObjects')
| -rw-r--r-- | src/GraphicObjects/GenericStack.cs | 13 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 91 | ||||
| -rw-r--r-- | src/GraphicObjects/PrivateContainer.cs | 7 | ||||
| -rw-r--r-- | src/GraphicObjects/Splitter.cs | 12 |
4 files changed, 71 insertions, 52 deletions
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index d5ff81c6..adf428c5 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -50,11 +50,18 @@ namespace Crow } protected override int measureRawSize (LayoutingType lt) { + int totSpace = 0; + for (int i = 0; i < Children.Count; i++) { + if (Children [i].Visible) + totSpace += Spacing; + } + if (totSpace > 0) + totSpace -= Spacing; if (lt == LayoutingType.Width) { if (Orientation == Orientation.Horizontal) - return contentSize.Width + (Children.Count - 1) * Spacing + 2 * Margin; + return contentSize.Width + totSpace + 2 * Margin; }else if (Orientation == Orientation.Vertical) - return contentSize.Height + (Children.Count - 1) * Spacing + 2 * Margin; + return contentSize.Height + totSpace + 2 * Margin; return base.measureRawSize (lt); } @@ -103,7 +110,7 @@ namespace Crow public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg) { GraphicObject go = sender as GraphicObject; - Debug.WriteLine ("child layout change: " + go.LastSlots.ToString() + " => " + go.Slot.ToString()); + //Debug.WriteLine ("child layout change: " + go.LastSlots.ToString() + " => " + go.Slot.ToString()); switch (arg.LayoutType) { case LayoutingType.Width: if (Orientation == Orientation.Horizontal) { diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 30aa4a95..549f9a91 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -672,7 +672,6 @@ namespace Crow } /// <summary> By default in groups, LayoutingType.ArrangeChildren is reset </summary> public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){ - } public virtual bool ArrangeChildren { get { return false; } } public virtual void RegisterForLayouting(LayoutingType layoutType){ @@ -680,9 +679,9 @@ namespace Crow return; lock (Interface.CurrentInterface.LayoutMutex) { //dont set position for stretched item - if (Width == 0) + if (Width == Measure.Stretched) layoutType &= (~LayoutingType.X); - if (Height == 0) + if (Height == Measure.Stretched) layoutType &= (~LayoutingType.Y); if (!ArrangeChildren) @@ -786,52 +785,58 @@ namespace Crow Slot.Y = Top; break; case LayoutingType.Width: - if (Width.IsFixed) - Slot.Width = Width; - else if (Width == Measure.Fit) { - Slot.Width = measureRawSize (LayoutingType.Width); - } else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width)) - return false; - else if (Width == Measure.Stretched) - Slot.Width = Parent.ClientRectangle.Width; - else - Slot.Width = (int)Math.Round ((double)(Parent.ClientRectangle.Width * Width) / 100.0); + if (Visible) { + if (Width.IsFixed) + Slot.Width = Width; + else if (Width == Measure.Fit) { + Slot.Width = measureRawSize (LayoutingType.Width); + } else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width)) + return false; + else if (Width == Measure.Stretched) + Slot.Width = Parent.ClientRectangle.Width; + else + Slot.Width = (int)Math.Round ((double)(Parent.ClientRectangle.Width * Width) / 100.0); - if (Slot.Width < 0) - return false; + if (Slot.Width < 0) + return false; - //size constrain - if (Slot.Width < MinimumSize.Width) { - Slot.Width = MinimumSize.Width; - NotifyValueChanged ("WidthPolicy", Measure.Stretched); - } else if (Slot.Width > MaximumSize.Width && MaximumSize.Width > 0) { - Slot.Width = MaximumSize.Width; - NotifyValueChanged ("WidthPolicy", Measure.Stretched); - } + //size constrain + if (Slot.Width < MinimumSize.Width) { + Slot.Width = MinimumSize.Width; + NotifyValueChanged ("WidthPolicy", Measure.Stretched); + } else if (Slot.Width > MaximumSize.Width && MaximumSize.Width > 0) { + Slot.Width = MaximumSize.Width; + NotifyValueChanged ("WidthPolicy", Measure.Stretched); + } + } else + Slot.Width = 0; break; case LayoutingType.Height: - if (Height.IsFixed) - Slot.Height = Height; - else if (Height == Measure.Fit) { - Slot.Height = measureRawSize (LayoutingType.Height); - } else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height)) - return false; - else if (Height == Measure.Stretched) - Slot.Height = Parent.ClientRectangle.Height; - else - Slot.Height = (int)Math.Round ((double)(Parent.ClientRectangle.Height * Height) / 100.0); + if (Visible) { + if (Height.IsFixed) + Slot.Height = Height; + else if (Height == Measure.Fit) { + Slot.Height = measureRawSize (LayoutingType.Height); + } else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height)) + return false; + else if (Height == Measure.Stretched) + Slot.Height = Parent.ClientRectangle.Height; + else + Slot.Height = (int)Math.Round ((double)(Parent.ClientRectangle.Height * Height) / 100.0); - if (Slot.Height < 0) - return false; + if (Slot.Height < 0) + return false; - //size constrain - if (Slot.Height < MinimumSize.Height) { - Slot.Height = MinimumSize.Height; - NotifyValueChanged ("HeightPolicy", Measure.Stretched); - } else if (Slot.Height > MaximumSize.Height && MaximumSize.Height > 0) { - Slot.Height = MaximumSize.Height; - NotifyValueChanged ("HeightPolicy", Measure.Stretched); - } + //size constrain + if (Slot.Height < MinimumSize.Height) { + Slot.Height = MinimumSize.Height; + NotifyValueChanged ("HeightPolicy", Measure.Stretched); + } else if (Slot.Height > MaximumSize.Height && MaximumSize.Height > 0) { + Slot.Height = MaximumSize.Height; + NotifyValueChanged ("HeightPolicy", Measure.Stretched); + } + } else + Slot.Height = 0; break; } diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index 0ff4beca..16a797d7 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -92,6 +92,13 @@ namespace Crow return child == goToFind ? true : child == null ? false : child.Contains(goToFind); } + public override void ChildrenLayoutingConstraints (ref LayoutingType layoutType) + { + if (Width == Measure.Fit) + layoutType &= (~LayoutingType.X); + if (Height == Measure.Fit) + layoutType &= (~LayoutingType.Y); + } public override bool UpdateLayout (LayoutingType layoutType) { if (child != null) { diff --git a/src/GraphicObjects/Splitter.cs b/src/GraphicObjects/Splitter.cs index 6a1f2254..527b4084 100644 --- a/src/GraphicObjects/Splitter.cs +++ b/src/GraphicObjects/Splitter.cs @@ -83,14 +83,14 @@ namespace Crow if (gs.Orientation == Orientation.Horizontal) { if (ptrThis >= 0) - gs.Children [ptrThis - 1].Width = Math.Max(gs.Children [ptrThis - 1].Slot.Width + e.XDelta*2, 1); + gs.Children [ptrThis - 1].Width = Math.Max(gs.Children [ptrThis - 1].Slot.Width + e.XDelta, 1); if (ptrThis < gs.Children.Count - 1) - gs.Children [ptrThis + 1].Width = Math.Max(gs.Children [ptrThis + 1].Slot.Width - e.XDelta*2, 1); + gs.Children [ptrThis + 1].Width = Math.Max(gs.Children [ptrThis + 1].Slot.Width - e.XDelta, 1); } else { if (ptrThis >= 0) - gs.Children [ptrThis - 1].Height = Math.Max(gs.Children [ptrThis - 1].Slot.Height + e.YDelta*2, 1); + gs.Children [ptrThis - 1].Height = Math.Max(gs.Children [ptrThis - 1].Slot.Height + e.YDelta, 1); if (ptrThis < gs.Children.Count - 1) - gs.Children [ptrThis + 1].Height = Math.Max(gs.Children [ptrThis + 1].Slot.Height - e.YDelta*2, 1); + gs.Children [ptrThis + 1].Height = Math.Max(gs.Children [ptrThis + 1].Slot.Height - e.YDelta, 1); } } public override bool UpdateLayout (LayoutingType layoutType) @@ -100,12 +100,12 @@ namespace Crow if (gs.Orientation == Orientation.Horizontal) Width = thickness; else - Width = 0; + Width = Measure.Stretched; } else if (layoutType == LayoutingType.Height){ if (gs.Orientation == Orientation.Vertical) Height = thickness; else - Height = 0; + Height = Measure.Stretched; } return base.UpdateLayout (layoutType); } |