Skip to content

Commit

Permalink
Merge branch 'master' into feature/push-items
Browse files Browse the repository at this point in the history
  • Loading branch information
miroiu committed Nov 21, 2024
2 parents 86409a0 + 12dabda commit 860ad9f
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
> - Breaking Changes:
> - Features:
> - Added InputGroupStyle and OutputGroupStyle to Node
> - Added PanWithMouseWheel, PanHorizontalModifierKey and PanVerticalModifierKey to EditorGestures.Editor
> - Added CornerRadius dependency property to LineConnection, CircuitConnection and StepConnection
> - Added EditorGestures.Editor.PushItems gesture used to start pushing ItemContainers vertically or horizontally
> - Added PushedAreaStyle, PushedAreaOrientation and IsPushingItems dependency properties to NodifyEditor
Expand Down
18 changes: 18 additions & 0 deletions Nodify/EditorGestures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ public NodifyEditorGestures()
ResetViewportLocation = new KeyGesture(Key.Home);
FitToScreen = new KeyGesture(Key.Home, ModifierKeys.Shift);
CancelAction = new AnyGesture(new MouseGesture(MouseAction.RightClick), new KeyGesture(Key.Escape));
PanWithMouseWheel = false;
PanHorizontalModifierKey = ModifierKeys.Shift;
PanVerticalModifierKey = ModifierKeys.None;
}

/// <summary>Gesture used to start selecting using a <see cref="SelectionGestures"/> strategy.</summary>
Expand All @@ -131,6 +134,18 @@ public NodifyEditorGestures()
/// <remarks>Defaults to <see cref="MouseAction.RightClick"/> or <see cref="MouseAction.MiddleClick"/>.</remarks>
public InputGestureRef Pan { get; }

/// <summary>Whether panning using mouse wheel is allowed.</summary>
/// <remarks>Set the <see cref="ZoomModifierKey"/> to allow zooming using the mouse wheel.</remarks>
public bool PanWithMouseWheel { get; set; }

/// <summary>The modifier key required to start panning vertically with the mouse wheel (see <see cref="PanWithMouseWheel"/>)</summary>
/// <remarks>Defaults to <see cref="ModifierKeys.None"/>.</remarks>
public ModifierKeys PanVerticalModifierKey { get; set; }

/// <summary>The modifier key required to start panning horizontally with the mouse wheel (see <see cref="PanWithMouseWheel"/>)</summary>
/// <remarks>Defaults to <see cref="ModifierKeys.Shift"/>.</remarks>
public ModifierKeys PanHorizontalModifierKey { get; set; }

/// <summary>Gesture used to start pushing.</summary>
/// <remarks>Defaults to <see cref="ModifierKeys.Control"/>+<see cref="ModifierKeys.Shift"/>+<see cref="MouseAction.LeftClick"/>.</remarks>
public InputGestureRef PushItems { get; }
Expand Down Expand Up @@ -172,6 +187,9 @@ public void Apply(NodifyEditorGestures gestures)
ResetViewportLocation.Value = gestures.ResetViewportLocation.Value;
FitToScreen.Value = gestures.FitToScreen.Value;
CancelAction.Value = gestures.CancelAction.Value;
PanWithMouseWheel = gestures.PanWithMouseWheel;
PanHorizontalModifierKey = gestures.PanHorizontalModifierKey;
PanVerticalModifierKey = gestures.PanVerticalModifierKey;
PushItems.Value = gestures.PushItems.Value;
}
}
Expand Down
21 changes: 20 additions & 1 deletion Nodify/EditorStates/EditorDefaultState.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Windows.Input;
using System.Windows;
using System.Windows.Input;
using static Nodify.SelectionHelper;

namespace Nodify
Expand Down Expand Up @@ -50,5 +51,23 @@ public override void HandleMouseDown(MouseButtonEventArgs e)
PushState(new EditorPanningState(Editor));
}
}

public override void HandleMouseWheel(MouseWheelEventArgs e)
{
EditorGestures.NodifyEditorGestures gestures = EditorGestures.Mappings.Editor;
if (gestures.PanWithMouseWheel)
{
if (Keyboard.Modifiers == gestures.PanHorizontalModifierKey)
{
Editor.ViewportLocation = new Point(Editor.ViewportLocation.X - e.Delta / Editor.ViewportZoom, Editor.ViewportLocation.Y);
e.Handled = true;
}
else if (Keyboard.Modifiers == gestures.PanVerticalModifierKey)
{
Editor.ViewportLocation = new Point(Editor.ViewportLocation.X, Editor.ViewportLocation.Y - e.Delta / Editor.ViewportZoom);
e.Handled = true;
}
}
}
}
}
40 changes: 40 additions & 0 deletions docs/API-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2879,6 +2879,16 @@ public override void HandleMouseDown(MouseButtonEventArgs e);

`e` [MouseButtonEventArgs](https://docs.microsoft.com/en-us/dotnet/api/System.Windows.Input.MouseButtonEventArgs)

#### HandleMouseWheel(MouseWheelEventArgs)

```csharp
public override void HandleMouseWheel(MouseWheelEventArgs e);
```

**Parameters**

`e` [MouseWheelEventArgs](https://docs.microsoft.com/en-us/dotnet/api/System.Windows.Input.MouseWheelEventArgs)

## EditorGestures Class

**Namespace:** Nodify
Expand Down Expand Up @@ -7077,6 +7087,36 @@ public InputGestureRef Pan { get; set; }

[InputGestureRef](#inputgestureref-class)

#### PanHorizontalModifierKey

```csharp
public ModifierKeys PanHorizontalModifierKey { get; set; }
```

**Property Value**

[ModifierKeys](https://docs.microsoft.com/en-us/dotnet/api/System.Windows.Input.ModifierKeys)

#### PanVerticalModifierKey

```csharp
public ModifierKeys PanVerticalModifierKey { get; set; }
```

**Property Value**

[ModifierKeys](https://docs.microsoft.com/en-us/dotnet/api/System.Windows.Input.ModifierKeys)

#### PanWithMouseWheel

```csharp
public bool PanWithMouseWheel { get; set; }
```

**Property Value**

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean)

#### PushItems

```csharp
Expand Down
40 changes: 40 additions & 0 deletions docs/localization/zh-CN/API-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2879,6 +2879,16 @@ public override void HandleMouseDown(MouseButtonEventArgs e);

`e` [MouseButtonEventArgs](https://docs.microsoft.com/en-us/dotnet/api/System.Windows.Input.MouseButtonEventArgs)

#### HandleMouseWheel(MouseWheelEventArgs)

```csharp
public override void HandleMouseWheel(MouseWheelEventArgs e);
```

**Parameters**

`e` [MouseWheelEventArgs](https://docs.microsoft.com/en-us/dotnet/api/System.Windows.Input.MouseWheelEventArgs)

## EditorGestures Class

**Namespace:** Nodify
Expand Down Expand Up @@ -7077,6 +7087,36 @@ public InputGestureRef Pan { get; set; }

[InputGestureRef](#inputgestureref-class)

#### PanHorizontalModifierKey

```csharp
public ModifierKeys PanHorizontalModifierKey { get; set; }
```

**Property Value**

[ModifierKeys](https://docs.microsoft.com/en-us/dotnet/api/System.Windows.Input.ModifierKeys)

#### PanVerticalModifierKey

```csharp
public ModifierKeys PanVerticalModifierKey { get; set; }
```

**Property Value**

[ModifierKeys](https://docs.microsoft.com/en-us/dotnet/api/System.Windows.Input.ModifierKeys)

#### PanWithMouseWheel

```csharp
public bool PanWithMouseWheel { get; set; }
```

**Property Value**

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean)

#### PushItems

```csharp
Expand Down

0 comments on commit 860ad9f

Please sign in to comment.