Skip to content

Commit

Permalink
feat(background_sizing): Added support of BackgroundSizing on Wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
carldebilly committed Aug 25, 2021
1 parent 7a9b306 commit 8afd0c8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
using Uno.Disposables;
using Uno.Extensions;
Expand All @@ -18,6 +19,7 @@ internal class BorderLayerRenderer
public void UpdateLayer(
UIElement element,
Brush background,
BackgroundSizing backgroundSizing,
Thickness borderThickness,
Brush borderBrush,
CornerRadius cornerRadius,
Expand Down
4 changes: 4 additions & 0 deletions src/Uno.UI/UI/Xaml/FrameworkElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ internal BackgroundSizing BackgroundSizing

private protected virtual void OnBackgroundSizingChanged(DependencyPropertyChangedEventArgs e)
{
OnBackgroundSizingChangedPartial(e);
}

partial void OnBackgroundSizingChangedPartial(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs);

#endregion


Expand Down
8 changes: 8 additions & 0 deletions src/Uno.UI/UI/Xaml/FrameworkElement.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,14 @@ protected void SetCornerRadius(CornerRadius cornerRadius)
protected void SetBorder(Thickness thickness, Brush brush)
=> BorderLayerRenderer.SetBorder(this, thickness, brush);

partial void OnBackgroundSizingChangedPartial(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
{
if (dependencyPropertyChangedEventArgs.NewValue is BackgroundSizing sizing)
{
SetStyle("background-clip", sizing == BackgroundSizing.InnerBorderEdge ? "padding-box" : "border-box");
}
}

internal override bool IsEnabledOverride() => IsEnabled && base.IsEnabledOverride();

#region Margin Dependency Property
Expand Down
5 changes: 5 additions & 0 deletions src/Uno.UI/WasmCSS/Uno.UI.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ body {
See WindowManager.ts on measureViewInternal() for more details.
*/
transform: translate(0, 0);

/*
By default, the background of UWP controls is not drawn under the border of the control.
*/
background-clip: padding-box;
}

.uno-uielement .noclip {
Expand Down

0 comments on commit 8afd0c8

Please sign in to comment.