-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add ColorPickerButton #3379
Conversation
Added just to be functional. Requires further work.
Thanks robloo for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌 |
|
@robloo Thanks for the PR. Whenever you get a chance if you could sign the license/cla above that would be great😄 |
I'm getting a lot of formatting errors. In my opinion the settings are too strict and I would like to override them. For example, I have the following code: Errors are:
If I break these things up it's going to make the code a lot more difficult to read. The null checks all over the place are required in a control and making them inline is easier to read. Concerning whitespace, I strongly disagree with this requirement as aligning code like this is a pretty standard practice for readability... at least in the embedded world. |
This completes the switch from NumberBox to TextBox
Thanks for the detailed info and clarification. |
@Kyaa-dost @michael-hawker This is largely implemented now in the toolkit. I don't have all the visual states and properties hooked up but your feedback on overall look of the control would be useful now before all of that is done. (See ToDo list in PR text) I have added this control to the SampleApp so it is easy to test. |
I ran across a bug I would like help diagnosing. These types of bugs can take a while so wonder if anyone has an idea if the problem is with UWP. Maybe it's just too late in the evening :) In OnApplyTemplate() I'm setting the color representation (RGB/HSV) RadioButton's IsChecked value by calling SetActiveColorRepresentation(). On the first ColorPickerButton loaded in the visual tree it works fine. For all other ColorPickerButton's loaded in the tree the radio button for RGB/HSV is never set. Clicking the radio buttons after initial load everything works fine. Looking at what is going on inside SetActiveColorRepresentation(), I see that when I call |
It appears there are a few UWP bugs making radio buttons unusable with implicit groups while in controls and especially with flyouts. microsoft/microsoft-ui-xaml#1299 |
@michael-hawker I merged your branch and closed several of the open items. Several updates were made splitting out the ColorPickerSlider as a separate control. Although more work is required to remove them as template parts, what was done includes:
The only new issue I noticed is keyboard navigation doesn't work to change tabs. The new switch presenter is very nice though. In the future it would also be nice to auto-size the tabs to fit available width when some tabs are hidden. |
@robloo I was able to navigate the tabs with the keyboard (it's just a listbox for the header). Not sure if the tab order for everything is set, so maybe that's a problem? I did notice we should edit the navigation on the palette grid as it doesn't let you use the arrow keys to move in the actual grid, that may just be a property we can set. We can do some fixes for this after. |
Microsoft.Toolkit.Uwp.UI.Controls/ColorPicker/ContrastBrushConverter.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, let's get this in to the next preview and collect some community feedback. 🎉
Hello @michael-hawker! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
Microsoft.Toolkit.Uwp.UI.Controls/SwitchPresenter/SwitchPresenter.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 🚀
Add ColorPickerButton to the Toolkit
Closes #3363
PR Type
What kind of change does this PR introduce?
Feature
Documentation content changes
Sample app changes
What is the current behavior?
The toolkit, and WinUI/UWP, has no flyout ColorPicker. The color picker that currently exists is a large canvas-type control (that is incorrectly named). This existing control has lots of usability concerns discussed in #3363 and the WinUI repository.
What is the new behavior?
A brand-new control is added to allow selecting and editing a color within a flyout. The selected color is always visible in the content area of a drop-down button as a preview.
The new properties for this picker are below. Note that these are purposely name 'CustomPalette...' instead of 'Palette...' as multiple palettes may be supported in the future (windows colors, recent colors, custom palette all in different sections visible at the same time).
Making all of this easier is a new IColorPalette interface. Any class can implement this interface to provide a custom color palette such as windows colors (the default), RYB colors, Flat UI colors, etc. Colors could also be algorithmically generated.
PR Checklist
Please check if your PR fulfills the following requirements:
Other information
Control
Switch to radio buttons to switch between RGB/HSV representation. A ComboBox within a Flyout is generally bad practice and is also limited by some bugs in UWP (Stale issue bot #1467).'CustomPaletteWrapCount'or 'CustomPaletteColumns' like UniformGridto match with windows settings app (check mark overlay)The check mark is not included as the size of swatches in the palette could be smaller than the check mark itself.Do not show the color (set the preview border visibility to collapsed) while the control is initializing. This prevents the default color from briefly appearing during initial load. Instead, the background will just show through.WindowsColorPalette
toFluentColorPalette
Code Review
Other
Future
These changes should be considered for future versions of the control. They are recorded here for lack of a better location.
Remove the custom 'ColorPickerButtonSlider' after switch to WinUI 3.0. This assumes there is no additional control-specific code at that point. (It currently exists just to work-around UWP bugs).This should be turned into it's own full primitive control.Ensure PivotItems are properly removed once/if Setting PivotItem.Visiblity to Collapsed Does not Remove It from Pivot microsoft/microsoft-ui-xaml#2952 is closed.