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;
mNotifyEndOfScroll( false )
{
mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
- mQuadIndexFormat[ "indices" ] = Property::UNSIGNED_INTEGER;
+ mQuadIndexFormat[ "indices" ] = Property::INTEGER;
mHighlightMaterial = Material::New( Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ) );
}
}
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()