X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Flayouts%2Flayout-engine.cpp;h=717c7525a917d33394c164e651b9050f66816d98;hb=709f6618b60d366c84e259564c53b6ef0c43b717;hp=4182acd28ed83f80919446987a29f77dc3f84588;hpb=726e147d14bb18ef193b102a36d8068b62db89ed;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index 4182acd..717c752 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -25,6 +25,7 @@ // INTERNAL INCLUDES #include +#include #include #include @@ -47,6 +48,7 @@ namespace const float MAX_FLOAT = std::numeric_limits::max(); const bool RTL = true; const float CURSOR_WIDTH = 1.f; +const float LINE_SPACING= 0.f; } //namespace @@ -104,6 +106,7 @@ struct LayoutEngine::Impl mHorizontalAlignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN ), mVerticalAlignment( LayoutEngine::VERTICAL_ALIGN_TOP ), mCursorWidth( CURSOR_WIDTH ), + mDefaultLineSpacing( LINE_SPACING ), mEllipsisEnabled( false ) { } @@ -464,34 +467,6 @@ struct LayoutEngine::Impl DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--GetLineLayoutForBox\n" ); } - /** - * @brief Calculates the vertical offset to add to the new laid-out glyphs. - * - * @pre @p lineIndex must be between 0 and the number of lines (both inclusive). - * - * @param[in] lines The previously laid-out lines. - * @param[in] lineIndex Index to the line where the new laid-out lines are inserted. - * - * @return The vertical offset of the lines starting from the beginning to the line @p lineIndex. - */ - float SetParagraphOffset( const Vector& lines, - LineIndex lineIndex ) - { - float offset = 0.f; - - for( Vector::ConstIterator it = lines.Begin(), - endIt = lines.Begin() + lineIndex; - it != endIt; - ++it ) - { - const LineRun& line = *it; - - offset += line.ascender + -line.descender; - } - - return offset; - } - void SetGlyphPositions( const GlyphInfo* const glyphsBuffer, Length numberOfGlyphs, Vector2* glyphPositionsBuffer ) @@ -621,7 +596,10 @@ struct LayoutEngine::Impl lineRun->ellipsis = true; layoutSize.width = layoutParameters.boundingBox.width; - layoutSize.height += ( lineRun->ascender + -lineRun->descender ); + if( layoutSize.height < Math::MACHINE_EPSILON_1000 ) + { + layoutSize.height += ( lineRun->ascender + -lineRun->descender ); + } SetGlyphPositions( layoutParameters.glyphsBuffer + lineRun->glyphRun.glyphIndex, ellipsisLayout.numberOfGlyphs, @@ -807,6 +785,7 @@ struct LayoutEngine::Impl { // Need to add a new line with no characters but with height to increase the layoutSize.height LineRun newLine; + Initialize( newLine ); lines.PushBack( newLine ); UpdateTextLayout( layoutParameters, @@ -819,6 +798,10 @@ struct LayoutEngine::Impl } } + // Calculates the layout size. + UpdateLayoutSize( lines, + layoutSize ); + // Nothing else do if there are no glyphs to layout. return false; } @@ -851,7 +834,7 @@ struct LayoutEngine::Impl Vector newLines; // Estimate the number of lines. - Length linesCapacity = layoutParameters.estimatedNumberOfLines; + Length linesCapacity = std::max( 1u, layoutParameters.estimatedNumberOfLines ); Length numberOfLines = 0u; if( updateCurrentBuffer ) @@ -870,8 +853,8 @@ struct LayoutEngine::Impl linesBuffer = lines.Begin(); } - float penY = SetParagraphOffset( lines, - layoutParameters.startLineIndex ); + float penY = CalculateLineOffset( lines, + layoutParameters.startLineIndex ); for( GlyphIndex index = layoutParameters.startGlyphIndex; index < lastGlyphPlusOne; ) { @@ -1193,10 +1176,26 @@ struct LayoutEngine::Impl } } + void Initialize( LineRun& line ) + { + line.glyphRun.glyphIndex = 0u; + line.glyphRun.numberOfGlyphs = 0u; + line.characterRun.characterIndex = 0u; + line.characterRun.numberOfCharacters = 0u; + line.width = 0.f; + line.ascender = 0.f; + line.descender = 0.f; + line.extraLength = 0.f; + line.alignmentOffset = 0.f; + line.direction = !RTL; + line.ellipsis = false; + } + LayoutEngine::Layout mLayout; LayoutEngine::HorizontalAlignment mHorizontalAlignment; LayoutEngine::VerticalAlignment mVerticalAlignment; float mCursorWidth; + float mDefaultLineSpacing; IntrusivePtr mMetrics; @@ -1226,11 +1225,13 @@ void LayoutEngine::SetLayout( Layout layout ) LayoutEngine::Layout LayoutEngine::GetLayout() const { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "GetLayout[%d]\n", mImpl->mLayout); return mImpl->mLayout; } void LayoutEngine::SetTextEllipsisEnabled( bool enabled ) { + DALI_LOG_INFO( gLogFilter, Debug::General, "-->LayoutEngine::SetTextEllipsisEnabled[%s]\n", (enabled)?"true":"false" ); mImpl->mEllipsisEnabled = enabled; } @@ -1302,6 +1303,16 @@ void LayoutEngine::Align( const Size& size, lines ); } +void LayoutEngine::SetDefaultLineSpacing( float lineSpacing ) +{ + mImpl->mDefaultLineSpacing = lineSpacing; +} + +float LayoutEngine::GetDefaultLineSpacing() const +{ + return mImpl->mDefaultLineSpacing; +} + } // namespace Text } // namespace Toolkit