-
-
Notifications
You must be signed in to change notification settings - Fork 65
More tap gestures #117
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
Merged
Merged
More tap gestures #117
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
40b10b2
Initial work for Gtk and UIKit
bbrk24 c75bbb0
Get right-click and long press fully working in GTK 4
bbrk24 7e692d6
Fix UIKit implementation
bbrk24 e9aabc4
Get other press types working in AppKitBackend
bbrk24 a99d9dd
Fix tap gesture test
bbrk24 6dd411c
Add parameter to Gtk3 and WinUI, and remove extraneous override in UIKit
bbrk24 242e5a1
address PR comments
bbrk24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,72 @@ | ||
| import CGtk | ||
|
|
||
| /// `GtkGestureLongPress` is a `GtkGesture` for long presses. | ||
| /// | ||
| /// This gesture is also known as “Press and Hold”. | ||
| /// | ||
| /// When the timeout is exceeded, the gesture is triggering the | ||
| /// [[email protected]::pressed] signal. | ||
| /// | ||
| /// If the touchpoint is lifted before the timeout passes, or if | ||
| /// it drifts too far of the initial press point, the | ||
| /// [[email protected]::cancelled] signal will be emitted. | ||
| /// | ||
| /// How long the timeout is before the ::pressed signal gets emitted is | ||
| /// determined by the [[email protected]:gtk-long-press-time] setting. | ||
| /// It can be modified by the [[email protected]:delay-factor] | ||
| /// property. | ||
| public class GestureLongPress: GestureSingle { | ||
| /// Returns a newly created `GtkGesture` that recognizes long presses. | ||
| public convenience init() { | ||
| self.init( | ||
| gtk_gesture_long_press_new() | ||
| ) | ||
| } | ||
|
|
||
| public override func registerSignals() { | ||
| super.registerSignals() | ||
|
|
||
| addSignal(name: "cancelled") { [weak self] () in | ||
| guard let self = self else { return } | ||
| self.cancelled?(self) | ||
| } | ||
|
|
||
| let handler1: | ||
| @convention(c) (UnsafeMutableRawPointer, Double, Double, UnsafeMutableRawPointer) -> | ||
| Void = | ||
| { _, value1, value2, data in | ||
| SignalBox2<Double, Double>.run(data, value1, value2) | ||
| } | ||
|
|
||
| addSignal(name: "pressed", handler: gCallback(handler1)) { | ||
| [weak self] (param0: Double, param1: Double) in | ||
| guard let self = self else { return } | ||
| self.pressed?(self, param0, param1) | ||
| } | ||
|
|
||
| let handler2: | ||
| @convention(c) (UnsafeMutableRawPointer, OpaquePointer, UnsafeMutableRawPointer) -> Void = | ||
| { _, value1, data in | ||
| SignalBox1<OpaquePointer>.run(data, value1) | ||
| } | ||
|
|
||
| addSignal(name: "notify::delay-factor", handler: gCallback(handler2)) { | ||
| [weak self] (param0: OpaquePointer) in | ||
| guard let self = self else { return } | ||
| self.notifyDelayFactor?(self, param0) | ||
| } | ||
| } | ||
|
|
||
| /// Factor by which to modify the default timeout. | ||
| @GObjectProperty(named: "delay-factor") public var delayFactor: Double | ||
|
|
||
| /// Emitted whenever a press moved too far, or was released | ||
| /// before [[email protected]::pressed] happened. | ||
| public var cancelled: ((GestureLongPress) -> Void)? | ||
|
|
||
| /// Emitted whenever a press goes unmoved/unreleased longer than | ||
| /// what the GTK defaults tell. | ||
| public var pressed: ((GestureLongPress, Double, Double) -> Void)? | ||
|
|
||
| public var notifyDelayFactor: ((GestureLongPress, OpaquePointer) -> Void)? | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.