// EXTERNAL INCLUDES
#include <limits>
-#include <iostream>
#include <dali/public-api/adaptor-framework/key.h>
#include <dali/integration-api/debug.h>
#include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
#include <dali-toolkit/internal/text/bidirectional-support.h>
#include <dali-toolkit/internal/text/character-set-conversion.h>
#include <dali-toolkit/internal/text/layouts/layout-parameters.h>
-#include <dali-toolkit/internal/text/multi-language-support.h>
-#include <dali-toolkit/internal/text/script-run.h>
-#include <dali-toolkit/internal/text/segmentation.h>
-#include <dali-toolkit/internal/text/shaper.h>
#include <dali-toolkit/internal/text/text-controller-impl.h>
-#include <dali-toolkit/internal/text/text-io.h>
-#include <dali-toolkit/internal/text/text-view.h>
namespace
{
DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfChars %d\n",
this, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfChars );
- if( ! mImpl->IsShowingPlaceholderText() )
+ if( !mImpl->IsShowingPlaceholderText() )
{
// Delete at current cursor position
Vector<Character>& currentText = mImpl->mLogicalModel->mText;
REORDER );
// Queue a cursor reposition event; this must wait until after DoRelayout()
- mImpl->mEventData->mScrollAfterDelete = true;
+ if( 0u == mImpl->mLogicalModel->mText.Count() )
+ {
+ mImpl->mEventData->mUpdateCursorPosition = true;
+ }
+ else
+ {
+ mImpl->mEventData->mScrollAfterDelete = true;
+ }
}
bool Controller::DoRelayout( const Size& size,
ShowPlaceholderText();
}
+ mImpl->mEventData->mUpdateCursorPosition = true; //If editing started without tap event, cursor update must be triggered.
mImpl->RequestRelayout();
}
}
this, text.c_str(), (COMMIT == type ? "COMMIT" : "PRE_EDIT"),
mImpl->mEventData->mPrimaryCursorPosition, mImpl->mEventData->mPreEditFlag, mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
+ // TODO: At the moment the underline runs are only for pre-edit.
+ mImpl->mVisualModel->mUnderlineRuns.Clear();
+
Vector<Character> utf32Characters;
Length characterCount( 0u );
}
else // PRE_EDIT
{
- if( ! mImpl->mEventData->mPreEditFlag )
+ if( !mImpl->mEventData->mPreEditFlag )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Entered PreEdit state" );
mImpl->mEventData->mPreEditLength = utf32Characters.Count();
mImpl->mEventData->mPreEditFlag = true;
+ // Add the underline for the pre-edit text.
+ const GlyphIndex* const charactersToGlyphBuffer = mImpl->mVisualModel->mCharactersToGlyph.Begin();
+ const Length* const glyphsPerCharacterBuffer = mImpl->mVisualModel->mGlyphsPerCharacter.Begin();
+
+ const GlyphIndex glyphStart = *( charactersToGlyphBuffer + mImpl->mEventData->mPreEditStartPosition );
+ const CharacterIndex lastPreEditCharacter = mImpl->mEventData->mPreEditStartPosition + ( ( mImpl->mEventData->mPreEditLength > 0u ) ? mImpl->mEventData->mPreEditLength - 1u : 0u );
+ const Length numberOfGlyphsLastCharacter = *( glyphsPerCharacterBuffer + lastPreEditCharacter );
+ const GlyphIndex glyphEnd = *( charactersToGlyphBuffer + lastPreEditCharacter ) + ( numberOfGlyphsLastCharacter > 1u ? numberOfGlyphsLastCharacter - 1u : 0u );
+
+ GlyphRun underlineRun;
+ underlineRun.glyphIndex = glyphStart;
+ underlineRun.numberOfGlyphs = 1u + glyphEnd - glyphStart;
+
+ // TODO: At the moment the underline runs are only for pre-edit.
+ mImpl->mVisualModel->mUnderlineRuns.PushBack( underlineRun );
+
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "mPreEditStartPosition %d mPreEditLength %d\n", mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
}
}
mImpl->mEventData->mEventQueue.push_back( event );
break;
}
+ case LEFT_SELECTION_HANDLE_MARKER:
+ case RIGHT_SELECTION_HANDLE_MARKER:
+ {
+ // Markers do not move the handles.
+ break;
+ }
case HANDLE_TYPE_COUNT:
{
DALI_ASSERT_DEBUG( !"Controller::HandleEvent. Unexpected handle type" );
}
case ImfManager::DELETESURROUNDING:
{
- RemoveText( imfEvent.cursorOffset, imfEvent.numberOfChars );
+ update = RemoveText( imfEvent.cursorOffset, imfEvent.numberOfChars );
+
+ if( update )
+ {
+ if( 0u != mImpl->mLogicalModel->mText.Count() ||
+ !mImpl->IsPlaceholderAvailable() )
+ {
+ mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
+ }
+ else
+ {
+ ShowPlaceholderText();
+ mImpl->mEventData->mUpdateCursorPosition = true;
+ }
+ }
requestRelayout = true;
break;
}