Browse Source

Merge pull request #374 from PixiEditor/master

v0.1.7.3-dev
Krzysztof Krysiński 3 years ago
parent
commit
49c122b12d

+ 5 - 1
PixiEditor/ViewModels/SubViewModels/Main/ToolsViewModel.cs

@@ -5,6 +5,7 @@ using PixiEditor.Models.Events;
 using PixiEditor.Models.Tools;
 using PixiEditor.Models.Tools.Tools;
 using PixiEditor.Models.Tools.ToolSettings.Settings;
+using PixiEditor.Models.UserPreferences;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -104,7 +105,10 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
 
             ActiveTool = tool;
 
-            ActiveTool.Toolbar.LoadSharedSettings();
+            if (IPreferences.Current.GetPreference<bool>("EnableSharedToolbar"))
+            {
+                ActiveTool.Toolbar.LoadSharedSettings();
+            }
 
             if (LastActionTool != ActiveTool)
                 SelectedToolChanged?.Invoke(this, new SelectedToolEventArgs(LastActionTool, ActiveTool));

+ 23 - 0
PixiEditor/ViewModels/SubViewModels/UserPreferences/Settings/ToolsSettings.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PixiEditor.ViewModels.SubViewModels.UserPreferences.Settings
+{
+    public class ToolsSettings : SettingsGroup
+    {
+        private bool enableSharedToolbar = GetPreference(nameof(EnableSharedToolbar), false);
+
+        public bool EnableSharedToolbar
+        {
+            get => enableSharedToolbar;
+            set
+            {
+                enableSharedToolbar = value;
+                RaiseAndUpdatePreference(nameof(EnableSharedToolbar), value);
+            }
+        }
+    }
+}

+ 2 - 0
PixiEditor/ViewModels/SubViewModels/UserPreferences/SettingsViewModel.cs

@@ -6,6 +6,8 @@ namespace PixiEditor.ViewModels.SubViewModels.UserPreferences
     {
         public GeneralSettings General { get; set; } = new GeneralSettings();
 
+        public ToolsSettings Tools { get; set; } = new ToolsSettings();
+
         public FileSettings File { get; set; } = new FileSettings();
 
         public UpdateSettings Update { get; set; } = new UpdateSettings();

+ 10 - 3
PixiEditor/Views/Dialogs/SettingsWindow.xaml

@@ -76,6 +76,8 @@
                     <RowDefinition Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=Tag}"/>
                     <RowDefinition Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=Tag}"/>
                     <RowDefinition Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=Tag}"/>
+                    <RowDefinition Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=Tag}"/>
+                    <RowDefinition Height="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=Tag}"/>
                 </Grid.RowDefinitions>
 
                 <Label Grid.Row="0" Grid.ColumnSpan="2" Style="{StaticResource SettingsHeader}">Misc</Label>
@@ -106,13 +108,18 @@
                                  Size="{Binding SettingsSubViewModel.File.DefaultNewFileHeight, Mode=TwoWay}" 
                                  Width="70" Height="21" MaxSize="9999" HorizontalAlignment="Left"/>
 
-                <Label Grid.Row="7" Grid.ColumnSpan="2" Style="{StaticResource SettingsHeader}">Automatic updates</Label>
+                <Label Grid.Row="7" Grid.ColumnSpan="2" Style="{StaticResource SettingsHeader}">Tools</Label>
 
                 <CheckBox Grid.Row="8" Grid.Column="1" VerticalAlignment="Center"
+                    IsChecked="{Binding SettingsSubViewModel.Tools.EnableSharedToolbar}">Enable shared toolbar</CheckBox>
+                
+                <Label Grid.Row="9" Grid.ColumnSpan="2" Style="{StaticResource SettingsHeader}">Automatic updates</Label>
+
+                <CheckBox Grid.Row="10" Grid.Column="1" VerticalAlignment="Center"
                     IsChecked="{Binding SettingsSubViewModel.Update.CheckUpdatesOnStartup}">Check updates on startup</CheckBox>
 
-                <Label Grid.Row="9" Grid.Column="1" Style="{StaticResource SettingsText}">Update stream</Label>
-                <ComboBox Grid.Row="9" Grid.Column="2" VerticalAlignment="Center"
+                <Label Grid.Row="11" Grid.Column="1" Style="{StaticResource SettingsText}">Update stream</Label>
+                <ComboBox Grid.Row="11" Grid.Column="2" VerticalAlignment="Center"
                     Width="110" Height="22" HorizontalAlignment="Left"
                     ItemsSource="{Binding SettingsSubViewModel.Update.UpdateChannels}"
                     SelectedValue="{Binding SettingsSubViewModel.Update.UpdateChannelName}"/>

+ 5 - 4
PixiEditor/Views/UserControls/Layers/LayersManager.xaml.cs

@@ -285,7 +285,8 @@ namespace PixiEditor.Views.UserControls.Layers
 
         private void LayerStructureItemContainer_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
         {
-            if (sender is LayerStructureItemContainer container && e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
+            if (sender is LayerStructureItemContainer container
+                && e.LeftButton == System.Windows.Input.MouseButtonState.Pressed && !container.Layer.IsRenaming)
             {
                 Dispatcher.InvokeAsync(() => DragDrop.DoDragDrop(container, container, DragDropEffects.Move));
             }
@@ -332,7 +333,8 @@ namespace PixiEditor.Views.UserControls.Layers
 
         private void LayerGroup_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
         {
-            if (sender is LayerGroupControl container && e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
+            if (sender is LayerGroupControl container && e.LeftButton == System.Windows.Input.MouseButtonState.Pressed
+                && !container.GroupData.IsRenaming)
             {
                 Dispatcher.InvokeAsync(() => DragDrop.DoDragDrop(container, container, DragDropEffects.Move));
             }
@@ -370,7 +372,6 @@ namespace PixiEditor.Views.UserControls.Layers
             }
 
             ShortcutController.UnblockShortcutExecutionAll();
-            MoveFocus(new System.Windows.Input.TraversalRequest(System.Windows.Input.FocusNavigationDirection.Next));
         }
 
         private void HandleLayerOpacityChange(float val, Layer layer)
@@ -462,4 +463,4 @@ namespace PixiEditor.Views.UserControls.Layers
             SelectedItem = sender;
         }
     }
-}
+}

+ 1 - 1
PixiEditor/Views/UserControls/NumberInput.xaml

@@ -6,7 +6,7 @@
              xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
              xmlns:behaviours="clr-namespace:PixiEditor.Helpers.Behaviours"
              mc:Ignorable="d"
-             d:DesignHeight="20" d:DesignWidth="40" x:Name="numberInput">
+             d:DesignHeight="20" d:DesignWidth="40" x:Name="numberInput" Focusable="True">
     <TextBox TextAlignment="Center" Style="{StaticResource DarkTextBoxStyle}" Focusable="True"
              InputScope="Number" MouseWheel="TextBox_MouseWheel"
              PreviewTextInput="TextBox_PreviewTextInput" Text="{Binding ElementName=numberInput, Path=Value}" Padding="0" VerticalContentAlignment="Center">