From: Kimmo Hoikka Date: Tue, 14 Apr 2015 10:52:41 +0000 (-0700) Subject: Merge "Size negotiation patch 3: Scope size negotiation enums" into tizen X-Git-Tag: dali_1.0.38~3 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=935e800159c04fa5d389628add6183eb68f778ee;hp=fc72d9dfdefd7434202ed73ac579d425279947f3 Merge "Size negotiation patch 3: Scope size negotiation enums" into tizen --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h index b094fde..36cb94b 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h @@ -19,8 +19,10 @@ */ // EXTERNAL INCLUDES +#include // fprintf #include #include +#include // for strcpy, strncpy #include // INTERNAL INCLUDES diff --git a/dali-toolkit/internal/controls/buttons/button-impl.cpp b/dali-toolkit/internal/controls/buttons/button-impl.cpp index c42531f..d1f30bc 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/button-impl.cpp @@ -19,6 +19,7 @@ #include "button-impl.h" // EXTERNAL INCLUDES +#include // for strcmp #include #include #include diff --git a/dali-toolkit/internal/controls/cluster/cluster-impl.cpp b/dali-toolkit/internal/controls/cluster/cluster-impl.cpp index d4daf3c..d43d63a 100644 --- a/dali-toolkit/internal/controls/cluster/cluster-impl.cpp +++ b/dali-toolkit/internal/controls/cluster/cluster-impl.cpp @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include // for strcmp #include #include #include diff --git a/dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.cpp b/dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.cpp index 84eb4e4..26956dc 100644 --- a/dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.cpp +++ b/dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.cpp @@ -19,6 +19,7 @@ #include "navigation-control-impl.h" // EXTERNAL INCLUDES +#include // for strcmp #include #include #include diff --git a/dali-toolkit/internal/controls/popup/popup-impl.cpp b/dali-toolkit/internal/controls/popup/popup-impl.cpp index 8a1c679..a5aed9b 100755 --- a/dali-toolkit/internal/controls/popup/popup-impl.cpp +++ b/dali-toolkit/internal/controls/popup/popup-impl.cpp @@ -19,6 +19,7 @@ #include // EXTERNAL INCLUDES +#include // for strcmp #include #include #include diff --git a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp index d57f2a4..0d7b833 100755 --- a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp +++ b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp @@ -19,6 +19,7 @@ #include // EXTERNAL INCLUDES +#include // for strcmp #include #include #include diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp index 9ad835f..a3f222e 100644 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -19,6 +19,7 @@ #include // EXTERNAL INCLUDES +#include // for strcmp #include #include #include diff --git a/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.cpp index 613b0e8..a789981 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.cpp @@ -19,6 +19,7 @@ #include // EXTERNAL INCLUDES +#include // for strcmp #include #include #include diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp index 09582cf..496d20f 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp @@ -19,6 +19,7 @@ #include // EXTERNAL INCLUDES +#include // for strcmp #include #include #include diff --git a/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp b/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp index 3db2f3e..5f7cf72 100644 --- a/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp @@ -16,6 +16,7 @@ */ // EXTERNAL INCLUDES +#include // for strcmp #include #include diff --git a/dali-toolkit/internal/controls/slider/slider-impl.cpp b/dali-toolkit/internal/controls/slider/slider-impl.cpp index 7ab8438..4c1b2fa 100755 --- a/dali-toolkit/internal/controls/slider/slider-impl.cpp +++ b/dali-toolkit/internal/controls/slider/slider-impl.cpp @@ -19,7 +19,9 @@ #include // EXTERNAL INCLUDES +#include // for strcmp #include +#include #include #include #include diff --git a/dali-toolkit/internal/controls/view/view-impl.cpp b/dali-toolkit/internal/controls/view/view-impl.cpp index 9a5ac2e..19dd781 100644 --- a/dali-toolkit/internal/controls/view/view-impl.cpp +++ b/dali-toolkit/internal/controls/view/view-impl.cpp @@ -19,6 +19,7 @@ #include "view-impl.h" // EXTERNAL INCLUDES +#include // for strcmp #include #include #include diff --git a/dali-toolkit/internal/focus-manager/focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/focus-manager-impl.cpp index 24343dd..b1f3c14 100644 --- a/dali-toolkit/internal/focus-manager/focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/focus-manager-impl.cpp @@ -19,6 +19,7 @@ #include "focus-manager-impl.h" // EXTERNAL INCLUDES +#include // for strcmp #include #include #include diff --git a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp index ff75d04..5b0bcb5 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -19,6 +19,7 @@ #include "keyboard-focus-manager-impl.h" // EXTERNAL INCLUDES +#include // for strcmp #include #include #include diff --git a/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.cpp index 5d7d4be..9fee428 100644 --- a/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.cpp @@ -19,6 +19,7 @@ #include "keyinput-focus-manager-impl.h" // EXTERNAL INCLUDES +#include // for strcmp #include #include diff --git a/dali-toolkit/internal/text/character-set-conversion.h b/dali-toolkit/internal/text/character-set-conversion.h index c8da542..7a62498 100644 --- a/dali-toolkit/internal/text/character-set-conversion.h +++ b/dali-toolkit/internal/text/character-set-conversion.h @@ -38,7 +38,7 @@ namespace Toolkit * * @return The number of characters. */ -DALI_IMPORT_API uint32_t GetNumberOfUtf8Characters( const uint8_t* const utf8, uint32_t length ); +uint32_t GetNumberOfUtf8Characters( const uint8_t* const utf8, uint32_t length ); /** * @brief Retrieves the number of bytes needed to encode in UTF8 the given text array encoded in UTF32. @@ -48,7 +48,7 @@ DALI_IMPORT_API uint32_t GetNumberOfUtf8Characters( const uint8_t* const utf8, u * * @return The number of bytes. */ -DALI_IMPORT_API uint32_t GetNumberOfUtf8Bytes( const uint32_t* const utf32, uint32_t numberOfCharacters ); +uint32_t GetNumberOfUtf8Bytes( const uint32_t* const utf32, uint32_t numberOfCharacters ); /** * @brief Converts a text array encoded in UTF8 into a text array encoded in UTF32. @@ -61,7 +61,7 @@ DALI_IMPORT_API uint32_t GetNumberOfUtf8Bytes( const uint32_t* const utf32, uint * * @return The number of characters. */ -DALI_IMPORT_API uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length, uint32_t* utf32 ); +uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length, uint32_t* utf32 ); /** * @brief Converts a text array encoded in UTF32 into a text array encoded in UTF8. @@ -74,7 +74,7 @@ DALI_IMPORT_API uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length * * @return The number of bytes. */ -DALI_IMPORT_API uint32_t Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters, uint8_t* utf8 ); +uint32_t Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters, uint8_t* utf8 ); } // namespace Toolkit diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index 1a97dd4..e165103 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -40,6 +40,7 @@ namespace { const float MAX_FLOAT = std::numeric_limits::max(); +const bool RTL = true; } //namespace @@ -48,12 +49,40 @@ const float MAX_FLOAT = std::numeric_limits::max(); */ struct LineLayout { + LineLayout() + : glyphIndex( 0u ), + characterIndex( 0u ), + numberOfCharacters( 0u ), + numberOfGlyphs( 0u ), + length( 0.f ), + widthAdvanceDiff( 0.f ), + wsLengthEndOfLine( 0.f ), + ascender( 0.f ), + descender( MAX_FLOAT ) + {} + + ~LineLayout() + {} + + void Clear() + { + glyphIndex = 0u; + characterIndex = 0u; + numberOfCharacters = 0u; + numberOfGlyphs = 0u; + length = 0.f; + widthAdvanceDiff = 0.f; + wsLengthEndOfLine = 0.f; + ascender = 0.f; + descender = MAX_FLOAT; + } + GlyphIndex glyphIndex; ///< Index of the first glyph to be laid-out. CharacterIndex characterIndex; ///< Index of the first character to be laid-out. Length numberOfCharacters; ///< The number of characters which fit in one line. Length numberOfGlyphs; ///< The number of glyph which fit in one line. float length; ///< The length of the glyphs which fit in one line. - float widthAdvanceDiff; ///< The difference between the width and the advance of the last glyph. + float widthAdvanceDiff; ///< The difference between the xBearing + width and the advance of the last glyph. float wsLengthEndOfLine; ///< The length of the white spaces at the end of the line. float ascender; ///< The maximum ascender of all fonts in the line. float descender; ///< The minimum descender of all fonts in the line. @@ -70,114 +99,118 @@ struct LayoutEngine::Impl } /** - * Retrieves the line layout for a given box width. + * @brief Updates the line ascender and descender with the metrics of a new font. + * + * @param[in] fontId The id of the new font. + * @param[in,out] lineLayout The line layout. */ - void GetLineLayoutForBox( const LayoutParameters& parameters, - LineLayout& lineLayout ) + void UpdateLineHeight( FontId fontId, LineLayout& lineLayout ) { - // Initializes the line layout. - lineLayout.numberOfCharacters = 0u; - lineLayout.numberOfGlyphs = 0u; - lineLayout.length = 0.f; - lineLayout.wsLengthEndOfLine = 0.f; - lineLayout.ascender = 0.f; - lineLayout.descender = MAX_FLOAT; - - // Get the last glyph index. - const GlyphIndex lastGlyphIndex = parameters.totalNumberOfGlyphs - 1u; + Text::FontMetrics fontMetrics; + mFontClient.GetFontMetrics( fontId, fontMetrics ); - FontId lastFontId = 0u; - for( GlyphIndex glyphIndex = lineLayout.glyphIndex; - glyphIndex < parameters.totalNumberOfGlyphs; - ++glyphIndex ) + // Sets the maximum ascender. + if( fontMetrics.ascender > lineLayout.ascender ) { - // Get the glyph info. - const GlyphInfo& glyphInfo = *( parameters.glyphsBuffer + glyphIndex ); - - // Check whether is a white space. - const Character character = *( parameters.textBuffer + lineLayout.numberOfCharacters ); - const bool isWhiteSpace = TextAbstraction::IsWhiteSpace( character ); - - // Get the character indices for the current glyph. The last character index is needed - // because there are glyphs formed by more than one character but their break info is - // given only for the last character. - const Length charactersPerGlyph = *( parameters.charactersPerGlyphBuffer + glyphIndex ); - - // Increase the number of characters. - lineLayout.numberOfCharacters += charactersPerGlyph; - - // Increase the number of glyphs. - lineLayout.numberOfGlyphs++; - - // Increase the accumulated length. - const float glyphLength = ( glyphIndex == lastGlyphIndex ) ? glyphInfo.width : glyphInfo.advance; + lineLayout.ascender = fontMetrics.ascender; + } - if( isWhiteSpace ) - { - // Add the length to the length of white spaces at the end of the line. - lineLayout.wsLengthEndOfLine += glyphLength; - } - else - { - // Add as well any previous white space length. - lineLayout.length += lineLayout.wsLengthEndOfLine + glyphLength; + // Sets the minimum descender. + if( fontMetrics.descender < lineLayout.descender ) + { + lineLayout.descender = fontMetrics.descender; + } + } - // Clear the white space length at the end of the line. - lineLayout.wsLengthEndOfLine = 0.f; - } + /** + * @brief Merges a temporary line layout into the line layout. + * + * @param[in,out] lineLayout The line layout. + * @param[in] tmpLineLayout A temporary line layout. + */ + void MergeLineLayout( LineLayout& lineLayout, + const LineLayout& tmpLineLayout ) + { + lineLayout.numberOfCharacters += tmpLineLayout.numberOfCharacters; + lineLayout.numberOfGlyphs += tmpLineLayout.numberOfGlyphs; + lineLayout.length += tmpLineLayout.length; - if( lastFontId != glyphInfo.fontId ) - { - Text::FontMetrics fontMetrics; - mFontClient.GetFontMetrics( glyphInfo.fontId, fontMetrics ); + if( 0.f < tmpLineLayout.length ) + { + lineLayout.length += lineLayout.wsLengthEndOfLine; - // Sets the maximum ascender. - if( fontMetrics.ascender > lineLayout.ascender ) - { - lineLayout.ascender = fontMetrics.ascender; - } + lineLayout.wsLengthEndOfLine = tmpLineLayout.wsLengthEndOfLine; + lineLayout.widthAdvanceDiff = tmpLineLayout.widthAdvanceDiff; + } + else + { + lineLayout.wsLengthEndOfLine += tmpLineLayout.wsLengthEndOfLine; + } - // Sets the minimum descender. - if( fontMetrics.descender < lineLayout.descender ) - { - lineLayout.descender = fontMetrics.descender; - } + if( tmpLineLayout.ascender > lineLayout.ascender ) + { + lineLayout.ascender = tmpLineLayout.ascender; + } - lastFontId = glyphInfo.fontId; - } + if( tmpLineLayout.descender < lineLayout.descender ) + { + lineLayout.descender = tmpLineLayout.descender; } } /** * Retrieves the line layout for a given box width. */ - void GetMultiLineLayoutForBox( const LayoutParameters& parameters, - LineLayout& lineLayout ) + void GetLineLayoutForBox( const LayoutParameters& parameters, + LineLayout& lineLayout ) { - // Initializes the line layout. - lineLayout.numberOfCharacters = 0u; - lineLayout.numberOfGlyphs = 0u; - lineLayout.length = 0.f; - lineLayout.widthAdvanceDiff = 0.f; - lineLayout.wsLengthEndOfLine = 0.f; - lineLayout.ascender = 0.f; - lineLayout.descender = MAX_FLOAT; - // Stores temporary line layout which has not been added to the final line layout. LineLayout tmpLineLayout; - tmpLineLayout.numberOfCharacters = 0u; - tmpLineLayout.numberOfGlyphs = 0u; - tmpLineLayout.length = 0.f; - tmpLineLayout.widthAdvanceDiff = 0.f; - tmpLineLayout.wsLengthEndOfLine = 0.f; - tmpLineLayout.ascender = 0.f; - tmpLineLayout.descender = MAX_FLOAT; - - FontId lastFontId = 0u; + + const bool isMultiline = mLayout == MULTI_LINE_BOX; + const GlyphIndex lastGlyphIndex = parameters.totalNumberOfGlyphs - 1u; + + // If the first glyph has a negative bearing its absolute value needs to be added to the line length. + // In the case the line starts with a right to left character the bearing needs to be substracted to the line length. + const GlyphInfo& glyphInfo = *( parameters.glyphsBuffer + lineLayout.glyphIndex ); + float initialHorizontalBearing = glyphInfo.xBearing; + + lineLayout.characterIndex = *( parameters.glyphsToCharactersBuffer + lineLayout.glyphIndex ); + const CharacterDirection firstCharacterDirection = ( NULL == parameters.characterDirectionBuffer ) ? false : *( parameters.characterDirectionBuffer + lineLayout.characterIndex ); + + if( RTL == firstCharacterDirection ) + { + initialHorizontalBearing = -initialHorizontalBearing; + + if( 0.f < glyphInfo.xBearing ) + { + tmpLineLayout.length = glyphInfo.xBearing; + initialHorizontalBearing = 0.f; + } + } + else + { + if( 0.f > glyphInfo.xBearing ) + { + tmpLineLayout.length = -glyphInfo.xBearing; + initialHorizontalBearing = 0.f; + } + } + + // Calculate the line height if there is no characters. + FontId lastFontId = glyphInfo.fontId; + UpdateLineHeight( lastFontId, tmpLineLayout ); + + const float boundingBoxWidth = parameters.boundingBox.width - initialHorizontalBearing; + + bool oneWordLaidOut = false; + for( GlyphIndex glyphIndex = lineLayout.glyphIndex; glyphIndex < parameters.totalNumberOfGlyphs; ++glyphIndex ) { + const bool isLastGlyph = glyphIndex == lastGlyphIndex; + // Get the glyph info. const GlyphInfo& glyphInfo = *( parameters.glyphsBuffer + glyphIndex ); @@ -208,121 +241,62 @@ struct LayoutEngine::Impl if( isWhiteSpace ) { // Add the length to the length of white spaces at the end of the line. - tmpLineLayout.wsLengthEndOfLine += glyphInfo.advance; // I use the advance as the width is always zero for the white spaces. - tmpLineLayout.widthAdvanceDiff = 0.f; + tmpLineLayout.wsLengthEndOfLine += glyphInfo.advance; // The advance is used as the width is always zero for the white spaces. } else { // Add as well any previous white space length. tmpLineLayout.length += tmpLineLayout.wsLengthEndOfLine + glyphInfo.advance; - tmpLineLayout.widthAdvanceDiff = glyphInfo.width - glyphInfo.advance; + if( RTL == firstCharacterDirection ) + { + tmpLineLayout.widthAdvanceDiff = -glyphInfo.xBearing; + } + else + { + tmpLineLayout.widthAdvanceDiff = glyphInfo.xBearing + glyphInfo.width - glyphInfo.advance; + } // Clear the white space length at the end of the line. tmpLineLayout.wsLengthEndOfLine = 0.f; } // Check if the accumulated length fits in the width of the box. - if( lineLayout.length + tmpLineLayout.length + tmpLineLayout.widthAdvanceDiff + ( ( 0.f < tmpLineLayout.length ) ? lineLayout.wsLengthEndOfLine : 0.f ) > parameters.boundingBox.width ) + if( isMultiline && oneWordLaidOut && !isWhiteSpace && + ( lineLayout.length + lineLayout.wsLengthEndOfLine + tmpLineLayout.length + tmpLineLayout.widthAdvanceDiff > boundingBoxWidth ) ) { // Current word does not fit in the box's width. return; } - if( TextAbstraction::LINE_MUST_BREAK == lineBreakInfo ) + if( ( isMultiline || isLastGlyph ) && + ( TextAbstraction::LINE_MUST_BREAK == lineBreakInfo ) ) { // Must break the line. Update the line layout and return. - lineLayout.numberOfCharacters += tmpLineLayout.numberOfCharacters; - lineLayout.numberOfGlyphs += tmpLineLayout.numberOfGlyphs; - lineLayout.length += tmpLineLayout.length; - lineLayout.widthAdvanceDiff = tmpLineLayout.widthAdvanceDiff; - - if( 0.f < tmpLineLayout.length ) - { - lineLayout.length += lineLayout.wsLengthEndOfLine; - - lineLayout.wsLengthEndOfLine = tmpLineLayout.wsLengthEndOfLine; - } - else - { - lineLayout.wsLengthEndOfLine += tmpLineLayout.wsLengthEndOfLine; - } - - if( tmpLineLayout.ascender > lineLayout.ascender ) - { - lineLayout.ascender = tmpLineLayout.ascender; - } + MergeLineLayout( lineLayout, tmpLineLayout ); - if( tmpLineLayout.descender < lineLayout.descender ) - { - lineLayout.descender = tmpLineLayout.descender; - } - - tmpLineLayout.numberOfCharacters = 0u; - tmpLineLayout.numberOfGlyphs = 0u; - tmpLineLayout.length = 0u; - tmpLineLayout.widthAdvanceDiff = 0u; - tmpLineLayout.wsLengthEndOfLine = 0u; - tmpLineLayout.ascender = 0.f; - tmpLineLayout.descender = MAX_FLOAT; return; } - if( TextAbstraction::WORD_BREAK == wordBreakInfo ) + if( isMultiline && + ( TextAbstraction::WORD_BREAK == wordBreakInfo ) ) { - // Current glyph is the last one of the current word. - // Add the temporal layout to the current one. - lineLayout.numberOfCharacters += tmpLineLayout.numberOfCharacters; - lineLayout.numberOfGlyphs += tmpLineLayout.numberOfGlyphs; - lineLayout.length += tmpLineLayout.length; - lineLayout.widthAdvanceDiff = tmpLineLayout.widthAdvanceDiff; - - if( 0.f < tmpLineLayout.length ) - { - lineLayout.length += lineLayout.wsLengthEndOfLine; - - lineLayout.wsLengthEndOfLine = tmpLineLayout.wsLengthEndOfLine; - } - else - { - lineLayout.wsLengthEndOfLine += tmpLineLayout.wsLengthEndOfLine; - } - - if( tmpLineLayout.ascender > lineLayout.ascender ) + if( !oneWordLaidOut && !isWhiteSpace ) { - lineLayout.ascender = tmpLineLayout.ascender; + oneWordLaidOut = true; } - if( tmpLineLayout.descender < lineLayout.descender ) - { - lineLayout.descender = tmpLineLayout.descender; - } + // Current glyph is the last one of the current word. + // Add the temporal layout to the current one. + MergeLineLayout( lineLayout, tmpLineLayout ); - tmpLineLayout.numberOfCharacters = 0u; - tmpLineLayout.numberOfGlyphs = 0u; - tmpLineLayout.length = 0u; - tmpLineLayout.widthAdvanceDiff = 0u; - tmpLineLayout.wsLengthEndOfLine = 0u; - tmpLineLayout.ascender = 0.f; - tmpLineLayout.descender = MAX_FLOAT; + tmpLineLayout.Clear(); } + // Check if the font of the current glyph is the same of the previous one. + // If it's different the ascender and descender need to be updated. if( lastFontId != glyphInfo.fontId ) { - Text::FontMetrics fontMetrics; - mFontClient.GetFontMetrics( glyphInfo.fontId, fontMetrics ); - - // Sets the maximum ascender. - if( fontMetrics.ascender > tmpLineLayout.ascender ) - { - tmpLineLayout.ascender = fontMetrics.ascender; - } - - // Sets the minimum descender. - if( -fontMetrics.descender < tmpLineLayout.descender ) - { - tmpLineLayout.descender = fontMetrics.descender; - } - + UpdateLineHeight( glyphInfo.fontId, tmpLineLayout ); lastFontId = glyphInfo.fontId; } } @@ -333,32 +307,77 @@ struct LayoutEngine::Impl Vector& lines, Size& actualSize ) { - // TODO Switch between different layouts - bool update = false; + Vector2* glyphPositionsBuffer = glyphPositions.Begin(); - switch( mLayout ) + float penY = 0.f; + for( GlyphIndex index = 0u; index < layoutParameters.totalNumberOfGlyphs; ) { - case LayoutEngine::SINGLE_LINE_BOX: + // Get the layout for the line. + LineLayout layout; + layout.glyphIndex = index; + GetLineLayoutForBox( layoutParameters, + layout ); + + if( 0u == layout.numberOfGlyphs ) { - update = SingleLineLayout( layoutParameters, - glyphPositions, - lines, - actualSize ); - break; + // The width is too small and no characters are laid-out. + return false; } - case LayoutEngine::MULTI_LINE_BOX: + + LineRun lineRun; + lineRun.glyphIndex = index; + lineRun.numberOfGlyphs = layout.numberOfGlyphs; + lineRun.characterRun.characterIndex = layout.characterIndex; + lineRun.characterRun.numberOfCharacters = layout.numberOfCharacters; + lineRun.width = layout.length + layout.widthAdvanceDiff; + lineRun.ascender = layout.ascender; + lineRun.descender = layout.descender; + lineRun.extraLength = layout.wsLengthEndOfLine > 0.f ? layout.wsLengthEndOfLine - layout.widthAdvanceDiff : 0.f; + lineRun.direction = false; + + lines.PushBack( lineRun ); + + // Update the actual size. + if( lineRun.width > actualSize.width ) { - update = MultiLineLayout( layoutParameters, - glyphPositions, - lines, - actualSize ); - break; + actualSize.width = lineRun.width; } - default: - break; + + actualSize.height += ( lineRun.ascender + -lineRun.descender ); + + // Traverse the glyphs and set the positions. + + penY += layout.ascender; + + // Check if the x bearing of the first character is negative. + // If it has a negative x bearing, it will exceed the boundaries of the actor, + // so the penX position needs to be moved to the right. + float penX = 0.f; + + const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + index ); + if( 0.f > glyph.xBearing ) + { + penX = -glyph.xBearing; + } + + for( GlyphIndex i = index; i < index + layout.numberOfGlyphs; ++i ) + { + const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + i ); + Vector2& position = *( glyphPositionsBuffer + i ); + + position.x = penX + glyph.xBearing; + position.y = penY - glyph.yBearing; + + penX += glyph.advance; + } + + penY += -layout.descender; + + // Increase the glyph index. + index += layout.numberOfGlyphs; } - return update; + return true; } void ReLayoutRightToLeftLines( const LayoutParameters& layoutParameters, @@ -371,6 +390,11 @@ struct LayoutEngine::Impl float penX = 0.f; + const CharacterIndex characterVisualIndex = bidiLine.characterRun.characterIndex + *bidiLine.visualToLogicalMap; + const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + *( layoutParameters.charactersToGlyphsBuffer + characterVisualIndex ) ); + + penX = -glyph.xBearing; + Vector2* glyphPositionsBuffer = glyphPositions.Begin(); // Traverses the characters of the right to left paragraph. @@ -462,125 +486,6 @@ struct LayoutEngine::Impl } } - bool SingleLineLayout( const LayoutParameters& layoutParameters, - Vector& glyphPositions, - Vector& lines, - Size& actualSize ) - { - LineLayout layout; - layout.glyphIndex = 0u; - GetLineLayoutForBox( layoutParameters, - layout ); - - // Create a line run and add it to the lines. - const GlyphIndex lastGlyphIndex = layoutParameters.totalNumberOfGlyphs - 1u; - - LineRun lineRun; - lineRun.glyphIndex = 0u; - lineRun.numberOfGlyphs = layoutParameters.totalNumberOfGlyphs; - lineRun.characterRun.characterIndex = 0u; - lineRun.characterRun.numberOfCharacters = *( layoutParameters.glyphsToCharactersBuffer + lastGlyphIndex ) + *( layoutParameters.charactersPerGlyphBuffer + lastGlyphIndex ); - lineRun.width = layout.length; - lineRun.ascender = layout.ascender; - lineRun.descender = layout.descender; - lineRun.extraLength = layout.wsLengthEndOfLine; - lineRun.direction = false; - - lines.PushBack( lineRun ); - - // Update the actual size. - actualSize.width = layout.length; - actualSize.height = lineRun.ascender + -lineRun.descender; - - float penX = 0.f; - float penY = layout.ascender; - - Vector2* glyphPositionsBuffer = glyphPositions.Begin(); - for( GlyphIndex glyphIndex = 0u; glyphIndex < layout.numberOfGlyphs; ++glyphIndex ) - { - const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + glyphIndex ); - Vector2& position = *( glyphPositionsBuffer + glyphIndex ); - - position.x = penX + glyph.xBearing; - position.y = penY - glyph.yBearing; - - penX += glyph.advance; - } - - return true; - } - - bool MultiLineLayout( const LayoutParameters& layoutParameters, - Vector& glyphPositions, - Vector& lines, - Size& actualSize ) - { - float penY = 0.f; - for( GlyphIndex index = 0u; index < layoutParameters.totalNumberOfGlyphs; ) - { - float penX = 0.f; - - // Get the layout for the line. - LineLayout layout; - layout.glyphIndex = index; - GetMultiLineLayoutForBox( layoutParameters, - layout ); - - if( 0u == layout.numberOfGlyphs ) - { - // The width is too small and no characters are laid-out. - return false; - } - - // Create a line run and add it to the lines. - const GlyphIndex lastGlyphIndex = index + layout.numberOfGlyphs - 1u; - - LineRun lineRun; - lineRun.glyphIndex = index; - lineRun.numberOfGlyphs = layout.numberOfGlyphs; - lineRun.characterRun.characterIndex = *( layoutParameters.glyphsToCharactersBuffer + index ); - lineRun.characterRun.numberOfCharacters = ( *( layoutParameters.glyphsToCharactersBuffer + lastGlyphIndex ) + *( layoutParameters.charactersPerGlyphBuffer + lastGlyphIndex ) ) - lineRun.characterRun.characterIndex; - lineRun.width = layout.length + ( ( layout.widthAdvanceDiff > 0.f ) ? layout.widthAdvanceDiff : 0.f ); - lineRun.ascender = layout.ascender; - lineRun.descender = layout.descender; - lineRun.extraLength = layout.wsLengthEndOfLine; - lineRun.direction = false; - - lines.PushBack( lineRun ); - - // Update the actual size. - if( layout.length + layout.widthAdvanceDiff > actualSize.width ) - { - actualSize.width = layout.length; - } - - actualSize.height += ( lineRun.ascender + -lineRun.descender ); - - // Traverse the glyphs and set the positions. - - penY += layout.ascender; - - Vector2* glyphPositionsBuffer = glyphPositions.Begin(); - for( GlyphIndex i = index; i < index + layout.numberOfGlyphs; ++i ) - { - const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + i ); - Vector2& position = *( glyphPositionsBuffer + i ); - - position.x = penX + glyph.xBearing; - position.y = penY - glyph.yBearing; - - penX += glyph.advance; - } - - penY += -layout.descender; - - // Increase the glyph index. - index += layout.numberOfGlyphs; - } - - return true; - } - float CalculateHorizontalAlignment( float boxWidth, float lineLength, float extraLength, diff --git a/dali-toolkit/internal/text/layouts/layout-parameters.h b/dali-toolkit/internal/text/layouts/layout-parameters.h index a370c02..8a49a91 100644 --- a/dali-toolkit/internal/text/layouts/layout-parameters.h +++ b/dali-toolkit/internal/text/layouts/layout-parameters.h @@ -56,6 +56,7 @@ struct LayoutParameters const Character* const textBuffer, const LineBreakInfo* const lineBreakInfoBuffer, const WordBreakInfo* const wordBreakInfoBuffer, + const CharacterDirection* const characterDirectionBuffer, Length totalNumberOfGlyphs, const GlyphInfo* const glyphsBuffer, const CharacterIndex* const glyphsToCharactersBuffer, @@ -64,6 +65,7 @@ struct LayoutParameters textBuffer( textBuffer ), lineBreakInfoBuffer( lineBreakInfoBuffer ), wordBreakInfoBuffer( wordBreakInfoBuffer ), + characterDirectionBuffer( characterDirectionBuffer ), totalNumberOfGlyphs( totalNumberOfGlyphs ), glyphsBuffer( glyphsBuffer ), glyphsToCharactersBuffer( glyphsToCharactersBuffer ), @@ -74,18 +76,19 @@ struct LayoutParameters numberOfBidirectionalInfoRuns( 0u ) {} - Vector2 boundingBox; - const Character* const textBuffer; - const LineBreakInfo* const lineBreakInfoBuffer; - const WordBreakInfo* const wordBreakInfoBuffer; - Length totalNumberOfGlyphs; - const GlyphInfo* const glyphsBuffer; - const CharacterIndex* const glyphsToCharactersBuffer; - const Length* const charactersPerGlyphBuffer; - GlyphIndex* charactersToGlyphsBuffer; ///< The character to glyph conversion table. - Length* glyphsPerCharacterBuffer; ///< The number of glyphs per character. - BidirectionalLineInfoRun* lineBidirectionalInfoRunsBuffer; ///< Bidirectional conversion tables per line. - Length numberOfBidirectionalInfoRuns; ///< The number of lines with bidirectional info. + Vector2 boundingBox; + const Character* const textBuffer; + const LineBreakInfo* const lineBreakInfoBuffer; + const WordBreakInfo* const wordBreakInfoBuffer; + const CharacterDirection* const characterDirectionBuffer; + Length totalNumberOfGlyphs; + const GlyphInfo* const glyphsBuffer; + const CharacterIndex* const glyphsToCharactersBuffer; + const Length* const charactersPerGlyphBuffer; + GlyphIndex* charactersToGlyphsBuffer; ///< The character to glyph conversion table. + Length* glyphsPerCharacterBuffer; ///< The number of glyphs per character. + BidirectionalLineInfoRun* lineBidirectionalInfoRunsBuffer; ///< Bidirectional conversion tables per line. + Length numberOfBidirectionalInfoRuns; ///< The number of lines with bidirectional info. }; } // namespace Text diff --git a/dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h b/dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h index cbfa754..6a10947 100644 --- a/dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h +++ b/dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h @@ -34,7 +34,7 @@ class AtlasGlyphManager; } -class DALI_IMPORT_API AtlasGlyphManager : public BaseHandle +class AtlasGlyphManager : public BaseHandle { public: diff --git a/dali-toolkit/internal/text/rendering/text-backend.h b/dali-toolkit/internal/text/rendering/text-backend.h index df7bfa2..42eacff 100644 --- a/dali-toolkit/internal/text/rendering/text-backend.h +++ b/dali-toolkit/internal/text/rendering/text-backend.h @@ -41,7 +41,7 @@ class Backend; /** * @brief Provides access to different text rendering backends. */ -class DALI_IMPORT_API Backend : public BaseHandle +class Backend : public BaseHandle { public: diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 2a3631f..1e9ee89 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -1804,6 +1804,7 @@ bool Controller::DoRelayout( const Size& size, Vector& lineBreakInfo = mImpl->mLogicalModel->mLineBreakInfo; Vector& wordBreakInfo = mImpl->mLogicalModel->mWordBreakInfo; + Vector& characterDirection = mImpl->mLogicalModel->mCharacterDirections; Vector& glyphs = mImpl->mVisualModel->mGlyphs; Vector& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters; Vector& charactersPerGlyph = mImpl->mVisualModel->mCharactersPerGlyph; @@ -1813,6 +1814,7 @@ bool Controller::DoRelayout( const Size& size, mImpl->mLogicalModel->mText.Begin(), lineBreakInfo.Begin(), wordBreakInfo.Begin(), + ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL, numberOfGlyphs, glyphs.Begin(), glyphsToCharactersMap.Begin(), diff --git a/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp b/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp index 1a58f8d..888322a 100644 --- a/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp +++ b/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp @@ -19,6 +19,7 @@ #include "cube-transition-effect-impl.h" // EXTERNAL INCLUDES +#include // for strcmp #include #include #include diff --git a/dali-toolkit/public-api/controls/cluster/cluster-style.cpp b/dali-toolkit/public-api/controls/cluster/cluster-style.cpp index 6ef28a6..0e2d988 100644 --- a/dali-toolkit/public-api/controls/cluster/cluster-style.cpp +++ b/dali-toolkit/public-api/controls/cluster/cluster-style.cpp @@ -18,6 +18,9 @@ // CLASS HEADER #include +// EXTERNAL INCLUDES +#include + // INTERNAL INCLUDES #include diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 9e21d2a..d65c16b 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -19,6 +19,8 @@ #include // EXTERNAL INCLUDES +#include // for strcmp +#include #include #include #include diff --git a/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h b/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h index d41a704..ee9ca7d 100644 --- a/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h +++ b/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h @@ -19,6 +19,7 @@ */ // EXTERNAL INCLUDES +#include #include #include diff --git a/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.cpp b/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.cpp index 45d0fbf..cc315c0 100644 --- a/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.cpp +++ b/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.cpp @@ -20,6 +20,7 @@ #include // EXTERNAL INCLUDES +#include // for strcmp // INTERNAL INCLUDES diff --git a/docs/content/programming-guide/custom-actor.h b/docs/content/programming-guide/custom-actor.h index 147ad73..808bfca 100644 --- a/docs/content/programming-guide/custom-actor.h +++ b/docs/content/programming-guide/custom-actor.h @@ -2,7 +2,7 @@ * The Dali::CustomActor is used as a base class for UI controls. It is a proxy object to enable derived classes access * to a subset of the methods defined in the internal Actor class. * - * Classes deriving from Custom Actor should follow the same design principle as the rest of the Dali API. + * Classes deriving from Custom Actor should follow the same handle - body design principle as the rest of the Dali API. * * One class of the new UI control should inherit from Dali::CustomActor, while a second should inherit * Dali::CustomActorImpl. This implementation class contains a number of pure virtual methods that enable the new UI @@ -13,30 +13,12 @@ * * In the New() method for the myNewButton class, the user should then create a new instance of the myNewButtonImpl class * and pass this to the constructor of the myNewButton object. Internally the connection will be made - * between the new widget actor and Dali, thus allowing messages such as OnSizeSet to be received by the new actor. + * between the new widget actor and Dali, thus allowing messages such as OnPropertySet to be received by the new actor. * * It is the responsibility of the implementation of the new UI control to implement the method bodies for the inherited * pure virtual methods from Dali::CustomActorImpl. Obviously the application won't compile if the methods are not * overidden, but the user does not need to fill in the code for methods they don't want or need to use. * - * The following code shows the static New() method from the implementation part of the TextView UI control: - * \code - * Dali::Toolkit::TextView TextView::New() - * { - * // Create the implementation, temporarily owned on stack - * boost::intrusive_ptr< TextView > textView = new TextView; - * - * // Pass ownership to CustomActor - * Dali::Toolkit::TextView handle( *textView ); - * - * // Second-phase init of the implementation - * // This can only be done after the CustomActor connection has been made... - * textView->Initialize(); - * - * return handle; - * } - * \endcode - * * After the implementation object is created it is passed back to the basic Text View through the constructor,the * constructor uses this passed in object to initialise the internal implementation objects. * @@ -47,10 +29,4 @@ * handler methods, and do all the rest of their widget processing the the main myNewButton class. Access to the * implementation class can be gained using the GetImpl(*this) method. For example: * - * \code - * void TextView::SetFont(const Font newFont) - * { - * GetImpl(*this).SetFont(newFont); - * } - * \endcode */ diff --git a/plugins/dali-script-v8/src/animation/animation-api.cpp b/plugins/dali-script-v8/src/animation/animation-api.cpp index 3fba14a..1a11440 100644 --- a/plugins/dali-script-v8/src/animation/animation-api.cpp +++ b/plugins/dali-script-v8/src/animation/animation-api.cpp @@ -19,12 +19,15 @@ #include "animation-api.h" #include "path-wrapper.h" +// EXTERNAL INCLUDES +#include // for strcmp +#include + + // INTERNAL INCLUDES #include -#include #include #include -#include namespace Dali { @@ -43,7 +46,6 @@ struct AlphaFuncStruct }; /** * Contains a list of alpha functions that can be used. - * We use a stl map as lookup to map a string name to the function */ const AlphaFuncStruct AlphaFunctionTable[]= { diff --git a/plugins/dali-script-v8/src/signals/signal-manager.cpp b/plugins/dali-script-v8/src/signals/signal-manager.cpp index 55d4a0e..d8359e2 100644 --- a/plugins/dali-script-v8/src/signals/signal-manager.cpp +++ b/plugins/dali-script-v8/src/signals/signal-manager.cpp @@ -18,6 +18,19 @@ // CLASS HEADER #include "signal-manager.h" +// EXTERNAL INCLUDES +#include // for strcmp +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + // INTERNAL INCLUDES #include #include @@ -29,16 +42,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include