mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 01:03:08 +00:00
回退 'Pull Request !40898 : pan recognizer mistack recognize bug fix'
This commit is contained in:
parent
294ceb8b7d
commit
d115972028
@ -544,44 +544,39 @@ bool PanRecognizer::CalculateTruthFingers(bool isDirectionUp) const
|
||||
return GreatNotEqual(totalDistance, judgeDistance) && static_cast<int32_t>(touchPointsDistance_.size()) >= fingers_;
|
||||
}
|
||||
|
||||
PanRecognizer::GestureAcceptResult PanRecognizer::IsPanGestureAcceptInAllDirection(double judgeDistance) const
|
||||
PanRecognizer::GestureAcceptResult PanRecognizer::IsPanGestureAccept() const
|
||||
{
|
||||
double offset = averageDistance_.GetDistance();
|
||||
double screenOffset = averageScreenDistance_.GetDistance();
|
||||
if (fabs(offset) < judgeDistance ||
|
||||
(fabs(screenOffset) < judgeDistance / 2 && inputEventType_ != InputEventType::AXIS)) {
|
||||
return GestureAcceptResult::DETECTING;
|
||||
auto judgeDistance = distance_;
|
||||
if (deviceType_ == SourceType::MOUSE) { // use mouseDistance_
|
||||
judgeDistance = mouseDistance_;
|
||||
}
|
||||
return GestureAcceptResult::ACCEPT;
|
||||
}
|
||||
|
||||
PanRecognizer::GestureAcceptResult PanRecognizer::IsPanGestureAcceptInHorizontalDirection(double judgeDistance) const
|
||||
{
|
||||
if ((direction_.type & PanDirection::HORIZONTAL) != 0) {
|
||||
double offset = averageDistance_.GetX();
|
||||
double screenOffset = averageScreenDistance_.GetDistance();
|
||||
if (fabs(offset) < judgeDistance ||
|
||||
(fabs(screenOffset) < judgeDistance / 2 && inputEventType_ != InputEventType::AXIS)) {
|
||||
if ((direction_.type & PanDirection::ALL) == PanDirection::ALL) {
|
||||
double offset = averageDistance_.GetDistance();
|
||||
if (fabs(offset) < judgeDistance) {
|
||||
return GestureAcceptResult::DETECTING;
|
||||
}
|
||||
if ((direction_.type & PanDirection::LEFT) == 0 && offset < 0) {
|
||||
return GestureAcceptResult::REJECT;
|
||||
}
|
||||
if ((direction_.type & PanDirection::RIGHT) == 0 && offset > 0) {
|
||||
return GestureAcceptResult::REJECT;
|
||||
}
|
||||
return GestureAcceptResult::ACCEPT;
|
||||
}
|
||||
return GestureAcceptResult::DETECTING;
|
||||
}
|
||||
|
||||
PanRecognizer::GestureAcceptResult PanRecognizer::IsPanGestureAcceptInVerticalDirection(double judgeDistance) const
|
||||
{
|
||||
if (fabs(averageDistance_.GetX()) > fabs(averageDistance_.GetY())) {
|
||||
if ((direction_.type & PanDirection::HORIZONTAL) != 0) {
|
||||
double offset = averageDistance_.GetX();
|
||||
if (fabs(offset) < judgeDistance) {
|
||||
return GestureAcceptResult::DETECTING;
|
||||
}
|
||||
if ((direction_.type & PanDirection::LEFT) == 0 && offset < 0) {
|
||||
return GestureAcceptResult::REJECT;
|
||||
}
|
||||
if ((direction_.type & PanDirection::RIGHT) == 0 && offset > 0) {
|
||||
return GestureAcceptResult::REJECT;
|
||||
}
|
||||
return GestureAcceptResult::ACCEPT;
|
||||
}
|
||||
return GestureAcceptResult::DETECTING;
|
||||
}
|
||||
if ((direction_.type & PanDirection::VERTICAL) != 0) {
|
||||
double offset = averageDistance_.GetY();
|
||||
double screenOffset = averageScreenDistance_.GetDistance();
|
||||
if (fabs(offset) < judgeDistance ||
|
||||
(fabs(screenOffset) < judgeDistance / 2 && inputEventType_ != InputEventType::AXIS)) {
|
||||
if (fabs(offset) < judgeDistance) {
|
||||
return GestureAcceptResult::DETECTING;
|
||||
}
|
||||
if (inputEventType_ == InputEventType::AXIS) {
|
||||
@ -604,22 +599,6 @@ PanRecognizer::GestureAcceptResult PanRecognizer::IsPanGestureAcceptInVerticalDi
|
||||
return GestureAcceptResult::DETECTING;
|
||||
}
|
||||
|
||||
PanRecognizer::GestureAcceptResult PanRecognizer::IsPanGestureAccept() const
|
||||
{
|
||||
auto judgeDistance = distance_;
|
||||
if (deviceType_ == SourceType::MOUSE) { // use mouseDistance_
|
||||
judgeDistance = mouseDistance_;
|
||||
}
|
||||
if ((direction_.type & PanDirection::ALL) == PanDirection::ALL) {
|
||||
return IsPanGestureAcceptInAllDirection(judgeDistance);
|
||||
}
|
||||
|
||||
if (fabs(averageDistance_.GetX()) > fabs(averageDistance_.GetY())) {
|
||||
return IsPanGestureAcceptInHorizontalDirection(judgeDistance);
|
||||
}
|
||||
return IsPanGestureAcceptInVerticalDirection(judgeDistance);
|
||||
}
|
||||
|
||||
Offset PanRecognizer::GetRawGlobalLocation(int32_t postEventNodeId)
|
||||
{
|
||||
PointF localPoint(globalPoint_.GetX(), globalPoint_.GetY());
|
||||
@ -963,14 +942,12 @@ void PanRecognizer::UpdateTouchEventInfo(const TouchEvent& event)
|
||||
windowTouchPoint, GetAttachedNode(), false, isPostEventResult_, event.postEventNodeId);
|
||||
delta_ =
|
||||
(Offset(windowPoint.GetX(), windowPoint.GetY()) - Offset(windowTouchPoint.GetX(), windowTouchPoint.GetY()));
|
||||
auto screenDelta = event.GetScreenOffset() - touchPoints_[event.id].GetScreenOffset();
|
||||
|
||||
if (SystemProperties::GetDebugEnabled()) {
|
||||
TAG_LOGD(AceLogTag::ACE_GESTURE, "Delta is x %{public}f, y %{public}f ", delta_.GetX(), delta_.GetY());
|
||||
}
|
||||
mainDelta_ = GetMainAxisDelta();
|
||||
averageDistance_ += delta_ / static_cast<double>(touchPoints_.size());
|
||||
averageScreenDistance_ += screenDelta / static_cast<double>(touchPoints_.size());
|
||||
touchPoints_[event.id] = event;
|
||||
touchPointsDistance_[event.id] += delta_;
|
||||
time_ = event.time;
|
||||
|
@ -117,9 +117,6 @@ private:
|
||||
|
||||
bool ReconcileFrom(const RefPtr<NGGestureRecognizer>& recognizer) override;
|
||||
GestureAcceptResult IsPanGestureAccept() const;
|
||||
GestureAcceptResult IsPanGestureAcceptInAllDirection(double judgeDistance) const;
|
||||
GestureAcceptResult IsPanGestureAcceptInHorizontalDirection(double judgeDistance) const;
|
||||
GestureAcceptResult IsPanGestureAcceptInVerticalDirection(double judgeDistance) const;
|
||||
bool CalculateTruthFingers(bool isDirectionUp) const;
|
||||
void UpdateTouchPointInVelocityTracker(const TouchEvent& event, bool end = false);
|
||||
void UpdateAxisPointInVelocityTracker(const AxisEvent& event, bool end = false);
|
||||
@ -153,7 +150,6 @@ private:
|
||||
double mouseDistance_ = 0.0;
|
||||
AxisEvent lastAxisEvent_;
|
||||
Offset averageDistance_;
|
||||
Offset averageScreenDistance_;
|
||||
std::map<int32_t, Offset> touchPointsDistance_;
|
||||
Offset delta_;
|
||||
double mainDelta_ = 0.0;
|
||||
|
Loading…
Reference in New Issue
Block a user