Skip to content

Commit

Permalink
Incremental Fixes to Refactor Codebase (#1449)
Browse files Browse the repository at this point in the history
## Description

First attempt to clean up the codebase:
- Clean up themeresources and styles in App.xaml
- Fix minimal mode TitleBar layout
- CaptureElement and AnnotatedScrollBar Icons

## Motivation and Context
Part of #1279 efforts
  • Loading branch information
karkarl authored Feb 16, 2024
1 parent 86b8b56 commit dc021e8
Show file tree
Hide file tree
Showing 20 changed files with 126 additions and 175 deletions.
77 changes: 22 additions & 55 deletions WinUIGallery/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,25 @@
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="HomePageBackgroundBrush" Color="Transparent" />
<StaticResource x:Key="ControlExampleDisplayBrush" ResourceKey="SolidBackgroundFillColorBaseBrush" />
<SolidColorBrush x:Key="SearchBoxBorderBrush" Color="Transparent" />
<Thickness x:Key="SearchBoxBorderThickness">0</Thickness>
<Thickness x:Key="ControlExampleDisplayBorderThickness">0</Thickness>
<SolidColorBrush x:Key="NavigationViewExpandedPaneBackground" Color="Transparent" />
<StaticResource x:Key="GalleryBackgroundBrush" ResourceKey="SolidBackgroundFillColorBaseBrush" />
<StaticResource x:Key="GalleryBorderBrush" ResourceKey="CardStrokeColorDefaultBrush" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="HomePageBackgroundBrush" Color="Transparent" />
<StaticResource x:Key="ControlExampleDisplayBrush" ResourceKey="SolidBackgroundFillColorBaseBrush" />
<SolidColorBrush x:Key="SearchBoxBorderBrush" Color="Transparent" />
<Thickness x:Key="SearchBoxBorderThickness">0</Thickness>
<Thickness x:Key="ControlExampleDisplayBorderThickness">0</Thickness>
<SolidColorBrush x:Key="NavigationViewExpandedPaneBackground" Color="Transparent" />
<StaticResource x:Key="GalleryBackgroundBrush" ResourceKey="SolidBackgroundFillColorBaseBrush" />
<StaticResource x:Key="GalleryBorderBrush" ResourceKey="CardStrokeColorDefaultBrush" />
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<SolidColorBrush x:Key="HomePageBackgroundBrush" Color="{ThemeResource SystemColorWindowColor}" />
<SolidColorBrush x:Key="ControlExampleDisplayBrush" Color="{ThemeResource SystemColorWindowColor}" />
<SolidColorBrush x:Key="SearchBoxBorderBrush" Color="{ThemeResource SystemColorWindowTextColor}" />
<Thickness x:Key="SearchBoxBorderThickness">2</Thickness>
<Thickness x:Key="ControlExampleDisplayBorderThickness">1</Thickness>
<SolidColorBrush x:Key="NavigationViewExpandedPaneBackground" Color="Transparent" />
<SolidColorBrush x:Key="GalleryBackgroundBrush" Color="{ThemeResource SystemColorWindowColor}" />
<SolidColorBrush x:Key="GalleryBorderBrush" Color="{ThemeResource SystemColorWindowColor}" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

<!-- Application-specific resources -->
<x:String x:Key="ControlsName">All samples</x:String>
<x:String x:Key="AppTitleName">WinUI 3 Gallery</x:String>

<common:NullableBooleanToBooleanConverter x:Key="nullableBooleanToBooleanConverter" />
<common:NullToVisibilityConverter x:Key="nullToVisibilityConverter" />
<common:EmptyStringToVisibilityConverter x:Key="emptyStringToVisibilityConverter" />
Expand All @@ -63,37 +57,19 @@

<!-- Breakpoints -->
<x:Double x:Key="Breakpoint640Plus">641</x:Double>
<Thickness x:Key="NavigationViewContentMargin">0,48,0,0</Thickness>
<Thickness x:Key="ControlElementScreenshotModePadding">67</Thickness>

<!-- Style Overrides -->
<SolidColorBrush x:Key="GridViewHeaderItemDividerStroke" Color="Transparent" />

<x:String x:Key="ControlsName">All samples</x:String>
<x:String x:Key="AppTitleName">WinUI 3 Gallery</x:String>

<x:Double x:Key="TeachingTipMinWidth">50</x:Double>

<!-- Application-specific styles -->
<Style
x:Key="OutputTextBlockStyle"
BasedOn="{StaticResource BodyTextBlockStyle}"
TargetType="TextBlock">
<Setter Property="Margin" Value="8,8,0,0" />
</Style>

<Style
x:Name="NarrowHeaderTextBlockStyle"
BasedOn="{StaticResource HeaderTextBlockStyle}"
TargetType="TextBlock">
<Setter Property="Foreground" Value="{StaticResource SystemControlForegroundChromeWhiteBrush}" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Margin" Value="36,12,0,0" />
</Style>

<Style x:Key="ControlPageScrollStyle" TargetType="ScrollViewer">
<Setter Property="VerticalScrollMode" Value="Auto" />
<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="ZoomMode" Value="Disabled" />
</Style>

<Style
x:Key="GridViewItemStyle"
BasedOn="{StaticResource DefaultGridViewItemStyle}"
Expand Down Expand Up @@ -124,29 +100,20 @@
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>

<Style x:Key="ColorPageExampleBox" TargetType="StackPanel">
<Setter Property="CornerRadius" Value="4" />
<Setter Property="Background" Value="White" />
<Setter Property="Spacing" Value="4" />
<Style x:Key="GalleryTileGridStyle" TargetType="Grid">
<Setter Property="Background" Value="{ThemeResource GalleryBackgroundBrush}" />
<Setter Property="BorderBrush" Value="{ThemeResource GalleryBorderBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="{StaticResource OverlayCornerRadius}" />
</Style>

<x:Double x:Key="TeachingTipMinWidth">50</x:Double>

<SolidColorBrush x:Key="WindowCaptionBackground">Transparent</SolidColorBrush>
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled">Transparent</SolidColorBrush>
<x:Double x:Key="ColorSectionSpacing">12</x:Double>

<!-- Icon Paths -->
<x:String x:Key="GitHubIconPath">M21.7999992370605,0L19.220495223999,0.26007080078125 16.81787109375,1.00595712661743 14.6436157226563,2.18616962432861 12.7492189407349,3.74921894073486 11.1861696243286,5.64361572265625 10.0059566497803,7.81787109375 9.26007080078125,10.2204961776733 9,12.8000001907349 9.65248012542725,16.8459720611572 11.4694375991821,20.3591785430908 14.2401514053345,23.1291217803955 17.7539005279541,24.9453010559082 18.4305686950684,24.8080005645752 18.6273498535156,24.3296756744385 18.6207065582275,23.4247951507568 18.609375,21.9468746185303 16.4340572357178,22.0373229980469 15.1187467575073,21.4822216033936 14.4708204269409,20.7821025848389 14.2976503372192,20.4375 13.8297338485718,19.5214366912842 13.3685493469238,18.947265625 12.8765497207642,18.5656261444092 12.3995819091797,18.1091804504395 12.4844465255737,17.87890625 12.7874250411987,17.7974605560303 12.9647998809814,17.7875003814697 13.8134965896606,18.0311241149902 14.4276065826416,18.4802703857422 14.8007507324219,18.9127178192139 14.926549911499,19.1062507629395 15.8880548477173,20.1437015533447 16.9443283081055,20.494140625 17.9229640960693,20.416259765625 18.6515502929688,20.1687507629395 18.9645938873291,19.1242198944092 19.4640502929688,18.4593753814697 17.3543262481689,18.0241260528564 15.4833002090454,17.014066696167 14.1450357437134,15.1450166702271 13.6336002349854,12.1328001022339 13.9853601455688,10.2268438339233 14.9500007629395,8.69764995574951 14.7027282714844,7.54188776016235 14.7441072463989,6.53565359115601 15.0765495300293,5.30859994888306 15.2825078964233,5.28076791763306 15.9191312789917,5.34375619888306 17.0145378112793,5.71729135513306 18.596851348877,6.62109994888306 21.799976348877,6.19062519073486 25.004674911499,6.62265014648438 26.5845413208008,5.71818733215332 27.6791000366211,5.34472513198853 28.315746307373,5.28210020065308 28.5218753814697,5.31015014648438 28.8556652069092,6.53784370422363 28.8976573944092,7.5438346862793 28.6499996185303,8.69764995574951 29.6154251098633,10.2268533706665 29.9656257629395,12.1328001022339 29.453296661377,15.1497011184692 28.1123065948486,17.0164012908936 26.2366523742676,18.020601272583 24.120325088501,18.4500007629395 24.7275562286377,19.3355484008789 24.9890747070313,20.8187503814697 24.9804744720459,23.0584030151367 24.9718742370605,24.3312511444092 25.1693305969238,24.8128852844238 25.8531246185303,24.9453010559082 29.3641395568848,23.1273632049561 32.1326217651367,20.3568344116211 33.948070526123,16.8442134857178 34.5999984741211,12.8000001907349 34.3399276733398,10.2204961776733 33.5940399169922,7.81787109375 32.4138298034668,5.64361572265625 30.8507804870605,3.74921894073486 28.9563827514648,2.18616962432861 26.7821273803711,1.00595712661743 24.3795032501221,0.26007080078125 21.7999992370605,0z</x:String>

<x:String x:Key="TemplateStudioIconPath">M39,30l-15,7.5-5-2.5v-9l-4-2v9l-3-1.5v-14.944l12,5.944,15.034-7.447L24,3.831,9,15.027v14.973L0,34.5l24,12,24-12-9-4.5ZM24,7.575v11.577l-9.323-4.618,9.323-6.959Z</x:String>
<x:Double x:Key="ColorSectionSpacing">12</x:Double>

<Style x:Key="ColorTilesPanelStyle" TargetType="Grid">
<Style.Setters>
<Setter Property="Background" Value="{ThemeResource ControlExampleDisplayBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}" />
<Setter Property="CornerRadius" Value="{StaticResource OverlayCornerRadius}" />
</Style.Setters>
</Style>

</ResourceDictionary>
</Application.Resources>
</Application>
2 changes: 0 additions & 2 deletions WinUIGallery/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
using Windows.ApplicationModel.Activation;
using WinUIGallery.DesktopWap.DataModel;
using WASDK = Microsoft.WindowsAppSDK;
using Microsoft.Windows.AppLifecycle;
using System.IO;
using WinUIGallery.Helper;

namespace AppUIBasics
Expand Down
Binary file modified WinUIGallery/Assets/ControlImages/AnnotatedScrollBar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion WinUIGallery/ContentIncludes.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Content Include="Assets\ControlImages\Button.png" />
<Content Include="Assets\ControlImages\CalendarDatePicker.png" />
<Content Include="Assets\ControlImages\CalendarView.png" />
<!-- TODO: Need a camera capture icon. -->
<Content Include="Assets\ControlImages\CaptureElement.png" />
<Content Include="Assets\ControlImages\Canvas.png" />
<Content Include="Assets\ControlImages\Checkbox.png" />
<Content Include="Assets\ControlImages\Clipboard.png" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,8 @@
TextWrapping="Wrap" />
<controls1:SampleThemeListener>
<Grid
Style="{ThemeResource GalleryTileGridStyle}"
Padding="8"
Background="{ThemeResource ControlExampleDisplayBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{StaticResource ControlCornerRadius}"
ColumnSpacing="8"
RowSpacing="8">
<Grid.RowDefinitions>
Expand Down
6 changes: 1 addition & 5 deletions WinUIGallery/ControlPages/DesignGuidance/IconsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,7 @@
MaxHeight="600"
VerticalAlignment="Top"
IsTabStop="True">
<Grid
Background="{ThemeResource ControlExampleDisplayBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{StaticResource OverlayCornerRadius}">
<Grid Style="{ThemeResource GalleryTileGridStyle}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="296" />
Expand Down
46 changes: 32 additions & 14 deletions WinUIGallery/Controls/ControlExample.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@
mc:Ignorable="d">

<Grid x:Name="rootGrid" Loaded="rootGrid_Loaded">
<Grid.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<StaticResource x:Key="ControlExampleDisplayBrush" ResourceKey="SolidBackgroundFillColorBaseBrush" />
<Thickness x:Key="ControlExampleDisplayBorderThickness">0</Thickness>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<StaticResource x:Key="ControlExampleDisplayBrush" ResourceKey="SolidBackgroundFillColorBaseBrush" />
<Thickness x:Key="ControlExampleDisplayBorderThickness">0</Thickness>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<SolidColorBrush x:Key="ControlExampleDisplayBrush" Color="{ThemeResource SystemColorWindowColor}" />
<Thickness x:Key="ControlExampleDisplayBorderThickness">1</Thickness>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

<Thickness x:Key="ControlElementScreenshotModePadding">67</Thickness>
</ResourceDictionary>
</Grid.Resources>

<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
Expand Down Expand Up @@ -94,10 +114,8 @@
<controls1:SampleThemeListener>
<Grid
x:Name="ExampleContainer"
Style="{ThemeResource GalleryTileGridStyle}"
x:FieldModifier="Public"
Background="{ThemeResource ControlExampleDisplayBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="8,8,0,0">
<Grid.RowDefinitions>
<RowDefinition />
Expand All @@ -110,17 +128,17 @@
</Grid.ColumnDefinitions>

<!-- Example Display -->
<ContentPresenter
x:Name="ControlPresenter"
Padding="12"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
HorizontalContentAlignment="{x:Bind HorizontalContentAlignment}"
Background="{ThemeResource ControlExampleDisplayBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="{ThemeResource ControlExampleDisplayBorderThickness}"
Content="{x:Bind Example}"
CornerRadius="8,8,0,0" />
<ContentPresenter
x:Name="ControlPresenter"
Padding="12"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
HorizontalContentAlignment="{x:Bind HorizontalContentAlignment}"
Background="{ThemeResource ControlExampleDisplayBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="{ThemeResource ControlExampleDisplayBorderThickness}"
Content="{x:Bind Example}"
CornerRadius="8,8,0,0" />

<!-- Output Display -->
<StackPanel
Expand Down
4 changes: 2 additions & 2 deletions WinUIGallery/Controls/DesignGuidance/ColorPageExample.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="{ThemeResource ControlExampleDisplayBrush}"
Background="{ThemeResource GalleryBackgroundBrush}"
mc:Ignorable="d">

<Grid>
Expand All @@ -21,7 +21,7 @@
Margin="0,36,0,0"
Padding="12"
Background="{x:Bind Background, Mode=OneWay}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderBrush="{ThemeResource GalleryBorderBrush}"
BorderThickness="1"
CornerRadius="{StaticResource OverlayCornerRadius}">
<Grid.RowDefinitions>
Expand Down
Loading

0 comments on commit dc021e8

Please sign in to comment.