void TextHighlight::UpdateHighlight( TextHighlight::HighlightInfo& newHighlightInfo )
{
-// Construct a Mesh with a texture to be used as the highlight 'box' for selected text
-//
-// Example scenarios where mesh is made from 3, 1, 2, 2 ,3 or 3 quads.
-//
-// [ TOP ] [ TOP ] [TOP ] [ TOP ] [ TOP ] [ TOP ]
-// [ MIDDLE ] [BOTTOM] [BOTTOM] [ MIDDLE ] [ MIDDLE ]
-// [ BOTTOM] [ MIDDLE ] [ MIDDLE ]
-// [BOTTOM] [ MIDDLE ]
-// [BOTTOM]
-//
-// Each quad is created as 2 triangles.
-// Middle is just 1 quad regardless of its size.
-//
-// (0,0) (0,0)
-// 0* *2 0* *2
-// TOP TOP
-// 3* *1 3* *1
-// 4* *1 4* *6
-// MIDDLE BOTTOM
-// 6* *5 7* *5
-// 6* *8
-// BOTTOM
-// 9* *7
-//
-
- // vertex and triangle buffers should always be present if MeshActor is alive.
- //HighlightInfo newHighlightInfo = CalculateHighlightInfo( handlePositionStart, handlePositionEnd );
- MeshData::VertexContainer vertices;
- Dali::MeshData::FaceIndices faceIndices;
-
- if( !newHighlightInfo.mQuadList.empty() )
- {
- std::vector<QuadCoordinates>::iterator iter = newHighlightInfo.mQuadList.begin();
- std::vector<QuadCoordinates>::iterator endIter = newHighlightInfo.mQuadList.end();
-
- // vertex position defaults to (0 0 0)
- MeshData::Vertex vertex;
- // set normal for all vertices as (0 0 1) pointing outward from TextInput Actor.
- vertex.nZ = 1.0f;
-
- for(std::size_t v = 0; iter != endIter; ++iter,v+=4 )
- {
- // Add each quad geometry (a sub-selection) to the mesh data.
-
- // 0-----1
- // |\ |
- // | \ A |
- // | \ |
- // | B \ |
- // | \|
- // 2-----3
-
- QuadCoordinates& quad = *iter;
- // top-left (v+0)
- vertex.x = quad.min.x;
- vertex.y = quad.min.y;
- vertices.push_back( vertex );
-
- // top-right (v+1)
- vertex.x = quad.max.x;
- vertex.y = quad.min.y;
- vertices.push_back( vertex );
-
- // bottom-left (v+2)
- vertex.x = quad.min.x;
- vertex.y = quad.max.y;
- vertices.push_back( vertex );
-
- // bottom-right (v+3)
- vertex.x = quad.max.x;
- vertex.y = quad.max.y;
- vertices.push_back( vertex );
-
- // triangle A (3, 1, 0)
- faceIndices.push_back( v + 3 );
- faceIndices.push_back( v + 1 );
- faceIndices.push_back( v );
-
- // triangle B (0, 2, 3)
- faceIndices.push_back( v );
- faceIndices.push_back( v + 2 );
- faceIndices.push_back( v + 3 );
- }
-
- mMeshData.SetVertices( vertices );
- mMeshData.SetFaceIndices( faceIndices );
-
- mHighlightMesh.UpdateMeshData(mMeshData);
- }
}
-Mesh TextHighlight::CreateHighLightMesh()
+void TextHighlight::CreateHighLightMesh()
{
- mMeshData = MeshData( );
- mMeshData.SetHasNormals( true );
-
- mCustomMaterial = Material::New("CustomMaterial");
- mCustomMaterial.SetDiffuseColor( LIGHTBLUE );
-
- mMeshData.SetMaterial( mCustomMaterial );
-
- mHighlightMesh = Mesh::New( mMeshData );
-
- return mHighlightMesh;
}
void TextHighlight::HighlightInfo::AddQuad( float x1, float y1, float x2, float y2 )