<?xml version="1.0" encoding="UTF-8" ?>
<GenericStack Orientation="Vertical" Spacing="0"
- Width="{../../WidthPolicy}" Height="{../../HeightPolicy}">
- <Label Margin="5" Name="TabTitle" Width="-1"
+ Width="{../../WidthPolicy}" Height="{../../HeightPolicy}"
+ Background="vgradient|0:DimGray|1:Black"
+ MouseEnter="{Background=vgradient|0:Gray|1:Black}"
+ MouseLeave="{Background=vgradient|0:DimGray|1:Black}">
+ <HorizontalStack Margin="2" Left="{../../TabOffset}"
+ Name="TabTitle"
HorizontalAlignment="Left"
- Text="{../../Caption}"
Height="{../../../TabThickness}"
- Left="{../../TabOffset}"/>
+ Width="-1">
+ <Label Text="{../../../Caption}"/>
+ <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="0" Height="0" Path="#Crow.Images.Icons.exit2.svg"
+ MouseClick="../../../../butCloseTabClick"/>
+ </Border>
+ </HorizontalStack>
<Container
Name="Content" Width="{../../../WidthPolicy}" Height="{../../../HeightPolicy}"/>
</GenericStack>
<?xml version="1.0" encoding="UTF-8" ?>
<HorizontalStack Fit="true">
- <TabView CacheEnabled="false" Width="400" Height="200" Orientation="Horizontal" Spacing="20" Margin="0">
- <TabItem Name="TabItem1" Caption="tab item 1" Width="0" Height="0" Margin="0" Background="Gray"
- MouseEnter="{Background=Red}" Focusable="true"
- MouseLeave="{Background=Gray}">
+ <TabView Margin="20"
+ Width="400" Height="200" Orientation="Horizontal" Spacing="20">
+ <TabItem Name="TabItem1" Caption="tab item 1" Width="0" Height="0" Margin="0">
<VerticalStack Fit="true">
<CheckBox/>
<CheckBox/>
<Label Text="{fps}" HorizontalAlignment="Right" Foreground="Black" Background="Yellow"/>
</VerticalStack>
</TabItem>
- <TabItem Name="TabItem2" Caption="tab item 2" Width="0" Height="0" Margin="0" Background="Gray"
- MouseEnter="{Background=BlueCrayola}"
- MouseLeave="{Background=Gray}">
+ <TabItem Name="TabItem2" Caption="tab item 2" Width="0" Height="0" Margin="0" Background="Gray">
<VerticalStack Fit="true">
<RadioButton/>
<RadioButton/>
<Label Text="{fps}" HorizontalAlignment="Left" Background="LimeGreen"/>
</VerticalStack>
</TabItem>
- <TabItem Name="TabItem2" Caption="tab item 3" Width="0" Height="0" Margin="0" Background="Gray"
- MouseEnter="{Background=BlueCrayola}"
- MouseLeave="{Background=Gray}">
- <TextBox Width="0" Height="0" Multiline="true" TextAlignment="TopLeft"/>
+ <TabItem Name="TabItem2" Caption="tab item 3" Width="0" Height="0" Margin="0" Background="Gray">
+ <Container Margin="5" CornerRadius="2" Width="0" Height="0">
+ <TextBox Margin="5" Width="0" Height="0" Multiline="true" TextAlignment="TopLeft"/>
+ </Container>
</TabItem>
- <TabItem Name="TabItem2" Caption="tab item 4" Width="0" Height="0" Margin="0" Background="Gray"
- MouseEnter="{Background=BlueCrayola}"
- MouseLeave="{Background=Gray}">
+ <TabItem Name="TabItem2" Caption="tab item 4" Width="0" Height="0" Margin="0" Background="Gray">
<TextBox/>
</TabItem>
</TabView>
<TabView CacheEnabled="false" Width="200" Height="200" Orientation="Horizontal" Spacing="20" Margin="0">
<TabItem
- MouseEnter="{Background=BlueCrayola}"
- MouseLeave="{Background=Gray}"
Name="TabItem1" Caption="tab 1" Width="0" Height="0" Margin="0" Background="Gray">
<VerticalStack Fit="true">
<CheckBox/>
</VerticalStack>
</TabItem>
<TabItem
- MouseEnter="{Background=BlueCrayola}"
- MouseLeave="{Background=Gray}"
Name="TabItem2" Caption="tab 2" Width="0" Height="0" Margin="0" Background="Gray">
<VerticalStack Fit="true">
<RadioButton/>
gr.LineTo (TabTitle.Slot.Left - spacing, TabTitle.Slot.Bottom);
gr.CurveTo (
TabTitle.Slot.Left - spacing / 2, TabTitle.Slot.Bottom,
- TabTitle.Slot.Left - spacing / 2, 0,
- TabTitle.Slot.Left, 0);
- gr.LineTo (TabTitle.Slot.Right, 0);
+ TabTitle.Slot.Left - spacing / 2, 1,
+ TabTitle.Slot.Left, 1);
+ gr.LineTo (TabTitle.Slot.Right, 1);
gr.CurveTo (
- TabTitle.Slot.Right + spacing / 2, 0,
+ TabTitle.Slot.Right + spacing / 2, 1,
TabTitle.Slot.Right + spacing / 2, TabTitle.Slot.Bottom,
TabTitle.Slot.Right + spacing, TabTitle.Slot.Bottom);
gr.LineTo (Slot.Width, TabTitle.Slot.Bottom);
TabView tv = Parent as TabView;
TabItem previous = null, next = null;
int tmp = TabOffset + e.XDelta;
- Debug.WriteLine (tmp);
if (tmp < tv.Spacing)
TabOffset = tv.Spacing;
else if (tmp > Parent.getSlot ().Width - TabTitle.Slot.Width - tv.Spacing)
TabOffset = tmp;
}
}
+ public void butCloseTabClick (object sender, OpenTK.Input.MouseButtonEventArgs e){
+ (Parent as TabView).RemoveChild(this);
+ }
#endregion
}
public virtual int SelectedTab {
get { return selectedTab; }
set {
- if (selectedTab == value)
- return;
-
- (Children [selectedTab] as TabItem).IsSelected = false;
+ if (selectedTab < Children.Count && SelectedTab >= 0)
+ (Children [selectedTab] as TabItem).IsSelected = false;
selectedTab = value;
- (Children [selectedTab] as TabItem).IsSelected = true;
+ if (selectedTab < Children.Count && SelectedTab >= 0)
+ (Children [selectedTab] as TabItem).IsSelected = true;
NotifyValueChanged ("SelectedTab", selectedTab);
registerForGraphicUpdate ();
}
}
int tabThickness;
- [XmlAttributeAttribute()][DefaultValue(20)]
+ [XmlAttributeAttribute()][DefaultValue(22)]
public virtual int TabThickness {
get { return tabThickness; }
set {
NotifyValueChanged ("TabThickness", tabThickness);
}
}
+
+ //prevent caching, because drawing order is different depending on selected tab
+ [XmlAttributeAttribute()][DefaultValue(false)]
+ public override bool CacheEnabled {
+ get {return false;}
+ set { }
+ }
+
public override T AddChild<T> (T child)
{
TabItem ti = child as TabItem;
}
public override void RemoveChild (GraphicObject child)
{
- TabItem ti = child as TabItem;
+ int idx = Children.IndexOf (child);
base.RemoveChild (child);
- if (ti.IsSelected)
- SelectedTab = Math.Min(0, Children.Count - 1);
-
+ if (selectedTab > Children.Count - 1)
+ SelectedTab--;
+ else
+ SelectedTab = selectedTab;
}
public override bool ArrangeChildren { get { return true; } }
public override bool UpdateLayout (LayoutingType layoutType)
continue;
Children [i].Paint (ref gr);
}
- Children [SelectedTab].Paint (ref gr);
+
+ if (SelectedTab < Children.Count && SelectedTab >= 0)
+ Children [SelectedTab].Paint (ref gr);
gr.Restore ();
}
HostContainer.hoverWidget = this;
onMouseEnter (this, e);
}
+
+ if (SelectedTab > Children.Count - 1)
+ return;
+
if (((Children[SelectedTab] as TabItem).Content.Parent as GraphicObject).MouseIsIn(e.Position))
{
Children[SelectedTab].checkHoverWidget (e);