Merge pull request #349 from irihitech/UrsaView

Ursa view
This commit is contained in:
Zhang Dian
2024-08-14 22:16:11 +08:00
committed by GitHub
15 changed files with 189 additions and 12 deletions

View File

@@ -0,0 +1,50 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa">
<!-- Add Resources Here -->
<ControlTheme x:Key="{x:Type u:UrsaView}" TargetType="{x:Type u:UrsaView}">
<Setter Property="Background" Value="{DynamicResource WindowDefaultBackground}" />
<Setter Property="Foreground" Value="{DynamicResource WindowDefaultForeground}" />
<Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
<Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}" />
<Setter Property="u:OverlayDialogHost.IsModalStatusScope" Value="True" />
<Setter Property="Template">
<ControlTemplate TargetType="u:UrsaView">
<Panel>
<Border Background="{TemplateBinding Background}" IsHitTestVisible="False" />
<Panel>
<ContentPresenter
Name="PART_ContentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
<Grid
Margin="{Binding $parent[u:UrsaWindow].TitleBarMargin}"
VerticalAlignment="Top"
ColumnDefinitions="Auto, *, Auto">
<ContentPresenter
Grid.Column="0"
VerticalAlignment="Center"
IsVisible="{TemplateBinding IsTitleBarVisible}"
Content="{TemplateBinding LeftContent}" />
<ContentPresenter
Grid.Column="1"
VerticalAlignment="Center"
IsVisible="{TemplateBinding IsTitleBarVisible}"
Content="{TemplateBinding TitleBarContent}" />
<ContentPresenter
Grid.Column="2"
VerticalAlignment="Center"
IsVisible="{TemplateBinding IsTitleBarVisible}"
Content="{TemplateBinding RightContent}" />
</Grid>
<u:OverlayDialogHost IsModalStatusReporter="True" />
</Panel>
</Panel>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>

View File

@@ -60,6 +60,7 @@
<VisualLayerManager Padding="{TemplateBinding OffScreenMargin, Mode=OneWay}">
<VisualLayerManager.ChromeOverlayLayer>
<u:TitleBar
IsTitleVisible="{Binding $parent[u:UrsaWindow].IsTitleBarVisible}"
Content="{Binding $parent[u:UrsaWindow].TitleBarContent}"
Margin="{Binding $parent[u:UrsaWindow].TitleBarMargin}"
LeftContent="{Binding $parent[u:UrsaWindow].LeftContent}"
@@ -97,14 +98,17 @@
<ContentPresenter
Grid.Column="0"
VerticalAlignment="Center"
IsVisible="{TemplateBinding IsTitleVisible}"
Content="{TemplateBinding LeftContent}" />
<ContentPresenter
Grid.Column="1"
VerticalAlignment="Center"
IsVisible="{TemplateBinding IsTitleVisible}"
Content="{TemplateBinding Content}" />
<ContentPresenter
Grid.Column="2"
VerticalAlignment="Center"
IsVisible="{TemplateBinding IsTitleVisible}"
Content="{TemplateBinding RightContent}" />
<u:CaptionButtons
x:Name="PART_CaptionButtons"

View File

@@ -48,6 +48,7 @@
<ResourceInclude Source="TwoTonePathIcon.axaml" />
<ResourceInclude Source="ToolBar.axaml" />
<ResourceInclude Source="TimeBox.axaml"/>
<ResourceInclude Source="UrsaView.axaml" />
<ResourceInclude Source="UrsaWindow.axaml"/>
<ResourceInclude Source="PinCode.axaml" />
</ResourceDictionary.MergedDictionaries>

View File

@@ -0,0 +1,14 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa">
<Design.PreviewWith>
<Border Padding="20">
<!-- Add Controls for Previewer Here -->
</Border>
</Design.PreviewWith>
<!-- Add Styles Here -->
<Style Selector=":is(u|UrsaView)">
<Setter Property="Theme" Value="{DynamicResource {x:Type u:UrsaView}}"/>
</Style>
</Styles>

View File

@@ -10,5 +10,6 @@
<StyleInclude Source="Skeleton.axaml" />
<StyleInclude Source="ToolBar.axaml"/>
<StyleInclude Source="TimeBox.axaml"/>
<StyleInclude Source="UrsaView.axaml" />
<!-- Add Styles Here -->
</Styles>

View File

@@ -29,6 +29,15 @@ public class TitleBar: ContentControl
get => GetValue(RightContentProperty);
set => SetValue(RightContentProperty, value);
}
public static readonly StyledProperty<bool> IsTitleVisibleProperty = AvaloniaProperty.Register<TitleBar, bool>(
nameof(IsTitleVisible));
public bool IsTitleVisible
{
get => GetValue(IsTitleVisibleProperty);
set => SetValue(IsTitleVisibleProperty, value);
}
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{

View File

@@ -0,0 +1,55 @@
using Avalonia;
using Avalonia.Controls;
namespace Ursa.Controls;
/// <summary>
/// Ursa window is designed to
/// </summary>
public class UrsaView: ContentControl
{
public static readonly StyledProperty<bool> IsTitleBarVisibleProperty =
UrsaWindow.IsTitleBarVisibleProperty.AddOwner<UrsaView>();
public bool IsTitleBarVisible
{
get => GetValue(IsTitleBarVisibleProperty);
set => SetValue(IsTitleBarVisibleProperty, value);
}
public static readonly StyledProperty<object?> LeftContentProperty =
UrsaWindow.LeftContentProperty.AddOwner<UrsaView>();
public object? LeftContent
{
get => GetValue(LeftContentProperty);
set => SetValue(LeftContentProperty, value);
}
public static readonly StyledProperty<object?> RightContentProperty =
UrsaWindow.RightContentProperty.AddOwner<UrsaView>();
public object? RightContent
{
get => GetValue(RightContentProperty);
set => SetValue(RightContentProperty, value);
}
public static readonly StyledProperty<object?> TitleBarContentProperty =
UrsaWindow.TitleBarContentProperty.AddOwner<UrsaView>();
public object? TitleBarContent
{
get => GetValue(TitleBarContentProperty);
set => SetValue(TitleBarContentProperty, value);
}
public static readonly StyledProperty<Thickness> TitleBarMarginProperty =
UrsaWindow.TitleBarMarginProperty.AddOwner<UrsaView>();
public Thickness TitleBarMargin
{
get => GetValue(TitleBarMarginProperty);
set => SetValue(TitleBarMarginProperty, value);
}
}

View File

@@ -47,7 +47,7 @@ public class UrsaWindow: Window
}
public static readonly StyledProperty<bool> IsTitleBarVisibleProperty = AvaloniaProperty.Register<UrsaWindow, bool>(
nameof(IsTitleBarVisible));
nameof(IsTitleBarVisible), true);
public bool IsTitleBarVisible
{