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

Color picker fixes #4134

Merged
merged 8 commits into from
Aug 30, 2021
Merged

Color picker fixes #4134

merged 8 commits into from
Aug 30, 2021

Conversation

robloo
Copy link
Contributor

@robloo robloo commented Jul 27, 2021

👉 It is imperative to resolve ONE ISSUE PER PR and avoid making multiple changes unless the changes interrelate with each other

Fixes #4121

Relates to #3643

  • [Bug] Ensures that the selected 'panel' or 'tab' is visible at first load. This fixes Color Picker custom style not load on selected pane #4121.
  • [Bug] Set default ColorPickerSlider DefaultForeground property Brush values in the XAML default style instead of when registering the DP. This is necessary to ensure a reference isn't shared across instances or threads. [From discord discussion]
  • Make tabs automatically size uniformly to width. This improves the design when some tabs are hidden
  • Add central OnDependencyPropertyChanged method in ColorPicker. This simplifies some code and makes adding future property changed handling easier.

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Refactoring (no functional changes, no api changes)

What is the current behavior?

What is the new behavior?

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Pull Request has been submitted to the documentation repository instructions. Link:
  • Sample in sample app has been added / updated (for bug fixes / features)
  • New major technical changes in the toolkit have or will be added to the Wiki e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

@ghost
Copy link

ghost commented Jul 27, 2021

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 🙌

@ghost ghost requested review from michael-hawker, azchohfi and Rosuavio July 27, 2021 02:51
@ghost ghost added bug 🐛 An unexpected issue that highlights incorrect behavior controls 🎛️ labels Jul 27, 2021
@@ -216,6 +220,7 @@ protected override void OnApplyTemplate()

base.OnApplyTemplate();
this.UpdateVisualState(false);
this.ValidateSelectedPanel();
Copy link
Contributor Author

@robloo robloo Jul 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an issue with validating and updating the selected panel only here. If the IsColorSpectrumVisible or IsColorChannelTextInputVisible properties are changed after the template is applied the selected tab may become invalid. This is because the base WinUI ColorPicker is currenlty responsible for updating the visual state that actually applies tab visibility for these two (it is all done in the style). Only IsColorPaletteVisible is managed by the derived toolkit ColorPicker. To fix this:

  1. Need to monitor for property changes on these properties as well, or
  2. Need to connect to VisualState changed events -- there are more than one and this is a bit ugly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an existing issue, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was waiting to see if its considered enough of an issue to fix. The changes now will work as long as the properties are updated in XAML which is by far the largest use case.

@robloo
Copy link
Contributor Author

robloo commented Jul 27, 2021

Overall the selection fix exposes an inconvenience with separating a selection control (ListBox) from the presenter content control (SwitchPresenter). Ideally, the control responsible for selection could be smart enough to ensure the selected item is actually visible. It is a bit more complex to do this in the control itself and obviously isn't general purpose. A nice 'Tab' control to handle this case would be better in my opinion.

robloo added 3 commits July 26, 2021 23:30
This improves the design when some tabs are hidden
This fixes potential issues with shared instances of the brush
@michael-hawker michael-hawker added the next preview ✈️ Label for marking what we want to include in the next preview release for developers to try. label Jul 27, 2021
@michael-hawker michael-hawker added this to the 7.1 milestone Jul 27, 2021
Copy link
Contributor

@Rosuavio Rosuavio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the new example is covering an existing one.

@michael-hawker michael-hawker removed the next preview ✈️ Label for marking what we want to include in the next preview release for developers to try. label Aug 3, 2021
@michael-hawker
Copy link
Member

@robloo couple of open questions and a small fix to the sample when you have a chance, thanks!

Rosuavio
Rosuavio previously approved these changes Aug 4, 2021
@Rosuavio Rosuavio dismissed their stale review August 4, 2021 18:40

Waiting on smaple changes

@robloo
Copy link
Contributor Author

robloo commented Aug 18, 2021

@michael-hawker Looks like there are a lot more changes to the template than I initially thought. You really moved a lot of things around when you broke up ColorPicker and ColorPickerButton. One of the things you removed appears to be the drop shadow behind the primary preview color (the one in the center). I'm planning to add this drop shadow back unless you had a good reason for taking it out. The comments look like you just forgot to add it back.

<!--<controls:DropShadowPanel Grid.RowSpan="3"
Grid.Column="2"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
BlurRadius="10.0"
OffsetX="0.0"
OffsetY="0.0"
ShadowOpacity="0.75"
Color="Black"> Not too far off without it, maybe we can fake?-->

Otherwise, I should get to finishing the PR next week.

@michael-hawker
Copy link
Member

@robloo can't remember why I removed it, think there was some rendering issue I was fighting. FYI, we're going to deprecate the DropShadowPanel as we're adding new shadows to the toolkit in #4179. Maybe just leave it still for now and we can resolve later for the next release?

@robloo
Copy link
Contributor Author

robloo commented Aug 21, 2021

@michael-hawker Sure, I'll wait until the new drop shadow methodology is in place. It's good there is advancement in this area! I also read you are updating to 2.6 styles so I can include the drop shadow with some teaks to make things look better with WinUI 2.6 styles. (at least some 2px -> 4px corner radius updates)

@michael-hawker
Copy link
Member

@robloo everything else about this PR was ready to go, eh? We can add a fix in for the DropShadow as a separate PR once #4179 is merged, eh?

@robloo
Copy link
Contributor Author

robloo commented Aug 25, 2021

@michael-hawker No, not ready to go. Need to fix the samples. I still plan on getting to that this week.

This is now the same as ColorPicker samples
@ghost
Copy link

ghost commented Aug 29, 2021

This PR has been marked as "needs attention 👋" and awaiting a response from the team.

@robloo
Copy link
Contributor Author

robloo commented Aug 29, 2021

This should be all set now

Copy link
Contributor

@Rosuavio Rosuavio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ghost
Copy link

ghost commented Aug 30, 2021

Hello @michael-hawker!

Because this pull request has the auto merge :zap: label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

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 (@msftbot) and give me an instruction to get started! Learn more here.

@michael-hawker michael-hawker added the next preview ✈️ Label for marking what we want to include in the next preview release for developers to try. label Aug 30, 2021
@michael-hawker michael-hawker merged commit aecbcad into CommunityToolkit:main Aug 30, 2021
@michael-hawker
Copy link
Member

Thanks @robloo for continued improvements to the Color Picker!

@robloo robloo deleted the color-picker-fixes branch August 30, 2021 22:06
@Rosuavio Rosuavio removed their assignment Sep 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merge ⚡ bug 🐛 An unexpected issue that highlights incorrect behavior controls 🎛️ next preview ✈️ Label for marking what we want to include in the next preview release for developers to try.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Color Picker custom style not load on selected pane
4 participants