std::string description;
std::string input;
std::size_t position;
- std::size_t lineIndex;
+ std::size_t paragraphIndex;
std::size_t wordIndex;
std::size_t characterIndex;
};
/**
- * Gets the line, word, and character indices for a given text and a given position and checks the results with the given indices.
+ * Gets the paragraph, word, and character indices for a given text and a given position and checks the results with the given indices.
*
* If the test fails it prints a short description and the line where this function was called.
*
* @param description Short description of the experiment.
* @param input The input text.
* @param position Global position of the character. i.e in a text with with 1000 characters, position could be any value from 0 to 1000.
- * @param resultLineIndex Index to the line where the character is located.
- * @param resultWordIndex Index to the word within the line where the character is located.
+ * @param resultParagraphIndex Index to the paragraph where the character is located.
+ * @param resultWordIndex Index to the word within the paragraph where the character is located.
* @param resultCharacterIndex Index to the character within the word where the character is located.
* @param location Where this function has been called.
*
bool TestGetIndicesFromGlobalCharacterIndex( const std::string& description,
const std::string& input,
const std::size_t position,
- const std::size_t resultLineIndex,
+ const std::size_t resultParagraphIndex,
const std::size_t resultWordIndex,
const std::size_t resultCharacterIndex,
const char* location )
inputLayout,
indices );
- if( indices.mLineIndex != resultLineIndex )
+ if( indices.mParagraphIndex != resultParagraphIndex )
{
- tet_printf( "Fail. different line index. %s", location );
+ tet_printf( "Fail. different paragraph index. %s", location );
return false;
}
if( indices.mWordIndex != resultWordIndex )
3
},
{
- std::string( "Test position 33. (end of the second word of the second line)" ),
+ std::string( "Test position 33. (end of the second word of the second paragraph)" ),
std::string( "text te<font size='30'>xt text text text\n</font>"
"text text טק<font size='30'>סט טקסט </font>text\n"
"text te<font size='30'>xt text text</font> text\n"
{
const GetIndicesFromGlobalCharacterIndexTest& test = getIndicesFromGlobalCharacterIndexTests[index];
- if( !TestGetIndicesFromGlobalCharacterIndex( test.description, test.input, test.position, test.lineIndex, test.wordIndex, test.characterIndex, TEST_LOCATION ) )
+ if( !TestGetIndicesFromGlobalCharacterIndex( test.description, test.input, test.position, test.paragraphIndex, test.wordIndex, test.characterIndex, TEST_LOCATION ) )
{
tet_result( TET_FAIL );
}
tet_infoline("UtcDaliTextViewDefaultConstructorDestructor : ");
TextViewProcessor::TextInfoIndices indices;
- DALI_TEST_EQUALS( indices.mLineIndex, 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( indices.mParagraphIndex, 0u, TEST_LOCATION );
DALI_TEST_EQUALS( indices.mWordIndex, 0u, TEST_LOCATION );
DALI_TEST_EQUALS( indices.mCharacterIndex, 0u, TEST_LOCATION );
DALI_TEST_EQUALS( wordLayoutInfo.mType, TextViewProcessor::NoSeparator, TEST_LOCATION );
DALI_TEST_EQUALS( wordLayoutInfo.mCharactersLayoutInfo.size(), 0u, TEST_LOCATION );
- TextViewProcessor::LineLayoutInfo lineLayoutInfo;
- DALI_TEST_EQUALS( lineLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo.mAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo.mLineHeightOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo.mWordsLayoutInfo.size(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo.mNumberOfCharacters, 0u, TEST_LOCATION );
+ TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo;
+ DALI_TEST_EQUALS( paragraphLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( paragraphLayoutInfo.mAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( paragraphLayoutInfo.mLineHeightOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( paragraphLayoutInfo.mWordsLayoutInfo.size(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( paragraphLayoutInfo.mNumberOfCharacters, 0u, TEST_LOCATION );
TextViewProcessor::TextLayoutInfo textLayoutInfo;
DALI_TEST_EQUALS( textLayoutInfo.mWholeTextSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( textLayoutInfo.mMaxWordWidth, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mLinesLayoutInfo.size(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( textLayoutInfo.mParagraphsLayoutInfo.size(), 0u, TEST_LOCATION );
DALI_TEST_EQUALS( textLayoutInfo.mNumberOfCharacters, 0u, TEST_LOCATION );
DALI_TEST_EQUALS( textLayoutInfo.mMaxItalicsOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( textLayoutInfo.mEllipsizeLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
TextViewProcessor::WordLayoutInfo wordLayoutInfo;
wordLayoutInfo.mSize = Vector2( 1.f, 1.f );
wordLayoutInfo.mAscender = 1.f;
- wordLayoutInfo.mType = TextViewProcessor::LineSeparator;
+ wordLayoutInfo.mType = TextViewProcessor::ParagraphSeparator;
TextViewProcessor::WordLayoutInfo wordLayoutInfo1;
wordLayoutInfo1 = wordLayoutInfo;
DALI_TEST_EQUALS( wordLayoutInfo1.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( wordLayoutInfo1.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo1.mType, TextViewProcessor::LineSeparator, TEST_LOCATION );
+ DALI_TEST_EQUALS( wordLayoutInfo1.mType, TextViewProcessor::ParagraphSeparator, TEST_LOCATION );
TextViewProcessor::WordLayoutInfo wordLayoutInfo2( wordLayoutInfo );
DALI_TEST_EQUALS( wordLayoutInfo2.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( wordLayoutInfo2.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo2.mType, TextViewProcessor::LineSeparator, TEST_LOCATION );
+ DALI_TEST_EQUALS( wordLayoutInfo2.mType, TextViewProcessor::ParagraphSeparator, TEST_LOCATION );
- TextViewProcessor::LineLayoutInfo lineLayoutInfo;
- lineLayoutInfo.mSize = Vector2( 1.f, 1.f );
- lineLayoutInfo.mAscender = 1.f;
- lineLayoutInfo.mLineHeightOffset = 1.f;
- lineLayoutInfo.mNumberOfCharacters = 1u;
+ TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo;
+ paragraphLayoutInfo.mSize = Vector2( 1.f, 1.f );
+ paragraphLayoutInfo.mAscender = 1.f;
+ paragraphLayoutInfo.mLineHeightOffset = 1.f;
+ paragraphLayoutInfo.mNumberOfCharacters = 1u;
- TextViewProcessor::LineLayoutInfo lineLayoutInfo1;
- lineLayoutInfo1 = lineLayoutInfo;
+ TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo1;
+ paragraphLayoutInfo1 = paragraphLayoutInfo;
- DALI_TEST_EQUALS( lineLayoutInfo1.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo1.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo1.mLineHeightOffset, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo1.mNumberOfCharacters, 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( paragraphLayoutInfo1.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( paragraphLayoutInfo1.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( paragraphLayoutInfo1.mLineHeightOffset, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( paragraphLayoutInfo1.mNumberOfCharacters, 1u, TEST_LOCATION );
- TextViewProcessor::LineLayoutInfo lineLayoutInfo2( lineLayoutInfo );
+ TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo2( paragraphLayoutInfo );
- DALI_TEST_EQUALS( lineLayoutInfo2.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo2.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo2.mLineHeightOffset, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo2.mNumberOfCharacters, 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( paragraphLayoutInfo2.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( paragraphLayoutInfo2.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( paragraphLayoutInfo2.mLineHeightOffset, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( paragraphLayoutInfo2.mNumberOfCharacters, 1u, TEST_LOCATION );
TextViewProcessor::TextLayoutInfo textLayoutInfo;
textLayoutInfo.mWholeTextSize = Vector2( 1.f, 1.f );
//////////////////////////////////////////////////////////////////
-struct SplitInLinesTest
+struct SplitInParagraphsTest
{
std::string inputText;
- std::size_t resultNumberOfLines;
+ std::size_t resultNumberOfParagraphs;
};
-bool TestSplitInLines( const SplitInLinesTest& test, const char* location )
+bool TestSplitInParagraphs( const SplitInParagraphsTest& test, const char* location )
{
// Creates a styled text with the markup or plain string.
MarkupProcessor::StyledTextArray styledText;
MarkupProcessor::GetStyledTextArray( test.inputText, styledText, true );
- std::vector<MarkupProcessor::StyledTextArray> lines;
+ std::vector<MarkupProcessor::StyledTextArray> paragraphs;
- TextProcessor::SplitInLines( styledText,
- lines );
+ TextProcessor::SplitInParagraphs( styledText,
+ paragraphs );
- if( lines.size() != test.resultNumberOfLines )
+ if( paragraphs.size() != test.resultNumberOfParagraphs )
{
tet_printf( "Fail. %s", location );
- tet_printf( "Different number of lines, result %d, expected result %d", lines.size(), test.resultNumberOfLines );
+ tet_printf( "Different number of paragraphs, result %d, expected result %d", paragraphs.size(), test.resultNumberOfParagraphs );
return false;
}
} // namespace
-int UtcDaliTextViewSplitInLines(void)
+int UtcDaliTextViewSplitInParagraphs(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliTextViewSplitInLines : ");
+ tet_infoline("UtcDaliTextViewSplitInParagraphs : ");
- struct SplitInLinesTest splitInLinesTest[] =
+ struct SplitInParagraphsTest splitInParagraphsTest[] =
{
{
std::string( "Hello world\nhello world." ),
for( std::size_t index = 0; index < numberOfTests; ++index )
{
- const SplitInLinesTest& test = splitInLinesTest[index];
+ const SplitInParagraphsTest& test = splitInParagraphsTest[index];
- if( !TestSplitInLines( test, TEST_LOCATION ) )
+ if( !TestSplitInParagraphs( test, TEST_LOCATION ) )
{
tet_result( TET_FAIL );
}
//////////////////////////////////////////////////////////////////
-struct CalculateSubLineLayoutTest
+struct CalculateLineLayoutTest
{
std::string description;
- std::string inputLine;
+ std::string inputParagraph;
float parentWidth;
std::size_t wordIndex;
std::size_t characterIndex;
- std::size_t characterLineIndex;
+ std::size_t characterParagraphIndex;
TextViewRelayout::HorizontalWrapType splitPolicy;
float shrinkFactor;
float resultMaxAscender;
};
-bool TestCalculateSubLineLayout( const CalculateSubLineLayoutTest& test, const char* location )
+bool TestCalculateLineLayout( const CalculateLineLayoutTest& test, const char* location )
{
tet_printf( "%s", test.description.c_str() );
// Create styled text.
MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( test.inputLine, inputStyledText, true );
+ MarkupProcessor::GetStyledTextArray( test.inputParagraph, inputStyledText, true );
// Create styled text layout info.
Toolkit::Internal::TextView::RelayoutData relayoutData;
// Creaqte indices.
TextViewProcessor::TextInfoIndices indices( 0u, test.wordIndex, test.characterIndex );
- // Get the input line.
- TextViewProcessor::LineLayoutInfo inputLineLayout;
+ // Get the input paragraph.
+ TextViewProcessor::ParagraphLayoutInfo inputParagraphLayout;
- if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
+ if( !relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.empty() )
{
- inputLineLayout = *relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin();
+ inputParagraphLayout = *relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin();
}
// Result struct.
- TextViewRelayout::SubLineLayoutInfo resultLayoutInfo;
+ TextViewRelayout::LineLayoutInfo resultLayoutInfo;
- CalculateSubLineLayout( test.parentWidth,
- indices,
- inputLineLayout,
- test.splitPolicy,
- test.shrinkFactor,
- resultLayoutInfo );
+ CalculateLineLayout( test.parentWidth,
+ indices,
+ inputParagraphLayout,
+ test.splitPolicy,
+ test.shrinkFactor,
+ resultLayoutInfo );
// Check results.
if( !TestEqual( test.resultLineLength, resultLayoutInfo.mLineLength ) )
TextViewRelayout::RelayoutParameters relayoutParameters;
DALI_TEST_EQUALS( relayoutParameters.mPositionOffset, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mLineSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( relayoutParameters.mParagraphSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( relayoutParameters.mWordSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( relayoutParameters.mCharacterSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mIndices.mLineIndex, 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( relayoutParameters.mIndices.mParagraphIndex, 0u, TEST_LOCATION );
DALI_TEST_EQUALS( relayoutParameters.mIndices.mWordIndex, 0u, TEST_LOCATION );
DALI_TEST_EQUALS( relayoutParameters.mIndices.mCharacterIndex, 0u, TEST_LOCATION );
DALI_TEST_EQUALS( relayoutParameters.mCharacterGlobalIndex, 0u, TEST_LOCATION );
DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacter );
DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacterOfWord );
DALI_TEST_CHECK( !relayoutParameters.mIsNewLine );
- DALI_TEST_CHECK( !relayoutParameters.mIsNewLineCharacter );
+ DALI_TEST_CHECK( !relayoutParameters.mIsNewParagraphCharacter );
DALI_TEST_CHECK( !relayoutParameters.mIsWhiteSpace );
DALI_TEST_CHECK( !relayoutParameters.mIsVisible );
DALI_TEST_EQUALS( textUnderlineStatus.mLineGlobalIndex, 0u, TEST_LOCATION );
DALI_TEST_CHECK( !textUnderlineStatus.mCurrentUnderlineStatus );
- // Test SubLineLayoutInfo defaults
- TextViewRelayout::SubLineLayoutInfo subLineLayoutInfo;
+ // Test LineLayoutInfo defaults
+ TextViewRelayout::LineLayoutInfo lineLayoutInfo;
- DALI_TEST_EQUALS( subLineLayoutInfo.mLineLength, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( subLineLayoutInfo.mMaxCharHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( subLineLayoutInfo.mMaxAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( lineLayoutInfo.mLineLength, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( lineLayoutInfo.mMaxCharHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( lineLayoutInfo.mMaxAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
END_TEST;
}
-int UtcDaliTextViewCalculateSubLineLayout(void)
+int UtcDaliTextViewCalculateLineLayout(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliTextViewCalculateSubLineLayout : ");
+ tet_infoline("UtcDaliTextViewCalculateLineLayout : ");
- struct CalculateSubLineLayoutTest calculateSubLineLayoutTest[] =
+ struct CalculateLineLayoutTest calculateLineLayoutTest[] =
{
//WrapByCharacter
{
- "The line is wraped by character. All characters have the same size.",
- "Hello world", // input line
+ "The paragraph is wraped by character. All characters have the same size.",
+ "Hello world", // input paragraph
100.f, // parent width
0, // indices
0,
10.242188f // max ascender
},
{
- "The line is wraped by character. There are characters with different sizes.",
- "Hello <font size='14'>world</font>", // input line
+ "The paragraph is wraped by character. There are characters with different sizes.",
+ "Hello <font size='14'>world</font>", // input paragraph
100.f, // parent width
0, // indices
0,
11.949220f // max ascender
},
{
- "The line is wraped by character. There are characters with different sizes. It calculates the layout for the second line.",
- "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input line
+ "The paragraph is wraped by character. There are characters with different sizes. It calculates the layout for the second line.",
+ "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input paragraph
100.f, // parent width
2, // indices. The third character of the third word starts in a new line.
2,
10.242188f // max ascender
},
{
- "The line is wraped by character. There are characters with different sizes. It calculates the layout for the third line.",
- "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input line
+ "The paragraph is wraped by character. There are characters with different sizes. It calculates the layout for the third line.",
+ "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input paragraph
100.f, // parent width
4, // indices. The fifth character of the fifth word starts in a new line.
4,
//WrapByWord
{
- "The line is wraped by word. All characters have the same size.",
- "Hello world", // input line
+ "The paragraph is wraped by word. All characters have the same size.",
+ "Hello world", // input paragraph
100.f, // parent width
0, // indices. It shouldn't use the index character so 9999999 shouldn't make it crash.
9999999,
10.242188f // max ascender
},
{
- "The line is wraped by word. There are characters with different sizes.",
- "Hell<font size='14'>o</font> world", // input line
+ "The paragraph is wraped by word. There are characters with different sizes.",
+ "Hell<font size='14'>o</font> world", // input paragraph
100.f, // parent width
0, // indices.
0,
11.949220f // max ascender
},
{
- "The line is wraped by word. There are characters with different sizes. It calculates the layout for the second line.",
- "Hello <font size='14'>wo</font>rld <font size='16'>hello world</font>", // input line
+ "The paragraph is wraped by word. There are characters with different sizes. It calculates the layout for the second line.",
+ "Hello <font size='14'>wo</font>rld <font size='16'>hello world</font>", // input paragraph
100.f, // parent width
2, // indices. The third word starts in a new line.
0,
11.949220f // max ascender
},
{
- "The line is wraped by word. The word doen't fit.",
- "Hello world", // input line
+ "The paragraph is wraped by word. The word doen't fit.",
+ "Hello world", // input paragraph
40.f, // parent width
0, // indices. The third word starts in a new line.
0,
//WrapByWordAndSplit
{
- "The line is wraped by word and by character. All characters have the same size. There is not a long word.",
- "Hello world hello world", // input line
+ "The paragraph is wraped by word and by character. All characters have the same size. There is not a long word.",
+ "Hello world hello world", // input paragraph
100.f, // parent width
0, // indices.
0,
10.242188f // max ascender
},
{
- "The line is wraped by word and by character. All characters have the same size. There is a long word.",
- "Helloooooooo world", // input line
+ "The paragraph is wraped by word and by character. All characters have the same size. There is a long word.",
+ "Helloooooooo world", // input paragraph
100.f, // parent width
0, // indices.
0,
10.242188f // max ascender
},
{
- "The line is wraped by word and by character. There are characters with different sizes. There is a long word. It calculates the layout for the second line.",
- "Helloooooooo <font size='14'>world</font>", // input line
+ "The paragraph is wraped by word and by character. There are characters with different sizes. There is a long word. It calculates the layout for the second line.",
+ "Helloooooooo <font size='14'>world</font>", // input paragraph
100.f, // parent width
0, // indices.
8,
10.242188f // max ascender
},
{
- "The line is wraped by word and by character. There are characters with different sizes. There is a shrink factor.",
- "Helloooooooo<font size='14'> world</font>", // input line
+ "The paragraph is wraped by word and by character. There are characters with different sizes. There is a shrink factor.",
+ "Helloooooooo<font size='14'> world</font>", // input paragraph
100.f, // parent width
0, // indices.
8,
7.169531f // max ascender
},
- //WrapByLineAndSplit
+ //WrapByParagraphCharacterAndSplit
{
- "The line is wraped by end of line and by character. All characters have the same size.",
- "Hello world", // input line
+ "The paragraph is wraped by end of paragraph and by character. All characters have the same size.",
+ "Hello world", // input paragraph
100.f, // parent width
0, // indices
0,
0,
- TextViewRelayout::WrapByLineAndSplit, // split policy
+ TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
1.f,
// results
91.041672f, // line length. (only fits 8 characters 8x11.38)
10.242188f // max ascender
},
{
- "The line fits in the width.",
- "Hello", // input line
+ "The paragraph fits in the width.",
+ "Hello", // input paragraph
100.f, // parent width
0, // indices
0,
0,
- TextViewRelayout::WrapByLineAndSplit, // split policy
+ TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
1.f,
// results
56.901047f, // line length. (only fits 5 characters 5x11.38)
10.242188f // max ascender
},
{
- "The line is wraped by end of line and by character. All characters have the same size. It calculates the layout for the second line.",
- "Hello world, hello world", // input line
+ "The paragraph is wraped by end of paragraph and by character. All characters have the same size. It calculates the layout for the second line.",
+ "Hello world, hello world", // input paragraph
100.f, // parent width
2, // indices
2,
8,
- TextViewRelayout::WrapByLineAndSplit, // split policy
+ TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
1.f,
// results
91.041672f, // line length. (only fits 8 characters 8x11.38)
for( std::size_t index = 0; index < numberOfTests; ++index )
{
- const CalculateSubLineLayoutTest& test = calculateSubLineLayoutTest[index];
+ const CalculateLineLayoutTest& test = calculateLineLayoutTest[index];
- if( !TestCalculateSubLineLayout( test, TEST_LOCATION ) )
+ if( !TestCalculateLineLayout( test, TEST_LOCATION ) )
{
tet_result( TET_FAIL );
}
// Internal headers are allowed here
#include <dali-toolkit/internal/controls/text-view/text-view-processor.h>
#include <dali-toolkit/internal/controls/text-view/text-view-processor-dbg.h>
-#include <dali-toolkit/internal/controls/text-view/text-view-line-processor.h>
+#include <dali-toolkit/internal/controls/text-view/text-view-paragraph-processor.h>
#include <dali-toolkit/internal/controls/text-view/text-view-word-processor.h>
#include <dali-toolkit/internal/controls/text-view/relayout-utilities.h>
std::string lastResult;
};
-struct SplitLineTest
+struct SplitParagraphTest
{
std::string description;
std::string input;
std::string result;
};
-struct MergeLinesTest
+struct MergeParagraphsTest
{
std::string description;
std::string inputFirst;
std::string result;
};
-struct RemoveWordsFromLineTest
+struct RemoveWordsFromParagraphTest
{
std::string description;
std::string input;
std::cout << "]"; std::cout << std::endl;
}
-void Print( const TextViewProcessor::LineLayoutInfo& line )
+void Print( const TextViewProcessor::ParagraphLayoutInfo& paragraph )
{
std::cout << "<";
- std::cout << " mSize : " << line.mSize << std::endl;
- std::cout << " mAscender : " << line.mAscender << std::endl;
- std::cout << "mNumberOfCharacters : " << line.mNumberOfCharacters << std::endl;
- for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = line.mWordsLayoutInfo.begin(), endIt = line.mWordsLayoutInfo.end(); it != endIt; ++it )
+ std::cout << " mSize : " << paragraph.mSize << std::endl;
+ std::cout << " mAscender : " << paragraph.mAscender << std::endl;
+ std::cout << "mNumberOfCharacters : " << paragraph.mNumberOfCharacters << std::endl;
+ for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = paragraph.mWordsLayoutInfo.begin(), endIt = paragraph.mWordsLayoutInfo.end(); it != endIt; ++it )
{
Print( *it );
}
void Print( const TextViewProcessor::TextLayoutInfo& text )
{
std::cout << "||";
- for( TextViewProcessor::LineLayoutInfoContainer::const_iterator it = text.mLinesLayoutInfo.begin(), endIt = text.mLinesLayoutInfo.end(); it != endIt; ++it )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::const_iterator it = text.mParagraphsLayoutInfo.begin(), endIt = text.mParagraphsLayoutInfo.end(); it != endIt; ++it )
{
Print( *it );
}
return text;
}
-std::string GetText( const TextViewProcessor::LineLayoutInfo& line )
+std::string GetText( const TextViewProcessor::ParagraphLayoutInfo& paragraph )
{
std::string text;
- for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = line.mWordsLayoutInfo.begin(), endIt = line.mWordsLayoutInfo.end(); it != endIt; ++it )
+ for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = paragraph.mWordsLayoutInfo.begin(), endIt = paragraph.mWordsLayoutInfo.end(); it != endIt; ++it )
{
text += GetText( *it );
}
return true;
}
-bool TestEqual( const TextViewProcessor::LineLayoutInfo& line1,
- const TextViewProcessor::LineLayoutInfo& line2 )
+bool TestEqual( const TextViewProcessor::ParagraphLayoutInfo& paragraph1,
+ const TextViewProcessor::ParagraphLayoutInfo& paragraph2 )
{
- if( !TestEqual( line1.mSize.x, line2.mSize.x ) )
+ if( !TestEqual( paragraph1.mSize.x, paragraph2.mSize.x ) )
{
return false;
}
- if( !TestEqual( line1.mSize.y, line2.mSize.y ) )
+ if( !TestEqual( paragraph1.mSize.y, paragraph2.mSize.y ) )
{
return false;
}
- if( !TestEqual( line1.mAscender, line2.mAscender ) )
+ if( !TestEqual( paragraph1.mAscender, paragraph2.mAscender ) )
{
return false;
}
- if( line1.mNumberOfCharacters != line2.mNumberOfCharacters )
+ if( paragraph1.mNumberOfCharacters != paragraph2.mNumberOfCharacters )
{
return false;
}
- if( line1.mWordsLayoutInfo.size() != line2.mWordsLayoutInfo.size() )
+ if( paragraph1.mWordsLayoutInfo.size() != paragraph2.mWordsLayoutInfo.size() )
{
return false;
}
- for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it1 = line1.mWordsLayoutInfo.begin(), endIt1 = line1.mWordsLayoutInfo.end(),
- it2 = line2.mWordsLayoutInfo.begin(), endIt2 = line2.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it1 = paragraph1.mWordsLayoutInfo.begin(), endIt1 = paragraph1.mWordsLayoutInfo.end(),
+ it2 = paragraph2.mWordsLayoutInfo.begin(), endIt2 = paragraph2.mWordsLayoutInfo.end();
( it1 != endIt1 ) && ( it2 != endIt2 );
++it1, ++it2 )
{
return false;
}
- if( text1.mLinesLayoutInfo.size() != text2.mLinesLayoutInfo.size() )
+ if( text1.mParagraphsLayoutInfo.size() != text2.mParagraphsLayoutInfo.size() )
{
return false;
}
- for( TextViewProcessor::LineLayoutInfoContainer::const_iterator it1 = text1.mLinesLayoutInfo.begin(), endIt1 = text1.mLinesLayoutInfo.end(),
- it2 = text2.mLinesLayoutInfo.begin(), endIt2 = text2.mLinesLayoutInfo.end();
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::const_iterator it1 = text1.mParagraphsLayoutInfo.begin(), endIt1 = text1.mParagraphsLayoutInfo.end(),
+ it2 = text2.mParagraphsLayoutInfo.begin(), endIt2 = text2.mParagraphsLayoutInfo.end();
( it1 != endIt1 ) && ( it2 != endIt2 );
++it1, ++it2 )
{
// Get the input word
TextViewProcessor::WordLayoutInfo inputWordLayout;
- if( !inputLayout.mLinesLayoutInfo.empty() )
+ if( !inputLayout.mParagraphsLayoutInfo.empty() )
{
- const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordsLayoutInfo.empty() )
+ const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputLayout.mParagraphsLayoutInfo.begin() );
+ if( !paragraph.mWordsLayoutInfo.empty() )
{
- inputWordLayout = *( *inputLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin();
+ inputWordLayout = *( *inputLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
}
}
// Get the first result word
TextViewProcessor::WordLayoutInfo firstResultWordLayout;
- if( !firstResultLayout.mLinesLayoutInfo.empty() )
+ if( !firstResultLayout.mParagraphsLayoutInfo.empty() )
{
- const TextViewProcessor::LineLayoutInfo& line( *firstResultLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordsLayoutInfo.empty() )
+ const TextViewProcessor::ParagraphLayoutInfo& paragraph( *firstResultLayout.mParagraphsLayoutInfo.begin() );
+ if( !paragraph.mWordsLayoutInfo.empty() )
{
- firstResultWordLayout = *( *firstResultLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin();
+ firstResultWordLayout = *( *firstResultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
}
}
// Get the last result word
TextViewProcessor::WordLayoutInfo lastResultWordLayout;
- if( !lastResultLayout.mLinesLayoutInfo.empty() )
+ if( !lastResultLayout.mParagraphsLayoutInfo.empty() )
{
- const TextViewProcessor::LineLayoutInfo& line( *lastResultLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordsLayoutInfo.empty() )
+ const TextViewProcessor::ParagraphLayoutInfo& paragraph( *lastResultLayout.mParagraphsLayoutInfo.begin() );
+ if( !paragraph.mWordsLayoutInfo.empty() )
{
- lastResultWordLayout = *( *lastResultLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin();
+ lastResultWordLayout = *( *lastResultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
}
}
}
/**
- * Splits the \e input line in two by the given \e wordIndex and \e characterIndex and checks the results with \e firstResult and \e lastResult.
+ * Splits the \e input paragraph in two by the given \e wordIndex and \e characterIndex and checks the results with \e firstResult and \e lastResult.
*
* If the test fails it prints a short description and the line where this function was called.
*
- * @param description Short description of the experiment. i.e. "Split the line from the beginning. (wordIndex 0 and characterIndex 0)".
+ * @param description Short description of the experiment. i.e. "Split the paragraph from the beginning. (wordIndex 0 and characterIndex 0)".
* @param input The input word.
- * @param wordIndex Index to the word within the line where to split it.
+ * @param wordIndex Index to the word within the paragraph where to split it.
* @param characterIndex Where to split the word.
* @param lineHeightOffset Offset between lines.
- * @param firstResult First part of the split line.
- * @param lastResult Last part of the split line.
+ * @param firstResult First part of the split paragraph.
+ * @param lastResult Last part of the split paragraph.
* @param location Where this function has been called.
*
* @return \e true if the experiment is successful. Otherwise returns \e false.
*/
-bool TestSplitLine( const std::string& description,
- const std::string& input,
- const size_t wordIndex,
- const size_t characterIndex,
- const float lineHeightOffset,
- const std::string& firstResult,
- const std::string& lastResult,
- const char* location )
+bool TestSplitParagraph( const std::string& description,
+ const std::string& input,
+ size_t wordIndex,
+ size_t characterIndex,
+ float lineHeightOffset,
+ const std::string& firstResult,
+ const std::string& lastResult,
+ const char* location )
{
tet_printf( "%s\n", description.c_str() );
- // Create layout info for the input line.
+ // Create layout info for the input paragraph.
Toolkit::Internal::TextView::RelayoutData relayoutData;
TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
true ),
relayoutData );
- // Get the input line
- TextViewProcessor::LineLayoutInfo inputLineLayout;
+ // Get the input paragraph
+ TextViewProcessor::ParagraphLayoutInfo inputParagraphLayout;
- if( !inputLayout.mLinesLayoutInfo.empty() )
+ if( !inputLayout.mParagraphsLayoutInfo.empty() )
{
- inputLineLayout = *inputLayout.mLinesLayoutInfo.begin();
+ inputParagraphLayout = *inputLayout.mParagraphsLayoutInfo.begin();
}
- // Create layout info for the first part of the result (after split the line)
+ // Create layout info for the first part of the result (after split the paragraph)
Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
TextViewProcessor::TextLayoutInfo& firstResultLayout( firstRelayoutData.mTextLayoutInfo );
true ),
firstRelayoutData );
- // Get the first result line
- TextViewProcessor::LineLayoutInfo firstResultLineLayout;
+ // Get the first result paragraph
+ TextViewProcessor::ParagraphLayoutInfo firstResultParagraphLayout;
- if( !firstResultLayout.mLinesLayoutInfo.empty() )
+ if( !firstResultLayout.mParagraphsLayoutInfo.empty() )
{
- firstResultLineLayout = *firstResultLayout.mLinesLayoutInfo.begin();
+ firstResultParagraphLayout = *firstResultLayout.mParagraphsLayoutInfo.begin();
}
- // Create layout info for the last part of the result (after split the line)
+ // Create layout info for the last part of the result (after split the paragraph)
Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
TextViewProcessor::TextLayoutInfo& lastResultLayout( lastRelayoutData.mTextLayoutInfo );
true ),
lastRelayoutData );
- // Get the last result line
- TextViewProcessor::LineLayoutInfo lastResultLineLayout;
+ // Get the last result paragraph
+ TextViewProcessor::ParagraphLayoutInfo lastResultParagraphLayout;
- if( !lastResultLayout.mLinesLayoutInfo.empty() )
+ if( !lastResultLayout.mParagraphsLayoutInfo.empty() )
{
- lastResultLineLayout = *lastResultLayout.mLinesLayoutInfo.begin();
+ lastResultParagraphLayout = *lastResultLayout.mParagraphsLayoutInfo.begin();
}
- // Split the line.
+ // Split the paragraph.
- TextViewProcessor::LineLayoutInfo lastLineLayoutInfo;
+ TextViewProcessor::ParagraphLayoutInfo lastParagraphLayoutInfo;
TextViewProcessor::TextInfoIndices indices( 0, wordIndex, characterIndex );
- SplitLine( indices,
- PointSize( lineHeightOffset ),
- inputLineLayout,
- lastLineLayoutInfo );
+ SplitParagraph( indices,
+ PointSize( lineHeightOffset ),
+ inputParagraphLayout,
+ lastParagraphLayoutInfo );
// Test results
- if( !TestEqual( inputLineLayout, firstResultLineLayout ) )
+ if( !TestEqual( inputParagraphLayout, firstResultParagraphLayout ) )
{
tet_printf( "Fail. different first layout info. %s\n", location );
return false;
}
- if( !TestEqual( lastLineLayoutInfo, lastResultLineLayout ) )
+ if( !TestEqual( lastParagraphLayoutInfo, lastResultParagraphLayout ) )
{
tet_printf( "Fail. different last layout info. %s\n", location );
return false;
// Get the input word
TextViewProcessor::WordLayoutInfo inputFirstWordLayout;
- if( !inputFirstLayout.mLinesLayoutInfo.empty() )
+ if( !inputFirstLayout.mParagraphsLayoutInfo.empty() )
{
- const TextViewProcessor::LineLayoutInfo& line( *inputFirstLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordsLayoutInfo.empty() )
+ const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputFirstLayout.mParagraphsLayoutInfo.begin() );
+ if( !paragraph.mWordsLayoutInfo.empty() )
{
- inputFirstWordLayout = *( *inputFirstLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin();
+ inputFirstWordLayout = *( *inputFirstLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
}
}
// Get the input word
TextViewProcessor::WordLayoutInfo inputLastWordLayout;
- if( !inputLastLayout.mLinesLayoutInfo.empty() )
+ if( !inputLastLayout.mParagraphsLayoutInfo.empty() )
{
- const TextViewProcessor::LineLayoutInfo& line( *inputLastLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordsLayoutInfo.empty() )
+ const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputLastLayout.mParagraphsLayoutInfo.begin() );
+ if( !paragraph.mWordsLayoutInfo.empty() )
{
- inputLastWordLayout = *( *inputLastLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin();
+ inputLastWordLayout = *( *inputLastLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
}
}
// Get the result word
TextViewProcessor::WordLayoutInfo resultWordLayout;
- if( !resultLayout.mLinesLayoutInfo.empty() )
+ if( !resultLayout.mParagraphsLayoutInfo.empty() )
{
- const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordsLayoutInfo.empty() )
+ const TextViewProcessor::ParagraphLayoutInfo& paragraph( *resultLayout.mParagraphsLayoutInfo.begin() );
+ if( !paragraph.mWordsLayoutInfo.empty() )
{
- resultWordLayout = *( *resultLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin();
+ resultWordLayout = *( *resultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
}
}
}
/**
- * Merges the \e inputFirst line and the \e inputLast line, and checks the results with \e result.
+ * Merges the \e inputFirst paragraph and the \e inputLast paragraph, and checks the results with \e result.
*
* If the test fails it prints a short description and the line where this function was called.
*
* @param description Short description of the experiment.
- * @param inputFirst The first part of the line.
- * @param inputLast The last part of the line.
+ * @param inputFirst The first part of the paragraph.
+ * @param inputLast The last part of the paragraph.
* @param lineHeightOffset Offset between lines.
- * @param result The merged line.
+ * @param result The merged paragraph.
* @param location Where this function has been called.
*
* @return \e true if the experiment is successful. Otherwise returns \e false.
*/
-bool TestMergeLines( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const float lineHeightOffset, const std::string& result, const char* location )
+bool TestMergeParagraphs( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const float lineHeightOffset, const std::string& result, const char* location )
{
tet_printf( "%s\n", description.c_str() );
- // Create layout info for the inputFirst line.
+ // Create layout info for the inputFirst paragraph.
Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo );
firstRelayoutData );
// Get the input word
- TextViewProcessor::LineLayoutInfo inputFirstLineLayout;
+ TextViewProcessor::ParagraphLayoutInfo inputFirstParagraphLayout;
- if( !inputFirstLayout.mLinesLayoutInfo.empty() )
+ if( !inputFirstLayout.mParagraphsLayoutInfo.empty() )
{
- inputFirstLineLayout = *inputFirstLayout.mLinesLayoutInfo.begin();
+ inputFirstParagraphLayout = *inputFirstLayout.mParagraphsLayoutInfo.begin();
}
- // Create layout info for the inputLast line.
+ // Create layout info for the inputLast paragraph.
Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo );
lastRelayoutData );
// Get the input word
- TextViewProcessor::LineLayoutInfo inputLastLineLayout;
+ TextViewProcessor::ParagraphLayoutInfo inputLastParagraphLayout;
- if( !inputLastLayout.mLinesLayoutInfo.empty() )
+ if( !inputLastLayout.mParagraphsLayoutInfo.empty() )
{
- inputLastLineLayout = *inputLastLayout.mLinesLayoutInfo.begin();
+ inputLastParagraphLayout = *inputLastLayout.mParagraphsLayoutInfo.begin();
}
// Create layout info for the result word.
resultRelayoutData );
// Get the result word
- TextViewProcessor::LineLayoutInfo resultLineLayout;
+ TextViewProcessor::ParagraphLayoutInfo resultParagraphLayout;
- if( !resultLayout.mLinesLayoutInfo.empty() )
+ if( !resultLayout.mParagraphsLayoutInfo.empty() )
{
- resultLineLayout = *resultLayout.mLinesLayoutInfo.begin();
+ resultParagraphLayout = *resultLayout.mParagraphsLayoutInfo.begin();
}
- MergeLine( inputFirstLineLayout,
- inputLastLineLayout );
+ MergeParagraph( inputFirstParagraphLayout,
+ inputLastParagraphLayout );
- if( !TestEqual( inputFirstLineLayout, resultLineLayout ) )
+ if( !TestEqual( inputFirstParagraphLayout, resultParagraphLayout ) )
{
tet_printf( "Fail. different layout info. %s\n", location );
return false;
// Get the input word
TextViewProcessor::WordLayoutInfo inputWordLayout;
- if( !inputLayout.mLinesLayoutInfo.empty() )
+ if( !inputLayout.mParagraphsLayoutInfo.empty() )
{
- const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordsLayoutInfo.empty() )
+ const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputLayout.mParagraphsLayoutInfo.begin() );
+ if( !paragraph.mWordsLayoutInfo.empty() )
{
- inputWordLayout = *( *inputLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin();
+ inputWordLayout = *( *inputLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
}
}
// Get the result word
TextViewProcessor::WordLayoutInfo resultWordLayout;
- if( !resultLayout.mLinesLayoutInfo.empty() )
+ if( !resultLayout.mParagraphsLayoutInfo.empty() )
{
- const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordsLayoutInfo.empty() )
+ const TextViewProcessor::ParagraphLayoutInfo& paragraph( *resultLayout.mParagraphsLayoutInfo.begin() );
+ if( !paragraph.mWordsLayoutInfo.empty() )
{
- resultWordLayout = *( *resultLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin();
+ resultWordLayout = *( *resultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
}
}
}
/**
- * Removes from the \e input line the \e numberOfWords words starting from the given \e wordIndex and checks the results with \e result.
+ * Removes from the \e input paragraph the \e numberOfWords words starting from the given \e wordIndex and checks the results with \e result.
*
* If the test fails it prints a short description and the line where this function was called.
*
* @param description Short description of the experiment.
- * @param input The input line.
- * @param wordIndex Index within the line where to start to remove words.
+ * @param input The input paragraph.
+ * @param wordIndex Index within the paragraph where to start to remove words.
* @param numberOfWords The number of words to remove.
* @param lineHeightOffset Offset between lines.
- * @param result The line without the removed words.
+ * @param result The paragraph without the removed words.
* @param location Where this function has been called.
*
* @return \e true if the experiment is successful. Otherwise returns \e false.
*/
-bool TestRemoveWordsFromLine( const std::string& description, const std::string& input, const std::size_t wordIndex, const std::size_t numberOfWords, const float lineHeightOffset, const std::string& result, const char* location )
+bool TestRemoveWordsFromParagraph( const std::string& description, const std::string& input, const std::size_t wordIndex, const std::size_t numberOfWords, const float lineHeightOffset, const std::string& result, const char* location )
{
tet_printf( "%s\n", description.c_str() );
- // Create layout info for the input line.
+ // Create layout info for the input paragraph.
Toolkit::Internal::TextView::RelayoutData relayoutData;
TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
true ),
relayoutData );
- // Get the input line
- TextViewProcessor::LineLayoutInfo inputLineLayout;
+ // Get the input paragraph
+ TextViewProcessor::ParagraphLayoutInfo inputParagraphLayout;
- if( !inputLayout.mLinesLayoutInfo.empty() )
+ if( !inputLayout.mParagraphsLayoutInfo.empty() )
{
- inputLineLayout = *inputLayout.mLinesLayoutInfo.begin();
+ inputParagraphLayout = *inputLayout.mParagraphsLayoutInfo.begin();
}
- // Create layout info for the result line.
+ // Create layout info for the result paragraph.
Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
true ),
resultRelayoutData );
- // Get the result line
- TextViewProcessor::LineLayoutInfo resultLineLayout;
+ // Get the result paragraph
+ TextViewProcessor::ParagraphLayoutInfo resultParagraphLayout;
- if( !resultLayout.mLinesLayoutInfo.empty() )
+ if( !resultLayout.mParagraphsLayoutInfo.empty() )
{
- resultLineLayout = *resultLayout.mLinesLayoutInfo.begin();
+ resultParagraphLayout = *resultLayout.mParagraphsLayoutInfo.begin();
}
- RemoveWordsFromLine( wordIndex,
- numberOfWords,
- lineHeightOffset,
- inputLineLayout );
+ RemoveWordsFromParagraph( wordIndex,
+ numberOfWords,
+ lineHeightOffset,
+ inputParagraphLayout );
- if( !TestEqual( inputLineLayout, resultLineLayout ) )
+ if( !TestEqual( inputParagraphLayout, resultParagraphLayout ) )
{
tet_printf( "Fail. different layout info. %s\n", location );
tet_printf( " input : [%s]\n", input.c_str() );
- tet_printf( " result : [%s]\n", GetText( resultLineLayout ).c_str() );
+ tet_printf( " result : [%s]\n", GetText( resultParagraphLayout ).c_str() );
tet_printf( " expected result : [%s]\n\n", result.c_str() );
- Print(inputLineLayout); std::cout << std::endl << std::endl;
- Print(resultLineLayout); std::cout << std::endl;
+ Print(inputParagraphLayout); std::cout << std::endl << std::endl;
+ Print(resultParagraphLayout); std::cout << std::endl;
return false;
}
* @return \e true if the experiment is successful. Otherwise returns \e false.
*/
bool TestUpdateTextInfo( const std::string& description,
- const UpdateTextInfoOperation operation,
+ UpdateTextInfoOperation operation,
const std::string& input,
- const std::size_t position,
- const std::size_t numberOfCharacters,
+ std::size_t position,
+ std::size_t numberOfCharacters,
const std::string& inputText,
- const float lineHeightOffset,
+ float lineHeightOffset,
const std::string& result,
const char* location )
{
layoutInfo12.mStyledText.mText = Text( "!" );
wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // !
- // (new line character)
+ // (new paragraph character)
wordLayout4.mSize = Size( 0.f, HEIGHT_12 );
wordLayout4.mAscender = ASCENDER_12;
- wordLayout4.mType = TextViewProcessor::LineSeparator;
+ wordLayout4.mType = TextViewProcessor::ParagraphSeparator;
layoutInfo12.mStyledText.mText = Text( "\n" );
layoutInfo12.mSize.width = 0.f;
- wordLayout4.mCharactersLayoutInfo.push_back( layoutInfo12 ); // (new line char)
+ wordLayout4.mCharactersLayoutInfo.push_back( layoutInfo12 ); // (new paragraph char)
- // Lines
+ // Paragraphs
- TextViewProcessor::LineLayoutInfo lineLayout1, lineLayout2, lineLayout3;
+ TextViewProcessor::ParagraphLayoutInfo paragraphLayout1, paragraphLayout2, paragraphLayout3;
- lineLayout1.mSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, HEIGHT_12 );
- lineLayout1.mAscender = ASCENDER_12;
- lineLayout1.mNumberOfCharacters = 13;
- lineLayout1.mWordsLayoutInfo.push_back( wordLayout1 );
- lineLayout1.mWordsLayoutInfo.push_back( wordLayout2 );
- lineLayout1.mWordsLayoutInfo.push_back( wordLayout3 );
- lineLayout1.mWordsLayoutInfo.push_back( wordLayout4 );
+ paragraphLayout1.mSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, HEIGHT_12 );
+ paragraphLayout1.mAscender = ASCENDER_12;
+ paragraphLayout1.mNumberOfCharacters = 13;
+ paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout1 );
+ paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout2 );
+ paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout3 );
+ paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout4 );
- lineLayout2.mSize = Size( 0.f, HEIGHT_12 );
- lineLayout2.mAscender = ASCENDER_12;
- lineLayout2.mNumberOfCharacters = 1;
- lineLayout2.mWordsLayoutInfo.push_back( wordLayout4 );
+ paragraphLayout2.mSize = Size( 0.f, HEIGHT_12 );
+ paragraphLayout2.mAscender = ASCENDER_12;
+ paragraphLayout2.mNumberOfCharacters = 1;
+ paragraphLayout2.mWordsLayoutInfo.push_back( wordLayout4 );
- lineLayout3.mSize = Size( 0.f, HEIGHT_12 );
+ paragraphLayout3.mSize = Size( 0.f, HEIGHT_12 );
// Text (layout)
TextViewProcessor::TextLayoutInfo textLayout;
textLayout.mWholeTextSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, 3.f * HEIGHT_12 );
textLayout.mMaxWordWidth = 2.f * WIDTH_10 + 4.f * WIDTH_12;
textLayout.mNumberOfCharacters = 14;
- textLayout.mLinesLayoutInfo.push_back( lineLayout1 );
- textLayout.mLinesLayoutInfo.push_back( lineLayout2 );
- textLayout.mLinesLayoutInfo.push_back( lineLayout3 );
+ textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout1 );
+ textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout2 );
+ textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout3 );
if(!TestEqual( textLayout, textLayoutInfo ))
{
std::string( "<font size='10'>oooo</font>" ),
},
};
- const std::size_t numberOfTests( 5 );
+ const std::size_t numberOfTests( 5u );
- for( std::size_t index = 0; index < numberOfTests; ++index )
+ for( std::size_t index = 0u; index < numberOfTests; ++index )
{
const SplitWordTest& test = splitWordTests[index];
// Remove operations
{
- std::string( "Remove from new line character to first character next line." ),
+ std::string( "Remove from new paragraph character to first character next paragraph." ),
Remove,
std::string("Hello world\nhello world."),
11,
std::string("Hello worldello world."),
},
{
- std::string( "Replace style from new line character to first character next line." ),
+ std::string( "Replace style from new paragraph character to first character next paragraph." ),
Replace,
std::string("Hello world\nhello world."),
11,
0.f,
std::string( "Hello <font size='10'>\nhello</font> world" )
},
- // * Remove whole word (merge lines)
+ // * Remove whole word (merge paragraphs)
{
- std::string( "Remove within the same word, whole word (merge lines)" ),
+ std::string( "Remove within the same word, whole word (merge paragraphs)" ),
Remove,
std::string("Hello <font size='30'>w</font>orl<font size='10'>d\nhello</font> world"),
11,
// * Remove RTL text within LTR
/* TODO check this when RTL text is working
{
- std::string( "Remove within the same line, RTL text within LTR." ),
+ std::string( "Remove within the same paragraph, RTL text within LTR." ),
Remove,
std::string("Hello world, שלום עולם, hello world"),
10,
std::string( "Hello worlello world" )
},
*/
- // * Remove whole line
+ // * Remove whole paragraph
{
- std::string( "Remove whole line" ),
+ std::string( "Remove whole paragraph" ),
Remove,
std::string("Hello world, hello world\n"
"Hello world, hello world\n"
"Hello world, hello world\n"),
},
{
- std::string( "Remove whole line" ),
+ std::string( "Remove whole paragraph" ),
Remove,
std::string("Hello world, hello world\n"
"H"),
std::string( "Touch <b>me\nhello\n</b>world" )
},
};
- const std::size_t numberOfTests( 21 );
+ const std::size_t numberOfTests( 21u );
- for( std::size_t index = 0; index < numberOfTests; ++index )
+ for( std::size_t index = 0u; index < numberOfTests; ++index )
{
const UpdateTextInfoTest& test = updateTextInfoTest[index];
END_TEST;
}
-int UtcDaliTextViewSplitLine(void)
+int UtcDaliTextViewSplitParagraph(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliTextViewSplitLine : ");
+ tet_infoline("UtcDaliTextViewSplitParagraph : ");
- struct SplitLineTest splitLineTests[] =
+ struct SplitParagraphTest splitParagraphTests[] =
{
{
- std::string( "Split line, wordPosition 0, position 0." ),
+ std::string( "Split paragraph, wordPosition 0, position 0." ),
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
0,
0,
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
},
{
- std::string( "Split line, wordPosition 10, position 4." ),
+ std::string( "Split paragraph, wordPosition 10, position 4." ),
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
10,
4,
std::string( "" ),
},
{
- std::string( "Split line, wordPosition 2, position 4." ),
+ std::string( "Split paragraph, wordPosition 2, position 4." ),
std::string("<font size='10'>Hello </font>wor<font size='12'>ld, hello wo</font>rld"),
2,
4,
}
/* TODO RTL
{
- std::string( "Split line, wordPosition 6, position 0." ),
+ std::string( "Split paragraph, wordPosition 6, position 0." ),
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
6,
0,
0.f,
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום" ),
- std::string( " עולם text text" ),
+ std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום " ),
+ std::string( "עולם text text" ),
},
{
- std::string( "Split line, wordPosition 4, position 0." ),
+ std::string( "Split paragraph, wordPosition 4, position 0." ),
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
4,
0,
std::string( "שלום עולם text text" ),
},
{
- std::string( "Split line2, wordPosition 8, position 0." ),
+ std::string( "Split paragraph2, wordPosition 8, position 0." ),
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
8,
0,
},
*/
};
- const std::size_t numberOfTests( 3 );
+ const std::size_t numberOfTests( 3u );
- for( std::size_t index = 0; index < numberOfTests; ++index )
+ for( std::size_t index = 0u; index < numberOfTests; ++index )
{
- const SplitLineTest& test = splitLineTests[index];
+ const SplitParagraphTest& test = splitParagraphTests[index];
- if( !TestSplitLine( test.description,
- test.input,
- test.wordIndex,
- test.characterIndex,
- test.lineHeightOffset,
- test.firstResult,
- test.lastResult,
- TEST_LOCATION ) )
+ if( !TestSplitParagraph( test.description,
+ test.input,
+ test.wordIndex,
+ test.characterIndex,
+ test.lineHeightOffset,
+ test.firstResult,
+ test.lastResult,
+ TEST_LOCATION ) )
{
tet_result( TET_FAIL );
}
std::string( "<font size='10'>Hel</font><font size='20'>lo</font>" )
},
};
- const std::size_t numberOfTests( 2 );
+ const std::size_t numberOfTests( 2u );
- for( std::size_t index = 0; index < numberOfTests; ++index )
+ for( std::size_t index = 0u; index < numberOfTests; ++index )
{
const MergeWordsTest& test = mergeWordsTests[index];
int UtcDaliTextViewMergeWord02(void)
{
// Negative test.
- // It test white spaces and new line characters can't be merged to other words.
+ // It test white spaces and new paragraph characters can't be merged to other words.
ToolkitTestApplication application;
TextViewProcessor::WordLayoutInfo wordLayoutInfo01;
- wordLayoutInfo01 = *( *textLayoutInfo01.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin();
+ wordLayoutInfo01 = *( *textLayoutInfo01.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
TextViewProcessor::CreateTextInfo( styledText02,
DEFAULT_LAYOUT_PARAMETERS,
TextViewProcessor::WordLayoutInfo wordLayoutInfo02;
- wordLayoutInfo02 = *( *textLayoutInfo02.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin();
+ wordLayoutInfo02 = *( *textLayoutInfo02.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
TextViewProcessor::CreateTextInfo( styledText03,
DEFAULT_LAYOUT_PARAMETERS,
TextViewProcessor::WordLayoutInfo wordLayoutInfo03;
- wordLayoutInfo03 = *( *textLayoutInfo03.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin();
+ wordLayoutInfo03 = *( *textLayoutInfo03.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- // Test MergeWord() asserts if white spaces or new line chars are merged.
+ // Test MergeWord() asserts if white spaces or new paragraph chars are merged.
bool assert1 = false;
bool assert2 = false;
bool assert3 = false;
catch( Dali::DaliException& e )
{
tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
+ DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
assert1 = true;
}
try
catch( Dali::DaliException& e )
{
tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
+ DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
assert2 = true;
}
try
catch( Dali::DaliException& e )
{
tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
+ DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
assert3 = true;
}
try
catch( Dali::DaliException& e )
{
tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
+ DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
assert4 = true;
}
try
catch( Dali::DaliException& e )
{
tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
+ DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
assert5 = true;
}
try
catch( Dali::DaliException& e )
{
tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
+ DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
assert6 = true;
}
END_TEST;
}
-int UtcDaliTextViewMergeLine01(void)
+int UtcDaliTextViewMergeParagraph01(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliTextViewMergeLine01 : ");
+ tet_infoline("UtcDaliTextViewMergeParagraph01 : ");
- struct MergeLinesTest mergeLinesTests[] =
+ struct MergeParagraphsTest mergeParagraphsTests[] =
{
{
- std::string( "Merge a void first line." ),
+ std::string( "Merge a void first paragraph." ),
std::string( "" ),
- std::string( "Hello world, this is a whole line" ),
+ std::string( "Hello world, this is a whole paragraph" ),
2.f,
- std::string( "Hello world, this is a whole line" )
+ std::string( "Hello world, this is a whole paragraph" )
},
{
- std::string( "Merge a void last line." ),
- std::string( "Hello world, this is a whole line" ),
+ std::string( "Merge a void last paragraph." ),
+ std::string( "Hello world, this is a whole paragraph" ),
std::string( "" ),
0.f,
- std::string( "Hello world, this is a whole line" )
+ std::string( "Hello world, this is a whole paragraph" )
},
/* TODO RTL
{
- std::string( "Merge lines: last starting with RTL text and first ending with RTL" ),
+ std::string( "Merge paragraphs: last starting with RTL text and first ending with RTL" ),
std::string( "Hello world, שלום" ),
std::string( " עולם, hello world." ),
6.f,
std::string( "Hello world, שלום עולם, hello world." )
},
{
- std::string( "Merge lines and don't merge last and first words." ),
+ std::string( "Merge paragraphs and don't merge last and first words." ),
std::string( "Hello world, " ),
std::string( "שלום עולם, hello world." ),
3.f,
},
*/
{
- std::string( "Merge lines. Don't merge words" ),
+ std::string( "Merge paragraphs. Don't merge words" ),
std::string( "Hello world," ),
- std::string( " this is a whole line" ),
+ std::string( " this is a whole paragraph" ),
0.f,
- std::string( "Hello world, this is a whole line" )
+ std::string( "Hello world, this is a whole paragraph" )
},
{
- std::string( "Merge lines. Merge words" ),
+ std::string( "Merge paragraphs. Merge words" ),
std::string( "Hello world, th" ),
- std::string( "is is a whole line" ),
+ std::string( "is is a whole paragraph" ),
0.f,
- std::string( "Hello world, this is a whole line" )
+ std::string( "Hello world, this is a whole paragraph" )
},
};
- const std::size_t numberOfTests( 4 );
+ const std::size_t numberOfTests( 4u );
- for( std::size_t index = 0; index < numberOfTests; ++index )
+ for( std::size_t index = 0u; index < numberOfTests; ++index )
{
- const MergeLinesTest& test = mergeLinesTests[index];
+ const MergeParagraphsTest& test = mergeParagraphsTests[index];
- if( !TestMergeLines( test.description, test.inputFirst, test.inputLast, test.lineHeightOffset, test.result, TEST_LOCATION ) )
+ if( !TestMergeParagraphs( test.description, test.inputFirst, test.inputLast, test.lineHeightOffset, test.result, TEST_LOCATION ) )
{
tet_result( TET_FAIL );
}
END_TEST;
}
-int UtcDaliTextViewMergeLine02(void)
+int UtcDaliTextViewMergeParagraph02(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliTextViewMergeLine02 : ");
+ tet_infoline("UtcDaliTextViewMergeParagraph02 : ");
Toolkit::Internal::TextView::RelayoutData relayoutData01;
Toolkit::Internal::TextView::RelayoutData relayoutData02;
DEFAULT_LAYOUT_PARAMETERS,
relayoutData01 );
- TextViewProcessor::LineLayoutInfo lineLayoutInfo01;
+ TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo01;
- lineLayoutInfo01 = *textLayoutInfo01.mLinesLayoutInfo.begin();
+ paragraphLayoutInfo01 = *textLayoutInfo01.mParagraphsLayoutInfo.begin();
TextViewProcessor::CreateTextInfo( styledText02,
DEFAULT_LAYOUT_PARAMETERS,
relayoutData02 );
- TextViewProcessor::LineLayoutInfo lineLayoutInfo02;
+ TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo02;
- lineLayoutInfo02 = *textLayoutInfo02.mLinesLayoutInfo.begin();
+ paragraphLayoutInfo02 = *textLayoutInfo02.mParagraphsLayoutInfo.begin();
bool assert1 = false;
try
{
- MergeLine( lineLayoutInfo01,
- lineLayoutInfo02 );
+ MergeParagraph( paragraphLayoutInfo01,
+ paragraphLayoutInfo02 );
}
catch( Dali::DaliException& e )
{
tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeLine(). ERROR: A line can't be merged to another line which finishes with a new line character.\"", TEST_LOCATION );
+ DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeParagraph(). ERROR: A paragraph can't be merged to another paragraph which finishes with a new paragraph character.\"", TEST_LOCATION );
assert1 = true;
}
std::string( "<font size='10'>Held</font>" ),
},
};
- const std::size_t numberOfTests( 11 );
+ const std::size_t numberOfTests( 11u );
- for( std::size_t index = 0; index < numberOfTests; ++index )
+ for( std::size_t index = 0u; index < numberOfTests; ++index )
{
const RemoveCharactersFromWordTest& test = removeCharactersFromWordTests[index];
END_TEST;
}
-int UtcDaliTextViewRemoveWordsFromLine(void)
+int UtcDaliTextViewRemoveWordsFromParagraph(void)
{
- // Note: Currently RemoveWordsFromLine() function is only used to remove a number of words from the beginning, or
+ // Note: Currently RemoveWordsFromParagraph() function is only used to remove a number of words from the beginning, or
// from a given index to the end.
ToolkitTestApplication application;
- tet_infoline("UtcDaliTextViewRemoveWordsFromLine : ");
- struct RemoveWordsFromLineTest removeWordsFromLineTest[] =
+ tet_infoline("UtcDaliTextViewRemoveWordsFromParagraph : ");
+ struct RemoveWordsFromParagraphTest removeWordsFromParagraphTest[] =
{
{
std::string( "Delete 0 words." ),
std::string( "hello hello" ),
},
};
- const std::size_t numberOfTests( 3 );
+ const std::size_t numberOfTests( 3u );
- for( std::size_t index = 0; index < numberOfTests; ++index )
+ for( std::size_t index = 0u; index < numberOfTests; ++index )
{
- const RemoveWordsFromLineTest& test = removeWordsFromLineTest[index];
+ const RemoveWordsFromParagraphTest& test = removeWordsFromParagraphTest[index];
- if( !TestRemoveWordsFromLine( test.description, test.input, test.wordIndex, test.numberOfWords, test.lineHeightOffset, test.result, TEST_LOCATION ) )
+ if( !TestRemoveWordsFromParagraph( test.description, test.input, test.wordIndex, test.numberOfWords, test.lineHeightOffset, test.result, TEST_LOCATION ) )
{
tet_result( TET_FAIL );
}
// TODO: TextView should have a table of visual rows, and each character a reference to the row
// that it resides on. That way this enumeration is not necessary.
Vector2 min, max;
- if(lastIt->mIsNewLineChar)
+ if(lastIt->mIsNewParagraphChar)
{
// If the last character is a new line, then to get the row rect, we need to scan from the character before the new line.
lastIt = std::max( mTextLayoutInfo.mCharacterLayoutInfoTable.begin(), lastIt - 1 );
{
// finished selection.
Vector2 min, max;
- if(lastIt->mIsNewLineChar)
+ if(lastIt->mIsNewParagraphChar)
{
lastIt = std::max( mTextLayoutInfo.mCharacterLayoutInfoTable.begin(), lastIt - 1 );
}
if( fabsf( closestYdifference - currentYdifference ) < CHARACTER_THRESHOLD )
{
// ignore new line character.
- if( !info.mIsNewLineChar )
+ if( !info.mIsNewParagraphChar )
{
matchedCharacters.push_back( info );
numberOfMatchedCharacters++;
// and check if user is touching below previous line.
const Toolkit::TextView::CharacterLayoutInfo& lastInfo( mTextLayoutInfo.mCharacterLayoutInfoTable[mTextLayoutInfo.mCharacterLayoutInfoTable.size() - 1] );
- if( ( lastInfo.mIsVisible ) && ( lastInfo.mIsNewLineChar ) && ( sourceScrollOffset.y > lastInfo.mPosition.y ) )
+ if( ( lastInfo.mIsVisible ) && ( lastInfo.mIsNewParagraphChar ) && ( sourceScrollOffset.y > lastInfo.mPosition.y ) )
{
closestIndex = mTextLayoutInfo.mCharacterLayoutInfoTable.size();
}
}
Toolkit::TextView::CharacterLayoutInfo info = mTextLayoutInfo.mCharacterLayoutInfoTable[ visualCharacterPosition ];
- if( ( visualCharacterPosition > 0 ) && info.mIsNewLineChar && !IsScrollEnabled() )
+ if( ( visualCharacterPosition > 0 ) && info.mIsNewParagraphChar && !IsScrollEnabled() )
{
// Prevents the cursor to exceed the boundary if the last visible character is a 'new line character' and the scroll is not enabled.
const Vector3& size = GetControlSize();
info = mTextLayoutInfo.mCharacterLayoutInfoTable[ visualCharacterPosition ];
}
- if(!info.mIsNewLineChar)
+ if(!info.mIsNewParagraphChar)
{
cursorPosition = PositionCursorAfterWordWrap( characterPosition ); // Get position of cursor/handles taking in account auto word wrap.
}
{
logicalPosition--;
std::size_t visualPosition = GetVisualPosition(logicalPosition);
- if(mTextLayoutInfo.mCharacterLayoutInfoTable[visualPosition].mIsNewLineChar)
+ if(mTextLayoutInfo.mCharacterLayoutInfoTable[visualPosition].mIsNewParagraphChar)
{
logicalPosition++;
break;
--it;
if( (it->mPosition.y < referenceLine) ||
- (it->mIsNewLineChar) ||
+ (it->mIsNewParagraphChar) ||
(!it->mIsVisible) )
{
break;
while(it != end)
{
if( (it->mPosition.y > referenceLine) ||
- (it->mIsNewLineChar) ||
+ (it->mIsNewParagraphChar) ||
(!it->mIsVisible) )
{
break;
// TODO: TextView should have a table of visual rows, and each character a reference to the row
// that it resides on. That way this enumeration is not necessary.
Vector2 min, max;
- if(lastIt->mIsNewLineChar)
+ if(lastIt->mIsNewParagraphChar)
{
// If the last character is a new line, then to get the row rect, we need to scan from the character before the new line.
lastIt = std::max( textLayoutInfo.mCharacterLayoutInfoTable.begin(), lastIt - 1 );
{
// finished selection.
Vector2 min, max;
- if(lastIt->mIsNewLineChar)
+ if(lastIt->mIsNewParagraphChar)
{
lastIt = std::max( textLayoutInfo.mCharacterLayoutInfoTable.begin(), lastIt - 1 );
}
RelayoutParameters::RelayoutParameters()
: mPositionOffset(),
- mLineSize(),
+ mParagraphSize(),
mWordSize(),
mCharacterSize(),
mIndices(),
mIsFirstCharacter( false ),
mIsFirstCharacterOfWord( false ),
mIsNewLine( false ),
- mIsNewLineCharacter( false ),
+ mIsNewParagraphCharacter( false ),
mIsWhiteSpace( false ),
mIsVisible( false )
{
{
}
-SubLineLayoutInfo::SubLineLayoutInfo()
+LineLayoutInfo::LineLayoutInfo()
: mLineLength( 0.f ),
mMaxCharHeight( 0.f ),
mMaxAscender( 0.f )
{
}
-SubLineLayoutInfo::~SubLineLayoutInfo()
+LineLayoutInfo::~LineLayoutInfo()
{
}
* @param[out] lineLength The length of the portion of line which doesn't exceed the parant's width
* @param[out] endWhiteSpaceLength The length of white spaces which are at the end of the line.
*/
-void CalculateLineLength( const bool isWhiteSpace, const float width, const float parentWidth, bool& found, float& lineLength, float& endWhiteSpaceLength )
+void CalculateLineLength( bool isWhiteSpace, float width, float parentWidth, bool& found, float& lineLength, float& endWhiteSpaceLength )
{
if( lineLength + width > parentWidth )
{
currentTextActorInfo.textActor.SetBlendMode( !visualParameters.mSnapshotModeEnabled ? BlendingMode::ON : BlendingMode::OFF );
}
-void CalculateSubLineLayout( const float parentWidth,
- const TextViewProcessor::TextInfoIndices& indices,
- const TextViewProcessor::LineLayoutInfo& lineLayoutInfo,
- const HorizontalWrapType splitPolicy,
- const float shrinkFactor,
- SubLineLayoutInfo& subLineInfo )
+void CalculateLineLayout( float parentWidth,
+ const TextViewProcessor::TextInfoIndices& indices,
+ const TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo,
+ HorizontalWrapType splitPolicy,
+ float shrinkFactor,
+ LineLayoutInfo& subLineInfo )
{
subLineInfo.mLineLength = 0.f;
subLineInfo.mMaxCharHeight = 0.f;
float lineOffset = 0.f;
bool found = false;
bool isFirstCharacter = true;
- for( TextViewProcessor::WordLayoutInfoContainer::const_iterator wordIt = lineLayoutInfo.mWordsLayoutInfo.begin() + indices.mWordIndex,
- wordEndIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::const_iterator wordIt = paragraphLayoutInfo.mWordsLayoutInfo.begin() + indices.mWordIndex,
+ wordEndIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
( wordIt != wordEndIt ) && !found;
++wordIt )
{
break;
}
case WrapByWord:
- case WrapByLine: // Fall through
+ case WrapByParagraphCharacter: // Fall through
{
splitByCharacter = false;
break;
splitByCharacter = ( shrunkWordWidth > parentWidth );
break;
}
- case WrapByLineAndSplit:
+ case WrapByParagraphCharacterAndSplit:
{
if( ( 0u != characterIndex ) ||
( ( 0u == characterIndex ) && ( lineOffset + shrunkWordWidth > parentWidth ) ) )
subLineInfo.mMaxAscender *= shrinkFactor;
}
-float CalculateXoffset( const Toolkit::Alignment::Type horizontalTextAlignment, const float parentWidth, const float wholeTextWidth )
+float CalculateXoffset( Toolkit::Alignment::Type horizontalTextAlignment, float parentWidth, float wholeTextWidth )
{
float xOffset( 0.f );
switch( horizontalTextAlignment )
return xOffset;
}
-float CalculateYoffset( const Toolkit::Alignment::Type verticalTextAlignment, const float parentHeight, const float wholeTextHeight )
+float CalculateYoffset( Toolkit::Alignment::Type verticalTextAlignment, float parentHeight, float wholeTextHeight )
{
float yOffset( 0.f );
switch( verticalTextAlignment )
return yOffset;
}
-float CalculateJustificationOffset( const Toolkit::TextView::LineJustification justification, const float wholeTextWidth, const float lineLength )
+float CalculateJustificationOffset( Toolkit::TextView::LineJustification justification, float wholeTextWidth, float lineLength )
{
float offset = 0.f;
switch( justification )
return offset;
}
-bool IsVisible( const Vector3& position, const Size& size, const Size& parentSize, const VisibilityTestType type )
+bool IsVisible( const Vector3& position, const Size& size, const Size& parentSize, VisibilityTestType type )
{
bool visible = false;
std::size_t lineJustificationIndex = 0u; // Index to the first position of the vector which stores all line justification info.
std::size_t infoTableCharacterIndex = 0u;
- relayoutParameters.mIndices.mLineIndex = 0u;
+ relayoutParameters.mIndices.mParagraphIndex = 0u;
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
- endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineLayoutIt != endLineLayoutIt;
- ++lineLayoutIt, ++relayoutParameters.mIndices.mLineIndex )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(),
+ endParagraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphLayoutIt != endParagraphLayoutIt;
+ ++paragraphLayoutIt, ++relayoutParameters.mIndices.mParagraphIndex )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphLayoutIt );
float justificationOffset = 0.f;
relayoutParameters.mIndices.mWordIndex = 0u;
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
- endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin(),
+ endWordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
wordLayoutIt != endWordLayoutIt;
++wordLayoutIt, ++relayoutParameters.mIndices.mWordIndex )
{
positionOffset.x += characterLayoutInfo.mAdvance * relayoutData.mShrinkFactor;
} // end characters
} // end words
- } // end lines
+ } // end paragraphs
}
void CalculateBearing( TextViewProcessor::CharacterLayoutInfo& characterLayoutInfo,
const Toolkit::TextView::CharacterLayoutInfo characterLayoutTableInfo( Size( characterLayoutInfo.mAdvance * relayoutData.mShrinkFactor,
characterLayoutInfo.mHeight * relayoutData.mShrinkFactor ),
positionOffset,
- ( TextViewProcessor::LineSeparator == wordLayoutInfo.mType ),
+ ( TextViewProcessor::ParagraphSeparator == wordLayoutInfo.mType ),
false, // VCC set the correct direction if needed.
true,
descender );
EllipsizeParameters& ellipsizeParameters,
TextView::RelayoutData& relayoutData )
{
- // Traverses the text layout info from the first character of the laid out line
+ // Traverses the text layout info from the first character of the line
// to the last one setting to each character its visibility. If needed, it adds the ellipsize text (...).
- // Indices to the first character of the laid out line.
+ // Indices to the first character of the line.
TextViewProcessor::TextInfoIndices firstIndices;
TextViewProcessor::GetIndicesFromGlobalCharacterIndex( ellipsizeParameters.mFirstIndex,
relayoutData.mTextLayoutInfo,
firstIndices );
- // Indices to the last character of the laid out line.
+ // Indices to the last character of the line.
TextViewProcessor::TextInfoIndices lastIndices;
TextViewProcessor::GetIndicesFromGlobalCharacterIndex( ellipsizeParameters.mLastIndex,
relayoutData.mTextLayoutInfo,
ellipsizeParameters.mEllipsizeBoundary = relayoutData.mTextViewSize;
ellipsizeParameters.mEllipsizeBoundary.width -= relayoutData.mTextLayoutInfo.mEllipsizeLayoutInfo.mSize.width;
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + firstIndices.mLineIndex,
- endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + lastIndices.mLineIndex + 1u;
- lineLayoutIt != endLineLayoutIt;
- ++lineLayoutIt )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + firstIndices.mParagraphIndex,
+ endParagraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + lastIndices.mParagraphIndex + 1u;
+ paragraphLayoutIt != endParagraphLayoutIt;
+ ++paragraphLayoutIt )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphLayoutIt );
ellipsizeParameters.mLineFits = ellipsizeParameters.mIsLineWidthFullyVisible && ellipsizeParameters.mIsLineHeightFullyVisible && ellipsizeParameters.mIsNextLineFullyVisibleHeight;
std::size_t wordCount = 0u;
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin() + firstIndices.mWordIndex,
- endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin() + lastIndices.mWordIndex + 1u;
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin() + firstIndices.mWordIndex,
+ endWordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin() + lastIndices.mWordIndex + 1u;
wordLayoutIt != endWordLayoutIt;
++wordLayoutIt, ++wordCount )
{
} // end characters
firstWord = false;
} // end words
- } // end lines
+ } // end paragraphs
}
void SetTextVisible( TextView::RelayoutData& relayoutData )
{
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
- endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineLayoutIt != endLineLayoutIt;
- ++lineLayoutIt )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(),
+ endParagraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphLayoutIt != endParagraphLayoutIt;
+ ++paragraphLayoutIt )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphLayoutIt );
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
- endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin(),
+ endWordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
wordLayoutIt != endWordLayoutIt;
++wordLayoutIt )
{
characterLayoutInfo.mColorAlpha = characterLayoutInfo.mStyledText.mStyle.GetTextColor().a;
} // end characters
} // end words
- } // end lines
+ } // end paragraphs
// Updates the visibility for text-input..
for( std::vector<Toolkit::TextView::CharacterLayoutInfo>::iterator it = relayoutData.mCharacterLayoutInfoTable.begin(),
std::size_t infoTableCharacterIndex = 0u;
- relayoutParameters.mIndices.mLineIndex = 0u;
+ relayoutParameters.mIndices.mParagraphIndex = 0u;
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
- endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineLayoutIt != endLineLayoutIt;
- ++lineLayoutIt, ++relayoutParameters.mIndices.mLineIndex )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(),
+ endParagraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphLayoutIt != endParagraphLayoutIt;
+ ++paragraphLayoutIt, ++relayoutParameters.mIndices.mParagraphIndex )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphLayoutIt );
relayoutParameters.mIndices.mWordIndex = 0u;
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
- endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin(),
+ endWordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
wordLayoutIt != endWordLayoutIt;
++wordLayoutIt, ++relayoutParameters.mIndices.mWordIndex )
{
relayoutParameters.mIsFirstCharacterOfWord = false;
} // end character
} // end words
- } // end lines
+ } // end paragraphs
}
void UpdateVisibilityForEllipsize( const TextView::LayoutParameters& layoutParameters,
const TextView::VisualParameters& visualParameters,
TextView::RelayoutData& relayoutData )
{
- // Traverses the laid-out lines and checks which ones doesn't fit in the text-view's boundary.
+ // Traverses the lines and checks which ones doesn't fit in the text-view's boundary.
for( Toolkit::TextView::LineLayoutInfoContainer::const_iterator lineInfoIt = relayoutData.mLines.begin(), endLineInfoIt = relayoutData.mLines.end();
lineInfoIt != endLineInfoIt;
++lineInfoIt )
{
const Toolkit::TextView::LineLayoutInfo& lineInfo( *lineInfoIt );
- // To check if a laid-out line fits in the text-view's boundary,
+ // To check if a line fits in the text-view's boundary,
// get the position of the first character is needed and do the test
- // with the laid-out line size.
+ // with the line size.
// An bearing offset may have been applied to the first character so it's needed to
// get the start position of the line.
*
* @param[in] visualParameters Some visual parameters (fade, sort modifier and blending).
* @param[in,out] relayoutData Natural size (metrics), layout, text-actor info.
- * @param[in,out] line Layout info for the line.
+ * @param[in,out] paragraph Layout info for the paragraph.
* @param[in,out] characterLayout Layout info for the character.
* @param[in] character The character.
* @param[in] style The character's style.
*/
void CreateTextActor( const TextView::VisualParameters& visualParameters,
TextView::RelayoutData& relayoutData,
- const TextViewProcessor::LineLayoutInfo& line,
+ const TextViewProcessor::ParagraphLayoutInfo& paragraph,
TextViewProcessor::CharacterLayoutInfo& characterLayout,
const Character& character,
const TextStyle& style,
SetVisualParameters( currentTextActorInfo,
visualParameters,
relayoutData,
- line.mSize.height );
+ paragraph.mSize.height );
}
currentTextActorInfo.text = Text( character );
}
/**
- * Traverses the whole line initializating renderable-actor handles and updating them with the new size and position.
+ * Traverses the whole paragraph initializating renderable-actor handles and updating them with the new size and position.
*
* @param[in] visualParameters Some visual parameters (fade, sort modifier and blending).
* @param[in,out] relayoutData Natural size (metrics), layout, text-actor info.
- * @param[in,out] line Layout info for the line.
+ * @param[in,out] paragraph Layout info for the paragraph.
* @param[in,out] characterGlobalIndex Index to the character within the whole text.
- * @param[in,out] lineLayoutInfoIndex Index to the table of laid out lines.
+ * @param[in,out] lineLayoutInfoIndex Index to the table of lines.
* @param[in,out] createGlyphActors Whether to initialize renderable-actor handles.
*/
-void UpdateTextActorInfoForLine( const TextView::VisualParameters& visualParameters,
- TextView::RelayoutData& relayoutData,
- TextViewProcessor::LineLayoutInfo& line,
- std::size_t& characterGlobalIndex,
- std::size_t& lineLayoutInfoIndex,
- bool createGlyphActors )
+void UpdateTextActorInfoForParagraph( const TextView::VisualParameters& visualParameters,
+ TextView::RelayoutData& relayoutData,
+ TextViewProcessor::ParagraphLayoutInfo& paragraph,
+ std::size_t& characterGlobalIndex,
+ std::size_t& lineLayoutInfoIndex,
+ bool createGlyphActors )
{
CurrentTextActorInfo currentTextActorInfo;
- const std::size_t lineLayoutInfoSize = relayoutData.mLines.size(); // Number of laid out lines.
- bool lineLayoutEnd = false; // Whether lineLayoutInfoIndex points at the last laid out line.
+ const std::size_t lineLayoutInfoSize = relayoutData.mLines.size(); // Number of lines.
+ bool lineLayoutEnd = false; // Whether lineLayoutInfoIndex points at the last line.
bool glyphActorCreatedForLine = false; // Whether a renderable actor has been created for this line.
TextStyle currentStyle; // style for the current text-actor.
std::vector<TextActor> textActorsToRemove; // Keep a vector of text-actors to be included into the cache.
- std::size_t characterLineIndex = 0u; // Index to the character (within the line).
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = line.mWordsLayoutInfo.begin(), wordEndIt = line.mWordsLayoutInfo.end();
+ std::size_t characterParagraphIndex = 0u; // Index to the character (within the paragraph).
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = paragraph.mWordsLayoutInfo.begin(), wordEndIt = paragraph.mWordsLayoutInfo.end();
wordIt != wordEndIt;
++wordIt )
{
bool appendCharacter = false;
if( characterLayout.mIsColorGlyph ||
- !character.IsWhiteSpace() || // A new line character is also a white space.
+ !character.IsWhiteSpace() || // A new paragraph character is also a white space.
( character.IsWhiteSpace() && style.IsUnderlineEnabled() ) )
{
- // Do not create a glyph-actor if it's a white space (without underline) or a new line character.
+ // Do not create a glyph-actor if it's a white space (without underline) or a new paragraph character.
// Creates one glyph-actor for each counsecutive group of characters, with the same style, per line, or if it's an emoticon.
{
CreateTextActor( visualParameters,
relayoutData,
- line,
+ paragraph,
characterLayout,
character,
style,
characterLayout.mGlyphActor.Reset();
}
}
- } // no white space / new line char
+ } // no white space / new paragraph char
else
{
appendCharacter = true;
if( appendCharacter )
{
// Add the character to the current text-actor and update the size.
- if( characterLayout.mIsVisible && ( TextViewProcessor::LineSeparator != word.mType ) )
+ if( characterLayout.mIsVisible && ( TextViewProcessor::ParagraphSeparator != word.mType ) )
{
currentTextActorInfo.text.Append( character );
}
++characterGlobalIndex;
- ++characterLineIndex;
+ ++characterParagraphIndex;
} // characters
} // words
SetVisualParameters( currentTextActorInfo,
visualParameters,
relayoutData,
- line.mSize.height );
+ paragraph.mSize.height );
}
}
TextView::RelayoutData& relayoutData,
bool createGlyphActors )
{
- if( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
+ if( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.empty() )
{
- // nothing to do if there is no lines.
+ // nothing to do if there is no paragraphs.
return;
}
std::size_t characterGlobalIndex = 0u; // Index to the global character (within the whole text).
- std::size_t lineLayoutInfoIndex = 0u; // Index to the laid out line info.
+ std::size_t lineLayoutInfoIndex = 0u; // Index to the line info.
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(), lineEndIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineIt != lineEndIt;
- ++lineIt )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(), paragraphEndIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphIt != paragraphEndIt;
+ ++paragraphIt )
{
- TextViewProcessor::LineLayoutInfo& line( *lineIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraph( *paragraphIt );
- UpdateTextActorInfoForLine( visualParameters,
- relayoutData,
- line,
- characterGlobalIndex,
- lineLayoutInfoIndex,
- createGlyphActors );
- } // lines
+ UpdateTextActorInfoForParagraph( visualParameters,
+ relayoutData,
+ paragraph,
+ characterGlobalIndex,
+ lineLayoutInfoIndex,
+ createGlyphActors );
+ } // paragraphs
for( std::vector<RenderableActor>::iterator it = relayoutData.mEllipsizedGlyphActors.begin(),
endIt = relayoutData.mEllipsizedGlyphActors.end();
void CalculateUnderlineInfo( TextView::RelayoutData& relayoutData, TextViewRelayout::TextUnderlineStatus& textUnderlineStatus )
{
- // Traverse the whole text to find all groups of consecutive underlined characters in the same laid-out line.
+ // Traverse the whole text to find all groups of consecutive underlined characters in the same line.
//
- // Note that relayoutData.mTextLayoutInfo contains layout info per line but these lines are the result of split the whole text every time a '\n' is found.
- // According with the layout option, one of this lines could be laid-out in more than one.
+ // Note that relayoutData.mTextLayoutInfo contains layout info per paragraph but these paragraphs are the result of split the whole text every time a '\n' is found.
+ // According with the layout option, one of this paragraphs could be laid-out in more than one line.
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(), lineEndIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineIt != lineEndIt;
- ++lineIt )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(), paragraphEndIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphIt != paragraphEndIt;
+ ++paragraphIt )
{
- TextViewProcessor::LineLayoutInfo& line( *lineIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraph( *paragraphIt );
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = line.mWordsLayoutInfo.begin(), wordEndIt = line.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = paragraph.mWordsLayoutInfo.begin(), wordEndIt = paragraph.mWordsLayoutInfo.end();
wordIt != wordEndIt;
++wordIt )
{
{
TextViewProcessor::CharacterLayoutInfo& character( *characterIt );
- // Check if current character is the first of a new laid-out line
+ // Check if current character is the first of a new line
const bool isNewLine = ( textUnderlineStatus.mLineGlobalIndex < relayoutData.mLines.size() ) &&
( textUnderlineStatus.mCharacterGlobalIndex == ( *( relayoutData.mLines.begin() + textUnderlineStatus.mLineGlobalIndex ) ).mCharacterGlobalIndex );
if( isNewLine )
if( character.mStyledText.mStyle.IsUnderlineEnabled() )
{
if( !textUnderlineStatus.mCurrentUnderlineStatus || // Current character is underlined but previous one it wasn't.
- isNewLine ) // Current character is underlined and is the first of current laid-out line.
+ isNewLine ) // Current character is underlined and is the first of current line.
{
// Create a new underline info for the current underlined characters.
UnderlineInfo underlineInfo;
++textUnderlineStatus.mCharacterGlobalIndex;
} // end characters.
} // end words.
- } // end lines.
+ } // end paragraphs.
}
void SetUnderlineInfo( TextView::RelayoutData& relayoutData )
{
- // Stores for each group of consecutive underlined characters in each laid-out line its maximum thicknes, its position of that thickness and the maximum character's height.
+ // Stores for each group of consecutive underlined characters in each line its maximum thicknes, its position of that thickness and the maximum character's height.
TextViewRelayout::TextUnderlineStatus textUnderlineStatus;
- // Traverse the whole text to find all groups of consecutive underlined characters in the same laid-out line.
+ // Traverse the whole text to find all groups of consecutive underlined characters in the same line.
CalculateUnderlineInfo( relayoutData, textUnderlineStatus );
if( textUnderlineStatus.mUnderlineInfo.empty() )
float currentLineHeight = 0.f;
float currentLineAscender = 0.f;
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(), lineEndIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineIt != lineEndIt;
- ++lineIt )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(), paragraphEndIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphIt != paragraphEndIt;
+ ++paragraphIt )
{
- TextViewProcessor::LineLayoutInfo& line( *lineIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraph( *paragraphIt );
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = line.mWordsLayoutInfo.begin(), wordEndIt = line.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = paragraph.mWordsLayoutInfo.begin(), wordEndIt = paragraph.mWordsLayoutInfo.end();
wordIt != wordEndIt;
++wordIt )
{
{
TextViewProcessor::CharacterLayoutInfo& character( *characterIt );
- // Check if current character is the first of a new laid-out line
+ // Check if current character is the first of a new line
bool isNewLine = false;
++textUnderlineStatus.mCharacterGlobalIndex;
} // end of characters.
} // end of word.
- } // end of lines.
+ } // end of paragraphs.
}
void RemoveGlyphActors( Actor textView,
{
// Add text-actors to the text-view.
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
- endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineLayoutIt != endLineLayoutIt;
- ++lineLayoutIt )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(),
+ endParagraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphLayoutIt != endParagraphLayoutIt;
+ ++paragraphLayoutIt )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphLayoutIt );
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
- endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin(),
+ endWordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
wordLayoutIt != endWordLayoutIt;
++wordLayoutIt )
{
}
} // end character
} // end words
- } // end lines
+ } // end paragraphs
for( std::vector<RenderableActor>::iterator it = relayoutData.mEllipsizedGlyphActors.begin(),
endIt = relayoutData.mEllipsizedGlyphActors.end();
extern const float MINIMUM_FADE_BOUNDARY; // When the fade boundary is the same as the text-view boundary, this constant reduces it in order to avoid a zero division.
/**
- * Define the type of line wrap.
+ * Define how to wrap a paragraph in lines.
*/
enum HorizontalWrapType
{
- WrapByCharacter, ///< Wrap a line per character (It may split a word in two).
- WrapByWord, ///< Wrap a line by word.
- WrapByWordAndSplit, ///< Wrap the line by word and split a word if it doesn't fit.
- WrapByLine, ///< Wrap the line when a \n is found.
- WrapByLineAndSplit ///< Wrap the line when a \n is found and split if it doesn't fit.
+ WrapByCharacter, ///< Wrap the paragraph per character (It may split a word in two).
+ WrapByWord, ///< Wrap the paragraph by word.
+ WrapByWordAndSplit, ///< Wrap the paragraph by word and split a word if it doesn't fit.
+ WrapByParagraphCharacter, ///< Wrap the paragraph when a '\n' is found.
+ WrapByParagraphCharacterAndSplit ///< Wrap the paragraph when a '\n' is found and split if it doesn't fit.
};
/**
*/
~RelayoutParameters();
- Vector3 mPositionOffset; ///< Offset (position.x + size.width, position.y, position.z) of the previous text-actor.
- Size mLineSize; ///< Current line's size.
- Size mWordSize; ///< Current word's size.
- Size mCharacterSize; ///< Current character's size.
- TextViewProcessor::TextInfoIndices mIndices; ///< Current indices to line, word and character.
- std::size_t mCharacterGlobalIndex; ///< Index to a single character within the whole text.
- bool mIsFirstCharacter:1; ///< Whether is the first character of the whole text.
- bool mIsFirstCharacterOfWord:1; ///< Whether is the first character of the word.
- bool mIsNewLine:1; ///< Whether the current character is the first character of a new line.
- bool mIsNewLineCharacter:1; ///< Whether the current character is a new line character.
- bool mIsWhiteSpace:1; ///< Whether the current character is a white space.
- bool mIsVisible:1; ///< Whether the current character is visible.
+ Vector3 mPositionOffset; ///< Offset (position.x + size.width, position.y, position.z) of the previous text-actor.
+ Size mParagraphSize; ///< Current paragraphs's size.
+ Size mWordSize; ///< Current word's size.
+ Size mCharacterSize; ///< Current character's size.
+ TextViewProcessor::TextInfoIndices mIndices; ///< Current indices to paragraph, word and character.
+ std::size_t mCharacterGlobalIndex; ///< Index to a single character within the whole text.
+ bool mIsFirstCharacter:1; ///< Whether is the first character of the whole text.
+ bool mIsFirstCharacterOfWord:1; ///< Whether is the first character of the word.
+ bool mIsNewLine:1; ///< Whether the current character is the first character of a new line.
+ bool mIsNewParagraphCharacter:1; ///< Whether the current character is a new paragraph character.
+ bool mIsWhiteSpace:1; ///< Whether the current character is a white space.
+ bool mIsVisible:1; ///< Whether the current character is visible.
};
/**
Vector3 mPosition; ///< Position of the first character of the ellipsize text.
float mLineDescender; ///< Distance from the base line to the bottom.
- float mLineWidth; ///< Current laid out line's width.
+ float mLineWidth; ///< Current line's width.
Size mEllipsizeBoundary; ///< Where to start to ellipsize a line.
- std::size_t mFirstIndex; ///< Global index within the whole text of the first character of the laid out line.
- std::size_t mLastIndex; ///< Global index within the whole text of the last character of the laid out line.
+ std::size_t mFirstIndex; ///< Global index within the whole text of the first character of the line.
+ std::size_t mLastIndex; ///< Global index within the whole text of the last character of the line.
bool mEllipsizeLine:1; ///< Whether current line must be ellipsized.
bool mIsLineWidthFullyVisible:1; ///< Whether current line fits in text-view's width.
bool mIsLineHeightFullyVisible:1; ///< Whether current line fits in text-view's height.
};
/**
- * Stores underline info for a group of consecutive characters in the same laid out line.
+ * Stores underline info for a group of consecutive characters in the same line.
*/
struct UnderlineInfo
{
std::vector<UnderlineInfo> mUnderlineInfo; ///< Underline info for each group of consecutive underlined characters.
std::size_t mCharacterGlobalIndex; ///< Global index (within the whole text) to current character.
- std::size_t mLineGlobalIndex; ///< Index to current laid out line. It takes into account the current layout configuration (is not the number of \n)
+ std::size_t mLineGlobalIndex; ///< Index to current line. It takes into account the current layout configuration (is not the number of \n)
bool mCurrentUnderlineStatus:1; ///< Whether current character is underlined.
};
/**
- * Stores layout information of the piece of a line.
+ * Stores layout information of a line.
*/
-struct SubLineLayoutInfo
+struct LineLayoutInfo
{
/**
* Default constructor.
*
* Initializes each member to its default.
*/
- SubLineLayoutInfo();
+ LineLayoutInfo();
/**
* Empty destructor.
*
* @note Added to increase coverage.
*/
- ~SubLineLayoutInfo();
+ ~LineLayoutInfo();
- float mLineLength; ///< The length of the portion of the line which fits on the text-view width.
- float mMaxCharHeight; ///< The maximum height of all characters of the portion of line which fits on the text-view width.
- float mMaxAscender; ///< The maximum ascender of all characters of the portion of line which fits on the text-view width.
+ float mLineLength; ///< The length of the portion of the paragraph which fits on the text-view width.
+ float mMaxCharHeight; ///< The maximum height of all characters of the portion of the paragraph which fits on the text-view width.
+ float mMaxAscender; ///< The maximum ascender of all characters of the portion of the paragraph which fits on the text-view width.
};
/**
- * Calculates the layout info of the portion of the line which fits on the text-view width.
+ * Calculates the layout info of the portion of the paragraph which fits on the text-view width.
*
* @param[in] parentWidth Text-view width
* @param[in] indices Indices to the word and character.
- * @param[in] lineLayoutInfo Layout info for the line.
- * @param[in] splitPolicy Whether a line is wraped by word, by character or by word and character.
+ * @param[in] paragraphLayoutInfo Layout info for the paragraph.
+ * @param[in] splitPolicy Whether a paragraph is wraped by word, by character or by word and character.
* @param[in] shrinkFactor Shrink factor used.
- * @param[out] layoutInfo Layout information of the part of the line which fits in the text-view width.
- */
-void CalculateSubLineLayout( float parentWidth,
- const TextViewProcessor::TextInfoIndices& indices,
- const TextViewProcessor::LineLayoutInfo& lineLayoutInfo,
- HorizontalWrapType splitPolicy,
- float shrinkFactor,
- SubLineLayoutInfo& layoutInfo );
+ * @param[out] layoutInfo Layout information of the part of the paragraph which fits in the text-view width.
+ */
+void CalculateLineLayout( float parentWidth,
+ const TextViewProcessor::TextInfoIndices& indices,
+ const TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo,
+ HorizontalWrapType splitPolicy,
+ float shrinkFactor,
+ LineLayoutInfo& layoutInfo );
/**
* Calculates the \e x offset position for the whole text.
( wordOffset + relayoutParameters.mCharacterSize.width > relayoutData.mTextViewSize.width ) ) )
{
if( !relayoutParameters.mIsNewLine &&
- ( relayoutParameters.mIsWhiteSpace || relayoutParameters.mIsNewLineCharacter ) )
+ ( relayoutParameters.mIsWhiteSpace || relayoutParameters.mIsNewParagraphCharacter ) )
{
// Current character is a white space. Don't want to move a white space to the next line.
// These white spaces are placed just in the edge.
else
{
// Calculate the line length and the max character height for the current line.
- TextViewRelayout::SubLineLayoutInfo subLineInfo;
+ TextViewRelayout::LineLayoutInfo subLineInfo;
subLineInfo.mLineLength = 0.f;
subLineInfo.mMaxCharHeight = 0.f;
subLineInfo.mMaxAscender = 0.f;
- const TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + relayoutParameters.mIndices.mLineIndex ) );
+ const TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + relayoutParameters.mIndices.mParagraphIndex ) );
- TextViewRelayout::CalculateSubLineLayout( relayoutData.mTextViewSize.width,
- relayoutParameters.mIndices,
- lineLayoutInfo,
- TextViewRelayout::WrapByCharacter,
- 1.f, // Shrink factor
- subLineInfo );
+ TextViewRelayout::CalculateLineLayout( relayoutData.mTextViewSize.width,
+ relayoutParameters.mIndices,
+ paragraphLayoutInfo,
+ TextViewRelayout::WrapByCharacter,
+ 1.f, // Shrink factor
+ subLineInfo );
// Stores some info to calculate the line justification in a post-process.
TextView::LineJustificationInfo justificationInfo;
Toolkit::TextView::LineLayoutInfo lineInfo;
lineInfo.mCharacterGlobalIndex = relayoutParameters.mCharacterGlobalIndex; // Index to the first character of the next line.
- lineInfo.mSize = Size( subLineInfo.mLineLength, subLineInfo.mMaxCharHeight ); // Size of this piece of line.
- lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of line.
+ lineInfo.mSize = Size( subLineInfo.mLineLength, subLineInfo.mMaxCharHeight ); // Size of this piece of paragraph.
+ lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of paragraph.
relayoutData.mLines.push_back( lineInfo );
return Vector3( 0.f, previousPositionY + subLineInfo.mMaxCharHeight + layoutParameters.mLineHeightOffset, 0.f );
relayoutParameters.mPositionOffset = Vector3::ZERO;
relayoutParameters.mIsFirstCharacter = true;
- relayoutParameters.mIndices.mLineIndex = 0u;
+ relayoutParameters.mIndices.mParagraphIndex = 0u;
relayoutParameters.mCharacterGlobalIndex = 0u;
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
- endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineLayoutIt != endLineLayoutIt;
- ++lineLayoutIt, ++relayoutParameters.mIndices.mLineIndex )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(),
+ endParagraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphLayoutIt != endParagraphLayoutIt;
+ ++paragraphLayoutIt, ++relayoutParameters.mIndices.mParagraphIndex )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphLayoutIt );
relayoutParameters.mIsNewLine = true;
- relayoutParameters.mLineSize = lineLayoutInfo.mSize;
+ relayoutParameters.mParagraphSize = paragraphLayoutInfo.mSize;
relayoutParameters.mIndices.mWordIndex = 0u;
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
- endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin(),
+ endWordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
wordLayoutIt != endWordLayoutIt;
++wordLayoutIt, ++relayoutParameters.mIndices.mWordIndex )
{
TextViewProcessor::WordLayoutInfo& wordLayoutInfo( *wordLayoutIt );
relayoutParameters.mIsWhiteSpace = TextViewProcessor::WordSeparator == wordLayoutInfo.mType;
- relayoutParameters.mIsNewLineCharacter = TextViewProcessor::LineSeparator == wordLayoutInfo.mType;
+ relayoutParameters.mIsNewParagraphCharacter = TextViewProcessor::ParagraphSeparator == wordLayoutInfo.mType;
relayoutParameters.mIsFirstCharacterOfWord = true;
relayoutParameters.mWordSize = wordLayoutInfo.mSize;
relayoutParameters.mIsNewLine = false;
} // end characters
} // end words
- } // end lines
+ } // end paragraphs
if( relayoutData.mCharacterLayoutInfoTable.empty() )
{
relayoutData.mTextSizeForRelayoutOption.height = minMaxXY.w - minMaxXY.y;
}
- // Check if the last character is a new line character. In that case the height should be added.
- if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
+ // Check if the last character is a new paragraph character. In that case the height should be added.
+ if( !relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.empty() )
{
- const TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u ) );
+ const TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end() - 1u ) );
- if( lineLayoutInfo.mWordsLayoutInfo.empty() ) // if it's empty, it means the last character is a new line character.
+ if( paragraphLayoutInfo.mWordsLayoutInfo.empty() ) // if it's empty, it means the last character is a new paragraph character.
{
- relayoutData.mTextSizeForRelayoutOption.height += lineLayoutInfo.mSize.height;
+ relayoutData.mTextSizeForRelayoutOption.height += paragraphLayoutInfo.mSize.height;
}
}
}
( wordOffset + relayoutParameters.mCharacterSize.width > relayoutData.mTextViewSize.width ) )
{
if( !relayoutParameters.mIsNewLine &&
- ( relayoutParameters.mIsWhiteSpace || relayoutParameters.mIsNewLineCharacter ) )
+ ( relayoutParameters.mIsWhiteSpace || relayoutParameters.mIsNewParagraphCharacter ) )
{
// Current character is a white space. Don't want to move a white space to the next line.
// These white spaces are placed just in the edge.
}
else
{
- const TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + relayoutParameters.mIndices.mLineIndex ) );
+ const TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + relayoutParameters.mIndices.mParagraphIndex ) );
- TextViewRelayout::SubLineLayoutInfo subLineInfo;
+ TextViewRelayout::LineLayoutInfo subLineInfo;
subLineInfo.mLineLength = 0.f;
subLineInfo.mMaxCharHeight = 0.f;
subLineInfo.mMaxAscender = 0.f;
- TextViewRelayout::CalculateSubLineLayout( relayoutData.mTextViewSize.width,
- relayoutParameters.mIndices,
- lineLayoutInfo,
- TextViewRelayout::WrapByLineAndSplit,
- 1.f, // Shrink factor
- subLineInfo );
+ TextViewRelayout::CalculateLineLayout( relayoutData.mTextViewSize.width,
+ relayoutParameters.mIndices,
+ paragraphLayoutInfo,
+ TextViewRelayout::WrapByParagraphCharacterAndSplit,
+ 1.f, // Shrink factor
+ subLineInfo );
// Stores some info to calculate the line justification in a post-process.
TextView::LineJustificationInfo justificationInfo;
Toolkit::TextView::LineLayoutInfo lineInfo;
lineInfo.mCharacterGlobalIndex = relayoutParameters.mCharacterGlobalIndex; // Index to the first character of the next line.
- lineInfo.mSize = Size( subLineInfo.mLineLength, subLineInfo.mMaxCharHeight ); // Size of this piece of line.
- lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of line.
+ lineInfo.mSize = Size( subLineInfo.mLineLength, subLineInfo.mMaxCharHeight ); // Size of this piece of paragraph.
+ lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of paragraph.
relayoutData.mLines.push_back( lineInfo );
return Vector3( 0.f, previousPositionY + subLineInfo.mMaxCharHeight + layoutParameters.mLineHeightOffset, 0.f );
}
relayoutParameters.mIsFirstCharacter = true;
- relayoutParameters.mIndices.mLineIndex = 0u;
+ relayoutParameters.mIndices.mParagraphIndex = 0u;
relayoutParameters.mPositionOffset = Vector3::ZERO;
relayoutParameters.mCharacterGlobalIndex = 0u;
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
- endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineLayoutIt != endLineLayoutIt;
- ++lineLayoutIt, ++relayoutParameters.mIndices.mLineIndex )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(),
+ endParagraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphLayoutIt != endParagraphLayoutIt;
+ ++paragraphLayoutIt, ++relayoutParameters.mIndices.mParagraphIndex )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphLayoutIt );
- relayoutParameters.mLineSize = lineLayoutInfo.mSize * relayoutData.mShrinkFactor;
+ relayoutParameters.mParagraphSize = paragraphLayoutInfo.mSize * relayoutData.mShrinkFactor;
relayoutParameters.mIsNewLine = true;
relayoutParameters.mIndices.mWordIndex = 0u;
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
- endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin(),
+ endWordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
wordLayoutIt != endWordLayoutIt;
++wordLayoutIt, ++relayoutParameters.mIndices.mWordIndex )
{
TextViewProcessor::WordLayoutInfo& wordLayoutInfo( *wordLayoutIt );
relayoutParameters.mIsWhiteSpace = TextViewProcessor::WordSeparator == wordLayoutInfo.mType;
- relayoutParameters.mIsNewLineCharacter = TextViewProcessor::LineSeparator == wordLayoutInfo.mType;
+ relayoutParameters.mIsNewParagraphCharacter = TextViewProcessor::ParagraphSeparator == wordLayoutInfo.mType;
relayoutParameters.mIsFirstCharacterOfWord = true;
relayoutParameters.mWordSize = wordLayoutInfo.mSize;
TextView::LineJustificationInfo justificationInfo;
justificationInfo.mIndices = relayoutParameters.mIndices;
- justificationInfo.mLineLength = relayoutParameters.mLineSize.width;
+ justificationInfo.mLineLength = relayoutParameters.mParagraphSize.width;
relayoutData.mLineJustificationInfo.push_back( justificationInfo );
}
if( relayoutParameters.mIsNewLine )
{
relayoutParameters.mPositionOffset.x = 0.f;
- relayoutParameters.mPositionOffset.y += lineLayoutInfo.mSize.height * relayoutData.mShrinkFactor;
+ relayoutParameters.mPositionOffset.y += paragraphLayoutInfo.mSize.height * relayoutData.mShrinkFactor;
}
characterLayoutInfo.mPosition = relayoutParameters.mPositionOffset;
relayoutParameters.mIsFirstCharacter )
{
Toolkit::TextView::LineLayoutInfo lineInfo;
- lineInfo.mCharacterGlobalIndex = relayoutParameters.mCharacterGlobalIndex; // Index to the first character of the next line.
- lineInfo.mSize = relayoutParameters.mLineSize; // Size of this piece of line.
- lineInfo.mAscender = lineLayoutInfo.mAscender * relayoutData.mShrinkFactor; // Ascender of this piece of line.
+ lineInfo.mCharacterGlobalIndex = relayoutParameters.mCharacterGlobalIndex; // Index to the first character of the next line.
+ lineInfo.mSize = relayoutParameters.mParagraphSize; // Size of this piece of paragraph.
+ lineInfo.mAscender = paragraphLayoutInfo.mAscender * relayoutData.mShrinkFactor; // Ascender of this piece of paragraph.
relayoutData.mLines.push_back( lineInfo );
}
break;
relayoutParameters.mIsNewLine = false;
} // end characters
} // end words
- } // end lines
+ } // end paragraphs
if( relayoutData.mCharacterLayoutInfoTable.empty() )
{
relayoutData.mTextSizeForRelayoutOption.height = minMaxXY.w - minMaxXY.y;
}
- // Check if the last character is a new line character. In that case the height should be added.
- if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
+ // Check if the last character is a new paragraph character. In that case the height should be added.
+ if( !relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.empty() )
{
- const TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u ) );
+ const TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end() - 1u ) );
- if( lineLayoutInfo.mWordsLayoutInfo.empty() ) // if it's empty, it means the last character is a new line character.
+ if( paragraphLayoutInfo.mWordsLayoutInfo.empty() ) // if it's empty, it means the last character is a new paragraph character.
{
- relayoutData.mTextSizeForRelayoutOption.height += lineLayoutInfo.mSize.height * relayoutData.mShrinkFactor;
+ relayoutData.mTextSizeForRelayoutOption.height += paragraphLayoutInfo.mSize.height * relayoutData.mShrinkFactor;
}
}
}
( relayoutParameters.mIsFirstCharacterOfWord && ( wordOffset + relayoutParameters.mWordSize.width > relayoutData.mTextViewSize.width ) ) )
{
if( !relayoutParameters.mIsNewLine &&
- ( relayoutParameters.mIsWhiteSpace || relayoutParameters.mIsNewLineCharacter ) )
+ ( relayoutParameters.mIsWhiteSpace || relayoutParameters.mIsNewParagraphCharacter ) )
{
// Current character is a white space. Don't want to move a white space to the next line.
// These white spaces are placed just in the edge.
}
else
{
- // Calculates the length of the portion of the line which doesn't exceed the text-view's width and the max character height for the current line.
- TextViewRelayout::SubLineLayoutInfo subLineInfo;
+ // Calculates the length of the portion of the paragraph which doesn't exceed the text-view's width and the max character height for the current line.
+ TextViewRelayout::LineLayoutInfo subLineInfo;
subLineInfo.mLineLength = 0.f;
subLineInfo.mMaxCharHeight = 0.f;
subLineInfo.mMaxAscender = 0.f;
- const TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + relayoutParameters.mIndices.mLineIndex ) );
+ const TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + relayoutParameters.mIndices.mParagraphIndex ) );
- TextViewRelayout::CalculateSubLineLayout( relayoutData.mTextViewSize.width,
- relayoutParameters.mIndices,
- lineLayoutInfo,
- TextViewRelayout::WrapByWord,
- 1.f, // Shrink factor
- subLineInfo );
+ TextViewRelayout::CalculateLineLayout( relayoutData.mTextViewSize.width,
+ relayoutParameters.mIndices,
+ paragraphLayoutInfo,
+ TextViewRelayout::WrapByWord,
+ 1.f, // Shrink factor
+ subLineInfo );
if( subLineInfo.mLineLength < Math::MACHINE_EPSILON_1000 )
{
// It may mean there is a word which is actually longer than the width of the text-view.
// In that case the length of this word is needed.
- if( !lineLayoutInfo.mWordsLayoutInfo.empty() )
+ if( !paragraphLayoutInfo.mWordsLayoutInfo.empty() )
{
- const TextViewProcessor::WordLayoutInfo& wordLayoutInfo( *( lineLayoutInfo.mWordsLayoutInfo.begin() + relayoutParameters.mIndices.mWordIndex ) );
+ const TextViewProcessor::WordLayoutInfo& wordLayoutInfo( *( paragraphLayoutInfo.mWordsLayoutInfo.begin() + relayoutParameters.mIndices.mWordIndex ) );
subLineInfo.mLineLength = wordLayoutInfo.mSize.width;
}
}
Toolkit::TextView::LineLayoutInfo lineInfo;
lineInfo.mCharacterGlobalIndex = relayoutParameters.mCharacterGlobalIndex; // Index to the first character of the next line.
- lineInfo.mSize = Size( subLineInfo.mLineLength, subLineInfo.mMaxCharHeight ); // Size of this piece of line.
- lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of line.
+ lineInfo.mSize = Size( subLineInfo.mLineLength, subLineInfo.mMaxCharHeight ); // Size of this piece of paragraph.
+ lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of paragraph.
relayoutData.mLines.push_back( lineInfo );
return Vector3( 0.f, previousPositionY + subLineInfo.mMaxCharHeight + layoutParameters.mLineHeightOffset, 0.f );
( wordOffset + relayoutParameters.mCharacterSize.width > relayoutData.mTextViewSize.width ) )
{
if( !relayoutParameters.mIsNewLine &&
- ( relayoutParameters.mIsWhiteSpace || relayoutParameters.mIsNewLineCharacter ) )
+ ( relayoutParameters.mIsWhiteSpace || relayoutParameters.mIsNewParagraphCharacter ) )
{
// Current character is a white space. Don't want to move a white space to the next line.
// These white spaces are placed just in the edge.
else
{
// Calculates the line length and the max character height for the current line.
- TextViewRelayout::SubLineLayoutInfo subLineInfo;
+ TextViewRelayout::LineLayoutInfo subLineInfo;
subLineInfo.mLineLength = 0.f;
subLineInfo.mMaxCharHeight = 0.f;
subLineInfo.mMaxAscender = 0.f;
- const TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + relayoutParameters.mIndices.mLineIndex ) );
+ const TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + relayoutParameters.mIndices.mParagraphIndex ) );
- TextViewRelayout::CalculateSubLineLayout( relayoutData.mTextViewSize.width,
- relayoutParameters.mIndices,
- lineLayoutInfo,
- TextViewRelayout::WrapByWordAndSplit,
- 1.f, // Shrink factor.
- subLineInfo );
+ TextViewRelayout::CalculateLineLayout( relayoutData.mTextViewSize.width,
+ relayoutParameters.mIndices,
+ paragraphLayoutInfo,
+ TextViewRelayout::WrapByWordAndSplit,
+ 1.f, // Shrink factor.
+ subLineInfo );
// Stores some info to calculate the line justification in a post-process.
TextView::LineJustificationInfo justificationInfo;
Toolkit::TextView::LineLayoutInfo lineInfo;
lineInfo.mCharacterGlobalIndex = relayoutParameters.mCharacterGlobalIndex; // Index to the first character of the next line.
- lineInfo.mSize = Size( subLineInfo.mLineLength, subLineInfo.mMaxCharHeight ); // Size of this piece of line.
- lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of line.
+ lineInfo.mSize = Size( subLineInfo.mLineLength, subLineInfo.mMaxCharHeight ); // Size of this piece of paragraph.
+ lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of paragraph.
relayoutData.mLines.push_back( lineInfo );
return Vector3( 0.f, previousPositionY + subLineInfo.mMaxCharHeight + layoutParameters.mLineHeightOffset, 0.f );
( relayoutParameters.mIsFirstCharacterOfWord && ( wordOffset + wordSize.width > relayoutData.mTextViewSize.width ) ) ) // The word doesn't fit in the parent width.
{
if( !relayoutParameters.mIsNewLine &&
- ( relayoutParameters.mIsWhiteSpace || relayoutParameters.mIsNewLineCharacter ) )
+ ( relayoutParameters.mIsWhiteSpace || relayoutParameters.mIsNewParagraphCharacter ) )
{
// Current character is a white space. Don't want to move a white space to the next line.
// These white spaces are placed just in the edge.
else
{
// Calculates the line length and the max character height for the current line.
- TextViewRelayout::SubLineLayoutInfo subLineInfo;
+ TextViewRelayout::LineLayoutInfo subLineInfo;
subLineInfo.mLineLength = 0.f;
subLineInfo.mMaxCharHeight = 0.f;
subLineInfo.mMaxAscender = 0.f;
- const TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + relayoutParameters.mIndices.mLineIndex ) );
+ const TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + relayoutParameters.mIndices.mParagraphIndex ) );
- TextViewRelayout::CalculateSubLineLayout( relayoutData.mTextViewSize.width,
- relayoutParameters.mIndices,
- lineLayoutInfo,
- TextViewRelayout::WrapByWord,
- relayoutData.mShrinkFactor,
- subLineInfo );
+ TextViewRelayout::CalculateLineLayout( relayoutData.mTextViewSize.width,
+ relayoutParameters.mIndices,
+ paragraphLayoutInfo,
+ TextViewRelayout::WrapByWord,
+ relayoutData.mShrinkFactor,
+ subLineInfo );
// Stores some info to calculate the line justification in a post-process.
TextView::LineJustificationInfo justificationInfo;
Toolkit::TextView::LineLayoutInfo lineInfo;
lineInfo.mCharacterGlobalIndex = relayoutParameters.mCharacterGlobalIndex; // Index to the first character of the next line.
- lineInfo.mSize = Size( subLineInfo.mLineLength, subLineInfo.mMaxCharHeight ); // Size of this piece of line.
- lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of line.
+ lineInfo.mSize = Size( subLineInfo.mLineLength, subLineInfo.mMaxCharHeight ); // Size of this piece of paragraph.
+ lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of paragraph.
relayoutData.mLines.push_back( lineInfo );
return Vector3( 0.f, previousPositionY + subLineInfo.mMaxCharHeight + layoutParameters.mLineHeightOffset * relayoutData.mShrinkFactor, 0.f );
// Stores the position of the previous character.
Vector3 previousPosition;
- // Reset the index of lines.
+ // Reset the index of paragraphs.
TextViewProcessor::TextInfoIndices indices;
- // Whether the last character of the whole text is a new line char.
+ // Whether the last character of the whole text is a new paragraph char.
// This information is used to increase or not the height of the whole text by one line.
// Increase the whole text's height by one line is useful i.e. in TextInput to place the cursor
- // after pressing 'Enter' in the last line.
- bool isLastCharacterNewLineChar = false;
+ // after pressing 'Enter' in the last paragraph.
+ bool isLastCharacterNewParagraphChar = false;
// Stores the height of the last character. This height used to be added to the whole text height if
- // isLastCharacterNewLineChar is true.
+ // isLastCharacterNewParagraphChar is true.
float lastCharHeight = 0.f;
relayoutData.mLines.clear();
std::size_t characterGlobalIndex = 0u;
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineIt = textLayoutInfo.mLinesLayoutInfo.begin(), lineEndIt = textLayoutInfo.mLinesLayoutInfo.end();
- lineIt != lineEndIt;
- ++lineIt, ++indices.mLineIndex )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphIt = textLayoutInfo.mParagraphsLayoutInfo.begin(), paragraphEndIt = textLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphIt != paragraphEndIt;
+ ++paragraphIt, ++indices.mParagraphIndex )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphIt );
// The next character is in a new line.
bool isNewLine = true;
// Reset the index of words.
indices.mWordIndex = 0u;
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = lineLayoutInfo.mWordsLayoutInfo.begin(), wordEndIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = paragraphLayoutInfo.mWordsLayoutInfo.begin(), wordEndIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
wordIt != wordEndIt;
++wordIt, ++indices.mWordIndex )
{
bool isFirstCharOfWord = true;
const float wordOffset = previousPosition.x + previousSize.width;
- isLastCharacterNewLineChar = ( TextViewProcessor::LineSeparator == wordLayoutInfo.mType );
+ isLastCharacterNewParagraphChar = ( TextViewProcessor::ParagraphSeparator == wordLayoutInfo.mType );
for( TextViewProcessor::CharacterLayoutInfoContainer::iterator charIt = wordLayoutInfo.mCharactersLayoutInfo.begin(), charEndIt = wordLayoutInfo.mCharactersLayoutInfo.end();
charIt != charEndIt;
isFirstChar = false;
// Calculates the line length and the max character height for the current line.
- TextViewRelayout::SubLineLayoutInfo subLineInfo;
+ TextViewRelayout::LineLayoutInfo subLineInfo;
subLineInfo.mLineLength = 0.f;
subLineInfo.mMaxCharHeight = 0.f;
subLineInfo.mMaxAscender = 0.f;
- TextViewRelayout::CalculateSubLineLayout( parentWidth,
- indices,
- lineLayoutInfo,
- TextViewRelayout::WrapByWord,
- shrinkFactor,
- subLineInfo );
+ TextViewRelayout::CalculateLineLayout( parentWidth,
+ indices,
+ paragraphLayoutInfo,
+ TextViewRelayout::WrapByWord,
+ shrinkFactor,
+ subLineInfo );
characterLayoutInfo.mPosition = Vector3( 0.f, previousPositionY + subLineInfo.mMaxCharHeight + layoutParameters.mLineHeightOffset * shrinkFactor, 0.f );
Toolkit::TextView::LineLayoutInfo lineInfo;
lineInfo.mCharacterGlobalIndex = characterGlobalIndex; // Index to the first character of the next line.
- lineInfo.mSize = Size( subLineInfo.mLineLength, subLineInfo.mMaxCharHeight ); // Size of this piece of line.
- lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of line.
+ lineInfo.mSize = Size( subLineInfo.mLineLength, subLineInfo.mMaxCharHeight ); // Size of this piece of paragraph.
+ lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of paragraph.
relayoutData.mLines.push_back( lineInfo );
// Stores some info to calculate the line justification in a post-process.
}
}
- if( isLastCharacterNewLineChar )
+ if( isLastCharacterNewParagraphChar )
{
newTextHeight += lastCharHeight + layoutParameters.mLineHeightOffset * shrinkFactor;
}
relayoutParameters.mPositionOffset = Vector3::ZERO;
relayoutParameters.mIsFirstCharacter = true;
- relayoutParameters.mIndices.mLineIndex = 0u;
+ relayoutParameters.mIndices.mParagraphIndex = 0u;
relayoutParameters.mCharacterGlobalIndex = 0u;
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
- endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineLayoutIt != endLineLayoutIt;
- ++lineLayoutIt, ++relayoutParameters.mIndices.mLineIndex )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(),
+ endParagraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphLayoutIt != endParagraphLayoutIt;
+ ++paragraphLayoutIt, ++relayoutParameters.mIndices.mParagraphIndex )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphLayoutIt );
relayoutParameters.mIsNewLine = true;
- relayoutParameters.mLineSize = lineLayoutInfo.mSize;
+ relayoutParameters.mParagraphSize = paragraphLayoutInfo.mSize;
relayoutParameters.mIndices.mWordIndex = 0u;
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
- endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin(),
+ endWordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
wordLayoutIt != endWordLayoutIt;
++wordLayoutIt, ++relayoutParameters.mIndices.mWordIndex )
{
TextViewProcessor::WordLayoutInfo& wordLayoutInfo( *wordLayoutIt );
relayoutParameters.mIsWhiteSpace = TextViewProcessor::WordSeparator == wordLayoutInfo.mType;
- relayoutParameters.mIsNewLineCharacter = TextViewProcessor::LineSeparator == wordLayoutInfo.mType;
+ relayoutParameters.mIsNewParagraphCharacter = TextViewProcessor::ParagraphSeparator == wordLayoutInfo.mType;
relayoutParameters.mIsFirstCharacterOfWord = true;
relayoutParameters.mWordSize = wordLayoutInfo.mSize;
relayoutParameters.mIsNewLine = false;
} // end characters
} // end words
- } // end lines
+ } // end paragraphs
if( relayoutData.mCharacterLayoutInfoTable.empty() )
{
relayoutData.mTextSizeForRelayoutOption.height = minMaxXY.w - minMaxXY.y;
}
- // Check if the last character is a new line character. In that case the height should be added.
- if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
+ // Check if the last character is a new paragraph character. In that case the height should be added.
+ if( !relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.empty() )
{
- const TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u ) );
+ const TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end() - 1u ) );
- if( lineLayoutInfo.mWordsLayoutInfo.empty() ) // if it's empty, it means the last character is a new line character.
+ if( paragraphLayoutInfo.mWordsLayoutInfo.empty() ) // if it's empty, it means the last character is a new paragraph character.
{
- relayoutData.mTextSizeForRelayoutOption.height += lineLayoutInfo.mSize.height * relayoutData.mShrinkFactor;
+ relayoutData.mTextSizeForRelayoutOption.height += paragraphLayoutInfo.mSize.height * relayoutData.mShrinkFactor;
}
}
}
namespace TextProcessor
{
-void SplitInLines( const MarkupProcessor::StyledTextArray& text,
- std::vector<MarkupProcessor::StyledTextArray>& lines )
+void SplitInParagraphs( const MarkupProcessor::StyledTextArray& text,
+ std::vector<MarkupProcessor::StyledTextArray>& paragraphs )
{
- MarkupProcessor::StyledTextArray line;
+ MarkupProcessor::StyledTextArray paragraph;
for( MarkupProcessor::StyledTextArray::const_iterator it = text.begin(), endIt = text.end(); it != endIt; ++it )
{
const MarkupProcessor::StyledText& styledText( *it );
{
Text newText( character );
MarkupProcessor::StyledText newStyledText( newText, styledText.mStyle );
- line.push_back( newStyledText );
+ paragraph.push_back( newStyledText );
- lines.push_back( line );
- line.clear();
+ paragraphs.push_back( paragraph );
+ paragraph.clear();
}
else
{
Text newText( character );
MarkupProcessor::StyledText newStyledText( newText, styledText.mStyle );
- line.push_back( newStyledText );
+ paragraph.push_back( newStyledText );
}
}
}
- // This line could be empty if the last character of the previous line is a 'new line' character
+ // This paragraph could be empty if the last character of the previous paragraph is a 'new paragraph' character
// and is the last of the text.
- lines.push_back( line );
+ paragraphs.push_back( paragraph );
}
-void SplitInWords( const MarkupProcessor::StyledTextArray& line,
+void SplitInWords( const MarkupProcessor::StyledTextArray& paragraph,
std::vector<MarkupProcessor::StyledTextArray>& words )
{
MarkupProcessor::StyledTextArray word;
- for( MarkupProcessor::StyledTextArray::const_iterator it = line.begin(), endIt = line.end(); it != endIt; ++it )
+ for( MarkupProcessor::StyledTextArray::const_iterator it = paragraph.begin(), endIt = paragraph.end(); it != endIt; ++it )
{
const MarkupProcessor::StyledText& styledText( *it );
const Dali::Character character = styledText.mText[0u];
}
}
+/**
+ * Wheather the character of the text pointed by the given offset is a white space.
+ *
+ * @param[in] text The text.
+ * @param[in] offset Offset pointing the character.
+ *
+ * @return \e true if the character pointed by the offset is a white space.
+ */
bool IsWhiteSpace( const MarkupProcessor::StyledTextArray& text, size_t offset )
{
DALI_ASSERT_DEBUG( offset < text.size() );
{
/**
- * Splits the given text in lines.
+ * Splits the given text in paragraphs.
*
* @note Assumes the StyledTextArray has 1 Character per Text element. (which is the case for text in TextInput, but
* not necessarily the case for text in TextView)
*
* @param [in] text The given text.
- * @param [out] lines The text split in lines.
+ * @param [out] paragraphs The text split in paragraphs.
*/
-void SplitInLines( const MarkupProcessor::StyledTextArray& text,
- std::vector<MarkupProcessor::StyledTextArray>& lines );
+void SplitInParagraphs( const MarkupProcessor::StyledTextArray& text,
+ std::vector<MarkupProcessor::StyledTextArray>& paragraphs );
/**
- * Splits the given line in words.
+ * Splits the given paragraph in words.
*
* @note Assumes the StyledTextArray has 1 Character per Text element. (which is the case for text in TextInput, but
* not necessarily the case for text in TextView)
*
- * @param [in] line The given line.
- * @param [out] words The line split in words.
+ * @param [in] paragraph The given paragraph.
+ * @param [out] words The paragraph split in words.
*/
-void SplitInWords( const MarkupProcessor::StyledTextArray& line,
+void SplitInWords( const MarkupProcessor::StyledTextArray& paragraph,
std::vector<MarkupProcessor::StyledTextArray>& words );
/**
{
}
+CharacterLayoutInfo::~CharacterLayoutInfo()
+{
+}
+
CharacterLayoutInfo::CharacterLayoutInfo( const CharacterLayoutInfo& character )
: mHeight( character.mHeight ),
mAdvance( character.mAdvance ),
MarkupProcessor::GetStyledTextArray( std::string( "..." ), mEllipsizeText, false );
}
+TextView::LayoutParameters::~LayoutParameters()
+{
+}
+
TextView::LayoutParameters::LayoutParameters( Toolkit::TextView::MultilinePolicy multilinePolicy,
Toolkit::TextView::ExceedPolicy widthExceedPolicy,
Toolkit::TextView::ExceedPolicy heightExceedPolicy,
LayoutParameters();
/**
+ * Default destructor.
+ */
+ ~LayoutParameters();
+
+ /**
* Constructor
*/
LayoutParameters( Toolkit::TextView::MultilinePolicy multilinePolicy,
+++ /dev/null
-#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_LINE_PROCESSOR_H__
-#define __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_LINE_PROCESSOR_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/text-view/text-view-impl.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace TextViewProcessor
-{
-
-/**
- * Creates a data structure with info to layout the line, and data structures with useful info to modify the layout data structure if characters are added or removed.
- *
- * @param[in] line The styled line.
- * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info and conversion from visual to logical order and vice versa (for RTL text).
- * @param[out] lineLayoutInfo Layout info for the whole line.
- */
-void CreateLineInfo( const MarkupProcessor::StyledTextArray& line,
- TextView::RelayoutData& relayoutData,
- LineLayoutInfo& lineLayoutInfo );
-
-/**
- * Updates the line layout size info.
- *
- * @param[in,out] lineLayoutInfo The line layout info.
- * @param[in] lineHeightOffset The line height offset.
- */
-void UpdateLayoutInfo( LineLayoutInfo& lineLayoutInfo, float lineHeightOffset );
-
-/**
- * Removes a given number of words from the given line.
- *
- * @pre \e wordIndex and \e wordIndex + \e numberOfWords can't exceed the bounds of the line.
- *
- * @param[in] wordIndex Index to the word within the line with the starting position to be deleted.
- * @param[in] numberOfWords The number of words to be deleted.
- * @param[in] lineHeightOffset Additional space between lines. Needed to update layout info.
- * @param[in,out] lineLayout The input is the layout info of the line. The output is the layout info of the line without the removed words.
- */
-void RemoveWordsFromLine( std::size_t wordIndex,
- std::size_t numberOfWords,
- float lineHeightOffset,
- LineLayoutInfo& lineLayout );
-
-/**
- * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info.
- * @param[in] numberOfCharacters The number of characters to be deleted.
- * @param[out] mergeWords Whether words need to be merged after removing characters.
- * @param[out] mergeLines Whether current line need to be merged with the next one.
- * @param[in,out] textInfoIndicesBegin Indices to the line, word and characters from where to delete characters. It returns from where words need to be removed.
- * @param[out] textInfoIndicesEnd If lines or words need to be merged it returns info to delete them (If a word is merged, it has to be removed. Equal for lines).
- * @param[out] textInfoMergeIndicesBegin The indices to the first part of the line and word to be merged.
- * @param[out] textInfoMergeIndicesEnd The indices to the last part of the line and word to be merged.
- * @param[in,out] lineLayout Layout info of the line where the word is located.
- * @param[out] removedTextActorsFromFirstWord Stores removed text-actors of the word pointed by the 'begin' index.
- * @param[out] removedTextActorsFromLastWord Stores removed text-actors of the word pointed by the 'end' index.
- */
-void RemoveCharactersFromLineInfo( TextView::RelayoutData& relayoutData,
- std::size_t numberOfCharacters,
- bool& mergeWords,
- bool& mergeLines,
- TextInfoIndices& textInfoIndicesBegin,
- TextInfoIndices& textInfoIndicesEnd,
- TextInfoIndices& textInfoMergeIndicesBegin,
- TextInfoIndices& textInfoMergeIndicesEnd,
- LineLayoutInfo& lineLayout,
- std::vector<TextActor>& removedTextActorsFromFirstWord,
- std::vector<TextActor>& removedTextActorsFromLastWord );
-
-/**
- * Splits a given line in two.
- *
- * @note It deletes whatever there is in the last part of the line.
- *
- * @param[in] indices Index to the word within the line and index to the character within the word to split the line.
- * @param[in] lineHeightOffset Additional space between lines. Needed to update layout info.
- * @param[in,out] firstLineLayoutInfo The input is the layout info of the given line. The output is the first part of the input line.
- * @param[in,out] lastLineLayoutInfo Layout info of the last part of the given line.
- */
-void SplitLine( const TextInfoIndices& indices,
- const PointSize& lineHeightOffset,
- LineLayoutInfo& firstLineLayoutInfo,
- LineLayoutInfo& lastLineLayoutInfo );
-
-/**
- * Merges the two given lines by adding words of the last line to the firs one.
- *
- * @note Does nothing if last part of the line is empty.
- * @note If the first part of the line is empty it just copy the last part to it.
- * @note it asserts if the last word of the first line is a line separator (new line character)
- *
- * @param[in,out] firstLineLineLayoutInfo The input is the layout info of the first line. The output is the layout info of the merged line.
- * @param[in] lastLineLayoutInfo Layout info of the last line.
- *
- */
-void MergeLine( LineLayoutInfo& firstLineLineLayoutInfo,
- const LineLayoutInfo& lastLineLayoutInfo );
-
-/**
- * Retrieves the layout information of the last word of the given line.
- *
- * @param[in] lineLayoutInfo The line layout.
- *
- * @return Layout information of the last word of the line.
- */
-WordLayoutInfo GetLastWordLayoutInfo( const LineLayoutInfo& lineLayoutInfo );
-
-/**
- * Retrieves the layout information of the first character of the given line.
- *
- * @param[in] lineLayoutInfo The line layout.
- *
- * @return Layout information of the first character of the line.
- */
-CharacterLayoutInfo GetFirstCharacterLayoutInfo( const LineLayoutInfo& lineLayoutInfo );
-
-/**
- * Retrieves the layout information of the last character of the given line.
- *
- * @param[in] lineLayoutInfo The line layout.
- *
- * @return Layout information of the last character of the line.
- */
-CharacterLayoutInfo GetLastCharacterLayoutInfo( const LineLayoutInfo& lineLayoutInfo );
-
-/**
- * Collects text-actors from the given lines and stores them into the text-actor vector.
- *
- * @param[out] textActors Stores the text-actors of the given lines.
- * @param[in] textLayoutInfo Whole text with the given lines.
- * @param[in] lineIndexBegin The first line.
- * @param[in] lineIndexEnd The last line.
- */
-void CollectTextActorsFromLines( std::vector<TextActor>& textActors, const TextLayoutInfo& textLayoutInfo, std::size_t lineIndexBegin, std::size_t lineIndexEnd );
-
-} //namespace TextViewProcessor
-
-} //namespace Internal
-
-} //namespace Toolkit
-
-} //namespace Dali
-
-#endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_LINE_PROCESSOR_H__
*/
// FILE HEADER
-#include <dali-toolkit/internal/controls/text-view/text-view-line-processor.h>
+#include <dali-toolkit/internal/controls/text-view/text-view-paragraph-processor.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/text-view/text-view-word-processor.h>
// Layout info.
/////////////////////
-LineLayoutInfo::LineLayoutInfo()
+ParagraphLayoutInfo::ParagraphLayoutInfo()
: mSize(),
mAscender( 0.f ),
mLineHeightOffset( 0.f ),
- mWordsLayoutInfo(),
- mNumberOfCharacters( 0u )
+ mNumberOfCharacters( 0u ),
+ mWordsLayoutInfo()
{
}
-LineLayoutInfo::LineLayoutInfo( const LineLayoutInfo& line )
-: mSize( line.mSize ),
- mAscender( line.mAscender ),
- mLineHeightOffset( line.mLineHeightOffset ),
- mWordsLayoutInfo( line.mWordsLayoutInfo ),
- mNumberOfCharacters( line.mNumberOfCharacters )
+ParagraphLayoutInfo::~ParagraphLayoutInfo()
{
}
-LineLayoutInfo& LineLayoutInfo::operator=( const LineLayoutInfo& line )
+ParagraphLayoutInfo::ParagraphLayoutInfo( const ParagraphLayoutInfo& paragraph )
+: mSize( paragraph.mSize ),
+ mAscender( paragraph.mAscender ),
+ mLineHeightOffset( paragraph.mLineHeightOffset ),
+ mNumberOfCharacters( paragraph.mNumberOfCharacters ),
+ mWordsLayoutInfo( paragraph.mWordsLayoutInfo )
{
- mSize = line.mSize;
- mAscender = line.mAscender;
- mLineHeightOffset = line.mLineHeightOffset;
- mWordsLayoutInfo = line.mWordsLayoutInfo;
- mNumberOfCharacters = line.mNumberOfCharacters;
+}
+
+ParagraphLayoutInfo& ParagraphLayoutInfo::operator=( const ParagraphLayoutInfo& paragraph )
+{
+ mSize = paragraph.mSize;
+ mAscender = paragraph.mAscender;
+ mLineHeightOffset = paragraph.mLineHeightOffset;
+ mNumberOfCharacters = paragraph.mNumberOfCharacters;
+ mWordsLayoutInfo = paragraph.mWordsLayoutInfo;
return *this;
}
-void CreateLineInfo( const MarkupProcessor::StyledTextArray& line,
- TextView::RelayoutData& relayoutData,
- LineLayoutInfo& lineLayoutInfo )
+void CreateParagraphInfo( const MarkupProcessor::StyledTextArray& paragraph,
+ TextView::RelayoutData& relayoutData,
+ ParagraphLayoutInfo& paragraphLayoutInfo )
{
- // Split the line in words.
+ // Split the paragraph in words.
// TODO: Proper RTL support.
- MarkupProcessor::StyledTextArray convertedLine;
- if( TextProcessor::ContainsRightToLeftCharacter( line ) )
+ MarkupProcessor::StyledTextArray convertedParagraph;
+ if( TextProcessor::ContainsRightToLeftCharacter( paragraph ) )
{
// If the text is bidirectional, the characters will be converted and reordered
// as specified by the Unicode Bidirectional Algorithm.
- // Reorders the line and converts arabic glyphs (if any).
- TextProcessor::ConvertBidirectionalText( line,
- convertedLine,
+ // Reorders the paragraph and converts arabic glyphs (if any).
+ TextProcessor::ConvertBidirectionalText( paragraph,
+ convertedParagraph,
relayoutData.mCharacterLogicalToVisualMap,
relayoutData.mCharacterVisualToLogicalMap);
}
else
{
// No bidirectional text to process.
- convertedLine = line;
+ convertedParagraph = paragraph;
// Create trivial bidirectional map tables.
std::size_t index = 0u;
- for( MarkupProcessor::StyledTextArray::const_iterator it = convertedLine.begin(), endIt = convertedLine.end(); it != endIt; ++it )
+ for( MarkupProcessor::StyledTextArray::const_iterator it = convertedParagraph.begin(), endIt = convertedParagraph.end(); it != endIt; ++it )
{
const MarkupProcessor::StyledText& styledText( *it );
}
}
- // Split the line in words
+ // Split the paragraph in words
std::vector<MarkupProcessor::StyledTextArray> words;
- TextProcessor::SplitInWords( convertedLine, words );
+ TextProcessor::SplitInWords( convertedParagraph, words );
- // if last word has a new line separator, create a new word.
+ // if last word has a new paragraph separator, create a new word.
if( !words.empty() )
{
MarkupProcessor::StyledTextArray& word( *( words.end() - 1u ) );
const std::size_t length = styledText.mText.GetLength();
if( styledText.mText[length-1u].IsNewLine() )
{
- // Last character of this word is a new line character.
+ // Last character of this word is a new paragraph character.
- // Remove line separator character from current word.
+ // Remove paragraph separator character from current word.
styledText.mText.Remove( length - 1u, 1u );
- // Create a new word with the line separator character.
- MarkupProcessor::StyledText newLineText( Text( styledText.mText[length-1u] ), styledText.mStyle );
+ // Create a new word with the paragraph separator character.
+ MarkupProcessor::StyledText newParagraphText( Text( styledText.mText[length-1u] ), styledText.mStyle );
- MarkupProcessor::StyledTextArray newLineWord;
- newLineWord.push_back( newLineText );
+ MarkupProcessor::StyledTextArray newParagraphWord;
+ newParagraphWord.push_back( newParagraphText );
- words.push_back( newLineWord );
+ words.push_back( newParagraphWord );
}
}
}
// Update the max word width figure.
relayoutData.mTextLayoutInfo.mMaxWordWidth = std::max( relayoutData.mTextLayoutInfo.mMaxWordWidth, wordLayoutInfo.mSize.width );
- // Update layout info for the current line.
- lineLayoutInfo.mAscender = std::max( lineLayoutInfo.mAscender, wordLayoutInfo.mAscender );
- lineLayoutInfo.mNumberOfCharacters += wordLayoutInfo.mCharactersLayoutInfo.size();
- UpdateSize( lineLayoutInfo.mSize, wordLayoutInfo.mSize );
+ // Update layout info for the current paragraph.
+ paragraphLayoutInfo.mAscender = std::max( paragraphLayoutInfo.mAscender, wordLayoutInfo.mAscender );
+ paragraphLayoutInfo.mNumberOfCharacters += wordLayoutInfo.mCharactersLayoutInfo.size();
+ UpdateSize( paragraphLayoutInfo.mSize, wordLayoutInfo.mSize );
- // Add the word to the current line.
- lineLayoutInfo.mWordsLayoutInfo.push_back( wordLayoutInfo );
+ // Add the word to the current paragraph.
+ paragraphLayoutInfo.mWordsLayoutInfo.push_back( wordLayoutInfo );
} // end of words
}
-void UpdateLayoutInfo( LineLayoutInfo& lineLayoutInfo, const float lineHeightOffset )
+void UpdateLayoutInfo( ParagraphLayoutInfo& paragraphLayoutInfo, float lineHeightOffset )
{
// Update layout info.
- lineLayoutInfo.mSize = Size::ZERO;
- lineLayoutInfo.mAscender = 0.f;
- lineLayoutInfo.mNumberOfCharacters = 0u;
- for( WordLayoutInfoContainer::iterator it = lineLayoutInfo.mWordsLayoutInfo.begin(), endIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ paragraphLayoutInfo.mSize = Size::ZERO;
+ paragraphLayoutInfo.mAscender = 0.f;
+ paragraphLayoutInfo.mNumberOfCharacters = 0u;
+ for( WordLayoutInfoContainer::iterator it = paragraphLayoutInfo.mWordsLayoutInfo.begin(), endIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
it != endIt;
++it )
{
WordLayoutInfo& word( *it );
- UpdateSize( lineLayoutInfo.mSize, word.mSize );
- lineLayoutInfo.mAscender = std::max( lineLayoutInfo.mAscender, word.mAscender );
- lineLayoutInfo.mNumberOfCharacters += word.mCharactersLayoutInfo.size();
+ UpdateSize( paragraphLayoutInfo.mSize, word.mSize );
+ paragraphLayoutInfo.mAscender = std::max( paragraphLayoutInfo.mAscender, word.mAscender );
+ paragraphLayoutInfo.mNumberOfCharacters += word.mCharactersLayoutInfo.size();
}
- lineLayoutInfo.mSize.height += lineHeightOffset;
- lineLayoutInfo.mLineHeightOffset = lineHeightOffset;
+ paragraphLayoutInfo.mSize.height += lineHeightOffset;
+ paragraphLayoutInfo.mLineHeightOffset = lineHeightOffset;
}
-void RemoveWordsFromLine( std::size_t wordIndex,
- std::size_t numberOfWords,
- float lineHeightOffset,
- LineLayoutInfo& lineLayout )
+void RemoveWordsFromParagraph( std::size_t wordIndex,
+ std::size_t numberOfWords,
+ float lineHeightOffset,
+ ParagraphLayoutInfo& paragraphLayout )
{
- // Removes words from a line.
+ // Removes words from a paragraph.
- // * Check if words or lines can be merged after removing a number of words or a line separator needs to be done outside this method.
+ // * Check if words or paragraphs can be merged after removing a number of words or a paragraph separator needs to be done outside this method.
// Remove words from layout info.
- lineLayout.mWordsLayoutInfo.erase( lineLayout.mWordsLayoutInfo.begin() + wordIndex,
- lineLayout.mWordsLayoutInfo.begin() + ( wordIndex + numberOfWords ) );
+ paragraphLayout.mWordsLayoutInfo.erase( paragraphLayout.mWordsLayoutInfo.begin() + wordIndex,
+ paragraphLayout.mWordsLayoutInfo.begin() + ( wordIndex + numberOfWords ) );
- UpdateLayoutInfo( lineLayout, lineHeightOffset );
+ UpdateLayoutInfo( paragraphLayout, lineHeightOffset );
}
-void RemoveCharactersFromLineInfo( TextView::RelayoutData& relayoutData,
+void RemoveCharactersFromParagraphInfo( TextView::RelayoutData& relayoutData,
const std::size_t numberOfCharacters,
bool& mergeWords,
- bool& mergeLines,
+ bool& mergeParagraphs,
TextInfoIndices& textInfoIndicesBegin,
TextInfoIndices& textInfoIndicesEnd,
TextInfoIndices& textInfoMergeIndicesBegin,
TextInfoIndices& textInfoMergeIndicesEnd,
- LineLayoutInfo& lineLayout,
+ ParagraphLayoutInfo& paragraphLayout,
std::vector<TextActor>& removedTextActorsFromFirstWord,
std::vector<TextActor>& removedTextActorsFromLastWord )
{
// Deleted text is from different words. The two different words may be merged.
// Get first word.
- WordLayoutInfo& firstWordLayout( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex ) );
+ WordLayoutInfo& firstWordLayout( *( paragraphLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex ) );
// Get last word.
- WordLayoutInfo& lastWordLayout( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesEnd.mWordIndex ) );
+ WordLayoutInfo& lastWordLayout( *( paragraphLayout.mWordsLayoutInfo.begin() + textInfoIndicesEnd.mWordIndex ) );
// whether first or last word need to be split and merged.
bool mergeFromBegin = false;
// Check if previous word could be merged.
// Get word before.
- WordLayoutInfo& previousWordLayout( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex - 1u ) );
+ WordLayoutInfo& previousWordLayout( *( paragraphLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex - 1u ) );
if( WordSeparator != previousWordLayout.mType )
{
// Previous word is not a word separator, so could be merged.
mergeToEnd = true;
textInfoMergeIndicesEnd.mWordIndex = textInfoIndicesEnd.mWordIndex;
}
- else if( ( textInfoIndicesEnd.mCharacterIndex + 1u == lastWordLayout.mCharactersLayoutInfo.size() ) && ( textInfoIndicesEnd.mWordIndex + 1u < lineLayout.mWordsLayoutInfo.size() ) )
+ else if( ( textInfoIndicesEnd.mCharacterIndex + 1u == lastWordLayout.mCharactersLayoutInfo.size() ) && ( textInfoIndicesEnd.mWordIndex + 1u < paragraphLayout.mWordsLayoutInfo.size() ) )
{
// Last word is going to be removed completely.
// Check if the word after could be merged.
// Get word after.
- WordLayoutInfo& afterWordLayout( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesEnd.mWordIndex + 1u ) );
+ WordLayoutInfo& afterWordLayout( *( paragraphLayout.mWordsLayoutInfo.begin() + textInfoIndicesEnd.mWordIndex + 1u ) );
if( WordSeparator != afterWordLayout.mType )
{
// The word after is not a word separator, so could be merged.
mergeWords = mergeFromBegin && mergeToEnd;
}
- if( ( textInfoIndicesEnd.mCharacterIndex + 1u == lastWordLayout.mCharactersLayoutInfo.size() ) && ( textInfoIndicesEnd.mWordIndex + 1u == lineLayout.mWordsLayoutInfo.size() ) )
+ if( ( textInfoIndicesEnd.mCharacterIndex + 1u == lastWordLayout.mCharactersLayoutInfo.size() ) && ( textInfoIndicesEnd.mWordIndex + 1u == paragraphLayout.mWordsLayoutInfo.size() ) )
{
- // Last word of the line is going to be removed completely.
- // Check if it's a line separator.
+ // Last word of the paragraph is going to be removed completely.
+ // Check if it's a paragraph separator.
- if( LineSeparator == lastWordLayout.mType )
+ if( ParagraphSeparator == lastWordLayout.mType )
{
- // The line separator is going to be removed.
- if( textInfoIndicesBegin.mLineIndex + 1u < textLayoutInfo.mLinesLayoutInfo.size() )
+ // The paragraph separator is going to be removed.
+ if( textInfoIndicesBegin.mParagraphIndex + 1u < textLayoutInfo.mParagraphsLayoutInfo.size() )
{
- // Line need to be merged.
- textInfoMergeIndicesBegin.mLineIndex = textInfoIndicesBegin.mLineIndex;
- textInfoMergeIndicesEnd.mLineIndex = textInfoIndicesBegin.mLineIndex + 1u;
- mergeLines= true;
+ // Paragraph need to be merged.
+ textInfoMergeIndicesBegin.mParagraphIndex = textInfoIndicesBegin.mParagraphIndex;
+ textInfoMergeIndicesEnd.mParagraphIndex = textInfoIndicesBegin.mParagraphIndex + 1u;
+ mergeParagraphs= true;
- ++textInfoIndicesBegin.mLineIndex; // increase both indices,
- textInfoIndicesEnd.mLineIndex +=2u; // will delete last line.
+ ++textInfoIndicesBegin.mParagraphIndex; // increase both indices,
+ textInfoIndicesEnd.mParagraphIndex +=2u; // will delete last paragraph.
}
}
}
RemoveCharactersFromWordInfo( relayoutData,
numberOfCharacters,
mergeWords,
- mergeLines,
+ mergeParagraphs,
textInfoIndicesBegin,
textInfoIndicesEnd,
textInfoMergeIndicesBegin,
textInfoMergeIndicesEnd,
- lineLayout,
+ paragraphLayout,
removedTextActorsFromFirstWord );
} // word indices
}
-void SplitLine( const TextInfoIndices& indices,
- const PointSize& lineHeightOffset,
- LineLayoutInfo& firstLineLayoutInfo,
- LineLayoutInfo& lastLineLayoutInfo )
+void SplitParagraph( const TextInfoIndices& indices,
+ float lineHeightOffset,
+ ParagraphLayoutInfo& firstParagraphLayoutInfo,
+ ParagraphLayoutInfo& lastParagraphLayoutInfo )
{
- // Splits a line in two.
+ // Splits a paragraph in two.
// A word may be split in two as well.
- // * Split the word within the line.
- // * Add last part of the word to the new line.
+ // * Split the word within the paragraph.
+ // * Add last part of the word to the new paragraph.
// * Add words from wordPosition + 1 to the end.
- // * Update layout info of the last line.
- // * Remove words added to the last part of the line from the first line.
+ // * Update layout info of the last paragraph.
+ // * Remove words added to the last part of the paragraph from the first paragraph.
// early returns!!
if( ( 0u == indices.mWordIndex ) && ( 0u == indices.mCharacterIndex ) )
{
- // the whole line goes to the last part.
- lastLineLayoutInfo = firstLineLayoutInfo;
+ // the whole paragraph goes to the last part.
+ lastParagraphLayoutInfo = firstParagraphLayoutInfo;
- firstLineLayoutInfo = LineLayoutInfo();
+ firstParagraphLayoutInfo = ParagraphLayoutInfo();
return;
}
- if( !firstLineLayoutInfo.mWordsLayoutInfo.empty() )
+ if( !firstParagraphLayoutInfo.mWordsLayoutInfo.empty() )
{
- const std::size_t numberOfWords = firstLineLayoutInfo.mWordsLayoutInfo.size();
+ const std::size_t numberOfWords = firstParagraphLayoutInfo.mWordsLayoutInfo.size();
if( indices.mWordIndex == numberOfWords - 1u )
{
- const WordLayoutInfo& word( *( firstLineLayoutInfo.mWordsLayoutInfo.end() - 1u ) );
+ const WordLayoutInfo& word( *( firstParagraphLayoutInfo.mWordsLayoutInfo.end() - 1u ) );
if( indices.mCharacterIndex == word.mCharactersLayoutInfo.size() )
{
- // the whole line goes to the first part.
+ // the whole paragraph goes to the first part.
- // Just delete whatever there is in the last part of the line.
- lastLineLayoutInfo = LineLayoutInfo();
+ // Just delete whatever there is in the last part of the paragraph.
+ lastParagraphLayoutInfo = ParagraphLayoutInfo();
return;
}
}
}
- lastLineLayoutInfo = LineLayoutInfo();
+ lastParagraphLayoutInfo = ParagraphLayoutInfo();
- // 1) Split the word whitin the line.
- WordLayoutInfo& firstWordLayoutInfo( *( firstLineLayoutInfo.mWordsLayoutInfo.begin() + indices.mWordIndex ) );
+ // 1) Split the word whitin the paragraph.
+ WordLayoutInfo& firstWordLayoutInfo( *( firstParagraphLayoutInfo.mWordsLayoutInfo.begin() + indices.mWordIndex ) );
WordLayoutInfo lastWordLayoutInfo;
SplitWord( indices.mCharacterIndex,
firstWordLayoutInfo,
lastWordLayoutInfo );
- // 2) Add last part of the word to the new line.
+ // 2) Add last part of the word to the new paragraph.
if( !lastWordLayoutInfo.mCharactersLayoutInfo.empty() )
{
- lastLineLayoutInfo.mWordsLayoutInfo.push_back( lastWordLayoutInfo );
+ lastParagraphLayoutInfo.mWordsLayoutInfo.push_back( lastWordLayoutInfo );
}
// 3) Add words from word-position + 1 to the end.
- lastLineLayoutInfo.mWordsLayoutInfo.insert( lastLineLayoutInfo.mWordsLayoutInfo.end(),
- firstLineLayoutInfo.mWordsLayoutInfo.begin() + indices.mWordIndex + 1u,
- firstLineLayoutInfo.mWordsLayoutInfo.end() );
+ lastParagraphLayoutInfo.mWordsLayoutInfo.insert( lastParagraphLayoutInfo.mWordsLayoutInfo.end(),
+ firstParagraphLayoutInfo.mWordsLayoutInfo.begin() + indices.mWordIndex + 1u,
+ firstParagraphLayoutInfo.mWordsLayoutInfo.end() );
- // 4) update layout info of the last line.
- for( WordLayoutInfoContainer::iterator it = lastLineLayoutInfo.mWordsLayoutInfo.begin(), endIt = lastLineLayoutInfo.mWordsLayoutInfo.end();
+ // 4) update layout info of the last paragraph.
+ for( WordLayoutInfoContainer::iterator it = lastParagraphLayoutInfo.mWordsLayoutInfo.begin(), endIt = lastParagraphLayoutInfo.mWordsLayoutInfo.end();
it != endIt;
++it )
{
WordLayoutInfo& layoutInfo( *it );
- UpdateSize( lastLineLayoutInfo.mSize, layoutInfo.mSize );
- lastLineLayoutInfo.mNumberOfCharacters += layoutInfo.mCharactersLayoutInfo.size();
- lastLineLayoutInfo.mAscender = std::max( lastLineLayoutInfo.mAscender, layoutInfo.mAscender );
+ UpdateSize( lastParagraphLayoutInfo.mSize, layoutInfo.mSize );
+ lastParagraphLayoutInfo.mNumberOfCharacters += layoutInfo.mCharactersLayoutInfo.size();
+ lastParagraphLayoutInfo.mAscender = std::max( lastParagraphLayoutInfo.mAscender, layoutInfo.mAscender );
}
- lastLineLayoutInfo.mSize.height += lineHeightOffset;
- lastLineLayoutInfo.mLineHeightOffset = lineHeightOffset;
+ lastParagraphLayoutInfo.mSize.height += lineHeightOffset;
+ lastParagraphLayoutInfo.mLineHeightOffset = lineHeightOffset;
- // 5) Remove words added to the last part of the line from the first line.
+ // 5) Remove words added to the last part of the paragraph from the first paragraph.
- // if the number of characters of the last word of the first line is zero, it should be removed.
+ // if the number of characters of the last word of the first paragraph is zero, it should be removed.
const std::size_t index = ( firstWordLayoutInfo.mCharactersLayoutInfo.empty() ? indices.mWordIndex : indices.mWordIndex + 1u );
- firstLineLayoutInfo.mWordsLayoutInfo.erase( firstLineLayoutInfo.mWordsLayoutInfo.begin() + index, firstLineLayoutInfo.mWordsLayoutInfo.end() );
+ firstParagraphLayoutInfo.mWordsLayoutInfo.erase( firstParagraphLayoutInfo.mWordsLayoutInfo.begin() + index, firstParagraphLayoutInfo.mWordsLayoutInfo.end() );
- // 6) update layout info of the first line.
- UpdateLayoutInfo( firstLineLayoutInfo, lineHeightOffset );
+ // 6) update layout info of the first paragraph.
+ UpdateLayoutInfo( firstParagraphLayoutInfo, lineHeightOffset );
}
-void MergeLine( LineLayoutInfo& firstLineLineLayoutInfo,
- const LineLayoutInfo& lastLineLayoutInfo )
+void MergeParagraph( ParagraphLayoutInfo& firstParagraphLayoutInfo,
+ const ParagraphLayoutInfo& lastParagraphLayoutInfo )
{
- // Merges two given lines.
+ // Merges two given paragraphs.
//
- // Can't merge two lines if the last word of the first one is a line separator (new line character)
+ // Can't merge two paragraphs if the last word of the first one is a paragraph separator (new paragraph character)
// Early returns.
- if( lastLineLayoutInfo.mWordsLayoutInfo.empty() )
+ if( lastParagraphLayoutInfo.mWordsLayoutInfo.empty() )
{
- // Nothing to merge if last line is empty.
+ // Nothing to merge if last paragraph is empty.
return;
}
- if( firstLineLineLayoutInfo.mWordsLayoutInfo.empty() )
+ if( firstParagraphLayoutInfo.mWordsLayoutInfo.empty() )
{
- // If first line is empty, just copy the last line to the first one.
- firstLineLineLayoutInfo = lastLineLayoutInfo;
+ // If first paragraph is empty, just copy the last paragraph to the first one.
+ firstParagraphLayoutInfo = lastParagraphLayoutInfo;
return;
}
- // Check the last word of the first line doesn't finish with a new line character.
- WordLayoutInfo& lastWordLayout( *( firstLineLineLayoutInfo.mWordsLayoutInfo.end() - 1u ) );
- if( LineSeparator == lastWordLayout.mType )
+ // Check the last word of the first paragraph doesn't finish with a new paragraph character.
+ WordLayoutInfo& lastWordLayout( *( firstParagraphLayoutInfo.mWordsLayoutInfo.end() - 1u ) );
+ if( ParagraphSeparator == lastWordLayout.mType )
{
- DALI_ASSERT_ALWAYS( !"TextViewProcessor::MergeLine(). ERROR: A line can't be merged to another line which finishes with a new line character." );
+ DALI_ASSERT_ALWAYS( !"TextViewProcessor::MergeParagraph(). ERROR: A paragraph can't be merged to another paragraph which finishes with a new paragraph character." );
}
- // If the las word of the first line or the first word of the last line is a white space, both lines can be concatenated.
+ // If the las word of the first paragraph or the first word of the last paragraph is a white space, both paragraphs can be concatenated.
// Otherwise both words need to be merged first.
- const WordLayoutInfo& firstWordLayout( *lastLineLayoutInfo.mWordsLayoutInfo.begin() );
+ const WordLayoutInfo& firstWordLayout( *lastParagraphLayoutInfo.mWordsLayoutInfo.begin() );
std::size_t index = 0u;
- if( ( WordSeparator != lastWordLayout.mType ) && ( WordSeparator != firstWordLayout.mType ) && ( LineSeparator != firstWordLayout.mType ) )
+ if( ( WordSeparator != lastWordLayout.mType ) && ( WordSeparator != firstWordLayout.mType ) && ( ParagraphSeparator != firstWordLayout.mType ) )
{
- // Last word of the first line is not a word separator and first word of the last line is not a word or line separator.
+ // Last word of the first paragraph is not a word separator and first word of the last paragraph is not a word or paragraph separator.
// Words need to be merged.
MergeWord( lastWordLayout,
// Merge layout info
// Insert the layout of the words.
- firstLineLineLayoutInfo.mWordsLayoutInfo.insert( firstLineLineLayoutInfo.mWordsLayoutInfo.end(),
- lastLineLayoutInfo.mWordsLayoutInfo.begin() + index, lastLineLayoutInfo.mWordsLayoutInfo.end() );
+ firstParagraphLayoutInfo.mWordsLayoutInfo.insert( firstParagraphLayoutInfo.mWordsLayoutInfo.end(),
+ lastParagraphLayoutInfo.mWordsLayoutInfo.begin() + index, lastParagraphLayoutInfo.mWordsLayoutInfo.end() );
// Update the size and other layout parameters.
- UpdateSize( firstLineLineLayoutInfo.mSize, lastLineLayoutInfo.mSize );
- firstLineLineLayoutInfo.mAscender = std::max( firstLineLineLayoutInfo.mAscender, lastLineLayoutInfo.mAscender );
- firstLineLineLayoutInfo.mLineHeightOffset = std::max( firstLineLineLayoutInfo.mLineHeightOffset, lastLineLayoutInfo.mLineHeightOffset );
- firstLineLineLayoutInfo.mNumberOfCharacters += lastLineLayoutInfo.mNumberOfCharacters;
+ UpdateSize( firstParagraphLayoutInfo.mSize, lastParagraphLayoutInfo.mSize );
+ firstParagraphLayoutInfo.mAscender = std::max( firstParagraphLayoutInfo.mAscender, lastParagraphLayoutInfo.mAscender );
+ firstParagraphLayoutInfo.mLineHeightOffset = std::max( firstParagraphLayoutInfo.mLineHeightOffset, lastParagraphLayoutInfo.mLineHeightOffset );
+ firstParagraphLayoutInfo.mNumberOfCharacters += lastParagraphLayoutInfo.mNumberOfCharacters;
}
-WordLayoutInfo GetLastWordLayoutInfo( const LineLayoutInfo& lineLayoutInfo )
+WordLayoutInfo GetLastWordLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo )
{
WordLayoutInfo layoutInfo;
- if( !lineLayoutInfo.mWordsLayoutInfo.empty() )
+ if( !paragraphLayoutInfo.mWordsLayoutInfo.empty() )
{
- layoutInfo = *( lineLayoutInfo.mWordsLayoutInfo.end() - 1u );
+ layoutInfo = *( paragraphLayoutInfo.mWordsLayoutInfo.end() - 1u );
}
return layoutInfo;
}
-CharacterLayoutInfo GetFirstCharacterLayoutInfo( const LineLayoutInfo& lineLayoutInfo )
+CharacterLayoutInfo GetFirstCharacterLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo )
{
CharacterLayoutInfo layoutInfo;
- if( !lineLayoutInfo.mWordsLayoutInfo.empty() )
+ if( !paragraphLayoutInfo.mWordsLayoutInfo.empty() )
{
- const WordLayoutInfo& wordInfo( *lineLayoutInfo.mWordsLayoutInfo.begin() );
+ const WordLayoutInfo& wordInfo( *paragraphLayoutInfo.mWordsLayoutInfo.begin() );
layoutInfo = GetFirstCharacterLayoutInfo( wordInfo );
}
return layoutInfo;
}
-CharacterLayoutInfo GetLastCharacterLayoutInfo( const LineLayoutInfo& lineLayoutInfo )
+CharacterLayoutInfo GetLastCharacterLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo )
{
- const WordLayoutInfo wordInfo = GetLastWordLayoutInfo( lineLayoutInfo );
+ const WordLayoutInfo wordInfo = GetLastWordLayoutInfo( paragraphLayoutInfo );
return GetLastCharacterLayoutInfo( wordInfo );
}
-void CollectTextActorsFromLines( std::vector<TextActor>& textActors, const TextLayoutInfo& textLayoutInfo, const std::size_t lineIndexBegin, const std::size_t lineIndexEnd )
+void CollectTextActorsFromParagraphs( std::vector<TextActor>& textActors, const TextLayoutInfo& textLayoutInfo, const std::size_t paragraphIndexBegin, const std::size_t paragraphIndexEnd )
{
- for( LineLayoutInfoContainer::const_iterator lineIt = textLayoutInfo.mLinesLayoutInfo.begin() + lineIndexBegin, lineEndIt = textLayoutInfo.mLinesLayoutInfo.begin() + lineIndexEnd;
- lineIt != lineEndIt;
- ++lineIt )
+ for( ParagraphLayoutInfoContainer::const_iterator paragraphIt = textLayoutInfo.mParagraphsLayoutInfo.begin() + paragraphIndexBegin, paragraphEndIt = textLayoutInfo.mParagraphsLayoutInfo.begin() + paragraphIndexEnd;
+ paragraphIt != paragraphEndIt;
+ ++paragraphIt )
{
- const LineLayoutInfo& line( *lineIt );
+ const ParagraphLayoutInfo& paragraph( *paragraphIt );
- CollectTextActorsFromWords( textActors, line, 0u, line.mWordsLayoutInfo.size() );
+ CollectTextActorsFromWords( textActors, paragraph, 0u, paragraph.mWordsLayoutInfo.size() );
}
}
--- /dev/null
+#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PARAGRAPH_PROCESSOR_H__
+#define __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PARAGRAPH_PROCESSOR_H__
+
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/text-view/text-view-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace TextViewProcessor
+{
+
+/**
+ * Creates a data structure with info to layout the paragraph, and data structures with useful info to modify the layout data structure if characters are added or removed.
+ *
+ * @param[in] paragraph The styled paragraph.
+ * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info and conversion from visual to logical order and vice versa (for RTL text).
+ * @param[out] paragraphLayoutInfo Layout info for the whole paragraph.
+ */
+void CreateParagraphInfo( const MarkupProcessor::StyledTextArray& line,
+ TextView::RelayoutData& relayoutData,
+ ParagraphLayoutInfo& paragraphLayoutInfo );
+
+/**
+ * Updates the paragraph layout info.
+ *
+ * @param[in,out] paragraphLayoutInfo The paragraph layout info.
+ * @param[in] lineHeightOffset The offset added to the line height.
+ */
+void UpdateLayoutInfo( ParagraphLayoutInfo& paragraphLayoutInfo, float lineHeightOffset );
+
+/**
+ * Removes a given number of words from the given paragraph.
+ *
+ * @pre \e wordIndex and \e wordIndex + \e numberOfWords can't exceed the bounds of the paragraph.
+ *
+ * @param[in] wordIndex Index to the word within the paragraph with the starting position to be deleted.
+ * @param[in] numberOfWords The number of words to be deleted.
+ * @param[in] lineHeightOffset The offset added to the line height. Needed to update the layout info.
+ * @param[in,out] paragraphLayout The input is the layout info of the paragraph. The output is the layout info of the paragraph without the removed words.
+ */
+void RemoveWordsFromParagraph( std::size_t wordIndex,
+ std::size_t numberOfWords,
+ float lineHeightOffset,
+ ParagraphLayoutInfo& paragraphLayout );
+
+/**
+ * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info.
+ * @param[in] numberOfCharacters The number of characters to be deleted.
+ * @param[out] mergeWords Whether words need to be merged after removing characters.
+ * @param[out] mergeParagraphs Whether current paragraph need to be merged with the next one.
+ * @param[in,out] textInfoIndicesBegin Indices to the paragraph, word and characters from where to delete characters. It returns from where words need to be removed.
+ * @param[out] textInfoIndicesEnd If paragraphs or words need to be merged it returns info to delete them (If a word is merged, it has to be removed. Equal for paragraphs).
+ * @param[out] textInfoMergeIndicesBegin The indices to the first part of the paragraph and word to be merged.
+ * @param[out] textInfoMergeIndicesEnd The indices to the last part of the paragraph and word to be merged.
+ * @param[in,out] paragraphLayout Layout info of the paragraph where the word is located.
+ * @param[out] removedTextActorsFromFirstWord Stores removed text-actors of the word pointed by the 'begin' index.
+ * @param[out] removedTextActorsFromLastWord Stores removed text-actors of the word pointed by the 'end' index.
+ */
+void RemoveCharactersFromParagraphInfo( TextView::RelayoutData& relayoutData,
+ std::size_t numberOfCharacters,
+ bool& mergeWords,
+ bool& mergeParagraphs,
+ TextInfoIndices& textInfoIndicesBegin,
+ TextInfoIndices& textInfoIndicesEnd,
+ TextInfoIndices& textInfoMergeIndicesBegin,
+ TextInfoIndices& textInfoMergeIndicesEnd,
+ ParagraphLayoutInfo& paragraphLayout,
+ std::vector<TextActor>& removedTextActorsFromFirstWord,
+ std::vector<TextActor>& removedTextActorsFromLastWord );
+
+/**
+ * Splits a given paragraph in two.
+ *
+ * @note It deletes whatever there is in the last part of the paragraph.
+ *
+ * @param[in] indices Index to the word within the paragraph and index to the character within the word to split the paragraph.
+ * @param[in] lineHeightOffset Additional space between lines. Needed to update layout info.
+ * @param[in,out] firstParagraphLayoutInfo The input is the layout info of the given paragraph. The output is the first part of the input paragraph.
+ * @param[in,out] lastParagraphLayoutInfo Layout info of the last part of the given paragraph.
+ */
+void SplitParagraph( const TextInfoIndices& indices,
+ float lineHeightOffset,
+ ParagraphLayoutInfo& firstParagraphLayoutInfo,
+ ParagraphLayoutInfo& lastParagraphLayoutInfo );
+
+/**
+ * Merges the two given paragraphs by adding words of the last paragraph to the firs one.
+ *
+ * @note Does nothing if last part of the paragraph is empty.
+ * @note If the first part of the paragraph is empty it just copy the last part to it.
+ * @note it asserts if the last word of the first paragraph is a paragraph separator (new paragraph character)
+ *
+ * @param[in,out] firstParagraphLayoutInfo The input is the layout info of the first paragraph. The output is the layout info of the merged paragraph.
+ * @param[in] lastParagraphLayoutInfo Layout info of the last paragraph.
+ *
+ */
+void MergeParagraph( ParagraphLayoutInfo& firstParagraphLayoutInfo,
+ const ParagraphLayoutInfo& lastParagraphLayoutInfo );
+
+/**
+ * Retrieves the layout information of the last word of the given paragraph.
+ *
+ * @param[in] paragraphLayoutInfo The paragraph layout.
+ *
+ * @return Layout information of the last word of the paragraph.
+ */
+WordLayoutInfo GetLastWordLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo );
+
+/**
+ * Retrieves the layout information of the first character of the given paragraph.
+ *
+ * @param[in] paragraphLayoutInfo The paragraph layout.
+ *
+ * @return Layout information of the first character of the paragraph.
+ */
+CharacterLayoutInfo GetFirstCharacterLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo );
+
+/**
+ * Retrieves the layout information of the last character of the given paragraph.
+ *
+ * @param[in] paragraphLayoutInfo The paragraph layout.
+ *
+ * @return Layout information of the last character of the paragraph.
+ */
+CharacterLayoutInfo GetLastCharacterLayoutInfo( const ParagraphLayoutInfo& paragraphLayoutInfo );
+
+/**
+ * Collects text-actors from the given paragraphs and stores them into the text-actor vector.
+ *
+ * @param[out] textActors Stores the text-actors of the given paragraphs.
+ * @param[in] textLayoutInfo Whole text with the given paragraphs.
+ * @param[in] paragraphIndexBegin The first paragraph.
+ * @param[in] paragraphIndexEnd The last paragraph.
+ */
+void CollectTextActorsFromParagraphs( std::vector<TextActor>& textActors, const TextLayoutInfo& textLayoutInfo, std::size_t paragraphIndexBegin, std::size_t paragraphIndexEnd );
+
+} //namespace TextViewProcessor
+
+} //namespace Internal
+
+} //namespace Toolkit
+
+} //namespace Dali
+
+#endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PARAGRAPH_PROCESSOR_H__
std::cout << "NoSeparator" << std::endl;
break;
}
- case LineSeparator:
+ case ParagraphSeparator:
{
- std::cout << "LineSeparator" << std::endl;
+ std::cout << "ParagraphSeparator" << std::endl;
break;
}
case WordSeparator:
}
}
-void dbgPrint( const LineLayoutInfo& line )
+void dbgPrint( const ParagraphLayoutInfo& paragraph )
{
std::cout << "< ";
- std::cout << line.mSize;
- for( WordLayoutInfoContainer::const_iterator wordIt = line.mWordsLayoutInfo.begin(), endWordIt = line.mWordsLayoutInfo.end();
+ std::cout << paragraph.mSize;
+ for( WordLayoutInfoContainer::const_iterator wordIt = paragraph.mWordsLayoutInfo.begin(), endWordIt = paragraph.mWordsLayoutInfo.end();
wordIt != endWordIt;
++wordIt )
{
{
std::cout << "||" << std::endl;
std::cout << textInfo.mWholeTextSize;
- for( LineLayoutInfoContainer::const_iterator it = textInfo.mLinesLayoutInfo.begin(), endIt = textInfo.mLinesLayoutInfo.end();
+ std::cout << textInfo.mNumberOfCharacters;
+ for( ParagraphLayoutInfoContainer::const_iterator it = textInfo.mParagraphsLayoutInfo.begin(), endIt = textInfo.mParagraphsLayoutInfo.end();
it != endIt;
++it )
{
void dbgPrint( const TextInfoIndices& indices )
{
- std::cout << " line : " << indices.mLineIndex << std::endl;
- std::cout << " word : " << indices.mWordIndex << std::endl;
- std::cout << " char : " << indices.mCharacterIndex << std::endl;
+ std::cout << " paragraph : " << indices.mParagraphIndex << std::endl;
+ std::cout << " word : " << indices.mWordIndex << std::endl;
+ std::cout << " char : " << indices.mCharacterIndex << std::endl;
}
void dbgPrint( const MarkupProcessor::StyledTextArray& textArray )
#endif
void dbgPrint( const WordLayoutInfo& word );
-void dbgPrint( const LineLayoutInfo& line );
+void dbgPrint( const ParagraphLayoutInfo& paragraph );
void dbgPrint( const TextLayoutInfo& textInfo );
void dbgPrint( const TextStyle& style );
void dbgPrint( const TextInfoIndices& indices );
TextSeparatorType GetTextSeparatorType( const Character& character )
{
- // returns if the given character is a line separator '\n', a word separator ' ' or if is not a separator (any other character).
- return ( character.IsNewLine() ? LineSeparator : ( character.IsWhiteSpace() ? WordSeparator : NoSeparator ) );
+ // returns if the given character is a paragraph separator '\n', a word separator ' ' or if is not a separator (any other character).
+ return ( character.IsNewLine() ? ParagraphSeparator : ( character.IsWhiteSpace() ? WordSeparator : NoSeparator ) );
}
void ChooseFontFamilyName( MarkupProcessor::StyledText& text )
indices = TextInfoIndices();
// Early return.
- if( textLayoutInfo.mLinesLayoutInfo.empty() )
+ if( textLayoutInfo.mParagraphsLayoutInfo.empty() )
{
// Text is empty. All indices are 0.
return;
std::size_t currentIndex = 0u; // stores how many characters have been traversed (within the whole text).
- // Traverse all lines and words until global index is found.
+ // Traverse all paragraphs and words until global index is found.
bool found = false;
- for( LineLayoutInfoContainer::const_iterator lineIt = textLayoutInfo.mLinesLayoutInfo.begin(),
- lineEndIt = textLayoutInfo.mLinesLayoutInfo.end();
- ( !found ) && ( lineIt != lineEndIt );
- ++lineIt, ++indices.mLineIndex )
+ for( ParagraphLayoutInfoContainer::const_iterator paragraphIt = textLayoutInfo.mParagraphsLayoutInfo.begin(),
+ paragraphEndIt = textLayoutInfo.mParagraphsLayoutInfo.end();
+ ( !found ) && ( paragraphIt != paragraphEndIt );
+ ++paragraphIt, ++indices.mParagraphIndex )
{
- const LineLayoutInfo& lineLayoutInfo( *lineIt );
+ const ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphIt );
- if( currentIndex + lineLayoutInfo.mNumberOfCharacters > index )
+ if( currentIndex + paragraphLayoutInfo.mNumberOfCharacters > index )
{
- // The character is in this line
- for( WordLayoutInfoContainer::const_iterator wordIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
- wordEndIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ // The character is in this paragraph
+ for( WordLayoutInfoContainer::const_iterator wordIt = paragraphLayoutInfo.mWordsLayoutInfo.begin(),
+ wordEndIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
( !found ) && ( wordIt != wordEndIt );
++wordIt, ++indices.mWordIndex )
{
currentIndex += wordLayoutInfo.mCharactersLayoutInfo.size();
}
} // end words.
- if( !lineLayoutInfo.mWordsLayoutInfo.empty() )
+ if( !paragraphLayoutInfo.mWordsLayoutInfo.empty() )
{
--indices.mWordIndex;
}
}
else
{
- // check in the next line
- currentIndex += lineLayoutInfo.mNumberOfCharacters;
+ // check in the next paragraph
+ currentIndex += paragraphLayoutInfo.mNumberOfCharacters;
}
- } // end lines.
+ } // end paragraphs.
// Need to decrease indices as they have been increased in the last loop.
- if( !textLayoutInfo.mLinesLayoutInfo.empty() )
+ if( !textLayoutInfo.mParagraphsLayoutInfo.empty() )
{
- --indices.mLineIndex;
+ --indices.mParagraphIndex;
}
}
{
/**
- * Whether the text is a new line character, a white space or normal text.
+ * Whether the text is a new paragraph character '\n', a white space or normal text.
*/
enum TextSeparatorType
{
- LineSeparator,
+ ParagraphSeparator,
WordSeparator,
NoSeparator
};
{
/**
* Default constructor.
+ *
+ * Initializes all members to their default values.
*/
TextInfoIndices();
/**
* Constructor.
*/
- TextInfoIndices( std::size_t lineIndex,
+ TextInfoIndices( std::size_t paragraphIndex,
std::size_t wordIndex,
std::size_t characterIndex );
*/
bool operator==( const TextInfoIndices& indices ) const;
- std::size_t mLineIndex;
- std::size_t mWordIndex;
- std::size_t mCharacterIndex;
+ std::size_t mParagraphIndex; ///< The paragraph index within the text.
+ std::size_t mWordIndex; ///< The word index within the paragraph.
+ std::size_t mCharacterIndex; ///< The character index within the word.
};
/**
CharacterLayoutInfo();
/**
+ * Default destructor.
+ *
+ * Deletes the gradient info.
+ */
+ ~CharacterLayoutInfo();
+
+ /**
* Copy constructor.
*/
CharacterLayoutInfo( const CharacterLayoutInfo& character );
WordLayoutInfo();
/**
+ * Default destructor.
+ *
+ * Clears all characters.
+ */
+ ~WordLayoutInfo();
+
+ /**
* Copy constructor.
*/
WordLayoutInfo( const WordLayoutInfo& word );
typedef std::vector<WordLayoutInfo> WordLayoutInfoContainer;
/**
- * Layout information for a line.
+ * Layout information for a paragraph.
*/
-struct LineLayoutInfo
+struct ParagraphLayoutInfo
{
/**
* Default constructor.
*
* Initializes all members to their default values.
*/
- LineLayoutInfo();
+ ParagraphLayoutInfo();
+
+ /**
+ * Default destructor.
+ *
+ * Clears all words and deletes all text styles.
+ */
+ ~ParagraphLayoutInfo();
/**
* Copy constructor.
*/
- LineLayoutInfo( const LineLayoutInfo& line );
+ ParagraphLayoutInfo( const ParagraphLayoutInfo& paragraph );
/**
* Assignment operator.
*/
- LineLayoutInfo& operator=( const LineLayoutInfo& line );
+ ParagraphLayoutInfo& operator=( const ParagraphLayoutInfo& paragraph );
- Size mSize; ///< Size of the line.
- float mAscender; ///< Max of all ascenders of all words.
- float mLineHeightOffset; ///< Line height offset.
- WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words.
- std::size_t mNumberOfCharacters; ///< Stores the number of characters.
+ Size mSize; ///< Size of the paragraph.
+ float mAscender; ///< Max of all ascenders of all words.
+ float mLineHeightOffset; ///< Line height offset.
+ std::size_t mNumberOfCharacters; ///< Stores the number of characters.
+ WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words.
};
-typedef std::vector<LineLayoutInfo> LineLayoutInfoContainer;
+typedef std::vector<ParagraphLayoutInfo> ParagraphLayoutInfoContainer;
/**
* Layout information for the whole text.
*/
TextLayoutInfo& operator=( const TextLayoutInfo& text );
- Size mWholeTextSize; ///< width and height of the whole text.
- float mMaxWordWidth; ///< maximum width between all words.
- LineLayoutInfoContainer mLinesLayoutInfo; ///< Layout information for all lines.
- std::size_t mNumberOfCharacters; ///< Stores the number of characters.
- float mMaxItalicsOffset; ///< When rendering text-view in offscreen an extra width offset is needed to prevent italic characters to be cut if they are in the right edge.
- WordLayoutInfo mEllipsizeLayoutInfo; ///< Layout information for the ellipsize text.
+ Size mWholeTextSize; ///< width and height of the whole text.
+ float mMaxWordWidth; ///< maximum width between all words.
+ float mMaxItalicsOffset; ///< When rendering text-view in offscreen an extra width offset is needed to prevent italic characters to be cut if they are in the right edge.
+ std::size_t mNumberOfCharacters; ///< Stores the number of characters.
+ ParagraphLayoutInfoContainer mParagraphsLayoutInfo; ///< Layout information for all paragraphs.
+ WordLayoutInfo mEllipsizeLayoutInfo; ///< Layout information for the ellipsize text.
};
} // namespace TextViewProcessor
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/text-view/text-view-word-processor.h>
-#include <dali-toolkit/internal/controls/text-view/text-view-line-processor.h>
+#include <dali-toolkit/internal/controls/text-view/text-view-paragraph-processor.h>
#include <dali-toolkit/internal/controls/text-view/text-view-processor-helper-functions.h>
#include <dali-toolkit/internal/controls/text-view/text-processor.h>
textLayoutInfo.mNumberOfCharacters = 0u;
// Traverse all text updating values.
- for( LineLayoutInfoContainer::const_iterator lineIt = textLayoutInfo.mLinesLayoutInfo.begin(), lineEndIt = textLayoutInfo.mLinesLayoutInfo.end();
- lineIt != lineEndIt;
- ++lineIt )
+ for( ParagraphLayoutInfoContainer::const_iterator paragraphIt = textLayoutInfo.mParagraphsLayoutInfo.begin(), paragraphEndIt = textLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphIt != paragraphEndIt;
+ ++paragraphIt )
{
- const LineLayoutInfo& line( *lineIt );
+ const ParagraphLayoutInfo& paragraph( *paragraphIt );
- // Updates text size with the size of all lines.
- UpdateSize( textLayoutInfo.mWholeTextSize, line.mSize, GrowHeight );
+ // Updates text size with the size of all paragraphs.
+ UpdateSize( textLayoutInfo.mWholeTextSize, paragraph.mSize, GrowHeight );
// Updates number of characters.
- textLayoutInfo.mNumberOfCharacters += line.mNumberOfCharacters;
+ textLayoutInfo.mNumberOfCharacters += paragraph.mNumberOfCharacters;
- for( WordLayoutInfoContainer::const_iterator wordIt = line.mWordsLayoutInfo.begin(), wordEndIt = line.mWordsLayoutInfo.end();
+ // Updates the max word's width.
+ for( WordLayoutInfoContainer::const_iterator wordIt = paragraph.mWordsLayoutInfo.begin(), wordEndIt = paragraph.mWordsLayoutInfo.end();
wordIt != wordEndIt;
++wordIt )
{
// Constructors and assignment operators
TextInfoIndices::TextInfoIndices()
-: mLineIndex( 0u ),
+: mParagraphIndex( 0u ),
mWordIndex( 0u ),
mCharacterIndex( 0u )
{
}
-TextInfoIndices::TextInfoIndices( const std::size_t lineIndex,
+TextInfoIndices::TextInfoIndices( const std::size_t paragraphIndex,
const std::size_t wordIndex,
const std::size_t characterIndex )
-: mLineIndex( lineIndex ),
+: mParagraphIndex( paragraphIndex ),
mWordIndex( wordIndex ),
mCharacterIndex( characterIndex )
{
bool TextInfoIndices::operator==( const TextInfoIndices& indices ) const
{
- return ( ( mLineIndex == indices.mLineIndex ) &&
+ return ( ( mParagraphIndex == indices.mParagraphIndex ) &&
( mWordIndex == indices.mWordIndex ) &&
( mCharacterIndex == indices.mCharacterIndex ) );
}
TextLayoutInfo::TextLayoutInfo()
: mWholeTextSize(),
mMaxWordWidth( 0.f ),
- mLinesLayoutInfo(),
- mNumberOfCharacters( 0u ),
mMaxItalicsOffset( 0.f ),
+ mNumberOfCharacters( 0u ),
+ mParagraphsLayoutInfo(),
mEllipsizeLayoutInfo()
{
}
TextLayoutInfo::TextLayoutInfo( const TextLayoutInfo& text )
: mWholeTextSize( text.mWholeTextSize ),
mMaxWordWidth( text.mMaxWordWidth ),
- mLinesLayoutInfo( text.mLinesLayoutInfo ),
- mNumberOfCharacters( text.mNumberOfCharacters ),
mMaxItalicsOffset( text.mMaxItalicsOffset ),
+ mNumberOfCharacters( text.mNumberOfCharacters ),
+ mParagraphsLayoutInfo( text.mParagraphsLayoutInfo ),
mEllipsizeLayoutInfo( text.mEllipsizeLayoutInfo )
{
}
TextLayoutInfo& TextLayoutInfo::operator=( const TextLayoutInfo& text )
{
- mWholeTextSize = text.mWholeTextSize;
- mMaxWordWidth = text.mMaxWordWidth;
- mLinesLayoutInfo = text.mLinesLayoutInfo;
- mNumberOfCharacters = text.mNumberOfCharacters;
- mMaxItalicsOffset = text.mMaxItalicsOffset;
- mEllipsizeLayoutInfo = text.mEllipsizeLayoutInfo;
+ if( this != &text )
+ {
+ mWholeTextSize = text.mWholeTextSize;
+ mMaxWordWidth = text.mMaxWordWidth;
+ mMaxItalicsOffset = text.mMaxItalicsOffset;
+ mNumberOfCharacters = text.mNumberOfCharacters;
+ mParagraphsLayoutInfo = text.mParagraphsLayoutInfo;
+ mEllipsizeLayoutInfo = text.mEllipsizeLayoutInfo;
+ }
return *this;
}
const TextView::LayoutParameters& layoutParameters,
TextView::RelayoutData& relayoutData )
{
- // * Traverse the given text spliting it in lines and each line in words.
- // * White spaces and new line characters are alone in one word.
- // * Bidirectional text is processed in each line.
+ // * Traverse the given text spliting it in paragraphs and each paragraph in words.
+ // * White spaces and new paragraph characters are alone in one word.
+ // * Bidirectional text is processed in each paragraph.
// * Generates a layout data structure to store layout information (size, position, ascender, text direction, etc) and metrics of all characters.
// * Generates a text-actor data structure to store text, style and text-actors.
// TODO: finish and test the bidirectional implementation.
// Collect previously created text-actors.
std::vector<TextActor> textActors;
- CollectTextActorsFromLines( textActors, relayoutData.mTextLayoutInfo, 0u, relayoutData.mTextLayoutInfo.mLinesLayoutInfo.size() );
+ CollectTextActorsFromParagraphs( textActors, relayoutData.mTextLayoutInfo, 0u, relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.size() );
if( !textActors.empty() )
{
// Sets the ellipsize layout info.
relayoutData.mTextLayoutInfo.mEllipsizeLayoutInfo = ellipsizeInfo;
- // Split the whole text in lines.
- std::vector<MarkupProcessor::StyledTextArray> lines;
- TextProcessor::SplitInLines( text,
- lines );
+ // Split the whole text in paragraphs.
+ std::vector<MarkupProcessor::StyledTextArray> paragraphs;
+ TextProcessor::SplitInParagraphs( text,
+ paragraphs );
- // Traverse all lines
- for( std::vector<MarkupProcessor::StyledTextArray>::const_iterator lineIt = lines.begin(), lineEndIt = lines.end(); lineIt != lineEndIt; ++lineIt )
+ // Traverse all paragraphs
+ for( std::vector<MarkupProcessor::StyledTextArray>::const_iterator paragraphIt = paragraphs.begin(), paragraphEndIt = paragraphs.end(); paragraphIt != paragraphEndIt; ++paragraphIt )
{
- const MarkupProcessor::StyledTextArray& line( *lineIt );
+ const MarkupProcessor::StyledTextArray& paragraph( *paragraphIt );
- // Data structures for the new line
- LineLayoutInfo lineLayoutInfo;
+ // Data structures for the new paragraph
+ ParagraphLayoutInfo paragraphLayoutInfo;
- // Fills the line data structures with the layout info.
- CreateLineInfo( line,
- relayoutData,
- lineLayoutInfo );
+ // Fills the paragraph data structures with the layout info.
+ CreateParagraphInfo( paragraph,
+ relayoutData,
+ paragraphLayoutInfo );
- if( 0u < lineLayoutInfo.mNumberOfCharacters )
+ if( 0u < paragraphLayoutInfo.mNumberOfCharacters )
{
- // do not add the line offset if the line has no characters.
- lineLayoutInfo.mSize.height += layoutParameters.mLineHeightOffset;
- lineLayoutInfo.mLineHeightOffset = layoutParameters.mLineHeightOffset;
+ // do not add the line offset if the paragraph has no characters.
+ paragraphLayoutInfo.mSize.height += layoutParameters.mLineHeightOffset;
+ paragraphLayoutInfo.mLineHeightOffset = layoutParameters.mLineHeightOffset;
}
else
{
- // line height needs to be added for the last line.
+ // line height needs to be added for the last paragraph.
float lineHeight = 0.f;
- // Get the last character of the last line.
- if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
+ // Get the last character of the last paragraph.
+ if( !relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.empty() )
{
- const LineLayoutInfo& lineInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u ) );
+ const ParagraphLayoutInfo& paragraphInfo( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end() - 1u ) );
- const CharacterLayoutInfo characterInfo = GetLastCharacterLayoutInfo( lineInfo );
+ const CharacterLayoutInfo characterInfo = GetLastCharacterLayoutInfo( paragraphInfo );
lineHeight = characterInfo.mSize.height;
}
- lineLayoutInfo.mSize.height = lineHeight;
+ paragraphLayoutInfo.mSize.height = lineHeight;
}
// Update layout info for the whole text.
- UpdateSize( relayoutData.mTextLayoutInfo.mWholeTextSize, lineLayoutInfo.mSize, GrowHeight );
- relayoutData.mTextLayoutInfo.mNumberOfCharacters += lineLayoutInfo.mNumberOfCharacters;
+ UpdateSize( relayoutData.mTextLayoutInfo.mWholeTextSize, paragraphLayoutInfo.mSize, GrowHeight );
+ relayoutData.mTextLayoutInfo.mNumberOfCharacters += paragraphLayoutInfo.mNumberOfCharacters;
- // Add the line to the current text.
- relayoutData.mTextLayoutInfo.mLinesLayoutInfo.push_back( lineLayoutInfo );
- } // end of lines
+ // Add the paragraph to the current text.
+ relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.push_back( paragraphLayoutInfo );
+ } // end of paragraphs
}
void UpdateTextInfo( const std::size_t position,
// * Creates layout info for the given text.
// * With the given position, find where to add the text.
- // * If the new text is not added at the end of current text, a line need to be split.
- // * Merge the last line of the new text to the last part or the split line.
- // * Add lines between first and last of the new text.
- // * Merge the first part of the split line with the first line of the new text.
+ // * If the new text is not added at the end of current text, a paragraph need to be split.
+ // * Merge the last paragraph of the new text to the last part or the split paragraph.
+ // * Add paragraphs between first and last of the new text.
+ // * Merge the first part of the split paragraph with the first paragraph of the new text.
// * Update layout info and create new text actors if needed.
// Early returns:
++index;
}
- // If a line is split, it stores the last part of the line.
- LineLayoutInfo lastLineLayoutInfo;
+ // If a paragraph is split, it stores the last part of the paragraph.
+ ParagraphLayoutInfo lastParagraphLayoutInfo;
- // Stores indices to the line, word and character of the given position.
+ // Stores indices to the paragraph, word and character of the given position.
TextInfoIndices textInfoIndices;
if( position < relayoutData.mTextLayoutInfo.mNumberOfCharacters )
{
- // Get line, word and character indices for given position.
+ // Get paragraph, word and character indices for given position.
GetIndicesFromGlobalCharacterIndex( position,
relayoutData.mTextLayoutInfo,
textInfoIndices );
- // 1) Split the line
+ // 1) Split the paragraph
- // Split a line in two is needed, then merge the first part of the split line
- // with the first line of the new text, add subsequent lines and merge the last line
- // of the new text with the last part of the split line.
+ // Split a paragraph in two is needed, then merge the first part of the split paragraph
+ // with the first paragraph of the new text, add subsequent paragraphs and merge the last paragraph
+ // of the new text with the last part of the split paragraph.
// Implementation notes!
//
- // These references to the first line are declared in this scope because if new lines are inserted in step 2,
+ // These references to the first paragraph are declared in this scope because if new paragraphs are inserted in step 2,
// they become invalid, making the algorithm to crash if used again.
- // In the step 3, references to the first line are needed and declared again.
+ // In the step 3, references to the first paragraph are needed and declared again.
- // Stores the first part of the split line.
- LineLayoutInfo& firstLineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndices.mLineIndex ) );
+ // Stores the first part of the split paragraph.
+ ParagraphLayoutInfo& firstParagraphLayoutInfo( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + textInfoIndices.mParagraphIndex ) );
- SplitLine( textInfoIndices,
- PointSize( layoutParameters.mLineHeightOffset ),
- firstLineLayoutInfo,
- lastLineLayoutInfo );
+ SplitParagraph( textInfoIndices,
+ PointSize( layoutParameters.mLineHeightOffset ),
+ firstParagraphLayoutInfo,
+ lastParagraphLayoutInfo );
}
else
{
// Position is just after the last character.
// Calculates indices for that position.
- if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
+ if( !relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.empty() )
{
- textInfoIndices.mLineIndex = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.size() - 1u;
- const LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u ) );
+ textInfoIndices.mParagraphIndex = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.size() - 1u;
+ const ParagraphLayoutInfo& paragraphLayoutInfo( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end() - 1u ) );
- if( !lineLayoutInfo.mWordsLayoutInfo.empty() )
+ if( !paragraphLayoutInfo.mWordsLayoutInfo.empty() )
{
- textInfoIndices.mWordIndex = lineLayoutInfo.mWordsLayoutInfo.size() - 1u;
+ textInfoIndices.mWordIndex = paragraphLayoutInfo.mWordsLayoutInfo.size() - 1u;
- const WordLayoutInfo& wordLayoutInfo( *( lineLayoutInfo.mWordsLayoutInfo.end() - 1u ) );
+ const WordLayoutInfo& wordLayoutInfo( *( paragraphLayoutInfo.mWordsLayoutInfo.end() - 1u ) );
textInfoIndices.mCharacterIndex = wordLayoutInfo.mCharactersLayoutInfo.size();
}
}
}
- // 2) If the new text has more than 1 line, merge the last line of the input text with the last part of the split line.
- //TODO check this cases ( num lines ==1, >1, >2 ) if it could be simplified.
- if( relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.size() > 1u )
+ // 2) If the new text has more than 1 paragraph, merge the last paragraph of the input text with the last part of the split paragraph.
+ //TODO check this cases ( num paragraphs ==1, >1, >2 ) if it could be simplified.
+ if( relayoutDataForNewText.mTextLayoutInfo.mParagraphsLayoutInfo.size() > 1u )
{
- LineLayoutInfo& lastInputLineLayoutInfo( *( relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u ) );
+ ParagraphLayoutInfo& lastInputParagraphLayoutInfo( *( relayoutDataForNewText.mTextLayoutInfo.mParagraphsLayoutInfo.end() - 1u ) );
- MergeLine( lastInputLineLayoutInfo,
- lastLineLayoutInfo );
+ MergeParagraph( lastInputParagraphLayoutInfo,
+ lastParagraphLayoutInfo );
- if( relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.size() > 2u )
+ if( relayoutDataForNewText.mTextLayoutInfo.mParagraphsLayoutInfo.size() > 2u )
{
- // Insert all lines except first and last in the text.
- relayoutData.mTextLayoutInfo.mLinesLayoutInfo.insert( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndices.mLineIndex + 1u,
- relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.begin() + 1u,
- relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u );
+ // Insert all paragraphs except first and last in the text.
+ relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.insert( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + textInfoIndices.mParagraphIndex + 1u,
+ relayoutDataForNewText.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + 1u,
+ relayoutDataForNewText.mTextLayoutInfo.mParagraphsLayoutInfo.end() - 1u );
}
- // Insert the last line to the text
- relayoutData.mTextLayoutInfo.mLinesLayoutInfo.insert( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndices.mLineIndex + relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.size() - 1u,
- lastInputLineLayoutInfo );
+ // Insert the last paragraph to the text
+ relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.insert( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + textInfoIndices.mParagraphIndex + relayoutDataForNewText.mTextLayoutInfo.mParagraphsLayoutInfo.size() - 1u,
+ lastInputParagraphLayoutInfo );
}
else
{
- // Merge the new line to the last part of the split line.
- LineLayoutInfo& inputLineLayoutInfo( *relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.begin() );
+ // Merge the new paragraph to the last part of the split paragraph.
+ ParagraphLayoutInfo& inputParagraphLayoutInfo( *relayoutDataForNewText.mTextLayoutInfo.mParagraphsLayoutInfo.begin() );
- MergeLine( inputLineLayoutInfo,
- lastLineLayoutInfo );
+ MergeParagraph( inputParagraphLayoutInfo,
+ lastParagraphLayoutInfo );
}
- // 3) Merge the first line of the split text with the first line of the input text.
- LineLayoutInfo& firstLineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndices.mLineIndex ) );
- LineLayoutInfo& firstInputLineLayoutInfo( *relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.begin() );
+ // 3) Merge the first paragraph of the split text with the first paragraph of the input text.
+ ParagraphLayoutInfo& firstParagraphLayoutInfo( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + textInfoIndices.mParagraphIndex ) );
+ ParagraphLayoutInfo& firstInputParagraphLayoutInfo( *relayoutDataForNewText.mTextLayoutInfo.mParagraphsLayoutInfo.begin() );
- MergeLine( firstLineLayoutInfo,
- firstInputLineLayoutInfo );
+ MergeParagraph( firstParagraphLayoutInfo,
+ firstInputParagraphLayoutInfo );
// 4) Update text info.
{
// Removes 'numberOfCharacters' starting from 'position'.
- // * It checks if text to be deleted is in the same line or not:
- // * If it is not, check which lines need to be split/merged or deleted.
- // * If it is but all characters of the line are going to be deleted, just delete the line (nothing needs to be split/merged)
- // * If only some characters of the same line are going to be deleted, proceed similarly: check if text to be deleted is in the same word.
+ // * It checks if text to be deleted is in the same paragraph or not:
+ // * If it is not, check which paragraphs need to be split/merged or deleted.
+ // * If it is but all characters of the paragraph are going to be deleted, just delete the paragraph (nothing needs to be split/merged)
+ // * If only some characters of the same paragraph are going to be deleted, proceed similarly: check if text to be deleted is in the same word.
// * If it is not, split/merge words.
// * Check if the whole word needs to be deleted.
// * Check if only some characters of the word need to be deleted.
// * Updates layout info.
- // * The algorithm checks if a word separator is deleted (in that case, different words need to be merged) and if a new line separator is deleted (two lines need to be merged).
+ // * The algorithm checks if a word separator is deleted (in that case, different words need to be merged) and if a new paragraph separator is deleted (two paragraphs need to be merged).
// Early return
relayoutData.mCharacterLogicalToVisualMap.erase( relayoutData.mCharacterLogicalToVisualMap.end() - numberOfCharacters, relayoutData.mCharacterLogicalToVisualMap.end() );
relayoutData.mCharacterVisualToLogicalMap.erase( relayoutData.mCharacterVisualToLogicalMap.end() - numberOfCharacters, relayoutData.mCharacterVisualToLogicalMap.end() );
- // Get line, word and character indices for the given start position.
+ // Get paragraph, word and character indices for the given start position.
TextInfoIndices textInfoIndicesBegin;
GetIndicesFromGlobalCharacterIndex( position,
relayoutData.mTextLayoutInfo,
textInfoIndicesBegin );
- // Get line, word and character indices for the given end position (start position + number of characters to be deleted).
+ // Get paragraph, word and character indices for the given end position (start position + number of characters to be deleted).
TextInfoIndices textInfoIndicesEnd;
GetIndicesFromGlobalCharacterIndex( position + numberOfCharacters - 1u,
relayoutData.mTextLayoutInfo,
std::vector<TextActor> removedTextActorsFromMid;
std::vector<TextActor> removedTextActorsFromEnd;
- // Whether lines and words need to be merged.
- bool mergeLines = false;
+ // Whether paragraphs and words need to be merged.
+ bool mergeParagraphs = false;
bool mergeWords = false;
- // Indices of the lines and words to be merged.
+ // Indices of the paragraphs and words to be merged.
TextInfoIndices textInfoMergeIndicesBegin;
TextInfoIndices textInfoMergeIndicesEnd;
- const LineLayoutInfo& lineLayout( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndicesBegin.mLineIndex ) ); // used to check the number of characters of the line
- // if all characters to be deleted are in the same line.
- if( textInfoIndicesBegin.mLineIndex < textInfoIndicesEnd.mLineIndex )
+ const ParagraphLayoutInfo& paragraphLayout( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + textInfoIndicesBegin.mParagraphIndex ) ); // used to check the number of characters of the paragraph
+ // if all characters to be deleted are in the same paragraph.
+ if( textInfoIndicesBegin.mParagraphIndex < textInfoIndicesEnd.mParagraphIndex )
{
- // Deleted text is from different lines. It may need to split two lines, and merge first part of the first one with last part of the last one.
+ // Deleted text is from different paragraphs. It may need to split two paragraphs, and merge first part of the first one with last part of the last one.
- // whether first or last line need to be split and merged with the last part.
- bool mergeFirstLine = false;
- bool mergeLastLine = true;
+ // whether first or last paragraph need to be split and merged with the last part.
+ bool mergeFirstParagraph = false;
+ bool mergeLastParagraph = true;
- textInfoMergeIndicesBegin.mLineIndex = textInfoIndicesBegin.mLineIndex;
- textInfoMergeIndicesEnd.mLineIndex = textInfoIndicesEnd.mLineIndex;
+ textInfoMergeIndicesBegin.mParagraphIndex = textInfoIndicesBegin.mParagraphIndex;
+ textInfoMergeIndicesEnd.mParagraphIndex = textInfoIndicesEnd.mParagraphIndex;
if( ( textInfoIndicesBegin.mWordIndex > 0u ) || ( textInfoIndicesBegin.mCharacterIndex > 0u ) )
{
- // first character to be deleted is not the first one of the current line.
- ++textInfoIndicesBegin.mLineIndex; // won't delete current line
+ // first character to be deleted is not the first one of the current paragraph.
+ ++textInfoIndicesBegin.mParagraphIndex; // won't delete current paragraph
- // As some characters remain, this line could be merged with the last one.
- mergeFirstLine = true;
+ // As some characters remain, this paragraph could be merged with the last one.
+ mergeFirstParagraph = true;
}
- // Check if all characters of the last line are going to be deleted.
- bool wholeLineDeleted = false;
- const LineLayoutInfo& lastLineLayout( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndicesEnd.mLineIndex ) );
- if( textInfoIndicesEnd.mWordIndex + 1u == lastLineLayout.mWordsLayoutInfo.size() )
+ // Check if all characters of the last paragraph are going to be deleted.
+ bool wholeParagraphDeleted = false;
+ const ParagraphLayoutInfo& lastParagraphLayout( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + textInfoIndicesEnd.mParagraphIndex ) );
+ if( textInfoIndicesEnd.mWordIndex + 1u == lastParagraphLayout.mWordsLayoutInfo.size() )
{
- const WordLayoutInfo& lastWordLayout( *( lastLineLayout.mWordsLayoutInfo.begin() + textInfoIndicesEnd.mWordIndex ) );
+ const WordLayoutInfo& lastWordLayout( *( lastParagraphLayout.mWordsLayoutInfo.begin() + textInfoIndicesEnd.mWordIndex ) );
if( textInfoIndicesEnd.mCharacterIndex + 1u == lastWordLayout.mCharactersLayoutInfo.size() )
{
- // All characters of the last line are going to be deleted.
- ++textInfoIndicesEnd.mLineIndex; // will delete the last line.
+ // All characters of the last paragraph are going to be deleted.
+ ++textInfoIndicesEnd.mParagraphIndex; // will delete the last paragraph.
- // the whole last line is deleted. Need to check if the next line could be merged.
- mergeLastLine = false;
- wholeLineDeleted = true;
+ // the whole last paragraph is deleted. Need to check if the next paragraph could be merged.
+ mergeLastParagraph = false;
+ wholeParagraphDeleted = true;
}
}
- if( wholeLineDeleted )
+ if( wholeParagraphDeleted )
{
- // It means the whole last line is deleted completely.
- // It's needed to check if there is another line after that could be merged.
- if( textInfoIndicesEnd.mLineIndex < relayoutData.mTextLayoutInfo.mLinesLayoutInfo.size() )
+ // It means the whole last paragraph is deleted completely.
+ // It's needed to check if there is another paragraph after that could be merged.
+ if( textInfoIndicesEnd.mParagraphIndex < relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.size() )
{
- mergeLastLine = true;
+ mergeLastParagraph = true;
- // Point the first characters of the next line.
+ // Point the first characters of the next paragraph.
textInfoIndicesEnd.mWordIndex = 0u;
textInfoIndicesEnd.mCharacterIndex = 0u;
- textInfoMergeIndicesEnd.mLineIndex = textInfoIndicesEnd.mLineIndex;
+ textInfoMergeIndicesEnd.mParagraphIndex = textInfoIndicesEnd.mParagraphIndex;
}
}
- // If some characters remain in the first and last line, they need to be merged.
- mergeLines = mergeFirstLine && mergeLastLine;
+ // If some characters remain in the first and last paragraph, they need to be merged.
+ mergeParagraphs = mergeFirstParagraph && mergeLastParagraph;
- if( mergeLines )
+ if( mergeParagraphs )
{
- // last line is going to be merged with the first one, so is not needed.
- ++textInfoIndicesEnd.mLineIndex; // will delete the last line.
+ // last paragraph is going to be merged with the first one, so is not needed.
+ ++textInfoIndicesEnd.mParagraphIndex; // will delete the last paragraph.
}
- if( mergeFirstLine )
+ if( mergeFirstParagraph )
{
- // Remove characters from the first line.
+ // Remove characters from the first paragraph.
- // Vectors used to temporary store text-actors removed from the line.
+ // Vectors used to temporary store text-actors removed from the paragraph.
// Three vectors are needed because text-actors are not removed in order
// but insert them in order is required to reuse them later.
std::vector<TextActor> removedTextActorsFromFirstWord;
- std::vector<TextActor> removedTextActorsFromFirstLine;
+ std::vector<TextActor> removedTextActorsFromFirstParagraph;
- // As lineIndexBegin has been increased just to not to remove the line, decrease now is needed to access it.
- LineLayoutInfo& lineLayout( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndicesBegin.mLineIndex - 1u ) );
+ // As paragraphIndexBegin has been increased just to not to remove the paragraph, decrease now is needed to access it.
+ ParagraphLayoutInfo& paragraphLayout( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + textInfoIndicesBegin.mParagraphIndex - 1u ) );
- if( ( textInfoIndicesBegin.mWordIndex + 1u < lineLayout.mWordsLayoutInfo.size() ) || ( 0u == textInfoIndicesBegin.mCharacterIndex ) )
+ if( ( textInfoIndicesBegin.mWordIndex + 1u < paragraphLayout.mWordsLayoutInfo.size() ) || ( 0u == textInfoIndicesBegin.mCharacterIndex ) )
{
- // Remove extra words within current line. (and current word if whole characters are removed)
+ // Remove extra words within current paragraph. (and current word if whole characters are removed)
// 0 == characterIndexBegin means the whole word is deleted.
const std::size_t wordIndex = ( ( 0u == textInfoIndicesBegin.mCharacterIndex ) ? textInfoIndicesBegin.mWordIndex : textInfoIndicesBegin.mWordIndex + 1u );
// Store text-actors before removing them.
- CollectTextActorsFromWords( removedTextActorsFromFirstLine, lineLayout, wordIndex, lineLayout.mWordsLayoutInfo.size() );
+ CollectTextActorsFromWords( removedTextActorsFromFirstParagraph, paragraphLayout, wordIndex, paragraphLayout.mWordsLayoutInfo.size() );
- RemoveWordsFromLine( wordIndex,
- lineLayout.mWordsLayoutInfo.size() - wordIndex,
- layoutParameters.mLineHeightOffset,
- lineLayout );
+ RemoveWordsFromParagraph( wordIndex,
+ paragraphLayout.mWordsLayoutInfo.size() - wordIndex,
+ layoutParameters.mLineHeightOffset,
+ paragraphLayout );
}
- if( ( textInfoIndicesBegin.mWordIndex < lineLayout.mWordsLayoutInfo.size() ) && ( textInfoIndicesBegin.mCharacterIndex > 0u ) )
+ if( ( textInfoIndicesBegin.mWordIndex < paragraphLayout.mWordsLayoutInfo.size() ) && ( textInfoIndicesBegin.mCharacterIndex > 0u ) )
{
// Only some characters of the word need to be removed.
- WordLayoutInfo& wordLayout( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex ) );
+ WordLayoutInfo& wordLayout( *( paragraphLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex ) );
// Store text-actors before removing them.
CollectTextActors( removedTextActorsFromFirstWord, wordLayout, textInfoIndicesBegin.mCharacterIndex, wordLayout.mCharactersLayoutInfo.size() );
// discount the removed number of characters.
const std::size_t removedNumberOfCharacters = ( wordNumberCharacters - wordLayout.mCharactersLayoutInfo.size() );
- lineLayout.mNumberOfCharacters -= removedNumberOfCharacters;
+ paragraphLayout.mNumberOfCharacters -= removedNumberOfCharacters;
}
- UpdateLayoutInfo( lineLayout, layoutParameters.mLineHeightOffset );
+ UpdateLayoutInfo( paragraphLayout, layoutParameters.mLineHeightOffset );
// Insert the text-actors in order.
removedTextActorsFromBegin.insert( removedTextActorsFromBegin.end(), removedTextActorsFromFirstWord.begin(), removedTextActorsFromFirstWord.end() );
- removedTextActorsFromBegin.insert( removedTextActorsFromBegin.end(), removedTextActorsFromFirstLine.begin(), removedTextActorsFromFirstLine.end() );
+ removedTextActorsFromBegin.insert( removedTextActorsFromBegin.end(), removedTextActorsFromFirstParagraph.begin(), removedTextActorsFromFirstParagraph.end() );
}
- if( mergeLastLine && !wholeLineDeleted )
+ if( mergeLastParagraph && !wholeParagraphDeleted )
{
- // Some characters from the last line need to be removed.
+ // Some characters from the last paragraph need to be removed.
- // Vectors used to temporary store text-actors removed from the line.
+ // Vectors used to temporary store text-actors removed from the paragraph.
// Three vectors are needed because text-actors are not removed in order
// but insert them in order is required to reuse them later.
std::vector<TextActor> removedTextActorsFromFirstWord;
- std::vector<TextActor> removedTextActorsFromFirstLine;
+ std::vector<TextActor> removedTextActorsFromFirstParagraph;
- // lineIndexEnd was increased to delete the last line if lines need to be merged.
- // To access now the last line we need to decrease the index.
- const std::size_t lineIndex = ( mergeLines ? textInfoIndicesEnd.mLineIndex - 1u : textInfoIndicesEnd.mLineIndex );
+ // paragraphIndexEnd was increased to delete the last paragraph if paragraphs need to be merged.
+ // To access now the last paragraph we need to decrease the index.
+ const std::size_t paragraphIndex = ( mergeParagraphs ? textInfoIndicesEnd.mParagraphIndex - 1u : textInfoIndicesEnd.mParagraphIndex );
- // Get the last line.
- LineLayoutInfo& lineLayout( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + lineIndex ) );
+ // Get the last paragraph.
+ ParagraphLayoutInfo& paragraphLayout( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + paragraphIndex ) );
// Check if is needed remove the whole word. (If the character index is pointing just after the end of the word)
- const WordLayoutInfo& wordLayout( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesEnd.mWordIndex ) );
+ const WordLayoutInfo& wordLayout( *( paragraphLayout.mWordsLayoutInfo.begin() + textInfoIndicesEnd.mWordIndex ) );
bool removeWholeWord = wordLayout.mCharactersLayoutInfo.size() == textInfoIndicesEnd.mCharacterIndex + 1u;
if( ( textInfoIndicesEnd.mWordIndex > 0u ) || ( removeWholeWord ) )
{
// Store text-actors before removing them.
- CollectTextActorsFromWords( removedTextActorsFromFirstLine,
- lineLayout,
+ CollectTextActorsFromWords( removedTextActorsFromFirstParagraph,
+ paragraphLayout,
0u,
( removeWholeWord ) ? textInfoIndicesEnd.mWordIndex + 1u : textInfoIndicesEnd.mWordIndex );
// Remove extra words. (and current word if whole characters are removed)
- RemoveWordsFromLine( 0u,
- ( removeWholeWord ) ? textInfoIndicesEnd.mWordIndex + 1u : textInfoIndicesEnd.mWordIndex,
- layoutParameters.mLineHeightOffset,
- lineLayout );
+ RemoveWordsFromParagraph( 0u,
+ ( removeWholeWord ) ? textInfoIndicesEnd.mWordIndex + 1u : textInfoIndicesEnd.mWordIndex,
+ layoutParameters.mLineHeightOffset,
+ paragraphLayout );
}
if( !removeWholeWord )
// Only some characters of the word need to be deleted.
// After removing all extra words. The word with the characters to be removed is the first one.
- WordLayoutInfo& wordLayout( *lineLayout.mWordsLayoutInfo.begin() );
+ WordLayoutInfo& wordLayout( *paragraphLayout.mWordsLayoutInfo.begin() );
// Store text-actors before removing them.
CollectTextActors( removedTextActorsFromFirstWord, wordLayout, 0u, textInfoIndicesEnd.mCharacterIndex + 1u );
// discount the removed number of characters.
const std::size_t removedNumberOfCharacters = ( wordNumberCharacters - wordLayout.mCharactersLayoutInfo.size() );
- lineLayout.mNumberOfCharacters -= removedNumberOfCharacters;
+ paragraphLayout.mNumberOfCharacters -= removedNumberOfCharacters;
}
- UpdateLayoutInfo( lineLayout, layoutParameters.mLineHeightOffset );
+ UpdateLayoutInfo( paragraphLayout, layoutParameters.mLineHeightOffset );
// Insert the text-actors in order.
removedTextActorsFromEnd.insert( removedTextActorsFromEnd.end(), removedTextActorsFromFirstWord.begin(), removedTextActorsFromFirstWord.end() );
- removedTextActorsFromEnd.insert( removedTextActorsFromEnd.end(), removedTextActorsFromFirstLine.begin(), removedTextActorsFromFirstLine.end() );
+ removedTextActorsFromEnd.insert( removedTextActorsFromEnd.end(), removedTextActorsFromFirstParagraph.begin(), removedTextActorsFromFirstParagraph.end() );
}
- } // end delete text from different lines
- else if( ( textInfoIndicesBegin.mLineIndex == textInfoIndicesEnd.mLineIndex ) && ( lineLayout.mNumberOfCharacters == numberOfCharacters ) )
+ } // end delete text from different paragraphs
+ else if( ( textInfoIndicesBegin.mParagraphIndex == textInfoIndicesEnd.mParagraphIndex ) && ( paragraphLayout.mNumberOfCharacters == numberOfCharacters ) )
{
- // the whole line needs to be deleted.
- ++textInfoIndicesEnd.mLineIndex; // will delete current line.
+ // the whole paragraph needs to be deleted.
+ ++textInfoIndicesEnd.mParagraphIndex; // will delete current paragraph.
}
else
{
- // deleted text is within the same line. (merge lines could be needed if the line separator character is deleted)
-
- // Line which contains the characters to be deleted.
- LineLayoutInfo& lineLayout( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndicesBegin.mLineIndex ) );
-
- // Remove the characters from the line layout info. It returns whether the current line can be merged with the next one.
- RemoveCharactersFromLineInfo( relayoutData,
- numberOfCharacters,
- mergeWords,
- mergeLines,
- textInfoIndicesBegin,
- textInfoIndicesEnd,
- textInfoMergeIndicesBegin,
- textInfoMergeIndicesEnd,
- lineLayout,
- removedTextActorsFromBegin,
- removedTextActorsFromEnd );
+ // deleted text is within the same paragraph. (merge paragraphs could be needed if the paragraph separator character is deleted)
+
+ // Paragraph which contains the characters to be deleted.
+ ParagraphLayoutInfo& paragraphLayout( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + textInfoIndicesBegin.mParagraphIndex ) );
+
+ // Remove the characters from the paragraph layout info. It returns whether the current paragraph can be merged with the next one.
+ RemoveCharactersFromParagraphInfo( relayoutData,
+ numberOfCharacters,
+ mergeWords,
+ mergeParagraphs,
+ textInfoIndicesBegin,
+ textInfoIndicesEnd,
+ textInfoMergeIndicesBegin,
+ textInfoMergeIndicesEnd,
+ paragraphLayout,
+ removedTextActorsFromBegin,
+ removedTextActorsFromEnd );
if( mergeWords )
{
// Merges words pointed by textInfoMergeIndicesBegin.mWordIndex and textInfoMergeIndicesEnd.mWordIndex calculated previously.
- DALI_ASSERT_DEBUG( ( textInfoMergeIndicesBegin.mWordIndex < lineLayout.mWordsLayoutInfo.size() ) && "TextViewProcessor::UpdateTextInfo (delete). Word index (begin) out of bounds." );
- DALI_ASSERT_DEBUG( ( textInfoMergeIndicesEnd.mWordIndex < lineLayout.mWordsLayoutInfo.size() ) && "TextViewProcessor::UpdateTextInfo (delete). Word index (end) out of bounds." );
+ DALI_ASSERT_DEBUG( ( textInfoMergeIndicesBegin.mWordIndex < paragraphLayout.mWordsLayoutInfo.size() ) && "TextViewProcessor::UpdateTextInfo (delete). Word index (begin) out of bounds." );
+ DALI_ASSERT_DEBUG( ( textInfoMergeIndicesEnd.mWordIndex < paragraphLayout.mWordsLayoutInfo.size() ) && "TextViewProcessor::UpdateTextInfo (delete). Word index (end) out of bounds." );
- WordLayoutInfo& firstWordLayout( *( lineLayout.mWordsLayoutInfo.begin() + textInfoMergeIndicesBegin.mWordIndex ) );
- WordLayoutInfo& lastWordLayout( *( lineLayout.mWordsLayoutInfo.begin() + textInfoMergeIndicesEnd.mWordIndex ) );
+ WordLayoutInfo& firstWordLayout( *( paragraphLayout.mWordsLayoutInfo.begin() + textInfoMergeIndicesBegin.mWordIndex ) );
+ WordLayoutInfo& lastWordLayout( *( paragraphLayout.mWordsLayoutInfo.begin() + textInfoMergeIndicesEnd.mWordIndex ) );
MergeWord( firstWordLayout,
lastWordLayout );
// Store text-actors before removing them.
const std::size_t endIndex = ( mergeWords && ( textInfoIndicesEnd.mWordIndex > 0u ) ) ? textInfoIndicesEnd.mWordIndex - 1u : textInfoIndicesEnd.mWordIndex; // text-actors from the last word may have been added in the merge above.
- CollectTextActorsFromWords( removedTextActorsFromMid, lineLayout, textInfoIndicesBegin.mWordIndex, endIndex );
+ CollectTextActorsFromWords( removedTextActorsFromMid, paragraphLayout, textInfoIndicesBegin.mWordIndex, endIndex );
// Remove unwanted words using previously calculated indices. (including the last part of the merged word)
- lineLayout.mWordsLayoutInfo.erase( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex, lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesEnd.mWordIndex );
+ paragraphLayout.mWordsLayoutInfo.erase( paragraphLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex, paragraphLayout.mWordsLayoutInfo.begin() + textInfoIndicesEnd.mWordIndex );
- // Update line info.
- UpdateLayoutInfo( lineLayout, layoutParameters.mLineHeightOffset );
- }// end delete text from same line.
+ // Update paragraph info.
+ UpdateLayoutInfo( paragraphLayout, layoutParameters.mLineHeightOffset );
+ }// end delete text from same paragraph.
- if( mergeLines )
+ if( mergeParagraphs )
{
- // Merges lines pointed by textInfoMergeIndicesBegin.mLineIndex and textInfoMergeIndicesEnd.mLineIndex calculated previously.
+ // Merges paragraphs pointed by textInfoMergeIndicesBegin.mParagraphIndex and textInfoMergeIndicesEnd.mParagraphIndex calculated previously.
- LineLayoutInfo& firstLineLayout( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoMergeIndicesBegin.mLineIndex ) );
+ ParagraphLayoutInfo& firstParagraphLayout( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + textInfoMergeIndicesBegin.mParagraphIndex ) );
- const LineLayoutInfo& lastLineLayout( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoMergeIndicesEnd.mLineIndex ) );
+ const ParagraphLayoutInfo& lastParagraphLayout( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + textInfoMergeIndicesEnd.mParagraphIndex ) );
- MergeLine( firstLineLayout,
- lastLineLayout );
+ MergeParagraph( firstParagraphLayout,
+ lastParagraphLayout );
}
// Store text-actors before removing them.
- const std::size_t endIndex = ( mergeLines && ( textInfoIndicesEnd.mLineIndex > 0u ) ) ? textInfoIndicesEnd.mLineIndex - 1u : textInfoIndicesEnd.mLineIndex; // text-actors from the last line may have been added in the merge above.
- CollectTextActorsFromLines( removedTextActorsFromMid,
+ const std::size_t endIndex = ( mergeParagraphs && ( textInfoIndicesEnd.mParagraphIndex > 0u ) ) ? textInfoIndicesEnd.mParagraphIndex - 1u : textInfoIndicesEnd.mParagraphIndex; // text-actors from the last paragraph may have been added in the merge above.
+ CollectTextActorsFromParagraphs( removedTextActorsFromMid,
relayoutData.mTextLayoutInfo,
- textInfoIndicesBegin.mLineIndex,
+ textInfoIndicesBegin.mParagraphIndex,
endIndex );
- // Remove unwanted lines using previously calculated indices. (including the last part of the merged line)
- relayoutData.mTextLayoutInfo.mLinesLayoutInfo.erase( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndicesBegin.mLineIndex,
- relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndicesEnd.mLineIndex );
+ // Remove unwanted paragraphs using previously calculated indices. (including the last part of the merged paragraph)
+ relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.erase( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + textInfoIndicesBegin.mParagraphIndex,
+ relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + textInfoIndicesEnd.mParagraphIndex );
// Update text info.
UpdateLayoutInfo( relayoutData.mTextLayoutInfo );
- // If the last character of the last line is a new line character, an empty line need to be added.
- if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
+ // If the last character of the last paragraph is a new paragraph character, an empty paragraph need to be added.
+ if( !relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.empty() )
{
- const WordLayoutInfo lastWordLayout = GetLastWordLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u ) );
+ const WordLayoutInfo lastWordLayout = GetLastWordLayoutInfo( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end() - 1u ) );
- if( LineSeparator == lastWordLayout.mType )
+ if( ParagraphSeparator == lastWordLayout.mType )
{
- LineLayoutInfo lastLineLayout;
+ ParagraphLayoutInfo lastParagraphLayout;
const CharacterLayoutInfo layoutInfo = GetLastCharacterLayoutInfo( lastWordLayout );
- lastLineLayout.mSize.height = layoutInfo.mSize.height;
+ lastParagraphLayout.mSize.height = layoutInfo.mSize.height;
- relayoutData.mTextLayoutInfo.mLinesLayoutInfo.push_back( lastLineLayout );
+ relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.push_back( lastParagraphLayout );
relayoutData.mTextLayoutInfo.mWholeTextSize.height += layoutInfo.mSize.height;
}
relayoutData );
}
-void UpdateTextInfo( const float lineHeightOffset,
+void UpdateTextInfo( float lineHeightOffset,
TextLayoutInfo& textLayoutInfo )
{
// Updates the space between lines with the new offset value.
float newTextHeight = 0.f;
- for( LineLayoutInfoContainer::iterator lineIt = textLayoutInfo.mLinesLayoutInfo.begin(), lineEndIt = textLayoutInfo.mLinesLayoutInfo.end();
- lineIt != lineEndIt;
- ++lineIt )
+ for( ParagraphLayoutInfoContainer::iterator paragraphIt = textLayoutInfo.mParagraphsLayoutInfo.begin(), paragraphEndIt = textLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphIt != paragraphEndIt;
+ ++paragraphIt )
{
- LineLayoutInfo& lineLayoutInfo( *lineIt );
+ ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphIt );
- lineLayoutInfo.mSize.height += ( lineHeightOffset - lineLayoutInfo.mLineHeightOffset );
- newTextHeight += lineLayoutInfo.mSize.height;
+ paragraphLayoutInfo.mSize.height += ( lineHeightOffset - paragraphLayoutInfo.mLineHeightOffset );
+ newTextHeight += paragraphLayoutInfo.mSize.height;
- lineLayoutInfo.mLineHeightOffset = lineHeightOffset;
+ paragraphLayoutInfo.mLineHeightOffset = lineHeightOffset;
}
textLayoutInfo.mWholeTextSize.height = newTextHeight;
{
// Change text style for all text-actors.
- for( LineLayoutInfoContainer::iterator lineIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(), lineEndIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineIt != lineEndIt;
- ++lineIt )
+ for( ParagraphLayoutInfoContainer::iterator paragraphIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(), paragraphEndIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphIt != paragraphEndIt;
+ ++paragraphIt )
{
- LineLayoutInfo& line( *lineIt );
+ ParagraphLayoutInfo& paragraph( *paragraphIt );
- for( WordLayoutInfoContainer::iterator wordIt = line.mWordsLayoutInfo.begin(), wordEndIt = line.mWordsLayoutInfo.end();
+ for( WordLayoutInfoContainer::iterator wordIt = paragraph.mWordsLayoutInfo.begin(), wordEndIt = paragraph.mWordsLayoutInfo.end();
wordIt != wordEndIt;
++wordIt )
{
characterLayout.mSetStyle = true;
} // end characters
} // end words
- } // end lines
+ } // end paragraphs
}
} // namespace TextViewProcessor
{
}
+WordLayoutInfo::~WordLayoutInfo()
+{
+}
+
WordLayoutInfo::WordLayoutInfo( const WordLayoutInfo& word )
: mSize( word.mSize ),
mAscender( word.mAscender ),
if( character.IsNewLine() && !characterLayoutInfo.mIsColorGlyph )
{
- // A new line character doesn't have any width.
+ // A new paragraph character doesn't have any width.
characterLayoutInfo.mSize.width = 0.f;
}
else
void RemoveCharactersFromWordInfo( TextView::RelayoutData& relayoutData,
const std::size_t numberOfCharacters,
bool& mergeWords,
- bool& mergeLines,
+ bool& mergeParagraphs,
TextInfoIndices& textInfoIndicesBegin,
TextInfoIndices& textInfoIndicesEnd,
TextInfoIndices& textInfoMergeIndicesBegin,
TextInfoIndices& textInfoMergeIndicesEnd,
- LineLayoutInfo& lineLayout,
+ ParagraphLayoutInfo& paragraphLayout,
std::vector<TextActor>& removedTextActors )
{
const TextLayoutInfo& textLayoutInfo = relayoutData.mTextLayoutInfo;
// Get the word.
- WordLayoutInfo& wordLayout( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex ) );
+ WordLayoutInfo& wordLayout( *( paragraphLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex ) );
- if( LineSeparator == wordLayout.mType )
+ if( ParagraphSeparator == wordLayout.mType )
{
- // If the word is a line separator and there is more lines, then current line and the line after need to be merged.
- if( textInfoIndicesBegin.mLineIndex + 1u < textLayoutInfo.mLinesLayoutInfo.size() )
+ // If the word is a paragraph separator and there is more paragraphs, then current paragraph and the paragraph after need to be merged.
+ if( textInfoIndicesBegin.mParagraphIndex + 1u < textLayoutInfo.mParagraphsLayoutInfo.size() )
{
- // current line is not the last one.
+ // current paragraph is not the last one.
- // Update indices to merge lines.
- textInfoMergeIndicesBegin.mLineIndex = textInfoIndicesBegin.mLineIndex;
- textInfoMergeIndicesEnd.mLineIndex = textInfoIndicesBegin.mLineIndex + 1u;
+ // Update indices to merge paragraphs.
+ textInfoMergeIndicesBegin.mParagraphIndex = textInfoIndicesBegin.mParagraphIndex;
+ textInfoMergeIndicesEnd.mParagraphIndex = textInfoIndicesBegin.mParagraphIndex + 1u;
- mergeLines = true;
+ mergeParagraphs = true;
- ++textInfoIndicesBegin.mLineIndex; // increase both indices,
- textInfoIndicesEnd.mLineIndex += 2u; // will delete last line.
+ ++textInfoIndicesBegin.mParagraphIndex; // increase both indices,
+ textInfoIndicesEnd.mParagraphIndex += 2u; // will delete last paragraph.
}
- ++textInfoIndicesEnd.mWordIndex; //will delete the line separator;
+ ++textInfoIndicesEnd.mWordIndex; //will delete the paragraph separator;
}
else if( WordSeparator == wordLayout.mType )
{
// If the word is a word separator. Check if the word before and the word after can be merged.
- if( ( 0u < textInfoIndicesBegin.mWordIndex ) && ( lineLayout.mWordsLayoutInfo.size() > textInfoIndicesBegin.mWordIndex + 1u ) )
+ if( ( 0u < textInfoIndicesBegin.mWordIndex ) && ( paragraphLayout.mWordsLayoutInfo.size() > textInfoIndicesBegin.mWordIndex + 1u ) )
{
- const WordLayoutInfo& wordLayoutBefore( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex - 1u ) );
- const WordLayoutInfo& wordLayoutAfter( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex + 1u ) );
+ const WordLayoutInfo& wordLayoutBefore( *( paragraphLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex - 1u ) );
+ const WordLayoutInfo& wordLayoutAfter( *( paragraphLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex + 1u ) );
if( ( NoSeparator == wordLayoutBefore.mType ) && ( NoSeparator == wordLayoutAfter.mType ) )
{
- // This word is a word separator (white space) and is not the first word of the line nor the last one.
+ // This word is a word separator (white space) and is not the first word of the paragraph nor the last one.
mergeWords = true;
// Set indices to merge the words.
if( ( NoSeparator != firstWordLayoutInfo.mType ) || ( NoSeparator != lastWordLayoutInfo.mType ) )
{
- // Do not merge white spaces or new line characters.
- DALI_ASSERT_ALWAYS( !"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words." );
+ // Do not merge white spaces or new paragraph characters.
+ DALI_ASSERT_ALWAYS( !"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words." );
}
// Merge layout info
}
}
-void CollectTextActorsFromWords( std::vector<TextActor>& textActors, const LineLayoutInfo& line, const std::size_t wordIndexBegin, const std::size_t wordIndexEnd )
+void CollectTextActorsFromWords( std::vector<TextActor>& textActors, const ParagraphLayoutInfo& paragraph, const std::size_t wordIndexBegin, const std::size_t wordIndexEnd )
{
- for( WordLayoutInfoContainer::const_iterator wordIt = line.mWordsLayoutInfo.begin() + wordIndexBegin, wordEndIt = line.mWordsLayoutInfo.begin() + wordIndexEnd;
+ for( WordLayoutInfoContainer::const_iterator wordIt = paragraph.mWordsLayoutInfo.begin() + wordIndexBegin, wordEndIt = paragraph.mWordsLayoutInfo.begin() + wordIndexEnd;
wordIt != wordEndIt;
++wordIt )
{
* It calls the RemoveCharactersFromWord() function to remove characters from the word.
*
* If the word is a white space \e mergeWords will return \e true and \e textInfoMergeIndicesBegin and \e textInfoMergeIndicesEnd will be set to merge the two adjacent words.
- * If the word is a new line character \e mergeLines will return \e true and \e textInfoMergeIndicesBegin and \e textInfoMergeIndicesEnd will be set to merge the two lines.
+ * If the word is a new paragraph character \e mergeParagraphs will return \e true and \e textInfoMergeIndicesBegin and \e textInfoMergeIndicesEnd will be set to merge the two paragraphs.
*
* @param[in,out] relayoutData Natural size (metrics), layout, text-actor info.
* @param[in] numberOfCharacters The number of characters to be deleted.
* @param[out] mergeWords Whether adjacent words need to be merged.
- * @param[out] mergeLines Whether current line need to be merged with the next one.
- * @param[in,out] textInfoIndicesBegin Indices to the line, word and characters from where to delete characters. It returns from where words need to be removed.
- * @param[out] textInfoIndicesEnd If lines or words need to be merged it returns info to delete them (If a word is merged, it has to be removed. Equal for lines).
- * @param[out] textInfoMergeIndicesBegin The indices to the first part of the line and word to be merged.
- * @param[out] textInfoMergeIndicesEnd The indices to the last part of the line and word to be merged.
- * @param[in,out] lineLayout Layout info of the line where the word is located.
+ * @param[out] mergeParagraphs Whether current paragraph need to be merged with the next one.
+ * @param[in,out] textInfoIndicesBegin Indices to the paragraph, word and characters from where to delete characters. It returns from where words need to be removed.
+ * @param[out] textInfoIndicesEnd If paragraphs or words need to be merged it returns info to delete them (If a word is merged, it has to be removed. Equal for paragraphs).
+ * @param[out] textInfoMergeIndicesBegin The indices to the first part of the paragraph and word to be merged.
+ * @param[out] textInfoMergeIndicesEnd The indices to the last part of the paragraph and word to be merged.
+ * @param[in,out] paragraphLayout Layout info of the paragraph where the word is located.
* @param[out] removedTextActors Stores handles of temoved text-actors.
*/
void RemoveCharactersFromWordInfo( TextView::RelayoutData& relayoutData,
std::size_t numberOfCharacters,
bool& mergeWords,
- bool& mergeLines,
+ bool& mergeParagraphs,
TextInfoIndices& textInfoIndicesBegin,
TextInfoIndices& textInfoIndicesEnd,
TextInfoIndices& textInfoMergeIndicesBegin,
TextInfoIndices& textInfoMergeIndicesEnd,
- LineLayoutInfo& lineLayout,
+ ParagraphLayoutInfo& paragraphLayout,
std::vector<TextActor>& removedTextActors );
/**
* Removes a given number of characters from the given word.
*
* @note Does nothing if last part of the word is empty.
* @note If the first part of the word is empty it just copy the last part to it.
- * @note It asserts if the first or the last word is a word separator (white space) or a line separator (new line character)
+ * @note It asserts if the first or the last word is a word separator (white space) or a paragraph separator (new paragraph character)
*
* @param[in,out] firstWordLayoutInfo The input is the layout info of the first word. The output is the layout info of the merged word.
* @param[in] lastWordLayoutInfo Layout info of the last word.
void CollectTextActors( std::vector<TextActor>& textActors, const WordLayoutInfo& word, std::size_t characterIndexBegin, std::size_t characterIndexEnd );
/**
- * Collects text-actors from the given line, within the given indices, and stores them into the text-actor vector.
+ * Collects text-actors from the given paragraph, within the given indices, and stores them into the text-actor vector.
*
- * @param[out] textActors Stores the text-actors of the given line.
- * @param[in] line The line with the words.
+ * @param[out] textActors Stores the text-actors of the given paragraph.
+ * @param[in] paragraph The paragraph with the words.
* @param[in] wordIndexBegin Index to the first word.
* @param[in] wordIndexEnd Index to the last word.
*/
-void CollectTextActorsFromWords( std::vector<TextActor>& textActors, const LineLayoutInfo& line, std::size_t wordIndexBegin, std::size_t wordIndexEnd );
+void CollectTextActorsFromWords( std::vector<TextActor>& textActors, const ParagraphLayoutInfo& paragraph, std::size_t wordIndexBegin, std::size_t wordIndexEnd );
} //namespace TextViewProcessor
$(toolkit_base_src_dir)/controls/text-view/text-processor.cpp \
$(toolkit_base_src_dir)/controls/text-view/text-view-impl.cpp \
$(toolkit_base_src_dir)/controls/text-view/text-view-character-processor.cpp \
- $(toolkit_base_src_dir)/controls/text-view/text-view-line-processor.cpp \
+ $(toolkit_base_src_dir)/controls/text-view/text-view-paragraph-processor.cpp \
$(toolkit_base_src_dir)/controls/text-view/text-view-processor.cpp \
$(toolkit_base_src_dir)/controls/text-view/text-view-processor-dbg.cpp \
$(toolkit_base_src_dir)/controls/text-view/text-view-processor-helper-functions.cpp \
: mSize(),
mPosition(),
mIsNewLineChar( false ),
+ mIsNewParagraphChar( false ),
mIsRightToLeftCharacter( false ),
mIsVisible( true ),
mDescender()
TextView::CharacterLayoutInfo::CharacterLayoutInfo( const TextView::CharacterLayoutInfo& characterLayoutInfo )
: mSize( characterLayoutInfo.mSize ),
mPosition( characterLayoutInfo.mPosition ),
- mIsNewLineChar( characterLayoutInfo.mIsNewLineChar ),
+ mIsNewLineChar( characterLayoutInfo.mIsNewParagraphChar ),
+ mIsNewParagraphChar( characterLayoutInfo.mIsNewParagraphChar ),
mIsRightToLeftCharacter( characterLayoutInfo.mIsRightToLeftCharacter ),
mIsVisible( characterLayoutInfo.mIsVisible ),
mDescender( characterLayoutInfo.mDescender )
{
mSize = characterLayoutInfo.mSize;
mPosition = characterLayoutInfo.mPosition;
- mIsNewLineChar = characterLayoutInfo.mIsNewLineChar;
+ mIsNewLineChar = characterLayoutInfo.mIsNewParagraphChar;
+ mIsNewParagraphChar = characterLayoutInfo.mIsNewParagraphChar;
mIsRightToLeftCharacter = characterLayoutInfo.mIsRightToLeftCharacter;
mIsVisible = characterLayoutInfo.mIsVisible;
mDescender = characterLayoutInfo.mDescender;
TextView::CharacterLayoutInfo::CharacterLayoutInfo( const Size& size,
const Vector3& position,
- bool isNewLineChar,
+ bool isNewParagraphChar,
bool isRightToLeftCharacter,
bool isVisible,
float descender )
: mSize( size ),
mPosition( position ),
- mIsNewLineChar( isNewLineChar ),
+ mIsNewLineChar( isNewParagraphChar ),
+ mIsNewParagraphChar( isNewParagraphChar ),
mIsRightToLeftCharacter( isRightToLeftCharacter ),
mIsVisible( isVisible ),
mDescender( descender )
*
* @param[in] size of the character.
* @param[in] position of the character.
- * @param[in] isNewLineChar Whether the character is a new line character.
+ * @param[in] isNewParagraphChar Whether the character is a new paragraph character.
* @param[in] isRightToLeftCharacter Whether is a right to left character.
* @param[in] visible Whether is visible.
* @param[in] descender of the character (distance from the base line to the bottom of the character.)
*/
CharacterLayoutInfo( const Size& size,
const Vector3& position,
- bool isNewLineChar,
+ bool isNewParagraphChar,
bool isRightToLeftCharacter,
bool visible,
float descender );
Size mSize; ///< Size of the character.
Vector3 mPosition; ///< Position of the character within the text view.
- bool mIsNewLineChar:1; ///< Whether this character represent a new line.
+ bool mIsNewLineChar:1; ///< @deprecated. Use mIsNewParagraphChar instead.
+ bool mIsNewParagraphChar:1; ///< Whether this character represent a new paragraph.
bool mIsRightToLeftCharacter:1; ///< Whether it's a right-to-left character.
bool mIsVisible:1; ///< Whether this character is visible or not.
float mDescender; ///< The character's descender which is the distance from the baseline to the bottom of the character
typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer; ///< Container of layout info per character.
/**
- * @brief Stores some info about a laid-out line.
+ * @brief Stores some info about a line.
*/
struct LineLayoutInfo
{
- std::size_t mCharacterGlobalIndex; ///< Global index within the whole text of the first character of current laid-out line.
- Size mSize; ///< Size of the current laid-out line.
- float mAscender; ///< The max ascender of the current laid-out line.
+ std::size_t mCharacterGlobalIndex; ///< Global index within the whole text of the first character of current line.
+ Size mSize; ///< Size of the current line.
+ float mAscender; ///< The max ascender of the current line.
};
typedef std::vector<LineLayoutInfo> LineLayoutInfoContainer; ///< Container of layout info per line.
TextLayoutInfo& operator=( const TextLayoutInfo& textLayoutInfo );
CharacterLayoutInfoContainer mCharacterLayoutInfoTable; ///< The table of character's positions and sizes sorted by the character's visual index.
- LineLayoutInfoContainer mLines; ///< For each laid-out line, it stores an index to the first character of the line.
+ LineLayoutInfoContainer mLines; ///< For each line, it stores an index to the first character of the line.
std::vector<int> mCharacterLogicalToVisualMap; ///< The map to store the character's logical (input) index according to its visual (reordered) index.
std::vector<int> mCharacterVisualToLogicalMap; ///< The map to store the character's visual (reordered) index according to its logical (input) index.
Size mTextSize; ///< Text size after relayout.
};
/**
- * @brief Define how to wrap the text in lines.
+ * @brief Define how to wrap the text's paragraphs in lines.
*
- * \e SplitByNewLineChar will wrap the text in lines when a '\\n' character or a \<br /\> is found.
+ * \e SplitByNewLineChar will wrap the text's paragraphs in lines when a '\\n' character or a \<br /\> is found.
* \e SplitByWord has effect only when TextView size is assigned.
- * It will wrap the text in lines when a '\\n' character or a \<br /\> is found or if a line exceeds the TextView's boundary. This option won't split a word in two.
+ * It will wrap the text's paragraphs in lines when a '\\n' character or a \<br /\> is found or if a paragraph exceeds the TextView's boundary. This option won't split a word in two.
* \e SplitByChar has effect only when TextView size is assigned.
- * It will wrap the text in lines when a '\\n' character or a \<br /\> is found or if a line exceeds the TextView's boundary. This option might split a word in two.
+ * It will wrap the text's paragraphs in lines when a '\\n' character or a \<br /\> is found or if a paragraph exceeds the TextView's boundary. This option might split a word in two.
* The default value is \e SplitByNewLineChar.
*/
enum MultilinePolicy
{
- SplitByNewLineChar, ///< Text lines will wrap when '\\n' character is found.
- SplitByWord, ///< Text lines will wrap by word or if '\\n' character is found. It has effect only when TextView size is assigned.
- SplitByChar ///< Text lines will wrap by char or if '\\n' character is found. It has effect only when TextView size is assigned.
+ SplitByNewLineChar, ///< Text's paragraphs will wrap in lines when '\\n' character is found.
+ SplitByWord, ///< Text's paragraphs will wrap in lines by word or if '\\n' character is found. It has effect only when TextView size is assigned.
+ SplitByChar ///< Text's paragraphs will wrap in lines by char or if '\\n' character is found. It has effect only when TextView size is assigned.
};
/**
- * @brief Define how to display the text when it doesn't fit inside the TextView after the line wrap.
+ * @brief Define how to display the lines when they doesn't fit inside the TextView after the text's paragraphs are wrapped in lines.
*
* The default value is \e Original.
*/
enum ExceedPolicy
{
- Original, ///< Will display the text in its original size. If a line, a word or a character is bigger than the TextView size it may exceed its boundary.
- Fade, ///< Will display the text in its original size. It won't display the text which exceeds the TextView boundary. It fades the text out.
- Split, ///< Will split the text in a new line.
- ShrinkToFit, ///< Will shrink the text to fit the TextView boundary.
- EllipsizeEnd ///< Will ellipsize the text by the end.
+ Original, ///< Will display the lines in their original size. If a line, a word or a character is bigger than the TextView size it may exceed its boundary.
+ Fade, ///< Will display the lines in their original size. It won't display the part of the line which exceeds the TextView boundary. It fades the text out.
+ Split, ///< Will split the lines in a new line(s).
+ ShrinkToFit, ///< Will shrink the lines to fit the TextView boundary.
+ EllipsizeEnd ///< Will ellipsize the lines by the end.
};
/**
- * @brief Define how to justify lines inside the text area.
+ * @brief Define how to justify lines inside the text's boundary.
*
* The default value is \e Left.
*/
Alignment::Type GetTextAlignment() const;
/**
- * @brief Sets how to wrap the text in lines policy.
+ * @brief Sets how to split the paragraphs into lines.
*
* @param policy The multi-line policy. \e SplitByNewLineChar is set by default.
*/
ExceedPolicy GetHeightExceedPolicy() const;
/**
- * @brief Sets how to justify lines inside the text area.
+ * @brief Sets how to justify lines inside the text's boundary.
*
* @param justification The line justification. Left is set by default.
*/