Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS");
#endif
+const int MAX_NUMBER_OF_CHARACTERS = 200000;
+
const float MAX_FLOAT = std::numeric_limits<float>::max();
const std::string EMPTY_STRING("");
return mImpl->mEventData->mSelectionEnabled;
}
+void Controller::SetShiftSelectionEnabled( bool enabled )
+{
+ mImpl->mEventData->mShiftSelectionFlag = enabled;
+}
+
+bool Controller::IsShiftSelectionEnabled() const
+{
+ return mImpl->mEventData->mShiftSelectionFlag;
+}
+
// public : Update
void Controller::SetText( const std::string& text )
return mImpl->mModel->mVisualModel->GetOutlineColor();
}
-void Controller::SetOutlineWidth( float width )
+void Controller::SetOutlineWidth( unsigned int width )
{
mImpl->mModel->mVisualModel->SetOutlineWidth( width );
mImpl->RequestRelayout();
}
-float Controller::GetOutlineWidth() const
+unsigned int Controller::GetOutlineWidth() const
{
return mImpl->mModel->mVisualModel->GetOutlineWidth();
}
return EMPTY_STRING;
}
-void Controller::SetDefaultLineSpacing( float lineSpacing )
+bool Controller::SetDefaultLineSpacing( float lineSpacing )
{
- //TODO finish implementation
- mImpl->mLayoutEngine.SetDefaultLineSpacing( lineSpacing );
+ if( std::abs(lineSpacing - mImpl->mLayoutEngine.GetDefaultLineSpacing()) > Math::MACHINE_EPSILON_1000 )
+ {
+ mImpl->mLayoutEngine.SetDefaultLineSpacing(lineSpacing);
+ mImpl->mRecalculateNaturalSize = true;
+ return true;
+ }
+ return false;
}
float Controller::GetDefaultLineSpacing() const
// Clear the update info. This info will be set the next time the text is updated.
mImpl->mTextUpdateInfo.Clear();
+ mImpl->mTextUpdateInfo.mClearAll = true;
// Restore the actual control's width.
mImpl->mModel->mVisualModel->mControlSize.width = actualControlWidth;
Toolkit::DevelText::TextDirection::Type Controller::GetTextDirection()
{
- const LineRun* const firstline = mImpl->mModel->mVisualModel->mLines.Begin();
- if ( firstline && firstline->direction )
+ if( ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) )
+ {
+ return Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT;
+ }
+
+ const Character character = mImpl->mModel->mLogicalModel->mText[0];
+ Script script = TextAbstraction::GetCharacterScript( character );
+
+ if( TextAbstraction::IsRightToLeftScript( script ) )
{
return Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT;
}
return Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT;
}
+Toolkit::DevelText::VerticalLineAlignment::Type Controller::GetVerticalLineAlignment() const
+{
+ return mImpl->mModel->GetVerticalLineAlignment();
+}
+
+void Controller::SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment )
+{
+ mImpl->mModel->mVerticalLineAlignment = alignment;
+}
+
// public : Relayout.
Controller::UpdateTextType Controller::Relayout( const Size& size )
uint32_t numberOfLines = mImpl->mModel->GetNumberOfLines();
// Logic to determine whether this text control will lose focus or not.
- if( ( Dali::DALI_KEY_CURSOR_LEFT == keyCode && 0 == cursorPosition ) ||
- ( Dali::DALI_KEY_CURSOR_RIGHT == keyCode && numberOfCharacters == cursorPosition) ||
+ if( ( Dali::DALI_KEY_CURSOR_LEFT == keyCode && 0 == cursorPosition && !keyEvent.IsShiftModifier() ) ||
+ ( Dali::DALI_KEY_CURSOR_RIGHT == keyCode && numberOfCharacters == cursorPosition && !keyEvent.IsShiftModifier() ) ||
( Dali::DALI_KEY_CURSOR_DOWN == keyCode && cursorLine == numberOfLines -1 ) ||
( Dali::DALI_KEY_CURSOR_DOWN == keyCode && numberOfCharacters == cursorPosition && cursorLine -1 == numberOfLines -1 ) ||
( Dali::DALI_KEY_CURSOR_UP == keyCode && cursorLine == 0 ) ||
( Dali::DALI_KEY_CURSOR_UP == keyCode && numberOfCharacters == cursorPosition && cursorLine == 1 ) )
{
+ // Release the active highlight.
+ if( mImpl->mEventData->mState == EventData::SELECTING )
+ {
+ mImpl->ChangeState( EventData::EDITING );
+
+ // Update selection position.
+ mImpl->mEventData->mLeftSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition;
+ mImpl->mEventData->mRightSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition;
+ mImpl->mEventData->mUpdateCursorPosition = true;
+ mImpl->RequestRelayout();
+ }
return false;
}
if( retrieveText )
{
- mImpl->GetText( numberOfWhiteSpaces, text );
+ if( !mImpl->IsShowingPlaceholderText() )
+ {
+ // Retrieves the normal text string.
+ mImpl->GetText( numberOfWhiteSpaces, text );
+ }
+ else
+ {
+ // When the current text is Placeholder Text, the surrounding text should be empty string.
+ // It means DALi should send empty string ("") to IME.
+ text = "";
+ }
}
ImfManager::ImfCallbackData callbackData( ( retrieveText || retrieveCursor ), cursorPosition, text, false );
{
bool removed = false;
+ // When the users press "Delete All" button, the IME sends numberOfCharacters as '200000' value which means the max number of characters.
+ const bool deleteAll = ( numberOfCharacters >= MAX_NUMBER_OF_CHARACTERS );
+
if( NULL == mImpl->mEventData )
{
return removed;
}
if( mImpl->mEventData->mPreEditFlag || // If the preedit flag is enabled, it means two (or more) of them came together i.e. when two keys have been pressed at the same time.
- ( ( cursorIndex + numberOfCharacters ) <= mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters ) )
+ ( ( cursorIndex + numberOfCharacters ) <= mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters ) || deleteAll /*'Delete All' button clicked*/ )
{
// Mark the paragraphs to be updated.
if( Layout::Engine::SINGLE_LINE_BOX == mImpl->mLayoutEngine.GetLayout() )
const Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mModel->mVisualModel->mGlyphsToCharacters;
const Vector<Length>& charactersPerGlyph = mImpl->mModel->mVisualModel->mCharactersPerGlyph;
const Character* const textBuffer = mImpl->mModel->mLogicalModel->mText.Begin();
- float outlineWidth = mImpl->mModel->GetOutlineWidth();
+ const float outlineWidth = static_cast<float>( mImpl->mModel->GetOutlineWidth() );
// Set the layout parameters.
Layout::Parameters layoutParameters( size,
1,
UPDATE_INPUT_STYLE );
}
- else if( ( mImpl->mEventData->mPrimaryCursorPosition >= 0 ) && ( keyCode == Dali::DevelKey::DALI_KEY_DELETE ) )
+ else if( keyCode == Dali::DevelKey::DALI_KEY_DELETE )
{
// Remove the character after the current cursor position
removed = RemoveText( 0,