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"
#endregion
#region Private fields
- int spacing;
+ int adjustedTab = -1;
int leftSlope;
int rightSlope;
Measure tabHeight, tabWidth;
}
[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) {
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();
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);
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 ();