// INTERNAL INCLUDES
#include <dali-toolkit/public-api/text/rendering-backend.h>
+#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/text/rendering/text-backend.h>
#include <dali-toolkit/internal/text/text-effects-style.h>
#include <dali-toolkit/internal/text/text-font-style.h>
{
Actor self = Self();
- mController = Text::Controller::New( *this );
+ mController = Text::Controller::New( this, this );
mDecorator = Text::Decorator::New( *mController,
*mController );
self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
self.OnStageSignal().Connect( this, &TextEditor::OnStageConnect );
+
+ // Creates an extra control to be used as stencil buffer.
+ mStencil = Control::New();
+ mStencil.SetAnchorPoint( AnchorPoint::CENTER );
+ mStencil.SetParentOrigin( ParentOrigin::CENTER );
+
+ // Creates a background visual. Even if the color is transparent it updates the stencil.
+ Property::Map backGroundMap;
+ backGroundMap[Toolkit::Visual::Property::TYPE] = Visual::COLOR;
+ backGroundMap[ColorVisual::Property::MIX_COLOR] = Color::TRANSPARENT;
+
+ mStencil.SetProperty( Toolkit::Control::Property::BACKGROUND, backGroundMap );
+
+ // Enable the clipping property.
+ mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+ mStencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+
+ self.Add( mStencil );
}
void TextEditor::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
}
- EnableClipping( true, size );
RenderText( updateTextType );
}
void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType )
{
- Actor self = Self();
Actor renderableActor;
if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
{
if( mRenderer )
{
- renderableActor = mRenderer->Render( mController->GetView(), DepthIndex::TEXT );
+ renderableActor = mRenderer->Render( mController->GetView(),
+ mAlignmentOffset,
+ DepthIndex::TEXT );
}
if( renderableActor != mRenderableActor )
{
const Vector2& scrollOffset = mController->GetScrollPosition();
- mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
+ mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset, scrollOffset.y );
- Actor clipRootActor;
- if( mClipper )
- {
- clipRootActor = mClipper->GetRootActor();
- }
+ // Make sure the actors are parented correctly with/without clipping
+ Actor self = mStencil ? mStencil : Self();
for( std::vector<Actor>::const_iterator it = mClippingDecorationActors.begin(),
endIt = mClippingDecorationActors.end();
it != endIt;
++it )
{
- Actor actor = *it;
-
- if( clipRootActor )
- {
- clipRootActor.Add( actor );
- }
- else
- {
- self.Add( actor );
- }
+ self.Add( *it );
}
mClippingDecorationActors.clear();
- // Make sure the actor is parented correctly with/without clipping
- if( clipRootActor )
- {
- clipRootActor.Add( mRenderableActor );
- }
- else
- {
- self.Add( mRenderableActor );
- }
+ self.Add( mRenderableActor );
}
}
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();
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() );
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 )
}
}
-void TextEditor::EnableClipping( bool clipping, 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 )
- {
- if( !mClipper )
- {
- Actor self = Self();
-
- 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();
- }
-}
-
void TextEditor::OnClipboardTextSelected( ClipboardEventNotifier& clipboard )
{
mController->PasteClipboardItemEvent();
TextEditor::TextEditor()
: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
mIdleCallback( NULL ),
+ mAlignmentOffset( 0.f ),
mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
mHasBeenStaged( false )
{
TextEditor::~TextEditor()
{
- mClipper.Reset();
+ UnparentAndReset( mStencil );
if( ( NULL != mIdleCallback ) && Adaptor::IsAvailable() )
{