From b65b76178d928c38e88181fcb52c5fa2fd590036 Mon Sep 17 00:00:00 2001
From: Paul Wisbey
Date: Sat, 2 May 2015 11:12:07 +0100
Subject: [PATCH] Fix for PLACEHOLDER_TEXT_FOCUSED feature
Change-Id: Ifd2601e7f5d9a012d18af9b5279ade4782d9a164
---
.../text/rendering/atlas/text-atlas-renderer.cpp | 2 +-
.../internal/text/text-controller-impl.cpp | 53 +++++++++-------------
dali-toolkit/internal/text/text-controller.cpp | 34 ++++++++++++++
3 files changed, 56 insertions(+), 33 deletions(-)
diff --git a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
index 1825840..6453f9a 100644
--- a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
+++ b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
@@ -307,7 +307,7 @@ struct AtlasRenderer::Impl : public ConnectionTracker
}
#if defined(DEBUG_ENABLED)
Toolkit::AtlasGlyphManager::Metrics metrics = mGlyphManager.GetMetrics();
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "TextAtlasRenderer::GlyphManager::GlyphCount: %i, AtlasCount: %i, TextureMemoryUse: %iK\n",
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextAtlasRenderer::GlyphManager::GlyphCount: %i, AtlasCount: %i, TextureMemoryUse: %iK\n",
metrics.mGlyphCount,
metrics.mAtlasMetrics.mAtlasCount,
metrics.mAtlasMetrics.mTextureMemoryUsed / 1024 );
diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp
index 49b8f3d..00c666e 100644
--- a/dali-toolkit/internal/text/text-controller-impl.cpp
+++ b/dali-toolkit/internal/text/text-controller-impl.cpp
@@ -455,44 +455,33 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event )
void Controller::Impl::OnTapEvent( const Event& event )
{
- if( NULL == mEventData )
+ if( NULL != mEventData )
{
- // Nothing to do if there is no text input.
- return;
- }
+ const unsigned int tapCount = event.p1.mUint;
- const unsigned int tapCount = event.p1.mUint;
-
- if( 1u == tapCount )
- {
- // Grab handle is not shown until a tap is received whilst EDITING
- if( EventData::EDITING == mEventData->mState &&
- !IsShowingPlaceholderText() )
+ if( 1u == tapCount )
{
- if( mEventData->mGrabHandleEnabled )
+ if( ! IsShowingPlaceholderText() )
{
- mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
- }
- mEventData->mDecorator->SetPopupActive( false );
- }
-
- ChangeState( EventData::EDITING );
-
- const float xPosition = event.p2.mFloat - mEventData->mScrollPosition.x - mAlignmentOffset.x;
- const float yPosition = event.p3.mFloat - mEventData->mScrollPosition.y - mAlignmentOffset.y;
-
- mEventData->mPrimaryCursorPosition = GetClosestCursorIndex( xPosition,
- yPosition );
+ const float xPosition = event.p2.mFloat - mEventData->mScrollPosition.x - mAlignmentOffset.x;
+ const float yPosition = event.p3.mFloat - mEventData->mScrollPosition.y - mAlignmentOffset.y;
- mEventData->mUpdateCursorPosition = true;
- mEventData->mScrollAfterUpdateCursorPosition = true;
- }
- else if( mEventData->mSelectionEnabled &&
- ( 2u == tapCount ) )
- {
- ChangeState( EventData::SELECTING );
+ mEventData->mPrimaryCursorPosition = GetClosestCursorIndex( xPosition,
+ yPosition );
+ }
+ else
+ {
+ mEventData->mPrimaryCursorPosition = 0u;
+ }
- RepositionSelectionHandles( event.p2.mFloat, event.p3.mFloat );
+ mEventData->mUpdateCursorPosition = true;
+ mEventData->mScrollAfterUpdateCursorPosition = true;
+ }
+ else if( mEventData->mSelectionEnabled &&
+ ( 2u == tapCount ) )
+ {
+ RepositionSelectionHandles( event.p2.mFloat, event.p3.mFloat );
+ }
}
}
diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp
index 57356d0..99bed83 100644
--- a/dali-toolkit/internal/text/text-controller.cpp
+++ b/dali-toolkit/internal/text/text-controller.cpp
@@ -1122,6 +1122,37 @@ void Controller::TapEvent( unsigned int tapCount, float x, float y )
{
DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected TapEvent" );
+ if( NULL != mImpl->mEventData )
+ {
+ if( 1u == tapCount )
+ {
+ bool tapDuringEditMode( EventData::EDITING == mImpl->mEventData->mState );
+
+ mImpl->ChangeState( EventData::EDITING );
+
+ if( mImpl->IsShowingPlaceholderText() )
+ {
+ // Alternative placeholder-text is used when editing
+ ShowPlaceholderText();
+ }
+ else if( EventData::EDITING == mImpl->mEventData->mState )
+ {
+ // Grab handle is not shown until a tap is received whilst EDITING
+ if( tapDuringEditMode )
+ {
+ mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
+ }
+ mImpl->mEventData->mDecorator->SetPopupActive( false );
+ }
+ }
+ else if( mImpl->mEventData->mSelectionEnabled &&
+ ( 2u == tapCount ) )
+ {
+ mImpl->ChangeState( EventData::SELECTING );
+ }
+ }
+
+ // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
if( mImpl->mEventData )
{
Event event( Event::TAP_EVENT );
@@ -1214,6 +1245,9 @@ void Controller::ShowPlaceholderText()
mImpl->mEventData->mIsShowingPlaceholderText = true;
+ // Cancel previously queued inserts etc.
+ mImpl->mModifyEvents.clear();
+
// Disable handles when showing place-holder text
mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
mImpl->mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
--
2.7.4