Skip to content

Commit

Permalink
Merge pull request #230 from sirdoombox/main
Browse files Browse the repository at this point in the history
Minor button tweak and small attempt to improve performance.
  • Loading branch information
kikipoulet authored Jun 28, 2024
2 parents a88da0d + 42ef4c9 commit 66cabc9
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 109 deletions.
11 changes: 11 additions & 0 deletions SukiUI.Demo/Features/ControlsLibrary/ButtonsView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<Setter Property="Content" Value="Button" />
<Setter Property="theme:ButtonExtensions.ShowProgress" Value="{Binding IsBusy}" />
<Setter Property="Command" Value="{Binding ButtonClickedCommand}" />
<Setter Property="IsEnabled" Value="{Binding IsEnabled}" />
</Style>
</UserControl.Styles>
<Grid RowDefinitions="Auto,*">
Expand All @@ -28,6 +29,16 @@
<TextBlock>
Clicking on any one of the buttons will make them all "Busy" for 3 seconds, and how this is achieved can be seen in the XAML for the Busy Button.
</TextBlock>
<StackPanel Margin="0,25,0,0" Orientation="Horizontal">
<TextBlock Margin="0,0,0,0"
VerticalAlignment="Center"
FontWeight="DemiBold"
Text="Buttons Enabled: " />
<ToggleButton Margin="15,0,0,0"
Classes="Switch"
IsChecked="{Binding IsEnabled}" />

</StackPanel>
</StackPanel>
</controls:GroupBox>
</controls:GlassCard>
Expand Down
1 change: 1 addition & 0 deletions SukiUI.Demo/Features/ControlsLibrary/ButtonsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace SukiUI.Demo.Features.ControlsLibrary;
public partial class ButtonsViewModel() : DemoPageBase("Buttons", MaterialIconKind.CursorDefaultClick)
{
[ObservableProperty] private bool _isBusy;
[ObservableProperty] private bool _isEnabled = true;

[RelayCommand]
private Task ButtonClicked()
Expand Down
1 change: 1 addition & 0 deletions SukiUI/Controls/SukiBackground.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public override void Render(DrawingContext context)
{
_draw.Bounds = Bounds;
context.Custom(_draw);
Dispatcher.UIThread.InvokeAsync(InvalidateVisual, DispatcherPriority.Background);
}

private void HandleBackgroundStyleChanges()
Expand Down
175 changes: 87 additions & 88 deletions SukiUI/Controls/SukiWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,95 +16,94 @@
CornerRadius="{OnPlatform '0',
Linux='10',
x:TypeArguments=CornerRadius}">
<Panel IsHitTestVisible="True">
<VisualLayerManager Name="PART_VisualLayerManager" IsHitTestVisible="True">
<suki:SukiHost>
<Panel x:Name="PART_Root">
<suki:SukiBackground Name="PART_Background"
AnimationEnabled="{TemplateBinding BackgroundAnimationEnabled}"
ShaderCode="{TemplateBinding BackgroundShaderCode}"
ShaderFile="{TemplateBinding BackgroundShaderFile}"
Style="{TemplateBinding BackgroundStyle}"
TransitionTime="{TemplateBinding BackgroundTransitionTime}"
TransitionsEnabled="{TemplateBinding BackgroundTransitionsEnabled}" />
<DockPanel LastChildFill="True">
<Panel DockPanel.Dock="Top">
<Panel.Styles>
<Style Selector="suki|SukiWindow[ShowBottomBorder=True] /template/ Border#PART_BottomBorder">
<Setter Property="BorderThickness" Value="0,0,0,1" />
</Style>
<Style Selector="suki|SukiWindow[ShowBottomBorder=False] /template/ Border#PART_BottomBorder">
<Setter Property="BorderThickness" Value="0,0,0,0" />
</Style>
</Panel.Styles>
<StackPanel>
<LayoutTransformControl Name="PART_LayoutTransform" RenderTransformOrigin="0%,0%">
<Panel>
<suki:GlassCard Name="PART_TitleBarBackground"
BorderThickness="0"
CornerRadius="0"
IsAnimated="False" />
<DockPanel Margin="12,9" LastChildFill="True">
<StackPanel VerticalAlignment="Center"
DockPanel.Dock="Right"
FlowDirection="RightToLeft"
Orientation="Horizontal"
Spacing="7">
<StackPanel.Styles>
<Style Selector="PathIcon">
<Setter Property="Height" Value="10" />
<Setter Property="Width" Value="10" />
</Style>
</StackPanel.Styles>
<Button Name="PART_CloseButton" Classes="Basic Rounded WindowControlsButton Close">
<PathIcon Data="{x:Static icons:Icons.WindowClose}" />
</Button>
<Button Name="PART_MaximizeButton"
Classes="Basic Rounded WindowControlsButton"
IsVisible="{TemplateBinding CanResize}">
<PathIcon x:Name="MaximizeIcon" Data="{x:Static icons:Icons.WindowMaximize}" />
</Button>
<Button Name="PART_MinimizeButton"
VerticalContentAlignment="Bottom"
Classes="Basic Rounded WindowControlsButton"
IsVisible="{TemplateBinding CanMinimize}">
<PathIcon Margin="0,0,0,4"
VerticalAlignment="Bottom"
Data="{x:Static icons:Icons.WindowMinimize}" />
</Button>
</StackPanel>
<StackPanel VerticalAlignment="Center"
IsHitTestVisible="False"
Orientation="Horizontal"
Spacing="10">
<ContentPresenter HorizontalAlignment="Left"
Content="{TemplateBinding LogoContent}"
IsHitTestVisible="False" />
<TextBlock VerticalAlignment="Center"
FontSize="{TemplateBinding TitleFontSize}"
FontWeight="{TemplateBinding TitleFontWeight}"
IsHitTestVisible="False"
Text="{TemplateBinding Title}" />
</StackPanel>
</DockPanel>
</Panel>
</LayoutTransformControl>
<Menu IsEnabled="{TemplateBinding IsMenuVisible}" ItemsSource="{TemplateBinding MenuItems}" />
<Border Name="PART_BottomBorder" BorderBrush="{DynamicResource SukiBorderBrush}" />
</StackPanel>
</Panel>
<ContentPresenter x:Name="PART_ContentPresenter"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
CornerRadius="10"
IsHitTestVisible="True" />
</DockPanel>
<VisualLayerManager Name="PART_VisualLayerManager" IsHitTestVisible="True">
<VisualLayerManager.ChromeOverlayLayer>
<suki:SukiHost />
</VisualLayerManager.ChromeOverlayLayer>
<Panel x:Name="PART_Root">
<suki:SukiBackground Name="PART_Background"
AnimationEnabled="{TemplateBinding BackgroundAnimationEnabled}"
ShaderCode="{TemplateBinding BackgroundShaderCode}"
ShaderFile="{TemplateBinding BackgroundShaderFile}"
Style="{TemplateBinding BackgroundStyle}"
TransitionTime="{TemplateBinding BackgroundTransitionTime}"
TransitionsEnabled="{TemplateBinding BackgroundTransitionsEnabled}" />
<DockPanel LastChildFill="True">
<Panel DockPanel.Dock="Top">
<Panel.Styles>
<Style Selector="suki|SukiWindow[ShowBottomBorder=True] /template/ Border#PART_BottomBorder">
<Setter Property="BorderThickness" Value="0,0,0,1" />
</Style>
<Style Selector="suki|SukiWindow[ShowBottomBorder=False] /template/ Border#PART_BottomBorder">
<Setter Property="BorderThickness" Value="0,0,0,0" />
</Style>
</Panel.Styles>
<StackPanel>
<LayoutTransformControl Name="PART_LayoutTransform" RenderTransformOrigin="0%,0%">
<Panel>
<suki:GlassCard Name="PART_TitleBarBackground"
BorderThickness="0"
CornerRadius="0"
IsAnimated="False" />
<DockPanel Margin="12,9" LastChildFill="True">
<StackPanel VerticalAlignment="Center"
DockPanel.Dock="Right"
FlowDirection="RightToLeft"
Orientation="Horizontal"
Spacing="7">
<StackPanel.Styles>
<Style Selector="PathIcon">
<Setter Property="Height" Value="10" />
<Setter Property="Width" Value="10" />
</Style>
</StackPanel.Styles>
<Button Name="PART_CloseButton" Classes="Basic Rounded WindowControlsButton Close">
<PathIcon Data="{x:Static icons:Icons.WindowClose}" />
</Button>
<Button Name="PART_MaximizeButton"
Classes="Basic Rounded WindowControlsButton"
IsVisible="{TemplateBinding CanResize}">
<PathIcon x:Name="MaximizeIcon" Data="{x:Static icons:Icons.WindowMaximize}" />
</Button>
<Button Name="PART_MinimizeButton"
VerticalContentAlignment="Bottom"
Classes="Basic Rounded WindowControlsButton"
IsVisible="{TemplateBinding CanMinimize}">
<PathIcon Margin="0,0,0,4"
VerticalAlignment="Bottom"
Data="{x:Static icons:Icons.WindowMinimize}" />
</Button>
</StackPanel>
<StackPanel VerticalAlignment="Center"
IsHitTestVisible="False"
Orientation="Horizontal"
Spacing="10">
<ContentPresenter HorizontalAlignment="Left"
Content="{TemplateBinding LogoContent}"
IsHitTestVisible="False" />
<TextBlock VerticalAlignment="Center"
FontSize="{TemplateBinding TitleFontSize}"
FontWeight="{TemplateBinding TitleFontWeight}"
IsHitTestVisible="False"
Text="{TemplateBinding Title}" />
</StackPanel>
</DockPanel>
</Panel>
</LayoutTransformControl>
<Menu IsEnabled="{TemplateBinding IsMenuVisible}" ItemsSource="{TemplateBinding MenuItems}" />
<Border Name="PART_BottomBorder" BorderBrush="{DynamicResource SukiBorderBrush}" />
</StackPanel>
</Panel>
</suki:SukiHost>
</VisualLayerManager>
</Panel>
<ContentPresenter x:Name="PART_ContentPresenter"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
CornerRadius="10"
IsHitTestVisible="True" />
</DockPanel>
</Panel>
</VisualLayerManager>
</Border>
</ControlTemplate>
</Setter>
Expand Down
Loading

0 comments on commit 66cabc9

Please sign in to comment.