Skip to content

Commit

Permalink
Merge pull request #283 from sirdoombox/main
Browse files Browse the repository at this point in the history
Add dedicated separator style. Demo TrayIcon.
  • Loading branch information
kikipoulet authored Aug 27, 2024
2 parents 5a4ab52 + 5f48524 commit ac659f4
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 21 deletions.
21 changes: 21 additions & 0 deletions SukiUI.Demo/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@
<Application.DataTemplates>
<common:ViewLocator />
</Application.DataTemplates>

<TrayIcon.Icons>
<TrayIcons>
<TrayIcon Icon="/Assets/OIG.N5o-removebg-preview.png"
ToolTipText="SukiUI Native Menu Demo">
<TrayIcon.Menu>
<NativeMenu>
<NativeMenuItem Header="Native Menu Demo">
<NativeMenu>
<NativeMenuItem Header="Option 1" />
<NativeMenuItem Header="Option 2" />
<NativeMenuItemSeparator/>
<NativeMenuItem Header="Option 3" />
</NativeMenu>
</NativeMenuItem>
</NativeMenu>
</TrayIcon.Menu>
</TrayIcon>
</TrayIcons>
</TrayIcon.Icons>

<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand Down
3 changes: 2 additions & 1 deletion SukiUI.Demo/Features/ControlsLibrary/ContextMenusView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Separator Next" />
<MenuItem Header="-" />
<Separator/>
<MenuItem Header="Submenu">
<MenuItem Header="Sub-Submenu">
<MenuItem Command="{Binding NestedOptionClickedCommand}" Header="Nested Option" />
<MenuItem Header="-" />
<MenuItem Header="Disabled Nested Option" IsEnabled="False" />
</MenuItem>
</MenuItem>
Expand Down
1 change: 1 addition & 0 deletions SukiUI/Theme/Index.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<ResourceInclude Source="avares://sukiUI/Theme/CalendarDatePickerStyle.axaml" />
<ResourceInclude Source="avares://sukiUI/Theme/TabControl.axaml" />
<ResourceInclude Source="avares://sukiUI/Theme/TabItem.axaml" />
<ResourceInclude Source="avares://sukiUI/Theme/Separator.axaml" />
<ResourceInclude Source="avares://sukiUI/Theme/DropDownButton.axaml" />
<ResourceInclude Source="avares://sukiUI/Theme/Menu.axaml" />
<ResourceInclude Source="avares://sukiUI/Theme/ContextMenu.axaml" />
Expand Down
14 changes: 8 additions & 6 deletions SukiUI/Theme/MenuFlyoutPresenter.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
BorderThickness="{TemplateBinding BorderThickness}"
ClipToBounds="True"
CornerRadius="{TemplateBinding CornerRadius}">
<ItemsPresenter Name="PART_ItemsPresenter"
HorizontalAlignment="Left"
VerticalAlignment="Center"
ItemsPanel="{TemplateBinding ItemsPanel}"
KeyboardNavigation.TabNavigation="Continue" />
<Panel Background="{DynamicResource PopupGradientBrush}">
<ItemsPresenter Name="PART_ItemsPresenter"
HorizontalAlignment="Left"
VerticalAlignment="Center"
ItemsPanel="{TemplateBinding ItemsPanel}"
KeyboardNavigation.TabNavigation="Continue" />
</Panel>
</Border>
</Panel>
</ControlTemplate>
Expand All @@ -32,4 +34,4 @@
<ControlTheme x:Key="{x:Type MenuFlyoutPresenter}"
BasedOn="{StaticResource SukiMenuFlyoutPresenterStyle}"
TargetType="MenuFlyoutPresenter" />
</ResourceDictionary>
</ResourceDictionary>
15 changes: 1 addition & 14 deletions SukiUI/Theme/MenuItem.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,6 @@
<Setter Property="Background" Value="{DynamicResource SukiLightBorderBrush}" />
</Style>

<Style Selector="^:separator">
<Setter Property="Template">
<ControlTemplate>
<Separator Height="1"
Margin="20,1,0,1"
Background="{DynamicResource ThemeControlMidBrush}" />
</ControlTemplate>
</Setter>
</Style>

<Style Selector="^:open /template/ LayoutTransformControl#PART_LayoutTransform">
<Style.Animations>
<Animation Easing="{StaticResource MenuEasing}"
Expand Down Expand Up @@ -152,12 +142,9 @@
</Style>

<Style Selector="^:separator">
<Setter Property="Height" Value="NaN" />
<Setter Property="Template">
<ControlTemplate>
<Separator Height="1"
Margin="0,0"
Background="{DynamicResource SukiLightBorderBrush}" />
<Separator Margin="0"/>
</ControlTemplate>
</Setter>
</Style>
Expand Down
36 changes: 36 additions & 0 deletions SukiUI/Theme/Separator.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTheme x:Key="SukiSeparatorStyle" TargetType="Separator">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="CornerRadius" Value="0" />
<Setter Property="Foreground" Value="{DynamicResource SukiLightBorderBrush}" />
<Setter Property="MinHeight" Value="1" />
<Setter Property="Height" Value="1" />
<Setter Property="Margin" Value="0" />
<Setter Property="Template">
<ControlTemplate>
<Border Name="PART_RootBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderThickness}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Rectangle Name="PART_Content" Fill="{TemplateBinding Foreground}" />
</Border>
</ControlTemplate>
</Setter>

<Style Selector="^ /template/ Border#PART_RootBorder">
<Setter Property="ClipToBounds" Value="True" />
</Style>

<Style Selector="^ /template/ Rectangle#PART_Content">
<Setter Property="Height" Value="1" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type Separator}" TargetType="Separator"
BasedOn="{StaticResource SukiSeparatorStyle}" />
</ResourceDictionary>

0 comments on commit ac659f4

Please sign in to comment.