Skip to content
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

1.2.9.4 #133

Merged
merged 7 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ V3 preview: subclassed `SkiaShaderEffect`, implementing `ISkiaGestureProcessor`,

## What's New

### Nuget 1.2.9.2
### Nuget 1.2.9.4
for SkiaSharp 2.88.9-preview.2.2

* Reverted SkiaSharp to 2.88.9-preview.2.2 back from 2.88.9
until [scaling issue](https://github.com/taublast/DrawnUi.Maui/issues/130) is solved for Windows
* Antialiasing [issue](https://github.com/taublast/DrawnUi.Maui/issues/122) solved for SkiaShape
* SkiaImageManager cancelling loads fix
* Fixed native crash when using Super.ReuseBitmaps
* SkiaSvg made more GC-friendly
* Added `WithParent` to FluentExtensions
* Some more
* SkiaShape new Types: Polygon and Line. New property for their Points: Smooth (0-1) to smooth angles.
* Shapes demo page inside SandBox project.
* VisualElement Shadow property now supported everywhere as an optional addition to existing shadows.
* Removed SkiaImage clipping to better support shadows.
* SkiaLabel new property AutoFont: Find and set system font where the first glyph in text is present. Useful for some quick unicode rendering like emoji etc.
* Updated Getsures nuget for correct lock inside MAUI native ScrollView, use Getures="Lock" for Canvas.
* Fixed controls sometimes not invalidated when canvas suface size changes
* Other fixes.

## Development Notes

Expand Down
4 changes: 2 additions & 2 deletions dev/github_uploadnugets.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ REM Define the source directory for the packages
set "source_dir=E:\Nugets"

REM Define the list of file masks for the packages
set "mask[1]=DrawnUi.Maui*.1.2.9.2*.nupkg"
set "mask[2]=AppoMobi.Maui.DrawnUi.1.2.9.2*.*nupkg"
set "mask[1]=DrawnUi.Maui*.1.2.9.4*.nupkg"
set "mask[2]=AppoMobi.Maui.DrawnUi.1.2.9.4*.*nupkg"
set "mask_count=2"

REM Loop through each file mask
Expand Down
4 changes: 2 additions & 2 deletions dev/nuget_uploadnugets.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ REM Define the source directory for the packages
set "source_dir=E:\Nugets"

REM Define the list of file masks for the packages
set "mask[1]=DrawnUi.Maui*.1.2.9.2*.nupkg"
set "mask[2]=AppoMobi.Maui.DrawnUi.1.2.9.2*.*nupkg"
set "mask[1]=DrawnUi.Maui*.1.2.9.4*.nupkg"
set "mask[2]=AppoMobi.Maui.DrawnUi.1.2.9.4*.*nupkg"
set "mask_count=2"

REM Loop through each file mask
Expand Down
2 changes: 1 addition & 1 deletion src/Addons/DrawnUi.Maui.Camera/DrawnUi.Maui.Camera.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

<!--production-->
<ItemGroup Condition="'$(UseNuget)' == 'true'">
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.2" />
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.4" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Addons/DrawnUi.Maui.Game/DrawnUi.Maui.Game.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<!--production-->
<ItemGroup Condition="'$(UseNuget)' == 'true'">
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.2" />
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.4" />
</ItemGroup>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

<!--production-->
<ItemGroup Condition="'$(UseNuget)' == 'true'">
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.2" />
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.4" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Addons/DrawnUi.Maui.Rive/DrawnUi.Maui.Rive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

<!--production-->
<ItemGroup Condition="'$(UseNuget)' == 'true'">
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.2" />
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.4" />
</ItemGroup>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<!--production-->
<ItemGroup Condition="'$(UseNuget)' == 'true'">
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.2" />
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.9.4" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<PropertyGroup Condition="'$(UseSkiaSharp3)' != 'true'">
<PackageReleaseNotes>Using SkiaSharp 2.xx. Checkout the DrawnUi Sandbox project for usage example.</PackageReleaseNotes>
<Version>1.2.9.2</Version>
<Version>1.2.9.4</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(UseSkiaSharp3)' == 'true'">
Expand Down
127 changes: 65 additions & 62 deletions src/Engine/Controls/Carousel/SkiaCarousel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Numerics;
using System.Collections.Concurrent;
using System.Numerics;
using SkiaControl = DrawnUi.Maui.Draw.SkiaControl;

namespace DrawnUi.Maui.Controls;
Expand Down Expand Up @@ -65,7 +66,7 @@ public override void ScrollToNearestAnchor(Vector2 location, Vector2 velocity)

public event EventHandler<Vector2> Stopped;

protected Dictionary<int, bool> ItemsVisibility { get; } = new();
protected ConcurrentDictionary<int, bool> ItemsVisibility { get; } = new();

void SendVisibility(int index, bool state)
{
Expand All @@ -86,6 +87,8 @@ void SendVisibility(int index, bool state)
}
}



void InitializeItemsVisibility(int count, bool force)
{
if (force || ItemsVisibility.Count != count)
Expand Down Expand Up @@ -1355,93 +1358,93 @@ void ResetPan()
{
case TouchActionResult.Down:

// if (!IsUserFocused) //first finger down
if (args.Event.NumberOfTouches == 1) //first finger down
{
ResetPan();
}
// if (!IsUserFocused) //first finger down
if (args.Event.NumberOfTouches == 1) //first finger down
{
ResetPan();
}

consumed = this;
consumed = this;

break;
break;

case TouchActionResult.Panning when args.Event.NumberOfTouches == 1:

if (!IsUserPanning)
{
//first pan
if (args.Event.Distance.Total.X == 0 || Math.Abs(args.Event.Distance.Total.Y) > Math.Abs(args.Event.Distance.Total.X) || Math.Abs(args.Event.Distance.Total.X) < 2)
if (!IsUserPanning)
{
return null;
//first pan
if (args.Event.Distance.Total.X == 0 || Math.Abs(args.Event.Distance.Total.Y) > Math.Abs(args.Event.Distance.Total.X) || Math.Abs(args.Event.Distance.Total.X) < 2)
{
return null;
}
}
}

if (!IsUserFocused)
{
ResetPan();
}
if (!IsUserFocused)
{
ResetPan();
}

//todo add direction
//this.IgnoreWrongDirection
//todo add direction
//this.IgnoreWrongDirection

IsUserPanning = true;
IsUserPanning = true;

var x = _panningOffset.X + args.Event.Distance.Delta.X / RenderingScale;
var y = _panningOffset.Y + args.Event.Distance.Delta.Y / RenderingScale;
var x = _panningOffset.X + args.Event.Distance.Delta.X / RenderingScale;
var y = _panningOffset.Y + args.Event.Distance.Delta.Y / RenderingScale;

Vector2 velocity;
float useVelocity = 0;
if (!IsVertical)
{
useVelocity = (float)(args.Event.Distance.Velocity.X / RenderingScale);
velocity = new(useVelocity, 0);
}
else
{
useVelocity = (float)(args.Event.Distance.Velocity.Y / RenderingScale);
velocity = new(0, useVelocity);
}
Vector2 velocity;
float useVelocity = 0;
if (!IsVertical)
{
useVelocity = (float)(args.Event.Distance.Velocity.X / RenderingScale);
velocity = new(useVelocity, 0);
}
else
{
useVelocity = (float)(args.Event.Distance.Velocity.Y / RenderingScale);
velocity = new(0, useVelocity);
}

//record velocity
VelocityAccumulator.CaptureVelocity(velocity);
//record velocity
VelocityAccumulator.CaptureVelocity(velocity);

//saving non clamped
_panningOffset.X = x;
_panningOffset.Y = y;
//saving non clamped
_panningOffset.X = x;
_panningOffset.Y = y;


var clamped = ClampOffset((float)x, (float)y, Bounces);
var clamped = ClampOffset((float)x, (float)y, Bounces);

//Debug.WriteLine($"[CAROUSEL] Panning: {_panningOffset:0} / {clamped:0}");
ApplyPosition(clamped);
//Debug.WriteLine($"[CAROUSEL] Panning: {_panningOffset:0} / {clamped:0}");
ApplyPosition(clamped);

consumed = this;
break;
consumed = this;
break;

case TouchActionResult.Up:
//Debug.WriteLine($"[Carousel] {args.Type} {IsUserFocused} {IsUserPanning} {InTransition}");
//Debug.WriteLine($"[Carousel] {args.Type} {IsUserFocused} {IsUserPanning} {InTransition}");

if (IsUserFocused)
{

if (IsUserPanning || InTransition)
if (IsUserFocused)
{
consumed = this;

var final = VelocityAccumulator.CalculateFinalVelocity(500);
if (IsUserPanning || InTransition)
{
consumed = this;

//animate
CurrentSnap = CurrentPosition;
var final = VelocityAccumulator.CalculateFinalVelocity(500);

ScrollToNearestAnchor(CurrentSnap, final);
}
//animate
CurrentSnap = CurrentPosition;

IsUserPanning = false;
IsUserFocused = false;
ScrollToNearestAnchor(CurrentSnap, final);
}

}
IsUserPanning = false;
IsUserFocused = false;

}

break;
break;
}

if (consumed != null || IsUserPanning)
Expand All @@ -1456,4 +1459,4 @@ void ResetPan()
}

#endregion
}
}
6 changes: 5 additions & 1 deletion src/Engine/Controls/Slider/SkiaSlider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ protected override void OnLayoutChanged()

public override ISkiaGestureListener ProcessGestures(SkiaGesturesParameters args, GestureEventProcessingInfo apply)
{
//Super.Log($"[Touch] SLIDER got {args.Type}");

bool passedToChildren = false;

ISkiaGestureListener PassToChildren()
Expand Down Expand Up @@ -183,7 +185,7 @@ void ResetPan()
IsUserPanning = true;


//synch this
//synch this
if (touchArea == RangeZone.Start)
lastTouchX = StartThumbX;
else
Expand All @@ -205,6 +207,8 @@ void ResetPan()
{
var maybe = lastTouchX + args.Event.Distance.Delta.X / RenderingScale;
SetEndOffsetClamped(maybe);

//Super.Log($"[Touch] SLIDER zone END {maybe}");
}

RecalculateValues();
Expand Down
54 changes: 54 additions & 0 deletions src/Engine/Draw/Base/SkiaControl.Maui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public partial class SkiaControl : VisualElement,
public static readonly BindableProperty ClearColorProperty = BindableProperty.Create(nameof(ClearColor), typeof(Color), typeof(SkiaControl),
Colors.Transparent,
propertyChanged: NeedDraw);

private SkiaShadow platformShadow;
private SKPath platformClip;

public Color ClearColor
{
get { return (Color)GetValue(ClearColorProperty); }
Expand Down Expand Up @@ -75,6 +79,16 @@ protected override void OnPropertyChanged([CallerMemberName] string propertyName
Update();
}
else
if (propertyName == nameof(Shadow))
{
UpdatePlatformShadow();
}
else
if (propertyName == nameof(Clip))
{
Update();
}
else
if (propertyName.IsEither(
nameof(Padding),
nameof(HorizontalOptions), nameof(VerticalOptions),
Expand Down Expand Up @@ -287,9 +301,49 @@ public static SKImageFilter CreateShadow(SkiaShadow shadow, float scale)
}
}

protected void UpdatePlatformShadow()
{
if (this.Shadow != null && Shadow.Brush != null)
{
PlatformShadow = this.Shadow.FromPlatform();
}
else
{
PlatformShadow = null;
}
}

protected SkiaShadow PlatformShadow
{
get => platformShadow;
set
{
if (platformShadow != value)
{
platformShadow = value;
OnPropertyChanged();
}
}
}

private void GetPlatformClip(SKPath path, SKRect destination, float renderingScale)
{
if (this.Clip != null)
{
this.Clip.FromPlatform(path, destination, renderingScale);
}
}

protected bool HasPlatformClip()
{
return Clip != null;
}

public static float GetDensity()
{
return (float)Super.Screen.Density;
}


}
}
Loading
Loading