Merge "Fix for grab/selection handle." into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 1 Jul 2015 16:53:53 +0000 (09:53 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Wed, 1 Jul 2015 16:53:53 +0000 (09:53 -0700)
1  2 
dali-toolkit/internal/text/text-controller-impl.cpp

@@@ -1228,6 -1228,7 +1228,7 @@@ CharacterIndex Controller::Impl::GetClo
  
    // Get the glyphs per character table.
    const Length* const glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin();
+   const Length* const charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin();
  
    // If the vector is void, there is no right to left characters.
    const bool hasRightToLeftCharacters = NULL != visualToLogicalBuffer;
      // The character in logical order.
      const CharacterIndex characterLogicalOrderIndex = hasRightToLeftCharacters ? *( visualToLogicalBuffer + visualIndex ) : visualIndex;
  
+     // Get the script of the character.
+     const Script script = mLogicalModel->GetScript( characterLogicalOrderIndex );
      // The first glyph for that character in logical order.
      const GlyphIndex glyphLogicalOrderIndex = *( charactersToGlyphBuffer + characterLogicalOrderIndex );
      // The number of glyphs for that character
      const Length numberOfGlyphs = *( glyphsPerCharacterBuffer + characterLogicalOrderIndex );
  
  
      const Vector2& position = *( positionsBuffer + glyphLogicalOrderIndex );
  
-     // Find the mid-point of the area containing the glyph
-     const float glyphCenter = -glyphMetrics.xBearing + position.x + 0.5f * glyphMetrics.advance;
+     // Prevents to jump the whole Latin ligatures like fi, ff, ...
+     const Length numberOfCharactersInLigature = ( TextAbstraction::LATIN == script ) ? *( charactersPerGlyphBuffer + glyphLogicalOrderIndex ) : 1u;
+     const float glyphAdvance = glyphMetrics.advance / static_cast<float>( numberOfCharactersInLigature );
+     for( GlyphIndex index = 0u; !matched && ( index < numberOfCharactersInLigature ); ++index )
+     {
+       // Find the mid-point of the area containing the glyph
+       const float glyphCenter = -glyphMetrics.xBearing + position.x + ( static_cast<float>( index ) + 0.5f ) * glyphAdvance;
+       if( visualX < glyphCenter )
+       {
+         visualIndex += index;
+         matched = true;
+         break;
+       }
+     }
  
-     if( visualX < glyphCenter )
+     if( matched )
      {
-       matched = true;
        break;
      }
    }
  
    logicalIndex = hasRightToLeftCharacters ? *( visualToLogicalCursorBuffer + visualIndex ) : visualIndex;
    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "%p closest visualIndex %d logicalIndex %d\n", this, visualIndex, logicalIndex );
    return logicalIndex;
  }
  
@@@ -1762,6 -1779,7 +1779,6 @@@ void Controller::Impl::ScrollTextToMatc
  
    if( cursorInfo.isSecondaryCursor )
    {
 -    mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_BOTH );
      mEventData->mDecorator->SetPosition( SECONDARY_CURSOR,
                                           cursorInfo.secondaryPosition.x + offset.x,
                                           cursorInfo.secondaryPosition.y + offset.y,
                                           cursorInfo.lineHeight );
      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Secondary cursor position: %f,%f\n", cursorInfo.secondaryPosition.x + offset.x, cursorInfo.secondaryPosition.y + offset.y );
    }
 +
 +  // Set which cursors are active according the state.
 +  if( ( EventData::EDITING == mEventData->mState ) ||
 +      ( EventData::EDITING_WITH_POPUP == mEventData->mState ) ||
 +      ( EventData::GRAB_HANDLE_PANNING == mEventData->mState ) )
 +  {
 +    if( cursorInfo.isSecondaryCursor )
 +    {
 +      mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_BOTH );
 +    }
 +    else
 +    {
 +      mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
 +    }
 +  }
    else
    {
 -    mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
 +    mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
    }
  }