Browse Source

Improved look of Apply Transform

flabbet 1 year ago
parent
commit
a53fb0c1b9

+ 1 - 1
src/PixiEditor/Models/Commands/XAML/ContextMenu.cs

@@ -35,7 +35,7 @@ internal class ContextMenu : global::Avalonia.Controls.ContextMenu
         var command = CommandController.Current.Commands[value];
         var command = CommandController.Current.Commands[value];
 
 
         item.Command = Command.GetICommand(command, false);
         item.Command = Command.GetICommand(command, false);
-        item.Bind(MenuItem.InputGestureProperty, ShortcutBinding.GetBinding(command, null));
+        item.Bind(MenuItem.InputGestureProperty, ShortcutBinding.GetBinding(command, null, true));
     }
     }
 
 
     private static void HandleDesignMode(MenuItem item, string name)
     private static void HandleDesignMode(MenuItem item, string name)

+ 1 - 1
src/PixiEditor/Models/Commands/XAML/Menu.cs

@@ -51,7 +51,7 @@ internal class Menu : global::Avalonia.Controls.Menu
 
 
         item.Command = Command.GetICommand(command, false);
         item.Command = Command.GetICommand(command, false);
         item.Icon = icon;
         item.Icon = icon;
-        item.Bind(MenuItem.InputGestureProperty, ShortcutBinding.GetBinding(command, null));
+        item.Bind(MenuItem.InputGestureProperty, ShortcutBinding.GetBinding(command, null, true));
     }
     }
 
 
     private static void HandleDesignMode(MenuItem item, string name)
     private static void HandleDesignMode(MenuItem item, string name)

+ 5 - 3
src/PixiEditor/Models/Commands/XAML/ShortcutBinding.cs

@@ -15,6 +15,8 @@ internal class ShortcutBinding : MarkupExtension
     private static CommandController commandController;
     private static CommandController commandController;
 
 
     public string Name { get; set; }
     public string Name { get; set; }
+    
+    public bool UseAvaloniaGesture { get; set; } = true;
 
 
     public IValueConverter Converter { get; set; }
     public IValueConverter Converter { get; set; }
     
     
@@ -32,7 +34,7 @@ internal class ShortcutBinding : MarkupExtension
 
 
         ICommandsHandler? handler = ViewModelMain.Current;
         ICommandsHandler? handler = ViewModelMain.Current;
         commandController ??= handler.CommandController;
         commandController ??= handler.CommandController;
-        return GetBinding(commandController.Commands[Name], Converter);
+        return GetBinding(commandController.Commands[Name], Converter, UseAvaloniaGesture);
 
 
         /*var targetValue = serviceProvider.GetService<IProvideValueTarget>();
         /*var targetValue = serviceProvider.GetService<IProvideValueTarget>();
         var targetObject = targetValue.TargetObject as AvaloniaObject;
         var targetObject = targetValue.TargetObject as AvaloniaObject;
@@ -43,10 +45,10 @@ internal class ShortcutBinding : MarkupExtension
         return instancedBinding; //TODO: This won't work, leaving it for now*/
         return instancedBinding; //TODO: This won't work, leaving it for now*/
     }
     }
 
 
-    public static Binding GetBinding(Commands.Command command, IValueConverter converter) => new Binding
+    public static Binding GetBinding(ActualCommand command, IValueConverter converter, bool useAvaloniaGesture) => new Binding
     {
     {
         Source = command,
         Source = command,
-        Path = new("Shortcut.Gesture"),
+        Path = useAvaloniaGesture ? "Shortcut.Gesture" : "Shortcut",
         Mode = BindingMode.OneWay,
         Mode = BindingMode.OneWay,
         StringFormat = "",
         StringFormat = "",
         Converter = converter
         Converter = converter

+ 2 - 2
src/PixiEditor/Views/Main/ViewportControls/Viewport.axaml

@@ -208,9 +208,9 @@
             </Button.IsVisible>
             </Button.IsVisible>
             <StackPanel Orientation="Horizontal">
             <StackPanel Orientation="Horizontal">
                 <TextBlock ui:Translator.Key="APPLY_TRANSFORM" VerticalAlignment="Center" Margin="0,0,5,0" />
                 <TextBlock ui:Translator.Key="APPLY_TRANSFORM" VerticalAlignment="Center" Margin="0,0,5,0" />
-                <Border Padding="10,3" CornerRadius="5" Background="{DynamicResource ThemeAccentBrush}"
+                <Border Padding="10,3" CornerRadius="5" Background="{DynamicResource ThemeControlLowBrush}"
                         IsVisible="{xaml:ShortcutBinding PixiEditor.Tools.ApplyTransform, Converter={converters:NotNullToVisibilityConverter}}">
                         IsVisible="{xaml:ShortcutBinding PixiEditor.Tools.ApplyTransform, Converter={converters:NotNullToVisibilityConverter}}">
-                    <TextBlock Text="{xaml:ShortcutBinding PixiEditor.Tools.ApplyTransform}" />
+                    <TextBlock Text="{xaml:ShortcutBinding PixiEditor.Tools.ApplyTransform, UseAvaloniaGesture=False}" />
                 </Border>
                 </Border>
             </StackPanel>
             </StackPanel>
         </Button>
         </Button>