X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fdecorator%2Ftext-decorator.cpp;h=0cb8b4c5eaec03990b1619787ff92a8b43a0c688;hp=58ccff638eef29db094a9dad70613519cd81e6e7;hb=41d36118a13932bcf1db39b780ac437fcda8aa08;hpb=c5660eb8cf963f8fc7b34bebeb9df827af7349ec diff --git a/dali-toolkit/internal/text/decorator/text-decorator.cpp b/dali-toolkit/internal/text/decorator/text-decorator.cpp index 58ccff6..0cb8b4c 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.cpp +++ b/dali-toolkit/internal/text/decorator/text-decorator.cpp @@ -46,7 +46,7 @@ namespace { const char* VERTEX_SHADER = MAKE_SHADER( attribute mediump vec2 aPosition; -uniform mediump mat4 uMvpMatrix; +uniform highp mat4 uMvpMatrix; void main() { @@ -104,36 +104,7 @@ const float CURSOR_WIDTH = 1.f; ///< The cursor's width in pixels. const float POPUP_PADDING = 2.f; ///< Padding space between the highlight box and the text's popup. -/** - * structure to hold coordinates of each quad, which will make up the mesh. - */ -struct QuadCoordinates -{ - /** - * Default constructor - */ - QuadCoordinates() - { - } - - /** - * Constructor - * @param[in] x1 left co-ordinate - * @param[in] y1 top co-ordinate - * @param[in] x2 right co-ordinate - * @param[in] y2 bottom co-ordinate - */ - QuadCoordinates(float x1, float y1, float x2, float y2) - : min(x1, y1), - max(x2, y2) - { - } - - Dali::Vector2 min; ///< top-left (minimum) position of quad - Dali::Vector2 max; ///< bottom-right (maximum) position of quad -}; - -typedef std::vector QuadContainer; +typedef Dali::Vector QuadContainer; /** * @brief Takes a bounding rectangle in the local coordinates of an actor and returns the world coordinates Bounding Box. @@ -193,7 +164,8 @@ struct Decorator::Impl : public ConnectionTracker : color( Dali::Color::BLACK ), position(), cursorHeight( 0.0f ), - lineHeight( 0.0f ) + lineHeight( 0.0f ), + glyphOffset( 0.0f ) { } @@ -201,6 +173,7 @@ struct Decorator::Impl : public ConnectionTracker Vector2 position; float cursorHeight; float lineHeight; + float glyphOffset; }; struct HandleImpl @@ -263,6 +236,9 @@ struct Decorator::Impl : public ConnectionTracker mBoundingBox(), mHighlightColor( LIGHT_BLUE ), mHighlightPosition( Vector2::ZERO ), + mHighlightSize( Vector2::ZERO ), + mControlSize( Vector2::ZERO ), + mHighlightOutlineOffset( 0.f ), mActiveCursor( ACTIVE_CURSOR_NONE ), mCursorBlinkInterval( CURSOR_BLINK_INTERVAL ), mCursorBlinkDuration( 0.0f ), @@ -1172,9 +1148,7 @@ struct Decorator::Impl : public ConnectionTracker { mHighlightActor = Actor::New(); -#ifdef DECORATOR_DEBUG mHighlightActor.SetName( "HighlightActor" ); -#endif mHighlightActor.SetParentOrigin( ParentOrigin::TOP_LEFT ); mHighlightActor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); mHighlightActor.SetColor( mHighlightColor ); @@ -1190,10 +1164,10 @@ struct Decorator::Impl : public ConnectionTracker if ( mHighlightActor ) { // Sets the position of the highlight actor inside the decorator. - mHighlightActor.SetPosition( mHighlightPosition.x, - mHighlightPosition.y ); + mHighlightActor.SetPosition( mHighlightPosition.x + mHighlightOutlineOffset, + mHighlightPosition.y + mHighlightOutlineOffset ); - const unsigned int numberOfQuads = mHighlightQuadList.size(); + const unsigned int numberOfQuads = mHighlightQuadList.Count(); if( 0u != numberOfQuads ) { // Set the size of the highlighted text to the actor. @@ -1213,33 +1187,33 @@ struct Decorator::Impl : public ConnectionTracker unsigned int v = 0u; // Traverse all quads. - for( std::vector::iterator it = mHighlightQuadList.begin(), - endIt = mHighlightQuadList.end(); + for( Vector::ConstIterator it = mHighlightQuadList.Begin(), + endIt = mHighlightQuadList.End(); it != endIt; ++it, v += 4u ) { - QuadCoordinates& quad = *it; + const Vector4& quad = *it; Vector2 vertex; // top-left (v+0) - vertex.x = quad.min.x - offsetX; - vertex.y = quad.min.y - offsetY; + vertex.x = quad.x - offsetX; + vertex.y = quad.y - offsetY; vertices.PushBack( vertex ); // top-right (v+1) - vertex.x = quad.max.x - offsetX; - vertex.y = quad.min.y - offsetY; + vertex.x = quad.z - offsetX; + vertex.y = quad.y - offsetY; vertices.PushBack( vertex ); // bottom-left (v+2) - vertex.x = quad.min.x - offsetX; - vertex.y = quad.max.y - offsetY; + vertex.x = quad.x - offsetX; + vertex.y = quad.w - offsetY; vertices.PushBack( vertex ); // bottom-right (v+3) - vertex.x = quad.max.x - offsetX; - vertex.y = quad.max.y - offsetY; + vertex.x = quad.z - offsetX; + vertex.y = quad.w - offsetY; vertices.PushBack( vertex ); // triangle A (3, 1, 0) @@ -1274,7 +1248,7 @@ struct Decorator::Impl : public ConnectionTracker } } - mHighlightQuadList.clear(); + mHighlightQuadList.Clear(); if( mHighlightRenderer ) { @@ -1932,13 +1906,14 @@ struct Decorator::Impl : public ConnectionTracker PropertyBuffer mQuadVertices; Geometry mQuadGeometry; - QuadContainer mHighlightQuadList; ///< Sub-selections that combine to create the complete selection highlight + QuadContainer mHighlightQuadList; ///< Sub-selections that combine to create the complete selection highlight. Vector4 mBoundingBox; ///< The bounding box in world coords. Vector4 mHighlightColor; ///< Color of the highlight Vector2 mHighlightPosition; ///< The position of the highlight actor. Size mHighlightSize; ///< The size of the highlighted text. Size mControlSize; ///< The control's size. Set by the Relayout. + float mHighlightOutlineOffset; ///< The outline's offset. unsigned int mActiveCursor; unsigned int mCursorBlinkInterval; @@ -2035,6 +2010,18 @@ const Vector2& Decorator::GetPosition( Cursor cursor ) const return mImpl->mCursor[cursor].position; } +void Decorator::SetGlyphOffset( Cursor cursor, float glyphOffset ) +{ + Impl::CursorImpl& cursorImpl = mImpl->mCursor[cursor]; + + cursorImpl.glyphOffset = glyphOffset; +} + +const float Decorator::GetGlyphOffset( Cursor cursor) const +{ + return mImpl->mCursor[cursor].glyphOffset; +} + void Decorator::SetCursorColor( Cursor cursor, const Dali::Vector4& color ) { mImpl->mCursor[cursor].color = color; @@ -2209,21 +2196,28 @@ void Decorator::SetSelectionHandleFlipState( bool indicesSwapped, bool left, boo mImpl->mFlipRightSelectionHandleDirection = right; } -void Decorator::AddHighlight( float x1, float y1, float x2, float y2 ) +void Decorator::AddHighlight( unsigned int index, const Vector4& quad ) { - mImpl->mHighlightQuadList.push_back( QuadCoordinates(x1, y1, x2, y2) ); + *( mImpl->mHighlightQuadList.Begin() + index ) = quad; } -void Decorator::SetHighLightBox( const Vector2& position, const Size& size ) +void Decorator::SetHighLightBox( const Vector2& position, const Size& size, float outlineOffset ) { mImpl->mHighlightPosition = position; mImpl->mHighlightSize = size; + mImpl->mHighlightOutlineOffset = outlineOffset; } void Decorator::ClearHighlights() { - mImpl->mHighlightQuadList.clear(); + mImpl->mHighlightQuadList.Clear(); mImpl->mHighlightPosition = Vector2::ZERO; + mImpl->mHighlightOutlineOffset = 0.f; +} + +void Decorator::ResizeHighlightQuads( unsigned int numberOfQuads ) +{ + mImpl->mHighlightQuadList.Resize( numberOfQuads ); } void Decorator::SetHighlightColor( const Vector4& color ) @@ -2246,6 +2240,11 @@ bool Decorator::IsHighlightActive() const return mImpl->mIsHighlightBoxActive; } +bool Decorator::IsHighlightVisible() const +{ + return ( mImpl->mHighlightActor && mImpl->mHighlightActor.GetParent() ); +} + void Decorator::SetTextDepth( int textDepth ) { mImpl->mTextDepth = textDepth;