-
-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from miroiu/feature/146-connection
Enable custom input processing for BaseConnection
- Loading branch information
Showing
11 changed files
with
166 additions
and
22 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
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,11 @@ | ||
namespace Nodify.Interactivity | ||
{ | ||
public static partial class ConnectionState | ||
{ | ||
internal static void RegisterDefaultHandlers() | ||
{ | ||
InputProcessor.Shared<BaseConnection>.RegisterHandlerFactory(elem => new Disconnect(elem)); | ||
InputProcessor.Shared<BaseConnection>.RegisterHandlerFactory(elem => new Split(elem)); | ||
} | ||
} | ||
} |
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,41 @@ | ||
using System.Windows.Input; | ||
|
||
namespace Nodify.Interactivity | ||
{ | ||
public static partial class ConnectionState | ||
{ | ||
/// <summary> | ||
/// Represents a state in which a connection can be disconnected from its connectors based on specific gestures. | ||
/// </summary> | ||
public class Disconnect : InputElementState<BaseConnection> | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Disconnect"/> class. | ||
/// </summary> | ||
/// <param name="connection">The <see cref="BaseConnection"/> element associated with this state.</param> | ||
public Disconnect(BaseConnection connection) : base(connection) | ||
{ | ||
} | ||
|
||
protected override void OnMouseDown(MouseButtonEventArgs e) | ||
{ | ||
EditorGestures.ConnectionGestures gestures = EditorGestures.Mappings.Connection; | ||
if (gestures.Disconnect.Matches(e.Source, e)) | ||
{ | ||
Element.Focus(); | ||
e.Handled = true; // prevent interacting with the editor | ||
} | ||
} | ||
|
||
protected override void OnMouseUp(MouseButtonEventArgs e) | ||
{ | ||
EditorGestures.ConnectionGestures gestures = EditorGestures.Mappings.Connection; | ||
if (gestures.Disconnect.Matches(e.Source, e)) | ||
{ | ||
Element.Remove(); | ||
e.Handled = true; // prevent opening context menu | ||
} | ||
} | ||
} | ||
} | ||
} |
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,33 @@ | ||
using System.Windows.Input; | ||
|
||
namespace Nodify.Interactivity | ||
{ | ||
public static partial class ConnectionState | ||
{ | ||
/// <summary> | ||
/// Represents a state in which a connection can be split. | ||
/// </summary> | ||
public class Split : InputElementState<BaseConnection> | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Split"/> class. | ||
/// </summary> | ||
/// <param name="connection">The <see cref="BaseConnection"/> element associated with this state.</param> | ||
public Split(BaseConnection connection) : base(connection) | ||
{ | ||
} | ||
|
||
protected override void OnMouseDown(MouseButtonEventArgs e) | ||
{ | ||
EditorGestures.ConnectionGestures gestures = EditorGestures.Mappings.Connection; | ||
if (gestures.Split.Matches(e.Source, e)) | ||
{ | ||
Element.Focus(); | ||
Element.SplitAtLocation(e.GetPosition(Element)); | ||
|
||
e.Handled = true; // prevent interacting with the editor | ||
} | ||
} | ||
} | ||
} | ||
} |
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