From 4efbdc677ed39c64b3359a7710a1880247a7e47b Mon Sep 17 00:00:00 2001 From: "joogab.yun" Date: Wed, 14 Dec 2022 15:25:19 +0900 Subject: [PATCH] [Tizen] Add RecalculatePosition api for rotation Change-Id: I5e5ebacfc2531ff95465bb41d8a516fea106d44d --- .../adaptor-framework/scene-holder-impl.cpp | 14 +++++++++----- dali/integration-api/adaptor-framework/scene-holder-impl.h | 10 +++++++--- dali/internal/window-system/common/gl-window-impl.cpp | 12 ++++++------ dali/internal/window-system/common/gl-window-impl.h | 6 +++--- dali/internal/window-system/common/window-impl.cpp | 6 ++---- dali/internal/window-system/common/window-impl.h | 4 ++-- 6 files changed, 29 insertions(+), 23 deletions(-) diff --git a/dali/integration-api/adaptor-framework/scene-holder-impl.cpp b/dali/integration-api/adaptor-framework/scene-holder-impl.cpp index aa033eb..182c546 100644 --- a/dali/integration-api/adaptor-framework/scene-holder-impl.cpp +++ b/dali/integration-api/adaptor-framework/scene-holder-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -212,10 +212,10 @@ void SceneHolder::SetAdaptor(Dali::Adaptor& adaptor) // Create the scene PositionSize surfacePositionSize = mSurface->GetPositionSize(); - int windowOrientation = mSurface->GetSurfaceOrientation(); - int screenOrientation = mSurface->GetScreenOrientation(); + int windowOrientation = mSurface->GetSurfaceOrientation(); + int screenOrientation = mSurface->GetScreenOrientation(); - mScene = Dali::Integration::Scene::New(Size(static_cast(surfacePositionSize.width), static_cast(surfacePositionSize.height)), windowOrientation, screenOrientation); + mScene = Dali::Integration::Scene::New(Size(static_cast(surfacePositionSize.width), static_cast(surfacePositionSize.height)), windowOrientation, screenOrientation); Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor); mAdaptor = &adaptorImpl; @@ -276,7 +276,8 @@ void SceneHolder::FeedTouchPoint(Dali::Integration::Point& point, int timeStamp) timeStamp = TimeService::GetMilliSeconds(); } - RecalculateTouchPosition(point); + Vector2 convertedPosition = RecalculatePosition(point.GetScreenPosition()); + point.SetScreenPosition(convertedPosition); Integration::TouchEvent touchEvent; Integration::HoverEvent hoverEvent; @@ -311,6 +312,9 @@ void SceneHolder::FeedWheelEvent(Dali::Integration::WheelEvent& wheelEvent) // Keep the handle alive until the core events are processed. Dali::BaseHandle sceneHolder(this); + Vector2 convertedPosition = RecalculatePosition(wheelEvent.point); + wheelEvent.point = convertedPosition; + mScene.QueueEvent(wheelEvent); mAdaptor->ProcessCoreEvents(); } diff --git a/dali/integration-api/adaptor-framework/scene-holder-impl.h b/dali/integration-api/adaptor-framework/scene-holder-impl.h index 8868d52..9911817 100644 --- a/dali/integration-api/adaptor-framework/scene-holder-impl.h +++ b/dali/integration-api/adaptor-framework/scene-holder-impl.h @@ -335,10 +335,14 @@ private: // The following methods can be overridden if required virtual void OnResume(){}; /** - * Recalculate the touch position if required - * @param[in,out] point The touch point + * Recalculate the position if required + * @param[in] position The screen position + * @return converted position by oriention */ - virtual void RecalculateTouchPosition(Integration::Point& point){}; + virtual Vector2 RecalculatePosition(const Vector2& position) + { + return position; + }; private: /** diff --git a/dali/internal/window-system/common/gl-window-impl.cpp b/dali/internal/window-system/common/gl-window-impl.cpp index db58107..1a33ca2 100644 --- a/dali/internal/window-system/common/gl-window-impl.cpp +++ b/dali/internal/window-system/common/gl-window-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -494,7 +494,9 @@ void GlWindow::OnTouchPoint(Dali::Integration::Point& point, int timeStamp) return; } - RecalculateTouchPosition(point); + Vector2 convertedPosition = RecalculatePosition(point.GetScreenPosition()); + point.SetScreenPosition(convertedPosition); + Dali::TouchEvent touchEvent = Dali::Integration::NewTouchEvent(timeStamp, point); Dali::GlWindow handle(this); mTouchedSignal.Emit(touchEvent); @@ -540,9 +542,8 @@ void GlWindow::OnRotation(const RotationEvent& rotation) } } -void GlWindow::RecalculateTouchPosition(Integration::Point& point) +Vector2 GlWindow::RecalculatePosition(const Vector2& position) { - Vector2 position = point.GetScreenPosition(); Vector2 convertedPosition; switch(mTotalRotationAngle) @@ -571,8 +572,7 @@ void GlWindow::RecalculateTouchPosition(Integration::Point& point) break; } } - - point.SetScreenPosition(convertedPosition); + return convertedPosition; } void GlWindow::SetAvailableAnlges(const std::vector& angles) diff --git a/dali/internal/window-system/common/gl-window-impl.h b/dali/internal/window-system/common/gl-window-impl.h index 98f8c93..7df776c 100644 --- a/dali/internal/window-system/common/gl-window-impl.h +++ b/dali/internal/window-system/common/gl-window-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_GL_WINDOW_IMPL_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -293,9 +293,9 @@ private: void SetEventHandler(); /** - * @brief calculate touch position for rotation. + * @brief calculate screen position for rotation. */ - void RecalculateTouchPosition(Integration::Point& point); + Vector2 RecalculatePosition(const Vector2& position); /** * @brief Sets window and class name. diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index e4c2cd5..9175ca7 100644 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -1076,9 +1076,8 @@ void Window::OnAccessibilityDisabled() bridge->RemoveTopLevelWindow(accessible); } -void Window::RecalculateTouchPosition(Integration::Point& point) +Vector2 Window::RecalculatePosition(const Vector2& position) { - Vector2 position = point.GetScreenPosition(); Vector2 convertedPosition; switch(mRotationAngle) @@ -1107,8 +1106,7 @@ void Window::RecalculateTouchPosition(Integration::Point& point) break; } } - - point.SetScreenPosition(convertedPosition); + return convertedPosition; } Dali::Window Window::Get(Dali::Actor actor) diff --git a/dali/internal/window-system/common/window-impl.h b/dali/internal/window-system/common/window-impl.h index eb3aac6..42e9aaf 100644 --- a/dali/internal/window-system/common/window-impl.h +++ b/dali/internal/window-system/common/window-impl.h @@ -638,9 +638,9 @@ private: // Dali::Internal::Adaptor::SceneHolder void OnResume() override; /** - * @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculateTouchPosition + * @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculatePosition */ - void RecalculateTouchPosition(Integration::Point& point) override; + Vector2 RecalculatePosition(const Vector2& position) override; private: // Dali::Internal::Adaptor::EventHandler::Observer /** -- 2.7.4