/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
#include <dali-toolkit/internal/text/text-font-style.h>
#include <dali-toolkit/internal/text/text-view.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
using namespace Dali::Toolkit::Text;
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "verticalAlignment", STRING, VERTICAL_ALIGNMENT )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "textColor", VECTOR4, TEXT_COLOR )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholderTextColor", VECTOR4, PLACEHOLDER_TEXT_COLOR )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadowOffset", VECTOR2, SHADOW_OFFSET )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadowColor", VECTOR4, SHADOW_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "reservedProperty01", STRING, RESERVED_PROPERTY_01 )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "reservedProperty02", STRING, RESERVED_PROPERTY_02 )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "primaryCursorColor", VECTOR4, PRIMARY_CURSOR_COLOR )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "secondaryCursorColor", VECTOR4, SECONDARY_CURSOR_COLOR )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enableCursorBlink", BOOLEAN, ENABLE_CURSOR_BLINK )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "ellipsis", BOOLEAN, ELLIPSIS )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableShiftSelection", BOOLEAN, ENABLE_SHIFT_SELECTION )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableGrabHandle", BOOLEAN, ENABLE_GRAB_HANDLE )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "matchSystemLanguageDirection", BOOLEAN, MATCH_SYSTEM_LANGUAGE_DIRECTION )
DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
}
break;
}
- case Toolkit::TextField::Property::SHADOW_OFFSET:
- {
- if( impl.mController )
- {
- const Vector2& shadowOffset = value.Get< Vector2 >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_OFFSET %f,%f\n", impl.mController.Get(), shadowOffset.x, shadowOffset.y );
-
- if ( impl.mController->GetShadowOffset() != shadowOffset )
- {
- impl.mController->SetShadowOffset( shadowOffset );
- impl.mRenderer.Reset();
- }
- }
- break;
- }
- case Toolkit::TextField::Property::SHADOW_COLOR:
- {
- if( impl.mController )
- {
- const Vector4& shadowColor = value.Get< Vector4 >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_COLOR %f,%f,%f,%f\n", impl.mController.Get(), shadowColor.r, shadowColor.g, shadowColor.b, shadowColor.a );
-
- if ( impl.mController->GetShadowColor() != shadowColor )
- {
- impl.mController->SetShadowColor( shadowColor );
- impl.mRenderer.Reset();
- }
- }
- break;
- }
case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
{
if( impl.mDecorator )
Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl();
if (control == textField)
{
- impl.mImfManager.ApplyOptions( impl.mInputMethodOptions );
+ impl.mInputMethodContext.ApplyOptions( impl.mInputMethodOptions );
}
break;
}
}
break;
}
+ case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
+ {
+ if( impl.mController )
+ {
+ impl.mController->SetMatchSystemLanguageDirection(value.Get< bool >());
+ }
+ break;
+ }
} // switch
} // textfield
}
}
break;
}
- case Toolkit::TextField::Property::SHADOW_OFFSET:
- {
- if ( impl.mController )
- {
- value = impl.mController->GetShadowOffset();
- }
- break;
- }
- case Toolkit::TextField::Property::SHADOW_COLOR:
- {
- if ( impl.mController )
- {
- value = impl.mController->GetShadowColor();
- }
- break;
- }
case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
{
if( impl.mDecorator )
}
break;
}
+ case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->IsMatchSystemLanguageDirection();
+ }
+ break;
+ }
} //switch
}
return value;
}
+InputMethodContext TextField::GetInputMethodContext()
+{
+ return mInputMethodContext;
+}
+
bool TextField::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
{
Dali::BaseHandle handle( object );
mDecorator = Text::Decorator::New( *mController,
*mController );
+ mInputMethodContext = InputMethodContext::New();
+
mController->GetLayoutEngine().SetLayout( Layout::Engine::SINGLE_LINE_BOX );
// Enables the text input.
- mController->EnableTextInput( mDecorator );
+ mController->EnableTextInput( mDecorator, mInputMethodContext );
// Enables the horizontal scrolling after the text input has been enabled.
mController->SetHorizontalScrollEnabled( true );
mController->SetNoTextDoubleTapAction( Controller::NoTextTap::HIGHLIGHT );
mController->SetNoTextLongPressAction( Controller::NoTextTap::HIGHLIGHT );
+ // Sets layoutDirection value
+ Dali::Stage stage = Dali::Stage::GetCurrent();
+ Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( stage.GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+ mController->SetLayoutDirection( layoutDirection );
+
// Forward input events to controller
EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) );
GetTapGestureDetector().SetMaximumTapsRequired( 2 );
- mImfManager = ImfManager::Get();
-
self.TouchSignal().Connect( this, &TextField::OnTouched );
// Set BoundingBox to stage size if not already set.
self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
self.OnStageSignal().Connect( this, &TextField::OnStageConnect );
+ DevelControl::SetInputMethodContext( *this, mInputMethodContext );
+
if( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy )
{
EnableClipping();
mActiveLayer.SetPosition( padding.start, padding.top );
}
- const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize );
+ const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize, layoutDirection );
if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
!mRenderer )
{
// @note: The callback manager takes the ownership of the callback object.
mIdleCallback = MakeCallback( this, &TextField::OnIdleSignal );
- adaptor.AddIdle( mIdleCallback );
+ adaptor.AddIdle( mIdleCallback, false );
}
}
}
void TextField::OnKeyInputFocusGained()
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() );
+ if ( mInputMethodContext )
+ {
+ mInputMethodContext.ApplyOptions( mInputMethodOptions );
- mImfManager.ApplyOptions( mInputMethodOptions );
-
- mImfManager.StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged );
-
- mImfManager.EventReceivedSignal().Connect( this, &TextField::OnImfEvent );
+ mInputMethodContext.StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged );
- // Notify that the text editing start.
- mImfManager.Activate();
+ mInputMethodContext.EventReceivedSignal().Connect( this, &TextField::OnInputMethodContextEvent );
- // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated.
- mImfManager.SetRestoreAfterFocusLost( true );
+ // Notify that the text editing start.
+ mInputMethodContext.Activate();
- ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
+ // When window gain lost focus, the inputMethodContext is deactivated. Thus when window gain focus again, the inputMethodContext must be activated.
+ mInputMethodContext.SetRestoreAfterFocusLost( true );
+ }
+ ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
- if ( notifier )
- {
- notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected );
- }
+ if ( notifier )
+ {
+ notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected );
+ }
mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event
void TextField::OnKeyInputFocusLost()
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField:OnKeyInputFocusLost %p\n", mController.Get() );
+ if ( mInputMethodContext )
+ {
+ mInputMethodContext.StatusChangedSignal().Disconnect( this, &TextField::KeyboardStatusChanged );
+ // The text editing is finished. Therefore the inputMethodContext don't have restore activation.
+ mInputMethodContext.SetRestoreAfterFocusLost( false );
- mImfManager.StatusChangedSignal().Disconnect( this, &TextField::KeyboardStatusChanged );
- // The text editing is finished. Therefore the imf manager don't have restore activation.
- mImfManager.SetRestoreAfterFocusLost( false );
-
- // Notify that the text editing finish.
- mImfManager.Deactivate();
-
- mImfManager.EventReceivedSignal().Disconnect( this, &TextField::OnImfEvent );
+ // Notify that the text editing finish.
+ mInputMethodContext.Deactivate();
+ mInputMethodContext.EventReceivedSignal().Disconnect( this, &TextField::OnInputMethodContextEvent );
+ }
ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
if ( notifier )
void TextField::OnTap( const TapGesture& gesture )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnTap %p\n", mController.Get() );
-
- mImfManager.Activate();
-
+ if ( mInputMethodContext )
+ {
+ mInputMethodContext.Activate();
+ }
// Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
Extents padding;
padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
void TextField::OnLongPress( const LongPressGesture& gesture )
{
- mImfManager.Activate();
-
+ if ( mInputMethodContext )
+ {
+ mInputMethodContext.Activate();
+ }
Extents padding;
padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
mController->LongPressEvent( gesture.state, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
}
}
-ImfManager::ImfCallbackData TextField::OnImfEvent( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
+InputMethodContext::CallbackData TextField::OnInputMethodContextEvent( Dali::InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnImfEvent %p eventName %d\n", mController.Get(), imfEvent.eventName );
- return mController->OnImfEvent( imfManager, imfEvent );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnInputMethodContextEvent %p eventName %d\n", mController.Get(), inputMethodContextEvent.eventName );
+ return mController->OnInputMethodContextEvent( inputMethodContext, inputMethodContextEvent );
}
void TextField::GetHandleImagePropertyValue( Property::Value& value, Text::HandleType handleType, Text::HandleImageType handleImageType )
Add( ColorVisual::Property::MIX_COLOR, Color::TRANSPARENT ) );
// Enable the clipping property.
- mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+ mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
mStencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
Self().Add( mStencil );