DeleteHighlightedText( false );
// Received key String
- mCursorPosition = mCursorPosition + InsertAt( Text( keyString ), mCursorPosition, 0 );
+ mCursorPosition += InsertAt( Text( keyString ), mCursorPosition, 0 );
update = true;
EmitTextModified();
}
{
// Get height of cursor and set its size
Size size( CURSOR_THICKNESS, 0.0f );
- if (!mTextLayoutInfo.mCharacterLayoutInfoTable.empty())
+ if( !mTextLayoutInfo.mCharacterLayoutInfoTable.empty() )
{
size.height = GetRowRectFromCharacterPosition( GetVisualPosition( mCursorPosition ) ).height;
}
// between RTL and LTR text...
if(characterPosition != mTextLayoutInfo.mCharacterLogicalToVisualMap.size())
{
- std::size_t visualCharacterAltPosition = mTextLayoutInfo.mCharacterLogicalToVisualMap[characterPosition] - 1;
+ std::size_t visualCharacterAltPosition = mTextLayoutInfo.mCharacterLogicalToVisualMap[characterPosition]; // VCC TODO: find why in the previous patch it was a -1 here.
DALI_ASSERT_ALWAYS(visualCharacterAltPosition < mTextLayoutInfo.mCharacterLayoutInfoTable.size());
const Toolkit::TextView::CharacterLayoutInfo& infoAlt = mTextLayoutInfo.mCharacterLayoutInfoTable[ visualCharacterAltPosition ];
void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const MarkupProcessor::StyledTextArray& text )
{
- // Creates metadata with the Insert operation.
- TextViewProcessorMetadata metadata;
- metadata.mType = TextView::TextReplaced;
- metadata.mPosition = position;
- metadata.mNumberOfCharacters = numberOfCharacters;
- metadata.mText = text;
+ std::string textStr;
+ MarkupProcessor::GetPlainString( text, textStr );
- // Store metadata.
- mTextViewProcessorOperations.push_back( metadata );
+ if( TextProcessor::ContainsRightToLeftCharacter( Text( textStr ) ) ||
+ TextProcessor::ContainsRightToLeftCharacter( Text( GetText() ) ) )
+ {
+ // Temporary fix. Creates the whole layout if there is rtl text.
- // Updates current styled text.
- MarkupProcessor::StyledTextArray::iterator it = mCurrentStyledText.begin() + position;
- mCurrentStyledText.erase( it, it + numberOfCharacters );
- it = mCurrentStyledText.begin() + position;
- mCurrentStyledText.insert( it, text.begin(), text.end() );
+ // Updates current styled text.
+ MarkupProcessor::StyledTextArray textToSet = mCurrentStyledText;
- // Request to be relaid out
- RelayoutRequest();
+ MarkupProcessor::StyledTextArray::iterator it = textToSet.begin() + position;
+ textToSet.erase( it, it + numberOfCharacters );
+ it = textToSet.begin() + position;
+ textToSet.insert( it, text.begin(), text.end() );
- // If a GetTextLayoutInfo() or GetHeightForWidth() arrives, relayout the text synchronously is needed on order to retrieve the right values.
- mRelayoutOperations = RELAYOUT_ALL;
+ SetText( textToSet );
+ }
+ else
+ {
+ // Creates metadata with the Insert operation.
+ TextViewProcessorMetadata metadata;
+ metadata.mType = TextView::TextReplaced;
+ metadata.mPosition = position;
+ metadata.mNumberOfCharacters = numberOfCharacters;
+ metadata.mText = text;
+
+ // Store metadata.
+ mTextViewProcessorOperations.push_back( metadata );
+
+ // Updates current styled text.
+ MarkupProcessor::StyledTextArray::iterator it = mCurrentStyledText.begin() + position;
+ mCurrentStyledText.erase( it, it + numberOfCharacters );
+ it = mCurrentStyledText.begin() + position;
+ mCurrentStyledText.insert( it, text.begin(), text.end() );
+
+ // Request to be relaid out
+ RelayoutRequest();
+
+ // If a GetTextLayoutInfo() or GetHeightForWidth() arrives, relayout the text synchronously is needed on order to retrieve the right values.
+ mRelayoutOperations = RELAYOUT_ALL;
+ }
}
void TextView::RemoveTextFrom( std::size_t position, std::size_t numberOfCharacters )
{
- // Creates metadata with the Remove operation.
- TextViewProcessorMetadata metadata;
- metadata.mType = TextView::TextRemoved;
- metadata.mPosition = position;
- metadata.mNumberOfCharacters = numberOfCharacters;
+ if( TextProcessor::ContainsRightToLeftCharacter( Text( GetText() ) ) )
+ {
+ // Temporary fix. Creates the whole layout if there is rtl text.
- // Store metadata.
- mTextViewProcessorOperations.push_back( metadata );
+ // Updates current styled text.
+ MarkupProcessor::StyledTextArray textToSet = mCurrentStyledText;
+ MarkupProcessor::StyledTextArray::iterator it = textToSet.begin() + position;
+ textToSet.erase( it, it + numberOfCharacters );
- // Updates current styled text.
- MarkupProcessor::StyledTextArray::iterator it = mCurrentStyledText.begin() + position;
- mCurrentStyledText.erase( it, it + numberOfCharacters );
+ SetText( textToSet );
+ }
+ else
+ {
+ // Creates metadata with the Remove operation.
+ TextViewProcessorMetadata metadata;
+ metadata.mType = TextView::TextRemoved;
+ metadata.mPosition = position;
+ metadata.mNumberOfCharacters = numberOfCharacters;
- // Request to be relaid out
- RelayoutRequest();
+ // Store metadata.
+ mTextViewProcessorOperations.push_back( metadata );
- // If a GetTextLayoutInfo() or GetHeightForWidth() arrives, relayout the text synchronously is needed on order to retrieve the right values.
- mRelayoutOperations = RELAYOUT_ALL;
+ // Updates current styled text.
+ MarkupProcessor::StyledTextArray::iterator it = mCurrentStyledText.begin() + position;
+ mCurrentStyledText.erase( it, it + numberOfCharacters );
+
+ // Request to be relaid out
+ RelayoutRequest();
+
+ // If a GetTextLayoutInfo() or GetHeightForWidth() arrives, relayout the text synchronously is needed on order to retrieve the right values.
+ mRelayoutOperations = RELAYOUT_ALL;
+ }
}
std::string TextView::GetText() const
CharacterLayoutInfo& operator=( const CharacterLayoutInfo& character );
// Metrics of the glyph.
- Size mSize; ///< Height of the font and advance (the horizontal distance from the origin of the current character and the next one).
- float mBearing; ///< Vertical distance from the baseline to the top of the glyph's boundary box.
- float mAscender; ///< Distance from the base line to the top of the line.
- float mUnderlineThickness; ///< The underline's thickness.
- float mUnderlinePosition; ///< The underline's position.
+ Size mSize; ///< Height of the font and advance (the horizontal distance from the origin of the current character and the next one).
+ float mBearing; ///< Vertical distance from the baseline to the top of the glyph's boundary box.
+ float mAscender; ///< Distance from the base line to the top of the line.
+ float mUnderlineThickness; ///< The underline's thickness.
+ float mUnderlinePosition; ///< The underline's position.
// Position and alignment offset. It depends on the lay-out.
- Vector3 mPosition; ///< Position within the text-view
- Vector2 mOffset; ///< Alignment and justification offset.
-
- RenderableActor mGlyphActor; ///< Handle to a text-actor.
- float mColorAlpha; ///< Alpha component for the initial text color when text is faded.
- GradientInfo* mGradientInfo; ///< Stores gradient info.
-
- bool mIsVisible:1; ///< Whether the text-actor is visible.
- bool mSetText:1; ///< Whether a new text needs to be set in the text-actor.
- bool mSetStyle:1; ///< Whether a new style needs to be set in the text-actor.
- bool mIsColorGlyph:1; ///< Whether this character is an emoticon.
+ Vector3 mPosition; ///< Position within the text-view
+ Vector2 mOffset; ///< Alignment and justification offset.
+
+ RenderableActor mGlyphActor; ///< Handle to a text-actor.
+ float mColorAlpha; ///< Alpha component for the initial text color when text is faded.
+ GradientInfo* mGradientInfo; ///< Stores gradient info.
+
+ bool mIsVisible:1; ///< Whether the text-actor is visible.
+ bool mSetText:1; ///< Whether a new text needs to be set in the text-actor.
+ bool mSetStyle:1; ///< Whether a new style needs to be set in the text-actor.
+ bool mIsColorGlyph:1; ///< Whether this character is an emoticon.
+ bool mIsRightToLeft:1; ///< Whether this character is right to left.
};
typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer;