Krzysztof Krysiński 2 роки тому
батько
коміт
20c5ca3f15

+ 0 - 79
src/PixiEditor.AvaloniaUI/Styles/PixiEditor.Layers.axaml

@@ -10,84 +10,5 @@
 
         <SolidColorBrush x:Key="SelectedLayerBrush" Color="{DynamicResource SelectedLayerColor}" />
         <SolidColorBrush x:Key="SoftSelectedLayerBrush" Color="{DynamicResource SoftSelectedLayerColor}" />
-
-        <ControlTheme x:Key="TreeViewItemTheme" TargetType="{x:Type TreeViewItem}">
-        <Setter Property="Background" Value="Transparent"/>
-        <Setter Property="Padding" Value="0,0,0,0"/>
-        <!--TODO: systemcolors-->
-        <!--<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>-->
-        <!--<Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}"/>-->
-        <Setter Property="ItemsPanel">
-            <Setter.Value>
-                <ItemsPanelTemplate>
-                    <ui:ReversedOrderStackPanel />
-                </ItemsPanelTemplate>
-            </Setter.Value>
-        </Setter>
-        <Setter Property="Template">
-            <Setter.Value>
-                <ControlTemplate TargetType="{x:Type TreeViewItem}">
-                    <Grid>
-                        <Grid.ColumnDefinitions>
-                            <ColumnDefinition MinWidth="15" Width="Auto"/>
-                            <ColumnDefinition Width="Auto"/>
-                            <ColumnDefinition Width="*"/>
-                        </Grid.ColumnDefinitions>
-                        <Grid.RowDefinitions>
-                            <RowDefinition Height="Auto"/>
-                            <RowDefinition/>
-                        </Grid.RowDefinitions>
-                        <ToggleButton x:Name="Expander"
-                                      Classes="ExpandCollapseToggleStyle"
-                                      ClickMode="Press"
-                                      IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" />
-                        <Border x:Name="Bd" Grid.Column="1" Grid.ColumnSpan="2" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
-                            <ContentPresenter x:Name="PART_Header" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Content="{TemplateBinding Header}"/>
-                        </Border>
-                        <ItemsPresenter x:Name="ItemsHost" Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="1"
-                                        ui1:TreeViewItemHelper.Indent="{Binding Path=(ui1:TreeViewItemHelper.Indent), Mode=OneWay, RelativeSource={RelativeSource AncestorType=ItemsPresenter}, Converter={converters:IndentConverter}}"/>
-                    </Grid>
-                    <!--TODO: Implement below-->
-                    <!--<Interaction.Behaviors>
-                        <DataTriggerBehavior Binding="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" Value="False">
-                            <Style Selector="TreeViewItem #ItemsHost">
-                                <Setter Property="IsVisible" Value="False"/>
-                            </Style>
-                        </DataTriggerBehavior>
-                        <DataTriggerBehavior Binding="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" Value="True">
-                        <Style Selector="TreeViewItem #ItemsHost">
-                            <Setter Property="IsVisible" Value="True"/>
-                        </Style>
-                        </DataTriggerBehavior>
-                        <DataTriggerBehavior Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Items.Empty}" Value="True">
-                            <Style Selector="TreeViewItem #Expander">
-                                <Setter Property="IsVisible" Value="False"/>
-                            </Style>
-                        </DataTriggerBehavior>
-                    </Interaction.Behaviors>-->
-                    <!--<ControlTemplate.Triggers>
-                        <MultiTrigger>
-                            <MultiTrigger.Conditions>
-                                <Condition Property="HasItems" Value="True"/>
-                                <Condition Property="IsSelected" Value="True"/>
-                            </MultiTrigger.Conditions>
-                            <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
-                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
-                        </MultiTrigger>
-                        <MultiTrigger>
-                            <MultiTrigger.Conditions>
-                                <Condition Property="IsSelected" Value="true"/>
-                                <Condition Property="IsSelectionActive" Value="false"/>
-                            </MultiTrigger.Conditions>
-                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}}"/>
-                        </MultiTrigger>
-                        <Trigger Property="IsEnabled" Value="false">
-                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
-                        </Trigger>
-                    </ControlTemplate.Triggers>-->
-                </ControlTemplate>
-            </Setter.Value>
-        </Setter>
-    </ControlTheme>
     </Styles.Resources>
 </Styles>

+ 7 - 1
src/PixiEditor.AvaloniaUI/ViewModels/Document/StructureMemberViewModel.cs

@@ -143,7 +143,13 @@ internal abstract class StructureMemberViewModel : ObservableObject, IStructureM
         set => SetProperty(ref selection, value);
     }
 
-    public WriteableBitmap? PreviewBitmap { get; set; }
+    private WriteableBitmap? previewBitmap;
+
+    public WriteableBitmap? PreviewBitmap
+    {
+        get => previewBitmap;
+        set => SetProperty(ref previewBitmap, value);
+    }
     public DrawingSurface? PreviewSurface { get; set; }
 
     public WriteableBitmap? MaskPreviewBitmap { get; set; }

+ 4 - 5
src/PixiEditor.AvaloniaUI/Views/Layers/FolderControl.axaml

@@ -35,10 +35,10 @@
         <Grid>
             <Grid.RowDefinitions>
                 <RowDefinition Height="10"/>
-                <RowDefinition Height="15"/>
+                <RowDefinition Height="16"/>
                 <RowDefinition Height="10"/>
             </Grid.RowDefinitions>
-            <Grid DragDrop.AllowDrop="True"  Grid.Row="0" Grid.ColumnSpan="3" Background="Transparent" Panel.ZIndex="3"/>
+            <Grid DragDrop.AllowDrop="True" Grid.Row="0" Grid.ColumnSpan="3" Background="Transparent" Panel.ZIndex="3"/>
             <Grid IsVisible="False" x:Name="middleDropGrid" Grid.Row="1" DragDrop.AllowDrop="True" Panel.ZIndex="2" Background="Transparent"></Grid>
             <Grid x:Name="centerGrid" Grid.Row="0" Grid.RowSpan="3" Background="Transparent">
                 <Grid.ColumnDefinitions>
@@ -64,13 +64,12 @@
                                 </ImageBrush>
                             </Border.Background>
                             <Image Source="{Binding Folder.PreviewBitmap, ElementName=folderControl}" Stretch="Uniform" Width="30" Height="30">
-                               <!--TODO: Avalonia throws error for below-->
-                                <!--<RenderOptions.BitmapInterpolationMode>
+                                <helpers:RenderOptionsBindable.BitmapInterpolationMode>
                                     <MultiBinding Converter="{converters:WidthToBitmapScalingModeConverter}">
                                         <Binding Path="Folder.PreviewBitmap.PixelSize.Width" ElementName="folderControl"/>
                                         <Binding RelativeSource="{RelativeSource Mode=Self}" Path="Bounds.Width"/>
                                     </MultiBinding>
-                                </RenderOptions.BitmapInterpolationMode>-->
+                                </helpers:RenderOptionsBindable.BitmapInterpolationMode>
                             </Image>
                         </Border>
                         <Border 

+ 3 - 3
src/PixiEditor.AvaloniaUI/Views/Layers/LayerControl.axaml

@@ -39,10 +39,10 @@
         <Grid>
             <Grid.RowDefinitions>
                 <RowDefinition Height="10"/>
-                <RowDefinition Height="25"/>
+                <RowDefinition Height="26"/>
             </Grid.RowDefinitions>
             <Grid DragDrop.AllowDrop="True" Grid.Row="0" Grid.ColumnSpan="3" Background="Transparent"/>
-            <Grid Grid.Row="1" Grid.RowSpan="3" Margin="0,-10,0,0" VerticalAlignment="Center" DragDrop.AllowDrop="False">
+            <Grid Grid.Row="1" Margin="0,-17,0,0" VerticalAlignment="Center" DragDrop.AllowDrop="False">
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="24"/>
                     <ColumnDefinition Width="*"/>
@@ -74,7 +74,7 @@
                                 <Binding ElementName="uc" Path="Layer.HasMaskBindable"/>
                             </MultiBinding>
                         </Border.BorderBrush>
-                        <Image Source="{Binding Layer.PreviewBitmap,ElementName=uc}" Stretch="Uniform" Width="30" Height="30"
+                        <Image Source="{Binding Layer.PreviewBitmap, ElementName=uc}" Stretch="Uniform" Width="30" Height="30"
                            RenderOptions.BitmapInterpolationMode="None" IsHitTestVisible="False"/>
                     </Border>
                     <Border

+ 7 - 7
src/PixiEditor.AvaloniaUI/Views/Layers/LayersManager.axaml

@@ -151,7 +151,7 @@
                 IsVisible="{Binding Path=DataContext.ActiveDocument, ElementName=layersManager, Converter={converters1:NotNullToVisibilityConverter}}"
                 Background="{DynamicResource ThemeBackgroundBrush}"
                 Grid.Row="3" VerticalAlignment="Bottom"/>
-            <TreeView ItemContainerTheme="{StaticResource TreeViewItemTheme}" DockPanel.Dock="Top" Name="treeView"
+            <TreeView DockPanel.Dock="Top" Name="treeView"
                       ItemsSource="{Binding DataContext.ActiveDocument.StructureRoot.Children, ElementName=layersManager}">
                 <TreeView.ItemsPanel>
                     <ItemsPanelTemplate>
@@ -166,18 +166,18 @@
                 <TreeView.DataTemplates>
                     <TreeDataTemplate DataType="docVm:FolderViewModel" ItemsSource="{Binding Children}">
                         <layers:FolderControl
-                            Folder="{Binding}"
-                            Manager="{Binding ElementName=layersManager}"
-                            PointerPressed="FolderControl_MouseDown"
-                            PointerReleased="FolderControl_MouseUp"/>
+                                Folder="{Binding}"
+                                Manager="{Binding ElementName=layersManager}"
+                                PointerPressed="FolderControl_MouseDown"
+                                PointerReleased="FolderControl_MouseUp"/>
                     </TreeDataTemplate>
-                    <TreeDataTemplate DataType="{x:Type docVm:LayerViewModel}">
+                    <DataTemplate DataType="{x:Type docVm:LayerViewModel}">
                         <layers:LayerControl
                             Layer="{Binding}"
                             Manager="{Binding ElementName=layersManager}"
                             PointerPressed="LayerControl_MouseDown"
                             PointerReleased="LayerControl_MouseUp"/>
-                    </TreeDataTemplate>
+                    </DataTemplate>
                 </TreeView.DataTemplates>
             </TreeView>
             <Border Name="dropBorder" DragDrop.AllowDrop="True" Background="Transparent" BorderThickness="0, 5, 0, 0"></Border>