/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
0.5f, // VerticalAlignment::CENTER
1.0f // VerticalAlignment::BOTTOM
};
+
+ const std::string TEXT_FIT_ENABLE_KEY( "enable" );
+ const std::string TEXT_FIT_MIN_SIZE_KEY( "minSize" );
+ const std::string TEXT_FIT_MAX_SIZE_KEY( "maxSize" );
+ const std::string TEXT_FIT_STEP_SIZE_KEY( "stepSize" );
+ const std::string TEXT_FIT_FONT_SIZE_TYPE_KEY( "fontSizeType" );
}
namespace
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "multiLine", BOOLEAN, MULTI_LINE )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "horizontalAlignment", STRING, HORIZONTAL_ALIGNMENT )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "verticalAlignment", STRING, VERTICAL_ALIGNMENT )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "unusedPropertyTextColor", VECTOR4, UNUSED_PROPERTY_TEXT_COLOR )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "shadowOffset", VECTOR2, SHADOW_OFFSET )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "shadowColor", VECTOR4, SHADOW_COLOR )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineEnabled", BOOLEAN, UNDERLINE_ENABLED )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineColor", VECTOR4, UNDERLINE_COLOR )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineHeight", FLOAT, UNDERLINE_HEIGHT )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "enableMarkup", BOOLEAN, ENABLE_MARKUP )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "enableAutoScroll", BOOLEAN, ENABLE_AUTO_SCROLL )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollSpeed", INTEGER, AUTO_SCROLL_SPEED )
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, "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::TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR:
- {
- label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, value );
- impl.mTextUpdateNeeded = true;
- break;
- }
-
- case Toolkit::TextLabel::Property::SHADOW_OFFSET:
- {
- if( impl.mController )
- {
- const Vector2& shadowOffset = value.Get< Vector2 >();
- if ( impl.mController->GetShadowOffset() != shadowOffset )
- {
- impl.mController->SetShadowOffset( shadowOffset );
- impl.mTextUpdateNeeded = true;
- }
- }
- break;
- }
- case Toolkit::TextLabel::Property::SHADOW_COLOR:
- {
- if( impl.mController )
- {
- const Vector4& shadowColor = value.Get< Vector4 >();
- if ( impl.mController->GetShadowColor() != shadowColor )
- {
- impl.mController->SetShadowColor( shadowColor );
- impl.mTextUpdateNeeded = true;
- }
- }
- break;
- }
- case Toolkit::TextLabel::Property::UNDERLINE_COLOR:
- {
- if( impl.mController )
- {
- const Vector4& color = value.Get< Vector4 >();
- if ( impl.mController->GetUnderlineColor() != color )
- {
- impl.mController->SetUnderlineColor( color );
- impl.mTextUpdateNeeded = true;
- }
- }
- break;
- }
- case Toolkit::TextLabel::Property::UNDERLINE_ENABLED:
- {
- if( impl.mController )
- {
- const bool enabled = value.Get< bool >();
- if ( impl.mController->IsUnderlineEnabled() != enabled )
- {
- impl.mController->SetUnderlineEnabled( enabled );
- impl.mTextUpdateNeeded = true;
- }
- }
- break;
- }
-
- case Toolkit::TextLabel::Property::UNDERLINE_HEIGHT:
- {
- if( impl.mController )
- {
- float height = value.Get< float >();
- if( fabsf( impl.mController->GetUnderlineHeight() - height ) > Math::MACHINE_EPSILON_1000 )
- {
- impl.mController->SetUnderlineHeight( height );
- impl.mTextUpdateNeeded = true;
- }
- }
- break;
- }
case Toolkit::TextLabel::Property::ENABLE_MARKUP:
{
if( impl.mController )
impl.mController->SetMatchSystemLanguageDirection(value.Get< bool >());
break;
}
+ case Toolkit::DevelTextLabel::Property::TEXT_FIT:
+ {
+ const Property::Map& propertiesMap = value.Get<Property::Map>();
+
+ bool enabled = false;
+ float minSize = 0.f;
+ float maxSize = 0.f;
+ float stepSize = 0.f;
+ bool isMinSizeSet = false, isMaxSizeSet = false, isStepSizeSet = false;
+ Controller::FontSizeType type = Controller::FontSizeType::POINT_SIZE;
+
+ if ( !propertiesMap.Empty() )
+ {
+ const unsigned int numberOfItems = propertiesMap.Count();
+
+ // Parses and applies
+ for( unsigned int index = 0u; index < numberOfItems; ++index )
+ {
+ const KeyValuePair& valueGet = propertiesMap.GetKeyValue( index );
+
+ if( ( Controller::TextFitInfo::Property::TEXT_FIT_ENABLE == valueGet.first.indexKey ) || ( TEXT_FIT_ENABLE_KEY == valueGet.first.stringKey ) )
+ {
+ /// Enable key.
+ enabled = valueGet.second.Get< bool >();
+ }
+ else if( ( Controller::TextFitInfo::Property::TEXT_FIT_MIN_SIZE == valueGet.first.indexKey ) || ( TEXT_FIT_MIN_SIZE_KEY == valueGet.first.stringKey ) )
+ {
+ /// min size.
+ minSize = valueGet.second.Get< float >();
+ isMinSizeSet = true;
+ }
+ else if( ( Controller::TextFitInfo::Property::TEXT_FIT_MAX_SIZE == valueGet.first.indexKey ) || ( TEXT_FIT_MAX_SIZE_KEY == valueGet.first.stringKey ) )
+ {
+ /// max size.
+ maxSize = valueGet.second.Get< float >();
+ isMaxSizeSet = true;
+ }
+ else if( ( Controller::TextFitInfo::Property::TEXT_FIT_STEP_SIZE == valueGet.first.indexKey ) || ( TEXT_FIT_STEP_SIZE_KEY == valueGet.first.stringKey ) )
+ {
+ /// step size.
+ stepSize = valueGet.second.Get< float >();
+ isStepSizeSet = true;
+ }
+ else if( ( Controller::TextFitInfo::Property::TEXT_FIT_FONT_SIZE_TYPE == valueGet.first.indexKey ) || ( TEXT_FIT_FONT_SIZE_TYPE_KEY == valueGet.first.stringKey ) )
+ {
+ if( "pixelSize" == valueGet.second.Get< std::string >() )
+ {
+ type = Controller::FontSizeType::PIXEL_SIZE;
+ }
+ }
+ }
+
+ impl.mController->SetTextFitEnabled( enabled );
+ if( isMinSizeSet )
+ {
+ impl.mController->SetTextFitMinSize( minSize, type );
+ }
+ if( isMaxSizeSet )
+ {
+ impl.mController->SetTextFitMaxSize( maxSize, type );
+ }
+ if( isStepSizeSet )
+ {
+ impl.mController->SetTextFitStepSize( stepSize, type );
+ }
+ }
+ 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
impl.RequestTextRelayout();
}
}
-
-
-
-
}
Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index index )
}
break;
}
- case Toolkit::TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR:
- {
- value = label.GetProperty( Toolkit::TextLabel::Property::TEXT_COLOR );
- break;
- }
- case Toolkit::TextLabel::Property::SHADOW_OFFSET:
- {
- if ( impl.mController )
- {
- value = impl.mController->GetShadowOffset();
- }
- break;
- }
- case Toolkit::TextLabel::Property::SHADOW_COLOR:
- {
- if ( impl.mController )
- {
- value = impl.mController->GetShadowColor();
- }
- break;
- }
- case Toolkit::TextLabel::Property::UNDERLINE_COLOR:
- {
- if ( impl.mController )
- {
- value = impl.mController->GetUnderlineColor();
- }
- break;
- }
- case Toolkit::TextLabel::Property::UNDERLINE_ENABLED:
- {
- if ( impl.mController )
- {
- value = impl.mController->IsUnderlineEnabled();
- }
- break;
- }
- case Toolkit::TextLabel::Property::UNDERLINE_HEIGHT:
- {
- if ( impl.mController )
- {
- value = impl.mController->GetUnderlineHeight();
- }
- break;
- }
case Toolkit::TextLabel::Property::ENABLE_MARKUP:
{
if( impl.mController )
value = impl.mController->IsMatchSystemLanguageDirection();
break;
}
+ case Toolkit::DevelTextLabel::Property::TEXT_FIT:
+ {
+ const bool enabled = impl.mController->IsTextFitEnabled();
+ const float minSize = impl.mController->GetTextFitMinSize();
+ const float maxSize = impl.mController->GetTextFitMaxSize();
+ const float stepSize = impl.mController->GetTextFitStepSize();
+
+ Property::Map map;
+ map.Insert( TEXT_FIT_ENABLE_KEY, enabled );
+ map.Insert( TEXT_FIT_MIN_SIZE_KEY, minSize );
+ map.Insert( TEXT_FIT_MAX_SIZE_KEY, maxSize );
+ map.Insert( TEXT_FIT_STEP_SIZE_KEY, stepSize );
+ map.Insert( TEXT_FIT_FONT_SIZE_TYPE_KEY, "pointSize" );
+
+ value = map;
+ break;
+ }
+ case Toolkit::DevelTextLabel::Property::MIN_LINE_SIZE:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetDefaultLineSize();
+ }
+ break;
+ }
}
}
Vector2 contentSize( size.x - ( padding.start + padding.end ), size.y - ( padding.top + padding.bottom ) );
+ if( mController->IsTextFitEnabled() )
+ {
+ mController->FitPointSizeforLayout( contentSize );
+ mController->SetTextFitContentSize( contentSize );
+ }
+
// Support Right-To-Left
Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( Self().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
void TextLabel::RequestTextRelayout()
{
RelayoutRequest();
- Toolkit::DevelControl::RequestLayout( *this );
+ // Signal that a Relayout may be needed
}
void TextLabel::SetUpAutoScrolling()
const int maxTextureSize = Dali::GetMaxTextureSize();
//if the texture size width exceed maxTextureSize, modify the visual model size and enabled the ellipsis
+ bool actualellipsis = mController->IsTextElideEnabled();
if( verifiedSize.width > maxTextureSize )
{
verifiedSize.width = maxTextureSize;
// Set parameters for scrolling
Renderer renderer = static_cast<Internal::Visual::Base&>( GetImplementation( mVisual ) ).GetRenderer();
mTextScroller->SetParameters( Self(), renderer, textureSet, controlSize, verifiedSize, wrapGap, direction, mController->GetHorizontalAlignment(), mController->GetVerticalAlignment() );
+ mController->SetTextElideEnabled( actualellipsis );
}
void TextLabel::ScrollingFinished()
// Pure Virtual from TextScroller Interface
DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::ScrollingFinished\n");
mController->SetAutoScrollEnabled( false );
- mController->SetTextElideEnabled( true );
RequestTextRelayout();
}