Browse Source

Fixed "floating" document preview

flabbet 7 months ago
parent
commit
fd5a5eca44

+ 1 - 1
src/Drawie

@@ -1 +1 @@
-Subproject commit 1dabfdaf8ccb547cee84689c08b4c1762b14c30e
+Subproject commit e9d3a727001548fe5d50793bfb31e5ececbfd8d1

+ 4 - 12
src/PixiEditor/Views/Main/DocumentPreview.axaml

@@ -26,14 +26,6 @@
                 x:Name="viewport"
                 x:Name="viewport"
                 Document="{Binding Document, ElementName=uc}"
                 Document="{Binding Document, ElementName=uc}"
                 Background="{Binding ActiveItem.Value, ElementName=backgroundButton}"/>
                 Background="{Binding ActiveItem.Value, ElementName=backgroundButton}"/>
-            <Border 
-                    x:Name="colorCursor" Width="1" Height="1"
-                    Margin="{Binding ColorCursorPosition, ElementName=uc}"
-                    HorizontalAlignment="Left" VerticalAlignment="Top"
-                    BorderBrush="{DynamicResource ThemeBorderLowBrush}" BorderThickness=".1"
-                    IsVisible="{Binding IsPointerOver, ElementName=imageGrid}">
-                <Border BorderThickness=".1" BorderBrush="White"/>
-            </Border>
         </Grid>
         </Grid>
 
 
         <Grid Grid.Row="1">
         <Grid Grid.Row="1">
@@ -41,16 +33,16 @@
                 <SolidColorBrush Color="{Binding ColorCursorColor, ElementName=uc, FallbackValue=Black}"/>
                 <SolidColorBrush Color="{Binding ColorCursorColor, ElementName=uc, FallbackValue=Black}"/>
             </Grid.Background>
             </Grid.Background>
         </Grid>
         </Grid>
-        <StackPanel Margin="10, 0, 0, 0" Grid.Row="2" Orientation="Horizontal" MinHeight="30"
-                    Background="{DynamicResource ThemeBackgroundBrush}" MaxHeight="60">
+        <StackPanel Margin="10, 0, 0, 0" Grid.Row="2" Orientation="Horizontal" Height="30"
+                    Background="{DynamicResource ThemeBackgroundBrush}">
             <StackPanel.Styles>
             <StackPanel.Styles>
                 <Style Selector="TextBlock">
                 <Style Selector="TextBlock">
                     <Setter Property="VerticalAlignment" Value="Center"/>
                     <Setter Property="VerticalAlignment" Value="Center"/>
                 </Style>
                 </Style>
             </StackPanel.Styles>
             </StackPanel.Styles>
 
 
-            <TextBlock Text="{Binding ColorCursorPosition.Left, ElementName=uc, StringFormat='X: {0}'}"/>
-            <TextBlock Text="{Binding ColorCursorPosition.Top, ElementName=uc, StringFormat='Y: {0}'}"/>
+            <TextBlock Text="{Binding ColorCursorPosition.X, ElementName=uc, StringFormat='X: {0}'}"/>
+            <TextBlock Text="{Binding ColorCursorPosition.Y, ElementName=uc, StringFormat='Y: {0}'}"/>
 
 
             <TextBlock VerticalAlignment="Center" Margin="10, 0, 0, 0">
             <TextBlock VerticalAlignment="Center" Margin="10, 0, 0, 0">
                 <TextBlock.Text>
                 <TextBlock.Text>

+ 12 - 14
src/PixiEditor/Views/Main/DocumentPreview.axaml.cs

@@ -18,9 +18,6 @@ internal partial class DocumentPreview : UserControl
     public static readonly StyledProperty<DocumentViewModel> DocumentProperty =
     public static readonly StyledProperty<DocumentViewModel> DocumentProperty =
         AvaloniaProperty.Register<DocumentPreview, DocumentViewModel>(nameof(Document));
         AvaloniaProperty.Register<DocumentPreview, DocumentViewModel>(nameof(Document));
 
 
-    public static readonly StyledProperty<Thickness> ColorCursorPositionProperty =
-        AvaloniaProperty.Register<DocumentPreview, Thickness>(nameof(ColorCursorPosition));
-
     public static readonly StyledProperty<Color> ColorCursorColorProperty =
     public static readonly StyledProperty<Color> ColorCursorColorProperty =
         AvaloniaProperty.Register<DocumentPreview, Color>(nameof(ColorCursorColor));
         AvaloniaProperty.Register<DocumentPreview, Color>(nameof(ColorCursorColor));
 
 
@@ -33,12 +30,6 @@ internal partial class DocumentPreview : UserControl
         set => SetValue(DocumentProperty, value);
         set => SetValue(DocumentProperty, value);
     }
     }
 
 
-    public Thickness ColorCursorPosition
-    {
-        get => GetValue(ColorCursorPositionProperty);
-        private set => SetValue(ColorCursorPositionProperty, value);
-    }
-
     public Color ColorCursorColor
     public Color ColorCursorColor
     {
     {
         get => GetValue(ColorCursorColorProperty);
         get => GetValue(ColorCursorColorProperty);
@@ -50,6 +41,15 @@ internal partial class DocumentPreview : UserControl
         get => GetValue(PrimaryColorProperty);
         get => GetValue(PrimaryColorProperty);
         set => SetValue(PrimaryColorProperty, value);
         set => SetValue(PrimaryColorProperty, value);
     }
     }
+
+    public static readonly StyledProperty<VecI> ColorCursorPositionProperty = AvaloniaProperty.Register<DocumentPreview, VecI>(
+        nameof(ColorCursorPosition));
+
+    public VecI ColorCursorPosition
+    {
+        get => GetValue(ColorCursorPositionProperty);
+        set => SetValue(ColorCursorPositionProperty, value);
+    }
     
     
     private MouseUpdateController mouseUpdateController;
     private MouseUpdateController mouseUpdateController;
 
 
@@ -151,15 +151,13 @@ internal partial class DocumentPreview : UserControl
         if (x < 0 || x > Document.Width || y < 0 || y > Document.Height)
         if (x < 0 || x > Document.Width || y < 0 || y > Document.Height)
             return;
             return;
         
         
-        Thickness newPos = new Thickness(x, y, 0, 0);
-
-        if (ColorCursorPosition == newPos)
+        if (x == ColorCursorPosition.X && y == ColorCursorPosition.Y)
         {
         {
             return;
             return;
         }
         }
 
 
-        ColorCursorPosition = newPos;
-
+        ColorCursorPosition = new VecI(x, y);
+        
         var color = Document.PickColor(new(x, y), DocumentScope.AllLayers, false, true, Document.AnimationDataViewModel.ActiveFrameBindable);
         var color = Document.PickColor(new(x, y), DocumentScope.AllLayers, false, true, Document.AnimationDataViewModel.ActiveFrameBindable);
         ColorCursorColor = Color.FromArgb(color.A, color.R, color.G, color.B);
         ColorCursorColor = Color.FromArgb(color.A, color.R, color.G, color.B);
     }
     }