/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
const LineIndex lineIndex = mModel->mVisualModel->GetLineOfCharacter( characterIndex );
+ const LineIndex previousLineIndex = ( lineIndex > 0 ? lineIndex - 1u : lineIndex );
- if( lineIndex > 0u )
- {
- // Retrieve the cursor position info.
- CursorInfo cursorInfo;
- GetCursorPosition( mEventData->mPrimaryCursorPosition,
- cursorInfo );
+ // Retrieve the cursor position info.
+ CursorInfo cursorInfo;
+ GetCursorPosition( mEventData->mPrimaryCursorPosition,
+ cursorInfo );
- // Get the line above.
- const LineRun& line = *( mModel->mVisualModel->mLines.Begin() + ( lineIndex - 1u ) );
+ // Get the line above.
+ const LineRun& line = *( mModel->mVisualModel->mLines.Begin() + previousLineIndex );
- // Get the next hit 'y' point.
- const float hitPointY = cursorInfo.lineOffset - 0.5f * ( line.ascender - line.descender );
+ // Get the next hit 'y' point.
+ const float hitPointY = cursorInfo.lineOffset - 0.5f * ( line.ascender - line.descender );
- // Use the cursor hook position 'x' and the next hit 'y' position to calculate the new cursor index.
- mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
- mModel->mLogicalModel,
- mMetrics,
- mEventData->mCursorHookPositionX,
- hitPointY );
- }
+ // Use the cursor hook position 'x' and the next hit 'y' position to calculate the new cursor index.
+ mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+ mModel->mLogicalModel,
+ mMetrics,
+ mEventData->mCursorHookPositionX,
+ hitPointY );
}
else if( Dali::DALI_KEY_CURSOR_DOWN == keyCode )
{
// Whether to retrieve the next line.
if( index == lastGlyphOfLine )
{
- // Retrieve the next line.
- ++lineRun;
-
- // Get the last glyph of the new line.
- lastGlyphOfLine = lineRun->glyphRun.glyphIndex + lineRun->glyphRun.numberOfGlyphs - 1u;
-
++lineIndex;
if( lineIndex < firstLineIndex + numberOfLines )
{
+ // Retrieve the next line.
+ ++lineRun;
+
+ // Get the last glyph of the new line.
+ lastGlyphOfLine = lineRun->glyphRun.glyphIndex + lineRun->glyphRun.numberOfGlyphs - 1u;
+
// Keep the offset and height of the current selection box.
const float currentLineOffset = selectionBoxInfo->lineOffset;
const float currentLineHeight = selectionBoxInfo->lineHeight;