Merge pull request #122 from irihitech/fix

Use PureRectangle in shared library.
This commit is contained in:
Dong Bin
2024-02-26 14:29:12 +08:00
committed by GitHub
11 changed files with 22 additions and 111 deletions

View File

@@ -1,14 +1,14 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa"
xmlns:shapes="clr-namespace:Ursa.Controls.Shapes;assembly=Ursa">
xmlns:iri="https://irihi.tech/shared">
<!-- Add Resources Here -->
<ControlTheme TargetType="u:DisableContainer" x:Key="{x:Type u:DisableContainer}">
<Setter Property="Template">
<ControlTemplate TargetType="u:DisableContainer">
<Panel>
<ContentPresenter Content="{TemplateBinding Content}"></ContentPresenter>
<shapes:PureRectangle Background="Transparent" IsVisible="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content.IsEnabled, Converter={x:Static BoolConverters.Not}}" Cursor="No" ToolTip.Tip="{TemplateBinding DisabledTip}"/>
<iri:PureRectangle Background="Transparent" IsVisible="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content.IsEnabled, Converter={x:Static BoolConverters.Not}}" Cursor="No" ToolTip.Tip="{TemplateBinding DisabledTip}"/>
</Panel>
</ControlTemplate>
</Setter>

View File

@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:Ursa.Themes.Semi.Converters"
xmlns:u="clr-namespace:Ursa.Controls;assembly=Ursa"
xmlns:shapes="clr-namespace:Ursa.Controls.Shapes;assembly=Ursa">
xmlns:iri="https://irihi.tech/shared">
<!-- Add Resources Here -->
<converters:BrushToColorConverter x:Key="BrushToColorConverter" />
<ControlTheme x:Key="{x:Type u:LoadingIcon}" TargetType="u:LoadingIcon">
@@ -68,9 +68,10 @@
<Setter Property="Template">
<ControlTemplate TargetType="u:Loading">
<Panel IsVisible="{TemplateBinding IsLoading}">
<shapes:PureRectangle
<iri:PureRectangle
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
IsHitTestVisible="True"
Background="{TemplateBinding Background}" />
<Grid
HorizontalAlignment="Center"

View File

@@ -1,7 +1,8 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa">
xmlns:u="https://irihi.tech/ursa"
xmlns:iri="https://irihi.tech/shared">
<Design.PreviewWith>
<Border Padding="20">
<!-- Add Controls for Previewer Here -->
@@ -24,19 +25,19 @@
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
<Border
<iri:PureRectangle
x:Name="PART_LoadingBorder"
Classes.Active="{Binding Path= IsActive, RelativeSource={RelativeSource TemplatedParent}}"
IsHitTestVisible="{TemplateBinding IsLoading}"
Background="{DynamicResource SkeletonDefaultBackground}"
IsVisible="{TemplateBinding IsLoading}">
</Border>
<Border
</iri:PureRectangle>
<iri:PureRectangle
x:Name="PART_ActiveBorder"
IsHitTestVisible="{TemplateBinding IsLoading}"
IsVisible="{TemplateBinding IsLoading}"
>
</Border>
</iri:PureRectangle>
</Panel>
</Border>
</ControlTemplate>

View File

@@ -1,6 +1,7 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa">
xmlns:u="https://irihi.tech/ursa"
xmlns:iri="https://irihi.tech/shared">
<Design.PreviewWith>
<Border Padding="20">
<!-- Add Controls for Previewer Here -->
@@ -8,7 +9,7 @@
</Design.PreviewWith>
<!-- Add Styles Here -->
<Style Selector="u|Skeleton[IsActive=True][IsLoading=True] /template/ Border#PART_ActiveBorder">
<Style Selector="u|Skeleton[IsActive=True][IsLoading=True] /template/ iri|PureRectangle#PART_ActiveBorder">
<Style.Animations>
<Animation
FillMode="None"
@@ -17,10 +18,10 @@
PlaybackDirection="Alternate"
Duration="0:0:1.4">
<KeyFrame Cue="0%">
<Setter Property="Border.Background" Value="{DynamicResource SkeletonStartAnimationBackground}" />
<Setter Property="Background" Value="{DynamicResource SkeletonStartAnimationBackground}" />
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="Border.Background" Value="{DynamicResource SkeletonEndAnimationBackground}" />
<Setter Property="Background" Value="{DynamicResource SkeletonEndAnimationBackground}" />
</KeyFrame>
</Animation>
</Style.Animations>

View File

@@ -1,12 +1,10 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
using Avalonia.Data.Converters;
using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.Media;
using Ursa.Controls.Shapes;
using Irihi.Avalonia.Shared.Shapes;
namespace Ursa.Controls;
@@ -33,7 +31,7 @@ public class DisabledAdorner
{
if (arg2.NewValue.Value)
{
var pureRectangle = new Border()
var pureRectangle = new PureRectangle()
{
Background = Brushes.Transparent,
IsHitTestVisible = true,

View File

@@ -1,17 +1,8 @@
using Avalonia;
using Avalonia.Animation;
using Avalonia.Animation.Easings;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.Media;
using Avalonia.Styling;
using Avalonia.Utilities;
using Irihi.Avalonia.Shared.Shapes;
using Ursa.Controls.OverlayShared;
using Ursa.Controls.Shapes;
using Ursa.EventArgs;
namespace Ursa.Controls;

View File

@@ -3,9 +3,9 @@ using Avalonia.Animation;
using Avalonia.Animation.Easings;
using Avalonia.Controls;
using Avalonia.Styling;
using Irihi.Avalonia.Shared.Shapes;
using Ursa.Common;
using Ursa.Controls.OverlayShared;
using Ursa.Controls.Shapes;
using Ursa.EventArgs;
namespace Ursa.Controls;

View File

@@ -1,15 +1,12 @@
using Avalonia;
using Avalonia.Animation;
using Avalonia.Controls;
using Avalonia.Controls.Shapes;
using Avalonia.Controls.Templates;
using Avalonia.Input;
using Avalonia.Media;
using Ursa.Controls.OverlayShared;
using Avalonia.Layout;
using Avalonia.Media.Immutable;
using Avalonia.Styling;
using Ursa.Controls.Shapes;
using Irihi.Avalonia.Shared.Shapes;
namespace Ursa.Controls;

View File

@@ -1,45 +0,0 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Media;
namespace Ursa.Controls.Shapes;
public class PureCircle: Control
{
public static readonly StyledProperty<IBrush?> BackgroundProperty =
TemplatedControl.BackgroundProperty.AddOwner<PureCircle>();
public IBrush? Background
{
get => GetValue(BackgroundProperty);
set => SetValue(BackgroundProperty, value);
}
public static readonly StyledProperty<double> DiameterProperty = AvaloniaProperty.Register<PureCircle, double>(
nameof(Diameter));
public double Diameter
{
get => GetValue(DiameterProperty);
set => SetValue(DiameterProperty, value);
}
static PureCircle()
{
FocusableProperty.OverrideDefaultValue<PureCircle>(false);
AffectsMeasure<PureCircle>(DiameterProperty);
AffectsRender<PureCircle>(DiameterProperty, BackgroundProperty);
}
protected override Size MeasureOverride(Size availableSize)
{
return new Size(Diameter, Diameter);
}
public override void Render(DrawingContext context)
{
double value = Diameter / 2;
context.DrawEllipse(Background, null, new(value, value), value, value);
}
}

View File

@@ -1,33 +0,0 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Shapes;
using Avalonia.Markup.Xaml.Templates;
using Avalonia.Media;
namespace Ursa.Controls.Shapes;
/// <summary>
/// A rectangle, with no corner radius.
/// </summary>
public class PureRectangle: Control
{
public static readonly StyledProperty<IBrush?> BackgroundProperty =
TemplatedControl.BackgroundProperty.AddOwner<PureRectangle>();
public IBrush? Background
{
get => GetValue(BackgroundProperty);
set => SetValue(BackgroundProperty, value);
}
static PureRectangle()
{
FocusableProperty.OverrideDefaultValue<PureRectangle>(false);
AffectsRender<PureRectangle>(BackgroundProperty);
}
public override void Render(DrawingContext context)
{
context.DrawRectangle(Background, null, new Rect(Bounds.Size));
}
}

View File

@@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="Irihi.Avalonia.Shared" Version="0.1.4" />
<PackageReference Include="Irihi.Avalonia.Shared" Version="0.1.5" />
</ItemGroup>
<ItemGroup>