END_TEST;
}
+
+int UtcDaliTextControllerSetGetLineSpacingProperty(void)
+{
+ tet_infoline(" UtcDaliTextControllerSetGetLineSpacingProperty");
+ ToolkitTestApplication application;
+
+ const Size size( Dali::Stage::GetCurrent().GetSize() );
+
+ // single line text
+ const std::string textSingle("A Quick Brown Fox Jumps Over The Lazy Dog");
+
+ // multi-line text
+ const std::string textMulti("A Quick Brown\nFox Jumps Over\nThe Lazy Dog");
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // single line, line spacing = 0px
+ {
+ const float EXPECTED_SPACING = 0.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE( 326.0f, 19.0f);
+ const Vector3 EXPECTED_NATURAL_SIZE( 326.0f, 20.0f, 0.0f );
+
+ controller->SetText(textSingle);
+ controller->Relayout(size);
+ controller->SetMultiLineEnabled( false );
+
+ Vector3 naturalSize = controller->GetNaturalSize();
+ Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
+ float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+ DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+ }
+
+ // single line, line spacing = 20px
+ {
+ const float EXPECTED_SPACING = 20.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE( 326.0f, 19.0f );
+ const Vector3 EXPECTED_NATURAL_SIZE( 326.0f, 40.0f, 0.0f );
+
+ controller->SetText(textSingle);
+ controller->Relayout(size);
+ controller->SetDefaultLineSpacing( 20 );
+ controller->SetMultiLineEnabled( false );
+
+ Vector3 naturalSize = controller->GetNaturalSize();
+ Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
+ float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+ DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+ }
+
+ // multi-line, line spacing = 0px
+ {
+ const float EXPECTED_SPACING = 0.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE( 318.0f, 39.0f );
+ const Vector3 EXPECTED_NATURAL_SIZE( 116.0f, 58.0f, 0.0f );
+
+ controller->SetText(textMulti);
+ controller->Relayout(size);
+ controller->SetMultiLineEnabled( true );
+ controller->SetDefaultLineSpacing( 0 );
+
+ Vector3 naturalSize = controller->GetNaturalSize();
+ Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
+ float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+ DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+ }
+
+ // multi-line, line spacing = 20px
+ {
+ const float EXPECTED_SPACING = 20.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE( 115.0f, 57.0f );
+ const Vector3 EXPECTED_NATURAL_SIZE( 116.0f, 118.0f, 0.0f );
+
+ controller->SetText(textMulti);
+ controller->Relayout(size);
+ controller->SetMultiLineEnabled( true );
+ controller->SetDefaultLineSpacing( 20 );
+
+ Vector3 naturalSize = controller->GetNaturalSize();
+ Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
+ float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+ DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+ }
+
+ // multi-line, line spacing = 30px
+ {
+ const float EXPECTED_SPACING = 30.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE( 115.0f, 117.0f );
+ const Vector3 EXPECTED_NATURAL_SIZE( 116.0f, 148.0f, 0.0f );
+
+ controller->SetText(textMulti);
+ controller->Relayout(size);
+ controller->SetMultiLineEnabled( true );
+ controller->SetDefaultLineSpacing( 30 );
+
+ Vector3 naturalSize = controller->GetNaturalSize();
+ Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
+ float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+ DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+ }
+
+
+ END_TEST;
+
+}
\ No newline at end of file
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
3.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-4.f,
5.f,
0.f,
+ 0.f,
false,
false
};
-4.f,
5.f,
0.f,
+ 0.f,
false,
false
};
-4.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
3.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
3.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-8.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
3.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
3.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
3.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
3.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
3.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
3.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
3.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
3.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
3.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
true
};
-5.f,
3.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
true
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
true
};
-5.f,
3.f,
0.f,
+ 0.f,
false,
false
};
-5.f,
4.f,
0.f,
+ 0.f,
false,
true
};
-5.f,
0.f,
0.f,
+ 0.f,
false,
true
};
tet_result(TET_PASS);
END_TEST;
}
+
+int UtcDaliTextTypesetterVerticalLineAlignment(void)
+{
+ tet_infoline(" UtcDaliTextTypesetter");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel( controller );
+
+ // Sets the text.
+ controller->SetMarkupProcessorEnabled( true );
+ controller->SetText( "<font family='TizenSansRegular'>Hello world</font>" );
+
+ // Creates the text's model and relais-out the text.
+ const Size relayoutSize( 120.f, 60.f );
+ controller->Relayout( relayoutSize );
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr renderingController = Typesetter::New( controller->GetTextModel() );
+ DALI_TEST_CHECK( renderingController );
+
+ {
+ controller->SetVerticalLineAlignment(Dali::Toolkit::DevelText::VerticalLineAlignment::TOP);
+ controller->Relayout(relayoutSize);
+
+ // Renders the text and creates the final bitmap.
+ auto bitmap = renderingController->Render(relayoutSize);
+ DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION );
+ }
+
+ {
+ controller->SetVerticalLineAlignment(Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE);
+ controller->Relayout(relayoutSize);
+
+ // Renders the text and creates the final bitmap.
+ auto bitmap = renderingController->Render(relayoutSize);
+ DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION );
+ }
+
+ {
+ controller->SetVerticalLineAlignment(Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM);
+ controller->Relayout(relayoutSize);
+
+ // Renders the text and creates the final bitmap.
+ auto bitmap = renderingController->Render(relayoutSize);
+ DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION );
+ }
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
\ No newline at end of file
label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
+ // test natural size with multi-line and line spacing
+ {
+ TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
+ Vector3 expected0(414.f, 192.f, 0.0f);
+ Vector3 expected1(414.f, 252.f, 0.0f);
+ label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
+ label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
+ DALI_TEST_EQUALS(expected0, label3.GetNaturalSize(), TEST_LOCATION);
+ label3.SetProperty(TextLabel::Property::LINE_SPACING, 20);
+ DALI_TEST_EQUALS(expected1, label3.GetNaturalSize(), TEST_LOCATION);
+ }
+ // single line, line spacing must not affect natural size
+ {
+ const Vector3 expected0(948.f, 64.f, 0.0f);
+ const Vector3 expected1(948.f, 84.f, 0.0f);
+ TextLabel label3 = TextLabel::New("Some text here end there end here");
+ label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
+ label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
+ DALI_TEST_EQUALS(expected0, label3.GetNaturalSize(), TEST_LOCATION);
+ label3.SetProperty(TextLabel::Property::LINE_SPACING, 20);
+ DALI_TEST_EQUALS(expected1, label3.GetNaturalSize(), TEST_LOCATION);
+ }
// Check the line spacing property
DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
// Check the underline property
-
underlineMapSet.Clear();
underlineMapSet.Insert( "enable", "true" );
underlineMapSet.Insert( "color", "red" );
END_TEST;
}
+
+int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
+
+ TextLabel label = TextLabel::New();
+
+ label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
+ label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
+ label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
+ label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
+ Stage::GetCurrent().Add( label );
+ DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
+
+ label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
+ DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
+
+ label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
+ DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
+
+ END_TEST;
+}
\ No newline at end of file
/**
* @brief The direction of the layout.
- * @details Name "textDirection", type Property::Integer, Read-Only.
+ * @details Name "textDirection", type [Type](@ref Dali::Toolkit::DevelText::TextDirection::Type) (Property::INTEGER), Read/Write
+ * @note The text direction can be changed only by replacing the text itself.
* @see TextDirection::Type for supported values.
*/
TEXT_DIRECTION,
+
+ /**
+ * @brief Alignment of text within area of single line
+ * @details Name "verticalLineAlignment", type [Type](@ref Dali::Toolkit::DevelText::VerticalLineAlignment::Type) (Property::INTEGER), Read/Write
+ * @note The default value is TOP
+ * @see VerticalLineAlignment::Type for supported values
+ */
+ VERTICAL_LINE_ALIGNMENT,
};
} // namespace Property
} // namespace TextDirection
+namespace VerticalLineAlignment
+{
+
+enum Type
+{
+ TOP,
+ MIDDLE,
+ BOTTOM
+};
+
+} // namespace VerticalLineAlignment
+
} // namespace DevelText
} // namespace Toolkit
{
if( impl.mController )
{
+
+ // The line spacing isn't supported by the TextEditor. Since it's supported
+ // by the TextLabel for now it must be ignored. The property is being shadowed
+ // locally so its value isn't affected.
const float lineSpacing = value.Get<float>();
- impl.mController->SetDefaultLineSpacing( lineSpacing );
+ impl.mLineSpacing = lineSpacing;
+ // set it to 0.0 due to missing implementation
+ impl.mController->SetDefaultLineSpacing( 0.0f );
impl.mRenderer.Reset();
}
break;
{
if( impl.mController )
{
- value = impl.mController->GetDefaultLineSpacing();
+ // LINE_SPACING isn't implemented for the TextEditor. Returning
+ // only shadowed value, not the real one.
+ value = impl.mLineSpacing;
}
break;
}
mIdleCallback( NULL ),
mAlignmentOffset( 0.f ),
mScrollAnimationDuration( 0.f ),
+ mLineSpacing( 0.f ),
mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
mHasBeenStaged( false ),
mScrollAnimationEnabled( false ),
float mAlignmentOffset;
float mScrollAnimationDuration;
+ float mLineSpacing;
int mRenderingBackend;
bool mHasBeenStaged:1;
bool mScrollAnimationEnabled:1;
DALI_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextLabel, "lineCount", INTEGER, LINE_COUNT )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "lineWrapMode", INTEGER, LINE_WRAP_MODE )
DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextLabel, "textDirection", INTEGER, TEXT_DIRECTION )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "verticalLineAlignment", INTEGER, VERTICAL_LINE_ALIGNMENT )
DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( Toolkit, TextLabel, "textColor", Color::BLACK, TEXT_COLOR )
DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, TextLabel, "textColorRed", TEXT_COLOR_RED, TEXT_COLOR, 0 )
DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, TextLabel, "textColorGreen", TEXT_COLOR_GREEN, TEXT_COLOR, 1 )
if( impl.mController )
{
const float lineSpacing = value.Get<float>();
- impl.mController->SetDefaultLineSpacing( lineSpacing );
- impl.mTextUpdateNeeded = true;
+
+ // Don't trigger anything if the line spacing didn't change
+ if( impl.mController->SetDefaultLineSpacing( lineSpacing ) )
+ {
+ impl.mTextUpdateNeeded = true;
+ }
}
break;
}
}
break;
}
+ case Toolkit::DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT:
+ {
+ if( impl.mController && impl.mController->GetTextModel() )
+ {
+ DevelText::VerticalLineAlignment::Type alignment = static_cast<DevelText::VerticalLineAlignment::Type>( value.Get<int>() );
+
+ impl.mController->SetVerticalLineAlignment( alignment );
+
+ // Property doesn't affect the layout, only Visual must be updated
+ TextVisual::EnableRendererUpdate( impl.mVisual );
+
+ // No need to trigger full re-layout. Instead call UpdateRenderer() directly
+ TextVisual::UpdateRenderer( impl.mVisual );
+ }
+ break;
+ }
+ }
+
+ // Request relayout when text update is needed. It's necessary to call it
+ // as changing the property not via UI interaction brings no effect if only
+ // the mTextUpdateNeeded is changed.
+ if( impl.mTextUpdateNeeded )
+ {
+ // need to request relayout as size of text may have changed
+ impl.RequestTextRelayout();
}
}
+
+
+
+
}
Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index index )
}
break;
}
+ case Toolkit::DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetVerticalLineAlignment();
+ }
+ break;
+ }
}
}
extraWidth( 0.f ),
wsLengthEndOfLine( 0.f ),
ascender( 0.f ),
- descender( MAX_FLOAT )
+ descender( MAX_FLOAT ),
+ lineSpacing( 0.f )
{}
~LineLayout()
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.
+ float lineSpacing; ///< The line spacing
};
struct Engine::Impl
{
lineLayout.descender = fontMetrics.descender;
}
+
+ // set the line spacing
+ lineLayout.lineSpacing = mDefaultLineSpacing;
}
/**
// Get the last line and layout it again with the 'completelyFill' flag to true.
lineRun = linesBuffer + ( numberOfLines - 1u );
- penY -= layout.ascender - lineRun->descender;
+ penY -= layout.ascender - lineRun->descender + lineRun->lineSpacing;
ellipsisLayout.glyphIndex = lineRun->glyphRun.glyphIndex;
}
layoutSize.width = layoutParameters.boundingBox.width;
if( layoutSize.height < Math::MACHINE_EPSILON_1000 )
{
- layoutSize.height += ( lineRun->ascender + -lineRun->descender );
+ layoutSize.height += ( lineRun->ascender + -lineRun->descender ) + lineRun->lineSpacing;
}
SetGlyphPositions( layoutParameters.glyphsBuffer + lineRun->glyphRun.glyphIndex,
lineRun.glyphRun.numberOfGlyphs = layout.numberOfGlyphs;
lineRun.characterRun.characterIndex = layout.characterIndex;
lineRun.characterRun.numberOfCharacters = layout.numberOfCharacters;
+ lineRun.lineSpacing = mDefaultLineSpacing;
+
if( isLastLine && !layoutParameters.isLastNewParagraph )
{
const float width = layout.extraBearing + layout.length + layout.extraWidth + layout.wsLengthEndOfLine;
layoutSize.width = lineRun.width;
}
- layoutSize.height += ( lineRun.ascender + -lineRun.descender );
+ layoutSize.height += ( lineRun.ascender + -lineRun.descender ) + lineRun.lineSpacing;
}
/**
lineRun.alignmentOffset = 0.f;
lineRun.direction = !RTL;
lineRun.ellipsis = false;
+ lineRun.lineSpacing = mDefaultLineSpacing;
- layoutSize.height += ( lineRun.ascender + -lineRun.descender );
+ layoutSize.height += ( lineRun.ascender + -lineRun.descender ) + lineRun.lineSpacing;
}
/**
layoutSize.width = line.width;
}
- layoutSize.height += ( line.ascender + -line.descender );
+ layoutSize.height += ( line.ascender + -line.descender ) + line.lineSpacing;
}
}
glyphPositionsBuffer + index - layoutParameters.startGlyphIndex );
// Updates the vertical pen's position.
- penY += -layout.descender;
+ penY += -layout.descender + layout.lineSpacing + mDefaultLineSpacing;
// Increase the glyph index.
index = nextIndex;
line.alignmentOffset = 0.f;
line.direction = !RTL;
line.ellipsis = false;
+ line.lineSpacing = mDefaultLineSpacing;
}
Type mLayout;
float descender; ///< The line's descender.
float extraLength; ///< The length of the white spaces at the end of the line.
float alignmentOffset; ///< The horizontal alignment offset.
+ float lineSpacing; ///< The line's spacing
CharacterDirection direction : 1; ///< Direction of the first character of the paragraph.
bool ellipsis : 1; ///< Wheter ellipsis is added to the line.
};
#include <dali-toolkit/internal/text/rendering/text-typesetter.h>
// EXTERNAL INCLUDES
-#include <dali/devel-api/text-abstraction/font-client.h>
#include <memory.h>
+#include <dali/devel-api/text-abstraction/font-client.h>
#include <dali/public-api/common/constants.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/text/rendering/view-model.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
namespace Dali
{
}
}
+ // Calculate vertical line alignment
+ switch( mModel->GetVerticalLineAlignment() )
+ {
+ case DevelText::VerticalLineAlignment::TOP:
+ {
+ break;
+ }
+ case DevelText::VerticalLineAlignment::MIDDLE:
+ {
+ const auto& line = *mModel->GetLines();
+ penY -= line.descender;
+ penY += static_cast<int>(line.lineSpacing*0.5f + line.descender);
+ break;
+ }
+ case DevelText::VerticalLineAlignment::BOTTOM:
+ {
+ const auto& line = *mModel->GetLines();
+ const auto lineHeight = line.ascender + (-line.descender) + line.lineSpacing;
+ penY += static_cast<int>(lineHeight - (line.ascender - line.descender));
+ break;
+ }
+ }
+
// Generate the image buffers of the text for each different style first,
// then combine all of them together as one final image buffer. We try to
// do all of these in CPU only, so that once the final texture is generated,
// Increases the vertical offset with the line's ascender.
glyphData.verticalOffset += static_cast<int>( line.ascender );
+ // Include line spacing after first line
+ if( lineIndex > 0u )
+ {
+ glyphData.verticalOffset += static_cast<int>( line.lineSpacing );
+ }
+
// Retrieves the glyph's outline width
float outlineWidth = mModel->GetOutlineWidth();
return mModel->GetVerticalAlignment();
}
+DevelText::VerticalLineAlignment::Type ViewModel::GetVerticalLineAlignment() const
+{
+ return mModel->GetVerticalLineAlignment();
+}
+
bool ViewModel::IsTextElideEnabled() const
{
return mModel->IsTextElideEnabled();
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/text/text-enumerations.h>
#include <dali-toolkit/internal/text/text-model-interface.h>
+#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
namespace Dali
{
virtual Text::VerticalAlignment::Type GetVerticalAlignment() const;
/**
+ * @copydoc ModelInterface::GetVerticalLineAlignment()
+ */
+ virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
+
+ /**
* @copydoc ModelInterface::IsTextElideEnabled()
*/
virtual bool IsTextElideEnabled() const;
return EMPTY_STRING;
}
-void Controller::SetDefaultLineSpacing( float lineSpacing )
+bool Controller::SetDefaultLineSpacing( float lineSpacing )
{
- //TODO finish implementation
- mImpl->mLayoutEngine.SetDefaultLineSpacing( lineSpacing );
+ if( std::abs(lineSpacing - mImpl->mLayoutEngine.GetDefaultLineSpacing()) > Math::MACHINE_EPSILON_1000 )
+ {
+ mImpl->mLayoutEngine.SetDefaultLineSpacing(lineSpacing);
+ mImpl->mRecalculateNaturalSize = true;
+ return true;
+ }
+ return false;
}
float Controller::GetDefaultLineSpacing() const
return Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT;
}
+Toolkit::DevelText::VerticalLineAlignment::Type Controller::GetVerticalLineAlignment() const
+{
+ return mImpl->mModel->GetVerticalLineAlignment();
+}
+
+void Controller::SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment )
+{
+ mImpl->mModel->mVerticalLineAlignment = alignment;
+}
+
// public : Relayout.
Controller::UpdateTextType Controller::Relayout( const Size& size )
* @brief Sets the default line spacing.
*
* @param[in] lineSpacing The line spacing.
+ *
+ * @return True if lineSpacing has been updated, false otherwise
*/
- void SetDefaultLineSpacing( float lineSpacing );
+ bool SetDefaultLineSpacing( float lineSpacing );
/**
* @brief Retrieves the default line spacing.
*/
Toolkit::DevelText::TextDirection::Type GetTextDirection();
+ /**
+ * @brief Retrieves vertical line alignment
+ * @return The vertical line alignment
+ */
+ Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
+
+ /**
+ * @brief Sets vertical line alignment
+ * @param[in] alignment The vertical line alignment for the text
+ */
+ void SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment );
+
public: // Relayout.
/**
#include <dali-toolkit/internal/text/line-run.h>
#include <dali-toolkit/internal/text/script-run.h>
#include <dali-toolkit/internal/text/text-definitions.h>
+#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
namespace Dali
{
virtual VerticalAlignment::Type GetVerticalAlignment() const = 0;
/**
+ * @brief Retrieves the text's vertical line alignment.
+ *
+ * @return The vertical line alignment.
+ */
+ virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const = 0;
+
+ /**
* @brief Whether the text elide property is enabled.
*
* @return @e true if the text elide property is enabled, @e false otherwise.
return mVerticalAlignment;
}
+DevelText::VerticalLineAlignment::Type Model::GetVerticalLineAlignment() const
+{
+ return mVerticalLineAlignment;
+}
+
bool Model::IsTextElideEnabled() const
{
return mElideEnabled;
mScrollPositionLast(),
mHorizontalAlignment( Text::HorizontalAlignment::BEGIN ),
mVerticalAlignment( Text::VerticalAlignment::TOP ),
+ mVerticalLineAlignment( DevelText::VerticalLineAlignment::TOP ),
mLineWrapMode( Text::LineWrap::WORD ),
mAlignmentOffset( 0.0f ),
mElideEnabled( false )
virtual VerticalAlignment::Type GetVerticalAlignment() const;
/**
+ * @copydoc ModelInterface::GetVerticalLineAlignment()
+ */
+ virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const override;
+
+ /**
* @copydoc ModelInterface::IsTextElideEnabled()
*/
virtual bool IsTextElideEnabled() const;
* 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
* Typically this will have a negative value with scrolling occurs.
*/
- Vector2 mScrollPosition; ///< The text is offset by this position when scrolling.
- Vector2 mScrollPositionLast; ///< The last offset value of mScrollPosition
- HorizontalAlignment::Type mHorizontalAlignment; ///< The layout's horizontal alignment.
- VerticalAlignment::Type mVerticalAlignment; ///< The layout's vertical alignment.
- Text::LineWrap::Mode mLineWrapMode; ///< The text wrap mode
- float mAlignmentOffset; ///< The alignment offset.
- bool mElideEnabled:1; ///< Whether the text's elide is enabled.
+ Vector2 mScrollPosition; ///< The text is offset by this position when scrolling.
+ Vector2 mScrollPositionLast; ///< The last offset value of mScrollPosition
+ HorizontalAlignment::Type mHorizontalAlignment; ///< The layout's horizontal alignment.
+ VerticalAlignment::Type mVerticalAlignment; ///< The layout's vertical alignment.
+ DevelText::VerticalLineAlignment::Type mVerticalLineAlignment; ///< The layout's vertical line alignment.
+ Text::LineWrap::Mode mLineWrapMode; ///< The text wrap mode
+ float mAlignmentOffset; ///< The alignment offset.
+ bool mElideEnabled:1; ///< Whether the text's elide is enabled.
};
} // namespace Text
GetVisualObject( visual ).mRendererUpdateNeeded = true;
};
+ /**
+ * @brief Instantly updates the renderer
+ * @param[in] visual The text visual.
+ */
+ static void UpdateRenderer( Toolkit::Visual::Base visual )
+ {
+ GetVisualObject( visual ).UpdateRenderer();
+ };
+
public: // from Visual::Base
/**