// INTERNAL INCLUDES
#include <dali-toolkit/internal/text/bidirectional-line-info-run.h>
+#include <dali-toolkit/internal/text/cursor-helper-functions.h>
#include <dali-toolkit/internal/text/glyph-metrics-helper.h>
#include <dali-toolkit/internal/text/layouts/layout-parameters.h>
const float MAX_FLOAT = std::numeric_limits<float>::max();
const bool RTL = true;
const float CURSOR_WIDTH = 1.f;
+const float LINE_SPACING= 0.f;
} //namespace
mHorizontalAlignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN ),
mVerticalAlignment( LayoutEngine::VERTICAL_ALIGN_TOP ),
mCursorWidth( CURSOR_WIDTH ),
+ mDefaultLineSpacing( LINE_SPACING ),
mEllipsisEnabled( false )
{
}
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<LineRun>& lines,
- LineIndex lineIndex )
- {
- float offset = 0.f;
-
- for( Vector<LineRun>::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 )
{
// 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,
}
}
+ // Calculates the layout size.
+ UpdateLayoutSize( lines,
+ layoutSize );
+
// Nothing else do if there are no glyphs to layout.
return false;
}
Vector<LineRun> newLines;
// Estimate the number of lines.
- Length linesCapacity = layoutParameters.estimatedNumberOfLines;
+ Length linesCapacity = std::max( 1u, layoutParameters.estimatedNumberOfLines );
Length numberOfLines = 0u;
if( updateCurrentBuffer )
linesBuffer = lines.Begin();
}
- float penY = SetParagraphOffset( lines,
- layoutParameters.startLineIndex );
+ float penY = CalculateLineOffset( lines,
+ layoutParameters.startLineIndex );
for( GlyphIndex index = layoutParameters.startGlyphIndex; index < lastGlyphPlusOne; )
{
}
}
+ 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<Metrics> mMetrics;
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;
}
lines );
}
+void LayoutEngine::SetDefaultLineSpacing( float lineSpacing )
+{
+ mImpl->mDefaultLineSpacing = lineSpacing;
+}
+
+float LayoutEngine::GetDefaultLineSpacing() const
+{
+ return mImpl->mDefaultLineSpacing;
+}
+
} // namespace Text
} // namespace Toolkit