projects
/
platform
/
core
/
uifw
/
dali-toolkit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Modify the cursor position.
[platform/core/uifw/dali-toolkit.git]
/
dali-toolkit
/
internal
/
text
/
text-controller-impl.cpp
diff --git
a/dali-toolkit/internal/text/text-controller-impl.cpp
b/dali-toolkit/internal/text/text-controller-impl.cpp
index
5e64f87
..
bd66860
100644
(file)
--- a/
dali-toolkit/internal/text/text-controller-impl.cpp
+++ b/
dali-toolkit/internal/text/text-controller-impl.cpp
@@
-33,7
+33,7
@@
namespace
{
#if defined(DEBUG_ENABLED)
{
#if defined(DEBUG_ENABLED)
- Debug::Filter* gLogFilter = Debug::Filter::New(Debug::
Concise
, true, "LOG_TEXT_CONTROLS");
+ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::
NoLogging
, true, "LOG_TEXT_CONTROLS");
#endif
/**
#endif
/**
@@
-58,8
+58,6
@@
struct GlyphMetrics
float xBearing; ///< The x bearing of the first glyph.
};
float xBearing; ///< The x bearing of the first glyph.
};
-const std::string EMPTY_STRING("");
-
} // namespace
namespace Dali
} // namespace
namespace Dali
@@
-78,20
+76,20
@@
namespace Text
* @param[in] numberOfGlyphs The number of glyphs.
* @param[out] glyphMetrics Some glyph metrics (font height, advance, ascender and x bearing).
* @param[in] visualModel The visual model.
* @param[in] numberOfGlyphs The number of glyphs.
* @param[out] glyphMetrics Some glyph metrics (font height, advance, ascender and x bearing).
* @param[in] visualModel The visual model.
- * @param[in]
fontClient The font c
lient.
+ * @param[in]
metrics Used to access metrics from FontC
lient.
*/
void GetGlyphsMetrics( GlyphIndex glyphIndex,
Length numberOfGlyphs,
GlyphMetrics& glyphMetrics,
*/
void GetGlyphsMetrics( GlyphIndex glyphIndex,
Length numberOfGlyphs,
GlyphMetrics& glyphMetrics,
- VisualModelPtr visualModel,
-
TextAbstraction::FontClient& fontClient
)
+ VisualModelPtr
&
visualModel,
+
MetricsPtr& metrics
)
{
const GlyphInfo* glyphsBuffer = visualModel->mGlyphs.Begin();
const GlyphInfo& firstGlyph = *( glyphsBuffer + glyphIndex );
Text::FontMetrics fontMetrics;
{
const GlyphInfo* glyphsBuffer = visualModel->mGlyphs.Begin();
const GlyphInfo& firstGlyph = *( glyphsBuffer + glyphIndex );
Text::FontMetrics fontMetrics;
-
fontClient.
GetFontMetrics( firstGlyph.fontId, fontMetrics );
+
metrics->
GetFontMetrics( firstGlyph.fontId, fontMetrics );
glyphMetrics.fontHeight = fontMetrics.height;
glyphMetrics.advance = firstGlyph.advance;
glyphMetrics.fontHeight = fontMetrics.height;
glyphMetrics.advance = firstGlyph.advance;
@@
-279,6
+277,8
@@
bool Controller::Impl::ProcessInputEvents()
void Controller::Impl::UpdateModel( OperationsMask operationsRequired )
{
void Controller::Impl::UpdateModel( OperationsMask operationsRequired )
{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::UpdateModel\n" );
+
// Calculate the operations to be done.
const OperationsMask operations = static_cast<OperationsMask>( mOperationsPending & operationsRequired );
// Calculate the operations to be done.
const OperationsMask operations = static_cast<OperationsMask>( mOperationsPending & operationsRequired );
@@
-423,7
+423,7
@@
void Controller::Impl::UpdateModel( OperationsMask operationsRequired )
if( GET_GLYPH_METRICS & operations )
{
GlyphInfo* glyphsBuffer = glyphs.Begin();
if( GET_GLYPH_METRICS & operations )
{
GlyphInfo* glyphsBuffer = glyphs.Begin();
- m
FontClient.
GetGlyphMetrics( glyphsBuffer, numberOfGlyphs );
+ m
Metrics->
GetGlyphMetrics( glyphsBuffer, numberOfGlyphs );
// Update the width and advance of all new paragraph characters.
for( Vector<GlyphIndex>::ConstIterator it = newParagraphGlyphs.Begin(), endIt = newParagraphGlyphs.End(); it != endIt; ++it )
// Update the width and advance of all new paragraph characters.
for( Vector<GlyphIndex>::ConstIterator it = newParagraphGlyphs.Begin(), endIt = newParagraphGlyphs.End(); it != endIt; ++it )
@@
-463,6
+463,7
@@
void Controller::Impl::GetDefaultFonts( Vector<FontRun>& fonts, Length numberOfC
{
if( mFontDefaults )
{
{
if( mFontDefaults )
{
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::GetDefaultFonts font family(%s)\n", mFontDefaults->mFontDescription.family.c_str() );
FontRun fontRun;
fontRun.characterRun.characterIndex = 0;
fontRun.characterRun.numberOfCharacters = numberOfCharacters;
FontRun fontRun;
fontRun.characterRun.characterIndex = 0;
fontRun.characterRun.numberOfCharacters = numberOfCharacters;
@@
-478,8
+479,8
@@
float Controller::Impl::GetDefaultFontLineHeight()
FontId defaultFontId = 0u;
if( NULL == mFontDefaults )
{
FontId defaultFontId = 0u;
if( NULL == mFontDefaults )
{
- defaultFontId = mFontClient.GetFontId( EMPTY_STRING,
-
EMPTY_STRING
);
+ TextAbstraction::FontDescription fontDescription;
+
defaultFontId = mFontClient.GetFontId( fontDescription
);
}
else
{
}
else
{
@@
-487,7
+488,7
@@
float Controller::Impl::GetDefaultFontLineHeight()
}
Text::FontMetrics fontMetrics;
}
Text::FontMetrics fontMetrics;
- m
FontClient.
GetFontMetrics( defaultFontId, fontMetrics );
+ m
Metrics->
GetFontMetrics( defaultFontId, fontMetrics );
return( fontMetrics.ascender - fontMetrics.descender );
}
return( fontMetrics.ascender - fontMetrics.descender );
}
@@
-876,12
+877,14
@@
void Controller::Impl::RetrieveSelection( std::string& selectedText, bool delete
return;
}
return;
}
+ const bool handlesCrossed = mEventData->mLeftSelectionPosition > mEventData->mRightSelectionPosition;
+
//Get start and end position of selection
//Get start and end position of selection
- uint32_t startOfSelectedText = mEventData->mLeftSelectionPosition;
- uint32_t lengthOfSelectedText =
mEventData->mRightSelectionPosition
- startOfSelectedText;
+ uint32_t startOfSelectedText =
handlesCrossed ? mEventData->mRightSelectionPosition :
mEventData->mLeftSelectionPosition;
+ uint32_t lengthOfSelectedText =
( handlesCrossed ? mEventData->mLeftSelectionPosition : mEventData->mRightSelectionPosition )
- startOfSelectedText;
// Validate the start and end selection points
// Validate the start and end selection points
- if(
( startOfSelectedText >= 0 ) && ( ( startOfSelectedText + lengthOfSelectedText ) <= mLogicalModel->mText.Count()
) )
+ if(
( startOfSelectedText + lengthOfSelectedText ) <= mLogicalModel->mText.Count(
) )
{
//Get text as a UTF8 string
Vector<Character>& utf32Characters = mLogicalModel->mText;
{
//Get text as a UTF8 string
Vector<Character>& utf32Characters = mLogicalModel->mText;
@@
-897,7
+900,7
@@
void Controller::Impl::RetrieveSelection( std::string& selectedText, bool delete
Vector<Character>::Iterator last = first + lengthOfSelectedText;
currentText.Erase( first, last );
}
Vector<Character>::Iterator last = first + lengthOfSelectedText;
currentText.Erase( first, last );
}
- mEventData->mPrimaryCursorPosition = mEventData->mLeftSelectionPosition;
+ mEventData->mPrimaryCursorPosition =
handlesCrossed ? mEventData->mRightSelectionPosition :
mEventData->mLeftSelectionPosition;
mEventData->mScrollAfterDelete = true;
mEventData->mDecoratorUpdated = true;
}
mEventData->mScrollAfterDelete = true;
mEventData->mDecoratorUpdated = true;
}
@@
-970,8
+973,16
@@
void Controller::Impl::RepositionSelectionHandles( CharacterIndex selectionStart
const LineRun& firstLine = *lines.Begin();
const float height = firstLine.ascender + -firstLine.descender;
const LineRun& firstLine = *lines.Begin();
const float height = firstLine.ascender + -firstLine.descender;
+ const bool isLastCharacter = selectionEnd >= mLogicalModel->mText.Count();
+ const bool startDirection = ( ( NULL == modelCharacterDirectionsBuffer ) ? false : *( modelCharacterDirectionsBuffer + selectionStart ) );
+ const bool endDirection = ( ( NULL == modelCharacterDirectionsBuffer ) ? false : *( modelCharacterDirectionsBuffer + ( selectionEnd - ( isLastCharacter ? 1u : 0u ) ) ) );
+
// Swap the indices if the start is greater than the end.
// Swap the indices if the start is greater than the end.
- const bool indicesSwapped = ( selectionStart > selectionEnd );
+ const bool indicesSwapped = selectionStart > selectionEnd;
+
+ // Tell the decorator to flip the selection handles if needed.
+ mEventData->mDecorator->SetSelectionHandleFlipState( indicesSwapped, startDirection, endDirection );
+
if( indicesSwapped )
{
std::swap( selectionStart, selectionEnd );
if( indicesSwapped )
{
std::swap( selectionStart, selectionEnd );
@@
-991,9
+1002,6
@@
void Controller::Impl::RepositionSelectionHandles( CharacterIndex selectionStart
const Length numberOfCharactersEnd = *( charactersPerGlyphBuffer + glyphEnd );
bool splitEndGlyph = ( glyphStart != glyphEnd ) && ( numberOfCharactersEnd > 1u ) && HasLigatureMustBreak( mLogicalModel->GetScript( selectionEndMinusOne ) );
const Length numberOfCharactersEnd = *( charactersPerGlyphBuffer + glyphEnd );
bool splitEndGlyph = ( glyphStart != glyphEnd ) && ( numberOfCharactersEnd > 1u ) && HasLigatureMustBreak( mLogicalModel->GetScript( selectionEndMinusOne ) );
- // Tell the decorator to swap the selection handles if needed.
- mEventData->mDecorator->SwapSelectionHandlesEnabled( firstLine.direction != indicesSwapped );
-
const Vector2 offset = mEventData->mScrollPosition + mAlignmentOffset;
// Traverse the glyphs.
const Vector2 offset = mEventData->mScrollPosition + mAlignmentOffset;
// Traverse the glyphs.
@@
-1078,7
+1086,7
@@
void Controller::Impl::RepositionSelectionHandles( CharacterIndex selectionStart
mEventData->mDecorator->SetPosition( RIGHT_SELECTION_HANDLE, secondaryPosition.x, secondaryPosition.y, secondaryCursorInfo.lineHeight );
// Cursor to be positioned at end of selection so if selection interrupted and edit mode restarted the cursor will be at end of selection
mEventData->mDecorator->SetPosition( RIGHT_SELECTION_HANDLE, secondaryPosition.x, secondaryPosition.y, secondaryCursorInfo.lineHeight );
// Cursor to be positioned at end of selection so if selection interrupted and edit mode restarted the cursor will be at end of selection
- mEventData->mPrimaryCursorPosition = (
indicesSwapped)?mEventData->mLeftSelectionPosition:
mEventData->mRightSelectionPosition;
+ mEventData->mPrimaryCursorPosition = (
indicesSwapped ) ? mEventData->mLeftSelectionPosition :
mEventData->mRightSelectionPosition;
// Set the flag to update the decorator.
mEventData->mDecoratorUpdated = true;
// Set the flag to update the decorator.
mEventData->mDecoratorUpdated = true;
@@
-1462,7
+1470,7
@@
CharacterIndex Controller::Impl::GetClosestCursorIndex( float visualX,
numberOfGlyphs,
glyphMetrics,
mVisualModel,
numberOfGlyphs,
glyphMetrics,
mVisualModel,
- m
FontClient
);
+ m
Metrics
);
const Vector2& position = *( positionsBuffer + glyphLogicalOrderIndex );
const Vector2& position = *( positionsBuffer + glyphLogicalOrderIndex );
@@
-1519,7
+1527,7
@@
void Controller::Impl::GetCursorPosition( CharacterIndex logical,
cursorInfo.lineHeight = GetDefaultFontLineHeight();
cursorInfo.primaryCursorHeight = cursorInfo.lineHeight;
cursorInfo.lineHeight = GetDefaultFontLineHeight();
cursorInfo.primaryCursorHeight = cursorInfo.lineHeight;
- cursorInfo.primaryPosition.x =
mEventData->mDecorator->GetCursorWidth()
;
+ cursorInfo.primaryPosition.x =
0.f
;
cursorInfo.primaryPosition.y = 0.f;
// Nothing else to do.
cursorInfo.primaryPosition.y = 0.f;
// Nothing else to do.
@@
-1601,7
+1609,7
@@
void Controller::Impl::GetCursorPosition( CharacterIndex logical,
primaryNumberOfGlyphs,
glyphMetrics,
mVisualModel,
primaryNumberOfGlyphs,
glyphMetrics,
mVisualModel,
- m
FontClient
);
+ m
Metrics
);
// Whether to add the glyph's advance to the cursor position.
// i.e if the paragraph is left to right and the logical cursor is zero, the position is the position of the first glyph and the advance is not added,
// Whether to add the glyph's advance to the cursor position.
// i.e if the paragraph is left to right and the logical cursor is zero, the position is the position of the first glyph and the advance is not added,
@@
-1691,7
+1699,7
@@
void Controller::Impl::GetCursorPosition( CharacterIndex logical,
secondaryNumberOfGlyphs,
glyphMetrics,
mVisualModel,
secondaryNumberOfGlyphs,
glyphMetrics,
mVisualModel,
- m
FontClient
);
+ m
Metrics
);
// Set the secondary cursor's position.
cursorInfo.secondaryPosition.x = -glyphMetrics.xBearing + secondaryPosition.x + ( isCurrentRightToLeft ? 0.f : glyphMetrics.advance );
// Set the secondary cursor's position.
cursorInfo.secondaryPosition.x = -glyphMetrics.xBearing + secondaryPosition.x + ( isCurrentRightToLeft ? 0.f : glyphMetrics.advance );
@@
-1768,8
+1776,8
@@
void Controller::Impl::UpdateCursorPosition()
FontId defaultFontId = 0u;
if( NULL == mFontDefaults )
{
FontId defaultFontId = 0u;
if( NULL == mFontDefaults )
{
- defaultFontId = mFontClient.GetFontId( EMPTY_STRING,
-
EMPTY_STRING
);
+ TextAbstraction::FontDescription fontDescription;
+
defaultFontId = mFontClient.GetFontId( fontDescription
);
}
else
{
}
else
{
@@
-1777,7
+1785,7
@@
void Controller::Impl::UpdateCursorPosition()
}
Text::FontMetrics fontMetrics;
}
Text::FontMetrics fontMetrics;
- m
FontClient.
GetFontMetrics( defaultFontId, fontMetrics );
+ m
Metrics->
GetFontMetrics( defaultFontId, fontMetrics );
lineHeight = fontMetrics.ascender - fontMetrics.descender;
lineHeight = fontMetrics.ascender - fontMetrics.descender;
@@
-1788,7
+1796,7
@@
void Controller::Impl::UpdateCursorPosition()
{
case LayoutEngine::HORIZONTAL_ALIGN_BEGIN:
{
{
case LayoutEngine::HORIZONTAL_ALIGN_BEGIN:
{
- cursorPosition.x =
mEventData->mDecorator->GetCursorWidth()
;
+ cursorPosition.x =
0.f
;
break;
}
case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
break;
}
case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
@@
-1798,7
+1806,7
@@
void Controller::Impl::UpdateCursorPosition()
}
case LayoutEngine::HORIZONTAL_ALIGN_END:
{
}
case LayoutEngine::HORIZONTAL_ALIGN_END:
{
- cursorPosition.x = mVisualModel->mControlSize.width;
+ cursorPosition.x = mVisualModel->mControlSize.width
- mEventData->mDecorator->GetCursorWidth()
;
break;
}
}
break;
}
}