Missing maui compliance
This commit is contained in:
@@ -143,12 +143,7 @@ public partial class LayoutHandler : ViewHandler<ILayout, SkiaLayoutView>
|
|||||||
|
|
||||||
if (layout is IPadding paddable)
|
if (layout is IPadding paddable)
|
||||||
{
|
{
|
||||||
var padding = paddable.Padding;
|
handler.PlatformView.Padding = paddable.Padding;
|
||||||
handler.PlatformView.Padding = new SKRect(
|
|
||||||
(float)padding.Left,
|
|
||||||
(float)padding.Top,
|
|
||||||
(float)padding.Right,
|
|
||||||
(float)padding.Bottom);
|
|
||||||
handler.PlatformView.InvalidateMeasure();
|
handler.PlatformView.InvalidateMeasure();
|
||||||
handler.PlatformView.Invalidate();
|
handler.PlatformView.Invalidate();
|
||||||
}
|
}
|
||||||
@@ -262,11 +257,7 @@ public partial class GridHandler : LayoutHandler
|
|||||||
if (VirtualView is IPadding paddable)
|
if (VirtualView is IPadding paddable)
|
||||||
{
|
{
|
||||||
var padding = paddable.Padding;
|
var padding = paddable.Padding;
|
||||||
platformView.Padding = new SKRect(
|
platformView.Padding = padding;
|
||||||
(float)padding.Left,
|
|
||||||
(float)padding.Top,
|
|
||||||
(float)padding.Right,
|
|
||||||
(float)padding.Bottom);
|
|
||||||
Console.WriteLine($"[GridHandler] Applied Padding: L={padding.Left}, T={padding.Top}, R={padding.Right}, B={padding.Bottom}");
|
Console.WriteLine($"[GridHandler] Applied Padding: L={padding.Left}, T={padding.Top}, R={padding.Right}, B={padding.Bottom}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ public static class LinuxProgramHost
|
|||||||
Spacing = 15,
|
Spacing = 15,
|
||||||
BackgroundColor = Color.FromRgb(0xF5, 0xF5, 0xF5)
|
BackgroundColor = Color.FromRgb(0xF5, 0xF5, 0xF5)
|
||||||
};
|
};
|
||||||
root.Padding = new SKRect(20, 20, 20, 20);
|
root.Padding = new Thickness(20, 20, 20, 20);
|
||||||
|
|
||||||
// ========== TITLE ==========
|
// ========== TITLE ==========
|
||||||
root.AddChild(new SkiaLabel
|
root.AddChild(new SkiaLabel
|
||||||
|
|||||||
@@ -66,12 +66,12 @@ public class SkiaCarouselView : SkiaLayoutView
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the peek amount (how much of adjacent items to show).
|
/// Gets or sets the peek amount (how much of adjacent items to show).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float PeekAreaInsets { get; set; } = 0f;
|
public double PeekAreaInsets { get; set; } = 0.0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the spacing between items.
|
/// Gets or sets the spacing between items.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float ItemSpacing { get; set; } = 0f;
|
public double ItemSpacing { get; set; } = 0.0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets whether swipe gestures are enabled.
|
/// Gets or sets whether swipe gestures are enabled.
|
||||||
@@ -204,20 +204,20 @@ public class SkiaCarouselView : SkiaLayoutView
|
|||||||
|
|
||||||
private float GetOffsetForPosition(int position)
|
private float GetOffsetForPosition(int position)
|
||||||
{
|
{
|
||||||
float itemWidth = Bounds.Width - PeekAreaInsets * 2;
|
float itemWidth = Bounds.Width - (float)PeekAreaInsets * 2;
|
||||||
return position * (itemWidth + ItemSpacing);
|
return position * (itemWidth + (float)ItemSpacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetPositionForOffset(float offset)
|
private int GetPositionForOffset(float offset)
|
||||||
{
|
{
|
||||||
float itemWidth = Bounds.Width - PeekAreaInsets * 2;
|
float itemWidth = Bounds.Width - (float)PeekAreaInsets * 2;
|
||||||
if (itemWidth <= 0) return 0;
|
if (itemWidth <= 0) return 0;
|
||||||
return Math.Clamp((int)Math.Round(offset / (itemWidth + ItemSpacing)), 0, Math.Max(0, _items.Count - 1));
|
return Math.Clamp((int)Math.Round(offset / (itemWidth + (float)ItemSpacing)), 0, Math.Max(0, _items.Count - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override SKSize MeasureOverride(SKSize availableSize)
|
protected override SKSize MeasureOverride(SKSize availableSize)
|
||||||
{
|
{
|
||||||
float itemWidth = availableSize.Width - PeekAreaInsets * 2;
|
float itemWidth = availableSize.Width - (float)PeekAreaInsets * 2;
|
||||||
float itemHeight = availableSize.Height - (ShowIndicators ? 30 : 0);
|
float itemHeight = availableSize.Height - (ShowIndicators ? 30 : 0);
|
||||||
|
|
||||||
foreach (var item in _items)
|
foreach (var item in _items)
|
||||||
@@ -230,12 +230,12 @@ public class SkiaCarouselView : SkiaLayoutView
|
|||||||
|
|
||||||
protected override SKRect ArrangeOverride(SKRect bounds)
|
protected override SKRect ArrangeOverride(SKRect bounds)
|
||||||
{
|
{
|
||||||
float itemWidth = bounds.Width - PeekAreaInsets * 2;
|
float itemWidth = bounds.Width - (float)PeekAreaInsets * 2;
|
||||||
float itemHeight = bounds.Height - (ShowIndicators ? 30 : 0);
|
float itemHeight = bounds.Height - (ShowIndicators ? 30 : 0);
|
||||||
|
|
||||||
for (int i = 0; i < _items.Count; i++)
|
for (int i = 0; i < _items.Count; i++)
|
||||||
{
|
{
|
||||||
float x = bounds.Left + PeekAreaInsets + i * (itemWidth + ItemSpacing) - _scrollOffset;
|
float x = bounds.Left + (float)PeekAreaInsets + i * (itemWidth + (float)ItemSpacing) - _scrollOffset;
|
||||||
var itemBounds = new SKRect(x, bounds.Top, x + itemWidth, bounds.Top + itemHeight);
|
var itemBounds = new SKRect(x, bounds.Top, x + itemWidth, bounds.Top + itemHeight);
|
||||||
_items[i].Arrange(itemBounds);
|
_items[i].Arrange(itemBounds);
|
||||||
}
|
}
|
||||||
@@ -271,12 +271,12 @@ public class SkiaCarouselView : SkiaLayoutView
|
|||||||
canvas.ClipRect(bounds);
|
canvas.ClipRect(bounds);
|
||||||
|
|
||||||
// Draw visible items
|
// Draw visible items
|
||||||
float itemWidth = bounds.Width - PeekAreaInsets * 2;
|
float itemWidth = bounds.Width - (float)PeekAreaInsets * 2;
|
||||||
float contentHeight = bounds.Height - (ShowIndicators ? 30 : 0);
|
float contentHeight = bounds.Height - (ShowIndicators ? 30 : 0);
|
||||||
|
|
||||||
for (int i = 0; i < _items.Count; i++)
|
for (int i = 0; i < _items.Count; i++)
|
||||||
{
|
{
|
||||||
float x = bounds.Left + PeekAreaInsets + i * (itemWidth + ItemSpacing) - _scrollOffset;
|
float x = bounds.Left + (float)PeekAreaInsets + i * (itemWidth + (float)ItemSpacing) - _scrollOffset;
|
||||||
|
|
||||||
// Only draw visible items
|
// Only draw visible items
|
||||||
if (x + itemWidth > bounds.Left && x < bounds.Right)
|
if (x + itemWidth > bounds.Left && x < bounds.Right)
|
||||||
@@ -389,7 +389,7 @@ public class SkiaCarouselView : SkiaLayoutView
|
|||||||
_isDragging = false;
|
_isDragging = false;
|
||||||
|
|
||||||
// Determine target position based on velocity and position
|
// Determine target position based on velocity and position
|
||||||
float itemWidth = Bounds.Width - PeekAreaInsets * 2;
|
float itemWidth = Bounds.Width - (float)PeekAreaInsets * 2;
|
||||||
int targetPosition = GetPositionForOffset(_scrollOffset);
|
int targetPosition = GetPositionForOffset(_scrollOffset);
|
||||||
|
|
||||||
// Apply velocity influence
|
// Apply velocity influence
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ public class SkiaCollectionView : SkiaItemsView
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets the SKColor for rendering selection highlight.</summary>
|
/// <summary>Gets the SKColor for rendering selection highlight.</summary>
|
||||||
public SKColor SelectionColorSK => _selectionColorSK;
|
internal SKColor SelectionColorSK => _selectionColorSK;
|
||||||
|
|
||||||
public Color HeaderBackgroundColor
|
public Color HeaderBackgroundColor
|
||||||
{
|
{
|
||||||
@@ -214,7 +214,7 @@ public class SkiaCollectionView : SkiaItemsView
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets the SKColor for rendering header background.</summary>
|
/// <summary>Gets the SKColor for rendering header background.</summary>
|
||||||
public SKColor HeaderBackgroundColorSK => _headerBackgroundColorSK;
|
internal SKColor HeaderBackgroundColorSK => _headerBackgroundColorSK;
|
||||||
|
|
||||||
public Color FooterBackgroundColor
|
public Color FooterBackgroundColor
|
||||||
{
|
{
|
||||||
@@ -223,7 +223,7 @@ public class SkiaCollectionView : SkiaItemsView
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets the SKColor for rendering footer background.</summary>
|
/// <summary>Gets the SKColor for rendering footer background.</summary>
|
||||||
public SKColor FooterBackgroundColorSK => _footerBackgroundColorSK;
|
internal SKColor FooterBackgroundColorSK => _footerBackgroundColorSK;
|
||||||
|
|
||||||
public event EventHandler<CollectionSelectionChangedEventArgs>? SelectionChanged;
|
public event EventHandler<CollectionSelectionChangedEventArgs>? SelectionChanged;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Licensed to the .NET Foundation under one or more agreements.
|
// Licensed to the .NET Foundation under one or more agreements.
|
||||||
// The .NET Foundation licenses this file to you under the MIT license.
|
// The .NET Foundation licenses this file to you under the MIT license.
|
||||||
|
|
||||||
|
using Microsoft.Maui.Graphics;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
|
|
||||||
namespace Microsoft.Maui.Platform;
|
namespace Microsoft.Maui.Platform;
|
||||||
@@ -27,7 +28,7 @@ public class SkiaContentPresenter : SkiaView
|
|||||||
propertyChanged: (b, o, n) => ((SkiaContentPresenter)b).InvalidateMeasure());
|
propertyChanged: (b, o, n) => ((SkiaContentPresenter)b).InvalidateMeasure());
|
||||||
|
|
||||||
public static readonly BindableProperty PaddingProperty =
|
public static readonly BindableProperty PaddingProperty =
|
||||||
BindableProperty.Create(nameof(Padding), typeof(SKRect), typeof(SkiaContentPresenter), SKRect.Empty,
|
BindableProperty.Create(nameof(Padding), typeof(Thickness), typeof(SkiaContentPresenter), default(Thickness),
|
||||||
propertyChanged: (b, o, n) => ((SkiaContentPresenter)b).InvalidateMeasure());
|
propertyChanged: (b, o, n) => ((SkiaContentPresenter)b).InvalidateMeasure());
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -64,9 +65,9 @@ public class SkiaContentPresenter : SkiaView
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the padding around the content.
|
/// Gets or sets the padding around the content.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SKRect Padding
|
public Thickness Padding
|
||||||
{
|
{
|
||||||
get => (SKRect)GetValue(PaddingProperty);
|
get => (Thickness)GetValue(PaddingProperty);
|
||||||
set => SetValue(PaddingProperty, value);
|
set => SetValue(PaddingProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,23 +128,27 @@ public class SkiaContentPresenter : SkiaView
|
|||||||
protected override SKSize MeasureOverride(SKSize availableSize)
|
protected override SKSize MeasureOverride(SKSize availableSize)
|
||||||
{
|
{
|
||||||
var padding = Padding;
|
var padding = Padding;
|
||||||
|
var paddingLeft = (float)padding.Left;
|
||||||
|
var paddingTop = (float)padding.Top;
|
||||||
|
var paddingRight = (float)padding.Right;
|
||||||
|
var paddingBottom = (float)padding.Bottom;
|
||||||
|
|
||||||
if (Content == null)
|
if (Content == null)
|
||||||
return new SKSize(padding.Left + padding.Right, padding.Top + padding.Bottom);
|
return new SKSize(paddingLeft + paddingRight, paddingTop + paddingBottom);
|
||||||
|
|
||||||
// When alignment is not Fill, give content unlimited size in that dimension
|
// When alignment is not Fill, give content unlimited size in that dimension
|
||||||
// so it can measure its natural size without truncation
|
// so it can measure its natural size without truncation
|
||||||
var measureWidth = HorizontalContentAlignment == LayoutAlignment.Fill
|
var measureWidth = HorizontalContentAlignment == LayoutAlignment.Fill
|
||||||
? Math.Max(0, availableSize.Width - padding.Left - padding.Right)
|
? Math.Max(0, availableSize.Width - paddingLeft - paddingRight)
|
||||||
: float.PositiveInfinity;
|
: float.PositiveInfinity;
|
||||||
var measureHeight = VerticalContentAlignment == LayoutAlignment.Fill
|
var measureHeight = VerticalContentAlignment == LayoutAlignment.Fill
|
||||||
? Math.Max(0, availableSize.Height - padding.Top - padding.Bottom)
|
? Math.Max(0, availableSize.Height - paddingTop - paddingBottom)
|
||||||
: float.PositiveInfinity;
|
: float.PositiveInfinity;
|
||||||
|
|
||||||
var contentSize = Content.Measure(new SKSize(measureWidth, measureHeight));
|
var contentSize = Content.Measure(new SKSize(measureWidth, measureHeight));
|
||||||
return new SKSize(
|
return new SKSize(
|
||||||
contentSize.Width + padding.Left + padding.Right,
|
contentSize.Width + paddingLeft + paddingRight,
|
||||||
contentSize.Height + padding.Top + padding.Bottom);
|
contentSize.Height + paddingTop + paddingBottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override SKRect ArrangeOverride(SKRect bounds)
|
protected override SKRect ArrangeOverride(SKRect bounds)
|
||||||
@@ -152,10 +157,10 @@ public class SkiaContentPresenter : SkiaView
|
|||||||
{
|
{
|
||||||
var padding = Padding;
|
var padding = Padding;
|
||||||
var contentBounds = new SKRect(
|
var contentBounds = new SKRect(
|
||||||
bounds.Left + padding.Left,
|
bounds.Left + (float)padding.Left,
|
||||||
bounds.Top + padding.Top,
|
bounds.Top + (float)padding.Top,
|
||||||
bounds.Right - padding.Right,
|
bounds.Right - (float)padding.Right,
|
||||||
bounds.Bottom - padding.Bottom);
|
bounds.Bottom - (float)padding.Bottom);
|
||||||
|
|
||||||
// Apply alignment
|
// Apply alignment
|
||||||
var contentSize = Content.DesiredSize;
|
var contentSize = Content.DesiredSize;
|
||||||
|
|||||||
@@ -94,17 +94,17 @@ public class SkiaIndicatorView : SkiaView
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the indicator size.
|
/// Gets or sets the indicator size.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float IndicatorSize { get; set; } = 10f;
|
public double IndicatorSize { get; set; } = 10.0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the selected indicator size.
|
/// Gets or sets the selected indicator size.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float SelectedIndicatorSize { get; set; } = 10f;
|
public double SelectedIndicatorSize { get; set; } = 10.0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the spacing between indicators.
|
/// Gets or sets the spacing between indicators.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float IndicatorSpacing { get; set; } = 8f;
|
public double IndicatorSpacing { get; set; } = 8.0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the indicator shape.
|
/// Gets or sets the indicator shape.
|
||||||
@@ -133,7 +133,7 @@ public class SkiaIndicatorView : SkiaView
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the border width.
|
/// Gets or sets the border width.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float BorderWidth { get; set; } = 1f;
|
public double BorderWidth { get; set; } = 1.0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the maximum visible indicators.
|
/// Gets or sets the maximum visible indicators.
|
||||||
@@ -153,8 +153,8 @@ public class SkiaIndicatorView : SkiaView
|
|||||||
}
|
}
|
||||||
|
|
||||||
int visibleCount = Math.Min(_count, MaximumVisible);
|
int visibleCount = Math.Min(_count, MaximumVisible);
|
||||||
float totalWidth = visibleCount * IndicatorSize + (visibleCount - 1) * IndicatorSpacing;
|
float totalWidth = visibleCount * (float)IndicatorSize + (visibleCount - 1) * (float)IndicatorSpacing;
|
||||||
float height = Math.Max(IndicatorSize, SelectedIndicatorSize);
|
float height = Math.Max((float)IndicatorSize, (float)SelectedIndicatorSize);
|
||||||
|
|
||||||
return new SKSize(totalWidth, height);
|
return new SKSize(totalWidth, height);
|
||||||
}
|
}
|
||||||
@@ -167,8 +167,8 @@ public class SkiaIndicatorView : SkiaView
|
|||||||
canvas.ClipRect(Bounds);
|
canvas.ClipRect(Bounds);
|
||||||
|
|
||||||
int visibleCount = Math.Min(_count, MaximumVisible);
|
int visibleCount = Math.Min(_count, MaximumVisible);
|
||||||
float totalWidth = visibleCount * IndicatorSize + (visibleCount - 1) * IndicatorSpacing;
|
float totalWidth = visibleCount * (float)IndicatorSize + (visibleCount - 1) * (float)IndicatorSpacing;
|
||||||
float startX = Bounds.MidX - totalWidth / 2 + IndicatorSize / 2;
|
float startX = Bounds.MidX - totalWidth / 2 + (float)IndicatorSize / 2;
|
||||||
float centerY = Bounds.MidY;
|
float centerY = Bounds.MidY;
|
||||||
|
|
||||||
// Determine visible range if count > MaximumVisible
|
// Determine visible range if count > MaximumVisible
|
||||||
@@ -204,18 +204,18 @@ public class SkiaIndicatorView : SkiaView
|
|||||||
{
|
{
|
||||||
Color = _borderColorSK,
|
Color = _borderColorSK,
|
||||||
Style = SKPaintStyle.Stroke,
|
Style = SKPaintStyle.Stroke,
|
||||||
StrokeWidth = BorderWidth,
|
StrokeWidth = (float)BorderWidth,
|
||||||
IsAntialias = true
|
IsAntialias = true
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = startIndex; i < endIndex; i++)
|
for (int i = startIndex; i < endIndex; i++)
|
||||||
{
|
{
|
||||||
int visualIndex = i - startIndex;
|
int visualIndex = i - startIndex;
|
||||||
float x = startX + visualIndex * (IndicatorSize + IndicatorSpacing);
|
float x = startX + visualIndex * ((float)IndicatorSize + (float)IndicatorSpacing);
|
||||||
bool isSelected = i == _position;
|
bool isSelected = i == _position;
|
||||||
|
|
||||||
var paint = isSelected ? selectedPaint : normalPaint;
|
var paint = isSelected ? selectedPaint : normalPaint;
|
||||||
float size = isSelected ? SelectedIndicatorSize : IndicatorSize;
|
float size = isSelected ? (float)SelectedIndicatorSize : (float)IndicatorSize;
|
||||||
|
|
||||||
DrawIndicator(canvas, x, centerY, size, paint, borderPaint);
|
DrawIndicator(canvas, x, centerY, size, paint, borderPaint);
|
||||||
}
|
}
|
||||||
@@ -282,7 +282,7 @@ public class SkiaIndicatorView : SkiaView
|
|||||||
if (_count > 0)
|
if (_count > 0)
|
||||||
{
|
{
|
||||||
int visibleCount = Math.Min(_count, MaximumVisible);
|
int visibleCount = Math.Min(_count, MaximumVisible);
|
||||||
float totalWidth = visibleCount * IndicatorSize + (visibleCount - 1) * IndicatorSpacing;
|
float totalWidth = visibleCount * (float)IndicatorSize + (visibleCount - 1) * (float)IndicatorSpacing;
|
||||||
float startX = Bounds.MidX - totalWidth / 2;
|
float startX = Bounds.MidX - totalWidth / 2;
|
||||||
|
|
||||||
int startIndex = 0;
|
int startIndex = 0;
|
||||||
@@ -298,8 +298,8 @@ public class SkiaIndicatorView : SkiaView
|
|||||||
|
|
||||||
for (int i = 0; i < visibleCount; i++)
|
for (int i = 0; i < visibleCount; i++)
|
||||||
{
|
{
|
||||||
float indicatorX = startX + i * (IndicatorSize + IndicatorSpacing);
|
float indicatorX = startX + i * ((float)IndicatorSize + (float)IndicatorSpacing);
|
||||||
if (x >= indicatorX && x <= indicatorX + IndicatorSize)
|
if (x >= indicatorX && x <= indicatorX + (float)IndicatorSize)
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -315,7 +315,7 @@ public class SkiaIndicatorView : SkiaView
|
|||||||
|
|
||||||
// Calculate which indicator was clicked
|
// Calculate which indicator was clicked
|
||||||
int visibleCount = Math.Min(_count, MaximumVisible);
|
int visibleCount = Math.Min(_count, MaximumVisible);
|
||||||
float totalWidth = visibleCount * IndicatorSize + (visibleCount - 1) * IndicatorSpacing;
|
float totalWidth = visibleCount * (float)IndicatorSize + (visibleCount - 1) * (float)IndicatorSpacing;
|
||||||
float startX = Bounds.MidX - totalWidth / 2;
|
float startX = Bounds.MidX - totalWidth / 2;
|
||||||
|
|
||||||
int startIndex = 0;
|
int startIndex = 0;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Licensed to the .NET Foundation under one or more agreements.
|
// Licensed to the .NET Foundation under one or more agreements.
|
||||||
// The .NET Foundation licenses this file to you under the MIT license.
|
// The .NET Foundation licenses this file to you under the MIT license.
|
||||||
|
|
||||||
|
using Microsoft.Maui.Graphics;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
using Microsoft.Maui;
|
using Microsoft.Maui;
|
||||||
|
|
||||||
@@ -19,9 +20,9 @@ public abstract class SkiaLayoutView : SkiaView
|
|||||||
public static readonly BindableProperty SpacingProperty =
|
public static readonly BindableProperty SpacingProperty =
|
||||||
BindableProperty.Create(
|
BindableProperty.Create(
|
||||||
nameof(Spacing),
|
nameof(Spacing),
|
||||||
typeof(float),
|
typeof(double),
|
||||||
typeof(SkiaLayoutView),
|
typeof(SkiaLayoutView),
|
||||||
0f,
|
0.0,
|
||||||
BindingMode.TwoWay,
|
BindingMode.TwoWay,
|
||||||
propertyChanged: (b, o, n) => ((SkiaLayoutView)b).InvalidateMeasure());
|
propertyChanged: (b, o, n) => ((SkiaLayoutView)b).InvalidateMeasure());
|
||||||
|
|
||||||
@@ -31,9 +32,9 @@ public abstract class SkiaLayoutView : SkiaView
|
|||||||
public static readonly BindableProperty PaddingProperty =
|
public static readonly BindableProperty PaddingProperty =
|
||||||
BindableProperty.Create(
|
BindableProperty.Create(
|
||||||
nameof(Padding),
|
nameof(Padding),
|
||||||
typeof(SKRect),
|
typeof(Thickness),
|
||||||
typeof(SkiaLayoutView),
|
typeof(SkiaLayoutView),
|
||||||
SKRect.Empty,
|
default(Thickness),
|
||||||
BindingMode.TwoWay,
|
BindingMode.TwoWay,
|
||||||
propertyChanged: (b, o, n) => ((SkiaLayoutView)b).InvalidateMeasure());
|
propertyChanged: (b, o, n) => ((SkiaLayoutView)b).InvalidateMeasure());
|
||||||
|
|
||||||
@@ -61,18 +62,18 @@ public abstract class SkiaLayoutView : SkiaView
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Spacing between children.
|
/// Spacing between children.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Spacing
|
public double Spacing
|
||||||
{
|
{
|
||||||
get => (float)GetValue(SpacingProperty);
|
get => (double)GetValue(SpacingProperty);
|
||||||
set => SetValue(SpacingProperty, value);
|
set => SetValue(SpacingProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Padding around the content.
|
/// Padding around the content.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SKRect Padding
|
public Thickness Padding
|
||||||
{
|
{
|
||||||
get => (SKRect)GetValue(PaddingProperty);
|
get => (Thickness)GetValue(PaddingProperty);
|
||||||
set => SetValue(PaddingProperty, value);
|
set => SetValue(PaddingProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,10 +202,10 @@ public abstract class SkiaLayoutView : SkiaView
|
|||||||
protected SKRect GetContentBounds(SKRect bounds)
|
protected SKRect GetContentBounds(SKRect bounds)
|
||||||
{
|
{
|
||||||
return new SKRect(
|
return new SKRect(
|
||||||
bounds.Left + Padding.Left,
|
bounds.Left + (float)Padding.Left,
|
||||||
bounds.Top + Padding.Top,
|
bounds.Top + (float)Padding.Top,
|
||||||
bounds.Right - Padding.Right,
|
bounds.Right - (float)Padding.Right,
|
||||||
bounds.Bottom - Padding.Bottom);
|
bounds.Bottom - (float)Padding.Bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDraw(SKCanvas canvas, SKRect bounds)
|
protected override void OnDraw(SKCanvas canvas, SKRect bounds)
|
||||||
@@ -359,10 +360,10 @@ public class SkiaStackLayout : SkiaLayoutView
|
|||||||
protected override SKSize MeasureOverride(SKSize availableSize)
|
protected override SKSize MeasureOverride(SKSize availableSize)
|
||||||
{
|
{
|
||||||
// Handle NaN/Infinity in padding
|
// Handle NaN/Infinity in padding
|
||||||
var paddingLeft = float.IsNaN(Padding.Left) ? 0 : Padding.Left;
|
var paddingLeft = (float)(double.IsNaN(Padding.Left) ? 0 : Padding.Left);
|
||||||
var paddingRight = float.IsNaN(Padding.Right) ? 0 : Padding.Right;
|
var paddingRight = (float)(double.IsNaN(Padding.Right) ? 0 : Padding.Right);
|
||||||
var paddingTop = float.IsNaN(Padding.Top) ? 0 : Padding.Top;
|
var paddingTop = (float)(double.IsNaN(Padding.Top) ? 0 : Padding.Top);
|
||||||
var paddingBottom = float.IsNaN(Padding.Bottom) ? 0 : Padding.Bottom;
|
var paddingBottom = (float)(double.IsNaN(Padding.Bottom) ? 0 : Padding.Bottom);
|
||||||
|
|
||||||
var contentWidth = availableSize.Width - paddingLeft - paddingRight;
|
var contentWidth = availableSize.Width - paddingLeft - paddingRight;
|
||||||
var contentHeight = availableSize.Height - paddingTop - paddingBottom;
|
var contentHeight = availableSize.Height - paddingTop - paddingBottom;
|
||||||
@@ -402,7 +403,7 @@ public class SkiaStackLayout : SkiaLayoutView
|
|||||||
|
|
||||||
// Add spacing
|
// Add spacing
|
||||||
var visibleCount = Children.Count(c => c.IsVisible);
|
var visibleCount = Children.Count(c => c.IsVisible);
|
||||||
var totalSpacing = Math.Max(0, visibleCount - 1) * Spacing;
|
var totalSpacing = (float)(Math.Max(0, visibleCount - 1) * Spacing);
|
||||||
|
|
||||||
if (Orientation == StackOrientation.Vertical)
|
if (Orientation == StackOrientation.Vertical)
|
||||||
{
|
{
|
||||||
@@ -459,7 +460,7 @@ public class SkiaStackLayout : SkiaLayoutView
|
|||||||
content.Top + offset,
|
content.Top + offset,
|
||||||
content.Left + contentWidth,
|
content.Left + contentWidth,
|
||||||
content.Top + offset + useHeight);
|
content.Top + offset + useHeight);
|
||||||
offset += useHeight + Spacing;
|
offset += useHeight + (float)Spacing;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -499,7 +500,7 @@ public class SkiaStackLayout : SkiaLayoutView
|
|||||||
childTop,
|
childTop,
|
||||||
content.Left + offset + useWidth,
|
content.Left + offset + useWidth,
|
||||||
childBottom);
|
childBottom);
|
||||||
offset += useWidth + Spacing;
|
offset += useWidth + (float)Spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply child's margin
|
// Apply child's margin
|
||||||
@@ -627,8 +628,8 @@ public class SkiaGrid : SkiaLayoutView
|
|||||||
|
|
||||||
protected override SKSize MeasureOverride(SKSize availableSize)
|
protected override SKSize MeasureOverride(SKSize availableSize)
|
||||||
{
|
{
|
||||||
var contentWidth = availableSize.Width - Padding.Left - Padding.Right;
|
var contentWidth = availableSize.Width - (float)Padding.Left - (float)Padding.Right;
|
||||||
var contentHeight = availableSize.Height - Padding.Top - Padding.Bottom;
|
var contentHeight = availableSize.Height - (float)Padding.Top - (float)Padding.Bottom;
|
||||||
|
|
||||||
// Handle NaN/Infinity
|
// Handle NaN/Infinity
|
||||||
if (float.IsNaN(contentWidth) || float.IsInfinity(contentWidth)) contentWidth = 800;
|
if (float.IsNaN(contentWidth) || float.IsInfinity(contentWidth)) contentWidth = 800;
|
||||||
@@ -713,8 +714,8 @@ public class SkiaGrid : SkiaLayoutView
|
|||||||
var totalHeight = _rowHeights.Sum() + Math.Max(0, rowCount - 1) * RowSpacing;
|
var totalHeight = _rowHeights.Sum() + Math.Max(0, rowCount - 1) * RowSpacing;
|
||||||
|
|
||||||
return new SKSize(
|
return new SKSize(
|
||||||
totalWidth + Padding.Left + Padding.Right,
|
totalWidth + (float)Padding.Left + (float)Padding.Right,
|
||||||
totalHeight + Padding.Top + Padding.Bottom);
|
totalHeight + (float)Padding.Top + (float)Padding.Bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetMaxRow()
|
private int GetMaxRow()
|
||||||
@@ -1042,8 +1043,8 @@ public class SkiaAbsoluteLayout : SkiaLayoutView
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new SKSize(
|
return new SKSize(
|
||||||
maxRight + Padding.Left + Padding.Right,
|
maxRight + (float)Padding.Left + (float)Padding.Right,
|
||||||
maxBottom + Padding.Top + Padding.Bottom);
|
maxBottom + (float)Padding.Top + (float)Padding.Bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override SKRect ArrangeOverride(SKRect bounds)
|
protected override SKRect ArrangeOverride(SKRect bounds)
|
||||||
|
|||||||
@@ -235,86 +235,86 @@ public static class SkiaTheme
|
|||||||
#region SKColor Cached Conversions (for rendering performance)
|
#region SKColor Cached Conversions (for rendering performance)
|
||||||
|
|
||||||
// Primary
|
// Primary
|
||||||
public static readonly SKColor PrimarySK = Primary.ToSKColor();
|
internal static readonly SKColor PrimarySK = Primary.ToSKColor();
|
||||||
public static readonly SKColor PrimaryDarkSK = PrimaryDark.ToSKColor();
|
internal static readonly SKColor PrimaryDarkSK = PrimaryDark.ToSKColor();
|
||||||
public static readonly SKColor PrimaryLightSK = PrimaryLight.ToSKColor();
|
internal static readonly SKColor PrimaryLightSK = PrimaryLight.ToSKColor();
|
||||||
public static readonly SKColor PrimarySelectionSK = PrimarySelection.ToSKColor();
|
internal static readonly SKColor PrimarySelectionSK = PrimarySelection.ToSKColor();
|
||||||
public static readonly SKColor PrimaryHalfSK = PrimaryHalf.ToSKColor();
|
internal static readonly SKColor PrimaryHalfSK = PrimaryHalf.ToSKColor();
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
public static readonly SKColor TextPrimarySK = TextPrimary.ToSKColor();
|
internal static readonly SKColor TextPrimarySK = TextPrimary.ToSKColor();
|
||||||
public static readonly SKColor TextSecondarySK = TextSecondary.ToSKColor();
|
internal static readonly SKColor TextSecondarySK = TextSecondary.ToSKColor();
|
||||||
public static readonly SKColor TextTertiarySK = TextTertiary.ToSKColor();
|
internal static readonly SKColor TextTertiarySK = TextTertiary.ToSKColor();
|
||||||
public static readonly SKColor TextDisabledSK = TextDisabled.ToSKColor();
|
internal static readonly SKColor TextDisabledSK = TextDisabled.ToSKColor();
|
||||||
public static readonly SKColor TextPlaceholderSK = TextPlaceholder.ToSKColor();
|
internal static readonly SKColor TextPlaceholderSK = TextPlaceholder.ToSKColor();
|
||||||
public static readonly SKColor TextLinkSK = TextLink.ToSKColor();
|
internal static readonly SKColor TextLinkSK = TextLink.ToSKColor();
|
||||||
public static readonly SKColor TextLinkVisitedSK = TextLinkVisited.ToSKColor();
|
internal static readonly SKColor TextLinkVisitedSK = TextLinkVisited.ToSKColor();
|
||||||
|
|
||||||
// Backgrounds
|
// Backgrounds
|
||||||
public static readonly SKColor BackgroundWhiteSK = SKColors.White;
|
internal static readonly SKColor BackgroundWhiteSK = SKColors.White;
|
||||||
public static readonly SKColor WhiteSemiTransparentSK = WhiteSemiTransparent.ToSKColor();
|
internal static readonly SKColor WhiteSemiTransparentSK = WhiteSemiTransparent.ToSKColor();
|
||||||
public static readonly SKColor BackgroundLightSK = BackgroundLight.ToSKColor();
|
internal static readonly SKColor BackgroundLightSK = BackgroundLight.ToSKColor();
|
||||||
public static readonly SKColor BackgroundLightAltSK = BackgroundLightAlt.ToSKColor();
|
internal static readonly SKColor BackgroundLightAltSK = BackgroundLightAlt.ToSKColor();
|
||||||
public static readonly SKColor BackgroundSurfaceSK = BackgroundSurface.ToSKColor();
|
internal static readonly SKColor BackgroundSurfaceSK = BackgroundSurface.ToSKColor();
|
||||||
public static readonly SKColor BackgroundDisabledSK = BackgroundDisabled.ToSKColor();
|
internal static readonly SKColor BackgroundDisabledSK = BackgroundDisabled.ToSKColor();
|
||||||
|
|
||||||
// Gray scale
|
// Gray scale
|
||||||
public static readonly SKColor Gray50SK = Gray50.ToSKColor();
|
internal static readonly SKColor Gray50SK = Gray50.ToSKColor();
|
||||||
public static readonly SKColor Gray100SK = Gray100.ToSKColor();
|
internal static readonly SKColor Gray100SK = Gray100.ToSKColor();
|
||||||
public static readonly SKColor Gray200SK = Gray200.ToSKColor();
|
internal static readonly SKColor Gray200SK = Gray200.ToSKColor();
|
||||||
public static readonly SKColor Gray300SK = Gray300.ToSKColor();
|
internal static readonly SKColor Gray300SK = Gray300.ToSKColor();
|
||||||
public static readonly SKColor Gray400SK = Gray400.ToSKColor();
|
internal static readonly SKColor Gray400SK = Gray400.ToSKColor();
|
||||||
public static readonly SKColor Gray500SK = Gray500.ToSKColor();
|
internal static readonly SKColor Gray500SK = Gray500.ToSKColor();
|
||||||
public static readonly SKColor Gray600SK = Gray600.ToSKColor();
|
internal static readonly SKColor Gray600SK = Gray600.ToSKColor();
|
||||||
public static readonly SKColor Gray700SK = Gray700.ToSKColor();
|
internal static readonly SKColor Gray700SK = Gray700.ToSKColor();
|
||||||
public static readonly SKColor Gray800SK = Gray800.ToSKColor();
|
internal static readonly SKColor Gray800SK = Gray800.ToSKColor();
|
||||||
public static readonly SKColor Gray900SK = Gray900.ToSKColor();
|
internal static readonly SKColor Gray900SK = Gray900.ToSKColor();
|
||||||
|
|
||||||
// Borders
|
// Borders
|
||||||
public static readonly SKColor BorderLightSK = BorderLight.ToSKColor();
|
internal static readonly SKColor BorderLightSK = BorderLight.ToSKColor();
|
||||||
public static readonly SKColor BorderMediumSK = BorderMedium.ToSKColor();
|
internal static readonly SKColor BorderMediumSK = BorderMedium.ToSKColor();
|
||||||
public static readonly SKColor BorderDarkSK = BorderDark.ToSKColor();
|
internal static readonly SKColor BorderDarkSK = BorderDark.ToSKColor();
|
||||||
|
|
||||||
// Shadows
|
// Shadows
|
||||||
public static readonly SKColor Shadow10SK = Shadow10.ToSKColor();
|
internal static readonly SKColor Shadow10SK = Shadow10.ToSKColor();
|
||||||
public static readonly SKColor Shadow15SK = Shadow15.ToSKColor();
|
internal static readonly SKColor Shadow15SK = Shadow15.ToSKColor();
|
||||||
public static readonly SKColor Shadow20SK = Shadow20.ToSKColor();
|
internal static readonly SKColor Shadow20SK = Shadow20.ToSKColor();
|
||||||
public static readonly SKColor Shadow25SK = Shadow25.ToSKColor();
|
internal static readonly SKColor Shadow25SK = Shadow25.ToSKColor();
|
||||||
public static readonly SKColor Shadow40SK = Shadow40.ToSKColor();
|
internal static readonly SKColor Shadow40SK = Shadow40.ToSKColor();
|
||||||
public static readonly SKColor Shadow50SK = Shadow50.ToSKColor();
|
internal static readonly SKColor Shadow50SK = Shadow50.ToSKColor();
|
||||||
|
|
||||||
// Overlays
|
// Overlays
|
||||||
public static readonly SKColor Overlay40SK = Overlay40.ToSKColor();
|
internal static readonly SKColor Overlay40SK = Overlay40.ToSKColor();
|
||||||
public static readonly SKColor Overlay50SK = Overlay50.ToSKColor();
|
internal static readonly SKColor Overlay50SK = Overlay50.ToSKColor();
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
public static readonly SKColor ErrorSK = Error.ToSKColor();
|
internal static readonly SKColor ErrorSK = Error.ToSKColor();
|
||||||
public static readonly SKColor SuccessSK = Success.ToSKColor();
|
internal static readonly SKColor SuccessSK = Success.ToSKColor();
|
||||||
public static readonly SKColor WarningSK = Warning.ToSKColor();
|
internal static readonly SKColor WarningSK = Warning.ToSKColor();
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
public static readonly SKColor ButtonCancelSK = ButtonCancel.ToSKColor();
|
internal static readonly SKColor ButtonCancelSK = ButtonCancel.ToSKColor();
|
||||||
public static readonly SKColor ButtonCancelHoverSK = ButtonCancelHover.ToSKColor();
|
internal static readonly SKColor ButtonCancelHoverSK = ButtonCancelHover.ToSKColor();
|
||||||
|
|
||||||
// Scrollbars
|
// Scrollbars
|
||||||
public static readonly SKColor ScrollbarThumbSK = ScrollbarThumb.ToSKColor();
|
internal static readonly SKColor ScrollbarThumbSK = ScrollbarThumb.ToSKColor();
|
||||||
public static readonly SKColor ScrollbarTrackSK = ScrollbarTrack.ToSKColor();
|
internal static readonly SKColor ScrollbarTrackSK = ScrollbarTrack.ToSKColor();
|
||||||
|
|
||||||
// Indicators
|
// Indicators
|
||||||
public static readonly SKColor IndicatorUnselectedSK = IndicatorUnselected.ToSKColor();
|
internal static readonly SKColor IndicatorUnselectedSK = IndicatorUnselected.ToSKColor();
|
||||||
public static readonly SKColor IndicatorSelectedSK = IndicatorSelected.ToSKColor();
|
internal static readonly SKColor IndicatorSelectedSK = IndicatorSelected.ToSKColor();
|
||||||
|
|
||||||
// Menu
|
// Menu
|
||||||
public static readonly SKColor MenuBackgroundSK = MenuBackground.ToSKColor();
|
internal static readonly SKColor MenuBackgroundSK = MenuBackground.ToSKColor();
|
||||||
public static readonly SKColor MenuHoverSK = MenuHover.ToSKColor();
|
internal static readonly SKColor MenuHoverSK = MenuHover.ToSKColor();
|
||||||
public static readonly SKColor MenuActiveSK = MenuActive.ToSKColor();
|
internal static readonly SKColor MenuActiveSK = MenuActive.ToSKColor();
|
||||||
public static readonly SKColor MenuSeparatorSK = MenuSeparator.ToSKColor();
|
internal static readonly SKColor MenuSeparatorSK = MenuSeparator.ToSKColor();
|
||||||
|
|
||||||
// Dark theme
|
// Dark theme
|
||||||
public static readonly SKColor DarkBackgroundSK = DarkBackground.ToSKColor();
|
internal static readonly SKColor DarkBackgroundSK = DarkBackground.ToSKColor();
|
||||||
public static readonly SKColor DarkSurfaceSK = DarkSurface.ToSKColor();
|
internal static readonly SKColor DarkSurfaceSK = DarkSurface.ToSKColor();
|
||||||
public static readonly SKColor DarkTextSK = DarkText.ToSKColor();
|
internal static readonly SKColor DarkTextSK = DarkText.ToSKColor();
|
||||||
public static readonly SKColor DarkHoverSK = DarkHover.ToSKColor();
|
internal static readonly SKColor DarkHoverSK = DarkHover.ToSKColor();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user