]> O.S.I.I.S - jp/crow.git/commitdiff
experimental Table and TableRow widgets, passed child widget instance on ChildrenLayo...
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 25 Mar 2021 11:43:58 +0000 (12:43 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 25 Mar 2021 11:43:58 +0000 (12:43 +0100)
14 files changed:
Crow/src/Widgets/GenericStack.cs
Crow/src/Widgets/Grid.cs
Crow/src/Widgets/Group.cs
Crow/src/Widgets/HorizontalStack.cs
Crow/src/Widgets/ILayoutable.cs
Crow/src/Widgets/ListItem.cs
Crow/src/Widgets/Splitter.cs
Crow/src/Widgets/Table.cs
Crow/src/Widgets/TableRow.cs [new file with mode: 0644]
Crow/src/Widgets/TemplatedGroup.cs
Crow/src/Widgets/VerticalStack.cs
Crow/src/Widgets/Widget.cs
Crow/src/Widgets/Wrapper.cs
Samples/ShowCase/ShowCase.cs

index de33aa2aa93fbcf8564cf228c9d5c6fb31b982ce..44b871339744531e9563632ce8bebd8e5c619138 100644 (file)
@@ -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) {
index 56b37f169ca1f98f97a33aa580f2725718fc18e8..1bf74d1ae0e32ffacd9304c649ced6691a688874 100644 (file)
@@ -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);
index 5f6a97f816ddf4d83bf773c81f436f2af4ccac22..7625493cdbb442aed00b56c1404203baa69896aa 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2020  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2021  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
 //
 // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 
@@ -57,13 +57,11 @@ namespace Crow
         bool _multiSelect = false;
                List<Widget> children = new List<Widget>();
 
-        public virtual List<Widget> Children {
-                       get { return children; }
-               }
+        public virtual List<Widget> 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");*/
index a6b0fd56354ce0e7f01dda2346e5134770076073..13676e30cc1e244e41a959f6b7233c3441b0caf3 100644 (file)
@@ -20,7 +20,8 @@ namespace Crow
         [XmlIgnore]
         public override Orientation Orientation
         {
-            get { return Orientation.Horizontal; }
+            get => Orientation.Horizontal;
+            set { base.Orientation = Orientation.Horizontal; }
         }
     }
 }
index c8aa38fbf1d88730755d2d56d843b79d70f5f00a..5a03b7da3eea0934c6b3dd3fe76590c56dbacdc9 100644 (file)
@@ -1,28 +1,6 @@
-//
-// ILayoutable.cs
+// Copyright (c) 2013-2021  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
 //
-// Author:
-//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// 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);
index 2ed492917ea8791de1c714fa798e7af3ae4d70c6..c0bdc23f7aae3e38624836dc3749c9b6770dec89 100644 (file)
@@ -10,7 +10,7 @@ namespace Crow
        /// Top container to use as ItemTemplate's root for TemplatedGroups (lists, treeviews, ...) that add selection
        /// status and events
        /// </summary>
-       public class ListItem : Container
+       public class ListItem : Container, ISelectable
        {
                #region CTOR
                public ListItem (){}
index e9b74cd3867f8b369fc8ea0f29fc7a0f6e685485..99db30c1b417a199ff02acbfaf124e3a90898a6a 100644 (file)
@@ -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;
index 10f6376f3a119f0a4f3c543245453d3dc70f6782..3719e3e22f50cef0a772c6eba9bbe31bddf4c8e5 100644 (file)
@@ -1,7 +1,11 @@
-// Copyright (c) 2019  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2019-2021  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
 //
 // 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
 {
        /// <summary>
@@ -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<Column> Columns = new ObservableList<Column> ();
-       }
+               //int lineWidth;
+               ObservableList<Column> columns = new ObservableList<Column>();
+
+               /*[DefaultValue (1)]
+               public int LineWidth {
+                       get => lineWidth;
+                       set {
+                               if (lineWidth == value)
+                                       return;
+                               lineWidth = value;
+                               NotifyValueChangedAuto (lineWidth);
+                               RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
+                       }
+               }*/
+
+               public ObservableList<Column> 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 (file)
index 0000000..2754771
--- /dev/null
@@ -0,0 +1,146 @@
+using System.Linq;
+// Copyright (c) 2019-2021  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// 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<Column> 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);
+               }*/
+       }
+}
index 36b117ebf0ef3f4f701db2874abe20849b3dcae5..3e22480e4b958d1c1a00c78fbecf986a427df220 100644 (file)
@@ -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;
index a0574ce2cc0cf0e2eb07318f0c8c01b09b9b54f8..ac4236b19ea1a28d8ac3ed4b05abc9607df27794 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2020  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2021  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
 //
 // 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; }
                }
        }
 }
index 4c35c153a298eb0637a84cc8c1d48beca2202a9f..908755809aa6b00f801901e6f2d16a8f04825704 100644 (file)
@@ -510,7 +510,7 @@ namespace Crow
                /// <summary>
                /// If true, rendering of GraphicObject is clipped inside client rectangle
                /// </summary>
-               [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;
                }
-               /// <summary> By default in groups, LayoutingType.ArrangeChildren is reset </summary>
-               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; } }
+               /// <summary>
+               /// 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.
+               /// </summary>
+               /// <param name="layoutable">The children that is calling the constraints</param>
+               /// <param name="layoutType">The currently registering layouting types</param>          
+               public virtual void ChildrenLayoutingConstraints(ILayoutable layoutable, ref LayoutingType layoutType){ }
                /// <summary> Query a layouting for the type pass as parameter, redraw only if layout changed. </summary>
                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);
index 6d792d259740231c9706f59917c4f44b8cc6ee1b..39648139c3656b1efd5639cceae911c87ebf1d6b 100644 (file)
@@ -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);
                }
index a1a5be2adbbdd8e42fee61d7fd1a4b209d29ee18..60e9ea3695439b5dca90cbfcfe811ac6d9fe61c8 100644 (file)
@@ -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);
                        }
                }