* Fixes the text's popup performance issue.
* Lays out the highlight text behind the text.
* Fixes the highlight color.
Change-Id: I65a1d5509117f33b6e77bcb2fa2517bb1cd42ff3
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
-const Dali::Vector4 LIGHT_BLUE( (0xb2 / 255.0f), (0xeb / 255.0f), (0xf2 / 255.0f), 0.5f ); // The text highlight color.
+const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
const float TO_MILLISECONDS = 1000.f;
return Control::DownCast<TextSelectionPopup, Internal::TextSelectionPopup>(handle);
}
+void TextSelectionPopup::RaiseAbove( Layer target )
+{
+ GetImpl(*this).RaiseAbove( target );
+}
+
TextSelectionPopup::TextSelectionPopup( Internal::TextSelectionPopup& implementation )
: Control(implementation)
{
*/
static TextSelectionPopup DownCast( BaseHandle handle );
+ /**
+ * @brief Raises the toolbar's layer above the given @e target layer.
+ *
+ * @param[in] target The layer to get above of.
+ */
+ void RaiseAbove( Layer target );
+
public: // Not intended for application developers
/**
GetImpl(*this).ResizeDividers( size );
}
+void TextSelectionToolbar::RaiseAbove( Layer target )
+{
+ GetImpl(*this).RaiseAbove( target );
+}
+
TextSelectionToolbar TextSelectionToolbar::DownCast( BaseHandle handle )
{
return Control::DownCast<TextSelectionToolbar, Internal::TextSelectionToolbar>(handle);
void ResizeDividers( Size& size );
/**
+ * @brief Raises the layer above the given @e target layer.
+ *
+ * @param[in] target The layer to get above of.
+ */
+ void RaiseAbove( Layer target );
+
+ /**
* @brief Downcast a handle to TextSelectionToolbar.
*
* If the BaseHandle points is a TextSelectionToolbar the downcast returns a valid handle.
void TextField::RenderText()
{
+ Actor self = Self();
Actor renderableActor;
if( mRenderer )
{
- renderableActor = mRenderer->Render( mController->GetView(), mDepth );
+ renderableActor = mRenderer->Render( mController->GetView(), self.GetHierarchyDepth() );
}
if( renderableActor != mRenderableActor )
mRenderableActor.SetPosition( offset.x, offset.y );
- // Make sure the actor is parented correctly with/without clipping
+ Actor clipRootActor;
if( mClipper )
{
- mClipper->GetRootActor().Add( mRenderableActor );
- }
- else
- {
- Self().Add( mRenderableActor );
+ clipRootActor = mClipper->GetRootActor();
}
for( std::vector<Actor>::const_iterator it = mClippingDecorationActors.begin(),
{
Actor actor = *it;
- if( mClipper )
+ if( clipRootActor )
{
- mClipper->GetRootActor().Add( actor );
+ clipRootActor.Add( actor );
}
else
{
- Self().Add( actor );
+ self.Add( actor );
}
}
mClippingDecorationActors.clear();
+
+ // Make sure the actor is parented correctly with/without clipping
+ if( clipRootActor )
+ {
+ clipRootActor.Add( mRenderableActor );
+ }
+ else
+ {
+ self.Add( mRenderableActor );
+ }
}
}
void TextField::OnStageConnection( int depth )
{
- mDepth = depth;
+ // Call the Control::OnStageConnection() to set the depth of the background.
+ Control::OnStageConnection( depth );
+
+ // Sets the depth to the renderers inside the text's decorator.
+ mDecorator->SetTextDepth( depth );
+
+ // The depth of the text renderer is set in the RenderText() called from OnRelayout().
}
bool TextField::OnTouched( Actor actor, const TouchEvent& event )
: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
mExceedPolicy( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ),
- mDepth( 0 ),
mHasBeenStaged( false )
{
}
int mRenderingBackend;
int mExceedPolicy;
- unsigned int mDepth;
bool mHasBeenStaged:1;
};
void TextLabel::RenderText()
{
+ Actor self = Self();
Actor renderableActor;
if( mRenderer )
{
- renderableActor = mRenderer->Render( mController->GetView(), mDepth );
+ renderableActor = mRenderer->Render( mController->GetView(), self.GetHierarchyDepth() );
}
if( renderableActor != mRenderableActor )
const Vector2& alignmentOffset = mController->GetAlignmentOffset();
renderableActor.SetPosition( alignmentOffset.x, alignmentOffset.y );
- Self().Add( renderableActor );
+ self.Add( renderableActor );
}
mRenderableActor = renderableActor;
}
void TextLabel::OnStageConnection( int depth )
{
- mDepth = depth;
+ // Call the Control::OnStageConnection() to set the depth of the background.
+ Control::OnStageConnection( depth );
+
+ // The depth of the text renderer is set in the RenderText() called from OnRelayout().
}
void TextLabel::TextChanged()
TextLabel::TextLabel()
: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
- mDepth( 0 ),
mHasBeenStaged( false )
{
}
Text::RendererPtr mRenderer;
Actor mRenderableActor;
int mRenderingBackend;
- unsigned int mDepth;
bool mHasBeenStaged:1;
};
return value;
}
+void TextSelectionPopup::RaiseAbove( Layer target )
+{
+ if( mToolbar )
+ {
+ mToolbar.RaiseAbove( target );
+ }
+}
+
void TextSelectionPopup::OnInitialize()
{
CreatePopup();
}
+void TextSelectionPopup::OnStageConnection( int depth )
+{
+ // Call the Control::OnStageConnection() to set the depth of the background.
+ Control::OnStageConnection( depth );
+
+ // TextSelectionToolbar::OnStageConnection() will set the depths of all the popup's components.
+}
+
bool TextSelectionPopup::OnCutButtonPressed( Toolkit::Button button )
{
if( mCallbackInterface )
void TextSelectionPopup::CreateOrderedListOfPopupOptions()
{
mOrderListOfButtons.clear();
+ mOrderListOfButtons.reserve( 8u );
// Create button for each possible option using Option priority
if ( !mCutIconImage )
void TextSelectionPopup::AddOption( const ButtonRequirement& button, bool showDivider, bool showIcons, bool showCaption )
{
-
const std::string& name = button.name;
const std::string& caption = button.caption;
Image iconImage = button.icon;
optionPressedContainer.AddChild( pressedCaptionTextLabel, Toolkit::TableView::CellPosition(( showIcons&showCaption)?1:0, 0 ) );
}
+ int depth = Self().GetHierarchyDepth();
// 3. Create the icons
if ( showIcons )
{
ImageActor pressedIcon = ImageActor::New( iconImage );
ImageActor icon = ImageActor::New( iconImage );
- icon.SetSortModifier( DECORATION_DEPTH_INDEX - 1 );
- pressedIcon.SetSortModifier( DECORATION_DEPTH_INDEX - 1 );
+ icon.SetSortModifier( DECORATION_DEPTH_INDEX + depth - 1 );
+ pressedIcon.SetSortModifier( DECORATION_DEPTH_INDEX + depth - 1 );
icon.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
pressedIcon.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
const Size size( mOptionDividerSize.width, 0.0f ); // Height FILL_TO_PARENT
ImageActor divider = Toolkit::CreateSolidColorActor( Color::WHITE );
+#ifdef DECORATOR_DEBUG
+ divider.SetName("Text's popup divider");
+#endif
divider.SetSize( size );
divider.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
divider.SetColor( mDividerColor );
+ divider.SetSortModifier( DECORATION_DEPTH_INDEX + depth );
mToolbar.AddDivider( divider );
}
}
self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
SetBackgroundImage( NinePatchImage::New( DEFAULT_POPUP_BACKGROUND_IMAGE ) );
- if ( !mToolbar )
+ if( !mToolbar )
{
mToolbar = Toolkit::TextSelectionToolbar::New();
mToolbar.SetParentOrigin( ParentOrigin::CENTER );
*/
static Property::Value GetProperty( BaseObject* object, Property::Index index );
+ /**
+ * @copydoc Toolkit::TextSelectionPopup::RaiseAbove()
+ */
+ void RaiseAbove( Layer target );
+
private: // From Control
/**
*/
virtual void OnInitialize();
+ /**
+ * @copydoc Control::OnStageConnection()
+ */
+ virtual void OnStageConnection( int depth );
+
private: // Implementation
/**
#include <dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
// EXTERNAL INCLUDES
mScrollView.SetRulerX( mRulerX );
}
+void TextSelectionToolbar::OnStageConnection( int depth )
+{
+ // Call the Control::OnStageConnection() to set the depth of the background.
+ Control::OnStageConnection( depth );
+
+ // Traverse the dividers and set the depth.
+ for( unsigned int i = 0; i < mDividerIndexes.Count(); ++i )
+ {
+ Actor divider = mTableOfButtons.GetChildAt( Toolkit::TableView::CellPosition( 0, mDividerIndexes[ i ] ) );
+
+ ImageActor dividerImageActor = ImageActor::DownCast( divider );
+ if( dividerImageActor )
+ {
+ dividerImageActor.SetSortModifier( DECORATION_DEPTH_INDEX + depth );
+ }
+ else
+ {
+ // TODO at the moment divider are image actors.
+ }
+ }
+
+ // Texts are controls, they have their own OnStageConnection() implementation.
+ // Icons are inside a TableView. It has it's own OnStageConnection() implementation.
+}
+
void TextSelectionToolbar::SetPopupMaxSize( const Size& maxSize )
{
mMaxSize = maxSize;
self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
// Create Layer and Stencil. Layer enable's clipping when content exceed maximum defined width.
- Layer stencilLayer = Layer::New();
- stencilLayer.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
- stencilLayer.SetParentOrigin( ParentOrigin::CENTER );
- stencilLayer.SetMaximumSize( mMaxSize );
+ mStencilLayer = Layer::New();
+ mStencilLayer.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
+ mStencilLayer.SetParentOrigin( ParentOrigin::CENTER );
+ mStencilLayer.SetMaximumSize( mMaxSize );
ImageActor stencil = CreateSolidColorActor( Color::RED );
stencil.SetDrawMode( DrawMode::STENCIL );
mTableOfButtons.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
- stencilLayer.Add( stencil );
- stencilLayer.Add( mScrollView );
+ mStencilLayer.Add( stencil );
+ mStencilLayer.Add( mScrollView );
mScrollView.Add( mTableOfButtons );
- self.Add( stencilLayer );
-
- stencilLayer.RaiseToTop();
+ self.Add( mStencilLayer );
}
void TextSelectionToolbar::OnScrollStarted( const Vector2& position )
void TextSelectionToolbar::AddDivider( Actor& divider )
{
AddOption( divider );
- mDividerIndexes.PushBack( mIndexInTable );
+ mDividerIndexes.PushBack( mIndexInTable - 1u );
}
void TextSelectionToolbar::ResizeDividers( Size& size )
RelayoutRequest();
}
+void TextSelectionToolbar::RaiseAbove( Layer target )
+{
+ mStencilLayer.RaiseAbove( target );
+}
+
TextSelectionToolbar::TextSelectionToolbar()
: Control( ControlBehaviour( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ) ),
mMaxSize ( DEFAULT_MAX_SIZE ),
mRulerX.Reset();
}
-
} // namespace Internal
} // namespace Toolkit
static Property::Value GetProperty( BaseObject* object, Property::Index index );
/**
- * @copydoc TextSelectionToolbar::AddOption
+ * @copydoc Toolkit::TextSelectionToolbar::AddOption()
*/
void AddOption( Actor& option );
/**
- * @copydoc TextSelectionToolbar::AddDivider
+ * @copydoc Toolkit::TextSelectionToolbar::AddDivider()
*/
void AddDivider( Actor& divider );
/**
- * @copydoc ResizeDividers
+ * @copydoc Toolkit::TextSelectionToolbar::ResizeDividers()
*/
void ResizeDividers( Size& size );
+ /**
+ * @copydoc Toolkit::TextSelectionToolbar::RaiseAbove()
+ */
+ void RaiseAbove( Layer target );
+
private: // From Control
/**
* @copydoc Control::OnRelayout()
*/
virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+
+ /**
+ * @copydoc Control::OnStageConnection()
+ */
+ virtual void OnStageConnection( int depth );
+
/**
* @brief Set max size of Popup
* @param[in] maxSize Size (Vector2)
private: // Data
- Toolkit::TableView mTableOfButtons; // Actor which holds all the buttons, sensitivity can be set on buttons via this actor
- Toolkit::ScrollView mScrollView; // Provides scrolling of Toolbar when content does not fit.
- RulerPtr mRulerX; // Ruler to clamp horizontal scrolling. Updates on Relayout
- Size mMaxSize; // Max size of the Toolbar
- unsigned int mIndexInTable; // Index in table to add option
- Dali::Vector< unsigned int > mDividerIndexes; // Vector of indexes in the Toolbar that contain dividers.
+ Layer mStencilLayer; ///< The stencil layer
+ Toolkit::TableView mTableOfButtons; ///< Actor which holds all the buttons, sensitivity can be set on buttons via this actor
+ Toolkit::ScrollView mScrollView; ///< Provides scrolling of Toolbar when content does not fit.
+ RulerPtr mRulerX; ///< Ruler to clamp horizontal scrolling. Updates on Relayout
+ Size mMaxSize; ///< Max size of the Toolbar
+ unsigned int mIndexInTable; ///< Index in table to add option
+ Dali::Vector< unsigned int > mDividerIndexes; ///< Vector of indexes in the Toolbar that contain dividers.
};
const Dali::Vector3 DEFAULT_GRAB_HANDLE_RELATIVE_SIZE( 1.25f, 1.5f, 1.0f );
const Dali::Vector3 DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE( 1.25f, 1.5f, 1.0f );
-const Dali::Vector4 LIGHT_BLUE( (0xb2 / 255.0f), (0xeb / 255.0f), (0xf2 / 255.0f), 0.5f ); // The text highlight color.
+const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color. TODO: due some problems, maybe with the blending function in the text clipping, the color is fully opaque.
const Dali::Vector4 HANDLE_COLOR( 0.0f, (183.0f / 255.0f), (229.0f / 255.0f), 1.0f );
const float TO_MILLISECONDS = 1000.f;
const float TO_SECONDS = 1.f / TO_MILLISECONDS;
-const float DISPLAYED_HIGHLIGHT_Z_OFFSET( -0.05f );
-
const unsigned int SCROLL_TICK_INTERVAL = 50u;
const float SCROLL_THRESHOLD = 10.f;
}
else if( grabHandle.actor )
{
- UnparentAndReset( grabHandle.actor );
+ grabHandle.actor.Unparent();
}
// Show or hide the selection handles/highlight
primary.actor.SetVisible( isPrimaryVisible );
secondary.actor.SetVisible( isSecondaryVisible );
- // Shouldn't be needed......
- UnparentAndReset( mHighlightActor );
-
CreateHighlight();
UpdateHighlight();
}
else
{
- UnparentAndReset( primary.actor );
- UnparentAndReset( secondary.actor );
- UnparentAndReset( mHighlightActor );
+ if( primary.actor )
+ {
+ primary.actor.Unparent();
+ }
+ if( secondary.actor )
+ {
+ secondary.actor.Unparent();
+ }
+ if( mHighlightActor )
+ {
+ mHighlightActor.Unparent();
+ }
}
- if ( mActiveCopyPastePopup )
+ if( mActiveCopyPastePopup )
{
- // todo Swap UnparentAndReset for DeterminePositionPopup() if mCopyPastePopup.actor valid Once the issue with the labels disappearing is fixed.
- UnparentAndReset( mCopyPastePopup.actor );
- if ( !mCopyPastePopup.actor )
+ if( !mCopyPastePopup.actor.GetParent() )
{
- mCopyPastePopup.actor = TextSelectionPopup::New( mEnabledPopupButtons, &mTextSelectionPopupCallbackInterface );
-#ifdef DECORATOR_DEBUG
- mCopyPastePopup.actor.SetName("mCopyPastePopup");
-#endif
- mCopyPastePopup.actor.SetAnchorPoint( AnchorPoint::CENTER );
- mCopyPastePopup.actor.OnRelayoutSignal().Connect( this, &Decorator::Impl::PopupRelayoutComplete ); // Position popup after size negotiation
- mActiveLayer.Add ( mCopyPastePopup.actor );
+ mActiveLayer.Add( mCopyPastePopup.actor );
}
+
+ mCopyPastePopup.actor.RaiseAbove( mActiveLayer );
}
else
{
- if ( mCopyPastePopup.actor )
- {
- UnparentAndReset( mCopyPastePopup.actor );
- }
+ if( mCopyPastePopup.actor )
+ {
+ mCopyPastePopup.actor.Unparent();
+ }
}
}
mHandle[ LEFT_SELECTION_HANDLE ].position += scrollOffset;
mHandle[ RIGHT_SELECTION_HANDLE ].position += scrollOffset;
mHighlightPosition += scrollOffset;
+ DeterminePositionPopup();
}
void DeterminePositionPopup()
{
if( mActiveCursor == ACTIVE_CURSOR_NONE )
{
- UnparentAndReset( mPrimaryCursor );
- UnparentAndReset( mSecondaryCursor );
+ if( mPrimaryCursor )
+ {
+ mPrimaryCursor.Unparent();
+ }
+ if( mSecondaryCursor )
+ {
+ mSecondaryCursor.Unparent();
+ }
}
else
{
#ifdef DECORATOR_DEBUG
mPrimaryCursor.SetName( "PrimaryCursorActor" );
#endif
+ }
+
+ if( !mPrimaryCursor.GetParent() )
+ {
mActiveLayer.Add( mPrimaryCursor );
}
}
#ifdef DECORATOR_DEBUG
mSecondaryCursor.SetName( "SecondaryCursorActor" );
#endif
+ }
+
+ if( !mSecondaryCursor.GetParent() )
+ {
mActiveLayer.Add( mSecondaryCursor );
}
}
else
{
- UnparentAndReset( mSecondaryCursor );
+ if( mSecondaryCursor )
+ {
+ mSecondaryCursor.Unparent();
+ }
}
}
}
mActiveLayer.Add( grabHandle.actor );
}
+
+ if( !grabHandle.actor.GetParent() )
+ {
+ mActiveLayer.Add( grabHandle.actor );
+ }
}
void CreateSelectionHandles()
primary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleOneTouched );
primary.actor.Add( primary.grabArea );
+ }
+
+ if( !primary.actor.GetParent() )
+ {
mActiveLayer.Add( primary.actor );
}
secondary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleTwoTouched );
secondary.actor.Add( secondary.grabArea );
+ }
+
+ if( !secondary.actor.GetParent() )
+ {
mActiveLayer.Add( secondary.actor );
}
}
void CreateHighlight()
{
- if ( !mHighlightActor )
+ if( !mHighlightActor )
{
mHighlightActor = Actor::New();
mHighlightActor.SetName( "HighlightActor" );
#endif
mHighlightActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mHighlightActor.SetPosition( 0.0f, 0.0f, DISPLAYED_HIGHLIGHT_Z_OFFSET );
mHighlightActor.SetSize( 1.0f, 1.0f );
mHighlightActor.SetColor( mHighlightColor );
mHighlightActor.SetColorMode( USE_OWN_COLOR );
-
- // Add the highlight box telling the controller it needs clipping.
- mController.AddDecoration( mHighlightActor, true );
}
+
+ // Add the highlight box telling the controller it needs clipping.
+ mController.AddDecoration( mHighlightActor, true );
}
void UpdateHighlight()
{
-
- if ( mHighlightActor && !mHighlightQuadList.empty() )
+ if ( mHighlightActor )
{
- Vector< Vector2 > vertices;
- Vector< unsigned int> indices;
- Vector2 vertex;
+ if( !mHighlightQuadList.empty() )
+ {
+ Vector< Vector2 > vertices;
+ Vector< unsigned int> indices;
+ Vector2 vertex;
- std::vector<QuadCoordinates>::iterator iter = mHighlightQuadList.begin();
- std::vector<QuadCoordinates>::iterator endIter = mHighlightQuadList.end();
+ std::vector<QuadCoordinates>::iterator iter = mHighlightQuadList.begin();
+ std::vector<QuadCoordinates>::iterator endIter = mHighlightQuadList.end();
- for(std::size_t v = 0; iter != endIter; ++iter,v+=4 )
- {
+ for( std::size_t v = 0; iter != endIter; ++iter,v+=4 )
+ {
+
+ QuadCoordinates& quad = *iter;
+
+ // top-left (v+0)
+ vertex.x = quad.min.x;
+ vertex.y = quad.min.y;
+ vertices.PushBack( vertex );
+
+ // top-right (v+1)
+ vertex.x = quad.max.x;
+ vertex.y = quad.min.y;
+ vertices.PushBack( vertex );
+
+ // bottom-left (v+2)
+ vertex.x = quad.min.x;
+ vertex.y = quad.max.y;
+ vertices.PushBack( vertex );
+
+ // bottom-right (v+3)
+ vertex.x = quad.max.x;
+ vertex.y = quad.max.y;
+ vertices.PushBack( vertex );
+
+ // triangle A (3, 1, 0)
+ indices.PushBack( v + 3 );
+ indices.PushBack( v + 1 );
+ indices.PushBack( v );
+
+ // triangle B (0, 2, 3)
+ indices.PushBack( v );
+ indices.PushBack( v + 2 );
+ indices.PushBack( v + 3 );
+ }
+
+ if( mQuadVertices )
+ {
+ mQuadVertices.SetSize( vertices.Size() );
+ }
+ else
+ {
+ mQuadVertices = PropertyBuffer::New( mQuadVertexFormat, vertices.Size() );
+ }
+
+ if( mQuadIndices )
+ {
+ mQuadIndices.SetSize( indices.Size() );
+ }
+ else
+ {
+ mQuadIndices = PropertyBuffer::New( mQuadIndexFormat, indices.Size() );
+ }
+
+ mQuadVertices.SetData( &vertices[ 0 ] );
+ mQuadIndices.SetData( &indices[ 0 ] );
+
+ mQuadGeometry = Geometry::New();
+ mQuadGeometry.AddVertexBuffer( mQuadVertices );
+ mQuadGeometry.SetIndexBuffer( mQuadIndices );
+
+ if( mHighlightRenderer )
+ {
+ mHighlightRenderer.SetGeometry( mQuadGeometry );
+ }
+ else
+ {
+ mHighlightRenderer = Dali::Renderer::New( mQuadGeometry, mHighlightMaterial );
+ mHighlightActor.AddRenderer( mHighlightRenderer );
+ }
- QuadCoordinates& quad = *iter;
-
- // top-left (v+0)
- vertex.x = quad.min.x;
- vertex.y = quad.min.y;
- vertices.PushBack( vertex );
-
- // top-right (v+1)
- vertex.x = quad.max.x;
- vertex.y = quad.min.y;
- vertices.PushBack( vertex );
-
- // bottom-left (v+2)
- vertex.x = quad.min.x;
- vertex.y = quad.max.y;
- vertices.PushBack( vertex );
-
- // bottom-right (v+3)
- vertex.x = quad.max.x;
- vertex.y = quad.max.y;
- vertices.PushBack( vertex );
-
- // triangle A (3, 1, 0)
- indices.PushBack( v + 3 );
- indices.PushBack( v + 1 );
- indices.PushBack( v );
-
- // triangle B (0, 2, 3)
- indices.PushBack( v );
- indices.PushBack( v + 2 );
- indices.PushBack( v + 3 );
+ mHighlightActor.SetPosition( mHighlightPosition.x,
+ mHighlightPosition.y );
}
- PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat, vertices.Size() );
- PropertyBuffer quadIndices = PropertyBuffer::New( mQuadIndexFormat, indices.Size() );
-
- quadVertices.SetData( &vertices[ 0 ] );
- quadIndices.SetData( &indices[ 0 ] );
-
- Geometry quadGeometry = Geometry::New();
- quadGeometry.AddVertexBuffer( quadVertices );
- quadGeometry.SetIndexBuffer( quadIndices );
-
- // if ( mHighlightRenderer )
- // {
- // mHighlightRenderer.SetGeometry( quadGeometry );
- // }
- // else
- // {
- mHighlightRenderer = Dali::Renderer::New( quadGeometry, mHighlightMaterial );
- mHighlightRenderer.SetDepthIndex( DECORATION_DEPTH_INDEX - 1 );
- // }
- mHighlightActor.AddRenderer( mHighlightRenderer );
+ mHighlightRenderer.SetDepthIndex( mTextDepth - 2u ); // text is rendered at mTextDepth and text's shadow at mTextDepth -1u.
}
}
CursorImpl mCursor[CURSOR_COUNT];
HandleImpl mHandle[HANDLE_TYPE_COUNT];
+
+ PropertyBuffer mQuadVertices;
+ PropertyBuffer mQuadIndices;
+ Geometry mQuadGeometry;
QuadContainer mHighlightQuadList; ///< Sub-selections that combine to create the complete selection highlight
Rect<int> mBoundingBox;
float mScrollThreshold; ///< Defines a square area inside the control, close to the edge. A cursor entering this area will trigger scroll events.
float mScrollSpeed; ///< The scroll speed in pixels per second.
float mScrollDistance; ///< Distance the text scrolls during a scroll interval.
+ int mTextDepth; ///< The depth used to render the text.
bool mActiveCopyPastePopup : 1;
bool mCursorBlinkStatus : 1; ///< Flag to switch between blink on and blink off.
return mImpl->mHighlightColor;
}
+void Decorator::SetTextDepth( int textDepth )
+{
+ mImpl->mTextDepth = textDepth;
+}
+
void Decorator::SetPopupActive( bool active )
{
mImpl->mActiveCopyPastePopup = active;
void Decorator::SetEnabledPopupButtons( TextSelectionPopup::Buttons& enabledButtonsBitMask )
{
mImpl->mEnabledPopupButtons = enabledButtonsBitMask;
+
+ UnparentAndReset( mImpl->mCopyPastePopup.actor );
+ mImpl->mCopyPastePopup.actor = TextSelectionPopup::New( mImpl->mEnabledPopupButtons,
+ &mImpl->mTextSelectionPopupCallbackInterface );
+#ifdef DECORATOR_DEBUG
+ mImpl->mCopyPastePopup.actor.SetName("mCopyPastePopup");
+#endif
+ mImpl->mCopyPastePopup.actor.SetAnchorPoint( AnchorPoint::CENTER );
+ mImpl->mCopyPastePopup.actor.OnRelayoutSignal().Connect( mImpl, &Decorator::Impl::PopupRelayoutComplete ); // Position popup after size negotiation
+
+ if( mImpl->mActiveLayer )
+ {
+ mImpl->mActiveLayer.Add( mImpl->mCopyPastePopup.actor );
+ }
}
TextSelectionPopup::Buttons& Decorator::GetEnabledPopupButtons()
const Vector4& GetHighlightColor() const;
/**
+ * @brief Sets into the decorator the depth used to render the text.
+ *
+ * @param[in] depth The text's depth.
+ */
+ void SetTextDepth( int textDepth );
+
+ /**
* @brief Set the Selection Popup to show or hide via the active flaf
* @param[in] active true to show, false to hide
*/
bool underlineEnabled,
const Vector4& underlineColor,
float underlineHeight,
- unsigned int depth )
+ int depth )
{
AtlasManager::AtlasSlot slot;
std::vector< MeshRecord > meshContainer;
Vector< Extent > extents;
TextCacheEntry textCacheEntry;
- mDepth = static_cast< int >( depth );
+ mDepth = depth;
float currentUnderlinePosition = ZERO;
float currentUnderlineThickness = underlineHeight;
Material material = mGlyphManager.GetMaterial( meshRecord.mAtlasId );
Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
- renderer.SetDepthIndex( mDepth );
+ renderer.SetDepthIndex( CONTENT_DEPTH_INDEX + mDepth );
Actor actor = Actor::New();
+#if defined(DEBUG_ENABLED)
+ actor.SetName( "Text renderable actor" );
+#endif
actor.AddRenderer( renderer );
actor.SetSize( 1.0f, 1.0f );
actor.SetColor( meshRecord.mColor );
Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
// Ensure shadow is behind the text...
- renderer.SetDepthIndex( mDepth + CONTENT_DEPTH_INDEX - 1 );
+ renderer.SetDepthIndex( CONTENT_DEPTH_INDEX + mDepth - 1 );
Actor actor = Actor::New();
actor.AddRenderer( renderer );
actor.SetSize( 1.0f, 1.0f );
return Text::RendererPtr( new AtlasRenderer() );
}
-Actor AtlasRenderer::Render( Text::ViewInterface& view, unsigned int depth )
+Actor AtlasRenderer::Render( Text::ViewInterface& view, int depth )
{
UnparentAndReset( mImpl->mActor );
* @param[in] depth The depth in the tree of the parent.
* @return The Renderable actor used to position the text.
*/
- virtual Actor Render( ViewInterface& view, unsigned int depth );
+ virtual Actor Render( ViewInterface& view, int depth );
protected:
* @param[in] depth The depth in the tree of the parent.
* @return The Renderable actor used to position the text.
*/
- virtual Actor Render( ViewInterface& view, unsigned int depth ) = 0;
+ virtual Actor Render( ViewInterface& view, int depth ) = 0;
protected: