END_TEST;
}
+
+int UtcDaliTextEditorScrolling(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextEditorScrolling ");
+
+ TextEditor textEditor = TextEditor::New();
+ DALI_TEST_CHECK( textEditor );
+
+ application.GetScene().Add( textEditor );
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+ application.SendNotification();
+ application.Render();
+
+ textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
+ textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
+ textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
+ textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
+
+
+ DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
+
+ DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
+
+ DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
+
+ DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
+ DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
+
+ textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
+ textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
+
+ DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
+
+ END_TEST;
+}
GetImpl(textEditor).SelectNone();
}
+void ScrollBy(TextEditor textEditor, Vector2 scroll)
+{
+ GetImpl(textEditor).ScrollBy(scroll);
+}
+
} // namespace DevelTextEditor
} // namespace Toolkit
SELECTED_TEXT_END,
/**
+ * @brief The horizontal scroll position in pixels.
+ * @details Name "horizontalScrollPosition", type Property::FLOAT.
+ */
+ HORIZONTAL_SCROLL_POSITION,
+
+ /**
+ * @brief The vertical scroll position in pixels.
+ * @details Name "verticalScrollPosition", type Property::FLOAT.
+ */
+ VERTICAL_SCROLL_POSITION,
+
+ /**
* @brief The Editable state of control.
* @details Name "enableEditing", type Property::BOOLEAN.
*/
*/
DALI_TOOLKIT_API void SelectNone(TextEditor textEditor);
+/**
+ * @brief Scroll the TextEditor by specific amount.
+ *
+ * @param[in] textEditor The instance of TextEditor.
+ * @param[in] scroll amount (in pixels) of scrolling in horizontal & vectical directions.
+ */
+DALI_TOOLKIT_API void ScrollBy(TextEditor textEditor, Vector2 scroll);
+
} // namespace DevelTextEditor
} // namespace Toolkit
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "maxLength", INTEGER, MAX_LENGTH )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectedTextStart", INTEGER, SELECTED_TEXT_START )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectedTextEnd", INTEGER, SELECTED_TEXT_END )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "horizontalScrollPosition", FLOAT, HORIZONTAL_SCROLL_POSITION )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "verticalScrollPosition", INTEGER, VERTICAL_SCROLL_POSITION )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableEditing", BOOLEAN, ENABLE_EDITING )
DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextEditor, "selectedText", STRING, SELECTED_TEXT )
impl.SetEditable( editable );
break;
}
+ case Toolkit::DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION:
+ {
+ float horizontalScroll = value.Get< float >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p HORIZONTAL_SCROLL_POSITION %d\n", impl.mController.Get(), horizontalScroll );
+ if (horizontalScroll >= 0.0f)
+ {
+ impl.ScrollBy( Vector2(horizontalScroll - impl.GetHorizontalScrollPosition(), 0 ));
+ }
+ break;
+ }
+ case Toolkit::DevelTextEditor::Property::VERTICAL_SCROLL_POSITION:
+ {
+ float verticalScroll = value.Get< float >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p VERTICAL_SCROLL_POSITION %d\n", impl.mController.Get(), verticalScroll );
+ if (verticalScroll >= 0.0f)
+ {
+ impl.ScrollBy( Vector2(0, verticalScroll - impl.GetVerticalScrollPosition() ));
+ }
+ break;
+ }
} // switch
} // texteditor
}
value = impl.IsEditable();
break;
}
+ case Toolkit::DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION:
+ {
+ value = impl.GetHorizontalScrollPosition();
+ break;
+ }
+ case Toolkit::DevelTextEditor::Property::VERTICAL_SCROLL_POSITION:
+ {
+ value = impl.GetVerticalScrollPosition();
+ break;
+ }
} //switch
}
}
}
+void TextEditor::ScrollBy(Vector2 scroll)
+{
+ if( mController && mController->IsShowingRealText() )
+ {
+ mController->ScrollBy(scroll);
+ }
+}
+
+float TextEditor::GetHorizontalScrollPosition()
+{
+ if( mController && mController->IsShowingRealText() )
+ {
+ return mController->GetHorizontalScrollPosition();
+ }
+ return 0;
+}
+
+float TextEditor::GetVerticalScrollPosition()
+{
+ if( mController && mController->IsShowingRealText() )
+ {
+ return mController->GetVerticalScrollPosition();
+ }
+ return 0;
+}
+
string TextEditor::GetSelectedText() const
{
string selectedText = "";
void SelectNone() override;
/**
+ * @copydoc Dali::Toolkit::DevelTextEditor::ScrollBy()
+ */
+ void ScrollBy(Vector2 Scroll);
+
+ /**
+ * @brief Get Horizontal scroll position of TextEditor.
+ *
+ * @return Horizontal scroll position (in pixels) of TextEditor.
+ */
+ float GetHorizontalScrollPosition();
+
+ /**
+ * @brief Get Vertical scroll position of TextEditor.
+ *
+ * @return Vertical scroll position (in pixels) of TextEditor.
+ */
+ float GetVerticalScrollPosition();
+
+ /**
* @copydoc Text::SelectableControlInterface::GetSelectedText()
*/
string GetSelectedText() const override;
}
}
+void Controller::ScrollBy( Vector2 scroll )
+{
+ if( mImpl->mEventData && (fabs(scroll.x) > Math::MACHINE_EPSILON_0 || fabs(scroll.y) > Math::MACHINE_EPSILON_0))
+ {
+ const Vector2& layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize();
+ const Vector2 currentScroll = mImpl->mModel->mScrollPosition;
+
+ scroll.x = -scroll.x;
+ scroll.y = -scroll.y;
+
+ if( fabs(scroll.x) > Math::MACHINE_EPSILON_0 )
+ {
+ mImpl->mModel->mScrollPosition.x += scroll.x;
+ mImpl->ClampHorizontalScroll( layoutSize );
+ }
+
+ if( fabs(scroll.y) > Math::MACHINE_EPSILON_0 )
+ {
+ mImpl->mModel->mScrollPosition.y += scroll.y;
+ mImpl->ClampVerticalScroll( layoutSize );
+ }
+
+ if (mImpl->mModel->mScrollPosition != currentScroll)
+ {
+ mImpl->mEventData->mDecorator->UpdatePositions( mImpl->mModel->mScrollPosition - currentScroll );
+ mImpl->RequestRelayout();
+ }
+ }
+}
+
+float Controller::GetHorizontalScrollPosition()
+{
+ if( mImpl->mEventData )
+ {
+ //scroll values are negative internally so we convert them to positive numbers
+ return -mImpl->mModel->mScrollPosition.x;
+ }
+ return 0;
+}
+
+float Controller::GetVerticalScrollPosition()
+{
+ if( mImpl->mEventData )
+ {
+ //scroll values are negative internally so we convert them to positive numbers
+ return -mImpl->mModel->mScrollPosition.y;
+ }
+ return 0;
+}
+
void Controller::DecorationEvent( HandleType handleType, HandleState state, float x, float y )
{
EventHandler::DecorationEvent(*this, handleType, state, x, y);
virtual void SetEditable( bool editable );
/**
+ * @copydoc Dali::Toolkit::Internal::TextEditor::ScrollBy()
+ */
+ virtual void ScrollBy( Vector2 scroll );
+
+ /**
+ * @copydoc Dali::Toolkit::Internal::TextEditor::GetHorizontalScrollPosition()
+ */
+ float GetHorizontalScrollPosition();
+
+ /**
+ * @copydoc Dali::Toolkit::Internal::TextEditor::GetVerticalScrollPosition()
+ */
+ float GetVerticalScrollPosition();
+
+ /**
* @brief Event received from input method context
*
* @param[in] inputMethodContext The input method context.