SukiWindow.axaml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <ResourceDictionary xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:icons="clr-namespace:SukiUI.Content"
  4. xmlns:suki="clr-namespace:SukiUI.Controls">
  5. <ControlTheme x:Key="SukiWindowTheme" TargetType="suki:SukiWindow">
  6. <Setter Property="Margin" Value="0" />
  7. <Setter Property="SystemDecorations" Value="Full" />
  8. <Setter Property="ExtendClientAreaChromeHints" Value="NoChrome" />
  9. <Setter Property="ExtendClientAreaTitleBarHeightHint" Value="-1" />
  10. <Setter Property="ExtendClientAreaToDecorationsHint" Value="True" />
  11. <Setter Property="TextElement.Foreground" Value="{DynamicResource SukiText}" />
  12. <Setter Property="FlowDirection" Value="{DynamicResource FlowDirectionPrimary}" />
  13. <Setter Property="Template">
  14. <ControlTemplate>
  15. <Border Margin="{TemplateBinding Margin}"
  16. ClipToBounds="True"
  17. CornerRadius="{OnPlatform '0',
  18. Linux='10',
  19. x:TypeArguments=CornerRadius}">
  20. <VisualLayerManager Name="PART_VisualLayerManager" IsHitTestVisible="True">
  21. <VisualLayerManager.ChromeOverlayLayer>
  22. <!-- <suki:SukiHost /> -->
  23. <ItemsControl ItemsSource="{Binding Hosts, RelativeSource={RelativeSource AncestorType={x:Type suki:SukiWindow}}}">
  24. <ItemsControl.ItemsPanel>
  25. <ItemsPanelTemplate>
  26. <Panel />
  27. </ItemsPanelTemplate>
  28. </ItemsControl.ItemsPanel>
  29. </ItemsControl>
  30. </VisualLayerManager.ChromeOverlayLayer>
  31. <Panel x:Name="PART_Root">
  32. <!-- Margin -100 is there to exclude the unwanted bright corners -->
  33. <suki:SukiBackground Name="PART_Background"
  34. Margin="-150"
  35. AnimationEnabled="{TemplateBinding BackgroundAnimationEnabled}"
  36. ShaderCode="{TemplateBinding BackgroundShaderCode}"
  37. ShaderFile="{TemplateBinding BackgroundShaderFile}"
  38. Style="{TemplateBinding BackgroundStyle}"
  39. TransitionTime="{TemplateBinding BackgroundTransitionTime}"
  40. TransitionsEnabled="{TemplateBinding BackgroundTransitionsEnabled}"
  41. ForceSoftwareRendering="{TemplateBinding BackgroundForceSoftwareRendering}"/>
  42. <Panel Background="White"
  43. IsVisible="{DynamicResource IsLight}"
  44. Opacity="0.1" />
  45. <DockPanel LastChildFill="True">
  46. <Panel DockPanel.Dock="Top">
  47. <Panel.Styles>
  48. <Style Selector="suki|SukiWindow[ShowBottomBorder=True] /template/ Border#PART_BottomBorder">
  49. <Setter Property="BorderThickness" Value="0,0,0,1" />
  50. </Style>
  51. <Style Selector="suki|SukiWindow[ShowBottomBorder=False] /template/ Border#PART_BottomBorder">
  52. <Setter Property="BorderThickness" Value="0,0,0,0" />
  53. </Style>
  54. </Panel.Styles>
  55. <StackPanel>
  56. <LayoutTransformControl Name="PART_LayoutTransform" RenderTransformOrigin="0%,0%">
  57. <Panel>
  58. <suki:GlassCard Name="PART_TitleBarBackground"
  59. BorderThickness="0"
  60. CornerRadius="0"
  61. IsAnimated="False" />
  62. <DockPanel Margin="12,9" LastChildFill="True">
  63. <StackPanel VerticalAlignment="Center"
  64. DockPanel.Dock="Right"
  65. Orientation="Horizontal"
  66. Spacing="7">
  67. <StackPanel.Styles>
  68. <Style Selector="PathIcon">
  69. <Setter Property="Height" Value="10" />
  70. <Setter Property="Width" Value="10" />
  71. </Style>
  72. </StackPanel.Styles>
  73. <ItemsControl ItemsSource="{TemplateBinding RightWindowTitleBarControls}">
  74. <ItemsControl.ItemsPanel>
  75. <ItemsPanelTemplate>
  76. <StackPanel FlowDirection="{DynamicResource FlowDirectionOpposite}" Orientation="Horizontal" />
  77. </ItemsPanelTemplate>
  78. </ItemsControl.ItemsPanel>
  79. </ItemsControl>
  80. <Button Name="PART_MinimizeButton"
  81. VerticalContentAlignment="Bottom"
  82. Classes="Basic Rounded WindowControlsButton"
  83. IsVisible="{TemplateBinding CanMinimize}">
  84. <PathIcon Margin="0,0,0,4"
  85. VerticalAlignment="Bottom"
  86. Data="{x:Static icons:Icons.WindowMinimize}" />
  87. </Button>
  88. <Button Name="PART_MaximizeButton"
  89. Classes="Basic Rounded WindowControlsButton"
  90. IsVisible="{TemplateBinding CanMaximize}">
  91. <PathIcon x:Name="MaximizeIcon" Data="{x:Static icons:Icons.WindowMaximize}" />
  92. </Button>
  93. <Button Name="PART_CloseButton" Classes="Basic Rounded WindowControlsButton Close">
  94. <PathIcon Data="{x:Static icons:Icons.WindowClose}" />
  95. </Button>
  96. </StackPanel>
  97. <StackPanel VerticalAlignment="Center"
  98. IsHitTestVisible="False"
  99. Orientation="Horizontal"
  100. Spacing="10">
  101. <ContentPresenter HorizontalAlignment="Left"
  102. Content="{TemplateBinding LogoContent}"
  103. IsHitTestVisible="False" />
  104. <TextBlock VerticalAlignment="Center"
  105. FontSize="{TemplateBinding TitleFontSize}"
  106. FontWeight="{TemplateBinding TitleFontWeight}"
  107. IsHitTestVisible="False"
  108. Text="{TemplateBinding Title}" />
  109. </StackPanel>
  110. </DockPanel>
  111. </Panel>
  112. </LayoutTransformControl>
  113. <Menu IsEnabled="{TemplateBinding IsMenuVisible}" ItemsSource="{TemplateBinding MenuItems}" />
  114. <Border Name="PART_BottomBorder" BorderBrush="{DynamicResource SukiBorderBrush}" />
  115. </StackPanel>
  116. </Panel>
  117. <ContentPresenter x:Name="PART_ContentPresenter"
  118. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  119. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
  120. Content="{TemplateBinding Content}"
  121. ContentTemplate="{TemplateBinding ContentTemplate}"
  122. CornerRadius="10"
  123. IsHitTestVisible="True" />
  124. </DockPanel>
  125. </Panel>
  126. </VisualLayerManager>
  127. </Border>
  128. </ControlTemplate>
  129. </Setter>
  130. <Style Selector="^[WindowState=Maximized] /template/ PathIcon#MaximizeIcon">
  131. <Setter Property="Data" Value="{x:Static icons:Icons.WindowRestore}" />
  132. </Style>
  133. <Style Selector="^[WindowState=Normal] /template/ PathIcon#MaximizeIcon">
  134. <Setter Property="Data" Value="{x:Static icons:Icons.WindowMaximize}" />
  135. </Style>
  136. <Style Selector="^[IsTitleBarVisible=True]">
  137. <Style Selector="^[TitleBarAnimationEnabled=True]">
  138. <Style Selector="^ /template/ LayoutTransformControl#PART_LayoutTransform">
  139. <Style.Animations>
  140. <Animation Easing="{StaticResource MenuEasing}"
  141. FillMode="Forward"
  142. Duration="{StaticResource MediumAnimationDuration}">
  143. <KeyFrame Cue="0%">
  144. <Setter Property="ScaleTransform.ScaleY" Value="0" />
  145. <Setter Property="IsVisible" Value="True" />
  146. </KeyFrame>
  147. <KeyFrame Cue="100%">
  148. <Setter Property="ScaleTransform.ScaleY" Value="1" />
  149. </KeyFrame>
  150. </Animation>
  151. </Style.Animations>
  152. </Style>
  153. </Style>
  154. <Style Selector="^[TitleBarAnimationEnabled=False]">
  155. <Style Selector="^ /template/ LayoutTransformControl#PART_LayoutTransform">
  156. <Setter Property="IsVisible" Value="True" />
  157. </Style>
  158. </Style>
  159. </Style>
  160. <Style Selector="^[IsTitleBarVisible=False]">
  161. <Style Selector="^[TitleBarAnimationEnabled=True]">
  162. <Style Selector="^ /template/ LayoutTransformControl#PART_LayoutTransform">
  163. <Style.Animations>
  164. <Animation Easing="{StaticResource MenuEasing}"
  165. FillMode="Forward"
  166. Duration="{StaticResource MediumAnimationDuration}">
  167. <KeyFrame Cue="0%">
  168. <Setter Property="ScaleTransform.ScaleY" Value="1" />
  169. </KeyFrame>
  170. <KeyFrame Cue="100%">
  171. <Setter Property="ScaleTransform.ScaleY" Value="0" />
  172. <Setter Property="IsVisible" Value="False" />
  173. </KeyFrame>
  174. </Animation>
  175. </Style.Animations>
  176. </Style>
  177. </Style>
  178. <Style Selector="^[TitleBarAnimationEnabled=False]">
  179. <Style Selector="^ /template/ LayoutTransformControl#PART_LayoutTransform">
  180. <Setter Property="IsVisible" Value="False" />
  181. </Style>
  182. </Style>
  183. </Style>
  184. </ControlTheme>
  185. <ControlTheme x:Key="{x:Type suki:SukiWindow}"
  186. BasedOn="{StaticResource SukiWindowTheme}"
  187. TargetType="suki:SukiWindow" />
  188. </ResourceDictionary>