Skip to content

Commit

Permalink
v3 shaders progress
Browse files Browse the repository at this point in the history
  • Loading branch information
taublast committed Oct 19, 2024
1 parent 8da1299 commit 665f529
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<UseSkiaSharp3>false</UseSkiaSharp3>
<UseSkiaSharp3>true</UseSkiaSharp3>
</PropertyGroup>

<PropertyGroup Condition="'$(UseSkiaSharp3)' != 'true'">
Expand Down
2 changes: 1 addition & 1 deletion src/samples/Sandbox/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ShellContent
Title="Drawn UI"
ContentTemplate="{DataTemplate mauiNet8:MainPage}"
ContentTemplate="{DataTemplate mauiNet8:MainPageDev}"
Route="MainPage" />

</Shell>
78 changes: 74 additions & 4 deletions src/samples/Sandbox/MainPageDev.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:Sandbox.Views.Controls"
xmlns:draw="http://schemas.appomobi.com/drawnUi/2023/draw"
xmlns:mauiNet8="clr-namespace:MauiNet8"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
xmlns:views="clr-namespace:Sandbox.Views"
x:Name="ThisPage"
x:DataType="mauiNet8:MainPageDev"
BackgroundColor="Black">

<draw:Canvas
Expand All @@ -17,6 +19,35 @@
Tag="MainPage"
VerticalOptions="Fill">

<draw:Canvas.Resources>
<ResourceDictionary>

<Style
x:Key="SkiaStyleControlInTable"
TargetType="draw:SkiaControl">
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="AddMarginLeft" Value="120" />
</Style>

<Style
x:Key="SkiaStyleControLabel"
TargetType="draw:SkiaLabel">
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="TextColor" Value="Black" />
</Style>

<Style
x:Key="SkiaStyleControlContainer"
TargetType="draw:SkiaLayout">
<Setter Property="Padding" Value="8,2" />
<Setter Property="HeightRequest" Value="44" />
<Setter Property="HorizontalOptions" Value="Fill" />
<Setter Property="UseCache" Value="Image" />
</Style>

</ResourceDictionary>
</draw:Canvas.Resources>

<draw:SkiaLayout
HorizontalOptions="Fill"
Tag="Wrapper"
Expand All @@ -32,16 +63,16 @@
VerticalOptions="Fill">

<draw:SkiaLayout
BackgroundColor="Blue"
BackgroundColor="Gainsboro"
HorizontalOptions="Fill"
Spacing="0"
Tag="Content"
Type="Column">
Type="Column"
UseCache="None">

<!-- -->
<controls:AnimatedCarousel
x:Name="MainCarousel"
AnimatorSpeedMs="1750"
BackgroundColor="DarkOliveGreen"
HeightRequest="300"
HorizontalOptions="Fill"
Expand Down Expand Up @@ -103,6 +134,45 @@
TextColor="White"
VerticalTextAlignment="Center" />



<!-- Select -->
<draw:SkiaLayout Style="{x:StaticResource SkiaStyleControlContainer}">
<draw:SkiaLabel
HorizontalOptions="Fill"
Style="{x:StaticResource SkiaStyleControLabel}"
Text="Transition" />

</draw:SkiaLayout>

<!-- Speed -->
<draw:SkiaLayout Style="{x:StaticResource SkiaStyleControlContainer}">
<draw:SkiaLabel
HorizontalOptions="Fill"
Style="{x:StaticResource SkiaStyleControLabel}"
Text="Speed" />
<controls:DrawnSlider
End="{Binding SpeedMs, Mode=TwoWay}"
HorizontalOptions="Fill"
Max="3000"
Min="1750"
MinMaxStringFormat="P0"
Step="1.0"
Style="{x:StaticResource SkiaStyleControlInTable}" />
</draw:SkiaLayout>

<!-- Switch -->
<draw:SkiaLayout Style="{x:StaticResource SkiaStyleControlContainer}">
<draw:SkiaLabel
HorizontalOptions="Fill"
Style="{x:StaticResource SkiaStyleControLabel}"
Text="Auto-Play" />
<controls:DrawnSwitch
IsToggled="{Binding AutoPlay, Mode=TwoWay}"
Style="{x:StaticResource SkiaStyleControlInTable}"
TranslationX="-4" />
</draw:SkiaLayout>

<!--<draw:SkiaLabel
BackgroundColor="Green"
FontAttributes="Bold"
Expand Down Expand Up @@ -131,7 +201,7 @@

</draw:SkiaLayout>

<controls:ButtonToRoot />
<!--<controls:ButtonToRoot />-->

<draw:SkiaLabelFps
Margin="0,0,4,24"
Expand Down
51 changes: 46 additions & 5 deletions src/samples/Sandbox/MainPageDev.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
using DrawnUi.Maui.Infrastructure;
using DrawnUi.Maui.Internals;
using Sandbox;
using Sandbox.Resources.Strings;
using Sandbox.Views;
using Sandbox.Views.Xaml2Pdf;
using System.Diagnostics;
using System.Text;



Expand All @@ -33,7 +29,7 @@ public MainPageDev()

_shaders = Files.ListAssets(path);


BindingContext = this;
}
catch (Exception e)
{
Expand Down Expand Up @@ -67,6 +63,51 @@ void Test()
//var effect = SkSl.Compile(shaderCode);
}

private double _SpeedMs = 1750;
public double SpeedMs
{
get
{
return _SpeedMs;
}
set
{
if (_SpeedMs != value)
{
_SpeedMs = value;
OnPropertyChanged();
MainCarousel.LinearSpeedMs = SpeedMs;
}
}
}


private bool _AutoPlay;
public bool AutoPlay
{
get
{
return _AutoPlay;
}
set
{
if (_AutoPlay != value)
{
_AutoPlay = value;
OnPropertyChanged();
if (value)
{
MainCarousel.AnimatorSpeedMs = SpeedMs;
}
else
{
MainCarousel.AnimatorSpeedMs = 0;
}
}
}
}


async void SelectFIle()
{
if (_shaders.Count > 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Diagnostics;
using System.Numerics;

namespace Sandbox.Views.Controls;
Expand All @@ -12,7 +11,8 @@ public CarouselWithTransitions()
{
Effect = new()
{
ShaderSource = ShaderFilename
ShaderSource = ShaderFilename,
ShaderTemplate = @"Shaders\transitions\_template.sksl"
};
}

Expand Down Expand Up @@ -54,6 +54,8 @@ protected virtual void OnFromToChanged()

}



protected override void OnScrollProgressChanged()
{
if (ScrollProgress >= 0 && ScrollProgress <= 1) //ignore bouncing
Expand Down

0 comments on commit 665f529

Please sign in to comment.