]> O.S.I.I.S - jp/crow.git/commitdiff
tab sizing adjustment
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 6 Mar 2018 18:09:09 +0000 (19:09 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 6 Mar 2018 18:09:09 +0000 (19:09 +0100)
Tests/Interfaces/TabItem.template
src/GraphicObjects/TabView.cs

index 084dae8eef7c515f893e6b48cb3112233cb319c1..63e31cce6f2cbb6e8c736bfeab5e9f05f63e849f 100644 (file)
@@ -8,10 +8,9 @@
                HorizontalAlignment="Left"
                Height="{./TabHeight}"
                Width="{./TabWidth}">
-               <Label Name="caption" Text="{./Caption}" Foreground="Gray"/>
+               <Label Name="caption" Text="{./Caption}" Foreground="Gray" Width="Stretched"/>
                <Label Text="{./ViewIndex}" Foreground="Green"/>
                <Label Text="{./TabOffset}" Foreground="Red"/>
-               <GraphicObject Height="1"/>
                <Border CornerRadius="5" BorderWidth="1" Foreground="Transparent"  Height="12" Width="12"
                                        MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}">
                        <Image Focusable="true" Name="Image" Margin="0" Width="Stretched" Height="Stretched" Path="#Crow.Images.Icons.exit2.svg"
index 06721651b57e7cb759cc0b663be5da2757793105..49d8729d4a1f0f6dd7a8be3ed02dfb315180b86b 100644 (file)
@@ -41,7 +41,7 @@ namespace Crow
                #endregion
 
                #region Private fields
-               int spacing;
+               int adjustedTab = -1;
                int leftSlope;
                int rightSlope;
                Measure tabHeight, tabWidth;
@@ -111,12 +111,12 @@ namespace Crow
                }
                [DefaultValue("120")]
                public Measure TabWidth {
-                       get { return tabWidth; }
+                       get { return adjustedTab > 0 ? (Measure)adjustedTab : tabWidth; }
                        set {
                                if (tabWidth == value)
                                        return;
                                tabWidth = value;
-                               NotifyValueChanged ("TabWidth", tabWidth);
+                               NotifyValueChanged ("TabWidth", TabWidth);
 //
 //                             childrenRWLock.EnterReadLock ();
 //                             foreach (GraphicObject ti in Children) { 
@@ -205,11 +205,17 @@ namespace Crow
                                Rectangle cb = ClientRectangle;
 
                                int tabSpace = tabWidth + leftSlope;
-                               int tc = Children.Count (c => c.Visible == true)-1;
+                               int tc = Children.Count (c => c.Visible == true);
+
                                if (tc > 0)
-                                       tabSpace = Math.Min(tabSpace, (cb.Width-tabSpace-rightSlope) / tc);
+                                       tabSpace = Math.Min(tabSpace, (cb.Width-rightSlope) / tc);
+
+                               if (tabSpace < tabWidth + leftSlope)
+                                       adjustedTab = tabSpace - leftSlope;
+                               else
+                                       adjustedTab = -1;
 
-                               //Console.WriteLine ("tabspace: {0} cb:{1}", tabSpace, cb);
+                               Console.WriteLine ("tabspace: {0} tw:{1}", tabSpace, tabWidth);
 
                                childrenRWLock.EnterReadLock();
                                TabItem[] tabItms = Children.Cast<TabItem>().OrderBy (t=>t.ViewIndex).ToArray();
@@ -220,7 +226,7 @@ namespace Crow
                                        if (!tabItms [i].Visible)
                                                continue;
                                        tabItms [i].NotifyValueChanged ("TabHeight", tabHeight);
-                                       tabItms [i].NotifyValueChanged ("TabWidth", tabWidth);
+                                       tabItms [i].NotifyValueChanged ("TabWidth", TabWidth);
                                        if (!tabItms [i].HoldCursor) {
                                                tabItms [i].TabOffset = curOffset;
                                                //Console.WriteLine ("offset: {0}=>{1}", tabItms [i].Name, tabItms [i].TabOffset);
@@ -310,7 +316,7 @@ namespace Crow
                        Point p = ScreenPointToLocal (IFace.Mouse.Position) - Margin;
 
                        p.X = Math.Max (leftSlope, p.X);
-                       p.X = Math.Min (ClientRectangle.Width - rightSlope - tabWidth, p.X);
+                       p.X = Math.Min (ClientRectangle.Width - rightSlope - TabWidth, p.X);
                        ti.TabOffset = p.X;
 
                        IFace.ClearDragImage ();