-
Notifications
You must be signed in to change notification settings - Fork 103
Touch control #77
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
Open
XITRIX
wants to merge
55
commits into
natinusala:main
Choose a base branch
from
XITRIX:Touch-control
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Touch control #77
Changes from 53 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
831def7
Basic touch event system
XITRIX cdfe9dc
Added Switch implementation
XITRIX 72b07de
Implemented gesture recognizion system
XITRIX 3cd8f27
Added scroll with PanGestureRecognizer
XITRIX a43aa87
Merge branch 'yoga' into Touch-control
XITRIX c66fe06
Naming fixes
XITRIX 5d1d99d
Merge branch 'yoga' into Touch-control
XITRIX ff04633
Merge branch 'yoga' into Touch-control
XITRIX 2b0b125
Merge remote-tracking branch 'Natinusala/yoga' into Touch-control
XITRIX 35277b2
Improvements in recognition states and interruption
XITRIX 67a9501
Some review changes and focus hiding an touch
XITRIX 380415b
Replaced double with float
XITRIX 2cc081d
Improved touch interactions
XITRIX 1f0b0e9
Meson fix
XITRIX e06f7ef
Improved touch mode disabling
XITRIX 009e9ad
made focusTouchMode private set
XITRIX a5342fb
Added scroll acceleration
XITRIX 1314ea4
Added animation time crop on top and bottom boundaries
XITRIX f35f81a
Added touch focus sound
XITRIX b924c51
Added touch sounds
XITRIX f853c27
Fix view shadow on focus in touch mode.
XITRIX 73a51dc
Merge remote-tracking branch 'Natinusala/yoga' into Touch-control
XITRIX 24d247f
Merge remote-tracking branch 'Natinusala/yoga' into Touch-control
XITRIX 8030aef
Moved first responder from public header
XITRIX 0eb4c6d
Updated license
XITRIX 7303792
Merge remote-tracking branch 'Natinusala/yoga' into Touch-control
XITRIX 0ab5950
Replaced focusTouchMode by InputType enum
XITRIX 49987c8
Added comments
XITRIX 79f891d
Review changes
XITRIX f1f28c3
clang formatter used
XITRIX 57c43ba
Added shouldPlayDefaultSound attribute
XITRIX 961e3cf
Review changes
XITRIX 6a5ff7c
Added structs for gesture callbacks
XITRIX e3a65bb
Merge branch 'yoga' into Touch-control
XITRIX a774569
Merge remote-tracking branch 'origin/main' into Touch-control
XITRIX 154a13c
Touch improvements
XITRIX 951effb
Format script run
XITRIX 53c0c14
END phase position fixed
XITRIX 55c3665
Disabled animation on scrollFrame scrolling
XITRIX 8722f51
Added bounce effect to scroll on edges
XITRIX ea63223
Moved metrics to core/geometry
XITRIX 0e2ea97
Added comments
XITRIX 10cfcec
Simplify scrolling limits
XITRIX 8bb51a9
PR review fixes
XITRIX 8d3ab5e
Stop scrolling on tap
XITRIX 2b3b7bf
Merge remote-tracking branch 'origin/main' into Touch-control
XITRIX a2f3899
Changed sound processing
XITRIX f63d92c
Changed function to Event in tap recognizer
XITRIX d5035fe
Gesture documentation update
XITRIX cdd150e
Mouse scrolling
XITRIX 859990c
Merge branch 'main' into Touch-control
XITRIX c8597c4
Fix blink on mouse scroll
XITRIX 9eea766
Fix scroll failed state chech
XITRIX cab3ac6
Review fixes
XITRIX 1d39f59
Merge remote-tracking branch 'origin/main' into Touch-control
XITRIX 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| /* | ||
| Copyright 2021 XITRIX | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <string> | ||
|
|
||
| namespace brls | ||
| { | ||
|
|
||
| // A structure that contains a point in a two-dimensional coordinate system. | ||
| struct Point | ||
| { | ||
| float x; // The x-coordinate of the point. | ||
| float y; // The y-coordinate of the point. | ||
|
|
||
| // Creates a point with location (0,0). | ||
| Point(); | ||
|
|
||
| // Creates a point with coordinates specified as float values. | ||
| Point(float x, float y); | ||
|
|
||
| Point operator+(const Point& a) const; | ||
| Point operator-(const Point& a) const; | ||
| Point operator/(const float& a) const; | ||
| Point operator*(const float& a) const; | ||
| bool operator==(const Point& other) const; | ||
| bool operator!=(const Point& other) const; | ||
| void operator+=(const Point& a); | ||
| void operator-=(const Point& a); | ||
| }; | ||
|
|
||
| // A structure that contains width and height values. | ||
| struct Size | ||
| { | ||
| float width; // A width value. | ||
| float height; // A height value. | ||
|
|
||
| // Creates a size with zero width and height. | ||
| Size(); | ||
|
|
||
| // Creates a size with dimensions specified as float values. | ||
| Size(float width, float height); | ||
|
|
||
| Size operator+(const Size& a) const; | ||
| Size operator-(const Size& a) const; | ||
| Size operator/(const float& a) const; | ||
| Size operator*(const float& a) const; | ||
| bool operator==(const Size& other) const; | ||
| }; | ||
|
|
||
| // Rect | ||
| // A structure that contains the location and dimensions of a rectangle. | ||
| struct Rect | ||
| { | ||
| Point origin; // A point that specifies the coordinates of the rectangle’s origin. | ||
| Size size; // A size that specifies the height and width of the rectangle. | ||
|
|
||
| // Creates a rectangle with origin (0,0) and size (0,0). | ||
| Rect(); | ||
|
|
||
| // Creates a rectangle with the specified origin and size. | ||
| Rect(Point origin, Size size); | ||
|
|
||
| // Creates a rectangle with coordinates and dimensions specified as float values. | ||
| Rect(float x, float y, float width, float height); | ||
|
|
||
| // Returns the width of a rectangle. | ||
| float getWidth() const; | ||
| // Returns the height of a rectangle. | ||
| float getHeight() const; | ||
|
|
||
| // Returns the smallest value for the x-coordinate of the rectangle. | ||
| float getMinX() const; | ||
| // Returns the smallest value for the y-coordinate of the rectangle. | ||
| float getMinY() const; | ||
|
|
||
| // Returns the x-coordinate that establishes the center of a rectangle. | ||
| float getMidX() const; | ||
| // Returns the y-coordinate that establishes the center of the rectangle. | ||
| float getMidY() const; | ||
|
|
||
| // Returns the largest value of the x-coordinate for the rectangle. | ||
| float getMaxX() const; | ||
| // Returns the largest value for the y-coordinate of the rectangle. | ||
| float getMaxY() const; | ||
|
|
||
| bool operator==(const Rect& other) const; | ||
|
|
||
| // Returns true if point is inside this Rect | ||
| bool pointInside(Point point); | ||
|
|
||
| // Returns string with description of current Rect | ||
| std::string describe(); | ||
| }; | ||
|
|
||
| } // namespace brls |
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,94 @@ | ||
| /* | ||
| Copyright 2021 XITRIX | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <borealis/core/audio.hpp> | ||
| #include <borealis/core/input.hpp> | ||
| #include <functional> | ||
|
|
||
| namespace brls | ||
| { | ||
|
|
||
| class View; | ||
|
|
||
| // Represents current gesture state | ||
| enum class GestureState | ||
| { | ||
| INTERRUPTED, // Gesture has been interupted, no callbacks will come | ||
| UNSURE, // Gesture started recognition and not sure if it should interupt other recognizers | ||
| START, // Gesture sure that it match to conditions and will interupt other recognizers | ||
| STAY, // Gesture in process, user still hold finger on screen | ||
| END, // User released their finger from screen, final frame of gesture | ||
| FAILED, // Gesture failed conditions | ||
| }; | ||
|
|
||
| /* | ||
| * Superclass for all recognizers | ||
| * | ||
| * To create a new type of gesture recognizer, you should implement | ||
| * recognitionLoop method. | ||
| * | ||
| * It should contain logic with changing gesture's state. | ||
| * Recognizers' first state is UNSURE, in that state calling stack cannot tell | ||
| * which gesture user tries to apply. I.E. user puts and holds finger on the screen, so it can't be | ||
| * told whether it's going to be a tap or a swipe | ||
| * | ||
| * If gesture has been recognized, change its state to START, but ONLY for the first frame, | ||
| * on the next frame it should be changed to STAY and remain the same until the end, then it | ||
| * should change state to END. | ||
| * | ||
| * When any recognizer changes its state to START, it sends an interrupt event to every recognizer in the stack, | ||
| * so don't forget to handle that case. | ||
| * | ||
| * If gesture does not apply to recognizer's pattern, change its state to FAILED. | ||
| * It could also be used as a placerholder when recognizer is not in use. | ||
| * | ||
| * Use touch argument to get current state of touch. | ||
| * | ||
| * View argument contains the view to which this recognizer is attached. | ||
| * | ||
| * Use soundToPlay pointer to set sound which will be played in current frame. | ||
| * Leave it empty or use SOUND_NONE to not play any sound. | ||
| */ | ||
| class GestureRecognizer | ||
XITRIX marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| public: | ||
| virtual ~GestureRecognizer() { } | ||
|
|
||
| // Main recognition loop, for internal usage only, should not be called anywhere, but Application | ||
XITRIX marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| virtual GestureState recognitionLoop(TouchState touch, View* view, Sound* soundToPlay); | ||
|
|
||
| // Interrupt this recognizer | ||
| // If onlyIfUnsureState == true recognizer will be interupted | ||
| // only if current state is UNSURE | ||
| void interrupt(bool onlyIfUnsureState); | ||
|
|
||
| // If false, this recognizer will be skipped | ||
| bool isEnabled() const { return this->enabled; } | ||
|
|
||
| // If false, this recognizer will be skipped | ||
| void setEnabled(bool enabled) { this->enabled = enabled; } | ||
|
|
||
| // Get the current state of recognizer | ||
| GestureState getState() const { return state; } | ||
|
|
||
| protected: | ||
| GestureState state = GestureState::FAILED; | ||
| bool enabled = true; | ||
| }; | ||
|
|
||
| } // namespace brls | ||
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.