committed by
GitHub
145 changed files with 4321 additions and 835 deletions
@ -0,0 +1,145 @@ |
|||
#include "common.h" |
|||
|
|||
|
|||
IAvnNativeControlHostTopLevelAttachment* CreateAttachment(); |
|||
|
|||
class AvnNativeControlHost : |
|||
public ComSingleObject<IAvnNativeControlHost, &IID_IAvnNativeControlHost> |
|||
{ |
|||
public: |
|||
FORWARD_IUNKNOWN(); |
|||
NSView* View; |
|||
AvnNativeControlHost(NSView* view) |
|||
{ |
|||
View = view; |
|||
} |
|||
|
|||
virtual HRESULT CreateDefaultChild(void* parent, void** retOut) override |
|||
{ |
|||
NSView* view = [NSView new]; |
|||
[view setWantsLayer: true]; |
|||
|
|||
*retOut = (__bridge_retained void*)view; |
|||
return S_OK; |
|||
}; |
|||
|
|||
virtual IAvnNativeControlHostTopLevelAttachment* CreateAttachment() override |
|||
{ |
|||
return ::CreateAttachment(); |
|||
}; |
|||
|
|||
virtual void DestroyDefaultChild(void* child) override |
|||
{ |
|||
// ARC will release the object for us |
|||
(__bridge_transfer NSView*) child; |
|||
} |
|||
}; |
|||
|
|||
class AvnNativeControlHostTopLevelAttachment : |
|||
public ComSingleObject<IAvnNativeControlHostTopLevelAttachment, &IID_IAvnNativeControlHostTopLevelAttachment> |
|||
{ |
|||
NSView* _holder; |
|||
NSView* _child; |
|||
public: |
|||
FORWARD_IUNKNOWN(); |
|||
|
|||
AvnNativeControlHostTopLevelAttachment() |
|||
{ |
|||
_holder = [NSView new]; |
|||
[_holder setWantsLayer:true]; |
|||
} |
|||
|
|||
virtual ~AvnNativeControlHostTopLevelAttachment() |
|||
{ |
|||
if(_child != nil && [_child superview] == _holder) |
|||
{ |
|||
[_child removeFromSuperview]; |
|||
} |
|||
|
|||
if([_holder superview] != nil) |
|||
{ |
|||
[_holder removeFromSuperview]; |
|||
} |
|||
} |
|||
|
|||
virtual void* GetParentHandle() override |
|||
{ |
|||
return (__bridge void*)_holder; |
|||
}; |
|||
|
|||
virtual HRESULT InitializeWithChildHandle(void* child) override |
|||
{ |
|||
if(_child != nil) |
|||
return E_FAIL; |
|||
_child = (__bridge NSView*)child; |
|||
if(_child == nil) |
|||
return E_FAIL; |
|||
[_holder addSubview:_child]; |
|||
[_child setHidden: false]; |
|||
return S_OK; |
|||
}; |
|||
|
|||
virtual HRESULT AttachTo(IAvnNativeControlHost* host) override |
|||
{ |
|||
if(host == nil) |
|||
{ |
|||
[_holder removeFromSuperview]; |
|||
[_holder setHidden: true]; |
|||
} |
|||
else |
|||
{ |
|||
AvnNativeControlHost* chost = dynamic_cast<AvnNativeControlHost*>(host); |
|||
if(chost == nil || chost->View == nil) |
|||
return E_FAIL; |
|||
[_holder setHidden:true]; |
|||
[chost->View addSubview:_holder]; |
|||
} |
|||
return S_OK; |
|||
}; |
|||
|
|||
virtual void MoveTo(float x, float y, float width, float height) override |
|||
{ |
|||
if(_child == nil) |
|||
return; |
|||
if(AvnInsidePotentialDeadlock::IsInside()) |
|||
{ |
|||
IAvnNativeControlHostTopLevelAttachment* slf = this; |
|||
slf->AddRef(); |
|||
dispatch_async(dispatch_get_main_queue(), ^{ |
|||
slf->MoveTo(x, y, width, height); |
|||
slf->Release(); |
|||
}); |
|||
return; |
|||
} |
|||
|
|||
NSRect childFrame = {0, 0, width, height}; |
|||
NSRect holderFrame = {x, y, width, height}; |
|||
|
|||
[_child setFrame: childFrame]; |
|||
[_holder setFrame: holderFrame]; |
|||
[_holder setHidden: false]; |
|||
if([_holder superview] != nil) |
|||
[[_holder superview] setNeedsDisplay:true]; |
|||
} |
|||
|
|||
virtual void Hide() override |
|||
{ |
|||
[_holder setHidden: true]; |
|||
} |
|||
|
|||
virtual void ReleaseChild() override |
|||
{ |
|||
[_child removeFromSuperview]; |
|||
_child = nil; |
|||
} |
|||
}; |
|||
|
|||
IAvnNativeControlHostTopLevelAttachment* CreateAttachment() |
|||
{ |
|||
return new AvnNativeControlHostTopLevelAttachment(); |
|||
} |
|||
|
|||
extern IAvnNativeControlHost* CreateNativeControlHost(NSView* parent) |
|||
{ |
|||
return new AvnNativeControlHost(parent); |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
#include "common.h" |
|||
|
|||
static int Counter = 0; |
|||
AvnInsidePotentialDeadlock::AvnInsidePotentialDeadlock() |
|||
{ |
|||
Counter++; |
|||
} |
|||
|
|||
AvnInsidePotentialDeadlock::~AvnInsidePotentialDeadlock() |
|||
{ |
|||
Counter--; |
|||
} |
|||
|
|||
bool AvnInsidePotentialDeadlock::IsInside() |
|||
{ |
|||
return Counter!=0; |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="ControlCatalog.Pages.ScrollViewerPage"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Classes="h1">ScrollViewer</TextBlock> |
|||
<TextBlock Classes="h2">Allows for horizontal and vertical content scrolling.</TextBlock> |
|||
|
|||
<Grid ColumnDefinitions="Auto, *"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<ToggleSwitch IsChecked="{Binding AllowAutoHide}" Content="Allow auto hide" /> |
|||
|
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Text="Horizontal Scroll" /> |
|||
<ComboBox Items="{Binding AvailableVisibility}" SelectedItem="{Binding HorizontalScrollVisibility}" /> |
|||
</StackPanel> |
|||
|
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Text="Vertical Scroll" /> |
|||
<ComboBox Items="{Binding AvailableVisibility}" SelectedItem="{Binding VerticalScrollVisibility}" /> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
|
|||
<ScrollViewer x:Name="ScrollViewer" |
|||
Grid.Column="1" |
|||
Width="400" Height="400" |
|||
AllowAutoHide="{Binding AllowAutoHide}" |
|||
HorizontalScrollBarVisibility="{Binding HorizontalScrollVisibility}" |
|||
VerticalScrollBarVisibility="{Binding VerticalScrollVisibility}"> |
|||
<Image Width="800" Height="800" Stretch="UniformToFill" |
|||
Source="/Assets/delicate-arch-896885_640.jpg" /> |
|||
</ScrollViewer> |
|||
</Grid> |
|||
|
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,65 @@ |
|||
using System.Collections.Generic; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Primitives; |
|||
using Avalonia.Markup.Xaml; |
|||
using ReactiveUI; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class ScrollViewerPageViewModel : ReactiveObject |
|||
{ |
|||
private bool _allowAutoHide; |
|||
private ScrollBarVisibility _horizontalScrollVisibility; |
|||
private ScrollBarVisibility _verticalScrollVisibility; |
|||
|
|||
public ScrollViewerPageViewModel() |
|||
{ |
|||
AvailableVisibility = new List<ScrollBarVisibility> |
|||
{ |
|||
ScrollBarVisibility.Auto, |
|||
ScrollBarVisibility.Visible, |
|||
ScrollBarVisibility.Hidden, |
|||
ScrollBarVisibility.Disabled, |
|||
}; |
|||
|
|||
HorizontalScrollVisibility = ScrollBarVisibility.Auto; |
|||
VerticalScrollVisibility = ScrollBarVisibility.Auto; |
|||
AllowAutoHide = true; |
|||
} |
|||
|
|||
public bool AllowAutoHide |
|||
{ |
|||
get => _allowAutoHide; |
|||
set => this.RaiseAndSetIfChanged(ref _allowAutoHide, value); |
|||
} |
|||
|
|||
public ScrollBarVisibility HorizontalScrollVisibility |
|||
{ |
|||
get => _horizontalScrollVisibility; |
|||
set => this.RaiseAndSetIfChanged(ref _horizontalScrollVisibility, value); |
|||
} |
|||
|
|||
public ScrollBarVisibility VerticalScrollVisibility |
|||
{ |
|||
get => _verticalScrollVisibility; |
|||
set => this.RaiseAndSetIfChanged(ref _verticalScrollVisibility, value); |
|||
} |
|||
|
|||
public List<ScrollBarVisibility> AvailableVisibility { get; } |
|||
} |
|||
|
|||
public class ScrollViewerPage : UserControl |
|||
{ |
|||
public ScrollViewerPage() |
|||
{ |
|||
InitializeComponent(); |
|||
|
|||
DataContext = new ScrollViewerPageViewModel(); |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
<Application xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="NativeEmbedSample.App"> |
|||
<Application.Styles> |
|||
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml"/> |
|||
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml"/> |
|||
</Application.Styles> |
|||
</Application> |
|||
@ -0,0 +1,22 @@ |
|||
using Avalonia; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace NativeEmbedSample |
|||
{ |
|||
public class App : Application |
|||
{ |
|||
public override void Initialize() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
|
|||
public override void OnFrameworkInitializationCompleted() |
|||
{ |
|||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime) |
|||
desktopLifetime.MainWindow = new MainWindow(); |
|||
|
|||
base.OnFrameworkInitializationCompleted(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,121 @@ |
|||
using System; |
|||
using System.Diagnostics; |
|||
using System.IO; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Threading; |
|||
using MonoMac.AppKit; |
|||
using MonoMac.Foundation; |
|||
using MonoMac.WebKit; |
|||
using Encoding = SharpDX.Text.Encoding; |
|||
|
|||
namespace NativeEmbedSample |
|||
{ |
|||
public class EmbedSample : NativeControlHost |
|||
{ |
|||
public bool IsSecond { get; set; } |
|||
private Process _mplayer; |
|||
|
|||
IPlatformHandle CreateLinux(IPlatformHandle parent) |
|||
{ |
|||
if (IsSecond) |
|||
{ |
|||
var chooser = GtkHelper.CreateGtkFileChooser(parent.Handle); |
|||
if (chooser != null) |
|||
return chooser; |
|||
} |
|||
|
|||
var control = base.CreateNativeControlCore(parent); |
|||
var nodes = Path.GetFullPath(Path.Combine(typeof(EmbedSample).Assembly.GetModules()[0].FullyQualifiedName, |
|||
"..", |
|||
"nodes.mp4")); |
|||
_mplayer = Process.Start(new ProcessStartInfo("mplayer", |
|||
$"-vo x11 -zoom -loop 0 -wid {control.Handle.ToInt64()} \"{nodes}\"") |
|||
{ |
|||
UseShellExecute = false, |
|||
|
|||
}); |
|||
return control; |
|||
} |
|||
|
|||
void DestroyLinux(IPlatformHandle handle) |
|||
{ |
|||
_mplayer?.Kill(); |
|||
_mplayer = null; |
|||
base.DestroyNativeControlCore(handle); |
|||
} |
|||
|
|||
private const string RichText = |
|||
@"{\rtf1\ansi\ansicpg1251\deff0\nouicompat\deflang1049{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
|
|||
{\colortbl ;\red255\green0\blue0;\red0\green77\blue187;\red0\green176\blue80;\red155\green0\blue211;\red247\green150\blue70;\red75\green172\blue198;} |
|||
{\*\generator Riched20 6.3.9600}\viewkind4\uc1 |
|||
\pard\sa200\sl276\slmult1\f0\fs22\lang9 <PREFIX>I \i am\i0 a \cf1\b Rich Text \cf0\b0\fs24 control\cf2\fs28 !\cf3\fs32 !\cf4\fs36 !\cf1\fs40 !\cf5\fs44 !\cf6\fs48 !\cf0\fs44\par |
|||
}";
|
|||
|
|||
IPlatformHandle CreateWin32(IPlatformHandle parent) |
|||
{ |
|||
WinApi.LoadLibrary("Msftedit.dll"); |
|||
var handle = WinApi.CreateWindowEx(0, "RICHEDIT50W", |
|||
@"Rich Edit", |
|||
0x800000 | 0x10000000 | 0x40000000 | 0x800000 | 0x10000 | 0x0004, 0, 0, 1, 1, parent.Handle, |
|||
IntPtr.Zero, WinApi.GetModuleHandle(null), IntPtr.Zero); |
|||
var st = new WinApi.SETTEXTEX { Codepage = 65001, Flags = 0x00000008 }; |
|||
var text = RichText.Replace("<PREFIX>", IsSecond ? "\\qr " : ""); |
|||
var bytes = Encoding.UTF8.GetBytes(text); |
|||
WinApi.SendMessage(handle, 0x0400 + 97, ref st, bytes); |
|||
return new PlatformHandle(handle, "HWND"); |
|||
|
|||
} |
|||
|
|||
void DestroyWin32(IPlatformHandle handle) |
|||
{ |
|||
WinApi.DestroyWindow(handle.Handle); |
|||
} |
|||
|
|||
IPlatformHandle CreateOSX(IPlatformHandle parent) |
|||
{ |
|||
// Note: We are using MonoMac for example purposes
|
|||
// It shouldn't be used in production apps
|
|||
MacHelper.EnsureInitialized(); |
|||
|
|||
var webView = new WebView(); |
|||
Dispatcher.UIThread.Post(() => |
|||
{ |
|||
webView.MainFrame.LoadRequest(new NSUrlRequest(new NSUrl( |
|||
IsSecond ? "https://bing.com": "https://google.com/"))); |
|||
}); |
|||
return new MacOSViewHandle(webView); |
|||
|
|||
} |
|||
|
|||
void DestroyOSX(IPlatformHandle handle) |
|||
{ |
|||
((MacOSViewHandle)handle).Dispose(); |
|||
} |
|||
|
|||
protected override IPlatformHandle CreateNativeControlCore(IPlatformHandle parent) |
|||
{ |
|||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
|||
return CreateLinux(parent); |
|||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
|||
return CreateWin32(parent); |
|||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) |
|||
return CreateOSX(parent); |
|||
return base.CreateNativeControlCore(parent); |
|||
} |
|||
|
|||
protected override void DestroyNativeControlCore(IPlatformHandle control) |
|||
{ |
|||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
|||
DestroyLinux(control); |
|||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
|||
DestroyWin32(control); |
|||
else if(RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) |
|||
DestroyOSX(control); |
|||
else |
|||
base.DestroyNativeControlCore(control); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Controls.Platform; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Platform.Interop; |
|||
using Avalonia.X11.NativeDialogs; |
|||
using static Avalonia.X11.NativeDialogs.Gtk; |
|||
using static Avalonia.X11.NativeDialogs.Glib; |
|||
namespace NativeEmbedSample |
|||
{ |
|||
public class GtkHelper |
|||
{ |
|||
private static Task<bool> s_gtkTask; |
|||
class FileChooser : INativeControlHostDestroyableControlHandle |
|||
{ |
|||
private readonly IntPtr _widget; |
|||
|
|||
public FileChooser(IntPtr widget, IntPtr xid) |
|||
{ |
|||
_widget = widget; |
|||
Handle = xid; |
|||
} |
|||
|
|||
public IntPtr Handle { get; } |
|||
public string HandleDescriptor => "XID"; |
|||
public void Destroy() |
|||
{ |
|||
RunOnGlibThread(() => |
|||
{ |
|||
gtk_widget_destroy(_widget); |
|||
return 0; |
|||
}).Wait(); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
public static IPlatformHandle CreateGtkFileChooser(IntPtr parentXid) |
|||
{ |
|||
if (s_gtkTask == null) |
|||
s_gtkTask = StartGtk(); |
|||
if (!s_gtkTask.Result) |
|||
return null; |
|||
return RunOnGlibThread(() => |
|||
{ |
|||
using (var title = new Utf8Buffer("Embedded")) |
|||
{ |
|||
var widget = gtk_file_chooser_dialog_new(title, IntPtr.Zero, GtkFileChooserAction.SelectFolder, |
|||
IntPtr.Zero); |
|||
gtk_widget_realize(widget); |
|||
var xid = gdk_x11_window_get_xid(gtk_widget_get_window(widget)); |
|||
gtk_window_present(widget); |
|||
return new FileChooser(widget, xid); |
|||
} |
|||
}).Result; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
using System; |
|||
using Avalonia.Platform; |
|||
using MonoMac.AppKit; |
|||
|
|||
namespace NativeEmbedSample |
|||
{ |
|||
public class MacHelper |
|||
{ |
|||
private static bool _isInitialized; |
|||
|
|||
public static void EnsureInitialized() |
|||
{ |
|||
if (_isInitialized) |
|||
return; |
|||
_isInitialized = true; |
|||
NSApplication.Init(); |
|||
} |
|||
} |
|||
|
|||
class MacOSViewHandle : IPlatformHandle, IDisposable |
|||
{ |
|||
private NSView _view; |
|||
|
|||
public MacOSViewHandle(NSView view) |
|||
{ |
|||
_view = view; |
|||
} |
|||
|
|||
public IntPtr Handle => _view?.Handle ?? IntPtr.Zero; |
|||
public string HandleDescriptor => "NSView"; |
|||
|
|||
public void Dispose() |
|||
{ |
|||
_view.Dispose(); |
|||
_view = null; |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
<Window xmlns="https://github.com/avaloniaui" MinWidth="500" MinHeight="300" |
|||
Width="1024" Height="800" |
|||
Title="Native embedding sample" |
|||
xmlns:local="clr-namespace:NativeEmbedSample" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="NativeEmbedSample.MainWindow"> |
|||
<DockPanel> |
|||
<Menu DockPanel.Dock="Top"> |
|||
<MenuItem Header="Test"> |
|||
<MenuItem Header="SubMenu"> |
|||
<MenuItem Header="Item 1"/> |
|||
<MenuItem Header="Item 2"/> |
|||
<MenuItem Header="Item 3"/> |
|||
</MenuItem> |
|||
<MenuItem Header="Item 1"/> |
|||
<MenuItem Header="Item 2"/> |
|||
<MenuItem Header="Item 3"/> |
|||
</MenuItem> |
|||
</Menu> |
|||
<DockPanel DockPanel.Dock="Top"> |
|||
<Button DockPanel.Dock="Right" Click="ShowPopupDelay">Show popup (delay)</Button> |
|||
<Button DockPanel.Dock="Right" Click="ShowPopup">Show popup</Button> |
|||
<TextBox Text="Lorem ipsum dolor sit amet"/> |
|||
</DockPanel> |
|||
<Grid ColumnDefinitions="*,5,*"> |
|||
<DockPanel> |
|||
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top"> |
|||
<CheckBox x:Name="firstVisible" IsChecked="True"/> |
|||
<TextBlock>Visible</TextBlock> |
|||
</StackPanel> |
|||
<local:EmbedSample IsVisible="{Binding #firstVisible.IsChecked}"/> |
|||
</DockPanel> |
|||
<GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch" /> |
|||
<DockPanel Grid.Column="2"> |
|||
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top"> |
|||
<CheckBox x:Name="secondVisible" IsChecked="True"/> |
|||
<TextBlock>Visible</TextBlock> |
|||
</StackPanel> |
|||
<local:EmbedSample IsSecond="True" IsVisible="{Binding #secondVisible.IsChecked}"/> |
|||
</DockPanel> |
|||
</Grid> |
|||
</DockPanel> |
|||
</Window> |
|||
@ -0,0 +1,36 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Interactivity; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace NativeEmbedSample |
|||
{ |
|||
public class MainWindow : Window |
|||
{ |
|||
public MainWindow() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
this.AttachDevTools(); |
|||
} |
|||
|
|||
public async void ShowPopupDelay(object sender, RoutedEventArgs args) |
|||
{ |
|||
await Task.Delay(3000); |
|||
ShowPopup(sender, args); |
|||
} |
|||
|
|||
public void ShowPopup(object sender, RoutedEventArgs args) |
|||
{ |
|||
|
|||
new ContextMenu() |
|||
{ |
|||
Items = new List<MenuItem> |
|||
{ |
|||
new MenuItem() { Header = "Test" }, new MenuItem() { Header = "Test" } |
|||
} |
|||
}.Open((Control)sender); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>netcoreapp2.0</TargetFramework> |
|||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> |
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="MonoMac.NetStandard" Version="0.0.4" /> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Desktop\Avalonia.Desktop.csproj" /> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" /> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.X11\Avalonia.X11.csproj" /> |
|||
<PackageReference Include="Avalonia.Angle.Windows.Natives" Version="2.1.0.2019013001" /> |
|||
|
|||
<AvaloniaResource Include="**\*.xaml"> |
|||
<SubType>Designer</SubType> |
|||
</AvaloniaResource> |
|||
<None Remove="nodes.mp4" /> |
|||
<Content Include="nodes.mp4"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Compile Include="..\..\..\src\Avalonia.X11\NativeDialogs\Gtk.cs" /> |
|||
</ItemGroup> |
|||
|
|||
<Import Project="..\..\..\build\SampleApp.props" /> |
|||
<Import Project="..\..\..\build\BuildTargets.targets" /> |
|||
<Import Project="..\..\..\build\ReferenceCoreLibraries.props" /> |
|||
</Project> |
|||
@ -0,0 +1,17 @@ |
|||
using Avalonia; |
|||
|
|||
namespace NativeEmbedSample |
|||
{ |
|||
class Program |
|||
{ |
|||
static int Main(string[] args) => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); |
|||
|
|||
public static AppBuilder BuildAvaloniaApp() |
|||
=> AppBuilder.Configure<App>() |
|||
.With(new AvaloniaNativePlatformOptions() |
|||
{ |
|||
}) |
|||
.UsePlatformDetect(); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,74 @@ |
|||
using System; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
namespace NativeEmbedSample |
|||
{ |
|||
public unsafe class WinApi |
|||
{ |
|||
public enum CommonControls : uint |
|||
{ |
|||
ICC_LISTVIEW_CLASSES = 0x00000001, // listview, header
|
|||
ICC_TREEVIEW_CLASSES = 0x00000002, // treeview, tooltips
|
|||
ICC_BAR_CLASSES = 0x00000004, // toolbar, statusbar, trackbar, tooltips
|
|||
ICC_TAB_CLASSES = 0x00000008, // tab, tooltips
|
|||
ICC_UPDOWN_CLASS = 0x00000010, // updown
|
|||
ICC_PROGRESS_CLASS = 0x00000020, // progress
|
|||
ICC_HOTKEY_CLASS = 0x00000040, // hotkey
|
|||
ICC_ANIMATE_CLASS = 0x00000080, // animate
|
|||
ICC_WIN95_CLASSES = 0x000000FF, |
|||
ICC_DATE_CLASSES = 0x00000100, // month picker, date picker, time picker, updown
|
|||
ICC_USEREX_CLASSES = 0x00000200, // comboex
|
|||
ICC_COOL_CLASSES = 0x00000400, // rebar (coolbar) control
|
|||
ICC_INTERNET_CLASSES = 0x00000800, |
|||
ICC_PAGESCROLLER_CLASS = 0x00001000, // page scroller
|
|||
ICC_NATIVEFNTCTL_CLASS = 0x00002000, // native font control
|
|||
ICC_STANDARD_CLASSES = 0x00004000, |
|||
ICC_LINK_CLASS = 0x00008000 |
|||
} |
|||
|
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public struct INITCOMMONCONTROLSEX |
|||
{ |
|||
public int dwSize; |
|||
public uint dwICC; |
|||
} |
|||
|
|||
[DllImport("Comctl32.dll")] |
|||
public static extern void InitCommonControlsEx(ref INITCOMMONCONTROLSEX init); |
|||
|
|||
[DllImport("user32.dll", SetLastError = true)] |
|||
public static extern bool DestroyWindow(IntPtr hwnd); |
|||
|
|||
[DllImport("kernel32.dll")] |
|||
public static extern IntPtr LoadLibrary(string lib); |
|||
|
|||
|
|||
[DllImport("kernel32.dll")] |
|||
public static extern IntPtr GetModuleHandle(string lpModuleName); |
|||
|
|||
[DllImport("user32.dll", SetLastError = true)] |
|||
public static extern IntPtr CreateWindowEx( |
|||
int dwExStyle, |
|||
string lpClassName, |
|||
string lpWindowName, |
|||
uint dwStyle, |
|||
int x, |
|||
int y, |
|||
int nWidth, |
|||
int nHeight, |
|||
IntPtr hWndParent, |
|||
IntPtr hMenu, |
|||
IntPtr hInstance, |
|||
IntPtr lpParam); |
|||
|
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public struct SETTEXTEX |
|||
{ |
|||
public uint Flags; |
|||
public uint Codepage; |
|||
} |
|||
|
|||
[DllImport("user32.dll", CharSet = CharSet.Unicode, EntryPoint = "SendMessageW")] |
|||
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, ref SETTEXTEX wParam, byte[] lParam); |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
nodes.mp4 by beeple is licensed under the creative commons license, downloaded from https://vimeo.com/9936271 |
|||
Binary file not shown.
@ -1,9 +1,29 @@ |
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Specifies a contract for a scrolling control that supports scroll anchoring.
|
|||
/// </summary>
|
|||
public interface IScrollAnchorProvider |
|||
{ |
|||
/// <summary>
|
|||
/// The currently chosen anchor element to use for scroll anchoring.
|
|||
/// </summary>
|
|||
IControl CurrentAnchor { get; } |
|||
|
|||
/// <summary>
|
|||
/// Registers a control as a potential scroll anchor candidate.
|
|||
/// </summary>
|
|||
/// <param name="element">
|
|||
/// A control within the subtree of the <see cref="IScrollAnchorProvider"/>.
|
|||
/// </param>
|
|||
void RegisterAnchorCandidate(IControl element); |
|||
|
|||
/// <summary>
|
|||
/// Unregisters a control as a potential scroll anchor candidate.
|
|||
/// </summary>
|
|||
/// <param name="element">
|
|||
/// A control within the subtree of the <see cref="IScrollAnchorProvider"/>.
|
|||
/// </param>
|
|||
void UnregisterAnchorCandidate(IControl element); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,141 @@ |
|||
using Avalonia.Controls.Platform; |
|||
using Avalonia.LogicalTree; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Threading; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
public class NativeControlHost : Control |
|||
{ |
|||
private TopLevel _currentRoot; |
|||
private INativeControlHostImpl _currentHost; |
|||
private INativeControlHostControlTopLevelAttachment _attachment; |
|||
private IPlatformHandle _nativeControlHandle; |
|||
private bool _queuedForDestruction; |
|||
static NativeControlHost() |
|||
{ |
|||
IsVisibleProperty.Changed.AddClassHandler<NativeControlHost>(OnVisibleChanged); |
|||
TransformedBoundsProperty.Changed.AddClassHandler<NativeControlHost>(OnBoundsChanged); |
|||
} |
|||
|
|||
private static void OnBoundsChanged(NativeControlHost host, AvaloniaPropertyChangedEventArgs arg2) |
|||
=> host.UpdateHost(); |
|||
|
|||
private static void OnVisibleChanged(NativeControlHost host, AvaloniaPropertyChangedEventArgs arg2) |
|||
=> host.UpdateHost(); |
|||
|
|||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) |
|||
{ |
|||
_currentRoot = e.Root as TopLevel; |
|||
UpdateHost(); |
|||
} |
|||
|
|||
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) |
|||
{ |
|||
_currentRoot = null; |
|||
UpdateHost(); |
|||
} |
|||
|
|||
|
|||
void UpdateHost() |
|||
{ |
|||
_currentHost = (_currentRoot?.PlatformImpl as ITopLevelImplWithNativeControlHost)?.NativeControlHost; |
|||
var needsAttachment = _currentHost != null; |
|||
var needsShow = needsAttachment && IsEffectivelyVisible && TransformedBounds.HasValue; |
|||
|
|||
if (needsAttachment) |
|||
{ |
|||
// If there is an existing attachment, ensure that we are attached to the proper host or destroy the attachment
|
|||
if (_attachment != null && _attachment.AttachedTo != _currentHost) |
|||
{ |
|||
if (_attachment != null) |
|||
{ |
|||
if (_attachment.IsCompatibleWith(_currentHost)) |
|||
{ |
|||
_attachment.AttachedTo = _currentHost; |
|||
} |
|||
else |
|||
{ |
|||
_attachment.Dispose(); |
|||
_attachment = null; |
|||
} |
|||
} |
|||
} |
|||
|
|||
// If there is no attachment, but the control exists,
|
|||
// attempt to attach to to the current toplevel or destroy the control if it's incompatible
|
|||
if (_attachment == null && _nativeControlHandle != null) |
|||
{ |
|||
if (_currentHost.IsCompatibleWith(_nativeControlHandle)) |
|||
_attachment = _currentHost.CreateNewAttachment(_nativeControlHandle); |
|||
else |
|||
DestroyNativeControl(); |
|||
} |
|||
|
|||
// There is no control handle an no attachment, create both
|
|||
if (_nativeControlHandle == null) |
|||
{ |
|||
_attachment = _currentHost.CreateNewAttachment(parent => |
|||
_nativeControlHandle = CreateNativeControlCore(parent)); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
// Immediately detach the control from the current toplevel if there is an existing attachment
|
|||
if (_attachment != null) |
|||
_attachment.AttachedTo = null; |
|||
|
|||
// Don't destroy the control immediately, it might be just being reparented to another TopLevel
|
|||
if (_nativeControlHandle != null && !_queuedForDestruction) |
|||
{ |
|||
_queuedForDestruction = true; |
|||
Dispatcher.UIThread.Post(CheckDestruction, DispatcherPriority.Background); |
|||
} |
|||
} |
|||
|
|||
if (needsShow) |
|||
_attachment?.ShowInBounds(TransformedBounds.Value); |
|||
else if (needsAttachment) |
|||
_attachment?.Hide(); |
|||
} |
|||
|
|||
public bool TryUpdateNativeControlPosition() |
|||
{ |
|||
var needsShow = _currentHost != null && IsEffectivelyVisible && TransformedBounds.HasValue; |
|||
|
|||
if(needsShow) |
|||
_attachment?.ShowInBounds(TransformedBounds.Value); |
|||
return needsShow; |
|||
} |
|||
|
|||
void CheckDestruction() |
|||
{ |
|||
_queuedForDestruction = false; |
|||
if (_currentRoot == null) |
|||
DestroyNativeControl(); |
|||
} |
|||
|
|||
protected virtual IPlatformHandle CreateNativeControlCore(IPlatformHandle parent) |
|||
{ |
|||
return _currentHost.CreateDefaultChild(parent); |
|||
} |
|||
|
|||
void DestroyNativeControl() |
|||
{ |
|||
if (_nativeControlHandle != null) |
|||
{ |
|||
_attachment?.Dispose(); |
|||
_attachment = null; |
|||
|
|||
DestroyNativeControlCore(_nativeControlHandle); |
|||
_nativeControlHandle = null; |
|||
} |
|||
} |
|||
|
|||
protected virtual void DestroyNativeControlCore(IPlatformHandle control) |
|||
{ |
|||
((INativeControlHostDestroyableControlHandle)control).Destroy(); |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -1,12 +0,0 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Platform |
|||
{ |
|||
/// <summary>
|
|||
/// Defines a platform-specific embeddable window implementation.
|
|||
/// </summary>
|
|||
public interface IEmbeddableWindowImpl : ITopLevelImpl |
|||
{ |
|||
event Action LostFocus; |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using System; |
|||
using Avalonia.Platform; |
|||
using Avalonia.VisualTree; |
|||
|
|||
namespace Avalonia.Controls.Platform |
|||
{ |
|||
public interface INativeControlHostImpl |
|||
{ |
|||
INativeControlHostDestroyableControlHandle CreateDefaultChild(IPlatformHandle parent); |
|||
INativeControlHostControlTopLevelAttachment CreateNewAttachment(Func<IPlatformHandle, IPlatformHandle> create); |
|||
INativeControlHostControlTopLevelAttachment CreateNewAttachment(IPlatformHandle handle); |
|||
bool IsCompatibleWith(IPlatformHandle handle); |
|||
} |
|||
|
|||
public interface INativeControlHostDestroyableControlHandle : IPlatformHandle |
|||
{ |
|||
void Destroy(); |
|||
} |
|||
|
|||
public interface INativeControlHostControlTopLevelAttachment : IDisposable |
|||
{ |
|||
INativeControlHostImpl AttachedTo { get; set; } |
|||
bool IsCompatibleWith(INativeControlHostImpl host); |
|||
void Hide(); |
|||
void ShowInBounds(TransformedBounds transformedBounds); |
|||
} |
|||
|
|||
public interface ITopLevelImplWithNativeControlHost |
|||
{ |
|||
INativeControlHostImpl NativeControlHost { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,136 @@ |
|||
using System; |
|||
using Avalonia.Controls.Platform; |
|||
using Avalonia.Native.Interop; |
|||
using Avalonia.Platform; |
|||
using Avalonia.VisualTree; |
|||
|
|||
namespace Avalonia.Native |
|||
{ |
|||
class NativeControlHostImpl : IDisposable, INativeControlHostImpl |
|||
{ |
|||
private IAvnNativeControlHost _host; |
|||
|
|||
public NativeControlHostImpl(IAvnNativeControlHost host) |
|||
{ |
|||
_host = host; |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
_host?.Dispose(); |
|||
_host = null; |
|||
} |
|||
|
|||
class DestroyableNSView : INativeControlHostDestroyableControlHandle |
|||
{ |
|||
private IAvnNativeControlHost _impl; |
|||
private IntPtr _nsView; |
|||
|
|||
public DestroyableNSView(IAvnNativeControlHost impl) |
|||
{ |
|||
_impl = new IAvnNativeControlHost(impl.NativePointer); |
|||
_impl.AddRef(); |
|||
_nsView = _impl.CreateDefaultChild(IntPtr.Zero); |
|||
} |
|||
|
|||
public IntPtr Handle => _nsView; |
|||
public string HandleDescriptor => "NSView"; |
|||
public void Destroy() |
|||
{ |
|||
if (_impl != null) |
|||
{ |
|||
_impl.DestroyDefaultChild(_nsView); |
|||
_impl.Dispose(); |
|||
_impl = null; |
|||
_nsView = IntPtr.Zero; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public INativeControlHostDestroyableControlHandle CreateDefaultChild(IPlatformHandle parent) |
|||
=> new DestroyableNSView(_host); |
|||
|
|||
public INativeControlHostControlTopLevelAttachment CreateNewAttachment( |
|||
Func<IPlatformHandle, IPlatformHandle> create) |
|||
{ |
|||
var a = new Attachment(_host.CreateAttachment()); |
|||
try |
|||
{ |
|||
var child = create(a.GetParentHandle()); |
|||
a.InitWithChild(child); |
|||
a.AttachedTo = this; |
|||
return a; |
|||
} |
|||
catch |
|||
{ |
|||
a.Dispose(); |
|||
throw; |
|||
} |
|||
} |
|||
|
|||
public INativeControlHostControlTopLevelAttachment CreateNewAttachment(IPlatformHandle handle) |
|||
{ |
|||
var a = new Attachment(_host.CreateAttachment()); |
|||
a.InitWithChild(handle); |
|||
a.AttachedTo = this; |
|||
return a; |
|||
} |
|||
|
|||
public bool IsCompatibleWith(IPlatformHandle handle) => handle.HandleDescriptor == "NSView"; |
|||
|
|||
class Attachment : INativeControlHostControlTopLevelAttachment |
|||
{ |
|||
private IAvnNativeControlHostTopLevelAttachment _native; |
|||
private NativeControlHostImpl _attachedTo; |
|||
public IPlatformHandle GetParentHandle() => new PlatformHandle(_native.ParentHandle, "NSView"); |
|||
public Attachment(IAvnNativeControlHostTopLevelAttachment native) |
|||
{ |
|||
_native = native; |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
if (_native != null) |
|||
{ |
|||
_native.ReleaseChild(); |
|||
_native.Dispose(); |
|||
_native = null; |
|||
} |
|||
} |
|||
|
|||
public INativeControlHostImpl AttachedTo |
|||
{ |
|||
get => _attachedTo; |
|||
set |
|||
{ |
|||
var host = (NativeControlHostImpl)value; |
|||
if(host == null) |
|||
_native.AttachTo(null); |
|||
else |
|||
_native.AttachTo(host._host); |
|||
_attachedTo = host; |
|||
} |
|||
} |
|||
|
|||
public bool IsCompatibleWith(INativeControlHostImpl host) => host is NativeControlHostImpl; |
|||
|
|||
public void Hide() |
|||
{ |
|||
_native?.Hide(); |
|||
} |
|||
|
|||
public void ShowInBounds(TransformedBounds transformedBounds) |
|||
{ |
|||
if (_attachedTo == null) |
|||
throw new InvalidOperationException("Native control isn't attached to a toplevel"); |
|||
var bounds = transformedBounds.Bounds.TransformToAABB(transformedBounds.Transform); |
|||
bounds = new Rect(bounds.X, bounds.Y, Math.Max(1, bounds.Width), |
|||
Math.Max(1, bounds.Height)); |
|||
_native.MoveTo((float) bounds.X, (float) bounds.Y, (float) bounds.Width, (float) bounds.Height); |
|||
} |
|||
|
|||
public void InitWithChild(IPlatformHandle handle) |
|||
=> _native.InitializeWithChildHandle(handle.Handle); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Style Selector="TextBlock" > |
|||
<Setter Property="FontSize" Value="14" /> |
|||
</Style> |
|||
<Style> |
|||
<Style.Resources> |
|||
<x:Double x:Key="ControlContentThemeFontSize">14</x:Double> |
|||
<x:Double x:Key="ContentControlFontSize">14</x:Double> |
|||
<x:Double x:Key="TextControlThemeMinHeight">24</x:Double> |
|||
<Thickness x:Key="TextControlThemePadding">2,2,6,1</Thickness> |
|||
<x:Double x:Key="ListViewItemMinHeight">32</x:Double> |
|||
<x:Double x:Key="TreeViewItemMinHeight">24</x:Double> |
|||
<Thickness x:Key="TimePickerHostPadding">0,1,0,2</Thickness> |
|||
<Thickness x:Key="DatePickerHostPadding">0,1,0,2</Thickness> |
|||
<Thickness x:Key="DatePickerHostMonthPadding">9,0,0,1</Thickness> |
|||
<Thickness x:Key="ComboBoxEditableTextPadding">10,0,30,0</Thickness> |
|||
<Thickness x:Key="ComboBoxMinHeight">24</Thickness> |
|||
<Thickness x:Key="ComboBoxPadding">12,1,0,3</Thickness> |
|||
<x:Double x:Key="NavigationViewItemOnLeftMinHeight">32</x:Double> |
|||
</Style.Resources> |
|||
</Style> |
|||
</Styles> |
|||
@ -1,142 +1,302 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui"> |
|||
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
|
|||
<Style Selector="ScrollBar"> |
|||
<Setter Property="Cursor" Value="Arrow" /> |
|||
<Setter Property="MinWidth" Value="{DynamicResource ScrollBarSize}" /> |
|||
<Setter Property="MinHeight" Value="{DynamicResource ScrollBarSize}" /> |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarBackground}" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource ScrollBarForeground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarBorderBrush}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar:vertical"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{DynamicResource ThemeControlMidBrush}" |
|||
UseLayoutRounding="False"> |
|||
<Grid RowDefinitions="Auto,*,Auto"> |
|||
<RepeatButton Name="PART_LineUpButton" HorizontalAlignment="Center" |
|||
Classes="repeat" |
|||
Grid.Row="0" |
|||
Focusable="False" |
|||
MinHeight="{DynamicResource ScrollBarThickness}"> |
|||
<Path Data="M 0 4 L 8 4 L 4 0 Z" /> |
|||
</RepeatButton> |
|||
<Track Grid.Row="1" |
|||
Grid.Column="1" |
|||
Minimum="{TemplateBinding Minimum}" |
|||
Maximum="{TemplateBinding Maximum}" |
|||
Value="{TemplateBinding Value, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding ViewportSize}" |
|||
Orientation="{TemplateBinding Orientation}" |
|||
IsDirectionReversed="True"> |
|||
<Track.DecreaseButton> |
|||
<RepeatButton Name="PART_PageUpButton" |
|||
Classes="repeattrack" |
|||
Focusable="False"/> |
|||
</Track.DecreaseButton> |
|||
<Track.IncreaseButton> |
|||
<RepeatButton Name="PART_PageDownButton" |
|||
Classes="repeattrack" |
|||
Focusable="False"/> |
|||
</Track.IncreaseButton> |
|||
<Thumb Name="thumb"/> |
|||
</Track> |
|||
<RepeatButton Name="PART_LineDownButton" HorizontalAlignment="Center" |
|||
Classes="repeat" |
|||
Grid.Row="2" |
|||
Grid.Column="2" |
|||
Focusable="False" |
|||
MinHeight="{DynamicResource ScrollBarThickness}"> |
|||
<Path Data="M 0 0 L 4 4 L 8 0 Z" /> |
|||
</RepeatButton> |
|||
</Grid> |
|||
</Border> |
|||
<Grid x:Name="Root"> |
|||
|
|||
<Border x:Name="VerticalRoot" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}"> |
|||
<Grid RowDefinitions="Auto,*,Auto"> |
|||
|
|||
<Rectangle x:Name="TrackRect" Grid.RowSpan="3" Margin="0" /> |
|||
|
|||
<RepeatButton Name="PART_LineUpButton" |
|||
HorizontalAlignment="Center" |
|||
Classes="line up" |
|||
Grid.Row="0" |
|||
Focusable="False" |
|||
MinWidth="{DynamicResource ScrollBarSize}" |
|||
Height="{DynamicResource ScrollBarSize}" /> |
|||
|
|||
<Track Grid.Row="1" |
|||
Minimum="{TemplateBinding Minimum}" |
|||
Maximum="{TemplateBinding Maximum}" |
|||
Value="{TemplateBinding Value, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding ViewportSize}" |
|||
Orientation="{TemplateBinding Orientation}" |
|||
IsDirectionReversed="True"> |
|||
<Track.DecreaseButton> |
|||
<RepeatButton Name="PART_PageUpButton" |
|||
Classes="largeIncrease" |
|||
Focusable="False" /> |
|||
</Track.DecreaseButton> |
|||
<Track.IncreaseButton> |
|||
<RepeatButton Name="PART_PageDownButton" |
|||
Classes="largeIncrease" |
|||
Focusable="False" /> |
|||
</Track.IncreaseButton> |
|||
<Thumb Classes="thumb" |
|||
Opacity="1" |
|||
Width="{DynamicResource ScrollBarSize}" |
|||
MinHeight="{DynamicResource ScrollBarSize}" |
|||
RenderTransformOrigin="100%,50%" /> |
|||
</Track> |
|||
|
|||
<RepeatButton Name="PART_LineDownButton" |
|||
HorizontalAlignment="Center" |
|||
Classes="line down" |
|||
Grid.Row="2" |
|||
Focusable="False" |
|||
MinWidth="{DynamicResource ScrollBarSize}" |
|||
Height="{DynamicResource ScrollBarSize}" /> |
|||
|
|||
</Grid> |
|||
</Border> |
|||
|
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar:horizontal"> |
|||
<Setter Property="Height" Value="{DynamicResource ScrollBarThickness}" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{DynamicResource ThemeControlMidBrush}" |
|||
UseLayoutRounding="False"> |
|||
<Grid ColumnDefinitions="Auto,*,Auto"> |
|||
<RepeatButton Name="PART_LineUpButton" VerticalAlignment="Center" |
|||
Classes="repeat" |
|||
Grid.Row="0" |
|||
Grid.Column="0" |
|||
Focusable="False" |
|||
MinWidth="{DynamicResource ScrollBarThickness}"> |
|||
<Path Data="M 4 0 L 4 8 L 0 4 Z" /> |
|||
</RepeatButton> |
|||
<Track Grid.Row="1" |
|||
Grid.Column="1" |
|||
Minimum="{TemplateBinding Minimum}" |
|||
Maximum="{TemplateBinding Maximum}" |
|||
Value="{TemplateBinding Value, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding ViewportSize}" |
|||
Orientation="{TemplateBinding Orientation}"> |
|||
<Track.DecreaseButton> |
|||
<RepeatButton Name="PART_PageUpButton" |
|||
Classes="repeattrack" |
|||
Focusable="False"/> |
|||
</Track.DecreaseButton> |
|||
<Track.IncreaseButton> |
|||
<RepeatButton Name="PART_PageDownButton" |
|||
Classes="repeattrack" |
|||
Focusable="False"/> |
|||
</Track.IncreaseButton> |
|||
<Thumb Name="thumb"/> |
|||
</Track> |
|||
<RepeatButton Name="PART_LineDownButton" VerticalAlignment="Center" |
|||
Classes="repeat" |
|||
Grid.Row="2" |
|||
Grid.Column="2" |
|||
Focusable="False" |
|||
MinWidth="{DynamicResource ScrollBarThickness}"> |
|||
<Path Data="M 0 0 L 4 4 L 0 8 Z" /> |
|||
</RepeatButton> |
|||
</Grid> |
|||
</Border> |
|||
<Grid x:Name="Root"> |
|||
|
|||
<Border x:Name="HorizontalRoot" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}"> |
|||
<Grid ColumnDefinitions="Auto,*,Auto"> |
|||
|
|||
<Rectangle x:Name="TrackRect" Grid.ColumnSpan="3" Margin="0" /> |
|||
|
|||
<RepeatButton Name="PART_LineUpButton" |
|||
VerticalAlignment="Center" |
|||
Classes="line up" |
|||
Grid.Column="0" |
|||
Focusable="False" |
|||
MinHeight="{DynamicResource ScrollBarSize}" |
|||
Width="{DynamicResource ScrollBarSize}" /> |
|||
|
|||
<Track Grid.Column="1" |
|||
Minimum="{TemplateBinding Minimum}" |
|||
Maximum="{TemplateBinding Maximum}" |
|||
Value="{TemplateBinding Value, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding ViewportSize}" |
|||
Orientation="{TemplateBinding Orientation}"> |
|||
<Track.DecreaseButton> |
|||
<RepeatButton Name="PART_PageUpButton" |
|||
Classes="largeIncrease" |
|||
Focusable="False" /> |
|||
</Track.DecreaseButton> |
|||
<Track.IncreaseButton> |
|||
<RepeatButton Name="PART_PageDownButton" |
|||
Classes="largeIncrease" |
|||
Focusable="False" /> |
|||
</Track.IncreaseButton> |
|||
<Thumb Classes="thumb" |
|||
Opacity="1" |
|||
Height="{DynamicResource ScrollBarSize}" |
|||
MinWidth="{DynamicResource ScrollBarSize}" |
|||
RenderTransformOrigin="50%,100%" /> |
|||
</Track> |
|||
|
|||
<RepeatButton Name="PART_LineDownButton" |
|||
VerticalAlignment="Center" |
|||
Classes="line down" |
|||
Grid.Column="2" |
|||
Focusable="False" |
|||
MinHeight="{DynamicResource ScrollBarSize}" |
|||
Width="{DynamicResource ScrollBarSize}" /> |
|||
|
|||
</Grid> |
|||
</Border> |
|||
|
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="ScrollBar /template/ Thumb#thumb"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlMidHighBrush}"/> |
|||
|
|||
<Style Selector="ScrollBar[IsExpanded=true] /template/ Grid#Root"> |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarBackgroundPointerOver}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ Thumb.thumb"> |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarPanningThumbBackground}" /> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate> |
|||
<Border Background="{TemplateBinding Background}"/> |
|||
<Border x:Name="ThumbVisual" Background="{TemplateBinding Background}" /> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.1" /> |
|||
</Transitions> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="ScrollBar /template/ Thumb#thumb:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlHighBrush}"/> |
|||
|
|||
<Style Selector="ScrollBar:vertical /template/ Thumb.thumb"> |
|||
<Setter Property="RenderTransform" Value="{DynamicResource VerticalSmallScrollThumbScaleTransform}" /> |
|||
</Style> |
|||
<Style Selector="ScrollBar /template/ Thumb#thumb:pressed"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlVeryHighBrush}"/> |
|||
|
|||
<Style Selector="ScrollBar:horizontal /template/ Thumb.thumb"> |
|||
<Setter Property="RenderTransform" Value="{DynamicResource HorizontalSmallScrollThumbScaleTransform}" /> |
|||
</Style> |
|||
<Style Selector="ScrollBar:horizontal /template/ Thumb#thumb"> |
|||
<Setter Property="MinWidth" Value="{DynamicResource ScrollBarThickness}" /> |
|||
<Setter Property="Height" Value="{DynamicResource ScrollBarThumbThickness}" /> |
|||
|
|||
<Style Selector="ScrollBar[IsExpanded=true] /template/ Thumb.thumb"> |
|||
<Setter Property="RenderTransform" Value="none" /> |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbBackgroundColor}" /> |
|||
</Style> |
|||
<Style Selector="ScrollBar:vertical"> |
|||
<Setter Property="Width" Value="{DynamicResource ScrollBarThickness}" /> |
|||
|
|||
<Style Selector="ScrollBar /template/ Thumb.thumb /template/ Border#ThumbVisual"> |
|||
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<CornerRadiusTransition Property="CornerRadius" Duration="0:0:0.1" /> |
|||
</Transitions> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="ScrollBar:vertical /template/ Thumb#thumb"> |
|||
<Setter Property="MinHeight" Value="{DynamicResource ScrollBarThickness}" /> |
|||
<Setter Property="Width" Value="{DynamicResource ScrollBarThumbThickness}" /> |
|||
|
|||
<Style Selector="ScrollBar[IsExpanded=true] /template/ Thumb.thumb /template/ Border#ThumbVisual"> |
|||
<Setter Property="CornerRadius" Value="0" /> |
|||
</Style> |
|||
<Style Selector="ScrollBar /template/ RepeatButton.repeat"> |
|||
<Setter Property="Padding" Value="2" /> |
|||
<Setter Property="BorderThickness" Value="0" /> |
|||
|
|||
<Style Selector="ScrollBar /template/ Thumb.thumb:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbFillPointerOver}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ Thumb.thumb:pressed"> |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbFillPressed}" /> |
|||
</Style> |
|||
<Style Selector="ScrollBar /template/ RepeatButton.repeattrack"> |
|||
|
|||
<Style Selector="ScrollBar /template/ Thumb.thumb:disabled"> |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarThumbFillDisabled}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{TemplateBinding Background}" /> |
|||
<Border x:Name="Root"> |
|||
<Viewbox Width="{DynamicResource ScrollBarButtonArrowIconFontSize}" |
|||
Height="{DynamicResource ScrollBarButtonArrowIconFontSize}"> |
|||
<Path x:Name="Arrow" |
|||
VerticalAlignment="Center" |
|||
HorizontalAlignment="Center" |
|||
Width="20" Height="20" /> |
|||
</Viewbox> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<DoubleTransition Property="Opacity" Duration="0:0:0.1" /> |
|||
</Transitions> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line /template/ Border#Root" > |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrush}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line:pointerover /template/ Border#Root" > |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackgroundPointerOver}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrushPointerOver}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line:pressed /template/ Border#Root" > |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackgroundPressed}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrushPressed}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line:disabled /template/ Border#Root" > |
|||
<Setter Property="Background" Value="{DynamicResource ScrollBarButtonBackgroundPressed}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrushDisabled}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line /template/ Path#Arrow" > |
|||
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForeground}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line:pointerover /template/ Path#Arrow" > |
|||
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForegroundPointerOver}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line:pressed /template/ Path#Arrow" > |
|||
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForegroundPressed}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.line:disabled /template/ Path#Arrow" > |
|||
<Setter Property="Fill" Value="{DynamicResource ScrollBarButtonArrowForegroundDisabled}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar[IsExpanded=true] /template/ RepeatButton.line"> |
|||
<Setter Property="Opacity" Value="1" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton > Path"> |
|||
<Setter Property="Fill" Value="{DynamicResource ThemeForegroundLowBrush}" /> |
|||
<Style Selector="ScrollBar:vertical /template/ RepeatButton.line.up /template/ Path"> |
|||
<Setter Property="Data" |
|||
Value="M 19.091797 14.970703 L 10 5.888672 L 0.908203 14.970703 L 0.029297 14.091797 L 10 4.111328 L 19.970703 14.091797 Z" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton:pointerover > Path"> |
|||
<Setter Property="Fill" Value="{DynamicResource ThemeAccentBrush}" /> |
|||
<Style Selector="ScrollBar:vertical /template/ RepeatButton.line.down /template/ Path"> |
|||
<Setter Property="Data" |
|||
Value="M 18.935547 4.560547 L 19.814453 5.439453 L 10 15.253906 L 0.185547 5.439453 L 1.064453 4.560547 L 10 13.496094 Z" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar:horizontal /template/ RepeatButton.line.up /template/ Path"> |
|||
<Setter Property="Data" Value="M 14.091797 19.970703 L 4.111328 10 L 14.091797 0.029297 L 14.970703 0.908203 L 5.888672 10 L 14.970703 19.091797 Z" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar:horizontal /template/ RepeatButton.line.down /template/ Path"> |
|||
<Setter Property="Data" Value="M 5.029297 19.091797 L 14.111328 10 L 5.029297 0.908203 L 5.908203 0.029297 L 15.888672 10 L 5.908203 19.970703 Z" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ Rectangle#TrackRect"> |
|||
<Setter Property="StrokeThickness" Value="{DynamicResource ScrollBarTrackBorderThemeThickness}" /> |
|||
<Setter Property="Fill" Value="{DynamicResource ScrollBarTrackFill}" /> |
|||
<Setter Property="Stroke" Value="{DynamicResource ScrollBarTrackStroke}" /> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<DoubleTransition Property="Opacity" Duration="0:0:0.1" /> |
|||
</Transitions> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar[IsExpanded=true] /template/ Rectangle#TrackRect"> |
|||
<Setter Property="Fill" Value="{DynamicResource ScrollBarTrackFillPointerOver}" /> |
|||
<Setter Property="Stroke" Value="{DynamicResource ScrollBarTrackStrokePointerOver}" /> |
|||
<Setter Property="Opacity" Value="1" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar /template/ RepeatButton.largeIncrease"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{TemplateBinding Background}" /> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
<Setter Property="Background" Value="Transparent" /> |
|||
<Setter Property="VerticalAlignment" Value="Stretch" /> |
|||
<Setter Property="HorizontalAlignment" Value="Stretch" /> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollBar[IsExpanded=true] /template/ RepeatButton.largeIncrease"> |
|||
<Setter Property="Opacity" Value="1" /> |
|||
</Style> |
|||
|
|||
</Styles> |
|||
|
|||
@ -1,47 +1,69 @@ |
|||
<Style xmlns="https://github.com/avaloniaui" Selector="ScrollViewer"> |
|||
<Setter Property="Background" |
|||
Value="Transparent" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid ColumnDefinitions="*,Auto" RowDefinitions="*,Auto"> |
|||
<ScrollContentPresenter Name="PART_ContentPresenter" |
|||
Background="{TemplateBinding Background}" |
|||
CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}" |
|||
CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}" |
|||
Content="{TemplateBinding Content}" |
|||
Extent="{TemplateBinding Extent, Mode=TwoWay}" |
|||
Margin="{TemplateBinding Padding}" |
|||
Offset="{TemplateBinding Offset, Mode=TwoWay}" |
|||
Viewport="{TemplateBinding Viewport, Mode=TwoWay}"> |
|||
<ScrollContentPresenter.GestureRecognizers> |
|||
<ScrollGestureRecognizer |
|||
CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}" |
|||
CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}" |
|||
/> |
|||
</ScrollContentPresenter.GestureRecognizers> |
|||
</ScrollContentPresenter> |
|||
<ScrollBar Name="horizontalScrollBar" |
|||
Orientation="Horizontal" |
|||
LargeChange="{Binding LargeChange.Width, RelativeSource={RelativeSource TemplatedParent}}" |
|||
SmallChange="{Binding SmallChange.Width, RelativeSource={RelativeSource TemplatedParent}}" |
|||
Maximum="{TemplateBinding HorizontalScrollBarMaximum}" |
|||
Value="{TemplateBinding HorizontalScrollBarValue, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding HorizontalScrollBarViewportSize}" |
|||
Visibility="{TemplateBinding HorizontalScrollBarVisibility}" |
|||
Grid.Row="1" |
|||
Focusable="False"/> |
|||
<ScrollBar Name="verticalScrollBar" |
|||
Orientation="Vertical" |
|||
LargeChange="{Binding LargeChange.Height, RelativeSource={RelativeSource TemplatedParent}}" |
|||
SmallChange="{Binding SmallChange.Height, RelativeSource={RelativeSource TemplatedParent}}" |
|||
Maximum="{TemplateBinding VerticalScrollBarMaximum}" |
|||
Value="{TemplateBinding VerticalScrollBarValue, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding VerticalScrollBarViewportSize}" |
|||
Visibility="{TemplateBinding VerticalScrollBarVisibility}" |
|||
Grid.Column="1" |
|||
Focusable="False"/> |
|||
<Panel Grid.Row="1" Grid.Column="1" Background="{DynamicResource ThemeControlMidBrush}"/> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
|
|||
<Style Selector="ScrollViewer"> |
|||
<Setter Property="Background" |
|||
Value="Transparent" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid ColumnDefinitions="*,Auto" RowDefinitions="*,Auto"> |
|||
<ScrollContentPresenter Name="PART_ContentPresenter" |
|||
Grid.Row="0" |
|||
Grid.Column="0" |
|||
Grid.RowSpan="2" |
|||
Grid.ColumnSpan="2" |
|||
Background="{TemplateBinding Background}" |
|||
CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}" |
|||
CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}" |
|||
Content="{TemplateBinding Content}" |
|||
Extent="{TemplateBinding Extent, Mode=TwoWay}" |
|||
Margin="{TemplateBinding Padding}" |
|||
Offset="{TemplateBinding Offset, Mode=TwoWay}" |
|||
Viewport="{TemplateBinding Viewport, Mode=TwoWay}"> |
|||
<ScrollContentPresenter.GestureRecognizers> |
|||
<ScrollGestureRecognizer |
|||
CanHorizontallyScroll="{TemplateBinding CanHorizontallyScroll}" |
|||
CanVerticallyScroll="{TemplateBinding CanVerticallyScroll}" /> |
|||
</ScrollContentPresenter.GestureRecognizers> |
|||
</ScrollContentPresenter> |
|||
<ScrollBar Name="PART_HorizontalScrollBar" |
|||
AllowAutoHide="{TemplateBinding AllowAutoHide}" |
|||
Orientation="Horizontal" |
|||
LargeChange="{Binding LargeChange.Width, RelativeSource={RelativeSource TemplatedParent}}" |
|||
SmallChange="{Binding SmallChange.Width, RelativeSource={RelativeSource TemplatedParent}}" |
|||
Maximum="{TemplateBinding HorizontalScrollBarMaximum}" |
|||
Value="{TemplateBinding HorizontalScrollBarValue, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding HorizontalScrollBarViewportSize}" |
|||
Visibility="{TemplateBinding HorizontalScrollBarVisibility}" |
|||
Grid.Row="1" |
|||
Focusable="False" /> |
|||
<ScrollBar Name="PART_VerticalScrollBar" |
|||
AllowAutoHide="{TemplateBinding AllowAutoHide}" |
|||
Orientation="Vertical" |
|||
LargeChange="{Binding LargeChange.Height, RelativeSource={RelativeSource TemplatedParent}}" |
|||
SmallChange="{Binding SmallChange.Height, RelativeSource={RelativeSource TemplatedParent}}" |
|||
Maximum="{TemplateBinding VerticalScrollBarMaximum}" |
|||
Value="{TemplateBinding VerticalScrollBarValue, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding VerticalScrollBarViewportSize}" |
|||
Visibility="{TemplateBinding VerticalScrollBarVisibility}" |
|||
Grid.Column="1" |
|||
Focusable="False" /> |
|||
<Panel x:Name="PART_ScrollBarsSeparator" Grid.Row="1" Grid.Column="1" Background="{DynamicResource ScrollViewerScrollBarsSeparatorBackground}" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollViewer /template/ Panel#PART_ScrollBarsSeparator"> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<DoubleTransition Property="Opacity" Duration="0:0:0.1" /> |
|||
</Transitions> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="ScrollViewer[IsExpanded=true] /template/ Panel#PART_ScrollBarsSeparator"> |
|||
<Setter Property="Opacity" Value="1" /> |
|||
</Style> |
|||
|
|||
</Styles> |
|||
|
|||
@ -1,62 +1,61 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Style Selector="TabControl"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border |
|||
Margin="{TemplateBinding Margin}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
Background="{TemplateBinding Background}" |
|||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}" |
|||
VerticalAlignment="{TemplateBinding VerticalAlignment}"> |
|||
<DockPanel> |
|||
<ItemsPresenter |
|||
Name="PART_ItemsPresenter" |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Design.PreviewWith> |
|||
<Border Width="400"> |
|||
<TabControl> |
|||
<TabItem Header="Arch"> |
|||
<Border Background="AntiqueWhite" |
|||
Height="100"> |
|||
<TextBlock Text="Content" Foreground="Black" FontSize="20"/> |
|||
</Border> |
|||
</TabItem> |
|||
<TabItem Header="Leaf"> |
|||
<Border Background="Green" |
|||
Height="100" /> |
|||
</TabItem> |
|||
<TabItem Header="Disabled" |
|||
IsEnabled="False" /> |
|||
</TabControl> |
|||
</Border> |
|||
</Design.PreviewWith> |
|||
|
|||
<Style Selector="TabControl"> |
|||
<Setter Property="Margin" Value="0" /> |
|||
<Setter Property="Padding" Value="{DynamicResource PivotItemMargin}" /> |
|||
<Setter Property="Background" Value="{DynamicResource PivotBackground}" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Margin="{TemplateBinding Margin}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
Background="{TemplateBinding Background}" |
|||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}" |
|||
VerticalAlignment="{TemplateBinding VerticalAlignment}"> |
|||
<DockPanel> |
|||
<ItemsPresenter Name="PART_ItemsPresenter" |
|||
Items="{TemplateBinding Items}" |
|||
ItemsPanel="{TemplateBinding ItemsPanel}" |
|||
ItemTemplate="{TemplateBinding ItemTemplate}"> |
|||
</ItemsPresenter> |
|||
<ContentPresenter |
|||
Name="PART_SelectedContentHost" |
|||
Margin="{TemplateBinding Padding}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
Content="{TemplateBinding SelectedContent}" |
|||
ContentTemplate="{TemplateBinding SelectedContentTemplate}"> |
|||
</ContentPresenter> |
|||
</DockPanel> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="TabControl[TabStripPlacement=Top]"> |
|||
<Setter Property="Padding" Value="0 4 0 0"/> |
|||
</Style> |
|||
<Style Selector="TabControl[TabStripPlacement=Top] /template/ ItemsPresenter#PART_ItemsPresenter"> |
|||
<Setter Property="DockPanel.Dock" Value="Top"/> |
|||
</Style> |
|||
<Style Selector="TabControl[TabStripPlacement=Bottom] /template/ ItemsPresenter#PART_ItemsPresenter"> |
|||
<Setter Property="DockPanel.Dock" Value="Bottom"/> |
|||
</Style> |
|||
<Style Selector="TabControl[TabStripPlacement=Bottom]"> |
|||
<Setter Property="Padding" Value="0 0 0 4"/> |
|||
</Style> |
|||
<Style Selector="TabControl[TabStripPlacement=Left] /template/ ItemsPresenter#PART_ItemsPresenter"> |
|||
<Setter Property="DockPanel.Dock" Value="Left"/> |
|||
</Style> |
|||
<Style Selector="TabControl[TabStripPlacement=Left] /template/ ItemsPresenter#PART_ItemsPresenter > WrapPanel"> |
|||
<Setter Property="Orientation" Value="Vertical"/> |
|||
</Style> |
|||
<Style Selector="TabControl[TabStripPlacement=Left]"> |
|||
<Setter Property="Padding" Value="4 0 0 0"/> |
|||
</Style> |
|||
<Style Selector="TabControl[TabStripPlacement=Right] /template/ ItemsPresenter#PART_ItemsPresenter"> |
|||
<Setter Property="DockPanel.Dock" Value="Right"/> |
|||
</Style> |
|||
<Style Selector="TabControl[TabStripPlacement=Right] /template/ ItemsPresenter#PART_ItemsPresenter > WrapPanel"> |
|||
<Setter Property="Orientation" Value="Vertical"/> |
|||
</Style> |
|||
<Style Selector="TabControl[TabStripPlacement=Right]"> |
|||
<Setter Property="Padding" Value="0 0 4 0"/> |
|||
</Style> |
|||
ItemTemplate="{TemplateBinding ItemTemplate}" |
|||
DockPanel.Dock="{TemplateBinding TabStripPlacement}"/> |
|||
<ContentPresenter Name="PART_SelectedContentHost" |
|||
Margin="{TemplateBinding Padding}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
Content="{TemplateBinding SelectedContent}" |
|||
ContentTemplate="{TemplateBinding SelectedContentTemplate}" /> |
|||
</DockPanel> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="TabControl[TabStripPlacement=Left] /template/ ItemsPresenter#PART_ItemsPresenter > WrapPanel"> |
|||
<Setter Property="Orientation" Value="Vertical" /> |
|||
</Style> |
|||
<Style Selector="TabControl[TabStripPlacement=Right] /template/ ItemsPresenter#PART_ItemsPresenter > WrapPanel"> |
|||
<Setter Property="Orientation" Value="Vertical" /> |
|||
</Style> |
|||
<Style Selector="TabControl[TabStripPlacement=Top] /template/ ItemsPresenter#PART_ItemsPresenter"> |
|||
<Setter Property="Margin" Value="0 0 0 2" /> |
|||
</Style> |
|||
</Styles> |
|||
|
|||
@ -1,45 +1,130 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui"> |
|||
<Style Selector="TabItem"> |
|||
<Setter Property="Background" Value="Transparent"/> |
|||
<Setter Property="FontSize" Value="{DynamicResource FontSizeLarge}"/> |
|||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundLightBrush}"/> |
|||
<Setter Property="HorizontalContentAlignment" Value="Left"/> |
|||
<Setter Property="Padding" Value="8"/> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<ContentPresenter |
|||
Name="PART_ContentPresenter" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
ContentTemplate="{TemplateBinding HeaderTemplate}" |
|||
Content="{TemplateBinding Header}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
Margin="{TemplateBinding Margin}" |
|||
Padding="{TemplateBinding Padding}"/> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="TabItem:disabled"> |
|||
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}"/> |
|||
</Style> |
|||
<Style Selector="TabItem:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlHighlightMidBrush}"/> |
|||
</Style> |
|||
<Style Selector="TabItem:selected"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush4}"/> |
|||
</Style> |
|||
<Style Selector="TabItem:selected:focus"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/> |
|||
</Style> |
|||
<Style Selector="TabItem:selected:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/> |
|||
</Style> |
|||
<Style Selector="TabItem:selected:focus:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush2}"/> |
|||
</Style> |
|||
<Style Selector="TabItem[TabStripPlacement=Right]"> |
|||
<Setter Property="HorizontalContentAlignment" Value="Right"/> |
|||
</Style> |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Design.PreviewWith> |
|||
<Border Padding="20"> |
|||
<StackPanel Spacing="20"> |
|||
<TabItem Header="Leaf" /> |
|||
<TabItem Header="Arch" IsSelected="True" /> |
|||
</StackPanel> |
|||
</Border> |
|||
</Design.PreviewWith> |
|||
<Styles.Resources> |
|||
<x:Double x:Key="TabItemMinHeight">48</x:Double> |
|||
<x:Double x:Key="TabItemVerticalPipeHeight">24</x:Double> |
|||
<x:Double x:Key="TabItemPipeThickness">2</x:Double> |
|||
</Styles.Resources> |
|||
|
|||
<Style Selector="TabItem"> |
|||
<Setter Property="FontSize" Value="{DynamicResource PivotHeaderItemFontSize}" /> |
|||
<Setter Property="FontWeight" Value="{DynamicResource PivotHeaderItemThemeFontWeight}" /> |
|||
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundUnselected}" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource PivotHeaderItemForegroundUnselected}" /> |
|||
<Setter Property="Padding" Value="{DynamicResource PivotHeaderItemMargin}" /> |
|||
<Setter Property="Margin" Value="0" /> |
|||
<Setter Property="MinHeight" Value="{DynamicResource TabItemMinHeight}" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Name="PART_LayoutRoot" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
Padding="{TemplateBinding Padding}"> |
|||
<Panel> |
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
ContentTemplate="{TemplateBinding HeaderTemplate}" |
|||
Content="{TemplateBinding Header}" |
|||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
TextBlock.FontFamily="{TemplateBinding FontFamily}" |
|||
TextBlock.FontSize="{TemplateBinding FontSize}" |
|||
TextBlock.FontWeight="{TemplateBinding FontWeight}" /> |
|||
<Border Name="PART_SelectedPipe" |
|||
CornerRadius="{DynamicResource ControlCornerRadius}" |
|||
Background="{DynamicResource PivotHeaderItemSelectedPipeFill}" /> |
|||
</Panel> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<!-- Nornal state --> |
|||
<Style Selector="TabItem /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{Binding $parent[TabItem].Background}" /> |
|||
</Style> |
|||
<Style Selector="TabItem /template/ Border#PART_SelectedPipe"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
|
|||
<!-- Selected state --> |
|||
<!-- We don't use selector to PART_LayoutRoot, so developer can override selected item background with TabStripItem.Background --> |
|||
<Style Selector="TabItem:selected"> |
|||
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundSelected}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource PivotHeaderItemForegroundSelected}" /> |
|||
</Style> |
|||
<Style Selector="TabItem:selected /template/ Border#PART_SelectedPipe"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
|
|||
<!-- PointerOver state --> |
|||
<Style Selector="TabItem:pointerover /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundUnselectedPointerOver}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource PivotHeaderItemForegroundUnselectedPointerOver}" /> |
|||
</Style> |
|||
|
|||
<!-- Selected PointerOver state --> |
|||
<Style Selector="TabItem:selected:pointerover /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundSelectedPointerOver}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource PivotHeaderItemForegroundSelectedPointerOver}" /> |
|||
</Style> |
|||
|
|||
<!-- Pressed state --> |
|||
<Style Selector="TabItem:pressed /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundUnselectedPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource PivotHeaderItemForegroundUnselectedPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Selected Pressed state --> |
|||
<Style Selector="TabItem:pressed /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundSelectedPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource PivotHeaderItemForegroundSelectedPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Disabled state --> |
|||
<Style Selector="TabItem:disabled /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundDisabled}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource PivotHeaderItemForegroundDisabled}" /> |
|||
</Style> |
|||
|
|||
<!-- TabStripPlacement States Group --> |
|||
<Style Selector="TabItem[TabStripPlacement=Left] /template/ Border#PART_SelectedPipe"> |
|||
<Setter Property="Width" Value="{StaticResource TabItemPipeThickness}" /> |
|||
<Setter Property="Height" Value="{StaticResource TabItemVerticalPipeHeight}" /> |
|||
<Setter Property="Margin" Value="0,0,2,0" /> |
|||
<Setter Property="HorizontalAlignment" Value="Left" /> |
|||
<Setter Property="VerticalAlignment" Value="Center" /> |
|||
</Style> |
|||
<Style Selector="TabItem[TabStripPlacement=Left] /template/ ContentPresenter#PART_ContentPresenter"> |
|||
<Setter Property="Margin" Value="8,0,0,0" /> |
|||
</Style> |
|||
|
|||
<Style Selector="TabItem[TabStripPlacement=Top] /template/ Border#PART_SelectedPipe, TabItem[TabStripPlacement=Bottom] /template/ Border#PART_SelectedPipe"> |
|||
<Setter Property="Height" Value="{StaticResource TabItemPipeThickness}" /> |
|||
<Setter Property="Margin" Value="0,0,0,2" /> |
|||
<Setter Property="HorizontalAlignment" Value="Stretch" /> |
|||
<Setter Property="VerticalAlignment" Value="Bottom" /> |
|||
</Style> |
|||
|
|||
<Style Selector="TabItem[TabStripPlacement=Right] /template/ Border#PART_SelectedPipe"> |
|||
<Setter Property="Width" Value="{StaticResource TabItemPipeThickness}" /> |
|||
<Setter Property="Height" Value="{StaticResource TabItemVerticalPipeHeight}" /> |
|||
<Setter Property="Margin" Value="2,0,0,0" /> |
|||
<Setter Property="HorizontalAlignment" Value="Right" /> |
|||
<Setter Property="VerticalAlignment" Value="Center" /> |
|||
</Style> |
|||
<Style Selector="TabItem[TabStripPlacement=Right] /template/ ContentPresenter#PART_ContentPresenter"> |
|||
<Setter Property="Margin" Value="0,0,8,0" /> |
|||
</Style> |
|||
<Style Selector="TabItem[TabStripPlacement=Right]"> |
|||
<Setter Property="HorizontalContentAlignment" Value="Right" /> |
|||
</Style> |
|||
</Styles> |
|||
|
|||
@ -1,23 +1,103 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui"> |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Design.PreviewWith> |
|||
<Border Padding="20"> |
|||
<StackPanel Spacing="20"> |
|||
<TabStripItem>Leaf</TabStripItem> |
|||
<TabStripItem IsSelected="True">Arch</TabStripItem> |
|||
</StackPanel> |
|||
</Border> |
|||
</Design.PreviewWith> |
|||
<Styles.Resources> |
|||
<x:Double x:Key="TabStripItemMinHeight">48</x:Double> |
|||
<x:Double x:Key="TabStripItemPipeThickness">2</x:Double> |
|||
</Styles.Resources> |
|||
|
|||
<Style Selector="TabStripItem"> |
|||
<Setter Property="Background" Value="Transparent"/> |
|||
<Setter Property="FontSize" Value="{DynamicResource FontSizeLarge}"/> |
|||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundLowBrush}"/> |
|||
<Setter Property="FontSize" Value="{DynamicResource PivotHeaderItemFontSize}" /> |
|||
<Setter Property="FontWeight" Value="{DynamicResource PivotHeaderItemThemeFontWeight}" /> |
|||
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundUnselected}" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource PivotHeaderItemForegroundUnselected}" /> |
|||
<Setter Property="Padding" Value="{DynamicResource PivotHeaderItemMargin}" /> |
|||
<Setter Property="Margin" Value="0" /> |
|||
<Setter Property="MinHeight" Value="{DynamicResource TabStripItemMinHeight}" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding Content}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
Padding="{TemplateBinding Padding}"/> |
|||
<Border Name="PART_LayoutRoot" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
Padding="{TemplateBinding Padding}"> |
|||
<Panel> |
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding Content}" |
|||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
TextBlock.FontFamily="{TemplateBinding FontFamily}" |
|||
TextBlock.FontSize="{TemplateBinding FontSize}" |
|||
TextBlock.FontWeight="{TemplateBinding FontWeight}" /> |
|||
<Border Name="PART_SelectedPipe" |
|||
CornerRadius="{DynamicResource ControlCornerRadius}" |
|||
Background="{DynamicResource PivotHeaderItemSelectedPipeFill}" /> |
|||
</Panel> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
|
|||
<!-- Nornal state --> |
|||
<Style Selector="TabStripItem /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{Binding $parent[TabStripItem].Background}" /> |
|||
</Style> |
|||
<Style Selector="TabStripItem /template/ Border#PART_SelectedPipe"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="TabStripItem /template/ Border#PART_SelectedPipe, TabItem[TabStripPlacement=Bottom] /template/ Border#PART_SelectedPipe"> |
|||
<Setter Property="Height" Value="{StaticResource TabStripItemPipeThickness}" /> |
|||
<Setter Property="Margin" Value="0,0,0,2" /> |
|||
<Setter Property="HorizontalAlignment" Value="Stretch" /> |
|||
<Setter Property="VerticalAlignment" Value="Bottom" /> |
|||
</Style> |
|||
|
|||
<!-- Selected state --> |
|||
<!-- We don't use selector to PART_LayoutRoot, so developer can override selected item background with TabStripItem.Background --> |
|||
<Style Selector="TabStripItem:selected"> |
|||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}"/> |
|||
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundSelected}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource PivotHeaderItemForegroundSelected}" /> |
|||
</Style> |
|||
<Style Selector="TabStripItem:selected /template/ Border#PART_SelectedPipe"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
|
|||
<!-- PointerOver state --> |
|||
<Style Selector="TabStripItem:pointerover /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundUnselectedPointerOver}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource PivotHeaderItemForegroundUnselectedPointerOver}" /> |
|||
</Style> |
|||
|
|||
<!-- Selected PointerOver state --> |
|||
<Style Selector="TabStripItem:selected:pointerover /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundSelectedPointerOver}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource PivotHeaderItemForegroundSelectedPointerOver}" /> |
|||
</Style> |
|||
|
|||
<!-- Pressed state --> |
|||
<Style Selector="TabStripItem:pressed /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundUnselectedPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource PivotHeaderItemForegroundUnselectedPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Selected Pressed state --> |
|||
<Style Selector="TabStripItem:pressed /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundSelectedPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource PivotHeaderItemForegroundSelectedPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Disabled state --> |
|||
<Style Selector="TabStripItem:disabled /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundDisabled}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource PivotHeaderItemForegroundDisabled}" /> |
|||
</Style> |
|||
</Styles> |
|||
</Styles> |
|||
|
|||
@ -1,92 +1,180 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls"> |
|||
<Style Selector="TreeViewItem"> |
|||
<Style.Resources> |
|||
<converters:MarginMultiplierConverter Indent="16" Left="True" x:Key="LeftMarginConverter" /> |
|||
</Style.Resources> |
|||
<Setter Property="Padding" Value="2"/> |
|||
<Setter Property="Background" Value="Transparent"/> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<StackPanel> |
|||
<Border Name="SelectionBorder" |
|||
Focusable="True" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
TemplatedControl.IsTemplateFocusTarget="True"> |
|||
<Grid Name="PART_Header" |
|||
ColumnDefinitions="16, *" |
|||
Margin="{TemplateBinding Level, Mode=OneWay, Converter={StaticResource LeftMarginConverter}}" > |
|||
<ToggleButton Name="expander" |
|||
Focusable="False" |
|||
IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}"/> |
|||
<ContentPresenter Name="PART_HeaderPresenter" |
|||
Focusable="False" |
|||
Content="{TemplateBinding Header}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalAlignment}" |
|||
Padding="{TemplateBinding Padding}" |
|||
Grid.Column="1"/> |
|||
</Grid> |
|||
</Border> |
|||
<ItemsPresenter Name="PART_ItemsPresenter" |
|||
IsVisible="{TemplateBinding IsExpanded}" |
|||
Items="{TemplateBinding Items}" |
|||
ItemsPanel="{TemplateBinding ItemsPanel}"/> |
|||
</StackPanel> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="TreeViewItem /template/ ToggleButton#expander"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="Transparent" |
|||
Width="14" |
|||
Height="12" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center"> |
|||
<Path Fill="{DynamicResource ThemeForegroundBrush}" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center" |
|||
Data="M 0 2 L 4 6 L 0 10 Z"/> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Design.PreviewWith> |
|||
<Border Padding="20" |
|||
MinWidth="300"> |
|||
<TreeView> |
|||
<TreeViewItem Header="Level 1"> |
|||
<TreeViewItem Header="Level 2.1"> |
|||
<TreeViewItem Header="Level 3.1" /> |
|||
<TreeViewItem Header="Level 3.2"> |
|||
<TreeViewItem Header="Level 4" /> |
|||
</TreeViewItem> |
|||
</TreeViewItem> |
|||
<TreeViewItem Header="Level 2.2" |
|||
IsEnabled="False" /> |
|||
</TreeViewItem> |
|||
</TreeView> |
|||
</Border> |
|||
</Design.PreviewWith> |
|||
|
|||
<Style Selector="TreeViewItem /template/ ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="Padding" Value="2"/> |
|||
</Style> |
|||
<Styles.Resources> |
|||
<x:Double x:Key="TreeViewItemIndent">16</x:Double> |
|||
<x:Double x:Key="TreeViewItemExpandCollapseChevronSize">12</x:Double> |
|||
<Thickness x:Key="TreeViewItemExpandCollapseChevronMargin">12, 0, 12, 0</Thickness> |
|||
<StreamGeometry x:Key="TreeViewItemCollapsedChevronPathData">M 1,0 10,10 l -9,10 -1,-1 L 8,10 -0,1 Z</StreamGeometry> |
|||
<StreamGeometry x:Key="TreeViewItemExpandedChevronPathData">M0,1 L10,10 20,1 19,0 10,8 1,0 Z</StreamGeometry> |
|||
<converters:MarginMultiplierConverter Indent="{StaticResource TreeViewItemIndent}" |
|||
Left="True" |
|||
x:Key="TreeViewItemLeftMarginConverter" /> |
|||
</Styles.Resources> |
|||
|
|||
<Style Selector="TreeViewItem /template/ Border#SelectionBorder:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlHighlightMidBrush}"/> |
|||
</Style> |
|||
<Style Selector="ToggleButton.ExpandCollapseChevron"> |
|||
<Setter Property="Margin" Value="0" /> |
|||
<Setter Property="Width" Value="{StaticResource TreeViewItemExpandCollapseChevronSize}" /> |
|||
<Setter Property="Height" Value="{StaticResource TreeViewItemExpandCollapseChevronSize}" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="Transparent" |
|||
Width="{TemplateBinding Width}" |
|||
Height="{TemplateBinding Height}" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center"> |
|||
<Path x:Name="ChevronPath" |
|||
Fill="{DynamicResource TreeViewItemForeground}" |
|||
Stretch="Uniform" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center" /> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush4}"/> |
|||
</Style> |
|||
<Style Selector="TreeViewItem"> |
|||
<Style.Resources /> |
|||
<Setter Property="Padding" Value="0" /> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrush}" /> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource TreeViewItemBorderThemeThickness}" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource TreeViewItemForeground}" /> |
|||
<Setter Property="MinHeight" Value="{DynamicResource TreeViewItemMinHeight}" /> |
|||
<Setter Property="VerticalAlignment" Value="Center" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<StackPanel> |
|||
<Border Name="PART_LayoutRoot" |
|||
Classes="TreeViewItemLayoutRoot" |
|||
Focusable="True" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
MinHeight="{TemplateBinding MinHeight}" |
|||
TemplatedControl.IsTemplateFocusTarget="True"> |
|||
<Grid Name="PART_Header" |
|||
ColumnDefinitions="Auto, *" |
|||
Margin="{TemplateBinding Level, Mode=OneWay, Converter={StaticResource TreeViewItemLeftMarginConverter}}"> |
|||
<Panel Name="PART_ExpandCollapseChevronContainer" |
|||
Margin="{StaticResource TreeViewItemExpandCollapseChevronMargin}"> |
|||
<ToggleButton Name="PART_ExpandCollapseChevron" |
|||
Classes="ExpandCollapseChevron" |
|||
Focusable="False" |
|||
IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}" /> |
|||
</Panel> |
|||
<ContentPresenter Name="PART_HeaderPresenter" |
|||
Grid.Column="1" |
|||
Focusable="False" |
|||
Content="{TemplateBinding Header}" |
|||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}" |
|||
VerticalAlignment="{TemplateBinding VerticalAlignment}" |
|||
Margin="{TemplateBinding Padding}" /> |
|||
</Grid> |
|||
</Border> |
|||
<ItemsPresenter Name="PART_ItemsPresenter" |
|||
IsVisible="{TemplateBinding IsExpanded}" |
|||
Items="{TemplateBinding Items}" |
|||
ItemsPanel="{TemplateBinding ItemsPanel}" /> |
|||
</StackPanel> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder:focus"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/> |
|||
</Style> |
|||
<!-- PointerOver state --> |
|||
<Style Selector="TreeViewItem /template/ Border#PART_LayoutRoot:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackgroundPointerOver}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrushPointerOver}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem /template/ Border#PART_LayoutRoot:pointerover > ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TreeViewItemForegroundPointerOver}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/> |
|||
</Style> |
|||
<!-- Pressed state --> |
|||
<Style Selector="TreeViewItem:pressed /template/ Border#PART_LayoutRoot:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackgroundPressed}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrushPressed}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:pressed /template/ Border#PART_LayoutRoot:pointerover > ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TreeViewItemForegroundPressed}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="TreeViewItem:selected /template/ Border#SelectionBorder:pointerover:focus"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush2}"/> |
|||
</Style> |
|||
<!-- Disabled state --> |
|||
<Style Selector="TreeViewItem:disabled /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackgroundDisabled}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrushDisabled}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:disabled /template/ Border#PART_LayoutRoot > ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TreeViewItemForegroundDisabled}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="TreeViewItem /template/ ToggleButton#expander:checked"> |
|||
<Setter Property="RenderTransform"> |
|||
<RotateTransform Angle="45"/> |
|||
</Setter> |
|||
</Style> |
|||
<!-- Selected state --> |
|||
<Style Selector="TreeViewItem:selected /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackgroundSelected}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrushSelected}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:selected /template/ Border#PART_LayoutRoot > ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TreeViewItemForegroundSelected}" /> |
|||
</Style> |
|||
|
|||
<!-- Selected PointerOver state --> |
|||
<Style Selector="TreeViewItem:selected /template/ Border#PART_LayoutRoot:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackgroundSelectedPointerOver}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrushSelectedPointerOver}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:selected /template/ Border#PART_LayoutRoot:pointerover > ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TreeViewItemForegroundSelectedPointerOver}" /> |
|||
</Style> |
|||
|
|||
<!-- Selected Pressed state --> |
|||
<Style Selector="TreeViewItem:pressed:selected /template/ Border#PART_LayoutRoot:pointerover"> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackgroundSelectedPressed}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrushSelectedPressed}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:pressed:selected /template/ Border#PART_LayoutRoot:pointerover > ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TreeViewItemForegroundSelectedPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Disabled Selected state --> |
|||
<Style Selector="TreeViewItem:disabled:selected /template/ Border#PART_LayoutRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackgroundSelectedDisabled}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrushSelectedDisabled}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:disabled:selected /template/ Border#PART_LayoutRoot > ContentPresenter#PART_HeaderPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TreeViewItemForegroundSelectedDisabled}" /> |
|||
</Style> |
|||
|
|||
<!-- ExpandCollapseChevron Group states --> |
|||
<Style Selector="ToggleButton.ExpandCollapseChevron /template/ Path#ChevronPath"> |
|||
<Setter Property="Data" Value="{StaticResource TreeViewItemCollapsedChevronPathData}" /> |
|||
</Style> |
|||
<Style Selector="ToggleButton.ExpandCollapseChevron:checked /template/ Path#ChevronPath"> |
|||
<Setter Property="Data" Value="{StaticResource TreeViewItemExpandedChevronPathData}" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:empty /template/ ToggleButton#PART_ExpandCollapseChevron"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="TreeViewItem:empty /template/ Panel#PART_ExpandCollapseChevronContainer"> |
|||
<Setter Property="Width" Value="{StaticResource TreeViewItemExpandCollapseChevronSize}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="TreeViewItem:empty /template/ ToggleButton#expander"> |
|||
<Setter Property="IsVisible" Value="False"/> |
|||
</Style> |
|||
</Styles> |
|||
|
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue