Pārlūkot izejas kodu

Improved UI of empty document and null checks

Krzysztof Krysiński 5 mēneši atpakaļ
vecāks
revīzija
691e89a1ca

+ 1 - 0
src/PixiEditor.UI.Common/Fonts/PixiPerfectIcons.axaml

@@ -5,6 +5,7 @@
         <ResourceDictionary>
             <FontFamily x:Key="PixiPerfectIcons">avares://PixiEditor.UI.Common/Fonts/PixiPerfect.ttf#pixiperfect</FontFamily>
 
+            <system:String x:Key="icon-ghost">&#xe812;</system:String>
             <system:String x:Key="icon-add-reference">&#xE900;</system:String>
             <system:String x:Key="icon-add-to-mask">&#xE901;</system:String>
             <system:String x:Key="icon-alpha-lock">&#xE902;</system:String>

+ 3 - 1
src/PixiEditor/Data/Localization/Languages/en.json

@@ -1007,5 +1007,7 @@
   "DIFFERENCE_VECTOR_PATH_OP": "Difference",
   "INTERSECT_VECTOR_PATH_OP": "Intersect",
   "XOR_VECTOR_PATH_OP": "XOR",
-  "REVERSE_DIFFERENCE_VECTOR_PATH_OP": "Reverse Difference"
+  "REVERSE_DIFFERENCE_VECTOR_PATH_OP": "Reverse Difference",
+  "NO_DOCUMENT_OPEN": "Nothing's here",
+  "EMPTY_DOCUMENT_ACTION_BTN": "Start creating"
 }

+ 7 - 1
src/PixiEditor/ViewModels/Tools/Tools/ColorPickerToolViewModel.cs

@@ -32,7 +32,7 @@ internal class ColorPickerToolViewModel : ToolViewModel, IColorPickerHandler
 
     public override string DefaultIcon => PixiPerfectIcons.Picker;
 
-    public override Type[]? SupportedLayerTypes { get; } = null;  // all layer types are supported
+    public override Type[]? SupportedLayerTypes { get; } = null; // all layer types are supported
 
     public override LocalizedString Tooltip => new("COLOR_PICKER_TOOLTIP", Shortcut);
 
@@ -173,12 +173,18 @@ internal class ColorPickerToolViewModel : ToolViewModel, IColorPickerHandler
 
     protected override void OnSelected(bool restoring)
     {
+        if (ViewModelMain.Current.DocumentManagerSubViewModel.ActiveDocument == null)
+            return;
+
         base.OnSelected(restoring);
         ViewModelMain.Current.DocumentManagerSubViewModel.ActiveDocument.SuppressAllOverlayEvents(ToolName);
     }
 
     protected override void OnDeselecting(bool transient)
     {
+        if (ViewModelMain.Current.DocumentManagerSubViewModel.ActiveDocument == null)
+            return;
+
         base.OnDeselecting(transient);
         ViewModelMain.Current.DocumentManagerSubViewModel.ActiveDocument.RestoreAllOverlayEvents(ToolName);
     }

+ 6 - 0
src/PixiEditor/ViewModels/Tools/Tools/MoveViewportToolViewModel.cs

@@ -27,12 +27,18 @@ internal class MoveViewportToolViewModel : ToolViewModel
 
     protected override void OnSelected(bool restoring)
     {
+        if (ViewModelMain.Current.DocumentManagerSubViewModel.ActiveDocument == null)
+            return;
+
         ActionDisplay = new LocalizedString("MOVE_VIEWPORT_ACTION_DISPLAY");
         ViewModelMain.Current.DocumentManagerSubViewModel.ActiveDocument.SuppressAllOverlayEvents(ToolName);
     }
 
     protected override void OnDeselecting(bool transient)
     {
+        if (ViewModelMain.Current.DocumentManagerSubViewModel.ActiveDocument == null)
+            return;
+
         base.OnDeselecting(transient);
         ViewModelMain.Current.DocumentManagerSubViewModel.ActiveDocument.RestoreAllOverlayEvents(ToolName);
     }

+ 6 - 3
src/PixiEditor/Views/Main/CreateDocumentFallbackView.axaml

@@ -3,6 +3,7 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              xmlns:viewModels="clr-namespace:PixiEditor.ViewModels"
+             xmlns:ui="clr-namespace:PixiEditor.Extensions.UI;assembly=PixiEditor.Extensions"
              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
              x:DataType="viewModels:ViewModelMain"
              x:Class="PixiEditor.Views.Main.CreateDocumentFallbackView">
@@ -10,8 +11,10 @@
         <viewModels:ViewModelMain/>
     </Design.DataContext>
 
-    <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
-        <TextBlock Text="Create new document" HorizontalAlignment="Center" VerticalAlignment="Center"/>
-        <Button Content="Create" Command="{Binding FileSubViewModel.CreateFromNewFileDialog}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+    <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Spacing="48">
+        <TextBlock Classes="h1" Foreground="{DynamicResource ThemeForegroundBrush}"  ui:Translator.Key="NO_DOCUMENT_OPEN" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+        <TextBlock FontSize="128" Opacity="0.5" Classes="pixi-icon" Foreground="{DynamicResource ThemeForegroundBrush}"
+                   Text="{DynamicResource icon-ghost}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+        <Button Width="240" Background="{DynamicResource ThemeAccentBrush}" ui:Translator.Key="EMPTY_DOCUMENT_ACTION_BTN" Command="{Binding WindowSubViewModel.OpenHelloThereWindow}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
     </StackPanel>
 </UserControl>