#include <iostream>
#include <stdlib.h>
#include <unistd.h>
-
#include <dali/public-api/rendering/renderer.h>
#include <dali/devel-api/adaptor-framework/clipboard.h>
#include <dali/integration-api/events/key-event-integ.h>
return true;
}
+class ScrollStateChangeCallback : public Dali::ConnectionTracker
+{
+public:
+ ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
+ : mStartedCalled( startedCalled ),
+ mFinishedCalled( finishedCalled )
+ {
+ }
+
+ void Callback( TextEditor editor, DevelTextEditor::Scroll::Type type )
+ {
+ if( type == DevelTextEditor::Scroll::STARTED )
+ {
+ mStartedCalled = true;
+ }
+ else if( type == DevelTextEditor::Scroll::FINISHED )
+ {
+ mFinishedCalled = true;
+ }
+ }
+
+ bool& mStartedCalled;
+ bool& mFinishedCalled;
+};
+
} // namespace
int UtcDaliToolkitTextEditorConstructorP(void)
END_TEST;
}
+
int utcDaliTextEditorGetPropertyLinecountP(void)
{
ToolkitTestApplication application;
END_TEST;
}
+
+int utcDaliTextEditorScrollStateChangedSignalTest(void)
+{
+
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK( editor );
+
+ Stage::GetCurrent().Add( editor );
+
+ editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
+ editor.SetSize( 50.f, 50.f );
+ editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
+ editor.SetKeyboardFocusable(true);
+
+ bool startedCalled = false;
+ bool finishedCalled = false;
+
+ ScrollStateChangeCallback callback( startedCalled, finishedCalled );
+ DevelTextEditor::ScrollStateChangedSignal( editor ).Connect( &callback, &ScrollStateChangeCallback::Callback );
+
+ KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
+ application.SendNotification();
+ application.Render(6000);
+
+ application.SendNotification();
+ DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
+
+ END_TEST;
+}
--- /dev/null
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
+
+// INTERNAL HEADER
+#include <dali-toolkit/internal/controls/text-controls/text-editor-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace DevelTextEditor
+{
+
+ScrollStateChangedSignalType& ScrollStateChangedSignal( TextEditor textEditor )
+{
+ return Dali::Toolkit::GetImpl( textEditor ).ScrollStateChangedSignal();
+}
+
+} // namespace DevelText
+
+} // namespace Toolkit
+
+} // namespace Dali
};
} // namespace Property
-} // namespace DevelText
+namespace Scroll
+{
+ enum Type
+ {
+ STARTED, ///< Scrolling is started.
+ FINISHED ///< Scrolling is finished.
+ };
+} // namespace Scroll
+
+typedef Signal< void ( TextEditor, Scroll::Type ) > ScrollStateChangedSignalType;
+
+/**
+ * @brief This signal is emitted when TextEditor scrolling is started or finished.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName( ScrollState::Type type );
+ * @endcode
+ * type: Whether the scrolling is started or finished.
+ * @return The signal to connect to
+ */
+DALI_IMPORT_API ScrollStateChangedSignalType& ScrollStateChangedSignal( TextEditor textEditor );
+
+} // namespace DevelTextEditor
} // namespace Toolkit
$(devel_api_src_dir)/controls/super-blur-view/super-blur-view.cpp \
$(devel_api_src_dir)/controls/text-controls/text-selection-popup.cpp \
$(devel_api_src_dir)/controls/text-controls/text-selection-toolbar.cpp \
+ $(devel_api_src_dir)/controls/text-controls/text-editor-devel.cpp \
$(devel_api_src_dir)/controls/tool-bar/tool-bar.cpp \
$(devel_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \
$(devel_api_src_dir)/focus-manager/keyboard-focus-manager-devel.cpp \
return mInputStyleChangedSignal;
}
+Toolkit::DevelTextEditor::ScrollStateChangedSignalType& TextEditor::ScrollStateChangedSignal()
+{
+ return mScrollStateChangedSignal;
+}
+
void TextEditor::OnInitialize()
{
Actor self = Self();
return;
}
+ // If scrolling is not started, start scrolling and emit ScrollStateChangedSignal
+ if( !mScrollStarted )
+ {
+ mScrollStarted = true;
+ Dali::Toolkit::TextEditor handle( GetOwner() );
+ mScrollStateChangedSignal.Emit( handle, DevelTextEditor::Scroll::STARTED );
+ }
+
CustomActor self = Self();
if( !mScrollBar )
{
indicator.SetOpacity(1.0f);
mAnimation.AnimateTo( Property( indicator, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::EASE_IN, mAnimationPeriod );
mAnimation.Play();
+ mAnimation.FinishedSignal().Connect( this, &TextEditor::OnScrollIndicatorAnimationFinished );
+}
+
+void TextEditor::OnScrollIndicatorAnimationFinished( Animation& animation )
+{
+ // If animation is successfully ended, then emit ScrollStateChangedSignal
+ if( animation.GetCurrentProgress() == 0.0f )
+ {
+ mScrollStarted = false;
+ Dali::Toolkit::TextEditor handle( GetOwner() );
+ mScrollStateChangedSignal.Emit( handle, DevelTextEditor::Scroll::FINISHED );
+ }
}
void TextEditor::OnStageConnect( Dali::Actor actor )
mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
mHasBeenStaged( false ),
mScrollAnimationEnabled( false ),
- mScrollBarEnabled( false )
+ mScrollBarEnabled( false ),
+ mScrollStarted( false )
{
}
#include <dali/public-api/animation/animation.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h>
#include <dali-toolkit/public-api/controls/text-controls/text-editor.h>
*/
Toolkit::TextEditor::InputStyleChangedSignalType& InputStyleChangedSignal();
+ /**
+ * @copydoc DevelTextEditor::ScrollStateChangedSignal()
+ */
+ Toolkit::DevelTextEditor::ScrollStateChangedSignalType& ScrollStateChangedSignal();
+
private: // From Control
/**
void ApplyScrollPosition();
/**
+ * @brief Callback function for ScrollBar indicator animation finished signal
+ *
+ * Emit ScrollBarStateChanged Signal and toggle mScrollStarted flag to false
+ */
+ void OnScrollIndicatorAnimationFinished( Animation& animation );
+
+ /**
* Construct a new TextEditor.
*/
TextEditor();
// Signals
Toolkit::TextEditor::TextChangedSignalType mTextChangedSignal;
Toolkit::TextEditor::InputStyleChangedSignalType mInputStyleChangedSignal;
+ Toolkit::DevelTextEditor::ScrollStateChangedSignalType mScrollStateChangedSignal;
ImfManager mImfManager;
Text::ControllerPtr mController;
bool mHasBeenStaged:1;
bool mScrollAnimationEnabled:1;
bool mScrollBarEnabled:1;
+ bool mScrollStarted:1;
};
} // namespace Internal