Merge "Add BuildPickingRay to devel api" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / events / key-event.h
index e20dc61..d853c91 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_KEY_EVENT_H__
-#define __DALI_KEY_EVENT_H__
+#ifndef DALI_KEY_EVENT_H
+#define DALI_KEY_EVENT_H
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
  */
 
 // EXTERNAL INCLUDES
+#include <cstdint> // int32_t
 #include <string>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/events/device.h>
+#include <dali/public-api/object/base-handle.h>
 
 namespace Dali
 {
+namespace Internal DALI_INTERNAL
+{
+class KeyEvent;
+}
+
 /**
- * @addtogroup dali-core-events
+ * @addtogroup dali_core_events
  * @{
  */
 
 /**
- * @brief The key event structure is used to store a key press.
+ * @brief The key event class is used to store a key press.
  *
  * It facilitates processing of these key presses and passing to other
  * libraries like Toolkit. The keyString is the actual character you
@@ -42,100 +50,205 @@ namespace Dali
  * pressed.
  *
  * Currently KeyEvent is also being used to relay messages from the
- * IMF keyboard to Core. In future IMF may communicate via its own
+ * IMF(Input Method Framework) keyboard to the internal core. In future IMF may communicate via its own
  * module.
+ * @SINCE_1_0.0
  */
-struct DALI_IMPORT_API KeyEvent
+class DALI_CORE_API KeyEvent : public BaseHandle
 {
+public:
   // Enumerations
 
   /**
-   * @brief Specifies the state of the key event.
+   * @brief Enumeration for specifying the state of the key event.
+   * @SINCE_1_9.27
    */
   enum State
   {
-    Down,        ///< Key down
-    Up,          ///< Key up
-    Last
+    DOWN, ///< Key down @SINCE_1_9.27
+    UP,   ///< Key up @SINCE_1_9.27
   };
 
   /**
-   * @brief Default constructor
+   * @brief An uninitialized KeyEvent instance.
+   *
+   * Calling member functions with an uninitialized KeyEvent handle is not allowed.
+   * @SINCE_1_0.0
    */
   KeyEvent();
 
   /**
-   * @brief Constructor.
+   * @brief Copy constructor.
+   * @SINCE_1_2.36
+   * @param[in] rhs A reference to the copied handle
+   */
+  KeyEvent(const KeyEvent& rhs);
+
+  /**
+   * @brief Move constructor.
+   *
+   * @SINCE_1_9.27
+   * @param[in] rhs A reference to the moved handle
+   */
+  KeyEvent(KeyEvent&& rhs) noexcept;
+
+  /**
+   * @brief Copy assignment operator.
+   * @SINCE_1_2.36
+   * @param[in] rhs A reference to the copied handle
+   * @return A reference to this
+   */
+  KeyEvent& operator=(const KeyEvent& rhs);
+
+  /**
+   * @brief Move assignment operator.
    *
-   * @param[in]  keyName       The name of the key pressed or command from the IMF, if later then the some following parameters will be needed.
-   * @param[in]  keyString     A string of input characters or key pressed
-   * @param[in]  keyCode       The unique key code for the key pressed.
-   * @param[in]  keyModifier   The key modifier for special keys like shift and alt
-   * @param[in]  timeStamp The time (in ms) that the key event occurred.
-   * @param[in]  keyState The state of the key event.
+   * @SINCE_1_9.27
+   * @param[in] rhs A reference to the moved handle
+   * @return A reference to this
    */
-  KeyEvent(const std::string& keyName, const std::string& keyString, int keyCode, int keyModifier, unsigned long timeStamp, const State& keyState);
+  KeyEvent& operator=(KeyEvent&& rhs) noexcept;
 
   /**
    * @brief Destructor.
+   * @SINCE_1_0.0
    */
   ~KeyEvent();
 
   /**
-   * @brief Check to see if Shift key modifier has been supplied.
+   * @brief Checks to see if Shift key modifier has been supplied.
    *
-   * @return bool true if shift modifier
+   * @SINCE_1_0.0
+   * @return True if shift modifier
    */
   bool IsShiftModifier() const;
 
   /**
-   * @brief Check to see if Ctrl (control) key modifier has been supplied.
+   * @brief Checks to see if Ctrl (control) key modifier has been supplied.
    *
-   * @return bool true if ctrl modifier
+   * @SINCE_1_0.0
+   * @return True if ctrl modifier
    */
   bool IsCtrlModifier() const;
 
   /**
-   * @brief Check to see if Alt key modifier has been supplied.
+   * @brief Checks to see if Alt key modifier has been supplied.
    *
-   * @return bool true if alt modifier
+   * @SINCE_1_0.0
+   * @return True if alt modifier
    */
   bool IsAltModifier() const;
 
-  // Data
+  /**
+   * @brief Get the key compose string.
+   *
+   * @SINCE_1_9.27
+   * @return The compose string
+   */
+  const std::string& GetCompose() const;
 
   /**
-   * @brief name given to the key pressed.
+   * @brief Get the device name the key event originated from.
+   *
+   * @SINCE_1_9.27
+   * @return The device name
    */
-  std::string keyPressedName;
+  const std::string& GetDeviceName() const;
 
   /**
-   * @brief The actual string returned that should be used for input editors.
+   * @brief Get the device class the key event originated from.
+   *
+   * The device class type is classification type of the input device of event received
+   * @SINCE_1_2.60
+   * @return The type of the device class
    */
-  std::string keyPressed;
+  Device::Class::Type GetDeviceClass() const;
 
   /**
-   * @brief Keycode for the key pressed.
+   * @brief Get the device subclass the key event originated from.
+   *
+   * The device subclass type is subclassification type of the input device of event received.
+   * @SINCE_1_2.60
+   * @return The type of the device subclass
    */
-  int  keyCode;
+  Device::Subclass::Type GetDeviceSubclass() const;
 
   /**
-   * @brief special keys like shift, alt and control which modify the next key pressed.
+   * @brief Get the name given to the key pressed or command from the IMF
+   *
+   * @SINCE_1_9.27
+   * @return The name given to the key pressed.
    */
-  int  keyModifier;
+  const std::string& GetKeyName() const;
 
   /**
-   * @brief The time (in ms) that the key event occurred.
+   * @brief Get the actual string of input characters that should be used for input editors.
+   *
+   * @SINCE_1_9.27
+   * @return The actual string of input characters
    */
-  unsigned long time;
+  const std::string& GetKeyString() const;
 
   /**
-   * @brief State of the key event.
+   * @brief Gets the logical key string.
+   *
+   * For example, when the user presses 'shift' key and '1' key together, the logical key is "exclamation".
+   * Plus, the key name is "1", and the key string is "!".
+   *
+   * @SINCE_1_9.27
+   * @return The logical key symbol
+   */
+  const std::string& GetLogicalKey() const;
+
+  /**
+   * @brief Get the unique key code for the key pressed.
+   *
+   * @SINCE_1_9.27
+   * @return The unique key code for the key pressed
+   *
+   * @remarks We recommend not to use this key code value directly because its meaning
+   * might be changed in the future. Currently, it means a platform-specific key code.
+   * You need to use IsKey() to know what a key event means instead of direct comparison
+   * of key code value.
+   */
+  int32_t GetKeyCode() const;
+
+  /**
+   * @brief Return the key modifier for special keys like Shift, Alt and Ctrl which modify the next key pressed.
+   *
+   * @SINCE_1_9.27
+   * @return The key modifier
+   */
+  int32_t GetKeyModifier() const;
+
+  /**
+   * @brief Get the time (in ms) that the key event occurred.
+   *
+   * @SINCE_1_9.27
+   * @return The time (in ms)
+   */
+  unsigned long GetTime() const;
+
+  /**
+   * @brief Get the state of the key event.
    *
    * @see State
+   *
+   * @SINCE_1_9.27
+   * @return The state of the key event
    */
-  State state;
+  State GetState() const;
 
+public: // Not intended for application developers
+  /// @cond internal
+  /**
+   * @brief This constructor is used internally to Create an initialized KeyEvent handle.
+   *
+   * @SINCE_1_9.27
+   * @param[in] keyEvent A pointer to a newly allocated Dali resource
+   */
+  explicit DALI_INTERNAL KeyEvent(Internal::KeyEvent* keyEvent);
+  /// @endcond
 };
 
 /**
@@ -143,4 +256,4 @@ struct DALI_IMPORT_API KeyEvent
  */
 } // namespace Dali
 
-#endif // __DALI_KEY_EVENT_H__
+#endif // DALI_KEY_EVENT_H