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
DatePicker and TimePicker flyout visual updates #3947
Merged
+1,018
−227
Merged
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
acb4abc
Initial checkin for DatePicker highlight rect
jevansaks 378cc6f
Change style default back for the test app
jevansaks 120c1bf
Merge remote-tracking branch 'origin/master' into user/jevansaks/date…
jevansaks d9ee343
Merge remote-tracking branch 'origin/master' into user/jevansaks/date…
jevansaks 6f7347d
Fix inner loop solution
jevansaks 2faf43d
Updates to make focus rect work (needs extensive comments, stay tuned)
jevansaks b2f559d
Merge branch 'master' into user/jevansaks/datepickerhighlightrect
almedina-ms bc91275
Merge branch 'master' into user/jevansaks/datepickerhighlightrect
almedina-ms dba843b
Merge branch 'master' into user/jevansaks/datepickerhighlightrect
almedina-ms 8606cc5
Merge branch 'master' into user/jevansaks/datepickerhighlightrect
almedina-ms 89c71ff
Rename ColorFilterOverlayControl to MonochromaticOverlayPresenter
almedina-ms 86a5451
[DatePicker | TimePicker] Update visual styles (#4460)
almedina-ms edc1ed5
Merge branch 'master' into user/jevansaks/datepickerhighlightrect
almedina-ms e6d4a24
Merge branch 'user/jevansaks/datepickerhighlightrect' of https://gith…
almedina-ms File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
dev/ColorFilterOverlayControl/ColorFilterOverlayControl.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
#include "pch.h" | ||
#include "common.h" | ||
#include "ColorFilterOverlayControl.h" | ||
#include "RuntimeProfiler.h" | ||
#include "ResourceAccessor.h" | ||
|
||
struct XamlCompBrush : winrt::Windows::UI::Xaml::Media::XamlCompositionBrushBaseT<XamlCompBrush> | ||
{ | ||
void SetCompositionBrush(winrt::CompositionBrush const& brush) | ||
{ | ||
CompositionBrush(brush); | ||
} | ||
}; | ||
|
||
ColorFilterOverlayControl::ColorFilterOverlayControl() | ||
{ | ||
SizeChanged([this](auto&&...) { | ||
InvalidateBrush(); | ||
}); | ||
} | ||
|
||
void ColorFilterOverlayControl::OnPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args) | ||
{ | ||
winrt::IDependencyProperty property = args.Property(); | ||
|
||
InvalidateBrush(); | ||
} | ||
|
||
void ColorFilterOverlayControl::InvalidateBrush() | ||
{ | ||
// Delay brush updates until Tick to coalesce changes and avoid rebuilding the effect when we don't need to. | ||
if (!_needsBrushUpdate) | ||
{ | ||
_needsBrushUpdate = true; | ||
SharedHelpers::QueueCallbackForCompositionRendering([weakThis = get_weak(), this]() { | ||
if (weakThis.get()) | ||
{ | ||
UpdateBrush(); | ||
} | ||
_needsBrushUpdate = false; | ||
}); | ||
} | ||
} | ||
|
||
void ColorFilterOverlayControl::UpdateBrush() | ||
{ | ||
if (auto targetElement = TargetElement()) | ||
{ | ||
auto const newColor = ReplacementColor(); | ||
if (_replacementColor != newColor) | ||
{ | ||
_replacementColor = newColor; | ||
_effectFactory = nullptr; | ||
} | ||
|
||
auto compositor = winrt::Window::Current().Compositor(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
nit: const |
||
|
||
if (!_effectFactory) | ||
{ | ||
// Build an effect that takes the source image and uses the alpha channel and replaces all other channels with | ||
// the ReplacementColor's RGB. | ||
auto colorMatrixEffect = winrt::make_self<Microsoft::UI::Composition::Effects::ColorMatrixEffect>(); | ||
colorMatrixEffect->Source(winrt::CompositionEffectSourceParameter{ L"source" }); | ||
winrt::Matrix5x4 colorMatrix = {}; | ||
|
||
// If the ReplacementColor is not transparent then use the RGB values as the new color. Otherwise | ||
// just show the target by using an Identity colorMatrix. | ||
if (_replacementColor.A != 0) | ||
{ | ||
colorMatrix.M51 = (float)((_replacementColor.R / 255.0)); | ||
colorMatrix.M52 = (float)((_replacementColor.G / 255.0)); | ||
colorMatrix.M53 = (float)((_replacementColor.B / 255.0)); | ||
colorMatrix.M44 = 1; | ||
} | ||
else | ||
{ | ||
colorMatrix.M11 = colorMatrix.M22 = colorMatrix.M33 = colorMatrix.M44 = 1; | ||
} | ||
colorMatrixEffect->ColorMatrix(colorMatrix); | ||
|
||
_effectFactory = compositor.CreateEffectFactory(*colorMatrixEffect); | ||
} | ||
|
||
auto const actualSize = winrt::float2{ (float)ActualWidth(), (float)ActualHeight() }; | ||
auto transform = TransformToVisual(targetElement); | ||
auto const offset = transform.TransformPoint(winrt::Point{ 0, 0 }); | ||
|
||
// Create a VisualSurface positioned at the same location as this control and feed that | ||
// through the color effect. | ||
auto surfaceBrush = compositor.CreateSurfaceBrush(); | ||
surfaceBrush.Stretch(winrt::CompositionStretch::None); | ||
auto surface = compositor.CreateVisualSurface(); | ||
|
||
// Select the source visual and the offset/size of this control in that element's space. | ||
surface.SourceVisual(winrt::ElementCompositionPreview::GetElementVisual(targetElement)); | ||
surface.SourceOffset({ offset.X, offset.Y }); | ||
surface.SourceSize(actualSize); | ||
surfaceBrush.Surface(surface); | ||
surfaceBrush.Stretch(winrt::CompositionStretch::None); | ||
auto compBrush = _effectFactory.CreateBrush(); | ||
compBrush.SetSourceParameter(L"source", surfaceBrush); | ||
|
||
auto visual = compositor.CreateSpriteVisual(); | ||
visual.Size(actualSize); | ||
visual.Brush(compBrush); | ||
|
||
winrt::ElementCompositionPreview::SetElementChildVisual(*this, visual); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
#pragma once | ||
|
||
#include "pch.h" | ||
#include "common.h" | ||
|
||
#include "ColorFilterOverlayControl.g.h" | ||
#include "ColorFilterOverlayControl.properties.h" | ||
|
||
#pragma warning(push) | ||
#pragma warning(disable: 6101) // Returning uninitialized memory '<value>'. A successful path through the function does not set the named _Out_ parameter. | ||
#include "Microsoft.UI.Composition.Effects_impl.h" | ||
#pragma warning(pop) | ||
|
||
class ColorFilterOverlayControl : | ||
public ReferenceTracker<ColorFilterOverlayControl, winrt::implementation::ColorFilterOverlayControlT>, | ||
public ColorFilterOverlayControlProperties | ||
{ | ||
|
||
public: | ||
ColorFilterOverlayControl(); | ||
~ColorFilterOverlayControl() {} | ||
|
||
void OnPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); | ||
|
||
private: | ||
void UpdateBrush(); | ||
void InvalidateBrush(); | ||
|
||
winrt::CompositionEffectFactory _effectFactory{ nullptr }; | ||
winrt::Color _replacementColor{}; | ||
bool _needsBrushUpdate{}; | ||
}; |
19 changes: 19 additions & 0 deletions
19
dev/ColorFilterOverlayControl/ColorFilterOverlayControl.idl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace MU_XCP_NAMESPACE | ||
{ | ||
|
||
[WUXC_VERSION_PREVIEW] | ||
[webhosthidden] | ||
[MUX_PROPERTY_CHANGED_CALLBACK(TRUE)] | ||
[MUX_PROPERTY_CHANGED_CALLBACK_METHODNAME("OnPropertyChanged")] | ||
unsealed runtimeclass ColorFilterOverlayControl : Windows.UI.Xaml.Controls.Grid | ||
StephenLPeters marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
ColorFilterOverlayControl(); | ||
|
||
Windows.UI.Xaml.UIElement TargetElement { get; set; }; | ||
Windows.UI.Color ReplacementColor { get; set; }; | ||
|
||
static Windows.UI.Xaml.DependencyProperty TargetElementProperty{ get; }; | ||
static Windows.UI.Xaml.DependencyProperty ReplacementColorProperty{ get; }; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think that the inner loop feature areas need to be updated as well.
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.
Can you be more specific about what is missing or what needs to change?
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.
You will need to add this feature to the DatePicker group in line 73 since we need to build this project if want the styles for DatePicker to work as expected.
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.
Thats right, DatePicker should not be dependent on ColorFilterOverlayControl so this PropertyGroup needs to add that as a
ProductOnly
dependency.