Repository navigation
Adjust RadialGradientBrush base type to match UWP - #7170
Youssef1313 wants to merge 6 commits into
Conversation
7455264 to
2418575
Compare
BREAKING CHANGE: `RadialGradientBrush` no longer derives from `GradientBrush`. It now derives from `XamlCompositionBrushBase`.
2418575 to
37cb9b2
Compare
|
@jeromelaban Will I get the "found UI Test snapshots differences" comment from @nventive-devops if this broke something or I need to validate screenshots manually from CI artifacts? |
| else if (newValue is RadialGradientBrush rgb) | ||
| { | ||
| _borderBrushColorChanged.Disposable = rgb.RegisterDisposablePropertyChangedCallback( | ||
| RadialGradientBrush.FallbackColorProperty, | ||
| (s, colorArg) => OnBorderBrushChangedPartial() | ||
| ); | ||
| _borderBrushOpacityChanged.Disposable = rgb.RegisterDisposablePropertyChangedCallback( | ||
| RadialGradientBrush.OpacityProperty, | ||
| (s, _) => OnBorderBrushChangedPartial() | ||
| ); | ||
| } |
There was a problem hiding this comment.
We'll need to refactor this one day... that's definitely not a good pattern and Border knows too much about specific brushes...
There was a problem hiding this comment.
@carldebilly Agreed. This should somehow be moved to each Brush-specific class. Will look into that as a follow-up
There was a problem hiding this comment.
I hate this kind of "type enumeration". WinUI is build using inheritance, we have to follow that pattern and take advantage of it when possible by moving that kind of logic in the implementation itself.
| using Microsoft.UI.Xaml.Media; | ||
|
|
||
| namespace Windows.UI.Xaml.Media | ||
| { | ||
| /// <summary> | ||
| /// This interface defines common functionality between <see cref="GradientBrush"/> and <see cref="RadialGradientBrush"/> | ||
| /// since, in UWP, <see cref="RadialGradientBrush"/> doesn't derive from <see cref="GradientBrush"/> | ||
| /// </summary> | ||
| internal partial interface IGradientBrush | ||
| { | ||
| } | ||
| } |
There was a problem hiding this comment.
Personally here I would prefer to define a private type _Layer per platform and use it in a single file interface, I find this much more readable / maintainable / converging:
| using Microsoft.UI.Xaml.Media; | |
| namespace Windows.UI.Xaml.Media | |
| { | |
| /// <summary> | |
| /// This interface defines common functionality between <see cref="GradientBrush"/> and <see cref="RadialGradientBrush"/> | |
| /// since, in UWP, <see cref="RadialGradientBrush"/> doesn't derive from <see cref="GradientBrush"/> | |
| /// </summary> | |
| internal partial interface IGradientBrush | |
| { | |
| } | |
| } | |
| #if __IOS__ || __MACOS__ | |
| using _Layer = UIKit.CALayer; | |
| #elif __ANDROID__ | |
| using _Layer = Shader; | |
| #elif __WASM__ | |
| using _Layer = SvgElement; | |
| #endif | |
| using Microsoft.UI.Xaml.Media; | |
| namespace Windows.UI.Xaml.Media | |
| { | |
| /// <summary> | |
| /// This interface defines common functionality between <see cref="GradientBrush"/> and <see cref="RadialGradientBrush"/> | |
| /// since, in UWP, <see cref="RadialGradientBrush"/> doesn't derive from <see cref="GradientBrush"/> | |
| /// </summary> | |
| internal partial interface IGradientBrush | |
| { | |
| _Shader GetShader(Windows.Foundation.Rect destinationRect); | |
| } | |
| } |
Thought @jeromelaban , @carldebilly @davidjohnoliver ?
There was a problem hiding this comment.
@dr1rrb I wanted the method name to match the terminology of each platform (ie, GetShader for Android, GetLayer for iOS & macOS, ToCssString and ToSvgElement on Wasm). But open to change that.
cc @jeromelaban @carldebilly @davidjohnoliver for opinions.
There was a problem hiding this comment.
The principle of unifying the name on all platforms is cool... but since the interface & signatures are different for each, I fail to see the value of such unification.
TBH I have no strong opinion about this.
Co-authored-by: David <[email protected]>
|
@ebariche Can you take a look please? |
|
@ebariche It looks like we have missed this PR for API alignments. |
|
@Youssef1313 it does not look like it's breaking, unless I missed something. Let's retarget it to master and see from there. |
| { | ||
| [ContentProperty(Name = nameof(GradientStops))] | ||
| public sealed partial class RadialGradientBrush : GradientBrush | ||
| public sealed partial class RadialGradientBrush : XamlCompositionBrushBase, IGradientBrush |
There was a problem hiding this comment.
@jeromelaban I think changing the base type here is breaking.
| return AssignAndObserveSolidColorBrush(colorBrush, compositor, brushSetter); | ||
| } | ||
| else if (brush is GradientBrush gradientBrush) | ||
| else if (brush is GradientBrush gradientBrush) // TOOD: RadialGradient |
There was a problem hiding this comment.
I think something is missing here.
There was a problem hiding this comment.
@ebariche Indeed. RadialGradientBrush used to fall into AssignAndObserveGradientBrush. Now it falls under AssignAndObserveXamlCompositionBrush.
I think we need to confirm if this regresses any scenario on Skia, and fix it.
|
Superseded by #12142 |
GitHub Issue (If applicable): Part of #2240
PR Type
What kind of change does this PR introduce?
What is the current behavior?
What is the new behavior?
PR Checklist
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information
Internal Issue (If applicable):