Add clockwise and counter clockwise direction type and movefocus 40/272040/6
authorjoogab.yun <joogab.yun@samsung.com>
Mon, 7 Mar 2022 08:35:15 +0000 (17:35 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Mon, 14 Mar 2022 00:17:37 +0000 (09:17 +0900)
Change-Id: I5352a15d78d53ca1efdf171b984be10df2565697

automated-tests/src/dali-toolkit/utc-Dali-Control.cpp
automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp
dali-toolkit/devel-api/controls/control-devel.h
dali-toolkit/internal/controls/control/control-data-impl.cpp
dali-toolkit/internal/controls/control/control-data-impl.h
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h
dali-toolkit/public-api/controls/control.h

index 9f02d5f..6745fea 100644 (file)
@@ -269,6 +269,8 @@ int UtcDaliControlNavigationProperties(void)
   DALI_TEST_EQUALS(-1, control.GetProperty(DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
   DALI_TEST_EQUALS(-1, control.GetProperty(DevelControl::Property::UP_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
   DALI_TEST_EQUALS(-1, control.GetProperty(DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
+  DALI_TEST_EQUALS(-1, control.GetProperty( DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION);
+  DALI_TEST_EQUALS(-1, control.GetProperty( DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION);
 
   control.SetProperty(DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, 1);
   DALI_TEST_EQUALS(1, control.GetProperty(DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
@@ -287,6 +289,10 @@ int UtcDaliControlNavigationProperties(void)
   DALI_TEST_EQUALS(17, control.GetProperty(DevelControl::Property::UP_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
   control.SetProperty(DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, 18);
   DALI_TEST_EQUALS(18, control.GetProperty(DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
+  control.SetProperty(DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID, 19);
+  DALI_TEST_EQUALS(19, control.GetProperty( DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION);
+  control.SetProperty(DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID, 20);
+  DALI_TEST_EQUALS(20, control.GetProperty( DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION);
 
   END_TEST;
 }
index 65876fb..ec95a75 100644 (file)
@@ -670,12 +670,16 @@ int UtcDaliKeyboardFocusManagerFocusablePropertiesMoveFocus(void)
   button1.SetProperty(Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty<int>(Actor::Property::ID)));
   button1.SetProperty(Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty<int>(Actor::Property::ID)));
   button1.SetProperty(Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty<int>(Actor::Property::ID)));
+  button1.SetProperty(Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty< int >( Actor::Property::ID)));
+  button1.SetProperty(Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty< int >( Actor::Property::ID)));
 
   // set the navigation properties of button2
   button2.SetProperty(Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, Property::Value((int)button1.GetProperty<int>(Actor::Property::ID)));
   button2.SetProperty(Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID, Property::Value((int)button1.GetProperty<int>(Actor::Property::ID)));
   button2.SetProperty(Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, Property::Value((int)button1.GetProperty<int>(Actor::Property::ID)));
   button2.SetProperty(Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::Value((int)button1.GetProperty<int>(Actor::Property::ID)));
+  button2.SetProperty(Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID, Property::Value((int)button1.GetProperty< int >( Actor::Property::ID)));
+  button2.SetProperty(Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID, Property::Value((int)button1.GetProperty< int >( Actor::Property::ID)));
 
   // Move the focus towards left
   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
@@ -717,6 +721,26 @@ int UtcDaliKeyboardFocusManagerFocusablePropertiesMoveFocus(void)
   DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button1);
   focusChangedCallback.Reset();
 
+  // Move the focus towards clockwise
+  DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::CLOCKWISE) == true);
+
+  // Confirm whether focus is moved to button2
+  DALI_TEST_EQUALS(button2.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
+  DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+  DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button1);
+  DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button2);
+  focusChangedCallback.Reset();
+
+  // Move the focus towards clockwise
+  DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::COUNTER_CLOCKWISE) == true);
+
+  // Confirm whether focus is moved to button1
+  DALI_TEST_EQUALS(button1.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
+  DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+  DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button2);
+  DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button1);
+  focusChangedCallback.Reset();
+
   // Create a 1x1 table view and try to move focus inside it
   TableView tableView = TableView::New(1, 1);
   application.GetScene().Add(tableView);
@@ -2097,3 +2121,64 @@ int UtcDaliKeyboardFocusManagerCheckWheelEvent(void)
 
   END_TEST;
 }
+
+int UtcDaliKeyboardFocusManagerChangeFocusDirectionByCustomWheelEvent(void)
+{
+  ToolkitTestApplication application;
+
+  tet_infoline(" UtcDaliKeyboardFocusManagerChangeFocusDirectionByCustomWheelEvent");
+  Dali::Integration::Scene scene = application.GetScene();
+
+  KeyboardFocusManager manager = KeyboardFocusManager::Get();
+  DALI_TEST_CHECK(manager);
+
+  bool focusChangedSignalVerified = false;
+  FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
+  manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
+
+  Integration::WheelEvent clockwiseEvent(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), 1, 1000u);
+  Integration::WheelEvent counterClockwiseEvent(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), -1, 1100u);
+
+  // Create the first button
+  PushButton first = PushButton::New();
+  first.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
+  scene.Add(first);
+
+  // Create the second button
+  PushButton second = PushButton::New();
+  second.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
+  scene.Add(second);
+
+   // set the navigation properties
+  first.SetProperty(Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID, Property::Value((int)second.GetProperty< int >( Actor::Property::ID )));
+  second.SetProperty(Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID, Property::Value((int)first.GetProperty< int >( Actor::Property::ID )));
+
+  // Set the focus to the first actor
+  DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
+  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+  DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+  DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
+  DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
+  focusChangedCallback.Reset();
+
+  // Send the clockwise wheel event to move the focus towards clockwise
+  application.ProcessEvent(clockwiseEvent);
+  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
+  DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+  DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
+  DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == second);
+  focusChangedCallback.Reset();
+
+  // Send the counter clockwise wheel event to move the focus towards count clockwise
+  application.ProcessEvent(counterClockwiseEvent);
+  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+  DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+  DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
+  DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
+  focusChangedCallback.Reset();
+
+  // Clear the focus
+  manager.ClearFocus();
+
+  END_TEST;
+}
index 07b5040..be9b759 100644 (file)
@@ -201,6 +201,20 @@ enum
    * @note The representative Accessible object will not appear in the AT-SPI tree.
    */
   ACCESSIBILITY_HIDDEN,
+
+  /**
+   * @brief The actor ID of the clockwise focusable control.
+   * @details Name "clockwiseFocusableActorId", type Property::INTEGER.
+   *
+   */
+  CLOCKWISE_FOCUSABLE_ACTOR_ID,
+
+  /**
+   * @brief The actor ID of the conter-clockwise focusable control.
+   * @details Name "counterClockwiseFocusableActorId", type Property::INTEGER.
+   *
+   */
+  COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID,
 };
 
 } // namespace Property
index 3d71f4d..3a154ca 100644 (file)
@@ -470,6 +470,8 @@ const PropertyRegistration Control::Impl::PROPERTY_20(typeRegistration, "accessi
 const PropertyRegistration Control::Impl::PROPERTY_21(typeRegistration, "accessibilityAttributes",        Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES,         Property::MAP,     &Control::Impl::SetProperty, &Control::Impl::GetProperty);
 const PropertyRegistration Control::Impl::PROPERTY_22(typeRegistration, "dispatchKeyEvents",              Toolkit::DevelControl::Property::DISPATCH_KEY_EVENTS,              Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
 const PropertyRegistration Control::Impl::PROPERTY_23(typeRegistration, "accessibilityHidden",            Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN,             Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
+const PropertyRegistration Control::Impl::PROPERTY_24(typeRegistration, "clockwiseFocusableActorId",      Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID,     Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
+const PropertyRegistration Control::Impl::PROPERTY_25(typeRegistration, "counterClockwiseFocusableActorId", Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
 
 // clang-format on
 
@@ -481,6 +483,8 @@ Control::Impl::Impl(Control& controlImpl)
   mRightFocusableActorId(-1),
   mUpFocusableActorId(-1),
   mDownFocusableActorId(-1),
+  mClockwiseFocusableActorId(-1),
+  mCounterClockwiseFocusableActorId(-1),
   mStyleName(""),
   mBackgroundColor(Color::TRANSPARENT),
   mStartingPinchScale(nullptr),
@@ -1367,6 +1371,24 @@ void Control::Impl::SetProperty(BaseObject* object, Property::Index index, const
         }
         break;
       }
+      case Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID:
+      {
+        int focusId;
+        if(value.Get(focusId))
+        {
+          controlImpl.mImpl->mClockwiseFocusableActorId = focusId;
+        }
+        break;
+      }
+      case Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID:
+      {
+        int focusId;
+        if(value.Get(focusId))
+        {
+          controlImpl.mImpl->mCounterClockwiseFocusableActorId = focusId;
+        }
+        break;
+      }
     }
   }
 }
@@ -1527,6 +1549,18 @@ Property::Value Control::Impl::GetProperty(BaseObject* object, Property::Index i
         value = controlImpl.mImpl->mAccessibilityHidden;
         break;
       }
+
+      case Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID:
+      {
+        value = controlImpl.mImpl->mClockwiseFocusableActorId;
+        break;
+      }
+
+      case Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID:
+      {
+        value = controlImpl.mImpl->mCounterClockwiseFocusableActorId;
+        break;
+      }
     }
   }
 
index 1321a10..73f87b9 100644 (file)
@@ -511,6 +511,8 @@ public:
   int mRightFocusableActorId; ///< Actor ID of Right focusable control.
   int mUpFocusableActorId;    ///< Actor ID of Up focusable control.
   int mDownFocusableActorId;  ///< Actor ID of Down focusable control.
+  int mClockwiseFocusableActorId;  ///< Actor ID of Clockwise focusable control.
+  int mCounterClockwiseFocusableActorId;  ///< Actor ID of Counter clockwise focusable control.
 
   RegisteredVisualContainer                 mVisuals; ///< Stores visuals needed by the control, non trivial type so std::vector used.
   std::string                               mStyleName;
@@ -594,6 +596,8 @@ public:
   static const PropertyRegistration PROPERTY_21;
   static const PropertyRegistration PROPERTY_22;
   static const PropertyRegistration PROPERTY_23;
+  static const PropertyRegistration PROPERTY_24;
+  static const PropertyRegistration PROPERTY_25;
 
 private:
   // Accessibility - notification for highlighted object to check if it is showing.
index 75ffbfb..ac86419 100644 (file)
@@ -29,6 +29,7 @@
 #include <dali/public-api/animation/constraints.h>
 #include <dali/public-api/events/key-event.h>
 #include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/events/wheel-event.h>
 #include <dali/public-api/object/property-map.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/public-api/object/type-registry.h>
@@ -145,7 +146,8 @@ void KeyboardFocusManager::OnAdaptorInit()
     {
       (*iter).KeyEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnKeyEvent);
       (*iter).TouchedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnTouch);
-      (*iter).WheelEventGeneratedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnWheelEvent);
+      (*iter).WheelEventGeneratedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnCustomWheelEvent);
+      (*iter).WheelEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnWheelEvent);
       Dali::Window window = DevelWindow::DownCast(*iter);
       if(window)
       {
@@ -162,7 +164,8 @@ void KeyboardFocusManager::OnSceneHolderCreated(Dali::Integration::SceneHolder&
 {
   sceneHolder.KeyEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnKeyEvent);
   sceneHolder.TouchedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnTouch);
-  sceneHolder.WheelEventGeneratedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnWheelEvent);
+  sceneHolder.WheelEventGeneratedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnCustomWheelEvent);
+  sceneHolder.WheelEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnWheelEvent);
   Dali::Window window = DevelWindow::DownCast(sceneHolder);
   if(window)
   {
@@ -470,6 +473,16 @@ bool KeyboardFocusManager::MoveFocus(Toolkit::Control::KeyboardFocus::Direction
           index = Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID;
           break;
         }
+        case Toolkit::Control::KeyboardFocus::CLOCKWISE:
+        {
+          index = Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID;
+          break;
+        }
+        case Toolkit::Control::KeyboardFocus::COUNTER_CLOCKWISE:
+        {
+          index = Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID;
+          break;
+        }
         default:
           break;
       }
@@ -992,19 +1005,29 @@ void KeyboardFocusManager::OnTouch(const TouchEvent& touch)
   }
 }
 
-bool KeyboardFocusManager::OnWheelEvent(const WheelEvent& event)
+void KeyboardFocusManager::OnWheelEvent(const WheelEvent& event)
+{
+  if(event.GetType() == Dali::WheelEvent::CUSTOM_WHEEL)
+  {
+    Toolkit::Control::KeyboardFocus::Direction direction = (event.GetDelta() > 0) ? Toolkit::Control::KeyboardFocus::CLOCKWISE : Toolkit::Control::KeyboardFocus::COUNTER_CLOCKWISE;
+    // Move the focus
+    MoveFocus(direction);
+  }
+}
+
+bool KeyboardFocusManager::OnCustomWheelEvent(const WheelEvent& event)
 {
   bool consumed = false;
   Actor actor = GetCurrentFocusActor();
   if(actor)
   {
     // Notify the actor about the wheel event
-    consumed = EmitWheelSignals(actor, event);
+    consumed = EmitCustomWheelSignals(actor, event);
   }
   return consumed;
 }
 
-bool KeyboardFocusManager::EmitWheelSignals(Actor actor, const WheelEvent& event)
+bool KeyboardFocusManager::EmitCustomWheelSignals(Actor actor, const WheelEvent& event)
 {
   bool consumed = false;
 
@@ -1027,7 +1050,7 @@ bool KeyboardFocusManager::EmitWheelSignals(Actor actor, const WheelEvent& event
       if(parent &&
          (parent == oldParent))
       {
-        consumed = EmitWheelSignals(parent, event);
+        consumed = EmitCustomWheelSignals(parent, event);
       }
     }
   }
index 783e3f5..3b4d59b 100644 (file)
@@ -295,7 +295,13 @@ private:
    * Callback for the wheel event when the custom wheel event occurs.
    * @param[in] wheel The WheelEvent information
    */
-  bool OnWheelEvent(const WheelEvent& wheel);
+  bool OnCustomWheelEvent(const WheelEvent& wheel);
+
+  /**
+   * Callback for the wheel event when the wheel event occurs.
+   * @param[in] wheel The WheelEvent information
+   */
+  void OnWheelEvent(const WheelEvent& wheel);
 
   /**
    * Called when the window focus is changed.
@@ -315,7 +321,7 @@ private:
    * @param[in]  event  The WheelEvent.
    * @return True if WheelEvent is consumed.
    */
-  bool EmitWheelSignals(Actor actor, const WheelEvent& event);
+  bool EmitCustomWheelSignals(Actor actor, const WheelEvent& event);
 
 private:
   // Undefined
index 7ac183e..410d638 100644 (file)
@@ -155,6 +155,8 @@ public:
       PAGE_DOWN, ///< Move keyboard focus towards the next page direction @SINCE_1_2.14
       FORWARD,   ///< Move keyboard focus towards the forward direction @SINCE_2_1.10
       BACKWARD,  ///< Move keyboard focus towards the backward direction @SINCE_2_1.10
+      CLOCKWISE,  ///< Move keyboard focus towards the clockwise direction @SINCE_2_1.14
+      COUNTER_CLOCKWISE,  ///< Move keyboard focus towards the counter clockwise direction @SINCE_2_1.14
     };
   };