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.3.6 #83

Merged
merged 5 commits into from
Jul 14, 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
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ https://github.com/taublast/DrawnUi.Maui/assets/25801194/3b360229-ce3b-4d33-a85b

## What's new

* `SkiaScroll` fixed scrolling vertically + horizontally at the same time (`Orientation="Both"`).
* `SkiaShell` Navigated and Navigating events now report popups too.
* `SkiaMediaImage` a subclassed `SkiaImage` for displaying any kind of images (image/animated gif/more..)
* `SkiaGif` a dedicated lightweight GIF-player with playback control properties. See Sandbox project.
* Fixed gestures inside `ImageCacheComposite` cache.
* Fixed bug `SkiaShell` navigation gets locked when spamming popups.
* Layout optimizations.
* Nuget 1.2.3.4
* Breaking ``ISkiaCell`` changed, check out demo app FestCellWithBanner new usage.
* Android loop changed along with its OpenGL renderer.
* Gestures fix: will not trigger Tapped after raised Longpressing.
* Other fixes.
* Nuget 1.2.3.6

## Demo Apps

Expand Down Expand Up @@ -595,6 +592,15 @@ It will render a mask over its children when hovered, think of it as an inverted

## Previously

* `SkiaScroll` fixed scrolling vertically + horizontally at the same time (`Orientation="Both"`).
* `SkiaShell` Navigated and Navigating events now report popups too.
* `SkiaMediaImage` a subclassed `SkiaImage` for displaying any kind of images (image/animated gif/more..)
* `SkiaGif` a dedicated lightweight GIF-player with playback control properties. See Sandbox project.
* Fixed gestures inside `ImageCacheComposite` cache.
* Fixed bug `SkiaShell` navigation gets locked when spamming popups.
* Layout optimizations.
* Nuget 1.2.3.4
*
* `SkiaLayout` Column/Row uses 2 layout passes when needed, can now use full alignment options inside.
* Critical fixes for Release builds.

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 @@ -43,7 +43,7 @@

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

</Project>
4 changes: 4 additions & 0 deletions src/Addons/DrawnUi.Maui.Camera/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

Only Android is actually implemented.

When i have spare time, hopefully soon..
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.3.4" />
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.3.6" />
</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.3.4" />
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.3.6" />
</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.3.4" />
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.3.6" />
</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.3.4" />
<PackageReference Include="AppoMobi.Maui.DrawnUi" Version="1.2.3.6" />
</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.3.4</Version>
<Version>1.2.3.6</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(UseSkiaSharp3)' == 'true'">
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Controls/Button/SkiaButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected override void CreateDefaultContent()
/// Clip effects with rounded rect of the frame inside
/// </summary>
/// <returns></returns>
public override SKPath CreateClip(object arguments, bool usePosition)
public override SKPath CreateClip(object arguments, bool usePosition, SKPath path = null)
{
if (MainFrame != null)
{
Expand Down
16 changes: 12 additions & 4 deletions src/Engine/Controls/Layouts/SkiaDecoratedGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,28 @@ protected override void OnLayoutChanged()
base.OnLayoutChanged();

UpdateLines();
}

protected override void PostArrange(SKRect destination, float widthRequest, float heightRequest, float scale)
{
base.PostArrange(destination, widthRequest, heightRequest, scale);

if (ContainerLines == null)
{
CreateLines();
}
}

protected override void Draw(SkiaDrawingContext context, SKRect destination, float scale)
{
base.Draw(context, destination, scale);

//if (ContainerLines == null)
//{
// CreateLines();
//}


if (ContainerLines != null)
{
ContainerLines.Render(context, GetDrawingRectForChildren(Destination, scale), scale);
}

FinalizeDrawingWithRenderObject(context, scale);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Controls/Pickers/ScrollPickerWheel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ protected override bool DrawChild(SkiaDrawingContext context, SKRect dest, ISkia

var ret = base.DrawChild(context, dest, child, scale);

context.Canvas.Restore();
context.Canvas.RestoreToCount(saved);

return true;
}
Expand Down
14 changes: 13 additions & 1 deletion src/Engine/Controls/PlayFrames/AnimatedFramesRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,15 @@ public void InitializeAnimator()

OnAnimatorInitializing();

if (AutoPlay && CheckCanStartAnimator())
if (_delayedPlay || AutoPlay && CheckCanStartAnimator())
{
_delayedPlay = false;
Start();
}
}

bool _delayedPlay;

protected virtual void OnAnimatorInitializing()
{ }

Expand Down Expand Up @@ -161,6 +166,13 @@ public void Seek(double frame)

public virtual void Start(int delayMs = 0)
{

if (Animator == null)
{
_delayedPlay = true;
return;
}

if (Animator.IsRunning)
{
Animator.Stop();
Expand Down
4 changes: 2 additions & 2 deletions src/Engine/Controls/Shapes/SkiaHoverMask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected override void Paint(SkiaDrawingContext ctx, SKRect destination, float
using var clipContent = CreateClip(arguments, true);
clipInsideParent.AddPath(clipContent);

ctx.Canvas.ClipPath(clipInsideParent, SKClipOperation.Difference, true);
ClipSmart(ctx.Canvas, clipInsideParent, SKClipOperation.Difference);

//paint this taking viewport dimensions
ctx.Canvas.DrawRect(Parent.DrawingRect, paint);
Expand All @@ -35,7 +35,7 @@ protected override void Paint(SkiaDrawingContext ctx, SKRect destination, float

//todo add stroke property?

ctx.Canvas.Restore();
ctx.Canvas.RestoreToCount(saved);
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/Engine/Draw/Layout/SkiaLayout.ViewsAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ public void MarkViewAsHidden(int index)
{
if (_dicoCellsInUse.TryGetValue(index, out SkiaControl hiddenView))
{
if (hiddenView is ISkiaCell notify)
{
notify.OnDisappeared();
}
//if (hiddenView is ISkiaCell notify)
//{
// notify.OnDisappeared();
//}

_dicoCellsInUse.Remove(index);
ReleaseView(hiddenView);
Expand Down Expand Up @@ -248,10 +248,10 @@ public SkiaControl GetChildAt(int index, SkiaControl template = null)

//Debug.WriteLine($"[InUse] {_dicoCellsInUse.Keys.Select(k => k.ToString()).Aggregate((current, next) => $"{current},{next}")}");

if (view is ISkiaCell notify)
{
notify.OnAppearing();
}
//if (view is ISkiaCell notify)
//{
// notify.OnAppearing();
//}
}

return view;
Expand Down
8 changes: 4 additions & 4 deletions src/Engine/Draw/Layout/SkiaLayout.Wrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ protected virtual int DrawStack(

//PASS 1 - VISIBILITY
//we need this pass before drawing to recycle views that became hidden
var viewsTotal = 0;
var currentIndex = -1;
foreach (var cell in structure.GetChildrenAsSpans())
{
viewsTotal++;
viewsTotal++;
if (cell.Destination == SKRect.Empty)
currentIndex++;

if (cell.Destination == SKRect.Empty || cell.Measured.Pixels.IsEmpty)
{
cell.IsVisible = false;
}
Expand Down
34 changes: 11 additions & 23 deletions src/Engine/Draw/Layout/SkiaLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,10 @@ protected override void Paint(SkiaDrawingContext ctx, SKRect destination, float
{
SetupRenderingWithComposition(ctx, destination);
}
else
{
DirtyChildren.Clear();
}

base.Paint(ctx, destination, scale, arguments);

Expand All @@ -993,16 +997,10 @@ protected override void Paint(SkiaDrawingContext ctx, SKRect destination, float
drawnChildrenCount = DrawViews(ctx, rectForChildren, scale);
}
else
//grid
if (Type == LayoutType.Grid) //todo add optimization for OptimizeRenderingViewport
{
drawnChildrenCount = DrawChildrenGrid(ctx, rectForChildren, scale);
}
//else
//if (Type == LayoutType.Row || Type == LayoutType.Column)
//{
// drawnChildrenCount = DrawChildrenStack(ctx, rectForChildren, scale);
//}
else
//stacklayout
if (IsStack)
Expand Down Expand Up @@ -1288,23 +1286,14 @@ private static void ItemsSourcePropertyChanged(BindableObject bindable, object o

}

//if (newvalue is IList newList)
//{
// foreach (var context in newList)
// {
// //todo
// }
//}

if (newvalue is INotifyCollectionChanged newCollection)
{
newCollection.CollectionChanged -= skiaControl.ItemsSourceCollectionChanged;
newCollection.CollectionChanged += skiaControl.ItemsSourceCollectionChanged;
}

skiaControl.PostponeInvalidation(nameof(OnItemSourceChanged), skiaControl.OnItemSourceChanged);

//skiaControl.OnItemSourceChanged();
skiaControl.OnItemSourceChanged();
}

private static void NeedUpdateItemsSource(BindableObject bindable, object oldvalue, object newvalue)
Expand All @@ -1313,8 +1302,8 @@ private static void NeedUpdateItemsSource(BindableObject bindable, object oldval

skiaControl.PostponeInvalidation(nameof(UpdateItemsSource), skiaControl.UpdateItemsSource);

//skiaControl.OnItemSourceChanged();
//skiaControl.Invalidate();
skiaControl.Update();

}

void UpdateItemsSource()
Expand All @@ -1326,8 +1315,8 @@ void UpdateItemsSource()

public override void OnItemTemplateChanged()
{
PostponeInvalidation(nameof(OnItemSourceChanged), OnItemSourceChanged);
//OnItemSourceChanged();
//PostponeInvalidation(nameof(OnItemSourceChanged), OnItemSourceChanged);
OnItemSourceChanged();
}

public bool ApplyNewItemsSource { get; set; }
Expand Down Expand Up @@ -1516,9 +1505,8 @@ protected virtual void ItemsSourceCollectionChanged(object sender, NotifyCollect
GetTemplatesPoolLimit(),
GetTemplatesPoolPrefill());

// Invalidate();

// return;
Invalidate();
return;
}

break;
Expand Down
2 changes: 2 additions & 0 deletions src/Engine/Draw/Scroll/SkiaScroll.Scrolling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ void BounceX(float offsetFrom, float offsetTo, float velocity)
if (displacement != 0)
{
var spring = new Spring((float)(1 * (1 + RubberDamping)), 200, (float)(0.5f * (1 + RubberDamping)));
_animatorFlingX.Stop();
_vectorAnimatorBounceX.Initialize(offsetTo, displacement, velocity, spring);
_vectorAnimatorBounceX.Start();
}
Expand All @@ -505,6 +506,7 @@ void BounceY(float offsetFrom, float offsetTo, float velocity)

if (displacement != 0)
{
_animatorFlingY.Stop();
var spring = new Spring((float)(1 * (1 + RubberDamping)), 200, (float)(0.5f * (1 + RubberDamping)));
_vectorAnimatorBounceY.Initialize(offsetTo, displacement, velocity, spring);
_vectorAnimatorBounceY.Start();
Expand Down
9 changes: 7 additions & 2 deletions src/Engine/Draw/Scroll/SkiaScroll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -914,12 +914,14 @@ ISkiaGestureListener PassToChildren()
if (Math.Abs(velocityX) > _minVelocity && !bounceX)
{
IsUserFocused = false;
_vectorAnimatorBounceX.Stop();
fling = StartToFlingFrom(_animatorFlingX, ViewportOffsetX, velocityX);
}

if (Math.Abs(velocityY) > _minVelocity && !bounceY)
{
IsUserFocused = false;
_vectorAnimatorBounceY.Stop();
fling = StartToFlingFrom(_animatorFlingY, ViewportOffsetY, velocityY);
}
}
Expand Down Expand Up @@ -2615,17 +2617,20 @@ protected override void Draw(SkiaDrawingContext context, SKRect destination,
var posX = (float)Math.Round(ViewportOffsetX * _zoomedScale);
var posY = (float)Math.Round(ViewportOffsetY * _zoomedScale);

//var posX = (float)(ViewportOffsetX * _zoomedScale);
//var posY = (float)(ViewportOffsetY * _zoomedScale);

var needReposition =
_updatedViewportForPixY != posY
|| _updatedViewportForPixX != posX
|| _destination != Destination;
|| _destination != destination;

//reposition viewport (scroll)
if (needReposition)
{
_updatedViewportForPixX = posX;
_updatedViewportForPixY = posY;
_destination = Destination;
_destination = destination;

PositionViewport(DrawingRect, new(posX, posY), _zoomedScale, (float)scale);

Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Draw/Scroll/SkiaScrollLooped.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ protected override void OnDrawn(SkiaDrawingContext context,

DrawViews(context, childRect, zoomedScale, debug);

context.Canvas.Restore();
context.Canvas.RestoreToCount(count);
}
else
{
Expand Down
Loading
Loading