X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fevents%2Fkey-event-impl.h;h=9675488c5aa49415341f8234177f11db3f69be3b;hb=ddcfbfa79b3abc35156679717387cdc54e14d550;hp=b6245b15e2a71c261264d42f338ea96f54a2a593;hpb=440d9de6b256b91373d82994e22ec5e9ec756438;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/events/key-event-impl.h b/dali/internal/event/events/key-event-impl.h index b6245b1..9675488 100644 --- a/dali/internal/event/events/key-event-impl.h +++ b/dali/internal/event/events/key-event-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTERNAL_KEY_EVENT_H__ -#define __DALI_INTERNAL_KEY_EVENT_H__ +#ifndef DALI_INTERNAL_KEY_EVENT_H +#define DALI_INTERNAL_KEY_EVENT_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -20,100 +20,244 @@ // INTERNAL INCLUDES #include -#include +#include namespace Dali { - namespace Internal { +class KeyEvent; +typedef IntrusivePtr KeyEventPtr; -struct KeyEventImpl +/** + * @copydoc Dali::KeyEvent + */ +class KeyEvent : public BaseObject { public: + /** + * @brief Default constructor. + */ + KeyEvent(); /** * @brief Constructor. + * + * @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] logicalKey The logical key symbol (eg. shift + 1 == "exclamation") + * @param[in] keyString The 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. + * @param[in] compose The key compose + * @param[in] deviceName The name of device the key event originated from + * @param[in] deviceClass The class of device the key event originated from + * @param[in] deviceSubclass The subclass of device the key event originated from */ - KeyEventImpl( Dali::KeyEvent* keyEvent ); + KeyEvent(const std::string& keyName, + const std::string& logicalKey, + const std::string& keyString, + int keyCode, + int keyModifier, + unsigned long timeStamp, + const Dali::KeyEvent::State& keyState, + const std::string& compose, + const std::string& deviceName, + const Device::Class::Type deviceClass, + const Device::Subclass::Type deviceSubclass); /** - * @brief Destructor. + * Create a new KeyEvent. + * + * @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] logicalKey The logical key symbol (eg. shift + 1 == "exclamation") + * @param[in] keyString The 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. + * @param[in] compose The key compose + * @param[in] deviceName The name of device the key event originated from + * @param[in] deviceClass The class of device the key event originated from + * @param[in] deviceSubclass The subclass of device the key event originated from + * @return A smart-pointer to the newly allocated KeyEvent. */ - ~KeyEventImpl(); + static KeyEventPtr New(const std::string& keyName, + const std::string& logicalKey, + const std::string& keyString, + int keyCode, + int keyModifier, + unsigned long timeStamp, + const Dali::KeyEvent::State& keyState, + const std::string& compose, + const std::string& deviceName, + const Device::Class::Type deviceClass, + const Device::Subclass::Type deviceSubclass); /** - * @brief Assignment operator. - * @param[in] rhs A reference to the copied handle - * @return A reference to this + * @copydoc Dali::KeyEvent::IsShiftModifier() */ - KeyEventImpl& operator=( const KeyEventImpl& rhs ); + bool IsShiftModifier() const; /** - * @brief Get the device name the key event originated from + * @copydoc Dali::KeyEvent::IsCtrlModifier() + */ + bool IsCtrlModifier() const; + + /** + * @copydoc Dali::KeyEvent::IsAltModifier() + */ + bool IsAltModifier() const; + + /** + * @copydoc Dali::KeyEvent::GetCompose() + */ + const std::string& GetCompose() const; + + /** + * @copydoc Dali::KeyEvent::GetDeviceName() + */ + const std::string& GetDeviceName() const; + + /** + * @copydoc Dali::KeyEvent::GetDeviceClass() + */ + Device::Class::Type GetDeviceClass() const; + + /** + * @copydoc Dali::KeyEvent::GetDeviceSubclass() + */ + Device::Subclass::Type GetDeviceSubclass() const; + + /** + * @copydoc Dali::KeyEvent::GetKeyName() + */ + const std::string& GetKeyName() const; + + /** + * @copydoc Dali::KeyEvent::GetKeyString() + */ + const std::string& GetKeyString() const; + + /** + * @copydoc Dali::KeyEvent::GetLogicalKey() + */ + const std::string& GetLogicalKey() const; + + /** + * @copydoc Dali::KeyEvent::GetKeyCode() + */ + int32_t GetKeyCode() const; + + /** + * @copydoc Dali::KeyEvent::GetKeyModifier() + */ + int32_t GetKeyModifier() const; + + /** + * @copydoc Dali::KeyEvent::GetTime() + */ + unsigned long GetTime() const; + + /** + * @copydoc Dali::KeyEvent::GetState() + */ + Dali::KeyEvent::State GetState() const; + + /** + * @brief Set the name given to the key pressed * - * @return The device name + * @param[in] keyName The name given to the key pressed. */ - std::string GetDeviceName() const; + void SetKeyName(const std::string& keyName); /** - * @brief Set the device name to the KeyEvent + * @brief Set the actual string of input characters that should be used for input editors. * - * @param[in] deviceName Device name string to set + * @param[in] The actual string of input characters */ - void SetDeviceName( const std::string& deviceName ); + void SetKeyString(const std::string& keyString); /** - * @brief Get the device class the key event originated from + * @brief Set the unique key code for the key pressed. * - * @return The device class + * @param[in] keyCode The unique key code for the key pressed */ - DevelDevice::Class::Type GetDeviceClass() const; + void SetKeyCode(int32_t keyCode); /** - * @brief Set the device class to the KeyEvent + * @brief Set the key modifier for special keys like Shift, Alt and Ctrl which modify the next key pressed. * - * @param[in] deviceClass Device class to set + * @param[in] keyModifier The key modifier */ - void SetDeviceClass( DevelDevice::Class::Type deviceClass ); + void SetKeyModifier(int32_t keyModifier); /** - * @brief Get the device subclass the key event originated from + * @brief Set the time (in ms) that the key event occurred. * - * @return The device subclass + * @param[in] time The time (in ms) */ - DevelDevice::Subclass::Type GetDeviceSubclass() const; + void SetTime(unsigned long time); /** - * @brief Set the device subclass to the KeyEvent + * @brief Set the state of the key event. * - * @param[in] deviceClass Device subclass to set + * @param[in] state The state of the key event */ - void SetDeviceSubclass( DevelDevice::Subclass::Type deviceSubclass ); + void SetState(const Dali::KeyEvent::State& state); private: + /** + * @brief Destructor. + * + * A reference counted object may only be deleted by calling Unreference() + */ + ~KeyEvent() override = default; - // Undefined - KeyEventImpl(); + // Not copyable or movable - // Undefined - KeyEventImpl( const KeyEventImpl& rhs ); + KeyEvent(const KeyEvent& rhs) = delete; ///< Deleted copy constructor + KeyEvent(KeyEvent&& rhs) = delete; ///< Deleted move constructor + KeyEvent& operator=(const KeyEvent& rhs) = delete; ///< Deleted copy assignment operator + KeyEvent& operator=(KeyEvent&& rhs) = delete; ///< Deleted move assignment operator private: - - std::string mDeviceName; - DevelDevice::Class::Type mDeviceClass; - DevelDevice::Subclass::Type mDeviceSubclass; + std::string mKeyName; ///< The name of the key pressed + std::string mLogicalKey; ///< The logical key symbol + std::string mKeyString; ///< The string of input characters + int mKeyCode; ///< TThe unique key code + int mKeyModifier; ///< The key modifier + unsigned long mTime; ///< The time that the key event occurred. + Dali::KeyEvent::State mState; ///< The state of the key event. + std::string mCompose; ///< The key compose + 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 }; } // namespace Internal // Helpers for public-api forwarding methods -Internal::KeyEventImpl* GetImplementation( KeyEvent* keyEvent ); +inline Internal::KeyEvent& GetImplementation(Dali::KeyEvent& keyEvent) +{ + DALI_ASSERT_ALWAYS(keyEvent && "Key Event handle is empty"); + + BaseObject& object = keyEvent.GetBaseObject(); + + return static_cast(object); +} + +inline const Internal::KeyEvent& GetImplementation(const Dali::KeyEvent& keyEvent) +{ + DALI_ASSERT_ALWAYS(keyEvent && "Key Event handle is empty"); + + const BaseObject& object = keyEvent.GetBaseObject(); -const Internal::KeyEventImpl* GetImplementation( const KeyEvent* keyEvent ); + return static_cast(object); +} } // namespace Dali -#endif // __DALI_INTERNAL_KEY_EVENT_H__ +#endif // DALI_INTERNAL_KEY_EVENT_H