Add isRepeat to KeyEvent 70/298970/2
authorBowon Ryu <bowon.ryu@samsung.com>
Mon, 18 Sep 2023 03:04:05 +0000 (12:04 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Mon, 18 Sep 2023 04:47:50 +0000 (13:47 +0900)
Change-Id: Ic7334bbba68fd472e257dc8d33a2c29555da79e7
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
automated-tests/src/dali/utc-Dali-KeyEvent.cpp
dali/devel-api/events/key-event-devel.cpp
dali/devel-api/events/key-event-devel.h
dali/integration-api/events/key-event-integ.cpp
dali/integration-api/events/key-event-integ.h
dali/internal/event/events/key-event-impl.cpp
dali/internal/event/events/key-event-impl.h
dali/internal/event/events/key-event-processor.cpp
dali/public-api/events/key-event.cpp
dali/public-api/events/key-event.h

index 32fb3d8..b03bacf 100644 (file)
@@ -535,3 +535,17 @@ int UtcDaliKeyEventSetState(void)
 
   END_TEST;
 }
+
+int UtcDaliKeyEventSetRepeat(void)
+{
+  TestApplication application;
+
+  Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE);
+
+  DALI_TEST_EQUALS(false, event.IsRepeat(), TEST_LOCATION);
+
+  DevelKeyEvent::SetRepeat(event, true);
+  DALI_TEST_EQUALS(true, event.IsRepeat(), TEST_LOCATION);
+
+  END_TEST;
+}
\ No newline at end of file
index 70ac649..0856d39 100644 (file)
@@ -70,6 +70,11 @@ void SetState(KeyEvent keyEvent, const KeyEvent::State& state)
   GetImplementation(keyEvent).SetState(state);\r
 }\r
 \r
+void SetRepeat(KeyEvent keyEvent, const bool repeat)\r
+{\r
+  GetImplementation(keyEvent).SetRepeat(repeat);\r
+}\r
+\r
 } // namespace DevelKeyEvent\r
 \r
 } // namespace Dali\r
index 1b1caac..24a0a23 100644 (file)
@@ -108,6 +108,15 @@ DALI_CORE_API void SetTime(KeyEvent keyEvent, unsigned long time);
  */\r
 DALI_CORE_API void SetState(KeyEvent keyEvent, const KeyEvent::State& state);\r
 \r
+/**\r
+ * @brief Set whether to repeat key event.\r
+ *\r
+ * @SINCE_2_2.44\r
+ * @param[in] keyEvent The instance of KeyEvent.\r
+ * @param[in] repeat Whether the key event is a repeating key.\r
+ */\r
+DALI_CORE_API void SetRepeat(KeyEvent keyEvent, const bool repeat);\r
+\r
 } // namespace DevelKeyEvent\r
 \r
 } // namespace Dali\r
index eac7cd3..80426f9 100644 (file)
@@ -37,7 +37,8 @@ KeyEvent::KeyEvent()
   compose(""),
   deviceName(""),
   deviceClass(Device::Class::NONE),
-  deviceSubclass(Device::Subclass::NONE)
+  deviceSubclass(Device::Subclass::NONE),
+  isRepeat(false)
 {
 }
 
@@ -63,7 +64,8 @@ KeyEvent::KeyEvent(const std::string&           keyName,
   compose(compose),
   deviceName(deviceName),
   deviceClass(deviceClass),
-  deviceSubclass(deviceSubclass)
+  deviceSubclass(deviceSubclass),
+  isRepeat(false)
 {
 }
 
index a990d35..37f4fc1 100644 (file)
@@ -137,6 +137,11 @@ struct DALI_CORE_API KeyEvent : public Event
    * The subclass of device KeyEvent originated from
    */
   Device::Subclass::Type deviceSubclass;
+
+  /**
+   * Whether the key referenced by the event is a repeating key.
+   */
+  bool isRepeat;
 };
 
 } // namespace Integration
index 4cfefd1..e177329 100644 (file)
@@ -69,7 +69,8 @@ KeyEvent::KeyEvent(const std::string&           keyName,
   mCompose(compose),
   mDeviceName(deviceName),
   mDeviceClass(deviceClass),
-  mDeviceSubclass(deviceSubclass)
+  mDeviceSubclass(deviceSubclass),
+  mIsRepeat(false)
 {
 }
 
@@ -159,6 +160,11 @@ Dali::KeyEvent::State KeyEvent::GetState() const
   return mState;
 }
 
+bool KeyEvent::IsRepeat() const
+{
+  return mIsRepeat;
+}
+
 void KeyEvent::SetKeyName(const std::string& keyName)
 {
   mKeyName = keyName;
@@ -189,6 +195,11 @@ void KeyEvent::SetState(const Dali::KeyEvent::State& state)
   mState = state;
 }
 
+void KeyEvent::SetRepeat(const bool repeat)
+{
+  mIsRepeat = repeat;
+}
+
 } // namespace Internal
 
 } // namespace Dali
index 9675488..175ab89 100644 (file)
@@ -166,6 +166,11 @@ public:
   Dali::KeyEvent::State GetState() const;
 
   /**
+   * @copydoc Dali::KeyEvent::IsRepeat()
+   */
+  bool IsRepeat() const;
+
+  /**
    * @brief Set the name given to the key pressed
    *
    * @param[in] keyName The name given to the key pressed.
@@ -207,6 +212,13 @@ public:
    */
   void SetState(const Dali::KeyEvent::State& state);
 
+  /**
+   * @brief Set whether to repeat key event.
+   *
+   * @param[in] repeat Whether the key event is a repeating key.
+   */
+  void SetRepeat(const bool repeat);
+
 private:
   /**
    * @brief Destructor.
@@ -234,6 +246,7 @@ private:
   std::string            mDeviceName;     ///< The name of device the key event originated from
   Device::Class::Type    mDeviceClass;    ///< The class of device the key event originated from
   Device::Subclass::Type mDeviceSubclass; ///< The subclass of device the key event originated from
+  bool                   mIsRepeat;       ///< Whether the key referenced by the event is a repeating key.
 };
 
 } // namespace Internal
index d454e5c..0b0d6f0 100644 (file)
@@ -57,6 +57,7 @@ KeyEventProcessor::~KeyEventProcessor() = default;
 void KeyEventProcessor::ProcessKeyEvent(const Integration::KeyEvent& event)
 {
   KeyEventPtr    keyEvent(new KeyEvent(event.keyName, event.logicalKey, event.keyString, event.keyCode, event.keyModifier, event.time, static_cast<Dali::KeyEvent::State>(event.state), event.compose, event.deviceName, event.deviceClass, event.deviceSubclass));
+  keyEvent->SetRepeat(event.isRepeat);
   Dali::KeyEvent keyEventHandle(keyEvent.Get());
 
 #ifdef TRACE_ENABLED
index 9693649..1391313 100644 (file)
@@ -108,6 +108,11 @@ KeyEvent::State KeyEvent::GetState() const
   return GetImplementation(*this).GetState();
 }
 
+bool KeyEvent::IsRepeat() const
+{
+  return GetImplementation(*this).IsRepeat();
+}
+
 KeyEvent::KeyEvent(Internal::KeyEvent* internal)
 : BaseHandle(internal)
 {
index d853c91..024de44 100644 (file)
@@ -239,6 +239,14 @@ public:
    */
   State GetState() const;
 
+  /**
+   * @brief Checks to see if key event is a repeating key.
+   *
+   * @SINCE_2_2.44
+   * @return Whether the key event is a repeating key.
+   */
+  bool IsRepeat() const;
+
 public: // Not intended for application developers
   /// @cond internal
   /**