Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbind gestures #182

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
> - Added AllowZoomingWhilePanning, AllowZoomingWhileSelecting, AllowZoomingWhileCutting and AllowZoomingWhilePushingItems to EditorState
> - Added EnableToggledSelectingMode, EnableToggledPanningMode, EnableToggledPushingItemsMode and EnableToggledCuttingMode to EditorState
> - Added MinimapState.EnableToggledPanningMode
> - Added Unbind to InputGestureRef and EditorGestures.SelectionGestures
> - Bugfixes:
> - Fixed an issue where the ItemContainer was selected by releasing the mouse button on it, even when the mouse was not captured
> - Fixed an issue where the ItemContainer could open its context menu even when it was not selected
Expand Down
2 changes: 1 addition & 1 deletion Examples/Nodify.Calculator/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public MainWindow()
{
InitializeComponent();

EditorGestures.Mappings.Editor.Cutting.Value = MultiGesture.None;
EditorGestures.Mappings.Editor.Cutting.Unbind();
}
}
}
28 changes: 14 additions & 14 deletions Examples/Nodify.Playground/EditorInputMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ public static void Apply(this EditorGestures mappings, EditorInputMode inputMode
switch (inputMode)
{
case EditorInputMode.PanOnly:
mappings.Editor.Selection.Apply(EditorGestures.SelectionGestures.None);
mappings.Editor.Cutting.Value = MultiGesture.None;
mappings.ItemContainer.Selection.Apply(EditorGestures.SelectionGestures.None);
mappings.ItemContainer.Drag.Value = MultiGesture.None;
mappings.Connector.Connect.Value = MultiGesture.None;
mappings.Editor.Selection.Unbind();
mappings.Editor.Cutting.Unbind();
mappings.ItemContainer.Selection.Unbind();
mappings.ItemContainer.Drag.Unbind();
mappings.Connector.Connect.Unbind();
break;
case EditorInputMode.SelectOnly:
mappings.Editor.Pan.Value = MultiGesture.None;
mappings.Editor.Cutting.Value = MultiGesture.None;
mappings.ItemContainer.Drag.Value = MultiGesture.None;
mappings.Connector.Connect.Value = MultiGesture.None;
mappings.Editor.Pan.Unbind();
mappings.Editor.Cutting.Unbind();
mappings.ItemContainer.Drag.Unbind();
mappings.Connector.Connect.Unbind();
break;
case EditorInputMode.CutOnly:
mappings.Editor.Cutting.Value = new Interactivity.MouseGesture(MouseAction.LeftClick);
mappings.Editor.Selection.Apply(EditorGestures.SelectionGestures.None);
mappings.Editor.Pan.Value = MultiGesture.None;
mappings.ItemContainer.Selection.Apply(EditorGestures.SelectionGestures.None);
mappings.ItemContainer.Drag.Value = MultiGesture.None;
mappings.Connector.Connect.Value = MultiGesture.None;
mappings.Editor.Selection.Unbind();
mappings.Editor.Pan.Unbind();
mappings.ItemContainer.Selection.Unbind();
mappings.ItemContainer.Drag.Unbind();
mappings.Connector.Connect.Unbind();
break;
case EditorInputMode.Default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public class UnboundGestureMappings : EditorGestures

public UnboundGestureMappings()
{
Editor.Selection.Apply(SelectionGestures.None);
ItemContainer.Selection.Apply(SelectionGestures.None);
Connection.Disconnect.Value = MultiGesture.None;
Connector.Connect.Value = MultiGesture.None;
Editor.Selection.Unbind();
ItemContainer.Selection.Unbind();
Connection.Disconnect.Unbind();
Connector.Connect.Unbind();
}
}
}
2 changes: 1 addition & 1 deletion Examples/Nodify.StateMachine/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public MainWindow()
ConnectorState.EnableToggledConnectingMode = true;
NodifyEditor.EnableCuttingLinePreview = true;

EditorGestures.Mappings.Connection.Disconnect.Value = MultiGesture.None;
EditorGestures.Mappings.Connection.Disconnect.Unbind();
EditorGestures.Mappings.Editor.ZoomModifierKey = ModifierKeys.Control;
EditorGestures.Mappings.Editor.PanWithMouseWheel = true;
}
Expand Down
6 changes: 6 additions & 0 deletions Nodify/Interactivity/Gestures/EditorGestures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ public void Apply(SelectionGestures gestures)
Select.Value = gestures.Select.Value;
Cancel.Value = gestures.Cancel.Value;
}

/// <summary>
/// Unbinds the all the gestures used for selection.
/// </summary>
public void Unbind()
=> Apply(None);
}

/// <summary>Gestures for the item containers.</summary>
Expand Down
6 changes: 6 additions & 0 deletions Nodify/Interactivity/Gestures/InputGestureRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ public static implicit operator InputGestureRef(KeyGesture gesture)

public static implicit operator InputGestureRef(MultiGesture gesture)
=> new InputGestureRef { Value = gesture };

/// <summary>
/// Unbinds the current gesture.
/// </summary>
public void Unbind()
=> Value = MultiGesture.None;
}
}
Loading