<ResourceDictionary xmlns="https://github.com/avaloniaui"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:conv="using:Avalonia.Controls.Converters"
                    xmlns:sys="using:System"
                    xmlns:converters="clr-namespace:PixiEditor.UI.Common.Converters"
                    x:ClassModifier="internal">
  <conv:PlatformKeyGestureConverter x:Key="KeyGestureConverter" />

  <ControlTheme x:Key="{x:Type MenuItem}"
                TargetType="MenuItem">
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}"/>
    <Setter Property="Padding" Value="6 0" />
    <Setter Property="Template">
      <ControlTemplate>
        <Border Name="root"
                Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CornerRadius="{TemplateBinding CornerRadius}">
          <Grid>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="20" />
              <ColumnDefinition Width="5" />
              <ColumnDefinition Width="*" />
              <ColumnDefinition Width="Auto"
                                SharedSizeGroup="MenuItemIGT" />
              <ColumnDefinition Width="20" />
            </Grid.ColumnDefinitions>
            <ContentPresenter Name="icon"
                              Width="16"
                              Height="16"
                              Margin="3"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              Content="{TemplateBinding Icon}" />
            <Path Name="check"
                  Margin="3"
                  VerticalAlignment="Center"
                  Data="F1M10,1.2L4.7,9.1 4.5,9.1 0,5.2 1.3,3.5 4.3,6.1 8.3,0 10,1.2z"
                  Fill="{TemplateBinding Foreground}"
                  IsVisible="False" />
            <ContentPresenter Name="PART_HeaderPresenter"
                              Grid.Column="2"
                              Margin="{TemplateBinding Padding}"
                              VerticalAlignment="Center"
                              Content="{TemplateBinding Header}"
                              ContentTemplate="{TemplateBinding HeaderTemplate}">
              <ContentPresenter.DataTemplates>
                <DataTemplate DataType="sys:String">
                  <AccessText Text="{Binding}" />
                </DataTemplate>
              </ContentPresenter.DataTemplates>
            </ContentPresenter>
            <TextBlock x:Name="PART_InputGestureText"
                       Grid.Column="3"
                       VerticalAlignment="Center"
                       Text="{TemplateBinding InputGesture,
                                              Converter={converters:MenuItemKeyGestureConverter}}" />
            <Path Name="rightArrow"
                  Grid.Column="4"
                  Margin="10,0,0,0"
                  VerticalAlignment="Center"
                  Data="M0,0L4,3.5 0,7z"
                  Fill="{DynamicResource ThemeForegroundBrush}" />
            <Popup Name="PART_Popup"
                   IsLightDismissEnabled="False"
                   IsOpen="{TemplateBinding IsSubMenuOpen,
                                            Mode=TwoWay}"
                   Placement="RightEdgeAlignedTop">
              <Border Background="{DynamicResource ThemeBackgroundBrush}"
                      BorderBrush="{DynamicResource ThemeBorderMidBrush}"
                      CornerRadius="{TemplateBinding CornerRadius}"
                      BorderThickness="{TemplateBinding BorderThickness}">
                <ScrollViewer>
                  <ItemsPresenter Name="PART_ItemsPresenter"
                                  Margin="2"
                                  Grid.IsSharedSizeScope="True"
                                  ItemsPanel="{TemplateBinding ItemsPanel}" />
                </ScrollViewer>
              </Border>
            </Popup>
          </Grid>
        </Border>
      </ControlTemplate>
    </Setter>

    <Style Selector="^:separator">
      <Setter Property="Template">
        <ControlTemplate>
          <Separator />
        </ControlTemplate>
      </Setter>
    </Style>

    <Style Selector="^:selected /template/ Border#root">
      <Setter Property="Background" Value="{DynamicResource ThemeControlHighBrush}" />
    </Style>

    <Style Selector="^:empty /template/ Path#rightArrow">
      <Setter Property="IsVisible" Value="False" />
    </Style>

    <Style Selector="^:disabled">
      <Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" />
    </Style>
  </ControlTheme>
</ResourceDictionary>