From: Jean-Philippe Bruyère Date: Thu, 25 Mar 2021 11:43:58 +0000 (+0100) Subject: experimental Table and TableRow widgets, passed child widget instance on ChildrenLayo... X-Git-Tag: v0.9.5-beta~53 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=d5aaa4f9be920a92256d68d8c14084953be8c94f;p=jp%2Fcrow.git experimental Table and TableRow widgets, passed child widget instance on ChildrenLayoutingConstraints call --- diff --git a/Crow/src/Widgets/GenericStack.cs b/Crow/src/Widgets/GenericStack.cs index de33aa2a..44b87133 100644 --- a/Crow/src/Widgets/GenericStack.cs +++ b/Crow/src/Widgets/GenericStack.cs @@ -47,8 +47,8 @@ namespace Crow { #endregion #region GraphicObject Overrides - public override bool ArrangeChildren { get { return true; } } - public override void ChildrenLayoutingConstraints (ref LayoutingType layoutType) { + public override bool ArrangeChildren => true; + public override void ChildrenLayoutingConstraints (ILayoutable layoutable, ref LayoutingType layoutType) { //Prevent child repositionning in the direction of stacking if (Orientation == Orientation.Horizontal) layoutType &= (~LayoutingType.X); @@ -104,39 +104,44 @@ namespace Crow { return base.UpdateLayout (layoutType); } + //force computed slot for child + protected void setChildWidth (Widget w, int newW) { + if (w.MaximumSize.Width > 0) + newW = Math.Min (newW, w.MaximumSize.Width); + + if (newW == w.Slot.Width) + return; + + w.Slot.Width = newW; + w.IsDirty = true; + w.LayoutChanged -= OnChildLayoutChanges; + w.OnLayoutChanges (LayoutingType.Width); + w.LayoutChanged += OnChildLayoutChanges; + w.LastSlots.Width = w.Slot.Width; + } + protected void setChildHeight (Widget w, int newH) { + if (w.MaximumSize.Height > 0) + newH = Math.Min (newH, w.MaximumSize.Height); + + if (newH == w.Slot.Height) + return; + w.Slot.Height = newH; + w.IsDirty = true; + w.LayoutChanged -= OnChildLayoutChanges; + w.OnLayoutChanges (LayoutingType.Height); + w.LayoutChanged += OnChildLayoutChanges; + w.LastSlots.Height = w.Slot.Height; + } void adjustStretchedGo (LayoutingType lt) { if (stretchedGO == null) return; - if (lt == LayoutingType.Width) { - int newW = Math.Max ( - this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1), - stretchedGO.MinimumSize.Width); - if (stretchedGO.MaximumSize.Width > 0) - newW = Math.Min (newW, stretchedGO.MaximumSize.Width); - if (newW != stretchedGO.Slot.Width) { - stretchedGO.Slot.Width = newW; - stretchedGO.IsDirty = true; - stretchedGO.LayoutChanged -= OnChildLayoutChanges; - stretchedGO.OnLayoutChanges (LayoutingType.Width); - stretchedGO.LayoutChanged += OnChildLayoutChanges; - stretchedGO.LastSlots.Width = stretchedGO.Slot.Width; - } - } else { - int newH = Math.Max ( - this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1), - stretchedGO.MinimumSize.Height); - if (stretchedGO.MaximumSize.Height > 0) - newH = Math.Min (newH, stretchedGO.MaximumSize.Height); - if (newH != stretchedGO.Slot.Height) { - stretchedGO.Slot.Height = newH; - stretchedGO.IsDirty = true; - stretchedGO.LayoutChanged -= OnChildLayoutChanges; - stretchedGO.OnLayoutChanges (LayoutingType.Height); - stretchedGO.LayoutChanged += OnChildLayoutChanges; - stretchedGO.LastSlots.Height = stretchedGO.Slot.Height; - } - } + if (lt == LayoutingType.Width) + setChildWidth (stretchedGO, Math.Max ( + ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1), stretchedGO.MinimumSize.Width)); + else + setChildHeight (stretchedGO, Math.Max ( + ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1), stretchedGO.MinimumSize.Height)); } public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg) { diff --git a/Crow/src/Widgets/Grid.cs b/Crow/src/Widgets/Grid.cs index 56b37f16..1bf74d1a 100644 --- a/Crow/src/Widgets/Grid.cs +++ b/Crow/src/Widgets/Grid.cs @@ -116,7 +116,7 @@ namespace Crow // // return tmp; // } - public override void ChildrenLayoutingConstraints (ref LayoutingType layoutType) + public override void ChildrenLayoutingConstraints (ILayoutable layoutable, ref LayoutingType layoutType) { //Prevent child repositionning layoutType &= (~LayoutingType.Positioning); diff --git a/Crow/src/Widgets/Group.cs b/Crow/src/Widgets/Group.cs index 5f6a97f8..7625493c 100644 --- a/Crow/src/Widgets/Group.cs +++ b/Crow/src/Widgets/Group.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2013-2020 Jean-Philippe Bruyère +// Copyright (c) 2013-2021 Jean-Philippe Bruyère // // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) @@ -57,13 +57,11 @@ namespace Crow bool _multiSelect = false; List children = new List(); - public virtual List Children { - get { return children; } - } + public virtual List Children => children; [DefaultValue(false)] public bool MultiSelect { - get { return _multiSelect; } + get => _multiSelect; set { _multiSelect = value; } } public virtual void AddChild(Widget g){ @@ -310,41 +308,41 @@ namespace Crow protected override void UpdateCache (Context ctx) { if (!Clipping.IsEmpty) { - Context gr = new Context (bmp); - for (int i = 0; i < Clipping.NumRectangles; i++) - gr.Rectangle(Clipping.GetRectangle(i)); - gr.ClipPreserve(); - gr.Operator = Operator.Clear; - gr.Fill(); - gr.Operator = Operator.Over; - - base.onDraw (gr); - - if (ClipToClientRect) { - CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius); - gr.Clip (); - } + using (Context gr = new Context (bmp)) { + for (int i = 0; i < Clipping.NumRectangles; i++) + gr.Rectangle(Clipping.GetRectangle(i)); + gr.ClipPreserve(); + gr.Operator = Operator.Clear; + gr.Fill(); + gr.Operator = Operator.Over; + + base.onDraw (gr); + + if (ClipToClientRect) { + CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius); + gr.Clip (); + } + + childrenRWLock.EnterReadLock (); + + foreach (Widget c in Children) { + if (!c.Visible) + continue; + if (Clipping.Contains (c.Slot + ClientRectangle.Position) == RegionOverlap.Out) + continue; + c.Paint (gr); + } - childrenRWLock.EnterReadLock (); + childrenRWLock.ExitReadLock (); - foreach (Widget c in Children) { - if (!c.Visible) - continue; - if (Clipping.Contains (c.Slot + ClientRectangle.Position) == RegionOverlap.Out) - continue; - c.Paint (gr); + #if DEBUG_CLIP_RECTANGLE + /*gr.LineWidth = 1; + gr.SetSourceColor(Color.DarkMagenta.AdjustAlpha (0.8)); + for (int i = 0; i < Clipping.NumRectangles; i++) + gr.Rectangle(Clipping.GetRectangle(i)); + gr.Stroke ();*/ + #endif } - - childrenRWLock.ExitReadLock (); - - #if DEBUG_CLIP_RECTANGLE - /*gr.LineWidth = 1; - gr.SetSourceColor(Color.DarkMagenta.AdjustAlpha (0.8)); - for (int i = 0; i < Clipping.NumRectangles; i++) - gr.Rectangle(Clipping.GetRectangle(i)); - gr.Stroke ();*/ - #endif - gr.Dispose (); Clipping.Reset (); }/*else Console.WriteLine("GROUP REPAINT WITH EMPTY CLIPPING");*/ diff --git a/Crow/src/Widgets/HorizontalStack.cs b/Crow/src/Widgets/HorizontalStack.cs index a6b0fd56..13676e30 100644 --- a/Crow/src/Widgets/HorizontalStack.cs +++ b/Crow/src/Widgets/HorizontalStack.cs @@ -20,7 +20,8 @@ namespace Crow [XmlIgnore] public override Orientation Orientation { - get { return Orientation.Horizontal; } + get => Orientation.Horizontal; + set { base.Orientation = Orientation.Horizontal; } } } } diff --git a/Crow/src/Widgets/ILayoutable.cs b/Crow/src/Widgets/ILayoutable.cs index c8aa38fb..5a03b7da 100644 --- a/Crow/src/Widgets/ILayoutable.cs +++ b/Crow/src/Widgets/ILayoutable.cs @@ -1,28 +1,6 @@ -// -// ILayoutable.cs +// Copyright (c) 2013-2021 Jean-Philippe Bruyère // -// Author: -// Jean-Philippe Bruyère -// -// Copyright (c) 2013-2017 Jean-Philippe Bruyère -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; using System.Collections.Generic; @@ -42,6 +20,7 @@ namespace Crow bool ArrangeChildren { get; } LayoutingType RegisteredLayoutings { get; set; } + void ChildrenLayoutingConstraints(ILayoutable layoutable, ref LayoutingType layoutType); void RegisterForLayouting(LayoutingType layoutType); void RegisterClip(Rectangle clip); bool UpdateLayout(LayoutingType layoutType); diff --git a/Crow/src/Widgets/ListItem.cs b/Crow/src/Widgets/ListItem.cs index 2ed49291..c0bdc23f 100644 --- a/Crow/src/Widgets/ListItem.cs +++ b/Crow/src/Widgets/ListItem.cs @@ -10,7 +10,7 @@ namespace Crow /// Top container to use as ItemTemplate's root for TemplatedGroups (lists, treeviews, ...) that add selection /// status and events /// - public class ListItem : Container + public class ListItem : Container, ISelectable { #region CTOR public ListItem (){} diff --git a/Crow/src/Widgets/Splitter.cs b/Crow/src/Widgets/Splitter.cs index e9b74cd3..99db30c1 100644 --- a/Crow/src/Widgets/Splitter.cs +++ b/Crow/src/Widgets/Splitter.cs @@ -58,7 +58,7 @@ namespace Crow if (value != null) { GenericStack gs = value as GenericStack; if (gs == null) - throw new Exception ("Splitter may only be chil of stack"); + throw new Exception ("Splitter may only be child of stack"); } base.Parent = value; diff --git a/Crow/src/Widgets/Table.cs b/Crow/src/Widgets/Table.cs index 10f6376f..3719e3e2 100644 --- a/Crow/src/Widgets/Table.cs +++ b/Crow/src/Widgets/Table.cs @@ -1,7 +1,11 @@ -// Copyright (c) 2019 Jean-Philippe Bruyère +// Copyright (c) 2019-2021 Jean-Philippe Bruyère // // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; +using System.ComponentModel; +using System.Linq; +using Crow.Cairo; + namespace Crow { /// @@ -16,7 +20,9 @@ namespace Crow #endregion string caption; - Measure width = Measure.Inherit; + Measure width = Measure.Fit; + //public int ComputedWidth; + public Widget LargestWidget; public string Caption { get => caption; @@ -41,19 +47,140 @@ namespace Crow } } - //public string Data { - - //} + public static Column Parse (string str) { + if (string.IsNullOrEmpty (str)) + return null; + Column c = new Column(); + string[] tmp = str.Split (','); + c.Caption = tmp[0]; + if (tmp.Length > 1) + c.Width = Measure.Parse (tmp[1]); + return c; + } } - public class Table : TemplatedGroup + public class Table : VerticalStack { #region CTOR public Table () {} public Table (Interface iface, string style = null) : base (iface, style) { } #endregion - public ObservableList Columns = new ObservableList (); - } + //int lineWidth; + ObservableList columns = new ObservableList(); + + /*[DefaultValue (1)] + public int LineWidth { + get => lineWidth; + set { + if (lineWidth == value) + return; + lineWidth = value; + NotifyValueChangedAuto (lineWidth); + RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren); + } + }*/ + + public ObservableList Columns { + get => columns; + set { + if (columns == value) + return; + columns = value; + NotifyValueChangedAuto(columns); + } + } + public override void AddChild (Widget child) { + TableRow tr = child as TableRow; + if (tr == null) + throw new Exception ("Table widget accept only TableRow as child."); + base.AddChild (child); + } + /*public override void ChildrenLayoutingConstraints(ILayoutable layoutable, ref LayoutingType layoutType) + { + //trigger layouting for width only in the first row, the other will be set at the same horizontal position and width. + if (layoutable == Children[0]) + layoutType &= (~LayoutingType.X); + else + layoutType &= (~(LayoutingType.X|LayoutingType.Width)); + }*/ + + public override void ComputeChildrenPositions () { + int d = 0; + childrenRWLock.EnterReadLock(); + foreach (Widget c in Children) { + if (!c.Visible) + continue; + c.Slot.Y = d; + d += c.Slot.Height + Spacing; + } + childrenRWLock.ExitReadLock(); + IsDirty = true; + } + public override bool UpdateLayout(LayoutingType layoutType) + { + RegisteredLayoutings &= (~layoutType); + + if (layoutType == LayoutingType.Width) { + foreach (TableRow row in Children) { + for (int i = 0; i < Columns.Count && i < row.Children.Count; i++) + row.Children[i].Width = Columns[i].Width; + } + } + return base.UpdateLayout(layoutType); + } + + /*public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg) { + TableRow row = sender as TableRow; + TableRow firstRow = Children[0] as TableRow; + + if (arg.LayoutType == LayoutingType.Width) { + if (row == firstRow) { + base.OnChildLayoutChanges (sender, arg); + foreach (TableRow r in Children.Skip(1)) { + r.contentSize = firstRow.contentSize; + setChildWidth (r, firstRow.Slot.Width); + } + } + } + + base.OnChildLayoutChanges (sender, arg); + }*/ + /*protected override void onDraw (Context gr) { + DbgLogger.StartEvent (DbgEvtType.GODraw, this); + + base.onDraw (gr); + + if (Children.Count > 0) { + + Rectangle cb = ClientRectangle; + TableRow fr = Children[0] as TableRow; + + + gr.LineWidth = lineWidth; + Foreground.SetAsSource (IFace, gr, cb); + CairoHelpers.CairoRectangle (gr, cb, CornerRadius, lineWidth); + double x = 0.5 + cb.Left + fr.Margin + 0.5 * fr.Spacing + fr.Children[0].Slot.Width; + for (int i = 1; i < fr.Children.Count ; i++) + { + gr.MoveTo (x, cb.Y); + gr.LineTo (x, cb.Bottom); + x += fr.Spacing + fr.Children[i].Slot.Width ; + } + + //horizontal lines + x = 0.5 + cb.Top + 0.5 * Spacing + Children[0].Slot.Height; + for (int i = 0; i < Children.Count - 1; i++) + { + gr.MoveTo (cb.Left, x); + gr.LineTo (cb.Right, x); + x += Spacing + Children[i].Slot.Height ; + } + gr.Stroke (); + } + + DbgLogger.EndEvent (DbgEvtType.GODraw); + }*/ + } } diff --git a/Crow/src/Widgets/TableRow.cs b/Crow/src/Widgets/TableRow.cs new file mode 100644 index 00000000..27547718 --- /dev/null +++ b/Crow/src/Widgets/TableRow.cs @@ -0,0 +1,146 @@ +using System.Linq; +// Copyright (c) 2019-2021 Jean-Philippe Bruyère +// +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) +using System; +using System.ComponentModel; + +namespace Crow +{ + public class TableRow : HorizontalStack, ISelectable { + #region ISelectable implementation + bool isSelected; + + public event EventHandler Selected; + public event EventHandler Unselected; + + [DefaultValue (false)] + public virtual bool IsSelected { + get { return isSelected; } + set { + if (isSelected == value) + return; + isSelected = value; + + if (isSelected) + Selected.Raise (this, null); + else + Unselected.Raise (this, null); + + NotifyValueChangedAuto (isSelected); + } + } + #endregion + + int spacing; + + public Table Table => Parent as Table; + + /*public override void ChildrenLayoutingConstraints(ILayoutable layoutable, ref LayoutingType layoutType) + { + //trigger layouting for width only in the first row, the other will be set at the same horizontal position and width. + if (Table == null) { + base.ChildrenLayoutingConstraints (layoutable, ref layoutType); + return; + } + if (this == Table.Children[0]) + layoutType &= (~LayoutingType.X); + else + layoutType &= (~(LayoutingType.X|LayoutingType.Width)); + }*/ + + public override void ComputeChildrenPositions () { + if (Children.Count == 0) + return; + int spacing = Table.Spacing; + ObservableList cols = Table.Columns; + + //int d = 0; + Widget first = Children[0]; + TableRow firstRow = Table.Children[0] as TableRow; + if (firstRow == this) { + base.ComputeChildrenPositions(); + return; + } + childrenRWLock.EnterReadLock(); + for (int i = 0; i < Children.Count && i < firstRow.Children.Count; i++) + { + Widget w = Children[i]; + w.Slot.X = firstRow.Children[i].Slot.X; + setChildWidth (w, firstRow.Children[i].Slot.Width); + //d += spacing + firstRow.Children[i].Slot.Width; + } + + childrenRWLock.ExitReadLock(); + IsDirty = true; + } + + public override bool UpdateLayout(LayoutingType layoutType) + { + RegisteredLayoutings &= (~layoutType); + + if (Table == null) + return false; + TableRow firstRow = Table.Children[0] as TableRow; + if (layoutType == LayoutingType.Width) { + if (firstRow.RegisteredLayoutings.HasFlag (LayoutingType.Width)) + return false; + if (this != firstRow) { + //contentSize = firstRow.contentSize; + Slot.Width = firstRow.Slot.Width; + if (Slot.Width != LastSlots.Width) { + IsDirty = true; + OnLayoutChanges (layoutType); + LastSlots.Width = Slot.Width; + } + if (RegisteredLayoutings == LayoutingType.None && IsDirty) + IFace.EnqueueForRepaint (this); + + return true; + } + } + + return base.UpdateLayout(layoutType); + } + /*public override int measureRawSize (LayoutingType lt) { + if (lt == LayoutingType.Width) { + if (Table == null) + return -1; + TableRow firstRow = Table.Children[0] as TableRow; + if (this != firstRow) { + if (firstRow.RegisteredLayoutings.HasFlag (LayoutingType.Width)) + return -1; + contentSize = firstRow.contentSize; + return firstRow.measureRawSize (lt); + } + + } + return base.measureRawSize (lt); + }*/ + public override void OnLayoutChanges(LayoutingType layoutType) + { + base.OnLayoutChanges(layoutType); + } + /*public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg) { + Widget go = sender as Widget; + TableRow row = go.Parent as TableRow; + TableRow firstRow = Table.Children[0] as TableRow; + + if (arg.LayoutType == LayoutingType.Width) { + if (row == firstRow) { + base.OnChildLayoutChanges (sender, arg); + int idx = Children.IndexOf (go); + foreach (TableRow r in Table.Children.Skip(1)) { + if (idx < r.Children.Count) + r.setChildWidth (r.Children[idx], go.Slot.Width); + r.contentSize = firstRow.contentSize; + } + } //else + this.RegisterForLayouting (LayoutingType.ArrangeChildren); + return; + } + + base.OnChildLayoutChanges (sender, arg); + }*/ + } +} diff --git a/Crow/src/Widgets/TemplatedGroup.cs b/Crow/src/Widgets/TemplatedGroup.cs index 36b117eb..3e22480e 100644 --- a/Crow/src/Widgets/TemplatedGroup.cs +++ b/Crow/src/Widgets/TemplatedGroup.cs @@ -498,10 +498,10 @@ namespace Crow { } internal virtual void itemClick(object sender, MouseButtonEventArgs e){ //SelectedIndex = (int)((IList)data)?.IndexOf((sender as Widget).DataSource); - if (selectedItemContainer is ListItem li) + if (selectedItemContainer is ISelectable li) li.IsSelected = false; selectedItemContainer = sender as Widget; - if (selectedItemContainer is ListItem nli) + if (selectedItemContainer is ISelectable nli) nli.IsSelected = true; if (selectedItemContainer == null) return; diff --git a/Crow/src/Widgets/VerticalStack.cs b/Crow/src/Widgets/VerticalStack.cs index a0574ce2..ac4236b1 100644 --- a/Crow/src/Widgets/VerticalStack.cs +++ b/Crow/src/Widgets/VerticalStack.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2013-2020 Jean-Philippe Bruyère +// Copyright (c) 2013-2021 Jean-Philippe Bruyère // // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) @@ -16,7 +16,8 @@ namespace Crow [XmlIgnore] public override Orientation Orientation { - get => Orientation.Vertical; + get => Orientation.Vertical; + set { base.Orientation = Orientation.Vertical; } } } } diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index 4c35c153..90875580 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -510,7 +510,7 @@ namespace Crow /// /// If true, rendering of GraphicObject is clipped inside client rectangle /// - [DesignCategory ("Appearance")][DefaultValue(true)] + [DesignCategory ("Appearance")][DefaultValue(false)] public virtual bool ClipToClientRect { get { return clipToClientRect; } set { @@ -1530,9 +1530,6 @@ namespace Crow return lt == LayoutingType.Width ? contentSize.Width + 2 * margin: contentSize.Height + 2 * margin; } - /// By default in groups, LayoutingType.ArrangeChildren is reset - public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){ - } internal bool firstUnresolvedFitWidth (out Widget ancestorInUnresolvedFit) { @@ -1549,11 +1546,19 @@ namespace Crow } public virtual bool ArrangeChildren { get { return false; } } + /// + /// Used to prevent some layouting type in children. For example, in the GenericStack, + /// x layouting is dismissed in the direction of the stacking to let the parent + /// arrange children in the x direction. + /// + /// The children that is calling the constraints + /// The currently registering layouting types + public virtual void ChildrenLayoutingConstraints(ILayoutable layoutable, ref LayoutingType layoutType){ } /// Query a layouting for the type pass as parameter, redraw only if layout changed. public virtual void RegisterForLayouting(LayoutingType layoutType){ -#if DEBUG +#if DEBUG_LOG if (disposed) { - System.Diagnostics.Debug.WriteLine ($"RegisterForLayouting({layoutType}) for disposed Widget: {this}\n{System.Environment.StackTrace}"); + DbgLogger.AddEvent (DbgEvtType.GORegisterLayouting | DbgEvtType.AlreadyDisposed, this); return; } #endif @@ -1578,8 +1583,7 @@ namespace Crow layoutType &= (~LayoutingType.ArrangeChildren); //apply constraints depending on parent type - if (Parent is Widget) - (Parent as Widget).ChildrenLayoutingConstraints (ref layoutType); + Parent.ChildrenLayoutingConstraints (this, ref layoutType); // //prevent queueing same LayoutingType for this layoutType &= (~RegisteredLayoutings); @@ -1710,13 +1714,11 @@ namespace Crow 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) { + if (Slot.Width < minimumSize.Width) + Slot.Width = minimumSize.Width; + else if (maximumSize.Width > 0 && Slot.Width > maximumSize.Width) Slot.Width = maximumSize.Width; - //NotifyValueChanged ("WidthPolicy", Measure.Stretched); - } + } else Slot.Width = 0; @@ -1746,13 +1748,11 @@ namespace Crow return false; //size constrain - if (Slot.Height < minimumSize.Height) { + if (Slot.Height < minimumSize.Height) Slot.Height = minimumSize.Height; - //NotifyValueChanged ("HeightPolicy", Measure.Stretched); - } else if (Slot.Height > maximumSize.Height && maximumSize.Height > 0) { + else if (maximumSize.Height > 0 && Slot.Height > maximumSize.Height) Slot.Height = maximumSize.Height; - //NotifyValueChanged ("HeightPolicy", Measure.Stretched); - } + } else Slot.Height = 0; @@ -1853,7 +1853,7 @@ namespace Crow Console.ForegroundColor = ConsoleColor.Magenta; if (!isVisible) System.Diagnostics.Debug.WriteLine ($"Paint invisible widget: {this}"); - Console.ForegroundColor = ConsoleColor.Gray; + Console.ResetColor (); #endif DbgLogger.AddEvent (DbgEvtType.Warning); DbgLogger.EndEvent (DbgEvtType.GOPaint); diff --git a/Crow/src/Widgets/Wrapper.cs b/Crow/src/Widgets/Wrapper.cs index 6d792d25..39648139 100644 --- a/Crow/src/Widgets/Wrapper.cs +++ b/Crow/src/Widgets/Wrapper.cs @@ -16,7 +16,7 @@ namespace Crow #endregion #region Group Overrides - public override void ChildrenLayoutingConstraints (ref LayoutingType layoutType) + public override void ChildrenLayoutingConstraints (ILayoutable layoutable, ref LayoutingType layoutType) { layoutType &= (~LayoutingType.Positioning); } diff --git a/Samples/ShowCase/ShowCase.cs b/Samples/ShowCase/ShowCase.cs index a1a5be2a..60e9ea36 100644 --- a/Samples/ShowCase/ShowCase.cs +++ b/Samples/ShowCase/ShowCase.cs @@ -218,11 +218,15 @@ namespace ShowCase crowContainer.SetChild (g); g.DataSource = this; } - } catch (InstantiatorException itorex) { - //Console.WriteLine (itorex); + } catch (InstantiatorException itorex) { + Console.ForegroundColor = ConsoleColor.DarkRed; + Console.WriteLine (itorex); + Console.ResetColor(); showError (itorex.InnerException); } catch (Exception ex) { - //Console.WriteLine (ex); + Console.ForegroundColor = ConsoleColor.DarkRed; + Console.WriteLine (ex); + Console.ResetColor(); showError (ex); } }