Browse Source

Merge pull request #100 from PixiEditor/action-display

Added action display at the bottom
Krzysztof Krysiński 4 years ago
parent
commit
dc3fe87d11

+ 20 - 1
PixiEditor/Models/Tools/Tool.cs

@@ -8,6 +8,7 @@ namespace PixiEditor.Models.Tools
     public abstract class Tool : NotifyableObject
     public abstract class Tool : NotifyableObject
     {
     {
         private bool isActive;
         private bool isActive;
+        private string actionDisplay = "";
 
 
         public abstract ToolType ToolType { get; }
         public abstract ToolType ToolType { get; }
 
 
@@ -15,7 +16,17 @@ namespace PixiEditor.Models.Tools
 
 
         public bool HideHighlight { get; set; } = false;
         public bool HideHighlight { get; set; } = false;
 
 
-        public string Tooltip { get; set; }
+        public string Tooltip { get; set; }
+
+        public string ActionDisplay
+        {
+            get => actionDisplay;
+            set
+            {
+                actionDisplay = value;
+                RaisePropertyChanged("ActionDisplay");
+            }
+        }
 
 
         public bool IsActive
         public bool IsActive
         {
         {
@@ -41,6 +52,14 @@ namespace PixiEditor.Models.Tools
         {
         {
         }
         }
 
 
+        public virtual void OnKeyDown(KeyEventArgs e)
+        {
+        }
+
+        public virtual void OnKeyUp(KeyEventArgs e)
+        {
+        }
+
         public virtual void OnRecordingLeftMouseDown(MouseEventArgs e)
         public virtual void OnRecordingLeftMouseDown(MouseEventArgs e)
         {
         {
         }
         }

+ 17 - 0
PixiEditor/Models/Tools/Tools/BrightnessTool.cs

@@ -21,6 +21,7 @@ namespace PixiEditor.Models.Tools.Tools
 
 
         public BrightnessTool()
         public BrightnessTool()
         {
         {
+            ActionDisplay = "Draw on pixel to make it brighter. Hold Ctrl to darken.";
             Tooltip = "Makes pixel brighter or darker pixel (U). Hold Ctrl to make pixel darker.";
             Tooltip = "Makes pixel brighter or darker pixel (U). Hold Ctrl to make pixel darker.";
             Toolbar = new BrightnessToolToolbar(CorrectionFactor);
             Toolbar = new BrightnessToolToolbar(CorrectionFactor);
         }
         }
@@ -34,6 +35,22 @@ namespace PixiEditor.Models.Tools.Tools
             pixelsVisited.Clear();
             pixelsVisited.Clear();
         }
         }
 
 
+        public override void OnKeyDown(KeyEventArgs e)
+        {
+            if (e.Key == Key.LeftCtrl)
+            {
+                ActionDisplay = "Draw on pixel to make it darker. Release Ctrl to brighten.";
+            }
+        }
+
+        public override void OnKeyUp(KeyEventArgs e)
+        {
+            if (e.Key == Key.LeftCtrl)
+            {
+                ActionDisplay = "Draw on pixel to make it brighter. Hold Ctrl to darken.";
+            }
+        }
+
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         {
         {
             int toolSize = Toolbar.GetSetting<SizeSetting>("ToolSize").Value;
             int toolSize = Toolbar.GetSetting<SizeSetting>("ToolSize").Value;

+ 18 - 0
PixiEditor/Models/Tools/Tools/CircleTool.cs

@@ -1,6 +1,7 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
+using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media;
 using PixiEditor.Helpers.Extensions;
 using PixiEditor.Helpers.Extensions;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
@@ -14,11 +15,28 @@ namespace PixiEditor.Models.Tools.Tools
     {
     {
         public CircleTool()
         public CircleTool()
         {
         {
+            ActionDisplay = "Click and move mouse to draw a circle. Hold Shift to draw an even one.";
             Tooltip = "Draws circle on canvas (C). Hold Shift to draw even circle.";
             Tooltip = "Draws circle on canvas (C). Hold Shift to draw even circle.";
         }
         }
 
 
         public override ToolType ToolType => ToolType.Circle;
         public override ToolType ToolType => ToolType.Circle;
 
 
+        public override void OnKeyDown(KeyEventArgs e)
+        {
+            if (e.Key == Key.LeftShift)
+            {
+                ActionDisplay = "Click and move mouse to draw an even circle.";
+            }
+        }
+
+        public override void OnKeyUp(KeyEventArgs e)
+        {
+            if (e.Key == Key.LeftShift)
+            {
+                ActionDisplay = "Click and move mouse to draw a circle. Hold Shift to draw an even one.";
+            }
+        }
+
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         {
         {
             int thickness = Toolbar.GetSetting<SizeSetting>("ToolSize").Value;
             int thickness = Toolbar.GetSetting<SizeSetting>("ToolSize").Value;

+ 1 - 0
PixiEditor/Models/Tools/Tools/ColorPickerTool.cs

@@ -10,6 +10,7 @@ namespace PixiEditor.Models.Tools.Tools
         public ColorPickerTool()
         public ColorPickerTool()
         {
         {
             HideHighlight = true;
             HideHighlight = true;
+            ActionDisplay = "Press on pixel to make it the primary color.";
             Tooltip = "Swaps primary color with selected on canvas. (O)";
             Tooltip = "Swaps primary color with selected on canvas. (O)";
         }
         }
 
 

+ 2 - 1
PixiEditor/Models/Tools/Tools/EraserTool.cs

@@ -13,7 +13,8 @@ namespace PixiEditor.Models.Tools.Tools
 
 
         public EraserTool()
         public EraserTool()
         {
         {
-            Tooltip = "Erasers color from pixel (E)";
+            ActionDisplay = "Draw to remove color from a pixel.";
+            Tooltip = "Erasers color from pixel. (E)";
             Toolbar = new BasicToolbar();
             Toolbar = new BasicToolbar();
         }
         }
 
 

+ 2 - 1
PixiEditor/Models/Tools/Tools/FloodFill.cs

@@ -11,7 +11,8 @@ namespace PixiEditor.Models.Tools.Tools
     {
     {
         public FloodFill()
         public FloodFill()
         {
         {
-            Tooltip = "Fills area with color (G)";
+            ActionDisplay = "Press on a area to fill it.";
+            Tooltip = "Fills area with color. (G)";
         }
         }
 
 
         public override ToolType ToolType => ToolType.Bucket;
         public override ToolType ToolType => ToolType.Bucket;

+ 18 - 0
PixiEditor/Models/Tools/Tools/LineTool.cs

@@ -1,5 +1,6 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
+using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Enums;
@@ -16,6 +17,7 @@ namespace PixiEditor.Models.Tools.Tools
 
 
         public LineTool()
         public LineTool()
         {
         {
+            ActionDisplay = "Click and move to draw a line. Hold Shift to draw an even one.";
             Tooltip = "Draws line on canvas (L). Hold Shift to draw even line.";
             Tooltip = "Draws line on canvas (L). Hold Shift to draw even line.";
             Toolbar = new BasicToolbar();
             Toolbar = new BasicToolbar();
             circleTool = new CircleTool();
             circleTool = new CircleTool();
@@ -23,6 +25,22 @@ namespace PixiEditor.Models.Tools.Tools
 
 
         public override ToolType ToolType => ToolType.Line;
         public override ToolType ToolType => ToolType.Line;
 
 
+        public override void OnKeyDown(KeyEventArgs e)
+        {
+            if (e.Key == Key.LeftShift)
+            {
+                ActionDisplay = "Click and move mouse to draw an even line.";
+            }
+        }
+
+        public override void OnKeyUp(KeyEventArgs e)
+        {
+            if (e.Key == Key.LeftShift)
+            {
+                ActionDisplay = "Click and move to draw a line. Hold Shift to draw an even one.";
+            }
+        }
+
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         {
         {
             BitmapPixelChanges pixels =
             BitmapPixelChanges pixels =

+ 18 - 1
PixiEditor/Models/Tools/Tools/MoveTool.cs

@@ -30,7 +30,8 @@ namespace PixiEditor.Models.Tools.Tools
 
 
         public MoveTool()
         public MoveTool()
         {
         {
-            Tooltip = "Moves selected pixels (V). Hold Ctrl to move all layers";
+            ActionDisplay = "Hold mouse to move selected pixels. Hold Ctrl to move all layers.";
+            Tooltip = "Moves selected pixels (V). Hold Ctrl to move all layers.";
             Cursor = Cursors.Arrow;
             Cursor = Cursors.Arrow;
             HideHighlight = true;
             HideHighlight = true;
             RequiresPreviewLayer = true;
             RequiresPreviewLayer = true;
@@ -41,6 +42,22 @@ namespace PixiEditor.Models.Tools.Tools
 
 
         public override ToolType ToolType => ToolType.Move;
         public override ToolType ToolType => ToolType.Move;
 
 
+        public override void OnKeyDown(KeyEventArgs e)
+        {
+            if (e.Key == Key.LeftCtrl)
+            {
+                ActionDisplay = "Hold mouse to move all selected layers.";
+            }
+        }
+
+        public override void OnKeyUp(KeyEventArgs e)
+        {
+            if (e.Key == Key.LeftCtrl)
+            {
+                ActionDisplay = "Hold mouse to move selected pixels. Hold Ctrl to move all layers.";
+            }
+        }
+
         public override void AfterAddedUndo()
         public override void AfterAddedUndo()
         {
         {
             if (currentSelection != null && currentSelection.Length != 0)
             if (currentSelection != null && currentSelection.Length != 0)

+ 1 - 0
PixiEditor/Models/Tools/Tools/MoveViewportTool.cs

@@ -13,6 +13,7 @@ namespace PixiEditor.Models.Tools.Tools
         {
         {
             HideHighlight = true;
             HideHighlight = true;
             Cursor = Cursors.SizeAll;
             Cursor = Cursors.SizeAll;
+            ActionDisplay = "Click and move to pan viewport.";
             Tooltip = "Move viewport. (H)";
             Tooltip = "Move viewport. (H)";
         }
         }
 
 

+ 2 - 1
PixiEditor/Models/Tools/Tools/PenTool.cs

@@ -16,7 +16,8 @@ namespace PixiEditor.Models.Tools.Tools
         public PenTool()
         public PenTool()
         {
         {
             Cursor = Cursors.Pen;
             Cursor = Cursors.Pen;
-            Tooltip = "Standard brush (B)";
+            ActionDisplay = "Click and move to draw.";
+            Tooltip = "Standard brush. (B)";
             Toolbar = new BasicToolbar();
             Toolbar = new BasicToolbar();
             toolSizeSetting = Toolbar.GetSetting<SizeSetting>("ToolSize");
             toolSizeSetting = Toolbar.GetSetting<SizeSetting>("ToolSize");
             lineTool = new LineTool();
             lineTool = new LineTool();

+ 18 - 0
PixiEditor/Models/Tools/Tools/RectangleTool.cs

@@ -1,6 +1,7 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
+using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media;
 using PixiEditor.Helpers.Extensions;
 using PixiEditor.Helpers.Extensions;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
@@ -14,6 +15,7 @@ namespace PixiEditor.Models.Tools.Tools
     {
     {
         public RectangleTool()
         public RectangleTool()
         {
         {
+            ActionDisplay = "Click and move to draw a rectangle.  Hold Shift to draw square.";
             Tooltip = "Draws rectangle on canvas (R). Hold Shift to draw square.";
             Tooltip = "Draws rectangle on canvas (R). Hold Shift to draw square.";
         }
         }
 
 
@@ -21,6 +23,22 @@ namespace PixiEditor.Models.Tools.Tools
 
 
         public bool Filled { get; set; } = false;
         public bool Filled { get; set; } = false;
 
 
+        public override void OnKeyDown(KeyEventArgs e)
+        {
+            if (e.Key == Key.LeftShift)
+            {
+                ActionDisplay = "Click and move to draw a square.";
+            }
+        }
+
+        public override void OnKeyUp(KeyEventArgs e)
+        {
+            if (e.Key == Key.LeftShift)
+            {
+                ActionDisplay = "Click and move to draw a rectangle.  Hold Shift to draw square.";
+            }
+        }
+
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
         {
         {
             int thickness = Toolbar.GetSetting<SizeSetting>("ToolSize").Value;
             int thickness = Toolbar.GetSetting<SizeSetting>("ToolSize").Value;

+ 1 - 0
PixiEditor/Models/Tools/Tools/SelectTool.cs

@@ -19,6 +19,7 @@ namespace PixiEditor.Models.Tools.Tools
 
 
         public SelectTool()
         public SelectTool()
         {
         {
+            ActionDisplay = "Click and move to select an area.";
             Tooltip = "Selects area. (M)";
             Tooltip = "Selects area. (M)";
             Toolbar = new SelectToolToolbar();
             Toolbar = new SelectToolToolbar();
         }
         }

+ 17 - 0
PixiEditor/Models/Tools/Tools/ZoomTool.cs

@@ -19,12 +19,29 @@ namespace PixiEditor.Models.Tools.Tools
         {
         {
             HideHighlight = true;
             HideHighlight = true;
             CanStartOutsideCanvas = true;
             CanStartOutsideCanvas = true;
+            ActionDisplay = "Click and move to zoom. Click to zoom in, hold alt and click to zoom out.";
             Tooltip = "Zooms viewport (Z). Click to zoom in, hold alt and click to zoom out.";
             Tooltip = "Zooms viewport (Z). Click to zoom in, hold alt and click to zoom out.";
             pixelsPerZoomMultiplier = workAreaWidth / ZoomSensitivityMultiplier;
             pixelsPerZoomMultiplier = workAreaWidth / ZoomSensitivityMultiplier;
         }
         }
 
 
         public override ToolType ToolType => ToolType.Zoom;
         public override ToolType ToolType => ToolType.Zoom;
 
 
+        public override void OnKeyDown(KeyEventArgs e)
+        {
+            if (e.Key == Key.LeftAlt)
+            {
+                ActionDisplay = "Click and move to zoom. Click to zoom out, release alt and click to zoom in.";
+            }
+        }
+
+        public override void OnKeyUp(KeyEventArgs e)
+        {
+            if (e.Key == Key.LeftAlt)
+            {
+                ActionDisplay = "Click and move to zoom. Click to zoom in, hold alt and click to zoom out.";
+            }
+        }
+
         public override void OnRecordingLeftMouseDown(MouseEventArgs e)
         public override void OnRecordingLeftMouseDown(MouseEventArgs e)
         {
         {
             startingX = MousePositionConverter.GetCursorPosition().X;
             startingX = MousePositionConverter.GetCursorPosition().X;

+ 3 - 0
PixiEditor/ViewModels/SubViewModels/Main/IoViewModel.cs

@@ -76,6 +76,7 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
             }
             }
 
 
             Owner.ShortcutController.KeyPressed(args.Key, Keyboard.Modifiers);
             Owner.ShortcutController.KeyPressed(args.Key, Keyboard.Modifiers);
+            Owner.BitmapManager.SelectedTool.OnKeyDown(args);
         }
         }
 
 
         private void MouseDown(object parameter)
         private void MouseDown(object parameter)
@@ -135,6 +136,8 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
                 Owner.ToolsSubViewModel.SetActiveTool(Owner.ToolsSubViewModel.LastActionTool);
                 Owner.ToolsSubViewModel.SetActiveTool(Owner.ToolsSubViewModel.LastActionTool);
                 ShortcutController.BlockShortcutExecution = false;
                 ShortcutController.BlockShortcutExecution = false;
             }
             }
+
+            Owner.BitmapManager.SelectedTool.OnKeyUp(args);
         }
         }
     }
     }
 }
 }

+ 1 - 0
PixiEditor/Views/MainWindow.xaml

@@ -386,6 +386,7 @@
             </avalondock:DockingManager>
             </avalondock:DockingManager>
         </Grid>
         </Grid>
         <DockPanel Grid.Row="3" Grid.Column="1">
         <DockPanel Grid.Row="3" Grid.Column="1">
+            <TextBlock Text="{Binding BitmapManager.SelectedTool.ActionDisplay}" Foreground="White" FontSize="16"  VerticalAlignment="Center"/>
             <StackPanel DockPanel.Dock="Right" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
             <StackPanel DockPanel.Dock="Right" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
                 <TextBlock Text="X:" Foreground="White" FontSize="16"/>
                 <TextBlock Text="X:" Foreground="White" FontSize="16"/>
                 <TextBlock Margin="4,0,10,0" Text="{Binding IoSubViewModel.MouseXOnCanvas, Converter={StaticResource DoubleToIntConverter}}" Foreground="White" FontSize="16"/>
                 <TextBlock Margin="4,0,10,0" Text="{Binding IoSubViewModel.MouseXOnCanvas, Converter={StaticResource DoubleToIntConverter}}" Foreground="White" FontSize="16"/>