From: Paul Wisbey
Date: Thu, 20 Oct 2016 09:06:04 +0000 (-0700)
Subject: Merge "TextController refactor." into devel/master
X-Git-Tag: dali_1.2.11~6
X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=e35b08ebd60473aef7500601706f665ac8cf7d39;hp=14b18fb7d1bd4a727e8dc9793fb9ef190d87a69f
Merge "TextController refactor." into devel/master
---
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp
index 7480435..c67f622 100644
--- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp
+++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp
@@ -23,6 +23,8 @@
#include
#include
#include
+#include
+#include
using namespace Dali;
using namespace Toolkit;
@@ -40,7 +42,7 @@ const char* const OPTION_CLIPBOARD("optionClipboard"); // "Clipboard" popup
const Size CONTROL_SIZE( 300.f, 60.f );
-class ControlImpl : public ControlInterface
+class ControlImpl : public ControlInterface, public Text::EditableControlInterface
{
public:
ControlImpl()
@@ -80,8 +82,7 @@ int UtcDaliTextController(void)
ToolkitTestApplication application;
// Creates a text controller.
- ControlImpl controlImpl;
- ControllerPtr controller = Controller::New( controlImpl );
+ ControllerPtr controller = Controller::New();
DALI_TEST_CHECK( controller );
@@ -95,8 +96,7 @@ int UtcDaliTextControllerEnableCursorBlinking(void)
ToolkitTestApplication application;
// Creates a text controller.
- ControlImpl controlImpl;
- ControllerPtr controller = Controller::New( controlImpl );
+ ControllerPtr controller = Controller::New();
DALI_TEST_CHECK( controller );
@@ -131,8 +131,7 @@ int UtcDaliTextControllerImfEvent(void)
ToolkitTestApplication application;
// Creates a text controller.
- ControlImpl controlImpl;
- ControllerPtr controller = Controller::New( controlImpl );
+ ControllerPtr controller = Controller::New();
std::string text;
ImfManager::ImfEventData imfEvent;
@@ -214,8 +213,7 @@ int UtcDaliTextControllerTextPopupButtonTouched(void)
ToolkitTestApplication application;
// Creates a text controller.
- ControlImpl controlImpl;
- ControllerPtr controller = Controller::New( controlImpl );
+ ControllerPtr controller = Controller::New();
DALI_TEST_CHECK( controller );
diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
index ddcb8d5..8e74c70 100644
--- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
+++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
@@ -933,7 +933,7 @@ void TextEditor::OnInitialize()
{
Actor self = Self();
- mController = Text::Controller::New( *this );
+ mController = Text::Controller::New( this, this );
mDecorator = Text::Decorator::New( *mController,
*mController );
@@ -1042,7 +1042,7 @@ void TextEditor::OnRelayout( const Vector2& size, RelayoutContainer& container )
mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
}
- EnableClipping( true, size );
+ EnableClipping( size );
RenderText( updateTextType );
}
@@ -1235,21 +1235,6 @@ bool TextEditor::OnKeyEvent( const KeyEvent& event )
return mController->KeyEvent( event );
}
-void TextEditor::AddDecoration( Actor& actor, bool needsClipping )
-{
- if( actor )
- {
- if( needsClipping )
- {
- mClippingDecorationActors.push_back( actor );
- }
- else
- {
- Self().Add( actor );
- }
- }
-}
-
void TextEditor::RequestTextRelayout()
{
RelayoutRequest();
@@ -1261,6 +1246,11 @@ void TextEditor::TextChanged()
mTextChangedSignal.Emit( handle );
}
+void TextEditor::MaxLengthReached()
+{
+ // Nothing to do as TextEditor doesn't emit a max length reached signal.
+}
+
void TextEditor::InputStyleChanged( Text::InputStyle::Mask inputStyleMask )
{
Dali::Toolkit::TextEditor handle( GetOwner() );
@@ -1315,9 +1305,19 @@ void TextEditor::InputStyleChanged( Text::InputStyle::Mask inputStyleMask )
mInputStyleChangedSignal.Emit( handle, editorInputStyleMask );
}
-void TextEditor::MaxLengthReached()
+void TextEditor::AddDecoration( Actor& actor, bool needsClipping )
{
- // Nothing to do as TextEditor doesn't emit a max length reached signal.
+ if( actor )
+ {
+ if( needsClipping )
+ {
+ mClippingDecorationActors.push_back( actor );
+ }
+ else
+ {
+ Self().Add( actor );
+ }
+ }
}
void TextEditor::OnStageConnect( Dali::Actor actor )
@@ -1353,31 +1353,23 @@ void TextEditor::GetHandleImagePropertyValue( Property::Value& value, Text::Han
}
}
-void TextEditor::EnableClipping( bool clipping, const Vector2& size )
+void TextEditor::EnableClipping( const Vector2& size )
{
- if( clipping )
+ // Not worth to created clip actor if width or height is equal to zero.
+ if( size.width > Math::MACHINE_EPSILON_1000 && size.height > Math::MACHINE_EPSILON_1000 )
{
- // Not worth to created clip actor if width or height is equal to zero.
- if( size.width > Math::MACHINE_EPSILON_1000 && size.height > Math::MACHINE_EPSILON_1000 )
+ if( !mClipper )
{
- if( !mClipper )
- {
- Actor self = Self();
+ Actor self = Self();
- mClipper = Clipper::New( size );
- self.Add( mClipper->GetRootActor() );
- self.Add( mClipper->GetImageView() );
- }
- else if ( mClipper )
- {
- mClipper->Refresh( size );
- }
+ mClipper = Clipper::New( size );
+ self.Add( mClipper->GetRootActor() );
+ self.Add( mClipper->GetImageView() );
+ }
+ else if ( mClipper )
+ {
+ mClipper->Refresh( size );
}
- }
- else
- {
- // Note - this will automatically remove the root actor & the image view
- mClipper.Reset();
}
}
diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h
index cb40406..12bbe0d 100644
--- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h
+++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h
@@ -1,5 +1,5 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_EDITOR_H__
-#define __DALI_TOOLKIT_INTERNAL_TEXT_EDITOR_H__
+#ifndef DALI_TOOLKIT_INTERNAL_TEXT_EDITOR_H
+#define DALI_TOOLKIT_INTERNAL_TEXT_EDITOR_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
@@ -24,6 +24,7 @@
#include
#include
#include
+#include
#include
#include
@@ -42,7 +43,7 @@ namespace Internal
/**
* @brief A control which renders a long text string with styles.
*/
-class TextEditor : public Control, public Text::ControlInterface
+class TextEditor : public Control, public Text::ControlInterface, public Text::EditableControlInterface
{
public:
@@ -157,15 +158,12 @@ private: // From Control
// From ControlInterface
/**
- * @copydoc Text::ControlInterface::AddDecoration()
- */
- virtual void AddDecoration( Actor& actor, bool needsClipping );
-
- /**
* @copydoc Text::ControlInterface::RequestTextRelayout()
*/
virtual void RequestTextRelayout();
+// From EditableControlInterface
+
/**
* @copydoc Text::ControlInterface::TextChanged()
*/
@@ -181,6 +179,11 @@ private: // From Control
*/
virtual void InputStyleChanged( Text::InputStyle::Mask inputStyleMask );
+ /**
+ * @copydoc Text::ControlInterface::AddDecoration()
+ */
+ virtual void AddDecoration( Actor& actor, bool needsClipping );
+
private: // Implementation
/**
@@ -205,10 +208,9 @@ private: // Implementation
/**
* @brief Enable or disable clipping.
*
- * @param[in] clipping True if clipping should be enabled.
* @param[in] size The area to clip within.
*/
- void EnableClipping( bool clipping, const Vector2& size );
+ void EnableClipping( const Vector2& size );
/**
* @brief Callback when keyboard is shown/hidden.
@@ -299,4 +301,4 @@ inline const Toolkit::Internal::TextEditor& GetImpl( const Toolkit::TextEditor&
} // namespace Dali
-#endif // __DALI_TOOLKIT_INTERNAL_TEXT_EDITOR_H__
+#endif // DALI_TOOLKIT_INTERNAL_TEXT_EDITOR_H
diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
index e0d75ce..4f8515f 100644
--- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
+++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
@@ -1114,7 +1114,7 @@ void TextField::OnInitialize()
{
Actor self = Self();
- mController = Text::Controller::New( *this );
+ mController = Text::Controller::New( this, this );
// When using the vector-based rendering, the size of the GLyphs are different
TextAbstraction::GlyphType glyphType = (Text::RENDERING_VECTOR_BASED == mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
@@ -1222,7 +1222,7 @@ void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
}
- EnableClipping( ( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy ), size );
+ EnableClipping( size );
RenderText( updateTextType );
}
@@ -1416,21 +1416,6 @@ bool TextField::OnKeyEvent( const KeyEvent& event )
return mController->KeyEvent( event );
}
-void TextField::AddDecoration( Actor& actor, bool needsClipping )
-{
- if( actor )
- {
- if( needsClipping )
- {
- mClippingDecorationActors.push_back( actor );
- }
- else
- {
- Self().Add( actor );
- }
- }
-}
-
void TextField::RequestTextRelayout()
{
RelayoutRequest();
@@ -1442,6 +1427,12 @@ void TextField::TextChanged()
mTextChangedSignal.Emit( handle );
}
+void TextField::MaxLengthReached()
+{
+ Dali::Toolkit::TextField handle( GetOwner() );
+ mMaxLengthReachedSignal.Emit( handle );
+}
+
void TextField::InputStyleChanged( Text::InputStyle::Mask inputStyleMask )
{
Dali::Toolkit::TextField handle( GetOwner() );
@@ -1492,6 +1483,21 @@ void TextField::InputStyleChanged( Text::InputStyle::Mask inputStyleMask )
mInputStyleChangedSignal.Emit( handle, fieldInputStyleMask );
}
+void TextField::AddDecoration( Actor& actor, bool needsClipping )
+{
+ if( actor )
+ {
+ if( needsClipping )
+ {
+ mClippingDecorationActors.push_back( actor );
+ }
+ else
+ {
+ Self().Add( actor );
+ }
+ }
+}
+
void TextField::OnStageConnect( Dali::Actor actor )
{
if ( mHasBeenStaged )
@@ -1504,12 +1510,6 @@ void TextField::OnStageConnect( Dali::Actor actor )
}
}
-void TextField::MaxLengthReached()
-{
- Dali::Toolkit::TextField handle( GetOwner() );
- mMaxLengthReachedSignal.Emit( handle );
-}
-
ImfManager::ImfCallbackData TextField::OnImfEvent( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnImfEvent %p eventName %d\n", mController.Get(), imfEvent.eventName );
@@ -1531,9 +1531,9 @@ void TextField::GetHandleImagePropertyValue( Property::Value& value, Text::Hand
}
}
-void TextField::EnableClipping( bool clipping, const Vector2& size )
+void TextField::EnableClipping( const Vector2& size )
{
- if( clipping )
+ if( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy )
{
// Not worth to created clip actor if width or height is equal to zero.
if( size.width > Math::MACHINE_EPSILON_1000 && size.height > Math::MACHINE_EPSILON_1000 )
diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.h b/dali-toolkit/internal/controls/text-controls/text-field-impl.h
index 558cced..9762c70 100644
--- a/dali-toolkit/internal/controls/text-controls/text-field-impl.h
+++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h
@@ -1,5 +1,5 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
-#define __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
+#ifndef DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H
+#define DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
@@ -24,6 +24,7 @@
#include
#include
#include
+#include
#include
#include
@@ -42,7 +43,7 @@ namespace Internal
/**
* @brief A control which renders a short text string.
*/
-class TextField : public Control, public Text::ControlInterface
+class TextField : public Control, public Text::ControlInterface, public Text::EditableControlInterface
{
public:
@@ -162,15 +163,12 @@ private: // From Control
// From ControlInterface
/**
- * @copydoc Text::ControlInterface::AddDecoration()
- */
- virtual void AddDecoration( Actor& actor, bool needsClipping );
-
- /**
* @copydoc Text::ControlInterface::RequestTextRelayout()
*/
virtual void RequestTextRelayout();
+// From EditableControlInterface
+
/**
* @copydoc Text::ControlInterface::TextChanged()
*/
@@ -186,6 +184,11 @@ private: // From Control
*/
virtual void InputStyleChanged( Text::InputStyle::Mask inputStyleMask );
+ /**
+ * @copydoc Text::ControlInterface::AddDecoration()
+ */
+ virtual void AddDecoration( Actor& actor, bool needsClipping );
+
private: // Implementation
/**
@@ -210,10 +213,9 @@ private: // Implementation
/**
* @brief Enable or disable clipping.
*
- * @param[in] clipping True if clipping should be enabled.
* @param[in] size The area to clip within.
*/
- void EnableClipping( bool clipping, const Vector2& size );
+ void EnableClipping( const Vector2& size );
/**
* @brief Callback when keyboard is shown/hidden.
@@ -306,4 +308,4 @@ inline const Toolkit::Internal::TextField& GetImpl( const Toolkit::TextField& te
} // namespace Dali
-#endif // __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
+#endif // DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H
diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
index bf8c866..6fbe3b6 100644
--- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
+++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
@@ -644,7 +644,7 @@ void TextLabel::OnInitialize()
{
Actor self = Self();
- mController = Text::Controller::New( *this );
+ mController = Text::Controller::New( this );
// When using the vector-based rendering, the size of the GLyphs are different
TextAbstraction::GlyphType glyphType = (Text::RENDERING_VECTOR_BASED == mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
@@ -791,11 +791,6 @@ void TextLabel::OnStageConnect( Dali::Actor actor )
}
}
-void TextLabel::AddDecoration( Actor& actor, bool needsClipping )
-{
- // TextLabel does not show decorations
-}
-
void TextLabel::OnStageConnection( int depth )
{
// Call the Control::OnStageConnection() to set the depth of the background.
@@ -804,21 +799,6 @@ void TextLabel::OnStageConnection( int depth )
// The depth of the text renderer is set in the RenderText() called from OnRelayout().
}
-void TextLabel::TextChanged()
-{
- // TextLabel does not provide a signal for this.
-}
-
-void TextLabel::MaxLengthReached()
-{
- // Pure Virtual from TextController Interface, only needed when inputting text
-}
-
-void TextLabel::InputStyleChanged( Text::InputStyle::Mask inputStyleMask )
-{
- // TextLabel does not provide a signal for this.
-}
-
void TextLabel::ScrollingFinished()
{
// Pure Virtual from TextScroller Interface
diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.h b/dali-toolkit/internal/controls/text-controls/text-label-impl.h
index 298ba1a..c928763 100644
--- a/dali-toolkit/internal/controls/text-controls/text-label-impl.h
+++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.h
@@ -1,5 +1,5 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
-#define __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
+#ifndef DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H
+#define DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
@@ -21,6 +21,7 @@
// INTERNAL INCLUDES
#include
#include
+#include
#include
#include
#include
@@ -95,35 +96,17 @@ private: // From Control
virtual float GetHeightForWidth( float width );
/**
- * @copydoc Text::ControlInterface::AddDecoration()
- */
- virtual void AddDecoration( Actor& actor, bool needsClipping );
-
- /**
* @copydoc Control::OnStageConnection()
*/
virtual void OnStageConnection( int depth );
+// From ControlInterface
+
/**
* @copydoc Text::ControlInterface::RequestTextRelayout()
*/
virtual void RequestTextRelayout();
- /**
- * @copydoc Text::ControlInterface::TextChanged()
- */
- virtual void TextChanged();
-
- /**
- * @copydoc Text::ControlInterface::MaxLengthReached()
- */
- virtual void MaxLengthReached();
-
- /**
- * @copydoc Text::ControlInterface::InputStyleChanged()
- */
- virtual void InputStyleChanged( Text::InputStyle::Mask inputStyleMask );
-
private: // from TextScroller
/**
@@ -198,4 +181,4 @@ inline const Toolkit::Internal::TextLabel& GetImpl( const Toolkit::TextLabel& te
} // namespace Dali
-#endif // __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
+#endif // DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H
diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list
index 5a52371..6f9ab11 100644
--- a/dali-toolkit/internal/file.list
+++ b/dali-toolkit/internal/file.list
@@ -106,7 +106,6 @@ toolkit_src_files = \
$(toolkit_src_dir)/text/property-string-parser.cpp \
$(toolkit_src_dir)/text/segmentation.cpp \
$(toolkit_src_dir)/text/shaper.cpp \
- $(toolkit_src_dir)/text/text-control-interface.cpp \
$(toolkit_src_dir)/text/text-controller.cpp \
$(toolkit_src_dir)/text/text-controller-impl.cpp \
$(toolkit_src_dir)/text/text-effects-style.cpp \
diff --git a/dali-toolkit/internal/text/text-control-interface.cpp b/dali-toolkit/internal/text/text-control-interface.cpp
deleted file mode 100644
index 8ac77d1..0000000
--- a/dali-toolkit/internal/text/text-control-interface.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2015 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
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Text
-{
-
-ControlInterface::ControlInterface()
-{
-}
-
-ControlInterface::~ControlInterface()
-{
-}
-
-} // namespace Text
-
-} // namespace Toolkit
-
-} // namespace Dali
diff --git a/dali-toolkit/internal/text/text-control-interface.h b/dali-toolkit/internal/text/text-control-interface.h
index f5346e0..ce5af88 100644
--- a/dali-toolkit/internal/text/text-control-interface.h
+++ b/dali-toolkit/internal/text/text-control-interface.h
@@ -1,5 +1,5 @@
-#ifndef __DALI_TOOLKIT_TEXT_CONTROL_INTERFACE_H__
-#define __DALI_TOOLKIT_TEXT_CONTROL_INTERFACE_H__
+#ifndef DALI_TOOLKIT_TEXT_CONTROL_INTERFACE_H
+#define DALI_TOOLKIT_TEXT_CONTROL_INTERFACE_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
@@ -18,14 +18,9 @@
*
*/
-// INTERNAL INCLUDES
-#include
-
namespace Dali
{
-class Actor;
-
namespace Toolkit
{
@@ -40,44 +35,15 @@ class ControlInterface
public:
/**
- * @brief Constructor.
- */
- ControlInterface();
-
- /**
* @brief Virtual destructor.
*/
- virtual ~ControlInterface();
-
- /**
- * @brief Add a decoration.
- *
- * @param[in] decoration The actor displaying a decoration.
- * @param[in] needsClipping Whether the actor needs clipping.
- */
- virtual void AddDecoration( Actor& actor, bool needsClipping ) = 0;
+ virtual ~ControlInterface()
+ {}
/**
* @brief Called to request a text relayout.
*/
virtual void RequestTextRelayout() = 0;
-
- /**
- * @brief Called to signal that text has been inserted or deleted.
- */
- virtual void TextChanged() = 0;
-
- /**
- * @brief Called when the number of characters to be inserted exceeds the maximum limit
- */
- virtual void MaxLengthReached() = 0;
-
- /**
- * @brief Called to signal that input style has been changed.
- *
- * @param[in] inputStyleMask Mask with the bits of the input style that has changed.
- */
- virtual void InputStyleChanged( InputStyle::Mask inputStyleMask ) = 0;
};
} // namespace Text
@@ -86,4 +52,4 @@ public:
} // namespace Dali
-#endif // __DALI_TOOLKIT_TEXT_CONTROL_INTERFACE_H__
+#endif // DALI_TOOLKIT_TEXT_CONTROL_INTERFACE_H
diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp
index 5769fac..7b3f2d6 100644
--- a/dali-toolkit/internal/text/text-controller-impl.cpp
+++ b/dali-toolkit/internal/text/text-controller-impl.cpp
@@ -31,6 +31,7 @@
#include
#include
#include
+#include
#include
namespace
@@ -2749,7 +2750,10 @@ void Controller::Impl::ScrollTextToMatchCursor( const CursorInfo& cursorInfo )
void Controller::Impl::RequestRelayout()
{
- mControlInterface.RequestTextRelayout();
+ if( NULL != mControlInterface )
+ {
+ mControlInterface->RequestTextRelayout();
+ }
}
} // namespace Text
diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h
index 9b17fa7..399de3f 100644
--- a/dali-toolkit/internal/text/text-controller-impl.h
+++ b/dali-toolkit/internal/text/text-controller-impl.h
@@ -1,5 +1,5 @@
-#ifndef __DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_H__
-#define __DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_H__
+#ifndef DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_H
+#define DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
@@ -285,8 +285,10 @@ struct OutlineDefaults
struct Controller::Impl
{
- Impl( ControlInterface& controlInterface )
+ Impl( ControlInterface* controlInterface,
+ EditableControlInterface* editableControlInterface )
: mControlInterface( controlInterface ),
+ mEditableControlInterface( editableControlInterface ),
mLogicalModel(),
mVisualModel(),
mFontDefaults( NULL ),
@@ -686,7 +688,8 @@ private:
public:
- ControlInterface& mControlInterface; ///< Reference to the text controller.
+ ControlInterface* mControlInterface; ///< Reference to the text controller.
+ EditableControlInterface* mEditableControlInterface; ///< Reference to the editable text controller.
LogicalModelPtr mLogicalModel; ///< Pointer to the logical model.
VisualModelPtr mVisualModel; ///< Pointer to the visual model.
FontDefaults* mFontDefaults; ///< Avoid allocating this when the user does not specify a font.
@@ -725,4 +728,4 @@ public:
} // namespace Dali
-#endif // __DALI_TOOLKIT_TEXT_CONTROLLER_H__
+#endif // DALI_TOOLKIT_TEXT_CONTROLLER_H
diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp
index 6dfb99e..91f8673 100644
--- a/dali-toolkit/internal/text/text-controller.cpp
+++ b/dali-toolkit/internal/text/text-controller.cpp
@@ -31,6 +31,7 @@
#include
#include
#include
+#include
namespace
{
@@ -100,11 +101,23 @@ FontDescriptionRun& UpdateSelectionFontStyleRun( EventData* eventData,
// public : Constructor.
-ControllerPtr Controller::New( ControlInterface& controlInterface )
+ControllerPtr Controller::New()
+{
+ return ControllerPtr( new Controller() );
+}
+
+ControllerPtr Controller::New( ControlInterface* controlInterface )
{
return ControllerPtr( new Controller( controlInterface ) );
}
+ControllerPtr Controller::New( ControlInterface* controlInterface,
+ EditableControlInterface* editableControlInterface )
+{
+ return ControllerPtr( new Controller( controlInterface,
+ editableControlInterface ) );
+}
+
// public : Configure the text controller.
void Controller::EnableTextInput( DecoratorPtr decorator )
@@ -460,8 +473,11 @@ void Controller::SetText( const std::string& text )
mImpl->mEventData->mEventQueue.clear();
}
- // Do this last since it provides callbacks into application code
- mImpl->mControlInterface.TextChanged();
+ // Do this last since it provides callbacks into application code.
+ if( NULL != mImpl->mEditableControlInterface )
+ {
+ mImpl->mEditableControlInterface->TextChanged();
+ }
}
void Controller::GetText( std::string& text ) const
@@ -1605,8 +1621,11 @@ void Controller::ProcessInputStyleChangedSignals()
{
const InputStyle::Mask mask = *it;
- // Emit the input style changed signal.
- mImpl->mControlInterface.InputStyleChanged( mask );
+ if( NULL != mImpl->mEditableControlInterface )
+ {
+ // Emit the input style changed signal.
+ mImpl->mEditableControlInterface->InputStyleChanged( mask );
+ }
}
mImpl->mEventData->mInputStyleChangedQueue.Clear();
@@ -1731,10 +1750,11 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
mImpl->RequestRelayout();
}
- if( textChanged )
+ if( textChanged &&
+ ( NULL != mImpl->mEditableControlInterface ) )
{
// Do this last since it provides callbacks into application code
- mImpl->mControlInterface.TextChanged();
+ mImpl->mEditableControlInterface->TextChanged();
}
return true;
@@ -1965,10 +1985,11 @@ ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, cons
ImfManager::ImfCallbackData callbackData( ( retrieveText || retrieveCursor ), cursorPosition, text, false );
- if( requestRelayout )
+ if( requestRelayout &&
+ ( NULL != mImpl->mEditableControlInterface ) )
{
// Do this last since it provides callbacks into application code
- mImpl->mControlInterface.TextChanged();
+ mImpl->mEditableControlInterface->TextChanged();
}
return callbackData;
@@ -2001,7 +2022,10 @@ void Controller::GetTargetSize( Vector2& targetSize )
void Controller::AddDecoration( Actor& actor, bool needsClipping )
{
- mImpl->mControlInterface.AddDecoration( actor, needsClipping );
+ if( NULL != mImpl->mEditableControlInterface )
+ {
+ mImpl->mEditableControlInterface->AddDecoration( actor, needsClipping );
+ }
}
void Controller::DecorationEvent( HandleType handleType, HandleState state, float x, float y )
@@ -2088,7 +2112,11 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt
mImpl->mEventData->mScrollAfterDelete = true;
mImpl->RequestRelayout();
- mImpl->mControlInterface.TextChanged();
+
+ if( NULL != mImpl->mEditableControlInterface )
+ {
+ mImpl->mEditableControlInterface->TextChanged();
+ }
break;
}
case Toolkit::TextSelectionPopup::COPY:
@@ -2375,8 +2403,11 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ
mImpl->ResetImfManager();
- // Do this last since it provides callbacks into application code
- mImpl->mControlInterface.MaxLengthReached();
+ if( NULL != mImpl->mEditableControlInterface )
+ {
+ // Do this last since it provides callbacks into application code
+ mImpl->mEditableControlInterface->MaxLengthReached();
+ }
}
}
@@ -2386,8 +2417,11 @@ void Controller::PasteText( const std::string& stringToPaste )
mImpl->ChangeState( EventData::EDITING );
mImpl->RequestRelayout();
- // Do this last since it provides callbacks into application code
- mImpl->mControlInterface.TextChanged();
+ if( NULL != mImpl->mEditableControlInterface )
+ {
+ // Do this last since it provides callbacks into application code
+ mImpl->mEditableControlInterface->TextChanged();
+ }
}
bool Controller::RemoveText( int cursorOffset,
@@ -3011,10 +3045,22 @@ void Controller::ResetScrollPosition()
// private : Private contructors & copy operator.
-Controller::Controller( ControlInterface& controlInterface )
+Controller::Controller()
: mImpl( NULL )
{
- mImpl = new Controller::Impl( controlInterface );
+ mImpl = new Controller::Impl( NULL, NULL );
+}
+
+Controller::Controller( ControlInterface* controlInterface )
+{
+ mImpl = new Controller::Impl( controlInterface, NULL );
+}
+
+Controller::Controller( ControlInterface* controlInterface,
+ EditableControlInterface* editableControlInterface )
+{
+ mImpl = new Controller::Impl( controlInterface,
+ editableControlInterface );
}
// The copy constructor and operator are left unimplemented.
diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h
index 07e1665..f99d5a9 100644
--- a/dali-toolkit/internal/text/text-controller.h
+++ b/dali-toolkit/internal/text/text-controller.h
@@ -1,5 +1,5 @@
-#ifndef __DALI_TOOLKIT_TEXT_CONTROLLER_H__
-#define __DALI_TOOLKIT_TEXT_CONTROLLER_H__
+#ifndef DALI_TOOLKIT_TEXT_CONTROLLER_H
+#define DALI_TOOLKIT_TEXT_CONTROLLER_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
@@ -26,7 +26,6 @@
#include
#include
#include
-#include
namespace Dali
{
@@ -38,10 +37,11 @@ namespace Text
{
class Controller;
+class ControlInterface;
+class EditableControlInterface;
class View;
typedef IntrusivePtr ControllerPtr;
-typedef Dali::Toolkit::Text::ControlInterface ControlInterface;
/**
* @brief A Text Controller is used by UI Controls which display text.
@@ -123,10 +123,29 @@ public: // Constructor.
/**
* @brief Create a new instance of a Controller.
*
- * @param[in] controlInterface An interface used to request a text relayout.
* @return A pointer to a new Controller.
*/
- static ControllerPtr New( ControlInterface& controlInterface );
+ static ControllerPtr New();
+
+ /**
+ * @brief Create a new instance of a Controller.
+ *
+ * @param[in] controlInterface The control's interface.
+ *
+ * @return A pointer to a new Controller.
+ */
+ static ControllerPtr New( ControlInterface* controlInterface );
+
+ /**
+ * @brief Create a new instance of a Controller.
+ *
+ * @param[in] controlInterface The control's interface.
+ * @param[in] editableControlInterface The editable control's interface.
+ *
+ * @return A pointer to a new Controller.
+ */
+ static ControllerPtr New( ControlInterface* controlInterface,
+ EditableControlInterface* editableControlInterface );
public: // Configure the text controller.
@@ -1058,7 +1077,18 @@ private: // Private contructors & copy operator.
/**
* @brief Private constructor.
*/
- Controller( ControlInterface& controlInterface );
+ Controller();
+
+ /**
+ * @brief Private constructor.
+ */
+ Controller( ControlInterface* controlInterface );
+
+ /**
+ * @brief Private constructor.
+ */
+ Controller( ControlInterface* controlInterface,
+ EditableControlInterface* editableControlInterface );
// Undefined
Controller( const Controller& handle );
@@ -1085,4 +1115,4 @@ private:
} // namespace Dali
-#endif // __DALI_TOOLKIT_TEXT_CONTROLLER_H__
+#endif // DALI_TOOLKIT_TEXT_CONTROLLER_H
diff --git a/dali-toolkit/internal/text/text-editable-control-interface.h b/dali-toolkit/internal/text/text-editable-control-interface.h
new file mode 100644
index 0000000..e54704c
--- /dev/null
+++ b/dali-toolkit/internal/text/text-editable-control-interface.h
@@ -0,0 +1,80 @@
+#ifndef DALI_TOOLKIT_TEXT_EDITABLE_CONTROL_INTERFACE_H
+#define DALI_TOOLKIT_TEXT_EDITABLE_CONTROL_INTERFACE_H
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include
+
+namespace Dali
+{
+
+class Actor;
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+/**
+ * @brief An interface that the Text::Controller uses to notify about text changes and add decoration to the text control.
+ */
+class EditableControlInterface
+{
+public:
+
+ /**
+ * @brief Virtual destructor.
+ */
+ virtual ~EditableControlInterface()
+ {}
+
+ /**
+ * @brief Called to signal that text has been inserted or deleted.
+ */
+ virtual void TextChanged() = 0;
+
+ /**
+ * @brief Called when the number of characters to be inserted exceeds the maximum limit
+ */
+ virtual void MaxLengthReached() = 0;
+
+ /**
+ * @brief Called to signal that input style has been changed.
+ *
+ * @param[in] inputStyleMask Mask with the bits of the input style that has changed.
+ */
+ virtual void InputStyleChanged( InputStyle::Mask inputStyleMask ) = 0;
+
+ /**
+ * @brief Add a decoration.
+ *
+ * @param[in] decoration The actor displaying a decoration.
+ * @param[in] needsClipping Whether the actor needs clipping.
+ */
+ virtual void AddDecoration( Actor& actor, bool needsClipping ) = 0;
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_EDITABLE_CONTROL_INTERFACE_H