#include <dali-toolkit/internal/controls/text-view/text-processor.h>
#include <dali-toolkit/public-api/controls/buttons/push-button.h>
#include <dali-toolkit/public-api/controls/alignment/alignment.h>
+#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
#include <dali/integration-api/debug.h>
const char* DEFAULT_SELECTION_HANDLE_TWO( DALI_IMAGE_DIR "text-input-selection-handle-right.png" );
const char* DEFAULT_SELECTION_HANDLE_ONE_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-left-press.png" );
const char* DEFAULT_SELECTION_HANDLE_TWO_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-right-press.png" );
-const char* DEFAULT_CURSOR( DALI_IMAGE_DIR "cursor.png" );
-
-const Vector4 DEFAULT_CURSOR_IMAGE_9_BORDER( 2.0f, 2.0f, 2.0f, 2.0f );
const std::size_t CURSOR_BLINK_INTERVAL = 500; ///< Cursor blink interval
const float CHARACTER_THRESHOLD( 2.5f ); ///< the threshold of a line.
const Vector3 DEFAULT_HANDLE_TWO_OFFSET(0.0f, -5.0f, 0.0f); ///< Handle Two's Offset
const float TOP_HANDLE_TOP_OFFSET( 34.0f); ///< Offset between top handle and cutCopyPaste pop-up
const float BOTTOM_HANDLE_BOTTOM_OFFSET(34.0f); ///< Offset between bottom handle and cutCopyPaste pop-up
-const float CURSOR_THICKNESS(6.0f);
+const float CURSOR_THICKNESS(4.0f);
const Degree CURSOR_ANGLE_OFFSET(2.0f); ///< Offset from the angle of italic angle.
+const Vector4 DEFAULT_CURSOR_COLOR(1.0f, 1.0f, 1.0f, 1.0f);
const std::string NEWLINE( "\n" );
const Property::Index TextInput::SELECT_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+11;
const Property::Index TextInput::SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+12;
const Property::Index TextInput::CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+13;
-
const Property::Index TextInput::POP_UP_OFFSET_FROM_TEXT_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+14;
+const Property::Index TextInput::CURSOR_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+15;
+
namespace Internal
{
PropertyRegistration property13( typeRegistration, "select-all-button-position-priority", Toolkit::TextInput::SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty );
PropertyRegistration property14( typeRegistration, "clipboard-button-position-priority", Toolkit::TextInput::CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty );
PropertyRegistration property15( typeRegistration, "popup-offset-from-text", Toolkit::TextInput::POP_UP_OFFSET_FROM_TEXT_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty );
+PropertyRegistration property16( typeRegistration, "cursor-color", Toolkit::TextInput::CURSOR_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty );
+
// [TextInput::HighlightInfo] /////////////////////////////////////////////////
TextInputPtr textInput(new TextInput());
// Pass ownership to CustomActor via derived handle
Dali::Toolkit::TextInput handle(*textInput);
+ handle.SetName( "TextInput");
textInput->Initialize();
-
return handle;
}
originY + boundingRectangle.height );
mBoundingRectangleWorldCoordinates = boundary;
-
- // Set Boundary for Popup so it keeps the Pop-up within the area also.
- mPopupPanel.SetPopupBoundary( boundingRectangle );
}
const Rect<float> TextInput::GetBoundingRectangle() const
{
Actor self = Self();
mActiveLayer = Layer::New();
+ mActiveLayer.SetName ( "ActiveLayerActor" );
mActiveLayer.SetAnchorPoint( AnchorPoint::CENTER);
mActiveLayer.SetParentOrigin( ParentOrigin::CENTER);
// Create 2 cursors (standard LTR and RTL cursor for when text can be added at
// different positions depending on language)
- Image mCursorImage = Image::New( DEFAULT_CURSOR );
- mCursor = CreateCursor( mCursorImage, DEFAULT_CURSOR_IMAGE_9_BORDER );
- mCursorRTL = CreateCursor( mCursorImage, DEFAULT_CURSOR_IMAGE_9_BORDER );
+ mCursor = CreateCursor(DEFAULT_CURSOR_COLOR);
+ mCursorRTL = CreateCursor(DEFAULT_CURSOR_COLOR);
Actor self = Self();
self.Add( mCursor );
{
DALI_LOG_INFO( gLogFilter, Debug::General, "OnLongPress\n" );
+ // Ignore longpress if in selection mode already
+ if( mHighlightMeshActor )
+ {
+ return;
+ }
+
if(longPress.state == Dali::Gesture::Started)
{
// Start edit mode on long press
scrollOffset.x += cursorPosition.x;
}
- if( cursorPosition.y - cursorSize.height < 0.f )
- {
- scrollOffset.y += ( cursorPosition.y - cursorSize.height );
- }
- else if( cursorPosition.y > controlSize.height )
+ if( cursorPosition.y - cursorSize.height < 0.f || cursorPosition.y > controlSize.height )
{
scrollOffset.y += cursorPosition.y;
}
void TextInput::CreateTextViewActor()
{
mDisplayedTextView = Toolkit::TextView::New();
+ mDisplayedTextView.SetName( "TextView ");
mDisplayedTextView.SetMarkupProcessingEnabled( mMarkUpEnabled );
mDisplayedTextView.SetParentOrigin(ParentOrigin::TOP_LEFT);
mDisplayedTextView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
}
else
{
- if( std::abs( imfEvent.cursorOffset ) < mCursorPosition )
+ if( static_cast<std::size_t>(std::abs( imfEvent.cursorOffset )) < mCursorPosition )
{
toDelete = mCursorPosition + imfEvent.cursorOffset;
}
RemoveHighlight();
+ EmitTextModified();
+
if( inheritStyle )
{
const TextStyle oldInputStyle( mInputStyle );
return insertedStringLength;
}
-ImageActor TextInput::CreateCursor( Image cursorImage, const Vector4& border )
+ImageActor TextInput::CreateCursor( const Vector4& color)
{
ImageActor cursor;
-
- if ( cursorImage )
- {
- cursor = ImageActor::New( cursorImage );
- }
- else
- {
- cursor = ImageActor::New( Image::New( DEFAULT_CURSOR ) );
- }
-
- cursor.SetStyle(ImageActor::STYLE_NINE_PATCH);
- cursor.SetNinePatchBorder( border );
+ cursor = CreateSolidColorActor(color);
cursor.SetParentOrigin(ParentOrigin::TOP_LEFT);
cursor.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER);
// 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;
mHighlightMeshActor = MeshActor::New( mHighlightMesh );
mHighlightMeshActor.SetName( "HighlightMeshActor" );
- mHighlightMeshActor.SetInheritShaderEffect( false );
mHighlightMeshActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
mHighlightMeshActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
mHighlightMeshActor.SetPosition( 0.0f, 0.0f, DISPLAYED_HIGHLIGHT_Z_OFFSET );
if( update )
{
CursorUpdate();
+ EmitTextModified();
}
if( insertedStringLength < text.GetLength() )
textInputImpl.SetOffsetFromText( value.Get< Vector4 >() );
break;
}
+ case Toolkit::TextInput::CURSOR_COLOR_PROPERTY:
+ {
+ textInputImpl.mCursor.SetColor( value.Get< Vector4 >() );
+ }
}
}
}
value = textInputImpl.GetOffsetFromText();
break;
}
+ case Toolkit::TextInput::CURSOR_COLOR_PROPERTY:
+ {
+ value = textInputImpl.mCursor.GetCurrentColor();
+ }
}
}
return value;