Browse Source

Some roundings and popup window wip

Krzysztof Krysiński 2 years ago
parent
commit
1ffc90210f

+ 8 - 0
src/PixiEditor/Data/ShortcutActionMaps/AsepriteShortcutMap.json

@@ -435,6 +435,14 @@
       },
       "Parameters": []
     },
+    "About": {
+      "Command": "PixiEditor.Window.OpenAboutWindow",
+      "DefaultShortcut": {
+        "key": "None",
+        "modifiers": null
+      },
+      "Parameters": []
+    },
     "TogglePreview": {
       "Command": "PixiEditor.Window.OpenNavigationWindow",
       "DefaultShortcut": {

+ 3 - 3
src/PixiEditor/Models/Commands/Attributes/Commands/BasicAttribute.cs

@@ -14,9 +14,9 @@ internal partial class Command
         /// </summary>
         /// <param name="internalName">The internal name of the command</param>
         /// <param name="displayName">A short description which is displayed in the the top menu, e.g. "Save as..."</param>
-        /// <param name="description">A description which is displayed in the search bar, e.g. "Save image as new". Leave empty to hide it from the search bar</param>
-        public BasicAttribute(string internalName, string displayName, string description)
-            : this(internalName, null, displayName, description)
+        /// <param name="descriptiveName">A description which is displayed in the search bar, e.g. "Save image as new". Leave empty to hide it from the search bar</param>
+        public BasicAttribute(string internalName, string displayName, string descriptiveName)
+            : this(internalName, null, displayName, descriptiveName)
         {
         }
 

+ 1 - 1
src/PixiEditor/Models/Commands/Attributes/Commands/DebugAttribute.cs

@@ -4,7 +4,7 @@ internal partial class Command
 {
     internal class DebugAttribute : BasicAttribute
     {
-        public DebugAttribute(string internalName, string displayName, string description) : base($"#DEBUG#{internalName}", displayName, description)
+        public DebugAttribute(string internalName, string displayName, string descriptiveName) : base($"#DEBUG#{internalName}", displayName, descriptiveName)
         {
         }
 

+ 1 - 0
src/PixiEditor/ViewModels/SubViewModels/Main/MiscViewModel.cs

@@ -1,6 +1,7 @@
 using PixiEditor.Helpers;
 using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
+using PixiEditor.Views.Dialogs;
 
 namespace PixiEditor.ViewModels.SubViewModels.Main;
 

+ 11 - 0
src/PixiEditor/ViewModels/SubViewModels/Main/WindowViewModel.cs

@@ -18,6 +18,9 @@ internal class WindowViewModel : SubViewModel<ViewModelMain>
     private ShortcutPopup? shortcutPopup;
     private ShortcutPopup ShortcutPopup => shortcutPopup ?? (shortcutPopup = new(commandController));
 
+    private AboutPopup? _aboutPopup;
+    private AboutPopup AboutPopup => _aboutPopup ??= new();
+
     public RelayCommand<string> ShowAvalonDockWindowCommand { get; set; }
     public ObservableCollection<ViewportWindowViewModel> Viewports { get; } = new();
     public event EventHandler<ViewportWindowViewModel>? ActiveViewportChanged;
@@ -131,6 +134,14 @@ internal class WindowViewModel : SubViewModel<ViewModelMain>
         ShortcutPopup.Show();
         ShortcutPopup.Activate();
     }
+    
+        
+    [Command.Basic("PixiEditor.Window.OpenAboutWindow", "Open About Window", "Open About Window")]
+    public void OpenAboutWindow()
+    {
+        AboutPopup.Show();
+        AboutPopup.Activate();
+    }
 
     [Command.Basic("PixiEditor.Window.OpenNavigationWindow", "navigation", "Open Navigation Window", "Open Navigation Window")]
     public static void ShowAvalonDockWindow(string id)

+ 34 - 0
src/PixiEditor/Views/Dialogs/AboutPopup.xaml

@@ -0,0 +1,34 @@
+<Window x:Class="PixiEditor.Views.Dialogs.AboutPopup"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:local="clr-namespace:PixiEditor.Views.Dialogs"
+        xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
+        xmlns:behaviours="clr-namespace:PixiEditor.Helpers.Behaviours"
+        mc:Ignorable="d" WindowStyle="None"
+        Title="About" WindowStartupLocation="CenterScreen" 
+        Height="300" Width="400">
+    <Window.CommandBindings>
+        <CommandBinding Command="{x:Static SystemCommands.CloseWindowCommand}" CanExecute="CommandBinding_CanExecute"
+                        Executed="CommandBinding_Executed_Close" />
+    </Window.CommandBindings>
+    
+    <WindowChrome.WindowChrome>
+        <WindowChrome CaptionHeight="32"  GlassFrameThickness="0.1"
+                      ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
+    </WindowChrome.WindowChrome>
+
+    <DockPanel Background="{StaticResource AccentColor}" Focusable="True">
+        <b:Interaction.Behaviors>
+            <behaviours:ClearFocusOnClickBehavior/>
+        </b:Interaction.Behaviors>
+
+        <local:DialogTitleBar DockPanel.Dock="Top"
+                             TitleText="{Binding ElementName=popup, Path=Title}" 
+                             CloseCommand="{x:Static SystemCommands.CloseWindowCommand}"/>
+        <Grid DockPanel.Dock="Bottom">
+            
+        </Grid>
+    </DockPanel>
+</Window>

+ 23 - 0
src/PixiEditor/Views/Dialogs/AboutPopup.xaml.cs

@@ -0,0 +1,23 @@
+using System.Windows;
+using System.Windows.Input;
+
+namespace PixiEditor.Views.Dialogs;
+
+public partial class AboutPopup : Window
+{
+    public AboutPopup()
+    {
+        InitializeComponent();
+    }
+    
+    private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
+    {
+        e.CanExecute = true;
+    }
+
+    private void CommandBinding_Executed_Close(object sender, ExecutedRoutedEventArgs e)
+    {
+        SystemCommands.CloseWindow(this);
+    }
+}
+

+ 25 - 22
src/PixiEditor/Views/Dialogs/ResizeCanvasPopup.xaml

@@ -38,27 +38,30 @@
         <Button DockPanel.Dock="Bottom" Width="70" HorizontalAlignment="Center" Margin="15"
                 Style="{StaticResource DarkRoundButton}" Content="Resize" Click="Button_Click" IsDefault="True" />
 
-        <StackPanel HorizontalAlignment="Center" Margin="0,30,0,0" Background="{StaticResource MainColor}"
-                    VerticalAlignment="Top" Grid.Row="1" Width="250" Height="290">
-            <userControls:SizePicker Margin="0,8,0,0" 
-                              Width="240"
-                              Height="170"
-                              x:Name="sizePicker"
-                              Focusable="True"
-                              ChosenHeight="{Binding NewAbsoluteHeight, Mode=TwoWay, ElementName=window}"
-                              ChosenWidth="{Binding NewAbsoluteWidth, Mode=TwoWay, ElementName=window}" 
-                              ChosenPercentageSize="{Binding NewPercentageSize, Mode=TwoWay, ElementName=window}"
-                              SelectedUnit="{ Binding NewSelectedUnit, Mode=TwoWay, ElementName=window}"
-                              SizeUnitSelectionVisibility="Visible"
-                              />
-            <Separator Margin="10,5,10,0" Background="{StaticResource AccentColor}" Height="1" />
-            <DockPanel>
-                <Label Content="Anchor point:" Foreground="White" Margin="25,5,0,0" HorizontalAlignment="Left"
-                       FontSize="12" />
-                <userControls:AnchorPointPicker AnchorPoint="{Binding Path=SelectedAnchorPoint, Mode=TwoWay, ElementName=window}"
-                                         HorizontalAlignment="Right"
-                                         Width="78" Margin="0,10,30,0" Height="78" />
-            </DockPanel>
-        </StackPanel>
+        <Border HorizontalAlignment="Center" Margin="0,30,0,0" Background="{StaticResource MainColor}"
+                 VerticalAlignment="Top" Grid.Row="1" Width="250" Height="290" CornerRadius="10">
+            <StackPanel
+                >
+                <userControls:SizePicker Margin="0,8,0,0" 
+                                  Width="240"
+                                  Height="170"
+                                  x:Name="sizePicker"
+                                  Focusable="True"
+                                  ChosenHeight="{Binding NewAbsoluteHeight, Mode=TwoWay, ElementName=window}"
+                                  ChosenWidth="{Binding NewAbsoluteWidth, Mode=TwoWay, ElementName=window}" 
+                                  ChosenPercentageSize="{Binding NewPercentageSize, Mode=TwoWay, ElementName=window}"
+                                  SelectedUnit="{ Binding NewSelectedUnit, Mode=TwoWay, ElementName=window}"
+                                  SizeUnitSelectionVisibility="Visible"
+                                  />
+                <Separator Margin="10,5,10,0" Background="{StaticResource AccentColor}" Height="1" />
+                <DockPanel>
+                    <Label Content="Anchor point:" Foreground="White" Margin="25,5,0,0" HorizontalAlignment="Left"
+                           FontSize="12" />
+                    <userControls:AnchorPointPicker AnchorPoint="{Binding Path=SelectedAnchorPoint, Mode=TwoWay, ElementName=window}"
+                                             HorizontalAlignment="Right"
+                                             Width="78" Margin="0,10,30,0" Height="78" />
+                </DockPanel>
+            </StackPanel>
+        </Border>
     </DockPanel>
 </dial:ResizeablePopup>

+ 4 - 0
src/PixiEditor/Views/MainWindow.xaml

@@ -313,6 +313,10 @@
                         <MenuItem
                             Header="_Third Party Licenses"
                             cmds:Menu.Command="PixiEditor.Links.OpenOtherLicenses" />
+                        <Separator/>
+                        <MenuItem
+                            Header="_About"
+                            cmds:Menu.Command="PixiEditor.Window.OpenAboutWindow" />
                     </MenuItem>
                     <MenuItem
                         Header="_Debug"

+ 2 - 2
src/PixiEditor/Views/UserControls/SizePicker.xaml

@@ -9,7 +9,7 @@
              xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
              xmlns:enums="clr-namespace:PixiEditor.Models.Enums"
              xmlns:userControls="clr-namespace:PixiEditor.Views.UserControls"
-             mc:Ignorable="d"
+             mc:Ignorable="d" Background="Transparent"
              d:DesignHeight="200" d:DesignWidth="240" Name="uc">
     <i:Interaction.Triggers>
         <i:EventTrigger EventName="Loaded">
@@ -27,7 +27,7 @@
             <Setter Property="Height" Value="25"/>
         </Style>
     </UserControl.Resources>
-    <Border Background="{StaticResource MainColor}" VerticalAlignment="Stretch">
+    <Border Background="{StaticResource MainColor}" VerticalAlignment="Stretch" CornerRadius="10">
         <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
             <Grid Height="60" HorizontalAlignment="Center" DockPanel.Dock="Top"
                   Visibility="{Binding SizeUnitSelectionVisibility, ElementName=uc}">