Add RecalculatePosition api for rotation 30/285530/1
authorjoogab.yun <joogab.yun@samsung.com>
Wed, 14 Dec 2022 06:25:19 +0000 (15:25 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Wed, 14 Dec 2022 06:25:19 +0000 (15:25 +0900)
Change-Id: I5e5ebacfc2531ff95465bb41d8a516fea106d44d

dali/integration-api/adaptor-framework/scene-holder-impl.cpp
dali/integration-api/adaptor-framework/scene-holder-impl.h
dali/internal/window-system/common/gl-window-impl.cpp
dali/internal/window-system/common/gl-window-impl.h
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h

index aa033eb..182c546 100644 (file)
@@ -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<float>(surfacePositionSize.width), static_cast<float>(surfacePositionSize.height)), windowOrientation, screenOrientation);
+  mScene = Dali::Integration::Scene::New(Size(static_cast<float>(surfacePositionSize.width), static_cast<float>(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();
 }
index 8868d52..9911817 100644 (file)
@@ -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:
   /**
index db58107..1a33ca2 100644 (file)
@@ -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<int>& angles)
index 98f8c93..7df776c 100644 (file)
@@ -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.
index 673f0bd..0cf5be8 100644 (file)
@@ -837,8 +837,8 @@ bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool
 
 void Window::OnIconifyChanged(bool iconified)
 {
-  const bool isActuallyChanged = (iconified != mIconified);
-  auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
+  const bool   isActuallyChanged = (iconified != mIconified);
+  auto         bridge            = Dali::Accessibility::Bridge::GetCurrentBridge();
   Dali::Window handle(this);
 
   if(iconified)
@@ -891,7 +891,7 @@ void Window::OnMaximizeChanged(bool maximized)
 
   if(isActuallyChanged)
   {
-    auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
+    auto         bridge = Dali::Accessibility::Bridge::GetCurrentBridge();
     Dali::Window handle(this);
 
     if(maximized)
@@ -1116,9 +1116,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)
@@ -1147,8 +1146,7 @@ void Window::RecalculateTouchPosition(Integration::Point& point)
       break;
     }
   }
-
-  point.SetScreenPosition(convertedPosition);
+  return convertedPosition;
 }
 
 Dali::Window Window::Get(Dali::Actor actor)
index f9d7fc7..35db02a 100644 (file)
@@ -644,9 +644,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
   /**