This commit is contained in:
Zihan Chen
2018-05-21 05:26:37 -07:00
parent 0e842a380f
commit c4b57cb085
2 changed files with 213 additions and 115 deletions
@@ -1,119 +1,214 @@
<Instance ref.CodeBehind="false" ref.Class="demo::DocumentEditorRibbonWindow" xmlns:demo="demo::*">
<ref.Members>
<![CDATA[
@cpp:Private
prop AlignLeftSelected : bool = true {}
@cpp:Private
prop AlignCenterSelected : bool = true {}
@cpp:Private
prop AlignRightSelected : bool = true {}
]]>
</ref.Members>
<demo:DocumentEditorWindowBase ref.Name="self" Text="Document Editor (Ribbon)">
<att.AlignLeftSelected-bind>self.document.observe as _(self.SelectAlignmentCommand() == self.commandAlignLeft on _.SelectionChanged)</att.AlignLeftSelected-bind>
<att.AlignCenterSelected-bind>self.document.observe as _(self.SelectAlignmentCommand() == self.commandAlignCenter on _.SelectionChanged)</att.AlignCenterSelected-bind>
<att.AlignRightSelected-bind>self.document.observe as _(self.SelectAlignmentCommand() == self.commandAlignRight on _.SelectionChanged)</att.AlignRightSelected-bind>
<Folder>
<Script name="RibbonScript">
<Workflow>
<![CDATA[
module ribbonscript;
<att.MenuContainer-set>
<RibbonTab>
<att.BoundsComposition-set AlignmentToParent="left:0 top:0 right:0 bottom:0"/>
<att.BeforeHeaders-set>
<Button Text="HOME">
<att.BoundsComposition-set AlignmentToParent="left:0 top:0 right:0 bottom:0" PreferredMinSize="x:80"/>
</Button>
</att.BeforeHeaders-set>
namespace demo
{
class StyleItem
{
new(value : string)
{
Value = value;
}
prop Value : string = 0 {not observe}
}
class StyleGroup
{
prop Name : string = "" {}
prop Items : observe StyleItem^[] = {} {const, not observe}
}
}
]]>
</Workflow>
</Script>
<att.Pages>
<RibbonTabPage Text="Edit">
<att.ContainerComposition-set PreferredMinSize="y:110"/>
<att.Groups>
<RibbonGroup Text="Alignment">
<att.Items>
<RibbonLargeDropdownButton Text="Edit Mode">
<att.LargeImage-bind>self.EditModeCommand.LargeImage ?? null</att.LargeImage-bind>
<att.SubMenu-set>
<MenuItemButton Command-eval="self.commandViewOnly" Alt="V"/>
<MenuItemButton Command-eval="self.commandSelectable" Alt="S"/>
<MenuItemButton Command-eval="self.commandEditable" Alt="E"/>
</att.SubMenu-set>
</RibbonLargeDropdownButton>
<RibbonSplitter/>
<RibbonButtons MaxSize="Large" MinSize="Icon">
<att.Buttons>
<ToolstripButton Command-eval="self.commandAlignLeft" Selected-bind="self.AlignLeftSelected"/>
<ToolstripButton Command-eval="self.commandAlignCenter" Selected-bind="self.AlignCenterSelected"/>
<ToolstripButton Command-eval="self.commandAlignRight" Selected-bind="self.AlignRightSelected"/>
</att.Buttons>
</RibbonButtons>
</att.Items>
</RibbonGroup>
<Instance name="StyleItemTemplateResource">
<Instance ref.CodeBehind="false" ref.Class="demo::StyleItemTemplate">
<ref.Parameter Name="ViewModel" Class="demo::StyleItem"/>
<TextListItemTemplate MinSizeLimitation="LimitToElementAndChildren" PreferredMinSize="x:64">
<SolidLabel Text-bind="ViewModel.Value" Color="#FF8000" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</TextListItemTemplate>
</Instance>
</Instance>
<RibbonGroup Text="Edit">
<att.Items>
<RibbonButtons MaxSize="Large" MinSize="Icon">
<att.Buttons>
<ToolstripButton Command-eval="self.commandUndo"/>
<ToolstripButton Command-eval="self.commandRedo"/>
</att.Buttons>
</RibbonButtons>
<RibbonSplitter/>
<RibbonButtons MaxSize="Large" MinSize="Icon">
<att.Buttons>
<ToolstripButton Command-eval="self.commandCopy"/>
<ToolstripButton Command-eval="self.commandCut"/>
<ToolstripButton Command-eval="self.commandPaste"/>
</att.Buttons>
</RibbonButtons>
<RibbonSplitter/>
<RibbonLargeButton Command-eval="self.commandDelete"/>
</att.Items>
</RibbonGroup>
<Instance name="DocumentEditorRibbonWindowResource">
<Instance ref.CodeBehind="false" ref.Class="demo::DocumentEditorRibbonWindow" xmlns:demo="demo::*">
<ref.Members>
<![CDATA[
@cpp:Private
prop AlignLeftSelected : bool = true {}
@cpp:Private
prop AlignCenterSelected : bool = true {}
@cpp:Private
prop AlignRightSelected : bool = true {}
<RibbonGroup Text="Text">
<att.Items>
<RibbonToolstrips>
<att.Groups>
<ToolstripGroup>
<ToolstripButton Command-eval="self.commandBold"/>
<ToolstripButton Command-eval="self.commandItalic"/>
</ToolstripGroup>
<ToolstripGroup>
<ToolstripButton Command-eval="self.commandUnderline"/>
<ToolstripButton Command-eval="self.commandStrike"/>
</ToolstripGroup>
<ToolstripGroup>
<ToolstripButton Command-eval="self.commandFont"/>
<ToolstripButton Command-eval="self.commandColor"/>
<ToolstripButton Command-eval="self.commandBackColor"/>
</ToolstripGroup>
<ToolstripGroup>
<ToolstripButton Command-eval="self.commandEditHyperlink"/>
<ToolstripButton Command-eval="self.commandRemoveHyperlink"/>
</ToolstripGroup>
</att.Groups>
</RibbonToolstrips>
</att.Items>
</RibbonGroup>
</att.Groups>
</RibbonTabPage>
@cpp:Private
func GetStyleGroups(): demo::StyleGroup^[]
{
var group1 = new StyleGroup^();
group1.Name = "Group A";
for (i in range [1, 5])
{
group1.Items.Add(new StyleItem^("A" & i));
}
<RibbonTabPage Text="Insert" Highlighted="true">
<att.Groups>
<RibbonGroup Text="Object">
<att.Items>
<RibbonButtons MaxSize="Large" MinSize="Small">
<att.Buttons>
<ToolstripButton Command-eval="self.commandInsertImage"/>
<ToolstripButton Command-eval="self.commandEditHyperlink"/>
<ToolstripButton Command-eval="self.commandRemoveHyperlink"/>
</att.Buttons>
</RibbonButtons>
</att.Items>
</RibbonGroup>
</att.Groups>
</RibbonTabPage>
</att.Pages>
</RibbonTab>
</att.MenuContainer-set>
</demo:DocumentEditorWindowBase>
</Instance>
var group2 = new StyleGroup^();
group2.Name = "Group B";
for (i in range [1, 5])
{
group2.Items.Add(new StyleItem^("B" & i));
}
return {group1 group2};
}
]]>
</ref.Members>
<demo:DocumentEditorWindowBase ref.Name="self" Text="Document Editor (Ribbon)">
<att.AlignLeftSelected-bind>self.document.observe as _(self.SelectAlignmentCommand() == self.commandAlignLeft on _.SelectionChanged)</att.AlignLeftSelected-bind>
<att.AlignCenterSelected-bind>self.document.observe as _(self.SelectAlignmentCommand() == self.commandAlignCenter on _.SelectionChanged)</att.AlignCenterSelected-bind>
<att.AlignRightSelected-bind>self.document.observe as _(self.SelectAlignmentCommand() == self.commandAlignRight on _.SelectionChanged)</att.AlignRightSelected-bind>
<att.MenuContainer-set>
<RibbonTab>
<att.BoundsComposition-set AlignmentToParent="left:0 top:0 right:0 bottom:0"/>
<att.BeforeHeaders-set>
<Button Text="HOME">
<att.BoundsComposition-set AlignmentToParent="left:0 top:0 right:0 bottom:0" PreferredMinSize="x:80"/>
</Button>
</att.BeforeHeaders-set>
<att.AfterHeaders-set>
<Stack Direction="Horizontal" AlignmentToParent="left:0 top:-1 right:0 bottom:0" MinSizeLimitation="LimitToElementAndChildren">
<StackItem InternalMargin="left:0 top:0 right:10 bottom:0">
<SolidLabel Font-bind="self.Font" Color="#FFFFFF" Text="Search:" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackItem>
<StackItem>
<SinglelineTextBox>
<att.BoundsComposition-set AlignmentToParent="left:0 top:0 right:0 bottom:1" PreferredMinSize="x:180"/>
</SinglelineTextBox>
</StackItem>
</Stack>
</att.AfterHeaders-set>
<att.Pages>
<RibbonTabPage Text="Edit">
<att.ContainerComposition-set PreferredMinSize="y:110"/>
<att.Groups>
<RibbonGroup Text="Alignment">
<att.Items>
<RibbonLargeDropdownButton Text="Edit Mode">
<att.LargeImage-bind>self.EditModeCommand.LargeImage ?? null</att.LargeImage-bind>
<att.SubMenu-set>
<MenuItemButton Command-eval="self.commandViewOnly" Alt="V"/>
<MenuItemButton Command-eval="self.commandSelectable" Alt="S"/>
<MenuItemButton Command-eval="self.commandEditable" Alt="E"/>
</att.SubMenu-set>
</RibbonLargeDropdownButton>
<RibbonSplitter/>
<RibbonButtons MaxSize="Large" MinSize="Icon">
<att.Buttons>
<ToolstripButton Command-eval="self.commandAlignLeft" Selected-bind="self.AlignLeftSelected"/>
<ToolstripButton Command-eval="self.commandAlignCenter" Selected-bind="self.AlignCenterSelected"/>
<ToolstripButton Command-eval="self.commandAlignRight" Selected-bind="self.AlignRightSelected"/>
</att.Buttons>
</RibbonButtons>
</att.Items>
</RibbonGroup>
<RibbonGroup Text="Edit">
<att.Items>
<RibbonButtons MaxSize="Large" MinSize="Icon">
<att.Buttons>
<ToolstripButton Command-eval="self.commandUndo"/>
<ToolstripButton Command-eval="self.commandRedo"/>
</att.Buttons>
</RibbonButtons>
<RibbonSplitter/>
<RibbonButtons MaxSize="Large" MinSize="Icon">
<att.Buttons>
<ToolstripButton Command-eval="self.commandCopy"/>
<ToolstripButton Command-eval="self.commandCut"/>
<ToolstripButton Command-eval="self.commandPaste"/>
</att.Buttons>
</RibbonButtons>
<RibbonSplitter/>
<RibbonLargeButton Command-eval="self.commandDelete"/>
</att.Items>
</RibbonGroup>
<RibbonGroup Text="Text">
<att.Items>
<RibbonToolstrips>
<att.Groups>
<ToolstripGroup>
<ToolstripButton Command-eval="self.commandBold"/>
<ToolstripButton Command-eval="self.commandItalic"/>
</ToolstripGroup>
<ToolstripGroup>
<ToolstripButton Command-eval="self.commandUnderline"/>
<ToolstripButton Command-eval="self.commandStrike"/>
</ToolstripGroup>
<ToolstripGroup>
<ToolstripButton Command-eval="self.commandFont"/>
<ToolstripButton Command-eval="self.commandColor"/>
<ToolstripButton Command-eval="self.commandBackColor"/>
</ToolstripGroup>
<ToolstripGroup>
<ToolstripButton Command-eval="self.commandEditHyperlink"/>
<ToolstripButton Command-eval="self.commandRemoveHyperlink"/>
</ToolstripGroup>
</att.Groups>
</RibbonToolstrips>
</att.Items>
</RibbonGroup>
<RibbonGroup Text="Style">
<att.Items>
<BindableRibbonGalleryList ItemTemplate="demo:StyleItemTemplate" MinCount="2" MaxCount="5" env.ItemType="demo::StyleGroup^">
<att.ItemSource-eval>self.GetStyleGroups()</att.ItemSource-eval>
<att.GroupTitleProperty>Name</att.GroupTitleProperty>
<att.GroupChildrenProperty>Items</att.GroupChildrenProperty>
<att.SubMenu-set>
<RibbonToolstripHeader Text="Header A"/>
<MenuItemButton Text="Item A1"/>
<MenuItemButton Text="Item A2"/>
<MenuItemButton Text="Item A3"/>
<RibbonToolstripHeader Text="Header B"/>
<MenuItemButton Text="Item B1"/>
<MenuItemButton Text="Item B2"/>
<MenuItemButton Text="Item B3"/>
</att.SubMenu-set>
</BindableRibbonGalleryList>
</att.Items>
</RibbonGroup>
</att.Groups>
</RibbonTabPage>
<RibbonTabPage Text="Insert" Highlighted="true">
<att.Groups>
<RibbonGroup Text="Object">
<att.Items>
<RibbonButtons MaxSize="Large" MinSize="Small">
<att.Buttons>
<ToolstripButton Command-eval="self.commandInsertImage"/>
<ToolstripButton Command-eval="self.commandEditHyperlink"/>
<ToolstripButton Command-eval="self.commandRemoveHyperlink"/>
</att.Buttons>
</RibbonButtons>
</att.Items>
</RibbonGroup>
</att.Groups>
</RibbonTabPage>
</att.Pages>
</RibbonTab>
</att.MenuContainer-set>
</demo:DocumentEditorWindowBase>
</Instance>
</Instance>
</Folder>