From: Agnelo Vaz Date: Fri, 22 May 2015 13:23:24 +0000 (+0100) Subject: VirtualKeyboard API for Settings X-Git-Tag: accepted/tizen/common/20150529.134105^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F00%2F40000%2F5;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git VirtualKeyboard API for Settings Change-Id: Ic16296cf6fe0e8f4b9c67d353dcc12495451c685 Signed-off-by: Agnelo Vaz --- diff --git a/adaptors/common/virtual-keyboard-impl.cpp b/adaptors/common/virtual-keyboard-impl.cpp index 6ba3924..9fca891 100644 --- a/adaptors/common/virtual-keyboard-impl.cpp +++ b/adaptors/common/virtual-keyboard-impl.cpp @@ -29,7 +29,6 @@ #include #include - namespace Dali { @@ -48,6 +47,8 @@ namespace Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_VIRTUAL_KEYBOARD"); #endif +#define TOKEN_STRING(x) #x + //forward declarations void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value ); void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value ); @@ -57,8 +58,6 @@ Dali::VirtualKeyboard::StatusSignalType gKeyboardStatusSignal; Dali::VirtualKeyboard::VoidSignalType gKeyboardResizeSignal; Dali::VirtualKeyboard::VoidSignalType gKeyboardLanguageChangedSignal; -Dali::VirtualKeyboard::ReturnKeyType gReturnKeyType = Dali::VirtualKeyboard::DEFAULT; // the currently used return key type. - void InputPanelStateChangeCallback( void* data, Ecore_IMF_Context* context, int value ) { switch (value) @@ -179,23 +178,28 @@ bool IsVisible() return false; } -void SetReturnKeyType( Dali::VirtualKeyboard::ReturnKeyType type ) +void ApplySettings( const Property::Map& settingsMap ) { - Dali::ImfManager imfManager = ImfManager::Get(); // Create ImfManager instance (if required) when setting values - Ecore_IMF_Context* imfContext = reinterpret_cast( imfManager.GetContext() ); + using namespace InputMethod; // Allows exclusion of namespace in TOKEN_STRING. - if( imfContext ) + for ( unsigned int i = 0, count = settingsMap.Count(); i < count; ++i ) { - DALI_LOG_INFO( gLogFilter, Debug::General, "VKB Retrun key type is changed[%d]\n", type ); - - gReturnKeyType = type; - ecore_imf_context_input_panel_return_key_type_set( imfContext, static_cast( type ) ); - } -} + std::string key = settingsMap.GetKey( i ); + Property::Value item = settingsMap.GetValue(i); -Dali::VirtualKeyboard::ReturnKeyType GetReturnKeyType() -{ - return gReturnKeyType; + if ( key == TOKEN_STRING( ACTION_BUTTON ) ) + { + if ( item.GetType() == Property::INTEGER ) + { + int value = item.Get< int >(); + VirtualKeyboard::SetReturnKeyType( static_cast(value) ); + } + } + else + { + DALI_LOG_INFO( gLogFilter, Debug::General, "Provided Settings Key not supported\n" ); + } + } } void EnablePrediction(const bool enable) diff --git a/adaptors/common/virtual-keyboard-impl.h b/adaptors/common/virtual-keyboard-impl.h index 671f399..6acd185 100644 --- a/adaptors/common/virtual-keyboard-impl.h +++ b/adaptors/common/virtual-keyboard-impl.h @@ -69,14 +69,19 @@ void Hide(); bool IsVisible(); /** + * @copydoc Dali::VirtualKeyboard::ApplySettings() + */ +void ApplySettings( const Property::Map& settingsMap ); + +/** * @copydoc Dali::VirtualKeyboard::SetReturnKeyType() */ -void SetReturnKeyType( Dali::VirtualKeyboard::ReturnKeyType type ); +void SetReturnKeyType( const Dali::InputMethod::ActionButton type ); /** * @copydoc Dali::VirtualKeyboard::GetReturnKeyType() */ -Dali::VirtualKeyboard::ReturnKeyType GetReturnKeyType(); +Dali::InputMethod::ActionButton GetReturnKeyType(); /** * @copydoc Dali::VirtualKeyboard::EnablePrediction() diff --git a/adaptors/devel-api/adaptor-framework/virtual-keyboard.cpp b/adaptors/devel-api/adaptor-framework/virtual-keyboard.cpp index 5798ada..50fa03e 100644 --- a/adaptors/devel-api/adaptor-framework/virtual-keyboard.cpp +++ b/adaptors/devel-api/adaptor-framework/virtual-keyboard.cpp @@ -42,12 +42,17 @@ bool IsVisible() return Internal::Adaptor::VirtualKeyboard::IsVisible(); } -void SetReturnKeyType( ReturnKeyType type ) +void ApplySettings( const Property::Map& settingsMap ) +{ + Internal::Adaptor::VirtualKeyboard::ApplySettings( settingsMap ); +} + +void SetReturnKeyType( const InputMethod::ActionButton type ) { Internal::Adaptor::VirtualKeyboard::SetReturnKeyType( type ); } -ReturnKeyType GetReturnKeyType() +InputMethod::ActionButton GetReturnKeyType() { return Internal::Adaptor::VirtualKeyboard::GetReturnKeyType(); } diff --git a/adaptors/devel-api/adaptor-framework/virtual-keyboard.h b/adaptors/devel-api/adaptor-framework/virtual-keyboard.h index ac6da9f..f0e0a94 100644 --- a/adaptors/devel-api/adaptor-framework/virtual-keyboard.h +++ b/adaptors/devel-api/adaptor-framework/virtual-keyboard.h @@ -20,8 +20,17 @@ // EXTERNAL INCLUDES #include +#include #include +// INTERNAL INCLUDES +#ifdef DALI_ADAPTOR_COMPILATION // full path doesn't exist until adaptor is installed so we have to use relative +// @todo Make dali-adaptor code folder structure mirror the folder structure installed to dali-env +#include "input-method.h" +#else +#include +#endif + namespace Dali { @@ -83,16 +92,22 @@ DALI_IMPORT_API void Hide(); DALI_IMPORT_API bool IsVisible(); /** + * @brief Set one or more of the Input Method Settings + * @param[in] settingsMap Map of Settings to be applied. + */ +DALI_IMPORT_API void ApplySettings( const Property::Map& settingsMap ); + +/** * @brief Set the specific return key into the virtual keyboard. * @param[in] type the kind of return key types. */ -DALI_IMPORT_API void SetReturnKeyType( ReturnKeyType type ); +DALI_IMPORT_API void SetReturnKeyType( const InputMethod::ActionButton type ); /** * @brief Retrieve the current return key type. * @return the type of retun key. */ -DALI_IMPORT_API ReturnKeyType GetReturnKeyType(); +DALI_IMPORT_API InputMethod::ActionButton GetReturnKeyType(); /** * @brief Enable/disable prediction (predictive text). diff --git a/adaptors/wayland/virtual-keyboard-impl-wl.cpp b/adaptors/wayland/virtual-keyboard-impl-wl.cpp index 57f87ac..3003364 100644 --- a/adaptors/wayland/virtual-keyboard-impl-wl.cpp +++ b/adaptors/wayland/virtual-keyboard-impl-wl.cpp @@ -44,10 +44,21 @@ namespace Adaptor namespace VirtualKeyboard { +Dali::InputMethod::ActionButton gActionButtonFunction = Dali::InputMethod::ACTION_DEFAULT; + void RotateTo(int angle) { } +void SetReturnKeyType( const InputMethod::ActionButton type ) +{ +} + +Dali::InputMethod::ActionButton GetReturnKeyType() +{ + return gActionButtonFunction; +} + } // namespace VirtualKeyboard } // namespace Adaptor diff --git a/adaptors/x11/virtual-keyboard-impl-x.cpp b/adaptors/x11/virtual-keyboard-impl-x.cpp index 947bad8..b1fdc60 100644 --- a/adaptors/x11/virtual-keyboard-impl-x.cpp +++ b/adaptors/x11/virtual-keyboard-impl-x.cpp @@ -44,6 +44,28 @@ namespace Adaptor namespace VirtualKeyboard { +Dali::InputMethod::ActionButton gActionButtonFunction = Dali::InputMethod::ACTION_DEFAULT; + +Ecore_IMF_Input_Panel_Return_Key_Type actionButtonMapping(Dali::InputMethod::ActionButton actionButton ) +{ + switch( actionButton ) + { + case InputMethod::ACTION_DEFAULT: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; + case InputMethod::ACTION_DONE: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE; + case InputMethod::ACTION_GO: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO; + case InputMethod::ACTION_JOIN: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN; + case InputMethod::ACTION_LOGIN: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN; + case InputMethod::ACTION_NEXT: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT; + case InputMethod::ACTION_PREVIOUS: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; + case InputMethod::ACTION_SEARCH: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH; + case InputMethod::ACTION_SEND: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND; + case InputMethod::ACTION_SIGNIN: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; + case InputMethod::ACTION_UNSPECIFIED: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; + case InputMethod::ACTION_NONE: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; + default: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; + } +} + void RotateTo(int angle) { // Get focus window used by Keyboard and rotate it @@ -62,6 +84,23 @@ void RotateTo(int angle) } } +void SetReturnKeyType( const InputMethod::ActionButton type ) +{ + Dali::ImfManager imfManager = ImfManager::Get(); // Create ImfManager instance (if required) when setting values + Ecore_IMF_Context* imfContext = reinterpret_cast( imfManager.GetContext() ); + + if( imfContext ) + { + gActionButtonFunction = type; + ecore_imf_context_input_panel_return_key_type_set( imfContext, actionButtonMapping( type ) ); + } +} + +Dali::InputMethod::ActionButton GetReturnKeyType() +{ + return gActionButtonFunction; +} + } // namespace VirtualKeyboard } // namespace Adaptor