This commit is contained in:
Zihan Chen
2021-06-18 19:14:47 -07:00
parent da6e54de30
commit aee14901e5
6 changed files with 68 additions and 42 deletions

View File

@@ -26,7 +26,7 @@
documentViewer.Text = text;
}
]]></ref.Ctor>
<TabPage Text-eval="Sys::LoremIpsumTitle(16)">
<TabPage Text-eval="Sys::LoremIpsumTitle(12)">
<DocumentViewer ref.Name="documentViewer" EditMode="Selectable" HorizontalAlwaysVisible="false" VerticalAlwaysVisible="false">
<att.BoundsComposition-set AlignmentToParent="left:5 top:5 right:5 bottom:5"/>
</DocumentViewer>

View File

@@ -26,20 +26,20 @@
{
if (remoteHeaderContainer is not null)
{
remoteHeaderContainer.RemoveChild(header);
remoteHeaderContainer.RemoveChild(headerTable);
}
else
{
headerContainer.RemoveChild(header);
headerContainer.RemoveChild(headerTable);
}
remoteHeaderContainer = value;
if (remoteHeaderContainer is not null)
{
remoteHeaderContainer.AddChild(header);
remoteHeaderContainer.AddChild(headerTable);
}
else
{
headerContainer.AddChild(header);
headerContainer.AddChild(headerTable);
}
}
]]>
@@ -53,7 +53,7 @@
]]>
</ev.SelectedTabPageChanged-eval>
<Table ref.Name="headerTable" AlignmentToParent="left:0 top:0 right:0 bottom:0" MinSizeLimitation="LimitToElementAndChildren">
<Table AlignmentToParent="left:0 top:0 right:0 bottom:0" MinSizeLimitation="LimitToElementAndChildren">
<SolidBackground Color="#2D2D30"/>
<att.Rows>
<CellOption>composeType:MinSize</CellOption>
@@ -65,27 +65,29 @@
</att.Columns>
<Cell ref.Name="headerContainer" Site="row:0 column:0">
<RepeatFlow ref.Name="header" AlignmentToParent="left:0 top:-1 right:0 bottom:0" ExtraMargin="left:2 top:2 right:2 bottom:0" MinSizeLimitation="LimitToElementAndChildren">
<att.ItemTemplate>sample::TabWindowTabHeaderTemplate</att.ItemTemplate>
<att.ItemSource-bind>self.TabPages</att.ItemSource-bind>
<ev.ItemInserted-eval>
<![CDATA[
{
var flowItem = header.FlowItems[arguments.itemIndex];
var item = cast (TabWindowTabHeaderTemplate*) flowItem.Children[0];
item.Commands = self.Commands;
self.UpdateTabHeader();
}
]]>
</ev.ItemInserted-eval>
<ev.ItemRemoved-eval>
<![CDATA[
{
self.UpdateTabHeader();
}
]]>
</ev.ItemRemoved-eval>
</RepeatFlow>
<Bounds ref.Name="headerTable" AlignmentToParent="left:0 top:0 right:0 bottom:0" MinSizeLimitation="LimitToElementAndChildren">
<RepeatFlow ref.Name="header" AlignmentToParent="left:0 top:-1 right:0 bottom:0" ExtraMargin="left:2 top:2 right:2 bottom:0" MinSizeLimitation="LimitToElementAndChildren">
<att.ItemTemplate>sample::TabWindowTabHeaderTemplate</att.ItemTemplate>
<att.ItemSource-bind>self.TabPages</att.ItemSource-bind>
<ev.ItemInserted-eval>
<![CDATA[
{
var flowItem = header.FlowItems[arguments.itemIndex];
var item = cast (TabWindowTabHeaderTemplate*) flowItem.Children[0];
item.Commands = self.Commands;
self.UpdateTabHeader();
}
]]>
</ev.ItemInserted-eval>
<ev.ItemRemoved-eval>
<![CDATA[
{
self.UpdateTabHeader();
}
]]>
</ev.ItemRemoved-eval>
</RepeatFlow>
</Bounds>
</Cell>
<Cell Site="row:1 column:0">
<SolidBackground Color="#007ACC"/>

View File

@@ -20,6 +20,18 @@
}
]]>
</ev.Clicked-eval>
<Button Text="X">
<ev.Clicked-eval><![CDATA[
{
var tabPage = CurrentTabPage;
Application::GetApplication().InvokeInMainThread(tabPage.RelatedControlHost, func():void
{
tabPage.OwnerTab.Pages.Remove(tabPage);
delete tabPage;
});
}
]]></ev.Clicked-eval>
</Button>
</CheckBox>
</ControlTemplate>
</Instance>

View File

@@ -4,7 +4,7 @@
prop TabFocused: bool = false {}
]]>
</ref.Members>
<SelectableButtonTemplate ref.Name="self" MinSizeLimitation="LimitToElementAndChildren">
<SelectableButtonTemplate ref.Name="self" MinSizeLimitation="LimitToElementAndChildren" ContainerComposition-ref="container">
<att.TabFocused-bind>(cast (TabPage*) self.Context).OwnerTab.Focused ?? false</att.TabFocused-bind>
<SolidBackground>
<att.Color-bind>
@@ -21,19 +21,31 @@
<Bounds AlignmentToParent="left:1 top:1 right:1 bottom:1" Visible-bind="self.Selected and self.TabFocused" MinSizeLimitation="LimitToElementAndChildren">
<FocusRectangle/>
</Bounds>
<Bounds AlignmentToParent="left:6 top:3 right:6 bottom:3" MinSizeLimitation="LimitToElementAndChildren">
<SolidLabel Text-bind="self.Text" Font-bind="self.Font" HorizontalAlignment="Center" VerticalAlignment="Center">
<att.Color-bind>
<![CDATA[
cast Color let state = self.State in (
not self.VisuallyEnabled ? "#6D6D6D" :
state == ButtonState::Active ? "#F1F1F1" :
state == ButtonState::Pressed ? "#FFFFFF" :
"#F1F1F1"
)
]]>
</att.Color-bind>
</SolidLabel>
</Bounds>
<Table AlignmentToParent="left:3 top:0 right:0 bottom:0" CellPadding="3" BorderVisible="true" MinSizeLimitation="LimitToElementAndChildren">
<att.Rows>
<CellOption>composeType:Percentage percentage:1.0</CellOption>
<CellOption>composeType:MinSize</CellOption>
</att.Rows>
<att.Columns>
<CellOption>composeType:Percentage percentage:1.0</CellOption>
<CellOption>composeType:MinSize</CellOption>
</att.Columns>
<Cell Site="row:0 column:0 rowSpan:2">
<SolidLabel Text-bind="self.Text" Font-bind="self.Font" HorizontalAlignment="Center" VerticalAlignment="Center">
<att.Color-bind>
<![CDATA[
cast Color let state = self.State in (
not self.VisuallyEnabled ? "#6D6D6D" :
state == ButtonState::Active ? "#F1F1F1" :
state == ButtonState::Pressed ? "#FFFFFF" :
"#F1F1F1"
)
]]>
</att.Color-bind>
</SolidLabel>
</Cell>
<Cell ref.Name="container" Site="row:1 column:1"/>
</Table>
</SelectableButtonTemplate>
</Instance>