label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+ // Check the line size property
+ DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ label.SetProperty( DevelTextLabel::Property::MIN_LINE_SIZE, 50.f );
+ DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
application.SendNotification();
application.Render();
*/
TEXT_FIT,
+ /**
+ * @brief Sets the height of the line in points.
+ * @details Name "lineSize", type Property::FLOAT.
+ * @note If the font size is larger than the line size, it works with the font size.
+ */
+ MIN_LINE_SIZE,
+
};
} // namespace Property
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "textBackground", MAP, BACKGROUND )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "ignoreSpacesAfterText", BOOLEAN, IGNORE_SPACES_AFTER_TEXT )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "matchSystemLanguageDirection", BOOLEAN, MATCH_SYSTEM_LANGUAGE_DIRECTION )
-DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "textFit", MAP, TEXT_FIT )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "textFit", MAP, TEXT_FIT )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "minLineSize", FLOAT, MIN_LINE_SIZE )
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 )
}
break;
}
+ case Toolkit::DevelTextLabel::Property::MIN_LINE_SIZE:
+ {
+ if( impl.mController )
+ {
+ const float lineSize = value.Get<float>();
+
+ if( impl.mController->SetDefaultLineSize( lineSize ) )
+ {
+ impl.mTextUpdateNeeded = true;
+ }
+ }
+ break;
+ }
}
// Request relayout when text update is needed. It's necessary to call it
value = map;
break;
}
+ case Toolkit::DevelTextLabel::Property::MIN_LINE_SIZE:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetDefaultLineSize();
+ }
+ break;
+ }
}
}
const float MAX_FLOAT = std::numeric_limits<float>::max();
const CharacterDirection LTR = false;
const CharacterDirection RTL = !LTR;
-const float LINE_SPACING= 0.f;
+const float LINE_SPACING = 0.f;
+const float MIN_LINE_SIZE = 0.f;
inline bool isEmptyLineAtLast( const Vector<LineRun>& lines, const Vector<LineRun>::Iterator& line )
{
Impl()
: mLayout{ Layout::Engine::SINGLE_LINE_BOX },
mCursorWidth{ 0.f },
- mDefaultLineSpacing{ LINE_SPACING }
+ mDefaultLineSpacing{ LINE_SPACING },
+ mDefaultLineSize{ MIN_LINE_SIZE }
{
}
// Sets the minimum descender.
lineLayout.descender = std::min( lineLayout.descender, fontMetrics.descender );
- // set the line spacing
- lineLayout.lineSpacing = mDefaultLineSpacing;
+ // Sets the line size
+ lineLayout.lineSpacing = mDefaultLineSize - ( lineLayout.ascender + -lineLayout.descender );
+ lineLayout.lineSpacing = lineLayout.lineSpacing < 0.f ? 0.f : lineLayout.lineSpacing;
+
+ // Add the line spacing
+ lineLayout.lineSpacing += mDefaultLineSpacing;
}
/**
lineRun.glyphRun.numberOfGlyphs = layout.numberOfGlyphs;
lineRun.characterRun.characterIndex = layout.characterIndex;
lineRun.characterRun.numberOfCharacters = layout.numberOfCharacters;
- lineRun.lineSpacing = mDefaultLineSpacing;
-
lineRun.width = layout.length;
lineRun.extraLength = std::ceil( layout.whiteSpaceLengthEndOfLine );
lineRun.direction = layout.direction;
lineRun.ellipsis = false;
+ lineRun.lineSpacing = mDefaultLineSize - ( lineRun.ascender + -lineRun.descender );
+ lineRun.lineSpacing = lineRun.lineSpacing < 0.f ? 0.f : lineRun.lineSpacing;
+
+ lineRun.lineSpacing += mDefaultLineSpacing;
+
+
// Update the actual size.
if( lineRun.width > layoutSize.width )
{
lineRun.alignmentOffset = 0.f;
lineRun.direction = LTR;
lineRun.ellipsis = false;
- lineRun.lineSpacing = mDefaultLineSpacing;
+
+ lineRun.lineSpacing = mDefaultLineSize - ( lineRun.ascender + -lineRun.descender );
+ lineRun.lineSpacing = lineRun.lineSpacing < 0.f ? 0.f : lineRun.lineSpacing;
+
+ lineRun.lineSpacing += mDefaultLineSpacing;
layoutSize.height += ( lineRun.ascender + -lineRun.descender ) + lineRun.lineSpacing;
}
Type mLayout;
float mCursorWidth;
float mDefaultLineSpacing;
+ float mDefaultLineSize;
IntrusivePtr<Metrics> mMetrics;
};
return mImpl->mDefaultLineSpacing;
}
+void Engine::SetDefaultLineSize( float lineSize )
+{
+ mImpl->mDefaultLineSize = lineSize;
+}
+
+float Engine::GetDefaultLineSize() const
+{
+ return mImpl->mDefaultLineSize;
+}
+
} // namespace Layout
} // namespace Text
*/
float GetDefaultLineSpacing() const;
+ /**
+ * @brief Sets the default line size.
+ *
+ * @param[in] lineSize The line size.
+ */
+ void SetDefaultLineSize( float lineSize );
+
+ /**
+ * @brief Retrieves the default line size.
+ *
+ * @return The line size.
+ */
+ float GetDefaultLineSize() const;
+
private:
// Undefined
return mImpl->mLayoutEngine.GetDefaultLineSpacing();
}
+bool Controller::SetDefaultLineSize( float lineSize )
+{
+ if( std::fabs( lineSize - mImpl->mLayoutEngine.GetDefaultLineSize() ) > Math::MACHINE_EPSILON_1000 )
+ {
+ mImpl->mLayoutEngine.SetDefaultLineSize(lineSize);
+ mImpl->mRecalculateNaturalSize = true;
+ return true;
+ }
+ return false;
+}
+
+float Controller::GetDefaultLineSize() const
+{
+ return mImpl->mLayoutEngine.GetDefaultLineSize();
+}
+
void Controller::SetInputColor( const Vector4& color )
{
if( NULL != mImpl->mEventData )
float GetDefaultLineSpacing() const;
/**
+ * @brief Sets the default line size.
+ *
+ * @param[in] lineSize The line size.
+ *
+ * @return True if lineSize has been updated, false otherwise
+ */
+ bool SetDefaultLineSize( float lineSize );
+
+ /**
+ * @brief Retrieves the default line size.
+ *
+ * @return The line size.
+ */
+ float GetDefaultLineSize() const;
+
+ /**
* @brief Sets the input text's color.
*
* @param[in] color The input text's color.