diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-03-06 19:09:09 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-03-06 19:09:09 +0100 |
| commit | 5f98acc7dac6255fceb81da2b8f7e37ffcbec1e8 (patch) | |
| tree | 475006f3bbbd8764a3ae72732a6e39d0b3c08bb8 | |
| parent | 8c42e8eb2016ca433cc7adea278a27800f9f0050 (diff) | |
tab sizing adjustment
| -rw-r--r-- | Tests/Interfaces/TabItem.template | 3 | ||||
| -rw-r--r-- | src/GraphicObjects/TabView.cs | 22 |
2 files changed, 15 insertions, 10 deletions
diff --git a/Tests/Interfaces/TabItem.template b/Tests/Interfaces/TabItem.template index 084dae8e..63e31cce 100644 --- a/Tests/Interfaces/TabItem.template +++ b/Tests/Interfaces/TabItem.template @@ -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" diff --git a/src/GraphicObjects/TabView.cs b/src/GraphicObjects/TabView.cs index 06721651..49d8729d 100644 --- a/src/GraphicObjects/TabView.cs +++ b/src/GraphicObjects/TabView.cs @@ -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 (); |