Files
Speckle.Material.Avalonia/Material.Styles/TreeView.xaml
T

213 lines
12 KiB
XML

<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters1="clr-namespace:Material.Styles.Converters"
xmlns:ripple="clr-namespace:Material.Ripple;assembly=Material.Ripple"
xmlns:naming="clr-namespace:Material.Styles.Resources.Naming"
xmlns:parameters="clr-namespace:Material.Styles.Converters.Parameters">
<Styles.Resources>
<converters1:BrushRoundConverter x:Key="BrushRoundConverter" />
<converters1:MarginMultiplyConverter x:Key="MarginCreator" />
<parameters:MarginMultiplyParameter x:Key="TreeItemContentMargin" LeftMultiplier="28" />
</Styles.Resources>
<Style Selector="TreeView">
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="BorderBrush" Value="{x:Null}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="{DynamicResource MaterialDesignBody}" />
<Setter Property="Padding" Value="0" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border Name="{x:Static naming:PartNames.PartRootBorder}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ScrollViewer Name="{x:Static naming:PartNames.PartScrollViewer}"
Focusable="false"
Padding="{TemplateBinding Padding}"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
<ItemsPresenter Name="{x:Static naming:PartNames.PartItemsPresenter}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
ItemTemplate="{TemplateBinding ItemTemplate}"/>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style Selector="TreeView:disabled">
<Setter Property="Opacity" Value="0.56" />
</Style>
<Style Selector="TreeViewItem">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="8" />
<Setter Property="ClipToBounds" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border Name="{x:Static naming:PartNames.PartRootBorder}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<StackPanel Name="{x:Static naming:PartNames.PartRootPanel}">
<Panel Name="{x:Static naming:PartNames.PartInnerPanel}">
<Border Name="{x:Static naming:PartNames.PartBehaviourEffect}"/>
<DockPanel Name="{x:Static naming:PartNames.PartContentPanel}"
Margin="{TemplateBinding Level,
Converter={StaticResource MarginCreator},
ConverterParameter={StaticResource TreeItemContentMargin}}">
<ToggleButton DockPanel.Dock="Left"
Name="{x:Static naming:PartNames.PartExpanderButton}"
IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}"
Classes="material-tree-view-item-expander"/>
<ContentPresenter DockPanel.Dock="Right"
Name="{x:Static naming:PartNames.PartHeaderPresenter}"
Content="{TemplateBinding Header}"
Padding="{TemplateBinding Padding}"/>
</DockPanel>
</Panel>
<ItemsPresenter Name="ItemsHost"
IsVisible="{TemplateBinding IsExpanded}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}" />
</StackPanel>
</Border>
<!-- Margin="16 0 0 0"
<Grid ColumnDefinitions="Auto,Auto,*" RowDefinitions="Auto,Auto,*">
<Rectangle Opacity="0" Fill="Red"
Grid.RowSpan="3" Grid.ColumnSpan="3" />
<ToggleButton Grid.Row="0" Grid.Column="0" Name="Expander" ClickMode="Press"
IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}"
Classes="MaterialDesignExpandCollapseToggleStyle"
Foreground="{TemplateBinding Foreground}"
Margin="8 0 8 0"
VerticalAlignment="Center" />
<Border Name="MouseOverBorder"
Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2"
IsHitTestVisible="False"
Background="{TemplateBinding Foreground, Converter={StaticResource BrushRoundConverter}}" />
<Border Name="SelectedBorder"
Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2"
IsHitTestVisible="False"
Background="{TemplateBinding Foreground, Converter={StaticResource BrushRoundConverter}}" />
<Grid Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" Name="ContentGrid" Background="Transparent">
<ripple:RippleEffect
RippleFill="{TemplateBinding Foreground, Converter={StaticResource BrushRoundConverter}}"
Focusable="False">
<ContentPresenter Name="PART_Header" Margin="{Binding $parent[TreeViewItem].Padding}"
Content="{TemplateBinding Header}" />
</ripple:RippleEffect>
</Grid>
<ItemsPresenter Name="ItemsHost"
Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2"
Margin="-16 0 0 0"
VerticalAlignment="Top"
IsVisible="{TemplateBinding IsExpanded}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}" />
</Grid>-->
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Transitions -->
<Style Selector="TreeViewItem:not(.no-transitions) /template/ Border#PART_BehaviourEffect">
<Setter Property="Transitions">
<Transitions>
<DoubleTransition Duration="0:0:0.25" Property="Opacity" Easing="LinearEasing" />
</Transitions>
</Setter>
</Style>
<Style Selector="TreeViewItem:disabled">
<Setter Property="Opacity" Value="0.56" />
</Style>
<Style Selector="TreeViewItem:empty /template/ ToggleButton#PART_ExpanderButton">
<Setter Property="IsVisible" Value="False" />
</Style>
<!-- Statements for transition elements -->
<!-- Default statement - behaviour effect border should have invisible (full-transparent) -->
<Style Selector="TreeViewItem /template/ Border#PART_BehaviourEffect">
<Setter Property="Background" Value="{TemplateBinding TemplatedControl.Foreground}"/>
<Setter Property="Opacity" Value="0" />
</Style>
<!-- Set behaviour effect highlight to semi-transparent barely visible when cursor hovering TreeViewItem -->
<Style Selector="TreeViewItem:pointerover /template/ Border#PART_BehaviourEffect">
<Setter Property="Opacity" Value="0.1" />
</Style>
<!-- Set behaviour effect highlight to semi-transparent visible when user selected TreeViewItem -->
<Style Selector="TreeViewItem:selected /template/ Border#PART_BehaviourEffect">
<Setter Property="Opacity" Value="0.3" />
</Style>
<Style Selector="ToggleButton.material-tree-view-item-expander">
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Focusable" Value="False" />
<Setter Property="CornerRadius" Value="16"/>
<Setter Property="Width" Value="24"/>
<Setter Property="Height" Value="24"/>
<Setter Property="Margin" Value="4,0,0,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border Background="Transparent"
CornerRadius="{TemplateBinding CornerRadius}"
ClipToBounds="True">
<ripple:RippleEffect
Name="{x:Static naming:PartNames.PartRipple}"
RippleFill="{TemplateBinding Foreground,
Converter={StaticResource BrushRoundConverter}}">
<Canvas Width="24" Height="24">
<Path Data="M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"
Name="ExpandPath"
Fill="{TemplateBinding Foreground}"
Stroke="{TemplateBinding Foreground}" RenderTransformOrigin="50%,50%" />
</Canvas>
</ripple:RippleEffect>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style Selector="ToggleButton.material-tree-view-item-expander:not(.no-transitions) /template/ Canvas">
<Setter Property="Transitions">
<Transitions>
<TransformOperationsTransition Duration="0:0:0.25" Property="RenderTransform" Easing="CircularEaseOut" />
</Transitions>
</Setter>
</Style>
<Style Selector="ToggleButton.material-tree-view-item-expander /template/ Canvas">
<Setter Property="RenderTransform" Value="rotate(0deg)" />
</Style>
<!-- Rotate the arrow to 45 degrees when TreeViewItem expanded -->
<Style Selector="ToggleButton.material-tree-view-item-expander:checked /template/ Canvas">
<Setter Property="RenderTransform" Value="rotate(45deg)" />
</Style>
</Styles>