- Added Padding in Text controls.
- Added Right-To-Left mode in TextField and TextEditor.
Change-Id: Iaf7e78b4c303bbcd442c8db11399231a24701c86
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/integration-api/events/tap-gesture-event.h>
#include <dali/integration-api/events/pan-gesture-event.h>
+#include <dali/integration-api/events/long-press-gesture-event.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
return tap;
}
+Integration::LongPressGestureEvent GenerateLongPress(
+ Gesture::State state,
+ unsigned int numberOfTouches,
+ Vector2 point)
+{
+ Integration::LongPressGestureEvent longPress( state );
+
+ longPress.numberOfTouches = numberOfTouches;
+ longPress.point = point;
+ return longPress;
+}
+
// Generate a PanGestureEvent to send to Core
Integration::PanGestureEvent GeneratePan( Gesture::State state,
const Vector2& previousPosition,
placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
+ editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
+ DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
END_TEST;
}
DALI_TEST_CHECK( renderer );
}
+ // Long Press
+ application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
+ application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
END_TEST;
}
END_TEST;
}
+
+int UtcDaliTextEditorSetPaddingProperty(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK( editor );
+ editor.SetSize( 300.f, 50.f );
+ editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ Stage::GetCurrent().Add( editor );
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 originalSize = editor.GetNaturalSize();
+
+ editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
+
+ Vector3 paddingAddedSize = editor.GetNaturalSize();
+
+ DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ END_TEST;
+}
field.SetProperty( TextField::Property::ELLIPSIS, true );
DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
+ field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
+ DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
END_TEST;
}
END_TEST;
}
+
+int UtcDaliTextFieldSetPaddingProperty(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK( field );
+ field.SetSize( 300.f, 50.f );
+ field.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ Stage::GetCurrent().Add( field );
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 originalSize = field.GetNaturalSize();
+
+ field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
+
+ Vector3 paddingAddedSize = field.GetNaturalSize();
+
+ DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ END_TEST;
+}
Vector3 TextEditor::GetNaturalSize()
{
- return mController->GetNaturalSize();
+ Extents padding;
+ padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+
+ Vector3 naturalSize = mController->GetNaturalSize();
+ naturalSize.width += ( padding.start + padding.end );
+ naturalSize.height += ( padding.top + padding.bottom );
+
+ return naturalSize;
}
float TextEditor::GetHeightForWidth( float width )
{
- Padding padding;
- Self().GetPadding( padding );
+ Extents padding;
+ padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
return mController->GetHeightForWidth( width ) + padding.top + padding.bottom;
}
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor OnRelayout\n");
Actor self = Self();
- Padding padding;
- self.GetPadding( padding );
- Vector2 contentSize( size.x - ( padding.left + padding.right ), size.y - ( padding.top + padding.bottom ) );
+ Extents padding;
+ padding = self.GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+
+ Vector2 contentSize( size.x - ( padding.start + padding.end ), size.y - ( padding.top + padding.bottom ) );
+
+ // Support Right-To-Left of padding
+ Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+ if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
+ {
+ std::swap( padding.start, padding.end );
+ }
if( mStencil )
{
- mStencil.SetPosition( padding.left , padding.top );
+ mStencil.SetPosition( padding.start, padding.top );
}
if( mActiveLayer )
{
- mActiveLayer.SetPosition( padding.left , padding.top );
+ mActiveLayer.SetPosition( padding.start, padding.top );
}
-
const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize );
if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
mImfManager.Activate();
// Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
- Padding padding;
- Self().GetPadding( padding );
- mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x - padding.left, gesture.localPoint.y - padding.top );
+ Extents padding;
+ padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+ mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
SetKeyInputFocus();
}
{
mImfManager.Activate();
- Padding padding;
- Self().GetPadding( padding );
- mController->LongPressEvent( gesture.state, gesture.localPoint.x - padding.left, gesture.localPoint.y - padding.top );
+ Extents padding;
+ padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+ mController->LongPressEvent( gesture.state, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
SetKeyInputFocus();
}
Vector3 TextField::GetNaturalSize()
{
- return mController->GetNaturalSize();
+ Extents padding;
+ padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+
+ Vector3 naturalSize = mController->GetNaturalSize();
+ naturalSize.width += ( padding.start + padding.end );
+ naturalSize.height += ( padding.top + padding.bottom );
+
+ return naturalSize;
}
float TextField::GetHeightForWidth( float width )
{
- Padding padding;
- Self().GetPadding( padding );
+ Extents padding;
+ padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
return mController->GetHeightForWidth( width ) + padding.top + padding.bottom;
}
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField OnRelayout\n");
Actor self = Self();
- Padding padding;
- self.GetPadding( padding );
- Vector2 contentSize( size.x - ( padding.left + padding.right ), size.y - ( padding.top + padding.bottom ) );
+ Extents padding;
+ padding = self.GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+
+ Vector2 contentSize( size.x - ( padding.start + padding.end ), size.y - ( padding.top + padding.bottom ) );
+
+ // Support Right-To-Left of padding
+ Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+ if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
+ {
+ std::swap( padding.start, padding.end );
+ }
if( mStencil )
{
- mStencil.SetPosition( padding.left , padding.top );
+ mStencil.SetPosition( padding.start, padding.top );
}
if( mActiveLayer )
{
- mActiveLayer.SetPosition( padding.left , padding.top );
+ mActiveLayer.SetPosition( padding.start, padding.top );
}
const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize );
if( mStencil )
{
- mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset, scrollOffset.y );
+ mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset, scrollOffset.y );
}
else
{
- Padding padding;
- Self().GetPadding( padding );
- mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset + padding.left, scrollOffset.y + padding.top );
+ Extents padding;
+ padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+
+ // Support Right-To-Left of padding
+ Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( Self().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+ if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
+ {
+ std::swap( padding.start, padding.end );
+ }
+
+ mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset + padding.start, scrollOffset.y + padding.top );
}
mImfManager.Activate();
// Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
- Padding padding;
- Self().GetPadding( padding );
- mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x - padding.left, gesture.localPoint.y - padding.top );
+ Extents padding;
+ padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+ mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
SetKeyInputFocus();
}
{
mImfManager.Activate();
- Padding padding;
- Self().GetPadding( padding );
- mController->LongPressEvent( gesture.state, gesture.localPoint.x - padding.left, gesture.localPoint.y - padding.top );
+ Extents padding;
+ padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+ mController->LongPressEvent( gesture.state, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
SetKeyInputFocus();
}
Vector3 TextLabel::GetNaturalSize()
{
- return mController->GetNaturalSize();
+ Extents padding;
+ padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+
+ Vector3 naturalSize = mController->GetNaturalSize();
+ naturalSize.width += ( padding.start + padding.end );
+ naturalSize.height += ( padding.top + padding.bottom );
+
+ return naturalSize;
}
float TextLabel::GetHeightForWidth( float width )
// Update the visual
TextVisual::EnableRendererUpdate( mVisual );
- Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( Self().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>() );
+ // Support Right-To-Left of padding
+ Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( Self().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
{
- std::swap(padding.start, padding.end);
+ std::swap( padding.start, padding.end );
}
Property::Map visualTransform;
visualTransform.Add( Toolkit::Visual::Transform::Property::SIZE, contentSize )
.Add( Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) )
- .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2(padding.start, padding.top) )
+ .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( padding.start, padding.top ) )
.Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) )
.Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
.Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN );