Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ColorPickerButton #3379

Merged
78 commits merged into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
307beca
Initial port of ColorPickerButton to the toolkit
robloo Jul 5, 2020
d51bbc8
Add the ColorPickerButton to SampleApp
robloo Jul 5, 2020
d173f9d
Rename 'ColorPickerSlider' to 'ColorPickerButtonSlider'
robloo Jul 5, 2020
3b0e1b2
Add conditional XAML for CornerRadius
robloo Jul 6, 2020
58108c9
Add XML comment
robloo Jul 6, 2020
3957abf
Several formatting changes to align with the toolkit
robloo Jul 6, 2020
84e5106
Several formatting changes to align with the toolkit
robloo Jul 6, 2020
1fe4104
Add ColorPickerButton icon and description
robloo Jul 6, 2020
459de36
Fully implement all color channel TextBoxes
robloo Jul 6, 2020
5d9872b
More formatting changes
robloo Jul 6, 2020
83cb6e0
Add WindowsColorPalette as the default
robloo Jul 6, 2020
6c7bbb6
Several formatting changes to align with the toolkit
robloo Jul 6, 2020
a0e6d88
Switch to RadioButtons for color representation
robloo Jul 7, 2020
2f2a256
Remove unused XAML
robloo Jul 7, 2020
49c3ff9
Add SampleApp XAML for ColorPickerButton
robloo Jul 7, 2020
c235308
Keep ColorPicker default property values in style
robloo Jul 7, 2020
4d6f9d5
Update SampleApp XAML for ColorPickerButton
robloo Jul 7, 2020
2de382f
Remove alpha from hex text when alpha is disabled
robloo Jul 7, 2020
da777c3
Move ColorPickerButton-specific converters to separate files
robloo Jul 7, 2020
545dc5e
Several formatting changes to align with the toolkit
robloo Jul 7, 2020
ce89a21
Add AlphaSliderVisibility visual states
robloo Jul 7, 2020
6673608
Switch to ToggleButton for RGB/HSV selection
robloo Jul 8, 2020
0a2598e
Rename 'CustomPaletteSectionCount' to 'CustomPaletteColumns'
robloo Jul 8, 2020
710e5d8
Adjust RGB/HSV ToggleButton style
robloo Jul 8, 2020
3bbcb11
Set slider thumb border brush based on selected color
robloo Jul 8, 2020
f39a297
Switch to ContrastBrushConverter
robloo Jul 12, 2020
4536993
Support both Color and SolidColorBrush in converters
robloo Jul 12, 2020
1875bfa
Fix comment by removing it
robloo Jul 12, 2020
f10cc75
Update styling based on feedback
robloo Jul 12, 2020
70a66cd
Fix comment
robloo Jul 19, 2020
0cc1db0
Update sample app XAML
robloo Jul 19, 2020
0943355
Add ColorToDisplayNameConverter
robloo Jul 19, 2020
f081e90
Add all AutomationProperties
robloo Jul 19, 2020
664dbe4
Merge branch 'master' into robloo/reimagined-color-picker
robloo Jul 19, 2020
6764330
Fix SampleApp.csproj after merge
robloo Jul 19, 2020
9ee2c61
Re-template GridViewItem so that the border has correct contrast with…
robloo Jul 19, 2020
3adef02
Add IsColorPaletteVisible property
robloo Jul 20, 2020
db75308
Implement all VisualStateGroups
robloo Jul 20, 2020
7b0f58a
Add missing header to ContrastBrushConverter
robloo Jul 20, 2020
1178c7e
Update sample app page design
robloo Aug 2, 2020
1fdf917
Specially handle min/max in ColorToColorShadeConverter
robloo Aug 2, 2020
9203f00
Simplify ColorToColorShadeConverter algorithm
robloo Aug 2, 2020
e2692c0
Rename 'CustomPaletteColumns' to 'CustomPaletteColumnCount'
robloo Aug 2, 2020
b51df4d
Adjust margin before/after channel sliders
robloo Aug 2, 2020
71cad62
Fix converter exception messages
robloo Aug 2, 2020
1b28240
Move ColorToDisplayNameConverter into Microsoft.Toolkit.Uwp.UI.Conver…
robloo Aug 2, 2020
7226bbb
Move color picker-specific converters into their own namespace
robloo Aug 2, 2020
ef8e9d4
Set alpha to max when interacting with the color spectrum and alpha i…
robloo Aug 2, 2020
664592d
Change default height to 32px
robloo Aug 3, 2020
f42060e
Always use HSV when updating the color spectrum color
robloo Aug 3, 2020
e4a45df
Ensure ColorPickerButton/Slider don't get optimized away by .NET native
robloo Aug 3, 2020
4e72f2b
Fix how color coercion is applied when interacting with spectrum
robloo Aug 3, 2020
7b1fef8
Initial Refactor of ColorPickerButton to ColorPicker
michael-hawker Sep 3, 2020
981b288
Merge remote-tracking branch 'origin/master' into mhawker/color-picke…
michael-hawker Oct 20, 2020
3da0975
Add SwitchPresenter control (first-pass)
michael-hawker Oct 22, 2020
0680e9b
Update Template usage to use nameof and swap default.
michael-hawker Oct 23, 2020
4bbef93
Apply XAML Styler to ColorPicker.xaml
michael-hawker Oct 23, 2020
1758a35
Fix extra unneeded file references in csproj for Controls
michael-hawker Oct 23, 2020
ea75c8a
Add in ColorPickerButton again to Codebase
michael-hawker Oct 27, 2020
9b561de
Add Transparency to the ColorPickerButton Preview
michael-hawker Oct 27, 2020
5767df4
Fix ColorPickerButton Event Registration
michael-hawker Oct 27, 2020
288a0cc
Fix Style-Cop Issues
michael-hawker Nov 3, 2020
8155112
Merge pull request #1 from michael-hawker/mhawker/color-picker-respon…
robloo Nov 8, 2020
415a818
Rename 'WindowsColorPalette' to 'FluentColorPalette'
robloo Nov 8, 2020
bf502c6
Use the WinUI algorithm for light/dark contrast color switching
robloo Nov 8, 2020
8cc36dd
Add corner radius to ColorPickerButton flyout
robloo Nov 8, 2020
21aea6f
Disconnect any old events in OnApplyTemplate()
robloo Nov 8, 2020
5f0d875
Show palette color in a ToolTip
robloo Nov 8, 2020
eff0f25
Separate ColorPickerSlider XAML into new file
robloo Nov 8, 2020
3877457
Use correct resource for overlay corner radius
robloo Nov 8, 2020
278bbf7
Adjust default width to align content
robloo Nov 8, 2020
4064179
Move ColorPickerSlider foreground/background calculation into the con…
robloo Nov 9, 2020
5a05f83
Merge branch 'master' into robloo/reimagined-color-picker
robloo Nov 9, 2020
eb28b0f
Add missing license header
robloo Nov 9, 2020
4efb60c
Fix comments
robloo Nov 9, 2020
4c29e58
Update Microsoft.Toolkit.Uwp.UI.Controls/ColorPicker/ContrastBrushCon…
michael-hawker Nov 9, 2020
55944ef
Merge branch 'master' into robloo/reimagined-color-picker
michael-hawker Nov 9, 2020
eb61e6d
Apply suggestions from code review
Kyaa-dost Nov 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@
<Content Include="Icons\More.png" />
<Content Include="Icons\Notifications.png" />
<Content Include="Icons\Services.png" />
<Content Include="SamplePages\ColorPicker\ColorPicker.png" />
<Content Include="SamplePages\TilesBrush\TilesBrush.png" />
<Content Include="SamplePages\Eyedropper\Eyedropper.png" />
<Content Include="SamplePages\OnDevice\OnDevice.png" />
Expand Down Expand Up @@ -509,6 +510,12 @@
<Compile Include="SamplePages\AutoFocusBehavior\AutoFocusBehaviorPage.xaml.cs">
<DependentUpon>AutoFocusBehaviorPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\ColorPicker\ColorPickerButtonPage.xaml.cs">
<DependentUpon>ColorPickerButtonPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\ColorPicker\ColorPickerPage.xaml.cs">
<DependentUpon>ColorPickerPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\EnumValuesExtension\EnumValuesExtensionPage.xaml.cs">
<DependentUpon>EnumValuesExtensionPage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -620,6 +627,8 @@
<Content Include="SamplePages\EnumValuesExtension\EnumValuesExtensionCode.bind" />
<Content Include="SamplePages\FocusBehavior\FocusBehaviorXaml.bind" />
<Content Include="SamplePages\AutoFocusBehavior\AutoFocusBehaviorXaml.bind" />
<Content Include="SamplePages\ColorPicker\ColorPickerXaml.bind" />
<Content Include="SamplePages\ColorPicker\ColorPickerButtonXaml.bind" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
Expand Down Expand Up @@ -993,6 +1002,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SamplePages\ColorPicker\ColorPickerButtonPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SamplePages\ColorPicker\ColorPickerPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SamplePages\EnumValuesExtension\EnumValuesExtensionPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.ColorPickerButtonPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:primitives="using:Microsoft.Toolkit.Uwp.UI.Controls.Primitives"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">

<Grid Visibility="Collapsed">
<controls:ColorPickerButton />
<primitives:ColorPickerSlider />
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.Toolkit.Uwp.UI.Controls;
using Windows.UI.Xaml.Controls;

namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
{
/// <summary>
/// A page that shows how to use the <see cref="UI.Controls.ColorPicker"/> control.
/// </summary>
public sealed partial class ColorPickerButtonPage : Page
{
public ColorPickerButtonPage()
{
this.InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<SolidColorBrush Color="{ThemeResource SystemChromeLowColor}" x:Key="SystemControlForegroundChromeLowBrush"/>
</Page.Resources>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- Example 1 -->
<StackPanel Grid.Row="0"
Orientation="Vertical"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Spacing="20">
<Border Background="{ThemeResource SystemChromeMediumColor}"
CornerRadius="4"
Height="100"
Width="300"
Padding="10">
<TextBlock TextAlignment="Center"
VerticalAlignment="Center">
Box-shaped spectrum <LineBreak />
Alpha channel disabled
</TextBlock>
</Border>
<controls:ColorPickerButton x:Name="ColorPickerButton1"
SelectedColor="Navy">
<controls:ColorPickerButton.ColorPickerStyle>
<Style TargetType="controls:ColorPicker">
<Setter Property="ColorSpectrumShape" Value="Box"/>
<Setter Property="IsAlphaEnabled" Value="False"/>
<Setter Property="IsHexInputVisible" Value="True"/>
</Style>
</controls:ColorPickerButton.ColorPickerStyle>
</controls:ColorPickerButton>
</StackPanel>
<!-- Example 2 -->
<StackPanel Grid.Row="1"
Orientation="Vertical"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Spacing="20">
<Border Background="{ThemeResource SystemChromeMediumColor}"
CornerRadius="4"
Height="100"
Width="300"
Padding="10">
<TextBlock TextAlignment="Center"
VerticalAlignment="Center">
Box-shaped spectrum <LineBreak />
Alpha channel enabled
</TextBlock>
</Border>
<controls:ColorPickerButton x:Name="ColorPickerButton2"
SelectedColor="Green">
<controls:ColorPickerButton.ColorPickerStyle>
<Style TargetType="controls:ColorPicker">
<Setter Property="ColorSpectrumShape" Value="Box"/>
<Setter Property="IsAlphaEnabled" Value="True"/>
<Setter Property="IsHexInputVisible" Value="False"/>
</Style>
</controls:ColorPickerButton.ColorPickerStyle>
</controls:ColorPickerButton>
</StackPanel>
<!-- Example 3 -->
<StackPanel Grid.Row="2"
Orientation="Vertical"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Spacing="20">
<Border Background="{ThemeResource SystemChromeMediumColor}"
CornerRadius="4"
Height="100"
Width="300"
Padding="10">
<TextBlock TextAlignment="Center"
VerticalAlignment="Center">
Ring-shaped spectrum <LineBreak />
Alpha channel enabled
</TextBlock>
</Border>
<controls:ColorPickerButton x:Name="ColorPickerButton3"
SelectedColor="Transparent">
<controls:ColorPickerButton.ColorPickerStyle>
<Style TargetType="controls:ColorPicker">
<Setter Property="ColorSpectrumShape" Value="Ring"/>
<Setter Property="IsAlphaEnabled" Value="True"/>
<Setter Property="IsHexInputVisible" Value="True"/>
</Style>
</controls:ColorPickerButton.ColorPickerStyle>
</controls:ColorPickerButton>
</StackPanel>
<!-- Example 4 -->
<StackPanel Grid.Row="3"
Orientation="Vertical"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Spacing="20">
<Border Background="{ThemeResource SystemChromeMediumColor}"
CornerRadius="4"
Height="100"
Width="300"
Padding="10">
<TextBlock TextAlignment="Center"
VerticalAlignment="Center">
Ring-shaped spectrum <LineBreak />
Alpha channel enabled <LineBreak />
Saturation+Value spectrum channels
</TextBlock>
</Border>
<controls:ColorPickerButton x:Name="ColorPickerButton4"
SelectedColor="Maroon">
<controls:ColorPickerButton.ColorPickerStyle>
<Style TargetType="controls:ColorPicker">
<Setter Property="ColorSpectrumShape" Value="Ring"/>
<Setter Property="ColorSpectrumComponents" Value="SaturationValue"/>
<Setter Property="IsAlphaEnabled" Value="True"/>
<Setter Property="IsHexInputVisible" Value="True"/>
</Style>
</controls:ColorPickerButton.ColorPickerStyle>
</controls:ColorPickerButton>
</StackPanel>
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.ColorPickerPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:primitives="using:Microsoft.Toolkit.Uwp.UI.Controls.Primitives"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid
Visibility="Collapsed">
<controls:ColorPicker />
<primitives:ColorPickerSlider />
</Grid>

</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.Toolkit.Uwp.UI.Controls;
using Windows.UI.Xaml.Controls;

namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
{
/// <summary>
/// A page that shows how to use the <see cref="UI.Controls.ColorPicker"/> control.
/// </summary>
public sealed partial class ColorPickerPage : Page
{
public ColorPickerPage()
{
this.InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<SolidColorBrush Color="{ThemeResource SystemChromeLowColor}" x:Key="SystemControlForegroundChromeLowBrush"/>
</Page.Resources>

<ScrollViewer>
<StackPanel Orientation="Vertical"
HorizontalAlignment="Center"
Spacing="20">
<!-- Example 1 -->
<Border Background="{ThemeResource SystemChromeMediumColor}"
CornerRadius="4"
Height="100"
Width="300"
Padding="10">
<TextBlock TextAlignment="Center"
VerticalAlignment="Center">
Box-shaped spectrum <LineBreak />
Alpha channel disabled
</TextBlock>
</Border>
<controls:ColorPicker x:Name="ColorPicker1"
Color="Navy"
ColorSpectrumShape="Box"
IsAlphaEnabled="False"
IsHexInputVisible="True" />
<!-- Example 2 -->
<Border Background="{ThemeResource SystemChromeMediumColor}"
CornerRadius="4"
Height="100"
Width="300"
Padding="10">
<TextBlock TextAlignment="Center"
VerticalAlignment="Center">
Box-shaped spectrum <LineBreak />
Alpha channel enabled
</TextBlock>
</Border>
<controls:ColorPicker x:Name="ColorPicker2"
Color="Green"
ColorSpectrumShape="Box"
IsAlphaEnabled="True"
IsHexInputVisible="False" />
<!-- Example 3 -->
<Border Background="{ThemeResource SystemChromeMediumColor}"
CornerRadius="4"
Height="100"
Width="300"
Padding="10">
<TextBlock TextAlignment="Center"
VerticalAlignment="Center">
Ring-shaped spectrum <LineBreak />
Alpha channel enabled
</TextBlock>
</Border>
<controls:ColorPicker x:Name="ColorPickerButton3"
Color="Transparent"
ColorSpectrumShape="Ring"
IsAlphaEnabled="True"
IsHexInputVisible="True" />
<!-- Example 4 -->
<Border Background="{ThemeResource SystemChromeMediumColor}"
CornerRadius="4"
Height="100"
Width="300"
Padding="10">
<TextBlock TextAlignment="Center"
VerticalAlignment="Center">
Ring-shaped spectrum <LineBreak />
Alpha channel enabled <LineBreak />
Saturation+Value spectrum channels
</TextBlock>
</Border>
<controls:ColorPicker x:Name="ColorPickerButton4"
Color="Maroon"
ColorSpectrumShape="Ring"
ColorSpectrumComponents="SaturationValue"
IsAlphaEnabled="True"
IsHexInputVisible="True"/>
</StackPanel>
</ScrollViewer>
</Page>
20 changes: 20 additions & 0 deletions Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@
"Icon": "/SamplePages/Carousel/Carousel.png",
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/Carousel.md"
},
{
"Name": "ColorPicker",
"Type": "ColorPickerPage",
"Subcategory": "Input",
"About": "An improved color picker control providing more options to select colors.",
"CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/ColorPicker",
"XamlCodeFile": "ColorPickerXaml.bind",
"Icon": "/SamplePages/ColorPicker/ColorPicker.png",
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/ColorPicker.md"
},
{
"Name": "ColorPickerButton",
"Type": "ColorPickerButtonPage",
"Subcategory": "Input",
"About": "A color picker within a flyout opened by pressing a dropdown button containing the selected color.",
"CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/ColorPicker",
"XamlCodeFile": "/SamplePages/ColorPicker/ColorPickerButtonXaml.bind",
"Icon": "/SamplePages/ColorPicker/ColorPicker.png",
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/ColorPickerButton.md"
},
{
"Name": "AdaptiveGridView",
"Type": "AdaptiveGridViewPage",
Expand Down
Loading