Merge pull request #36 from jsuarezruiz/implement-opacity
Implement Opacity property
This commit is contained in:
Коммит
c0529c5404
|
@ -56,13 +56,4 @@
|
|||
<ProjectReference Include="..\AlohaKit.UI\AlohaKit.UI.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<MauiXaml Update="Views\MainPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</MauiXaml>
|
||||
<MauiXaml Update="Views\XAML\MainPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</MauiXaml>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
WidthRequest="50" HeightRequest="50"
|
||||
X="30" Y="30"
|
||||
ScaleX="0.5" ScaleY="0.5"
|
||||
Opacity="0.25"
|
||||
Fill="Green" />
|
||||
<alohakit:RoundRectangle
|
||||
WidthRequest="50" HeightRequest="50"
|
||||
|
|
|
@ -39,9 +39,12 @@
|
|||
public virtual void Draw(ICanvas canvas, RectF bounds)
|
||||
{
|
||||
foreach (var child in Children)
|
||||
{
|
||||
if (child.IsVisible)
|
||||
{
|
||||
child.Draw(canvas, bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,6 +43,7 @@ namespace AlohaKit.UI
|
|||
canvas.FillRectangle(bounds);
|
||||
}
|
||||
|
||||
canvas.Alpha = (float)Opacity;
|
||||
canvas.Transform(TranslationX, TranslationY, ScaleX, ScaleY);
|
||||
|
||||
base.Draw(canvas, bounds);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
public interface IVisualElement
|
||||
{
|
||||
bool IsVisible { get; set; }
|
||||
double Opacity { get; set; }
|
||||
|
||||
float X { get; set; }
|
||||
float Y { get; set; }
|
||||
|
@ -25,6 +26,10 @@
|
|||
BindableProperty.Create(nameof(IsVisible), typeof(bool), typeof(VisualElement), true,
|
||||
propertyChanged: InvalidatePropertyChanged);
|
||||
|
||||
public static readonly BindableProperty OpacityProperty =
|
||||
BindableProperty.Create(nameof(Opacity), typeof(double), typeof(VisualElement), 1d,
|
||||
propertyChanged: InvalidatePropertyChanged);
|
||||
|
||||
public static readonly BindableProperty XProperty =
|
||||
BindableProperty.Create(nameof(X), typeof(float), typeof(VisualElement), 0.0f,
|
||||
propertyChanged: InvalidatePropertyChanged);
|
||||
|
@ -66,6 +71,12 @@
|
|||
set => SetValue(IsVisibleProperty, value);
|
||||
}
|
||||
|
||||
public double Opacity
|
||||
{
|
||||
get { return (double)GetValue(OpacityProperty); }
|
||||
set { SetValue(OpacityProperty, value); }
|
||||
}
|
||||
|
||||
public float X
|
||||
{
|
||||
get => (float)GetValue(XProperty);
|
||||
|
|
Загрузка…
Ссылка в новой задаче