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

feat(web): allows shifting the recognition zone of an active GestureSource 🐵 #9526

Merged
merged 8 commits into from
Sep 27, 2023

Conversation

jahorton
Copy link
Contributor

This PR allows "pushing" an alternate configuration for the engine's "recognition zone" for an ongoing gesture. This is particularly designed to model the shift from a longpress to subkey-selection, which is generally within a smaller and more restrictive area.

The need for this was discovered as part of #9525; the changes are easily significant enough to merit spinning it off in this manner, as it'll ease that future review.

It also includes a number of new unit tests for GestureSource and adds new "guards" to certain methods, prohibiting a subview from performing update commands either on or separate from its underlying, base Source.

@keymanapp-test-bot skip

@jahorton jahorton added this to the A17S20 milestone Aug 30, 2023
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Aug 30, 2023

User Test Results

Test specification and instructions

User tests are not required

Test Artifacts

Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, I think. I am struggling to keep the abstractions in my head and relate them to how gestures work though!

I see that the build failed, but here's some review feedback anyway 😀

config: GestureRecognizerConfiguration<HoveredItemType>
): Nonoptional<GestureRecognizerConfiguration<HoveredItemType>> {
// Allows configuration pre-processing during this method.
let processingConfig: Mutable<Nonoptional<GestureRecognizerConfiguration<HoveredItemType>>> = {...config} as Nonoptional<GestureRecognizerConfiguration<HoveredItemType>>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is one heck of a type -- starting to feel downright Java!

Copy link
Contributor Author

@jahorton jahorton Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always have loved generics a little too much... and yeah, I felt like this was brushing up against "too much". Fits well, though.

FWIW, it can get much worse - it's been noted that TypeScript's type system is Turing-complete. That'd clearly be way too far.

Okay, maybe I don't love them that much - some people clearly had fun writing their analyses in that issue. (Like the guy who wrote a MUD with them!)

Comment on lines +94 to +101
processingConfig.mouseEventRoot = processingConfig.mouseEventRoot ?? processingConfig.targetRoot;
processingConfig.touchEventRoot = processingConfig.touchEventRoot ?? processingConfig.targetRoot;

processingConfig.inputStartBounds = processingConfig.inputStartBounds ?? processingConfig.targetRoot;
processingConfig.maxRoamingBounds = processingConfig.maxRoamingBounds ?? processingConfig.targetRoot;
processingConfig.safeBounds = processingConfig.safeBounds ?? new PaddedZoneSource([2]);

processingConfig.itemIdentifier = processingConfig.itemIdentifier ?? (() => null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments on why these are being setup this way would be helpful

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the documentation for the fields and their defaults has already been established in JSDoc-style comments on each of them. It shows up via IntelliSense within VS Code.

Granted, why the defaults are set as they are... that is a different question. Is that your concern?

Edit:

And ... now I see[...]

Ah. Got it, the concern would make more sense if the code were appearing without any context.

if(typeof paddingArray == 'number') {
paddingArray = [ paddingArray ];
}
paddingArray = paddingArray ?? [3];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 3? Magic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* If not specified, this will default to a padding of 3px inside the standard safeBounds
* unless `paddedSafeBounds` is defined.

From:

/**
* Used to define a "boundary" slightly more constrained than `safeBounds`. Events that
* start within this pixel range from a safe bound will disable that bound for the duration
* of its corresponding input sequence. May be a number or an array of 1, 2, or 4 numbers,
* as with CSS styling.
*
* If not specified, this will default to a padding of 3px inside the standard safeBounds
* unless `paddedSafeBounds` is defined.
*
* If `paddedSafeBounds` was specified initially, this will be set to `undefined`.
*/
readonly safeBoundPadding?: number | number[];

If memory serves, this default is derived from the corresponding value KMW is already using for the OSK. I've just abstracted its purpose and given it a name and documentation.

Comment on lines +103 to +104
if(!config.paddedSafeBounds) {
let paddingArray = config.safeBoundPadding;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two member names are super conflatable!

@@ -12,39 +10,9 @@ export class GestureRecognizer<HoveredItemType> extends TouchpointCoordinator<Ho
private readonly mouseEngine: MouseEventEngine<HoveredItemType>;
private readonly touchEngine: TouchEventEngine<HoveredItemType>;

protected static preprocessConfig<HoveredItemType>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And ... now I see that my comments relate to pre-existing code. I still think they are good comments though 😁

@mcdurdin mcdurdin modified the milestones: A17S21, A17S22 Sep 15, 2023
@github-actions github-actions bot added web/ and removed web/ labels Sep 22, 2023
@jahorton jahorton force-pushed the feat/web/config-shifting-and-source-rigor branch from 4f182d8 to be19674 Compare September 22, 2023 02:01
@github-actions github-actions bot added web/ and removed web/ labels Sep 22, 2023
@jahorton
Copy link
Contributor Author

jahorton commented Sep 22, 2023

Accidentally pushed a new commit to this PR instead of the one after it in the chain; the force-push simply removed that one commit. Didn't want to revert, as I'd have to revert the reversion in the child PR, and that sounds like a recipe for a headache.

@github-actions github-actions bot added web/ and removed web/ labels Sep 26, 2023
@github-actions github-actions bot added web/ and removed web/ labels Sep 26, 2023
Base automatically changed from refactor/web/matcher-abstraction to feature-gestures September 27, 2023 01:56
@github-actions github-actions bot added web/ and removed web/ labels Sep 27, 2023
@jahorton jahorton merged commit ca6b4f9 into feature-gestures Sep 27, 2023
17 of 19 checks passed
@jahorton jahorton deleted the feat/web/config-shifting-and-source-rigor branch September 27, 2023 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants