-
Notifications
You must be signed in to change notification settings - Fork 760
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Use fallback color for unsupported brushes
(cherry picked from commit a6f162a) # Conflicts: # src/Uno.UI/UI/Xaml/Media/RevealBrush.cs
- Loading branch information
1 parent
5bf4c2c
commit 67657f1
Showing
8 changed files
with
100 additions
and
57 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Android.Graphics; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Media; | ||
using Rect = Windows.Foundation.Rect; | ||
|
||
namespace Microsoft.UI.Xaml.Media; | ||
|
||
public partial class RevealBrush : XamlCompositionBrushBase | ||
{ | ||
protected override Paint GetPaintInner(Rect destinationRect) | ||
{ | ||
var color = this.IsDependencyPropertySet(FallbackColorProperty) ? | ||
GetColorWithOpacity(FallbackColor) : | ||
GetColorWithOpacity(Color); | ||
return new Paint() { Color = color, AntiAlias = true }; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,9 @@ | ||
| ||
namespace Windows.UI.Xaml.Media | ||
namespace Windows.UI.Xaml.Media; | ||
|
||
public partial class RevealBackgroundBrush : RevealBrush | ||
{ | ||
public partial class RevealBackgroundBrush : RevealBrush | ||
public RevealBackgroundBrush() | ||
{ | ||
public RevealBackgroundBrush() | ||
{ | ||
|
||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,8 @@ | ||
| ||
namespace Windows.UI.Xaml.Media | ||
namespace Windows.UI.Xaml.Media; | ||
|
||
public partial class RevealBorderBrush : RevealBrush | ||
{ | ||
public partial class RevealBorderBrush : RevealBrush | ||
public RevealBorderBrush() | ||
{ | ||
public RevealBorderBrush() | ||
{ | ||
|
||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,16 +1,15 @@ | ||
using Android.Graphics; | ||
using Rect = Windows.Foundation.Rect; | ||
|
||
namespace Windows.UI.Xaml.Media | ||
namespace Windows.UI.Xaml.Media; | ||
|
||
partial class RevealBrush | ||
{ | ||
public partial class RevealBrush : XamlCompositionBrushBase | ||
protected override Paint GetPaintInner(Rect destinationRect) | ||
{ | ||
protected override Paint GetPaintInner(Rect destinationRect) | ||
{ | ||
var color = this.IsDependencyPropertySet(FallbackColorProperty) ? | ||
GetColorWithOpacity(FallbackColor) : | ||
GetColorWithOpacity(Color); | ||
return new Paint() { Color = color, AntiAlias = true }; | ||
} | ||
var color = this.IsDependencyPropertySet(FallbackColorProperty) ? | ||
GetColorWithOpacity(FallbackColor) : | ||
GetColorWithOpacity(Color); | ||
return new Paint() { Color = color, AntiAlias = true }; | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
src/Uno.UI/UI/Xaml/Media/XamlCompositionBrushBase.Android.cs
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,14 @@ | ||
using Android.Graphics; | ||
using Rect = Windows.Foundation.Rect; | ||
|
||
namespace Windows.UI.Xaml.Media; | ||
|
||
public partial class XamlCompositionBrushBase : Brush | ||
{ | ||
protected override Paint GetPaintInner(Rect destinationRect) | ||
{ | ||
// By default fallback to FallbackColor, unless overridden by a derived class. | ||
var color = GetColorWithOpacity(FallbackColor); | ||
return new Paint() { Color = color, AntiAlias = true }; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,42 +1,39 @@ | ||
using Color = Windows.UI.Color; | ||
namespace Windows.UI.Xaml.Media; | ||
|
||
namespace Windows.UI.Xaml.Media | ||
public partial class XamlCompositionBrushBase : Brush | ||
{ | ||
public partial class XamlCompositionBrushBase : Brush | ||
protected XamlCompositionBrushBase() : base() | ||
{ | ||
protected XamlCompositionBrushBase() : base() | ||
} | ||
|
||
public Color FallbackColor | ||
{ | ||
get | ||
{ | ||
return (Color)this.GetValue(FallbackColorProperty); | ||
} | ||
|
||
public Color FallbackColor | ||
set | ||
{ | ||
get | ||
{ | ||
return (Color)this.GetValue(FallbackColorProperty); | ||
} | ||
set | ||
{ | ||
this.SetValue(FallbackColorProperty, value); | ||
} | ||
this.SetValue(FallbackColorProperty, value); | ||
} | ||
} | ||
|
||
public static DependencyProperty FallbackColorProperty { get; } = | ||
DependencyProperty.Register( | ||
nameof(FallbackColor), typeof(Color), | ||
typeof(XamlCompositionBrushBase), | ||
new FrameworkPropertyMetadata(default(Color))); | ||
public static DependencyProperty FallbackColorProperty { get; } = | ||
DependencyProperty.Register( | ||
nameof(FallbackColor), typeof(Color), | ||
typeof(XamlCompositionBrushBase), | ||
new FrameworkPropertyMetadata(default(Color))); | ||
|
||
/// <summary> | ||
/// Returns the fallback color mixed with opacity value. | ||
/// </summary> | ||
internal Color FallbackColorWithOpacity => FallbackColor.WithOpacity(Opacity); | ||
/// <summary> | ||
/// Returns the fallback color mixed with opacity value. | ||
/// </summary> | ||
internal Color FallbackColorWithOpacity => FallbackColor.WithOpacity(Opacity); | ||
|
||
protected virtual void OnConnected() | ||
{ | ||
} | ||
protected virtual void OnConnected() | ||
{ | ||
} | ||
|
||
protected virtual void OnDisconnected() | ||
{ | ||
} | ||
protected virtual void OnDisconnected() | ||
{ | ||
} | ||
} |