-
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow changing editor gestures at runtime (#104)
Separated selection gestures for ItemContainer and GroupingNode from the NodifyEditor Added new gesture types: AnyGesture, AllGestures, and NodifyGesture Fixed a bug where the item container would incorrectly transition to the dragging state on mouse over
- Loading branch information
Showing
18 changed files
with
422 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System.Windows.Input; | ||
|
||
namespace Nodify.Playground | ||
{ | ||
public enum EditorInputMode | ||
{ | ||
Default, | ||
PanOnly, | ||
SelectOnly | ||
} | ||
|
||
public enum EditorGesturesMappings | ||
{ | ||
Default, | ||
Custom | ||
} | ||
|
||
public static class EditorInputModeExtensions | ||
{ | ||
public static void Apply(this EditorGestures mappings, EditorInputMode inputMode) | ||
{ | ||
mappings.Apply(PlaygroundSettings.Instance.EditorGesturesMappings.ToGesturesMappings()); | ||
|
||
switch (inputMode) | ||
{ | ||
case EditorInputMode.PanOnly: | ||
mappings.Editor.Selection.Apply(EditorGestures.SelectionGestures.None); | ||
mappings.ItemContainer.Selection.Apply(EditorGestures.SelectionGestures.None); | ||
mappings.ItemContainer.Drag.Value = MultiGesture.None; | ||
mappings.Connector.Connect.Value = MultiGesture.None; | ||
break; | ||
case EditorInputMode.SelectOnly: | ||
mappings.Editor.Pan.Value = MultiGesture.None; | ||
mappings.ItemContainer.Drag.Value = MultiGesture.None; | ||
mappings.Connector.Connect.Value = MultiGesture.None; | ||
break; | ||
case EditorInputMode.Default: | ||
break; | ||
} | ||
} | ||
|
||
public static void Apply(this EditorGestures value, EditorGesturesMappings mappings) | ||
{ | ||
var newMappings = mappings.ToGesturesMappings(); | ||
value.Apply(newMappings); | ||
} | ||
|
||
public static EditorGestures ToGesturesMappings(this EditorGesturesMappings mappings) | ||
{ | ||
return mappings switch | ||
{ | ||
EditorGesturesMappings.Custom => new CustomGesturesMappings(), | ||
_ => new EditorGestures() | ||
}; | ||
} | ||
} | ||
|
||
public class CustomGesturesMappings : EditorGestures | ||
{ | ||
public CustomGesturesMappings() | ||
{ | ||
Editor.Pan.Value = new AnyGesture(new MouseGesture(MouseAction.LeftClick), new MouseGesture(MouseAction.MiddleClick)); | ||
Editor.ZoomModifierKey = ModifierKeys.Control; | ||
Editor.Selection.Apply(new SelectionGestures(MouseAction.RightClick)); | ||
// comment to drag with right click - we copy the default gestures of the item container which uses left click for selection | ||
ItemContainer.Drag.Value = new AnyGesture(ItemContainer.Selection.Replace.Value, ItemContainer.Selection.Remove.Value, ItemContainer.Selection.Append.Value, ItemContainer.Selection.Invert.Value); | ||
ItemContainer.Selection.Apply(Editor.Selection); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.