extern int UtcDaliTextActorPropertyIndices(void);
extern int UtcDaliTextStyleDefaultConstructor(void);
extern int UtcDaliTextStyleCopyConstructor(void);
+extern int UtcDaliTextStyleAssignmentOperator(void);
extern int UtcDaliTextStyleComparisonOperator(void);
extern int UtcDaliTextStyleCopy(void);
+extern int UtcDaliTextStyleReset(void);
extern int UtcDaliTextStyleSetGetFontName(void);
extern int UtcDaliTextStyleSetGetFontStyle(void);
extern int UtcDaliTextStyleSetGetFontPointSize(void);
-extern int UtcDaliTextStyleSetGetWeight(void);
extern int UtcDaliTextStyleSetGetTextColor(void);
+extern int UtcDaliTextStyleSetGetWeight(void);
+extern int UtcDaliTextStyleSetGetSmoothEdge(void);
extern int UtcDaliTextStyleSetGetItalics(void);
-extern int UtcDaliTextStyleSetGetItalicsAngle(void);
extern int UtcDaliTextStyleSetGetUnderline(void);
extern int UtcDaliTextStyleSetGetShadow(void);
extern int UtcDaliTextStyleSetGetGlow(void);
extern int UtcDaliTextStyleSetGetOutline(void);
-extern int UtcDaliTextStyleSetGetSmoothEdge(void);
+extern int UtcDaliTextStyleSetGetGradient(void);
extern int UtcDaliTouchEventCombinerConstructors(void);
extern int UtcDaliTouchEventCombinerConstructorsNegative(void);
extern int UtcDaliTouchEventCombinerSettersAndGetters(void);
{"UtcDaliTextActorPropertyIndices", UtcDaliTextActorPropertyIndices, text_actor_test_startup, text_actor_test_cleanup},
{"UtcDaliTextStyleDefaultConstructor", UtcDaliTextStyleDefaultConstructor, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
{"UtcDaliTextStyleCopyConstructor", UtcDaliTextStyleCopyConstructor, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
+ {"UtcDaliTextStyleAssignmentOperator", UtcDaliTextStyleAssignmentOperator, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
{"UtcDaliTextStyleComparisonOperator", UtcDaliTextStyleComparisonOperator, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
{"UtcDaliTextStyleCopy", UtcDaliTextStyleCopy, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
+ {"UtcDaliTextStyleReset", UtcDaliTextStyleReset, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
{"UtcDaliTextStyleSetGetFontName", UtcDaliTextStyleSetGetFontName, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
{"UtcDaliTextStyleSetGetFontStyle", UtcDaliTextStyleSetGetFontStyle, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
{"UtcDaliTextStyleSetGetFontPointSize", UtcDaliTextStyleSetGetFontPointSize, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
- {"UtcDaliTextStyleSetGetWeight", UtcDaliTextStyleSetGetWeight, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
{"UtcDaliTextStyleSetGetTextColor", UtcDaliTextStyleSetGetTextColor, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
+ {"UtcDaliTextStyleSetGetWeight", UtcDaliTextStyleSetGetWeight, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
+ {"UtcDaliTextStyleSetGetSmoothEdge", UtcDaliTextStyleSetGetSmoothEdge, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
{"UtcDaliTextStyleSetGetItalics", UtcDaliTextStyleSetGetItalics, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
- {"UtcDaliTextStyleSetGetItalicsAngle", UtcDaliTextStyleSetGetItalicsAngle, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
{"UtcDaliTextStyleSetGetUnderline", UtcDaliTextStyleSetGetUnderline, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
{"UtcDaliTextStyleSetGetShadow", UtcDaliTextStyleSetGetShadow, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
{"UtcDaliTextStyleSetGetGlow", UtcDaliTextStyleSetGetGlow, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
{"UtcDaliTextStyleSetGetOutline", UtcDaliTextStyleSetGetOutline, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
- {"UtcDaliTextStyleSetGetSmoothEdge", UtcDaliTextStyleSetGetSmoothEdge, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
+ {"UtcDaliTextStyleSetGetGradient", UtcDaliTextStyleSetGetGradient, utc_dali_text_style_startup, utc_dali_text_style_cleanup},
{"UtcDaliTouchEventCombinerConstructors", UtcDaliTouchEventCombinerConstructors, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup},
{"UtcDaliTouchEventCombinerConstructorsNegative", UtcDaliTouchEventCombinerConstructorsNegative, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup},
{"UtcDaliTouchEventCombinerSettersAndGetters", UtcDaliTouchEventCombinerSettersAndGetters, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup},
static const char* TestTextHelloWorld = "Hello World";
static const char* LongTestText = "This is a very long piece of text, and is sure not to fit into any box presented to it";
-const std::string FAMILY_NAME = "Arial";
-const std::string STYLE = "Bold";
-const unsigned int POINT_SIZE = 11.f;
-static const Vector4 FONT_TEXT_COLOR = Color::RED;
-static const Degree FONT_ITALICS_ANGLE(10.f);
-static const Radian FONT_ITALICS_RADIAN_ANGLE(0.4f);
-static const bool FONT_ITALICS = true;
-static const bool FONT_UNDERLINE = true;
-static const bool FONT_SHADOW = true;
-static const bool FONT_GLOW = true;
-static const bool FONT_OUTLINE = true;
-static const float FONT_UNDERLINE_THICKNESS = 5.0f;
-static const float FONT_UNDERLINE_POSITION = 60.0f;
-static const Vector4 FONT_SHADOW_COLOR = Color::BLUE;
-static const Vector2 FONT_SHADOW_OFFSET(2.f, 2.f );
-static const float FONT_SHADOW_SIZE = 55.f;
-static const Vector4 FONT_TEXT_GLOW_COLOR = Color::BLACK;
-static const float FONT_GLOW_INTENSITY = 10.0f;
-static const float FONT_SMOOTH_EDGE = 5.0f;
-static const Vector4 FONT_OUTLINE_COLOR = Color::MAGENTA;
-static const Vector2 FONT_OUTLINE_THICKNESS(15.f, 14.f );
-
+static const std::string DEFAULT_NAME_STYLE( "" );
+static const PointSize DEFAULT_FONT_POINT_SIZE( 0.f );
+
+static const std::string FONT_FAMILY( "Arial" );
+static const std::string FONT_STYLE( "Bold" );
+static const PointSize FONT_POINT_SIZE( 12.f );
+static const Vector4 TEXT_COLOR( Color::RED );
+
+static const TextStyle::Weight TEXT_WEIGHT( TextStyle::EXTRALIGHT );
+static const float SMOOTH_EDGE( 5.0f );
+
+static const bool ITALICS( true );
+static const Degree ITALICS_ANGLE( 10.f );
+static const Radian ITALICS_RADIAN_ANGLE(0.4f);
+
+static const bool UNDERLINE( true );
+static const float UNDERLINE_THICKNESS( 5.0f );
+static const float UNDERLINE_POSITION( 60.0f );
+
+static const bool SHADOW( true );
+static const Vector4 SHADOW_COLOR( Color::BLUE );
+static const Vector2 SHADOW_OFFSET( 2.f, 2.f );
+static const float SHADOW_SIZE( 55.f );
+
+static const bool GLOW( true );
+static const Vector4 GLOW_COLOR( Color::BLACK );
+static const float GLOW_INTENSITY( 10.0f );
+
+static const bool OUTLINE( true );
+static const Vector4 OUTLINE_COLOR( Color::MAGENTA );
+static const Vector2 OUTLINE_THICKNESS( 15.f, 14.f );
+
+static const bool GRADIENT( true );
+static const Vector4 GRADIENT_COLOR( Color::YELLOW );
+static const Vector2 GRADIENT_START_POINT( 1.f, 1.f );
+static const Vector2 GRADIENT_END_POINT( 2.f, 2.f );
} // anon namespace
int UtcDaliTextActorConstructorVoid(void)
TextActor actor = TextActor::New(TestTextHello);
- PointSize pointSize( POINT_SIZE );
- FontParameters params( FAMILY_NAME, STYLE, pointSize);
+ Font defaultFont = actor.GetFont();
+ DALI_TEST_EQUALS( defaultFont.GetName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultFont.GetStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_CHECK( defaultFont.IsDefaultSystemSize() );
+
+ TextStyle defaultStyle = actor.GetTextStyle();
+ DALI_TEST_EQUALS( defaultStyle.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
+
+ FontParameters params( FONT_FAMILY, FONT_STYLE, FONT_POINT_SIZE );
Font font = Font::New( params );
actor.SetFont( font );
- DALI_TEST_CHECK( actor.GetFont().GetName() == FAMILY_NAME );
+ Font font2 = actor.GetFont();
+
+ DALI_TEST_EQUALS( font2.GetName(), FONT_FAMILY, TEST_LOCATION );
+ DALI_TEST_EQUALS( font2.GetStyle(), FONT_STYLE, TEST_LOCATION );
+ DALI_TEST_CHECK( !font2.IsDefaultSystemSize() );
+ DALI_TEST_EQUALS( PointSize( font2.GetPointSize() ), FONT_POINT_SIZE, TEST_LOCATION );
+
+ TextStyle style = actor.GetTextStyle();
+ DALI_TEST_EQUALS( style.GetFontName(), FONT_FAMILY, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetFontStyle(), FONT_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION );
+
END_TEST;
}
TestApplication application;
TextActor actor = TextActor::New(TestTextHello);
+ TextStyle defaultStyle = actor.GetTextStyle();
- actor.SetTextColor( FONT_TEXT_COLOR);
+ DALI_TEST_EQUALS( actor.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
- DALI_TEST_CHECK( actor.GetTextColor() == FONT_TEXT_COLOR );
+ DALI_TEST_EQUALS( actor.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
- actor.SetSmoothEdge( FONT_SMOOTH_EDGE );
+ DALI_TEST_EQUALS( defaultStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- actor.SetOutline( FONT_OUTLINE, FONT_OUTLINE_COLOR, FONT_OUTLINE_THICKNESS );
+ DALI_TEST_CHECK( !actor.GetItalics() );
+ DALI_TEST_EQUALS( actor.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
+ DALI_TEST_CHECK( defaultStyle.IsItalicsDefault() );
+ DALI_TEST_CHECK( !defaultStyle.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
- actor.SetShadow( FONT_SHADOW, FONT_SHADOW_COLOR, FONT_SHADOW_OFFSET, FONT_SHADOW_SIZE );
+ DALI_TEST_CHECK( !actor.GetUnderline() );
+ DALI_TEST_CHECK( defaultStyle.IsUnderlineDefault() );
+ DALI_TEST_CHECK( !defaultStyle.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- actor.SetItalics( FONT_ITALICS, FONT_ITALICS_ANGLE );
+ DALI_TEST_CHECK( defaultStyle.IsShadowDefault() );
+ DALI_TEST_CHECK( !defaultStyle.IsShadowEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
- actor.SetGlow( FONT_GLOW, FONT_TEXT_GLOW_COLOR, FONT_GLOW_INTENSITY );
+ DALI_TEST_CHECK( defaultStyle.IsGlowDefault() );
+ DALI_TEST_CHECK( !defaultStyle.IsGlowEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( defaultStyle.IsOutlineDefault() );
+ DALI_TEST_CHECK( !defaultStyle.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
+
+ DALI_TEST_CHECK( defaultStyle.IsGradientDefault() );
+ DALI_TEST_CHECK( !defaultStyle.IsGradientEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
- TextStyle style = actor.GetTextStyle();
- DALI_TEST_CHECK( FONT_TEXT_COLOR == style.GetTextColor() );
+ actor.SetTextColor( TEXT_COLOR );
- DALI_TEST_CHECK( FONT_SMOOTH_EDGE == style.GetSmoothEdge() );
+ actor.SetWeight( TEXT_WEIGHT );
+ actor.SetSmoothEdge( SMOOTH_EDGE );
- DALI_TEST_CHECK( FONT_OUTLINE == style.GetOutline() );
- DALI_TEST_CHECK( FONT_OUTLINE_COLOR == style.GetOutlineColor() );
- DALI_TEST_CHECK( FONT_OUTLINE_THICKNESS == style.GetOutlineThickness() );
+ actor.SetItalics( ITALICS, ITALICS_ANGLE );
+ actor.SetUnderline( UNDERLINE );
+ actor.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
+ actor.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
+ actor.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
+ actor.SetGradientColor( GRADIENT_COLOR );
+ actor.SetGradientStartPoint( GRADIENT_START_POINT );
+ actor.SetGradientEndPoint( GRADIENT_END_POINT );
- DALI_TEST_CHECK( FONT_SHADOW == style.GetShadow() );
- DALI_TEST_CHECK( FONT_SHADOW_COLOR == style.GetShadowColor() );
- DALI_TEST_CHECK( FONT_SHADOW_OFFSET == style.GetShadowOffset() );
- DALI_TEST_CHECK( FONT_SHADOW_SIZE == style.GetShadowSize() );
- DALI_TEST_CHECK( FONT_ITALICS == style.GetItalics() );
- DALI_TEST_CHECK( FONT_ITALICS_ANGLE == style.GetItalicsAngle() );
+ TextStyle style = actor.GetTextStyle();
+
+ DALI_TEST_EQUALS( actor.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( actor.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
- DALI_TEST_CHECK( FONT_GLOW == style.GetGlow() );
- DALI_TEST_CHECK( FONT_OUTLINE == style.GetOutline() );
- DALI_TEST_CHECK( FONT_TEXT_GLOW_COLOR == style.GetGlowColor() );
- DALI_TEST_CHECK( FONT_GLOW_INTENSITY == style.GetGlowIntensity() );
+ DALI_TEST_EQUALS( style.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_CHECK( actor.GetItalics() );
+ DALI_TEST_EQUALS( actor.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
+ DALI_TEST_CHECK( !style.IsItalicsDefault() );
+ DALI_TEST_CHECK( style.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( style.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
+
+ DALI_TEST_CHECK( actor.GetUnderline() );
+ DALI_TEST_CHECK( !style.IsUnderlineDefault() );
+ DALI_TEST_CHECK( style.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style.IsShadowDefault() );
+ DALI_TEST_CHECK( style.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style.IsGlowDefault() );
+ DALI_TEST_CHECK( style.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style.GetGlowColor(), GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style.IsOutlineDefault() );
+ DALI_TEST_CHECK( style.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( actor.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION );
+ DALI_TEST_CHECK( !style.IsGradientDefault() );
+ DALI_TEST_CHECK( style.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION );
+
+ // Added to increase coverage.
+
+ // Set a different color.
+ actor.SetTextColor( TEXT_COLOR );
+ actor.SetTextColor( Color::GREEN );
+ DALI_TEST_EQUALS( actor.GetTextColor(), Color::GREEN, TEST_LOCATION );
+
+ // Set a different weight
+ actor.SetWeight( TEXT_WEIGHT );
+ actor.SetWeight( TextStyle::BOLD );
+ DALI_TEST_EQUALS( actor.GetWeight(), TextStyle::BOLD, TEST_LOCATION );
- actor.SetItalics( FONT_ITALICS, FONT_ITALICS_RADIAN_ANGLE );
- style = actor.GetTextStyle();
- DALI_TEST_CHECK( FONT_ITALICS_RADIAN_ANGLE == style.GetItalicsAngle() );
+ // Set a different smooth edge
+ actor.SetSmoothEdge( SMOOTH_EDGE );
+ actor.SetSmoothEdge( 1.f );
+ DALI_TEST_EQUALS( actor.GetTextStyle().GetSmoothEdge(), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ // Set different italic parameters
+ actor.SetItalics( true, ITALICS_ANGLE );
+ actor.SetItalics( false );
+ DALI_TEST_CHECK( !actor.GetItalics() );
+ actor.SetItalics( true, Degree( 15.f ) );
+ DALI_TEST_EQUALS( actor.GetItalicsAngle(), Degree( 15.f ), TEST_LOCATION );
END_TEST;
}
TextActor actor = TextActor::New(TestTextHello);
- TextStyle defaultStyle = actor.GetTextStyle();
- DALI_TEST_CHECK( defaultStyle.GetFontName().empty() );
- DALI_TEST_CHECK( TextStyle::REGULAR == defaultStyle.GetWeight() );
- DALI_TEST_CHECK( Color::WHITE == defaultStyle.GetTextColor() );
- DALI_TEST_CHECK( !defaultStyle.GetItalics() );
- DALI_TEST_CHECK( !defaultStyle.GetUnderline() );
+ const TextStyle defaultStyle = actor.GetTextStyle();
+
+ DALI_TEST_EQUALS( defaultStyle.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( defaultStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( defaultStyle.IsItalicsDefault() );
+ DALI_TEST_CHECK( !defaultStyle.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
+
+ DALI_TEST_CHECK( defaultStyle.IsUnderlineDefault() );
+ DALI_TEST_CHECK( !defaultStyle.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( defaultStyle.IsShadowDefault() );
+ DALI_TEST_CHECK( !defaultStyle.IsShadowEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
+
+ DALI_TEST_CHECK( defaultStyle.IsGlowDefault() );
+ DALI_TEST_CHECK( !defaultStyle.IsGlowEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( defaultStyle.IsOutlineDefault() );
+ DALI_TEST_CHECK( !defaultStyle.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
+
+ DALI_TEST_CHECK( defaultStyle.IsGradientDefault() );
+ DALI_TEST_CHECK( !defaultStyle.IsGradientEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
+
+
+ // Set a non default style.
TextStyle style;
- style.SetFontPointSize(PointSize( 16.f ));
- style.SetWeight(TextStyle::EXTRABLACK);
- style.SetTextColor(Color::BLUE);
- style.SetItalics(true);
- style.SetUnderline(true);
- style.SetShadow(false);
- style.SetGlow(false);
- style.SetOutline(false);
+ style.SetFontName( FONT_FAMILY );
+ style.SetFontStyle( FONT_STYLE );
+ style.SetFontPointSize( FONT_POINT_SIZE );
+ style.SetTextColor( TEXT_COLOR );
+
+ style.SetWeight( TEXT_WEIGHT );
+ style.SetSmoothEdge( SMOOTH_EDGE );
+
+ style.SetItalics( ITALICS, ITALICS_ANGLE );
+ style.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION );
+
+ style.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
+ style.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
+ style.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
+ style.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
actor.SetTextStyle( style );
+
// This is necessary since SetColor (via TextStyle) is asynchronous
application.SendNotification();
application.Render();
- style = actor.GetTextStyle();
-
- DALI_TEST_CHECK( style.GetFontName().empty() );
- DALI_TEST_CHECK( style.GetFontStyle().empty() );
- DALI_TEST_EQUALS( static_cast<float>( PointSize( 16.f ) ),
- static_cast<float>( style.GetFontPointSize() ),
- GetRangedEpsilon( PointSize( 16.f ), style.GetFontPointSize() ),
- TEST_LOCATION );
- DALI_TEST_CHECK( TextStyle::EXTRABLACK == style.GetWeight() );
- DALI_TEST_EQUALS( Vector4( 0.f, 0.f, 1.f, 1.f ), style.GetTextColor(), TEST_LOCATION );
- DALI_TEST_CHECK( style.GetItalics() );
- DALI_TEST_CHECK( style.GetUnderline() );
+
+ TextStyle style2 = actor.GetTextStyle();
+
+ DALI_TEST_CHECK( !style2.IsFontNameDefault() );
+ DALI_TEST_CHECK( !style2.IsFontStyleDefault() );
+ DALI_TEST_CHECK( !style2.IsFontSizeDefault() );
+ DALI_TEST_CHECK( !style2.IsTextColorDefault() );
+ DALI_TEST_CHECK( !style2.IsFontWeightDefault() );
+ DALI_TEST_CHECK( !style2.IsSmoothEdgeDefault() );
+ DALI_TEST_CHECK( !style2.IsItalicsDefault() );
+ DALI_TEST_CHECK( !style2.IsUnderlineDefault() );
+ DALI_TEST_CHECK( !style2.IsShadowDefault() );
+ DALI_TEST_CHECK( !style2.IsGlowDefault() );
+ DALI_TEST_CHECK( !style2.IsOutlineDefault() );
+ DALI_TEST_CHECK( !style2.IsGradientDefault() );
+
+ DALI_TEST_EQUALS( style2.GetFontName(), FONT_FAMILY, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetFontStyle(), FONT_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( style2.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( style2.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style2.GetUnderlineThickness(), UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetUnderlinePosition(), UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style2.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style2.GetGlowColor(), GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style2.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style2.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION );
+
+
+ // Set a default style
+ actor.SetTextStyle( defaultStyle );
+
+ TextStyle style3 = actor.GetTextStyle();
+
+ DALI_TEST_EQUALS( style3.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style3.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style3.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style3.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( style3.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style3.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style3.IsItalicsDefault() );
+ DALI_TEST_CHECK( !style3.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( style3.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style3.IsUnderlineDefault() );
+ DALI_TEST_CHECK( !style3.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style3.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style3.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style3.IsShadowDefault() );
+ DALI_TEST_CHECK( !style3.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style3.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style3.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style3.IsGlowDefault() );
+ DALI_TEST_CHECK( !style3.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style3.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style3.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style3.IsOutlineDefault() );
+ DALI_TEST_CHECK( !style3.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style3.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style3.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style3.IsGradientDefault() );
+ DALI_TEST_CHECK( !style3.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style3.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style3.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style3.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
+
+ // Added to increase coverage.
+ // Reset what is already reset.
+
+ actor.SetTextStyle( style3 );
+
+ TextStyle style4 = actor.GetTextStyle();
+
+ DALI_TEST_EQUALS( style4.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style4.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style4.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style4.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( style4.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style4.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style4.IsItalicsDefault() );
+ DALI_TEST_CHECK( !style4.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( style4.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style4.IsUnderlineDefault() );
+ DALI_TEST_CHECK( !style4.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style4.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style4.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style4.IsShadowDefault() );
+ DALI_TEST_CHECK( !style4.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style4.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style4.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style4.IsGlowDefault() );
+ DALI_TEST_CHECK( !style4.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style4.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style4.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style4.IsOutlineDefault() );
+ DALI_TEST_CHECK( !style4.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style4.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style4.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style4.IsGradientDefault() );
+ DALI_TEST_CHECK( !style4.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style4.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style4.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style4.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
+
END_TEST;
}
namespace
{
+static const std::string DEFAULT_FONT_NAME_STYLE( "" );
+static const PointSize DEFAULT_FONT_POINT_SIZE( 0.f );
-static const std::string FONT_FAMILY="Arial";
-static const std::string FONT_STYLE="Bold";
-static const PointSize FONT_POINT=PointSize(12.f);
-static const TextStyle::Weight FONT_TEXT_STYLE_WEIGHT = TextStyle::EXTRALIGHT;
-
-static const Vector4 FONT_TEXT_COLOR = Color::RED;
-static const Degree FONT_ITALICS_ANGLE(10.f);
-static const bool FONT_ITALICS = true;
-static const bool FONT_UNDERLINE = true;
-static const bool FONT_SHADOW = true;
-static const bool FONT_GLOW = true;
-static const bool FONT_OUTLINE = true;
-static const float FONT_UNDERLINE_THICKNESS = 5.0f;
-static const float FONT_UNDERLINE_POSITION = 60.0f;
-static const Vector4 FONT_SHADOW_COLOR = Color::BLUE;
-static const Vector2 FONT_SHADOW_OFFSET(2.f, 2.f );
-static const float FONT_SHADOW_SIZE = 55.f;
-static const Vector4 FONT_TEXT_GLOW_COLOR = Color::BLACK;
-static const float FONT_GLOW_INTENSITY = 10.0f;
-static const float FONT_SMOOTH_EDGE = 5.0f;
-static const Vector4 FONT_OUTLINE_COLOR = Color::MAGENTA;
-static const Vector2 FONT_OUTLINE_THICKNESS(15.f, 14.f );
+static const std::string FONT_FAMILY( "Arial" );
+static const std::string FONT_STYLE( "Bold" );
+static const PointSize FONT_POINT_SIZE( 12.f );
+static const Vector4 TEXT_COLOR( Color::RED );
+static const TextStyle::Weight TEXT_WEIGHT( TextStyle::EXTRALIGHT );
+static const float SMOOTH_EDGE( 5.0f );
+
+static const bool ITALICS( true );
+static const Degree ITALICS_ANGLE( 10.f );
+
+static const bool UNDERLINE( true );
+static const float UNDERLINE_THICKNESS( 5.0f );
+static const float UNDERLINE_POSITION( 60.0f );
+
+static const bool SHADOW( true );
+static const Vector4 SHADOW_COLOR( Color::BLUE );
+static const Vector2 SHADOW_OFFSET( 2.f, 2.f );
+static const float SHADOW_SIZE( 55.f );
+
+static const bool GLOW( true );
+static const Vector4 GLOW_COLOR( Color::BLACK );
+static const float GLOW_INTENSITY( 10.0f );
+
+static const bool OUTLINE( true );
+static const Vector4 OUTLINE_COLOR( Color::MAGENTA );
+static const Vector2 OUTLINE_THICKNESS( 15.f, 14.f );
+
+static const bool GRADIENT( true );
+static const Vector4 GRADIENT_COLOR( Color::YELLOW );
+static const Vector2 GRADIENT_START_POINT( 1.f, 1.f );
+static const Vector2 GRADIENT_END_POINT( 2.f, 2.f );
} // anon namespace
int UtcDaliTextStyleDefaultConstructor(void)
TextStyle defaultStyle;
- DALI_TEST_CHECK( defaultStyle.GetFontName().empty() );
- DALI_TEST_CHECK( PointSize( 0.f ) == defaultStyle.GetFontPointSize() );
- DALI_TEST_CHECK( TextStyle::REGULAR == defaultStyle.GetWeight() );
- DALI_TEST_CHECK( Color::WHITE == defaultStyle.GetTextColor() );
- DALI_TEST_CHECK( !defaultStyle.GetItalics() );
-
- DALI_TEST_CHECK( !defaultStyle.GetUnderline() );
- DALI_TEST_CHECK( fabs( TextStyle::DEFAULT_UNDERLINE_THICKNESS - defaultStyle.GetUnderlineThickness() ) < GetRangedEpsilon( TextStyle::DEFAULT_UNDERLINE_THICKNESS, defaultStyle.GetUnderlineThickness() ) );
- DALI_TEST_CHECK( fabs( TextStyle::DEFAULT_UNDERLINE_POSITION - defaultStyle.GetUnderlinePosition() ) < GetRangedEpsilon( TextStyle::DEFAULT_UNDERLINE_POSITION, defaultStyle.GetUnderlinePosition() ) );
-
- DALI_TEST_CHECK( TextStyle::DEFAULT_ITALICS_ANGLE == defaultStyle.GetItalicsAngle() );
- DALI_TEST_CHECK( TextStyle::DEFAULT_SHADOW_COLOR == defaultStyle.GetShadowColor() );
- DALI_TEST_CHECK( TextStyle::DEFAULT_GLOW_COLOR == defaultStyle.GetGlowColor() );
- DALI_TEST_CHECK( TextStyle::DEFAULT_OUTLINE_COLOR == defaultStyle.GetOutlineColor() );
-
- DALI_TEST_CHECK( TextStyle::DEFAULT_SHADOW_OFFSET == defaultStyle.GetShadowOffset() );
- DALI_TEST_CHECK( TextStyle::DEFAULT_OUTLINE_THICKNESS == defaultStyle.GetOutlineThickness() );
- DALI_TEST_CHECK( fabs( TextStyle::DEFAULT_GLOW_INTENSITY - defaultStyle.GetGlowIntensity() ) < GetRangedEpsilon( TextStyle::DEFAULT_GLOW_INTENSITY, defaultStyle.GetGlowIntensity() ) );
- DALI_TEST_CHECK( fabs( TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD - defaultStyle.GetSmoothEdge() ) < GetRangedEpsilon( TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, defaultStyle.GetSmoothEdge() ) );
+ DALI_TEST_CHECK( defaultStyle.IsFontNameDefault() );
+ DALI_TEST_CHECK( defaultStyle.IsFontStyleDefault() );
+ DALI_TEST_CHECK( defaultStyle.IsFontSizeDefault() );
+ DALI_TEST_CHECK( defaultStyle.IsTextColorDefault() );
+ DALI_TEST_CHECK( defaultStyle.IsFontWeightDefault() );
+ DALI_TEST_CHECK( defaultStyle.IsSmoothEdgeDefault() );
+ DALI_TEST_CHECK( defaultStyle.IsItalicsDefault() );
+ DALI_TEST_CHECK( defaultStyle.IsUnderlineDefault() );
+ DALI_TEST_CHECK( defaultStyle.IsShadowDefault() );
+ DALI_TEST_CHECK( defaultStyle.IsGlowDefault() );
+ DALI_TEST_CHECK( defaultStyle.IsOutlineDefault() );
+ DALI_TEST_CHECK( defaultStyle.IsGradientDefault() );
+
+ DALI_TEST_EQUALS( defaultStyle.GetFontName(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetFontStyle(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( defaultStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !defaultStyle.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !defaultStyle.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !defaultStyle.IsShadowEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !defaultStyle.IsGlowEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !defaultStyle.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !defaultStyle.IsGradientEnabled() );
+ DALI_TEST_EQUALS( defaultStyle.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( defaultStyle.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
+
END_TEST;
}
TestApplication application;
- const std::string fontName( "Arial" );
- const std::string fontStyle( "Book" );
-
TextStyle style;
- style.SetFontName( fontName );
- style.SetFontStyle( fontStyle );
- style.SetFontPointSize( PointSize( 16.f ) );
- style.SetWeight( TextStyle::EXTRABLACK );
- style.SetTextColor( Color::BLUE );
- style.SetItalics( true );
- style.SetUnderline( true );
- style.SetItalicsAngle( Degree( 15.f ) );
- style.SetUnderlineThickness( 3.5f );
- style.SetUnderlinePosition( 12.f );
- style.SetShadow( true, Color::RED, Vector2( 0.5f, 0.5f ), TextStyle::DEFAULT_SHADOW_SIZE );
- style.SetGlow( true, Color::GREEN, 0.75f );
- style.SetSmoothEdge( 0.8f );
- style.SetOutline( true, Color::BLUE, Vector2( 0.9f, 0.9f ) );
+ style.SetFontName( FONT_FAMILY );
+ style.SetFontStyle( FONT_STYLE );
+ style.SetFontPointSize( FONT_POINT_SIZE );
+ style.SetTextColor( TEXT_COLOR );
+
+ style.SetWeight( TEXT_WEIGHT );
+ style.SetSmoothEdge( SMOOTH_EDGE );
+
+ style.SetItalics( ITALICS, ITALICS_ANGLE );
+ style.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION );
+ style.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
+ style.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
+ style.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
+ style.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
TextStyle style1( style );
TextStyle style2 = style;
- DALI_TEST_CHECK( fontName == style1.GetFontName() );
- DALI_TEST_CHECK( fontStyle == style.GetFontStyle() );
- DALI_TEST_CHECK( PointSize( 16.f ) == style1.GetFontPointSize() );
- DALI_TEST_CHECK( TextStyle::EXTRABLACK == style1.GetWeight() );
- DALI_TEST_CHECK( Vector4( 0.f, 0.f, 1.f, 1.f ) == style1.GetTextColor() );
- DALI_TEST_CHECK( style1.GetItalics() );
- DALI_TEST_CHECK( style1.GetUnderline() );
-
- DALI_TEST_CHECK( Degree( 15.f ) == style1.GetItalicsAngle() );
- DALI_TEST_CHECK( Color::RED == style1.GetShadowColor() );
- DALI_TEST_CHECK( Color::GREEN == style1.GetGlowColor() );
- DALI_TEST_CHECK( Color::BLUE == style1.GetOutlineColor() );
-
- DALI_TEST_CHECK( Vector2( 0.5f, 0.5f ) == style1.GetShadowOffset() );
- DALI_TEST_CHECK( Vector2( 0.9f, 0.9f ) == style1.GetOutlineThickness() );
- DALI_TEST_CHECK( fabs( 0.75f - style1.GetGlowIntensity() ) < GetRangedEpsilon( 0.75f, style1.GetGlowIntensity() ) );
- DALI_TEST_CHECK( fabs( 0.8f - style1.GetSmoothEdge() ) < GetRangedEpsilon( 0.8f, style1.GetSmoothEdge() ) );
-
- DALI_TEST_CHECK( fontName == style2.GetFontName() );
- DALI_TEST_CHECK( PointSize( 16.f ) == style2.GetFontPointSize() );
- DALI_TEST_CHECK( TextStyle::EXTRABLACK == style2.GetWeight() );
- DALI_TEST_CHECK( Vector4( 0.f, 0.f, 1.f, 1.f ) == style2.GetTextColor() );
- DALI_TEST_CHECK( style2.GetItalics() );
-
- DALI_TEST_CHECK( style2.GetUnderline() );
- DALI_TEST_CHECK( fabs( 3.5f - style2.GetUnderlineThickness() ) < GetRangedEpsilon( 3.5f, style2.GetUnderlineThickness() ) );
- DALI_TEST_CHECK( fabs( 12.f - style2.GetUnderlinePosition() ) < GetRangedEpsilon( 12.f, style2.GetUnderlinePosition() ) );
-
- DALI_TEST_CHECK( Color::RED == style2.GetShadowColor() );
- DALI_TEST_CHECK( Color::GREEN == style2.GetGlowColor() );
- DALI_TEST_CHECK( Color::BLUE == style2.GetOutlineColor() );
-
- DALI_TEST_CHECK( Vector2( 0.5f, 0.5f ) == style2.GetShadowOffset() );
- DALI_TEST_CHECK( Vector2( 0.9f, 0.9f ) == style2.GetOutlineThickness() );
- DALI_TEST_CHECK( fabs( 0.75f - style2.GetGlowIntensity() ) < GetRangedEpsilon( 0.75f, style2.GetGlowIntensity() ) );
- DALI_TEST_CHECK( fabs( 0.8f - style2.GetSmoothEdge() ) < GetRangedEpsilon( 0.8f, style2.GetSmoothEdge() ) );
+ DALI_TEST_CHECK( !style1.IsFontNameDefault() );
+ DALI_TEST_CHECK( !style1.IsFontStyleDefault() );
+ DALI_TEST_CHECK( !style1.IsFontSizeDefault() );
+ DALI_TEST_CHECK( !style1.IsTextColorDefault() );
+ DALI_TEST_CHECK( !style1.IsFontWeightDefault() );
+ DALI_TEST_CHECK( !style1.IsSmoothEdgeDefault() );
+ DALI_TEST_CHECK( !style1.IsItalicsDefault() );
+ DALI_TEST_CHECK( !style1.IsUnderlineDefault() );
+ DALI_TEST_CHECK( !style1.IsShadowDefault() );
+ DALI_TEST_CHECK( !style1.IsGlowDefault() );
+ DALI_TEST_CHECK( !style1.IsOutlineDefault() );
+ DALI_TEST_CHECK( !style1.IsGradientDefault() );
+
+ DALI_TEST_EQUALS( style1.GetFontName(), FONT_FAMILY, TEST_LOCATION );
+ DALI_TEST_EQUALS( style1.GetFontStyle(), FONT_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style1.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style1.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( style1.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style1.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style1.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( style1.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style1.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style1.GetUnderlineThickness(), UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style1.GetUnderlinePosition(), UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style1.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style1.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style1.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style1.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style1.GetGlowColor(), GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style1.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style1.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style1.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style1.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style1.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style1.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style1.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style1.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsFontNameDefault() );
+ DALI_TEST_CHECK( !style2.IsFontStyleDefault() );
+ DALI_TEST_CHECK( !style2.IsFontSizeDefault() );
+ DALI_TEST_CHECK( !style2.IsTextColorDefault() );
+ DALI_TEST_CHECK( !style2.IsFontWeightDefault() );
+ DALI_TEST_CHECK( !style2.IsSmoothEdgeDefault() );
+ DALI_TEST_CHECK( !style2.IsItalicsDefault() );
+ DALI_TEST_CHECK( !style2.IsUnderlineDefault() );
+ DALI_TEST_CHECK( !style2.IsShadowDefault() );
+ DALI_TEST_CHECK( !style2.IsGlowDefault() );
+ DALI_TEST_CHECK( !style2.IsOutlineDefault() );
+ DALI_TEST_CHECK( !style2.IsGradientDefault() );
+
+ DALI_TEST_EQUALS( style2.GetFontName(), FONT_FAMILY, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetFontStyle(), FONT_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( style2.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( style2.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style2.GetUnderlineThickness(), UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetUnderlinePosition(), UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style2.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style2.GetGlowColor(), GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style2.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style2.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextStyleAssignmentOperator(void)
+{
+ tet_infoline(" UtcDaliTextStyleAssignmentOperator ");
+
+ TestApplication application;
+
+ TextStyle style1;
+ TextStyle style2;
+
+ style1.SetFontName( FONT_FAMILY );
+ style1.SetFontStyle( FONT_STYLE );
+ style1.SetFontPointSize( FONT_POINT_SIZE );
+ style1.SetTextColor( TEXT_COLOR );
+
+ style1.SetWeight( TEXT_WEIGHT );
+ style1.SetSmoothEdge( SMOOTH_EDGE );
+
+ style1.SetItalics( ITALICS, ITALICS_ANGLE );
+
+ style1.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION );
+
+ style1.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
+ style1.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
+ style1.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
+ style1.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+
+ // Test the copy of all parameters.
+ style2 = style1;
+
+ DALI_TEST_CHECK( !style2.IsFontNameDefault() );
+ DALI_TEST_CHECK( !style2.IsFontStyleDefault() );
+ DALI_TEST_CHECK( !style2.IsFontSizeDefault() );
+ DALI_TEST_CHECK( !style2.IsTextColorDefault() );
+ DALI_TEST_CHECK( !style2.IsFontWeightDefault() );
+ DALI_TEST_CHECK( !style2.IsSmoothEdgeDefault() );
+ DALI_TEST_CHECK( !style2.IsItalicsDefault() );
+ DALI_TEST_CHECK( !style2.IsUnderlineDefault() );
+ DALI_TEST_CHECK( !style2.IsShadowDefault() );
+ DALI_TEST_CHECK( !style2.IsGlowDefault() );
+ DALI_TEST_CHECK( !style2.IsOutlineDefault() );
+ DALI_TEST_CHECK( !style2.IsGradientDefault() );
+
+ DALI_TEST_EQUALS( style2.GetFontName(), FONT_FAMILY, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetFontStyle(), FONT_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( style2.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( style2.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style2.GetUnderlineThickness(), UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetUnderlinePosition(), UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style2.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style2.GetGlowColor(), GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style2.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION );
+
+ DALI_TEST_CHECK( style2.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style2.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION );
+
+ // Test assignment of the same object.
+ const TextStyle& style( style2 );
+
+ style2 = style;
+
+ // Test the assignment of the defaults.
+
+ // Test copy all defaults.
+
+ TextStyle defaultStyle;
+ style2 = defaultStyle;
+
+ DALI_TEST_CHECK( style2.IsFontNameDefault() );
+ DALI_TEST_CHECK( style2.IsFontStyleDefault() );
+ DALI_TEST_CHECK( style2.IsFontSizeDefault() );
+ DALI_TEST_CHECK( style2.IsTextColorDefault() );
+ DALI_TEST_CHECK( style2.IsFontWeightDefault() );
+ DALI_TEST_CHECK( style2.IsSmoothEdgeDefault() );
+ DALI_TEST_CHECK( style2.IsItalicsDefault() );
+ DALI_TEST_CHECK( style2.IsUnderlineDefault() );
+ DALI_TEST_CHECK( style2.IsShadowDefault() );
+ DALI_TEST_CHECK( style2.IsGlowDefault() );
+ DALI_TEST_CHECK( style2.IsOutlineDefault() );
+ DALI_TEST_CHECK( style2.IsGradientDefault() );
+
+ DALI_TEST_EQUALS( style2.GetFontName(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetFontStyle(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( style2.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( style2.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style2.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style2.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style2.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style2.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style2.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
+
+ // Test copy some defaults.
+
+ // set style2 with non defaults.
+ style2 = style1;
+
+ // create a style with all defaults excepd the font name.
+ defaultStyle.SetFontName( FONT_FAMILY );
+
+ // should reset all to defaults except the font name.
+ style2 = defaultStyle;
+
+ DALI_TEST_CHECK( !style2.IsFontNameDefault() );
+ DALI_TEST_CHECK( style2.IsFontStyleDefault() );
+ DALI_TEST_CHECK( style2.IsFontSizeDefault() );
+ DALI_TEST_CHECK( style2.IsTextColorDefault() );
+ DALI_TEST_CHECK( style2.IsFontWeightDefault() );
+ DALI_TEST_CHECK( style2.IsSmoothEdgeDefault() );
+ DALI_TEST_CHECK( style2.IsItalicsDefault() );
+ DALI_TEST_CHECK( style2.IsUnderlineDefault() );
+ DALI_TEST_CHECK( style2.IsShadowDefault() );
+ DALI_TEST_CHECK( style2.IsGlowDefault() );
+ DALI_TEST_CHECK( style2.IsOutlineDefault() );
+ DALI_TEST_CHECK( style2.IsGradientDefault() );
+
+ DALI_TEST_EQUALS( style2.GetFontName(), FONT_FAMILY, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetFontStyle(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( style2.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( style2.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style2.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style2.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style2.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style2.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style2.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
+
+ // reset the text-style to default.
+ defaultStyle = TextStyle();
+
+ // test now the default font name.
+ defaultStyle.SetFontStyle( FONT_STYLE );
+
+ style2 = defaultStyle;
+
+ DALI_TEST_CHECK( style2.IsFontNameDefault() );
+ DALI_TEST_CHECK( !style2.IsFontStyleDefault() );
+ DALI_TEST_CHECK( style2.IsFontSizeDefault() );
+ DALI_TEST_CHECK( style2.IsTextColorDefault() );
+ DALI_TEST_CHECK( style2.IsFontWeightDefault() );
+ DALI_TEST_CHECK( style2.IsSmoothEdgeDefault() );
+ DALI_TEST_CHECK( style2.IsItalicsDefault() );
+ DALI_TEST_CHECK( style2.IsUnderlineDefault() );
+ DALI_TEST_CHECK( style2.IsShadowDefault() );
+ DALI_TEST_CHECK( style2.IsGlowDefault() );
+ DALI_TEST_CHECK( style2.IsOutlineDefault() );
+ DALI_TEST_CHECK( style2.IsGradientDefault() );
+
+ DALI_TEST_EQUALS( style2.GetFontName(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetFontStyle(), FONT_STYLE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( style2.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( style2.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style2.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style2.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style2.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style2.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
+
+ DALI_TEST_CHECK( !style2.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style2.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
+
END_TEST;
}
TextStyle style1;
TextStyle style2;
- const std::string fontName( "Arial" );
+ // Compares equality and inequality operators
+
+ // Compare two defaults.
+
+ DALI_TEST_CHECK( style1 == style2 );
+ DALI_TEST_CHECK( !( style1 != style2 ) );
+
+ // Compare with defaults.
+
+ style1.SetFontName( FONT_FAMILY );
+
+ DALI_TEST_CHECK( !( style1 == style2 ) );
+ DALI_TEST_CHECK( style1 != style2 );
+
+ style1 = TextStyle();
+ style2.SetFontName( FONT_FAMILY );
- style1.SetFontName( fontName );
+ DALI_TEST_CHECK( !( style1 == style2 ) );
DALI_TEST_CHECK( style1 != style2 );
- style2.SetFontName( fontName );
+ // Compare non defaults.
+
+ // Compare different flags
+
+ style1.SetFontName( FONT_FAMILY );
+ style2.SetFontStyle( FONT_STYLE );
+ style1.SetFontPointSize( FONT_POINT_SIZE );
+ style2.SetTextColor( TEXT_COLOR );
+
+ style1.SetWeight( TEXT_WEIGHT );
+ style2.SetSmoothEdge( SMOOTH_EDGE );
+
+ style1.SetItalics( ITALICS, ITALICS_ANGLE );
+
+ style2.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION );
+
+ style1.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
+ style2.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
+ style1.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
+ style2.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+
+ DALI_TEST_CHECK( !( style1 == style2 ) );
+ DALI_TEST_CHECK( style1 != style2 );
+
+ // Compare same styles
+ style1 = style2;
+
DALI_TEST_CHECK( style1 == style2 );
+ DALI_TEST_CHECK( !( style1 != style2 ) );
+
+ // Compare same flags but different values
+ style1.SetTextColor( Color::GREEN );
+
+ DALI_TEST_CHECK( !( style1 == style2 ) );
+ DALI_TEST_CHECK( style1 != style2 );
+
END_TEST;
}
// Set a style different than default.
TextStyle style2;
- style2.SetFontName( "Arial" );
- style2.SetFontStyle( "Bold" );
- style2.SetFontPointSize( PointSize( 24.f ) );
- style2.SetWeight( TextStyle::BOLD );
- style2.SetTextColor( Color::RED );
- style2.SetItalics( true );
- style2.SetUnderline( true );
- style2.SetItalicsAngle( Degree( 15.f ) );
- style2.SetUnderlineThickness( 3.5f );
- style2.SetUnderlinePosition( 12.f );
- style2.SetShadow( true, Color::GREEN, Vector2( 0.5f, 0.5f ), 0.5f );
- style2.SetGlow( true, Color::BLUE, 0.5f );
- style2.SetSmoothEdge( 0.5f );
- style2.SetOutline( true, Color::WHITE, Vector2( 0.05f, 0.5f ) );
+ style2.SetFontName( FONT_FAMILY );
+ style2.SetFontStyle( FONT_STYLE );
+ style2.SetFontPointSize( FONT_POINT_SIZE );
+ style2.SetTextColor( TEXT_COLOR );
+
+ style2.SetWeight( TEXT_WEIGHT );
+ style2.SetSmoothEdge( SMOOTH_EDGE );
+
+ style2.SetItalics( ITALICS, ITALICS_ANGLE );
+ style2.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION );
+ style2.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
+ style2.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
+ style2.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
+ style2.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+
+ // Test not to copy the same object. To increase coverage.
+
+ const TextStyle& same( style2 );
+
+ style2.Copy( same );
+
+ DALI_TEST_CHECK( same == style2 );
// Test mask.
DALI_TEST_CHECK( style == style2 );
+ // Copy the default
+ TextStyle defaultStyle;
+
+ style.Copy( defaultStyle );
+
// Test FONT
style = TextStyle();
style.Copy( style2, TextStyle::FONT );
- DALI_TEST_CHECK( style.GetFontName() != "" );
+ DALI_TEST_EQUALS( style.GetFontName(), FONT_FAMILY, TEST_LOCATION );
+
+ style.Copy( defaultStyle, TextStyle::FONT );
+
+ DALI_TEST_EQUALS( style.GetFontName(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION );
// Test STYLE
style = TextStyle();
style.Copy( style2, TextStyle::STYLE );
- DALI_TEST_CHECK( style.GetFontStyle() != "" );
+ DALI_TEST_EQUALS( style.GetFontStyle(), FONT_STYLE, TEST_LOCATION );
+
+ style.Copy( defaultStyle, TextStyle::STYLE );
+
+ DALI_TEST_EQUALS( style.GetFontStyle(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION );
// Test SIZE
style = TextStyle();
style.Copy( style2, TextStyle::SIZE );
- DALI_TEST_CHECK( style.GetFontPointSize() > 0.f );
+ DALI_TEST_EQUALS( style.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION );
+
+ style.Copy( defaultStyle, TextStyle::SIZE );
+
+ DALI_TEST_EQUALS( style.GetFontPointSize(), PointSize( 0.f ), TEST_LOCATION );
+
+ // Test COLOR
+ style = TextStyle();
+
+ style.Copy( style2, TextStyle::COLOR );
+
+ DALI_TEST_EQUALS( style.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
+
+ style.Copy( defaultStyle, TextStyle::COLOR );
+
+ DALI_TEST_EQUALS( style.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
// Test WEIGHT
style = TextStyle();
style.Copy( style2, TextStyle::WEIGHT );
- DALI_TEST_CHECK( style.GetWeight() != TextStyle::REGULAR );
- DALI_TEST_CHECK( fabsf( style.GetSmoothEdge() - TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD ) > Math::MACHINE_EPSILON_1000 );
+ DALI_TEST_EQUALS( style.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
- // Test COLOR
+ style.Copy( defaultStyle, TextStyle::WEIGHT );
+
+ DALI_TEST_EQUALS( style.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
+
+ // Test SMOOTH
style = TextStyle();
- style.Copy( style2, TextStyle::COLOR );
+ style.Copy( style2, TextStyle::SMOOTH );
+
+ DALI_TEST_EQUALS( style.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( style.GetTextColor() != TextStyle::DEFAULT_TEXT_COLOR );
+ style.Copy( defaultStyle, TextStyle::SMOOTH );
+
+ DALI_TEST_EQUALS( style.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
// Test ITALICS
style = TextStyle();
style.Copy( style2, TextStyle::ITALICS );
- DALI_TEST_CHECK( style.GetItalics() );
- DALI_TEST_CHECK( Degree( 15.f ) == style.GetItalicsAngle() );
+ DALI_TEST_CHECK( style.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( style.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
+
+ style.Copy( defaultStyle, TextStyle::ITALICS );
+
+ DALI_TEST_CHECK( !style.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( style.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
// Test UNDERLINE
style = TextStyle();
style.Copy( style2, TextStyle::UNDERLINE );
- DALI_TEST_CHECK( style.GetUnderline() );
- DALI_TEST_CHECK( fabs( 3.5f - style.GetUnderlineThickness() ) < GetRangedEpsilon( 3.5f, style.GetUnderlineThickness() ) );
- DALI_TEST_CHECK( fabs( 12.f - style.GetUnderlinePosition() ) < GetRangedEpsilon( 12.f, style.GetUnderlinePosition() ) );
+ DALI_TEST_CHECK( style.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style.GetUnderlineThickness(), UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetUnderlinePosition(), UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ style.Copy( defaultStyle, TextStyle::UNDERLINE );
+
+ DALI_TEST_CHECK( !style.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
// Test SHADOW
style = TextStyle();
style.Copy( style2, TextStyle::SHADOW );
- DALI_TEST_CHECK( style.GetShadow() );
- DALI_TEST_CHECK( style.GetShadowColor() != TextStyle::DEFAULT_SHADOW_COLOR );
- DALI_TEST_CHECK( style.GetShadowOffset() != TextStyle::DEFAULT_SHADOW_OFFSET );
- DALI_TEST_CHECK( fabsf( style.GetShadowSize() - TextStyle::DEFAULT_SHADOW_SIZE ) > Math::MACHINE_EPSILON_1000 );
+ DALI_TEST_CHECK( style.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetShadowSize(), SHADOW_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ style.Copy( defaultStyle, TextStyle::SHADOW );
+
+ DALI_TEST_CHECK( !style.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetShadowSize(), TextStyle::DEFAULT_SHADOW_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
// Test GLOW
style = TextStyle();
style.Copy( style2, TextStyle::GLOW );
- DALI_TEST_CHECK( style.GetGlow() );
- DALI_TEST_CHECK( style.GetGlowColor() != TextStyle::DEFAULT_GLOW_COLOR );
- DALI_TEST_CHECK( fabsf( style.GetGlowIntensity() - TextStyle::DEFAULT_GLOW_INTENSITY ) > Math::MACHINE_EPSILON_1000 );
+ DALI_TEST_CHECK( style.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style.GetGlowColor(), GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ style.Copy( defaultStyle, TextStyle::GLOW );
+
+ DALI_TEST_CHECK( !style.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
// Test OUTLINE
style = TextStyle();
style.Copy( style2, TextStyle::OUTLINE );
- DALI_TEST_CHECK( style.GetOutline() );
- DALI_TEST_CHECK( style.GetOutlineColor() != TextStyle::DEFAULT_OUTLINE_COLOR );
- DALI_TEST_CHECK( style.GetOutlineThickness() != TextStyle::DEFAULT_OUTLINE_THICKNESS );
+ DALI_TEST_CHECK( style.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION );
+
+ style.Copy( defaultStyle, TextStyle::OUTLINE );
+
+ DALI_TEST_CHECK( !style.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
+
+ // Test GRADIENT
+ style = TextStyle();
+
+ style.Copy( style2, TextStyle::GRADIENT );
+
+ DALI_TEST_CHECK( style.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION );
+
+ style.Copy( defaultStyle, TextStyle::GRADIENT );
+
+ DALI_TEST_CHECK( !style.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
+
+ // Copy to a default.
+ defaultStyle.Copy( style2 );
+ DALI_TEST_CHECK( defaultStyle == style2);
+
+ // Copy from default.
+ defaultStyle = TextStyle();
+
+ defaultStyle.SetItalics( ITALICS, ITALICS_ANGLE );
+ defaultStyle.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION );
+ defaultStyle.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
+ defaultStyle.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
+ defaultStyle.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
+ defaultStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+
+ // Copy the default values
+ style2.Copy( defaultStyle, static_cast<TextStyle::Mask>( TextStyle::FONT |
+ TextStyle::STYLE |
+ TextStyle::SIZE |
+ TextStyle::COLOR |
+ TextStyle::WEIGHT |
+ TextStyle::SMOOTH ) );
+
+ defaultStyle = TextStyle();
+
+ defaultStyle.SetFontName( FONT_FAMILY );
+ defaultStyle.SetFontStyle( FONT_STYLE );
+ defaultStyle.SetFontPointSize( FONT_POINT_SIZE );
+ defaultStyle.SetTextColor( TEXT_COLOR );
+ defaultStyle.SetWeight( TEXT_WEIGHT );
+ defaultStyle.SetSmoothEdge( SMOOTH_EDGE );
+
+ // Copy the default values
+ style2.Copy( defaultStyle, static_cast<TextStyle::Mask>( TextStyle::ITALICS |
+ TextStyle::UNDERLINE |
+ TextStyle::SHADOW |
+ TextStyle::GLOW |
+ TextStyle::OUTLINE |
+ TextStyle::GRADIENT ) );
+
+ defaultStyle = TextStyle();
+
+ DALI_TEST_CHECK( defaultStyle == style2 );
+
+ END_TEST;
+}
+
+int UtcDaliTextStyleReset(void)
+{
+ tet_infoline(" UtcDaliTextStyleReset ");
+
+ TestApplication application;
+
+ const TextStyle defaultStyle;
+
+ // Reset a default.
+ TextStyle style;
+
+ style.Reset();
+
+ DALI_TEST_CHECK( defaultStyle == style );
+
+ // Reset NONE
+ style.Reset( TextStyle::NONE );
+
+ DALI_TEST_CHECK( defaultStyle == style );
+
+ // Reset ALL
+ TextStyle style2;
+ style2.SetFontName( FONT_FAMILY );
+ style2.SetFontStyle( FONT_STYLE );
+ style2.SetFontPointSize( FONT_POINT_SIZE );
+ style2.SetTextColor( TEXT_COLOR );
+
+ style2.SetWeight( TEXT_WEIGHT );
+ style2.SetSmoothEdge( SMOOTH_EDGE );
+
+ style2.SetItalics( ITALICS, ITALICS_ANGLE );
+ style2.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION );
+ style2.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
+ style2.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
+ style2.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
+ style2.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+
+ style2.Reset( TextStyle::ALL );
+
+ DALI_TEST_CHECK( defaultStyle == style2 );
+
+ // Set all parameters
+ style2.SetFontName( FONT_FAMILY );
+ style2.SetFontStyle( FONT_STYLE );
+ style2.SetFontPointSize( FONT_POINT_SIZE );
+ style2.SetTextColor( TEXT_COLOR );
+
+ style2.SetWeight( TEXT_WEIGHT );
+ style2.SetSmoothEdge( SMOOTH_EDGE );
+
+ style2.SetItalics( ITALICS, ITALICS_ANGLE );
+ style2.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION );
+ style2.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
+ style2.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
+ style2.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
+ style2.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+
+ // Reset FONT
+ style2.Reset( TextStyle::FONT );
+
+ DALI_TEST_CHECK( style2.IsFontNameDefault() );
+ DALI_TEST_EQUALS( style2.GetFontName(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION );
+
+ // Reset STYLE
+ style2.Reset( TextStyle::STYLE );
+
+ DALI_TEST_CHECK( style2.IsFontStyleDefault() );
+ DALI_TEST_EQUALS( style2.GetFontStyle(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION );
+
+ // Reset SIZE
+ style2.Reset( TextStyle::SIZE );
+
+ DALI_TEST_CHECK( style2.IsFontSizeDefault() );
+ DALI_TEST_EQUALS( style2.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
+
+ // Reset COLOR
+ style2.Reset( TextStyle::COLOR );
+
+ DALI_TEST_CHECK( style2.IsTextColorDefault() );
+ DALI_TEST_EQUALS( style2.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
+
+ // Reset WEIGHT
+ style2.Reset( TextStyle::WEIGHT );
+
+ DALI_TEST_CHECK( style2.IsFontWeightDefault() );
+ DALI_TEST_EQUALS( style2.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
+
+ // Reset SMOOTH
+ style2.Reset( TextStyle::SMOOTH );
+
+ DALI_TEST_CHECK( style2.IsSmoothEdgeDefault() );
+ DALI_TEST_EQUALS( style2.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ // Reset ITALICS
+ style2.Reset( TextStyle::ITALICS );
+
+ DALI_TEST_CHECK( style2.IsItalicsDefault() );
+ DALI_TEST_CHECK( !style2.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( style2.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
+
+ // Reset UNDERLINE
+ style2.Reset( TextStyle::UNDERLINE );
+
+ DALI_TEST_CHECK( style2.IsUnderlineDefault() );
+ DALI_TEST_CHECK( !style2.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style2.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ // Reset SHADOW
+ style2.Reset( TextStyle::SHADOW );
+
+ DALI_TEST_CHECK( style2.IsShadowDefault() );
+ DALI_TEST_CHECK( !style2.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style2.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetShadowSize(), TextStyle::DEFAULT_SHADOW_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ // Reset GLOW
+ style2.Reset( TextStyle::GLOW );
+
+ DALI_TEST_CHECK( style2.IsGlowDefault() );
+ DALI_TEST_CHECK( !style2.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style2.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ // Reset OUTLINE
+ style2.Reset( TextStyle::OUTLINE );
+
+ DALI_TEST_CHECK( style2.IsOutlineDefault() );
+ DALI_TEST_CHECK( !style2.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style2.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
+
+ // Reset GRADIENT
+ style2.Reset( TextStyle::GRADIENT );
+
+ DALI_TEST_CHECK( style2.IsGradientDefault() );
+ DALI_TEST_CHECK( !style2.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style2.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style2.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
+
+
+ // Added to increase coverage.
+
+ {
+ // Reset the font name when there is another parameter of a different struct.
+ // Test when the struct storing the font name is in the last position of the vector and when is not.
+
+ TextStyle nameStyle;
+
+ nameStyle.SetFontName( FONT_FAMILY );
+ nameStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+ nameStyle.Reset( TextStyle::FONT );
+
+ DALI_TEST_EQUALS( nameStyle.GetFontName(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION );
+
+ nameStyle.SetFontName( FONT_FAMILY );
+ nameStyle.Reset( TextStyle::FONT );
+
+ DALI_TEST_EQUALS( nameStyle.GetFontName(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION );
+ }
+
+ {
+ // Reset the font style when there is another parameter of a different struct.
+ // Test when the struct storing the font style is in the last position of the vector and when is not.
+
+ TextStyle styleStyle;
+
+ styleStyle.SetFontStyle( FONT_STYLE );
+ styleStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+ styleStyle.Reset( TextStyle::STYLE );
+
+ DALI_TEST_EQUALS( styleStyle.GetFontStyle(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION );
+
+ styleStyle.SetFontStyle( FONT_STYLE );
+ styleStyle.Reset( TextStyle::STYLE );
+
+ DALI_TEST_EQUALS( styleStyle.GetFontStyle(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION );
+ }
+
+ {
+ // Reset the font size when there is another parameter of a different struct.
+ // Test when the struct storing the font size is in the last position of the vector and when is not.
+
+ TextStyle sizeStyle;
+
+ sizeStyle.SetFontPointSize( FONT_POINT_SIZE );
+ sizeStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+ sizeStyle.Reset( TextStyle::SIZE );
+
+ DALI_TEST_EQUALS( sizeStyle.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
+
+ sizeStyle.SetFontPointSize( FONT_POINT_SIZE );
+ sizeStyle.Reset( TextStyle::SIZE );
+
+ DALI_TEST_EQUALS( sizeStyle.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
+ }
+
+ {
+ // Reset the text color when there is another parameter of a different struct.
+ // Test when the struct storing the text color is in the last position of the vector and when is not.
+
+ TextStyle colorStyle;
+
+ colorStyle.SetTextColor( TEXT_COLOR );
+ colorStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+ colorStyle.Reset( TextStyle::COLOR );
+
+ DALI_TEST_EQUALS( colorStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
+
+ colorStyle.SetTextColor( TEXT_COLOR );
+ colorStyle.Reset( TextStyle::COLOR );
+
+ DALI_TEST_EQUALS( colorStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
+ }
+
+ {
+ // Reset the text weight when there is another parameter of a different struct.
+ // Test when the struct storing the text weight is in the last position of the vector and when is not.
+
+ TextStyle weightStyle;
+
+ weightStyle.SetWeight( TEXT_WEIGHT );
+ weightStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+ weightStyle.Reset( TextStyle::WEIGHT );
+
+ DALI_TEST_EQUALS( weightStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
+
+ weightStyle.SetWeight( TEXT_WEIGHT );
+ weightStyle.Reset( TextStyle::WEIGHT );
+
+ DALI_TEST_EQUALS( weightStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
+ }
+
+ {
+ // Reset the smooth edge when there is another parameter of a different struct.
+ // Test when the struct storing the smooth edge is in the last position of the vector and when is not.
+
+ TextStyle smoothStyle;
+
+ smoothStyle.SetSmoothEdge( SMOOTH_EDGE );
+ smoothStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+ smoothStyle.Reset( TextStyle::SMOOTH );
+
+ DALI_TEST_EQUALS( smoothStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ smoothStyle.SetSmoothEdge( SMOOTH_EDGE );
+ smoothStyle.Reset( TextStyle::SMOOTH );
+
+ DALI_TEST_EQUALS( smoothStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ }
+
+ {
+ // Reset the italics when there is another parameter of a different struct.
+ // Test when the struct storing the italics is in the last position of the vector and when is not.
+
+ TextStyle italicsStyle;
+
+ italicsStyle.SetItalics( ITALICS, ITALICS_ANGLE );
+ italicsStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+ italicsStyle.Reset( TextStyle::ITALICS );
+
+ DALI_TEST_EQUALS( italicsStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
+
+ italicsStyle.SetItalics( ITALICS, ITALICS_ANGLE );
+ italicsStyle.Reset( TextStyle::ITALICS );
+
+ DALI_TEST_EQUALS( italicsStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
+ }
+
+ {
+ // Reset the underline when there is another parameter of a different struct.
+ // Test when the struct storing the underline is in the last position of the vector and when is not.
+
+ TextStyle underlineStyle;
+
+ underlineStyle.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION );
+ underlineStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+ underlineStyle.Reset( TextStyle::UNDERLINE );
+
+ DALI_TEST_EQUALS( underlineStyle.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( underlineStyle.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ underlineStyle.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION );
+ underlineStyle.Reset( TextStyle::UNDERLINE );
+
+ DALI_TEST_EQUALS( underlineStyle.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( underlineStyle.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ }
+
+
+
+
+
+ {
+ // Reset the shadow when there is another parameter of a different struct.
+ // Test when the struct storing the shadow is in the last position of the vector and when is not.
+
+ TextStyle shadowStyle;
+
+ shadowStyle.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
+ shadowStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+ shadowStyle.Reset( TextStyle::SHADOW );
+
+ DALI_TEST_CHECK( shadowStyle.IsShadowDefault() );
+
+ shadowStyle.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
+ shadowStyle.Reset( TextStyle::SHADOW );
+
+ DALI_TEST_CHECK( shadowStyle.IsShadowDefault() );
+}
+
+ {
+ // Reset the glow when there is another parameter of a different struct.
+ // Test when the struct storing the glow is in the last position of the vector and when is not.
+
+ TextStyle glowStyle;
+
+ glowStyle.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
+ glowStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+ glowStyle.Reset( TextStyle::GLOW );
+
+ DALI_TEST_CHECK( glowStyle.IsGlowDefault() );
+
+ glowStyle.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
+ glowStyle.Reset( TextStyle::GLOW );
+
+ DALI_TEST_CHECK( glowStyle.IsGlowDefault() );
+ }
+
+ {
+ // Reset the outline when there is another parameter of a different struct.
+ // Test when the struct storing the outline is in the last position of the vector and when is not.
+
+ TextStyle outlineStyle;
+
+ outlineStyle.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
+ outlineStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+ outlineStyle.Reset( TextStyle::OUTLINE );
+
+ DALI_TEST_CHECK( outlineStyle.IsOutlineDefault() );
+
+ outlineStyle.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
+ outlineStyle.Reset( TextStyle::OUTLINE );
+
+ DALI_TEST_CHECK( outlineStyle.IsOutlineDefault() );
+ }
+
+ {
+ // Reset the gradient when there is another parameter of a different struct.
+ // Test when the struct storing the gradient is in the last position of the vector and when is not.
+
+ TextStyle gradientStyle;
+
+ gradientStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+ gradientStyle.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
+ gradientStyle.Reset( TextStyle::GRADIENT );
+
+ DALI_TEST_CHECK( gradientStyle.IsGradientDefault() );
+
+ gradientStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+ gradientStyle.Reset( TextStyle::GRADIENT );
+
+ DALI_TEST_CHECK( gradientStyle.IsGradientDefault() );
+ }
+
END_TEST;
}
TextStyle style;
- const std::string fontName( "Arial" );
- style.SetFontName( fontName );
+ style.SetFontName( FONT_FAMILY );
+
+ DALI_TEST_EQUALS( style.GetFontName(), FONT_FAMILY, TEST_LOCATION );
+
+ // Added to increase coverage
+ style.SetFontStyle( FONT_STYLE );
+ DALI_TEST_EQUALS( style.GetFontStyle(), FONT_STYLE, TEST_LOCATION );
- DALI_TEST_CHECK( fontName == style.GetFontName() );
END_TEST;
}
TextStyle style;
- const std::string fontStyle( "Book" );
- style.SetFontStyle( fontStyle );
+ style.SetFontStyle( FONT_STYLE );
+
+ DALI_TEST_EQUALS( style.GetFontStyle(), FONT_STYLE, TEST_LOCATION );
+
+ // Added to increase coverage
+ style.SetFontName( FONT_FAMILY );
+ DALI_TEST_EQUALS( style.GetFontName(), FONT_FAMILY, TEST_LOCATION );
- DALI_TEST_CHECK( fontStyle == style.GetFontStyle() );
END_TEST;
}
TextStyle style;
- style.SetFontPointSize( PointSize( 16.f ) );
+ style.SetFontPointSize( FONT_POINT_SIZE );
+
+ DALI_TEST_EQUALS( style.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION );
+
+ // Added to increase coverage
+ style.SetTextColor( TEXT_COLOR );
+ DALI_TEST_EQUALS( style.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
- DALI_TEST_CHECK( PointSize( 16.f ) == style.GetFontPointSize() );
END_TEST;
}
-int UtcDaliTextStyleSetGetWeight(void)
+int UtcDaliTextStyleSetGetTextColor(void)
{
- tet_infoline(" UtcDaliTextStyleSetGetWeight ");
+ tet_infoline(" UtcDaliTextStyleSetGetTextColor ");
TestApplication application;
TextStyle style;
- style.SetWeight( TextStyle::EXTRABLACK );
+ style.SetTextColor( TEXT_COLOR );
+
+ DALI_TEST_EQUALS( style.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
+
+ // Added to increase coverage
+ style.SetFontPointSize( FONT_POINT_SIZE );
+ DALI_TEST_EQUALS( style.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION );
- DALI_TEST_CHECK( TextStyle::EXTRABLACK == style.GetWeight() );
END_TEST;
}
-int UtcDaliTextStyleSetGetTextColor(void)
+int UtcDaliTextStyleSetGetWeight(void)
{
- tet_infoline(" UtcDaliTextStyleSetGetTextColor ");
+ tet_infoline(" UtcDaliTextStyleSetGetWeight ");
TestApplication application;
TextStyle style;
- style.SetTextColor( Color::GREEN );
+ style.SetWeight( TEXT_WEIGHT );
+
+ DALI_TEST_EQUALS( style.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
+
+ // Added to increase coverage
+ style.SetSmoothEdge( SMOOTH_EDGE );
+ DALI_TEST_EQUALS( style.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( Vector4( 0.f, 1.f, 0.f, 1.f ) == style.GetTextColor() );
END_TEST;
}
-int UtcDaliTextStyleSetGetItalics(void)
+int UtcDaliTextStyleSetGetSmoothEdge(void)
{
- tet_infoline(" UtcDaliTextStyleSetGetItalics ");
+ tet_infoline(" UtcDaliTextStyleSetGetGlow ");
TestApplication application;
TextStyle style;
- style.SetItalics( true );
+ style.SetSmoothEdge( SMOOTH_EDGE );
- DALI_TEST_CHECK( style.GetItalics() );
+ DALI_TEST_EQUALS( style.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- style.SetItalics( false );
+ // Added to increase coverage
+ style.SetWeight( TEXT_WEIGHT );
+ DALI_TEST_EQUALS( style.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
- DALI_TEST_CHECK( !style.GetItalics() );
END_TEST;
}
-int UtcDaliTextStyleSetGetItalicsAngle(void)
+int UtcDaliTextStyleSetGetItalics(void)
{
- tet_infoline(" UtcDaliTextStyleSetGetItalicsAngle ");
+ tet_infoline(" UtcDaliTextStyleSetGetItalics ");
TestApplication application;
TextStyle style;
- DALI_TEST_CHECK( TextStyle::DEFAULT_ITALICS_ANGLE == style.GetItalicsAngle() );
+ DALI_TEST_EQUALS( style.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
+
+ style.SetItalics( ITALICS, ITALICS_ANGLE );
+
+ DALI_TEST_CHECK( style.IsItalicsEnabled() );
+ DALI_TEST_EQUALS( style.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
+
+ style.SetItalics( !ITALICS, TextStyle::DEFAULT_ITALICS_ANGLE );
- style.SetItalicsAngle( Degree( 15.f ) );
+ DALI_TEST_CHECK( !style.IsItalicsEnabled() );
- DALI_TEST_CHECK( Degree( 15.f ) == style.GetItalicsAngle() );
END_TEST;
}
TextStyle style;
- style.SetUnderline( true );
+ style.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION );
- DALI_TEST_CHECK( style.GetUnderline() );
+ DALI_TEST_CHECK( style.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style.GetUnderlineThickness(), UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetUnderlinePosition(), UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- style.SetUnderline( false );
+ style.SetUnderline( !UNDERLINE, TextStyle::DEFAULT_UNDERLINE_THICKNESS, TextStyle::DEFAULT_UNDERLINE_POSITION );
- DALI_TEST_CHECK( !style.GetUnderline() );
+ DALI_TEST_CHECK( !style.IsUnderlineEnabled() );
+ DALI_TEST_EQUALS( style.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- style.SetUnderlineThickness( 3.5f );
- style.SetUnderlinePosition( 12.f );
-
- DALI_TEST_CHECK( fabs( 3.5f - style.GetUnderlineThickness() ) < GetRangedEpsilon( 3.5f, style.GetUnderlineThickness() ) );
- DALI_TEST_CHECK( fabs( 12.f - style.GetUnderlinePosition() ) < GetRangedEpsilon( 12.f, style.GetUnderlinePosition() ) );
END_TEST;
}
TextStyle style;
- DALI_TEST_CHECK( !style.GetShadow() );
-
- style.SetShadow( true );
+ DALI_TEST_CHECK( !style.IsShadowEnabled() );
- DALI_TEST_CHECK( style.GetShadow() );
+ style.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
- style.SetShadow( true, Color::RED, Vector2( 0.5f, 0.5f ) );
+ DALI_TEST_CHECK( style.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetShadowSize(), SHADOW_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( style.GetShadowColor(), Color::RED, TEST_LOCATION );
- DALI_TEST_CHECK( Vector2( 0.5f, 0.5f ) == style.GetShadowOffset() );
+ style.SetShadow( !SHADOW, TextStyle::DEFAULT_SHADOW_COLOR, TextStyle::DEFAULT_SHADOW_OFFSET, TextStyle::DEFAULT_SHADOW_SIZE );
+ DALI_TEST_CHECK( !style.IsShadowEnabled() );
+ DALI_TEST_EQUALS( style.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetShadowSize(), TextStyle::DEFAULT_SHADOW_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- style.SetShadow( false );
-
- DALI_TEST_CHECK( !style.GetShadow() );
END_TEST;
}
TextStyle style;
- DALI_TEST_CHECK( !style.GetGlow() );
-
- style.SetGlow( true );
+ DALI_TEST_CHECK( !style.IsGlowEnabled() );
- DALI_TEST_CHECK( style.GetGlow() );
+ style.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
- style.SetGlow( true, Color::RED, 0.75f );
+ DALI_TEST_CHECK( style.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style.GetGlowColor(), GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( style.GetGlowColor(), Color::RED, TEST_LOCATION );
- DALI_TEST_CHECK( fabs( 0.75f - style.GetGlowIntensity() ) < GetRangedEpsilon( 0.75f, style.GetGlowIntensity() ) );
+ style.SetGlow( !GLOW, TextStyle::DEFAULT_GLOW_COLOR, TextStyle::DEFAULT_GLOW_INTENSITY );
- style.SetGlow( false );
+ DALI_TEST_CHECK( !style.IsGlowEnabled() );
+ DALI_TEST_EQUALS( style.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( !style.GetGlow() );
END_TEST;
}
int UtcDaliTextStyleSetGetOutline(void)
{
- tet_infoline(" UtcDaliTextStyleSetGetGlow ");
+ tet_infoline(" UtcDaliTextStyleSetGetOutline ");
TestApplication application;
TextStyle style;
- DALI_TEST_CHECK( !style.GetOutline() );
-
- style.SetOutline( true );
+ DALI_TEST_CHECK( !style.IsOutlineEnabled() );
- DALI_TEST_CHECK( style.GetOutline() );
+ style.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
- style.SetOutline( true, Color::RED, Vector2( 0.9f, 0.9f ) );
+ DALI_TEST_CHECK( style.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION );
- DALI_TEST_EQUALS( style.GetOutlineColor(), Color::RED, TEST_LOCATION );
- DALI_TEST_CHECK( Vector2( 0.9f, 0.9f ) == style.GetOutlineThickness() );
+ style.SetOutline( !OUTLINE, TextStyle::DEFAULT_OUTLINE_COLOR, TextStyle::DEFAULT_OUTLINE_THICKNESS );
- style.SetOutline( false );
+ DALI_TEST_CHECK( !style.IsOutlineEnabled() );
+ DALI_TEST_EQUALS( style.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
- DALI_TEST_CHECK( !style.GetOutline() );
END_TEST;
}
-int UtcDaliTextStyleSetGetSmoothEdge(void)
+int UtcDaliTextStyleSetGetGradient(void)
{
- tet_infoline(" UtcDaliTextStyleSetGetGlow ");
+ tet_infoline(" UtcDaliTextStyleSetGetGradient ");
TestApplication application;
TextStyle style;
- style.SetSmoothEdge( 0.5f );
+ DALI_TEST_CHECK( !style.IsGradientEnabled() );
+
+ style.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
+
+ DALI_TEST_CHECK( style.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION );
+
+ style.SetGradient( !GRADIENT, TextStyle::DEFAULT_GRADIENT_COLOR, TextStyle::DEFAULT_GRADIENT_START_POINT, TextStyle::DEFAULT_GRADIENT_END_POINT );
+
+ DALI_TEST_CHECK( !style.IsGradientEnabled() );
+ DALI_TEST_EQUALS( style.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
+ DALI_TEST_EQUALS( style.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
- DALI_TEST_CHECK( fabs( 0.5f - style.GetSmoothEdge() ) < GetRangedEpsilon( 0.5f, style.GetSmoothEdge() ) );
END_TEST;
}
* @param[in] smoothEdge Specify the distance field value for the center of the text edge.
* 0 <= smoothEdge <= 1
*/
- void SetSmoothEdge(const float smoothEdge = TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD);
+ void SetSmoothEdge( float smoothEdge = TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD );
/**
* @brief Set text outlining.
* 0 <= smoothEdge[0] <= 1.
* 0 <= smoothEdge[1] <= 1.
*/
- void SetOutline(const bool enable, const Vector4& color, const Vector2& thickness = TextStyle::DEFAULT_OUTLINE_THICKNESS);
+ void SetOutline( bool enable, const Vector4& color, const Vector2& thickness = TextStyle::DEFAULT_OUTLINE_THICKNESS );
/**
* @brief Set text glow.
* The edge of the text is at the value set with SetSmoothEdge().
* SetSmoothEdge() The distance field value at which the glow becomes fully transparent.
*/
- void SetGlow(const bool enable, const Vector4& color, const float intensity = TextStyle::DEFAULT_GLOW_INTENSITY);
+ void SetGlow( bool enable, const Vector4& color, float intensity = TextStyle::DEFAULT_GLOW_INTENSITY );
/**
* @brief Set text shadow.
* @param[in] offset Offset in pixels. To avoid cropping of the drop shadow limit the offset to PointSize / 3.5
* @param[in] size Size of shadow in pixels. 0 means the shadow is the same size as the text.
*/
- void SetShadow(const bool enable, const Vector4& color, const Vector2& offset = TextStyle::DEFAULT_SHADOW_OFFSET,
- const float size = TextStyle::DEFAULT_SHADOW_SIZE );
+ void SetShadow( bool enable, const Vector4& color, const Vector2& offset = TextStyle::DEFAULT_SHADOW_OFFSET,
+ float size = TextStyle::DEFAULT_SHADOW_SIZE );
/**
* @brief Enable italics on the text actor, the text will be sheared by the given angle.
* @param[in] enabled True will enable italics, false disable it.
* @param[in] angle Italics angle in degrees.
*/
- void SetItalics( const bool enabled, const Degree& angle = TextStyle::DEFAULT_ITALICS_ANGLE );
+ void SetItalics( bool enabled, Degree angle = TextStyle::DEFAULT_ITALICS_ANGLE );
/**
* @brief Enable italics on the text actor, the text will be sheared by the given angle.
* @param[in] enabled True will enable italics, false disable it.
* @param[in] angle Italics angle in radians.
*/
- void SetItalics( const bool enabled, const Radian& angle );
+ void SetItalics( bool enabled, Radian angle );
/**
* @brief Get text italics for the actor.
*
* @returns Angle as a Radian.
*/
- const Radian& GetItalicsAngle() const;
+ Radian GetItalicsAngle() const;
/**
* @brief Set text underline.
*/
~Any();
-/**
+ /**
* @brief Pass Assert message
*
* @param assertMessage Assert message to report
*
* @return true if the container is empty, else false.
*/
- bool Empty()
+ bool Empty() const
{
return ( NULL == mContainer ) ? true : false;
}
namespace Dali DALI_IMPORT_API
{
+class TextStyleContainer;
+
/**
* @brief Encapsulates style properties for text, such as weight, italics, underline, shadow, etc.
*/
*/
enum Mask
{
- FONT = 1 << 0, ///< Sets the given font family.
- STYLE = 1 << 1, ///< Sets the given font style.
- SIZE = 1 << 2, ///< Sets the given font point size.
- WEIGHT = 1 << 3, ///< Sets the given font weight to bold.
- COLOR = 1 << 4, ///< Sets the given text color.
- ITALICS = 1 << 5, ///< Sets italics.
- UNDERLINE = 1 << 6, ///< Sets underline.
- SHADOW = 1 << 7, ///< Sets shadow.
- GLOW = 1 << 8, ///< Sets glow.
- OUTLINE = 1 << 9, ///< Sets outline
- ALL = -1 ///< Sets all given style parameters.
+ NONE = 0, ///< No parameter set.
+ FONT = 1 << 0, ///< Sets the given font family.
+ STYLE = 1 << 1, ///< Sets the given font style.
+ SIZE = 1 << 2, ///< Sets the given font point size.
+ COLOR = 1 << 3, ///< Sets the given text color.
+ WEIGHT = 1 << 4, ///< Sets the given font weight and smooth edge.
+ SMOOTH = 1 << 5, ///< Sets the smooth edge.
+ ITALICS = 1 << 6, ///< Sets italics.
+ UNDERLINE = 1 << 7, ///< Sets underline.
+ SHADOW = 1 << 8, ///< Sets shadow.
+ GLOW = 1 << 9, ///< Sets glow.
+ OUTLINE = 1 << 10, ///< Sets outline
+ GRADIENT = 1 << 11, ///< Sets gradient parameters.
+ ALL = -1 ///< Sets all given style parameters.
};
/**
};
public:
+ static const Vector4 DEFAULT_TEXT_COLOR; ///< Default color for the text (white)
+ static const Weight DEFAULT_FONT_WEIGHT; ///< Default weight for the text (regular)
+ static const float DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD; ///< Default distance field used for edge smooth. @see SetSmoothEdge()
static const Degree DEFAULT_ITALICS_ANGLE; ///< Default angle used for text italics. @see SetItalics()
static const float DEFAULT_UNDERLINE_THICKNESS; ///< Default underline's thickness.
static const float DEFAULT_UNDERLINE_POSITION; ///< Default underline's position.
- static const Vector4 DEFAULT_TEXT_COLOR; ///< Default color for the text (white)
static const Vector4 DEFAULT_SHADOW_COLOR; ///< Default color for the shadow (black)
static const Vector2 DEFAULT_SHADOW_OFFSET; ///< Default offset used for text shadow. @see SetShadow()
static const float DEFAULT_SHADOW_SIZE; ///< Default size of text shadow. @see SetShadow()
static const Vector4 DEFAULT_GLOW_COLOR; ///< Default color for the glow (white)
static const float DEFAULT_GLOW_INTENSITY; ///< Default intensity used for text glow. @see SetGlow()
- static const float DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD; ///< Default distance field used for edge smooth. @see SetSmoothEdge()
static const Vector4 DEFAULT_OUTLINE_COLOR; ///< Default color for the outline (white)
static const Vector2 DEFAULT_OUTLINE_THICKNESS; ///< Default thickness used for text outline. @see SetOutline()
static const Vector4 DEFAULT_GRADIENT_COLOR; ///< Default gradient color
* @brief Default constructor.
*
* The style created used a default font @see Dali::Font, color is white, and is neither underlined nor italics.
+ * Shadow, glow, outline and gradient are not enabled.
*/
TextStyle();
/**
+ * @brief Destructor.
+ */
+ ~TextStyle();
+
+ /**
* @brief Copy constructor.
*
* @param[in] textStyle The text style to be copied.
TextStyle( const TextStyle& textStyle );
/**
- * @brief Destructor.
- */
- virtual ~TextStyle();
-
- /**
* @brief Assignment operator.
*
* @param[in] textStyle The text style to be assigned.
/**
* @brief Copies from the given text style those parameters specified in the given mask.
*
- *
* @param[in] textStyle The given text style.
* @param[in] mask Specifies which text style parameters are going to be copied. By default all parateres are copied.
*/
- void Copy( const TextStyle& textStyle, const Mask mask = ALL );
+ void Copy( const TextStyle& textStyle, Mask mask = ALL );
+
+ /**
+ * @brief Resets to default the text style parameters specified in the mask.
+ *
+ * @param[in] mask Specifies which text style parameters are going to be reset. By default all parateres are reset.
+ */
+ void Reset( Mask mask = ALL );
/**
* @brief Retrieves the font name.
*
- * @return The font name.
+ * @return The font family name.
*/
const std::string& GetFontName() const;
/**
* @brief Sets the font name.
*
- * @param[in] fontName
+ * @param[in] fontName The font family name.
*/
void SetFontName( const std::string& fontName );
void SetFontPointSize( PointSize fontPointSize );
/**
- * @brief Retrieves the style weight.
+ * @brief Retrieves the text color.
*
- * @return The style weight.
+ * @return The text color.
*/
- Weight GetWeight() const;
+ const Vector4& GetTextColor() const;
/**
- * @brief Sets the style weight.
+ * @brief Sets the text color.
*
- * @param[in] weight The style weight
+ * @param[in] textColor The text color
*/
- void SetWeight( Weight weight );
+ void SetTextColor( const Vector4& textColor );
/**
- * @brief Retrieves the text color.
+ * @brief Retrieves the font weight.
*
- * @return The text color.
+ * @return The font weight.
*/
- const Vector4& GetTextColor() const;
+ Weight GetWeight() const;
/**
- * @brief Sets the text color.
+ * @brief Sets the font weight.
*
- * @param[in] textColor The text color
+ * @param[in] weight The font weight
*/
- void SetTextColor( const Vector4& textColor );
+ void SetWeight( Weight weight );
/**
- * @brief Whether the style italics option is enabled or not.
+ * @brief Retrieves the soft smooth edge.
*
- * @return \e true if italics is enabled.
+ * @return The soft smooth edge.
*/
- bool GetItalics() const;
+ float GetSmoothEdge() const;
/**
- * @brief Sets the italics option.
+ * @brief Set soft edge smoothing.
*
- * @param[in] italics The italics option.
+ * @param[in] smoothEdge Specify the distance field value for the center of the text edge.
+ * 0 <= smoothEdge <= 1
*/
- void SetItalics( bool italics );
+ void SetSmoothEdge( float smoothEdge = DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD );
+
+ /**
+ * @brief Whether the italics is enabled.
+ *
+ * @return \e true if italics is enabled, otherwise \e false.
+ */
+ bool IsItalicsEnabled() const;
/**
* @brief Retrieves the italics angle.
Degree GetItalicsAngle() const;
/**
- * @brief Sets the italics angle.
+ * @brief Enables or disables the italics.
+ *
+ * It sets the italics angle in degree. By default DEFAULT_ITALICS_ANGLE.
*
+ * @param[in] enable \e true enables the italics.
* @param[in] angle The italics angle in degree.
+ *
+ * @note uncoment the default parameter when the deprecated SetItalics() method is finally removed.
*/
- void SetItalicsAngle( Degree angle );
+ void SetItalics( bool enable, Degree angle /*= DEFAULT_ITALICS_ANGLE*/ );
/**
- * @brief Whether the style underline option is enabled or not.
- *
- * @return \e true if underline is enabled.
+ * @deprecated. Use IsItalicsEnabled()
*/
- bool GetUnderline() const;
+ bool GetItalics() const;
/**
- * @brief Sets the underline option.
- *
- * @param[in] underline The underline option.
+ * @deprecated Use SetItalicsEnabled( bool enable, Degree angle )
*/
- void SetUnderline( bool underline );
+ void SetItalics( bool italics );
/**
- * @brief Retrieves the underline thickness.
+ * @deprecated Use SetItalics( bool enable, Degree angle )
+ */
+ void SetItalicsAngle( Degree angle );
+
+ /**
+ * @brief Whether text underline is enabled.
*
- * @return The underline thickness.
+ * @return \e true if underline is enabled, otherwise \e false.
*/
- float GetUnderlineThickness() const;
+ bool IsUnderlineEnabled() const;
/**
- * @brief Sets the underline thickness.
+ * @brief Retrieves the underline thickness.
*
- * @param[in] thickness The underline thickness.
+ * @return The underline thickness.
*/
- void SetUnderlineThickness( float thickness );
+ float GetUnderlineThickness() const;
/**
* @brief Retrieves the underline position.
float GetUnderlinePosition() const;
/**
- * @brief Sets the underline position.
+ * @brief Enables or disables the text underline.
+ *
+ * It used DEFAULT_UNDERLINE_THICKNESS as default thickness and DEFAULT_UNDERLINE_POSITION as default position.
*
+ * @param[in] enable \e true enables the text underline.
+ * @param[in] thickness The underline thickness.
* @param[in] position The underline position.
+ *
+ * @note uncoment the default parameters when the deprecated SetUnderline() method is finally removed.
+ */
+ void SetUnderline( bool enable, float thickness /*= DEFAULT_UNDERLINE_THICKNESS*/, float position /*= DEFAULT_UNDERLINE_POSITION*/ );
+
+ /**
+ * @deprecated Use IsUnderlineEnabled()
+ */
+ bool GetUnderline() const;
+
+ /**
+ * @deprecated Use SetUnderline( bool enable, float thickness, float position )
+ */
+ void SetUnderline( bool underline );
+
+ /**
+ * @deprecated Use SetUnderline( bool enable, float thickness, float position )
+ */
+ void SetUnderlineThickness( float thickness );
+
+ /**
+ * @deprecated Use SetUnderline( bool enable, float thickness, float position )
*/
void SetUnderlinePosition( float position );
/**
- * @brief Whether the style shadow option is enabled or not.
+ * @brief Whether the text shadow is enabled.
*
- * @return \e true if shadow is enabled.
+ * @return \e true if shadow is enabled, otherwise \e false.
*/
- bool GetShadow() const;
+ bool IsShadowEnabled() const;
/**
* @brief Retrieves the shadow color.
/**
* @brief Retrieves the shadow offset
* @return The shadow offset.
- *
*/
const Vector2& GetShadowOffset() const;
/**
* @brief Retrieves the shadow size
* @return The shadow size.
- *
*/
float GetShadowSize() const;
/**
- * @brief Sets the shadow option.
+ * @brief Enables or disables the text shadow.
*
- * @param[in] shadow The shadow option.
+ * @param[in] enable \e true enables the text shadow.
* @param[in] shadowColor The color of the shadow
* @param[in] shadowOffset Offset in pixels.
* @param[in] shadowSize Size of shadow in pixels. 0 means the shadow is the same size as the text.
*/
- void SetShadow( bool shadow,
+ void SetShadow( bool enable,
const Vector4& shadowColor = DEFAULT_SHADOW_COLOR,
const Vector2& shadowOffset = DEFAULT_SHADOW_OFFSET,
- const float shadowSize = DEFAULT_SHADOW_SIZE );
+ float shadowSize = DEFAULT_SHADOW_SIZE );
/**
- * @brief Whether the glow option is enabled or not.
+ * @deprecated Use IsShadowEnabled()
+ */
+ bool GetShadow() const;
+
+ /**
+ * @brief Whether the text glow is enabled.
*
- * @return \e true if glow is enabled.
+ * @return \e true if glow is enabled, otherwise \e false.
*/
- bool GetGlow() const;
+ bool IsGlowEnabled() const;
/**
* @brief Retrieves the glow color.
float GetGlowIntensity() const;
/**
- * @brief Sets the glow option and color.
+ * @brief Enables or disables the text glow.
*
- * @param[in] glow The glow option.
+ * @param[in] enable \e true enables the text glow.
* @param[in] glowColor The color of the glow.
* @param[in] glowIntensity Determines the amount of glow around text.
* The edge of the text is at the value set with smoothEdge.
* SetSmoothEdge() The distance field value at which the glow becomes fully transparent.
*/
- void SetGlow( bool glow, const Vector4& glowColor = DEFAULT_GLOW_COLOR, float glowIntensity = DEFAULT_GLOW_INTENSITY );
+ void SetGlow( bool enable, const Vector4& glowColor = DEFAULT_GLOW_COLOR, float glowIntensity = DEFAULT_GLOW_INTENSITY );
/**
- * @brief Retrieves the soft smooth edge.
- *
- * @return The soft smooth edge.
- */
- float GetSmoothEdge() const;
-
- /**
- * @brief Set soft edge smoothing.
- *
- * @param[in] smoothEdge Specify the distance field value for the center of the text edge.
- * 0 <= smoothEdge <= 1
+ * @deprecated Use IsGlowEnabled()
*/
- void SetSmoothEdge( float smoothEdge = DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD );
+ bool GetGlow() const;
/**
- * @brief Whether the outline option is enabled or not.
+ * @brief Whether the text outline is enabled.
*
- * @return \e true if outline is enabled.
+ * @return \e true if outline is enabled, otherwise \e false.
*/
- bool GetOutline() const;
+ bool IsOutlineEnabled() const;
/**
* @brief Retrieves the outline color.
const Vector2& GetOutlineThickness() const;
/**
- * @brief Sets the outline option and color.
+ * @brief Enables or disables the text outline.
*
- * @param[in] outline The outline option.
+ * @param[in] enable \e true enables the text outline.
* @param[in] outlineColor The color of the outline.
* @param[in] outlineThickness Thickness of outline. The outline thickness is determined by two parameters.
* outlineThickness[0] Specifies the distance field value for the center of the outline.
* 0 <= smoothEdge[0] <= 1.
* 0 <= smoothEdge[1] <= 1.
*/
- void SetOutline( bool outline, const Vector4& outlineColor = DEFAULT_OUTLINE_COLOR, const Vector2& outlineThickness = DEFAULT_OUTLINE_THICKNESS );
+ void SetOutline( bool enable, const Vector4& outlineColor = DEFAULT_OUTLINE_COLOR, const Vector2& outlineThickness = DEFAULT_OUTLINE_THICKNESS );
+
+ /**
+ * @deprecated Use IsOutlineEnabled()
+ */
+ bool GetOutline() const;
+
+ /**
+ * @brief Whether the text gradient is enabled.
+ *
+ * @return \e true if gradient is enabled, otherwise \e false.
+ */
+ bool IsGradientEnabled() const;
+
+ /**
+ * @brief Retrieves the gradient color.
+ *
+ * @return The gradient color.
+ */
+ const Vector4& GetGradientColor() const;
+
+ /**
+ * @brief Retrieves the gradient start point.
+ *
+ * @return The gradient start point.
+ */
+ const Vector2& GetGradientStartPoint() const;
+
+ /**
+ * @brief Retrieves the gradient end point.
+ *
+ * @return The gradient end point.
+ */
+ const Vector2& GetGradientEndPoint() const;
+
+ /**
+ * @brief Enables or disables the text gradient.
+ *
+ * @param[in] enable \e true enables the text gradient.
+ * @param[in] color The gradient color.
+ * @param[in] startPoint The start point.
+ * @param[in] endPoint The end point.
+ */
+ void SetGradient( bool enable,
+ const Vector4& color = DEFAULT_GRADIENT_COLOR,
+ const Vector2& startPoint = DEFAULT_GRADIENT_START_POINT,
+ const Vector2& endPoint = DEFAULT_GRADIENT_END_POINT );
+
+ /**
+ * @brief Whether the font name is the default.
+ */
+ bool IsFontNameDefault() const;
+
+ /**
+ * @brief Whether the font style is the default.
+ */
+ bool IsFontStyleDefault() const;
+
+ /**
+ * @brief Whether the font size is the default.
+ */
+ bool IsFontSizeDefault() const;
+
+ /**
+ * @brief Whether the text color is the default.
+ */
+ bool IsTextColorDefault() const;
+
+ /**
+ * @brief Whether the font weight is the default.
+ */
+ bool IsFontWeightDefault() const;
+
+ /**
+ * @brief Whether the smooth edge is the default.
+ */
+ bool IsSmoothEdgeDefault() const;
+
+ /**
+ * @brief Whether the italic is the default.
+ */
+ bool IsItalicsDefault() const;
+
+ /**
+ * @brief Whether the underline is the default.
+ */
+ bool IsUnderlineDefault() const;
+
+ /**
+ * @brief Whether the shadow is the default.
+ */
+ bool IsShadowDefault() const;
+
+ /**
+ * @brief Whether the glow is the default.
+ */
+ bool IsGlowDefault() const;
+
+ /**
+ * @brief Whether the outline is the default.
+ */
+ bool IsOutlineDefault() const;
+
+ /**
+ * @brief Whether the gradient is the default.
+ */
+ bool IsGradientDefault() const;
private:
- struct Impl;
- Impl* mImpl; ///< Implementation pointer
/**
- * @brief Creates A TextStyle::Impl object when needed
+ * @brief Create a container, when the text-style needs any attributes
*/
- void CreateImplementationJustInTime();
+ void CreateContainerJustInTime();
+ TextStyleContainer* mContainer; // container for any needed text style structures
};
TextParameters::~TextParameters()
{
- // nothing to do
+ // destroy all containers.
+ if ( mFlags & OUTLINE_EXISTS )
+ {
+ OutlineAttributes* attrPtr = reinterpret_cast<OutlineAttributes*>( *( mParameters.Begin() + ( mFlags & TEXT_PARAMETER_MASK ) ) );
+ delete attrPtr;
+ }
+ if ( mFlags & GLOW_EXISTS )
+ {
+ GlowAttributes* attrPtr = reinterpret_cast<GlowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) );
+ delete attrPtr;
+ }
+ if ( mFlags & DROP_SHADOW_EXISTS )
+ {
+ DropShadowAttributes* attrPtr = reinterpret_cast<DropShadowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) );
+ delete attrPtr;
+ }
+ if ( mFlags & GRADIENT_EXISTS )
+ {
+ GradientAttributes* attrPtr = reinterpret_cast<GradientAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) );
+ delete attrPtr;
+ }
}
void TextParameters::SetOutline( bool enable, const Vector4& color, const Vector2& thickness )
{
- if ( mFlags & OUTLINE_ENABLED )
+ if ( mFlags & OUTLINE_EXISTS )
{
- OutlineAttributes* attrPtr = AnyCast< OutlineAttributes >( &mParameters[ mFlags & TEXT_PARAMETER_MASK ] );
+ OutlineAttributes* attrPtr = reinterpret_cast<OutlineAttributes*>( *( mParameters.Begin() + ( mFlags & TEXT_PARAMETER_MASK ) ) );
attrPtr->mOutlineColor = color;
attrPtr->mOutlineThickness = thickness;
}
else
{
- OutlineAttributes attr;
- attr.mOutlineColor = color;
- attr.mOutlineThickness = thickness;
- mParameters.push_back( attr );
- mFlags |= ( ( mFlags & ~OUTLINE_INDEX ) | ( ( mParameters.size() - 1 ) & TEXT_PARAMETER_MASK ) | OUTLINE_ENABLED );
+ OutlineAttributes* attr = new OutlineAttributes();
+ attr->mOutlineColor = color;
+ attr->mOutlineThickness = thickness;
+ mFlags |= ( ( mFlags & ~OUTLINE_INDEX ) | ( mParameters.Size() & TEXT_PARAMETER_MASK ) | OUTLINE_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
}
-}
-void TextParameters::SetGlow( bool enable, const Vector4& color, const float intensity)
-{
- if ( mFlags & GLOW_ENABLED )
+ if( enable )
{
- GlowAttributes* attrPtr = AnyCast< GlowAttributes >( &mParameters[ ( mFlags >> GLOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
- attrPtr->mGlowColor = color;
- attrPtr->mGlowIntensity = intensity;
+ mFlags |= OUTLINE_ENABLED;
}
else
{
- GlowAttributes attr;
- attr.mGlowColor = color;
- attr.mGlowIntensity = intensity;
- mParameters.push_back( attr );
- mFlags |= ( ( mFlags & ~GLOW_INDEX ) | ( ( ( mParameters.size() - 1 ) & TEXT_PARAMETER_MASK ) << GLOW_INDEX_SHIFT ) | GLOW_ENABLED );
+ mFlags &= ~OUTLINE_ENABLED;
}
}
-void TextParameters::SetShadow( bool enable, const Vector4& color, const Vector2& offset, const float size )
+void TextParameters::SetGlow( bool enable, const Vector4& color, float intensity )
{
- if ( mFlags & DROP_SHADOW_ENABLED )
+ if ( mFlags & GLOW_EXISTS )
{
- DropShadowAttributes* attrPtr = AnyCast< DropShadowAttributes >( &mParameters[ ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
- attrPtr->mDropShadowColor = color;
- attrPtr->mDropShadowOffset = offset;
- attrPtr->mDropShadowSize = size;
+ GlowAttributes* attrPtr = reinterpret_cast<GlowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) );
+ attrPtr->mGlowColor = color;
+ attrPtr->mGlowIntensity = intensity;
}
else
{
- DropShadowAttributes attr;
- attr.mDropShadowColor = color;
- attr.mDropShadowOffset = offset;
- attr.mDropShadowSize = size;
- mParameters.push_back( attr );
- mFlags |= ( ( mFlags & ~DROP_SHADOW_INDEX ) | ( ( ( mParameters.size() - 1 ) & TEXT_PARAMETER_MASK ) << DROP_SHADOW_INDEX_SHIFT ) | DROP_SHADOW_ENABLED );
+ GlowAttributes* attr = new GlowAttributes();
+ attr->mGlowColor = color;
+ attr->mGlowIntensity = intensity;
+ mFlags |= ( ( mFlags & ~GLOW_INDEX ) | ( ( mParameters.Size() & TEXT_PARAMETER_MASK ) << GLOW_INDEX_SHIFT ) | GLOW_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
}
-}
-void TextParameters::SetGradient( const Vector4& color, const Vector2& start, const Vector2& end )
-{
- if ( mFlags & GRADIENT_EXISTS )
+ if( enable )
{
- GradientAttributes* attrPtr = AnyCast< GradientAttributes >( &mParameters[ ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
- attrPtr->mGradientColor = color;
- attrPtr->mGradientStartPoint = start;
- attrPtr->mGradientEndPoint = end;
+ mFlags |= GLOW_ENABLED;
}
else
{
- GradientAttributes attr;
- attr.mGradientColor = color;
- attr.mGradientStartPoint = start;
- attr.mGradientEndPoint = end;
- mParameters.push_back( attr );
- mFlags |= ( ( mFlags & ~GRADIENT_INDEX ) | ( ( ( mParameters.size() - 1 ) & TEXT_PARAMETER_MASK ) << GRADIENT_INDEX_SHIFT ) | GRADIENT_EXISTS );
+ mFlags &= ~GLOW_ENABLED;
}
+}
- if ( end != start )
+void TextParameters::SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size )
+{
+ if ( mFlags & DROP_SHADOW_EXISTS )
{
- mFlags |= GRADIENT_ENABLED;
+ DropShadowAttributes* attrPtr = reinterpret_cast<DropShadowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) );
+ attrPtr->mDropShadowColor = color;
+ attrPtr->mDropShadowOffset = offset;
+ attrPtr->mDropShadowSize = size;
}
else
{
- mFlags &=~GRADIENT_ENABLED;
+ DropShadowAttributes* attr = new DropShadowAttributes();
+ attr->mDropShadowColor = color;
+ attr->mDropShadowOffset = offset;
+ attr->mDropShadowSize = size;
+ mFlags |= ( ( mFlags & ~DROP_SHADOW_INDEX ) | ( ( mParameters.Size() & TEXT_PARAMETER_MASK ) << DROP_SHADOW_INDEX_SHIFT ) | DROP_SHADOW_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
}
-}
-void TextParameters::SetGradientColor( const Vector4& color )
-{
- if ( mFlags & GRADIENT_EXISTS )
+ if( enable )
{
- GradientAttributes* attrPtr = AnyCast< GradientAttributes >( &mParameters[ ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
- attrPtr->mGradientColor = color;
+ mFlags |= DROP_SHADOW_ENABLED;
}
else
{
- GradientAttributes attr;
- attr.mGradientColor = color;
- attr.mGradientStartPoint = TextStyle::DEFAULT_GRADIENT_START_POINT;
- attr.mGradientEndPoint = TextStyle::DEFAULT_GRADIENT_END_POINT;
- mParameters.push_back( attr );
- mFlags |= ( ( mFlags & ~GRADIENT_INDEX ) | ( ( ( mParameters.size() - 1 ) & TEXT_PARAMETER_MASK ) << GRADIENT_INDEX_SHIFT ) | GRADIENT_EXISTS );
+ mFlags &= ~DROP_SHADOW_ENABLED;
}
}
-void TextParameters::SetGradientStartPoint( const Vector2& start )
+void TextParameters::SetGradient( const Vector4& color, const Vector2& start, const Vector2& end )
{
if ( mFlags & GRADIENT_EXISTS )
{
- GradientAttributes* attrPtr = AnyCast< GradientAttributes >( &mParameters[ ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+ GradientAttributes* attrPtr = reinterpret_cast<GradientAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) );
+ attrPtr->mGradientColor = color;
attrPtr->mGradientStartPoint = start;
+ attrPtr->mGradientEndPoint = end;
}
else
{
- GradientAttributes attr;
- attr.mGradientStartPoint = start;
- attr.mGradientEndPoint = TextStyle::DEFAULT_GRADIENT_END_POINT;
- attr.mGradientColor = TextStyle::DEFAULT_GRADIENT_COLOR;
- mParameters.push_back( attr );
- mFlags |= ( ( mFlags & ~GRADIENT_INDEX ) | ( ( ( mParameters.size() - 1 ) & TEXT_PARAMETER_MASK ) << GRADIENT_INDEX_SHIFT ) | GRADIENT_EXISTS );
+ GradientAttributes* attr = new GradientAttributes();
+ attr->mGradientColor = color;
+ attr->mGradientStartPoint = start;
+ attr->mGradientEndPoint = end;
+ mFlags |= ( ( mFlags & ~GRADIENT_INDEX ) | ( ( mParameters.Size() & TEXT_PARAMETER_MASK ) << GRADIENT_INDEX_SHIFT ) | GRADIENT_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
}
-}
-void TextParameters::SetGradientEndPoint( const Vector2& end )
-{
- if ( mFlags & GRADIENT_EXISTS )
+ if ( end != start )
{
- GradientAttributes* attrPtr = AnyCast< GradientAttributes >( &mParameters[ ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
- attrPtr->mGradientEndPoint = end;
+ mFlags |= GRADIENT_ENABLED;
}
else
{
- GradientAttributes attr;
- attr.mGradientEndPoint = end;
- attr.mGradientStartPoint = TextStyle::DEFAULT_GRADIENT_START_POINT;
- attr.mGradientColor = TextStyle::DEFAULT_GRADIENT_COLOR;
- mParameters.push_back( attr );
- mFlags |= ( ( mFlags & ~GRADIENT_INDEX ) | ( ( ( mParameters.size() - 1 ) & TEXT_PARAMETER_MASK ) << GRADIENT_INDEX_SHIFT ) | GRADIENT_EXISTS );
+ mFlags &=~GRADIENT_ENABLED;
}
}
-const Vector4& TextParameters::GetOutlineColor()
+const Vector4& TextParameters::GetOutlineColor() const
{
if ( mFlags & OUTLINE_ENABLED )
{
- const OutlineAttributes* attrPtr = AnyCast< OutlineAttributes >( &mParameters[ mFlags & TEXT_PARAMETER_MASK ] );
+ const OutlineAttributes* attrPtr = reinterpret_cast<OutlineAttributes*>( *( mParameters.Begin() + ( mFlags & TEXT_PARAMETER_MASK ) ) );
return attrPtr->mOutlineColor;
}
else
}
}
-const Vector2& TextParameters::GetOutlineThickness()
+const Vector2& TextParameters::GetOutlineThickness() const
{
- if ( mFlags & OUTLINE_ENABLED )
+ if ( mFlags & OUTLINE_EXISTS )
{
- const OutlineAttributes* attrPtr = AnyCast< OutlineAttributes >( &mParameters[ mFlags & TEXT_PARAMETER_MASK ] );
+ const OutlineAttributes* attrPtr = reinterpret_cast<OutlineAttributes*>( *( mParameters.Begin() + ( mFlags & TEXT_PARAMETER_MASK ) ) );
return attrPtr->mOutlineThickness;
}
else
}
}
-const Vector4& TextParameters::GetGlowColor()
+const Vector4& TextParameters::GetGlowColor() const
{
- if ( mFlags & GLOW_ENABLED )
+ if ( mFlags & GLOW_EXISTS )
{
- const GlowAttributes* attrPtr = AnyCast< GlowAttributes >( &mParameters[ ( mFlags >> GLOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+ const GlowAttributes* attrPtr = reinterpret_cast<GlowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) );
return attrPtr->mGlowColor;
}
else
}
}
-float TextParameters::GetGlowIntensity()
+float TextParameters::GetGlowIntensity() const
{
- if ( mFlags & GLOW_ENABLED )
+ if ( mFlags & GLOW_EXISTS )
{
- const GlowAttributes* attrPtr = AnyCast< GlowAttributes >( &mParameters[ ( mFlags >> GLOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+ const GlowAttributes* attrPtr = reinterpret_cast<GlowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) );
return attrPtr->mGlowIntensity;
}
else
}
}
-const Vector4& TextParameters::GetDropShadowColor()
+const Vector4& TextParameters::GetDropShadowColor() const
{
- if ( mFlags & DROP_SHADOW_ENABLED )
+ if ( mFlags & DROP_SHADOW_EXISTS )
{
- const DropShadowAttributes* attrPtr = AnyCast< DropShadowAttributes >( &mParameters[ ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+ const DropShadowAttributes* attrPtr = reinterpret_cast<DropShadowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) );
return attrPtr->mDropShadowColor;
}
else
}
}
-const Vector2& TextParameters::GetDropShadowOffset()
+const Vector2& TextParameters::GetDropShadowOffset() const
{
- if ( mFlags & DROP_SHADOW_ENABLED )
+ if ( mFlags & DROP_SHADOW_EXISTS )
{
- const DropShadowAttributes* attrPtr = AnyCast< DropShadowAttributes >( &mParameters[ ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+ const DropShadowAttributes* attrPtr = reinterpret_cast<DropShadowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) );
return attrPtr->mDropShadowOffset;
}
else
}
}
-float TextParameters::GetDropShadowSize()
+float TextParameters::GetDropShadowSize() const
{
- if ( mFlags & DROP_SHADOW_ENABLED )
+ if ( mFlags & DROP_SHADOW_EXISTS )
{
- const DropShadowAttributes* attrPtr = AnyCast< DropShadowAttributes >( &mParameters[ ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+ const DropShadowAttributes* attrPtr = reinterpret_cast<DropShadowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) );
return attrPtr->mDropShadowSize;
}
else
}
}
-const Vector4& TextParameters::GetGradientColor()
+const Vector4& TextParameters::GetGradientColor() const
{
if ( mFlags & GRADIENT_EXISTS )
{
- const GradientAttributes* attrPtr = AnyCast< GradientAttributes >( &mParameters[ ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+ const GradientAttributes* attrPtr = reinterpret_cast<GradientAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) );
return attrPtr->mGradientColor;
}
else
}
}
-const Vector2& TextParameters::GetGradientStartPoint()
+const Vector2& TextParameters::GetGradientStartPoint() const
{
if ( mFlags & GRADIENT_EXISTS )
{
- const GradientAttributes* attrPtr = AnyCast< GradientAttributes >( &mParameters[ ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+ const GradientAttributes* attrPtr = reinterpret_cast<GradientAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) );
return attrPtr->mGradientStartPoint;
}
else
}
}
-const Vector2& TextParameters::GetGradientEndPoint()
+const Vector2& TextParameters::GetGradientEndPoint() const
{
if ( mFlags & GRADIENT_EXISTS )
{
- const GradientAttributes* attrPtr = AnyCast< GradientAttributes >( &mParameters[ ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+ const GradientAttributes* attrPtr = reinterpret_cast<GradientAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) );
return attrPtr->mGradientEndPoint;
}
else
// INTERNAL HEADERS
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/math/vector4.h>
-
-#include <dali/public-api/object/any.h>
-#include <vector>
+#include <dali/public-api/common/dali-vector.h>
namespace Dali
{
// Number of bits for an index mask - increase if more attributes are added...
- const unsigned int TEXT_PARAMETER_BITS = 2;
+ const unsigned int TEXT_PARAMETER_BITS = 2u;
// Set mask for this number of bits
const unsigned int TEXT_PARAMETER_MASK = ~( -1 << TEXT_PARAMETER_BITS );
// Shift values for attribute indices
- const unsigned int OUTLINE_INDEX_SHIFT = 0;
+ const unsigned int OUTLINE_INDEX_SHIFT = 0u;
const unsigned int GLOW_INDEX_SHIFT = OUTLINE_INDEX_SHIFT + TEXT_PARAMETER_BITS;
const unsigned int DROP_SHADOW_INDEX_SHIFT = GLOW_INDEX_SHIFT + TEXT_PARAMETER_BITS;
const unsigned int GRADIENT_INDEX_SHIFT = DROP_SHADOW_INDEX_SHIFT + TEXT_PARAMETER_BITS;
const unsigned int TEXT_PARAMETER_FLAGS = GRADIENT_INDEX_SHIFT + TEXT_PARAMETER_BITS;
// Position in flags for attribute index
- const unsigned int OUTLINE_INDEX = 0;
- const unsigned int GLOW_INDEX = TEXT_PARAMETER_MASK << GLOW_INDEX_SHIFT;
- const unsigned int DROP_SHADOW_INDEX = TEXT_PARAMETER_MASK << DROP_SHADOW_INDEX_SHIFT;
- const unsigned int GRADIENT_INDEX = TEXT_PARAMETER_MASK << GRADIENT_INDEX_SHIFT;
+ const unsigned int OUTLINE_INDEX = 0u; // bits 0,1
+ const unsigned int GLOW_INDEX = TEXT_PARAMETER_MASK << GLOW_INDEX_SHIFT; // bits 2,3
+ const unsigned int DROP_SHADOW_INDEX = TEXT_PARAMETER_MASK << DROP_SHADOW_INDEX_SHIFT; // bits 4,5
+ const unsigned int GRADIENT_INDEX = TEXT_PARAMETER_MASK << GRADIENT_INDEX_SHIFT; // bits 6,7
// Flag positions for attributes ( gradient has two as parameters can be set independently )
- const unsigned int OUTLINE_ENABLED = 1 << TEXT_PARAMETER_FLAGS;
- const unsigned int GLOW_ENABLED = 1 << ( TEXT_PARAMETER_FLAGS + 1 );
- const unsigned int DROP_SHADOW_ENABLED = 1 << ( TEXT_PARAMETER_FLAGS + 2 );
- const unsigned int GRADIENT_EXISTS = 1 << ( TEXT_PARAMETER_FLAGS + 3 );
- const unsigned int GRADIENT_ENABLED = 1 << ( TEXT_PARAMETER_FLAGS + 4 );
+ const unsigned int OUTLINE_EXISTS = 1u << TEXT_PARAMETER_FLAGS; // bit 8
+ const unsigned int OUTLINE_ENABLED = 1u << ( TEXT_PARAMETER_FLAGS + 1u ); // bit 9
+ const unsigned int GLOW_EXISTS = 1u << ( TEXT_PARAMETER_FLAGS + 2u ); // bit 10
+ const unsigned int GLOW_ENABLED = 1u << ( TEXT_PARAMETER_FLAGS + 3u ); // bit 11
+ const unsigned int DROP_SHADOW_EXISTS = 1u << ( TEXT_PARAMETER_FLAGS + 4u ); // bit 12
+ const unsigned int DROP_SHADOW_ENABLED = 1u << ( TEXT_PARAMETER_FLAGS + 5u ); // bit 13
+ const unsigned int GRADIENT_EXISTS = 1u << ( TEXT_PARAMETER_FLAGS + 6u ); // bit 14
+ const unsigned int GRADIENT_ENABLED = 1u << ( TEXT_PARAMETER_FLAGS + 7u ); // bit 15
const unsigned int ATTRIBUTE_END = GRADIENT_ENABLED;
/**
void SetOutline( bool enable, const Vector4& color, const Vector2& thickness );
/// @copydoc Dali::TextActor::SetGlow
- void SetGlow( bool enable, const Vector4& color, const float intensity);
+ void SetGlow( bool enable, const Vector4& color, float intensity );
/// @copydoc Dali::TextActor::SetShadow
- void SetShadow(bool enable, const Vector4& color, const Vector2& offset, const float size);
+ void SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size );
/**
* @brief Set Gradient parameters.
* @param[in] start The relative position of the gradient start point.
* @param[in] end The relative position of the gradient end point.
*/
- void SetGradient( const Vector4& color, const Vector2& start, const Vector2& end);
-
- /**
- * @brief Set Gradient color
- *
- * @param color Gradient color
- */
- void SetGradientColor( const Vector4& color );
-
- /**
- * @brief Set Gradient Start Point
- *
- * @param start Position of gradient start
- */
- void SetGradientStartPoint( const Vector2& start );
-
- /**
- * @brief Set Gradient End Point
- *
- * @param end Position of gradient end
- */
- void SetGradientEndPoint( const Vector2& end );
+ void SetGradient( const Vector4& color, const Vector2& start, const Vector2& end );
/**
* @brief Get the Gradient Color
*
* @return Gradient Color
*/
- const Vector4& GetOutlineColor();
+ const Vector4& GetOutlineColor() const;
/**
* @brief Get Outline Thickness
*
* @return Outline Thickness
*/
- const Vector2& GetOutlineThickness();
+ const Vector2& GetOutlineThickness() const;
/**
* @brief Get Glow Color
*
* @return Glow Color
*/
- const Vector4& GetGlowColor();
+ const Vector4& GetGlowColor() const;
/**
* @brief Get Glow Intensity
*
* @return Glow Intensity
*/
- float GetGlowIntensity();
+ float GetGlowIntensity() const;
/**
* @brief Get Drop Shadow Color
*
* @return Drop Shadow Color
*/
- const Vector4& GetDropShadowColor();
+ const Vector4& GetDropShadowColor() const;
/**
* @brief Get Drop Shadow Offset
*
* @return Drop Shadow Offset
*/
- const Vector2& GetDropShadowOffset();
+ const Vector2& GetDropShadowOffset() const;
/**
* @brief Get Drop Shadow Size
*
* @return Drop Shadow Size
*/
- float GetDropShadowSize();
+ float GetDropShadowSize() const;
/**
* @brief Get Gradient Color
*
* @return Gradient Color
*/
- const Vector4& GetGradientColor();
+ const Vector4& GetGradientColor() const;
/**
* @brief Get Gradient Start Point
*
* @return Position of Gradient Start Point
*/
- const Vector2& GetGradientStartPoint();
+ const Vector2& GetGradientStartPoint() const;
/**
* @brief Get Gradient End Point
*
* @return Position of Gradient End Point
*/
- const Vector2& GetGradientEndPoint();
+ const Vector2& GetGradientEndPoint() const;
/**
* @brief Get if Outline is enabled
*
* @return true if enabled, false if not
*/
- const bool IsOutlineEnabled() const
+ bool IsOutlineEnabled() const
{
return ( ( mFlags & OUTLINE_ENABLED ) != 0 );
}
*
* @return true if enabled, false if not
*/
- const bool IsGlowEnabled() const
+ bool IsGlowEnabled() const
{
return ( ( mFlags & GLOW_ENABLED ) != 0 );
}
*
* @return true if enabled, false if not
*/
- const bool IsDropShadowEnabled() const
+ bool IsDropShadowEnabled() const
{
return ( ( mFlags & DROP_SHADOW_ENABLED ) != 0 );
}
*
* @return true if enabled, false if not
*/
- const bool IsGradientEnabled() const
+ bool IsGradientEnabled() const
{
return ( ( mFlags & GRADIENT_ENABLED ) != 0 );
}
- /**
- * @brief Enable Gradient
- *
- * @param enable Set gradient enabled flag to enable
- */
- void SetGradientEnabled( bool enable )
- {
- if ( enable )
- {
- mFlags |= GRADIENT_ENABLED;
- }
- else
- {
- mFlags &=~GRADIENT_ENABLED;
- }
- }
-
private: // unimplemented copy constructor and assignment operator
TextParameters( const TextParameters& copy );
TextParameters& operator=(const TextParameters& rhs);
- std::vector< Dali::Any > mParameters; // container for any used attributes
+ Vector<char*> mParameters; // container for any used attributes
#if ( ATTRIBUTE_END > 0x8000 )
- unsigned int mFlags; // flags for used attributes, packed with position in container
+ unsigned int mFlags; // flags for used attributes, packed with position in container
#else
- unsigned short mFlags; // might be rendered irrelevant by alignment / packing
+ unsigned short mFlags; // might be rendered irrelevant by alignment / packing
#endif
}; // class TextParameters
#include <dali/public-api/common/dali-common.h>
#include <dali/internal/update/node-attachments/scene-graph-text-attachment.h>
#include <dali/internal/event/common/stage-impl.h>
-#include <dali/internal/common/text-parameters.h>
-
namespace Dali
{
// Keep raw pointer for message passing
attachment->mSceneObject = sceneObject;
- attachment->SetSmoothEdge(attachment->mSmoothing); // adjust smoothedge for font weight
+ attachment->CalculateWeightedSmoothing( TextStyle::DEFAULT_FONT_WEIGHT, TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD ); // adjust smoothedge for font weight
return attachment;
}
TextAttachment::TextAttachment( Stage& stage )
: RenderableAttachment( stage ),
mTextRequestHelper( *this ),
- mUnderlineEnabled( false ),
+ mTextColor( NULL ),
mIsLeftToRight(true),
mTextChanged( true ),
mFontChanged( true ),
mUnderlineChanged( true ),
mItalicsChanged( true ),
- mItalicsEnabled( false ),
mTextureIdSet( false ),
mTextureId(0),
- mSmoothing(Dali::TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD),
- mItalicsAngle( Radian(0.0f) ),
- mUnderlineThickness( 0.f ),
- mUnderlinePosition( 0.f ),
- mTextSize( Vector3::ZERO ),
- mWeight( TextStyle::REGULAR ),
- mTextColor( NULL )
+ mTextSize( Vector3::ZERO )
{
}
mFontChanged = true;
}
-void TextAttachment::SetGradientColor( const Vector4& color )
+void TextAttachment::SetTextColor( const Vector4& color )
{
- AllocateTextParameters();
+ bool sendMessage( false );
- if( mTextParameters->GetGradientColor() != color )
+ Vector4 clampedColor = Clamp( color, 0.f, 1.f );
+
+ if( NULL == mTextColor )
+ {
+ // A color (different from default) has been set, so allocate storage for the text color
+ mTextColor = new Vector4( clampedColor );
+ sendMessage = true;
+ }
+ else
{
- mTextParameters->SetGradientColor( color );
+ if( *mTextColor != clampedColor )
+ {
+ // text color has changed
+ *mTextColor = clampedColor;
+ sendMessage = true;
+ }
+ }
- SetGradientColorMessage( mStage->GetUpdateInterface(), *mSceneObject, color );
+ if( sendMessage )
+ {
+ SetTextColorMessage( mStage->GetUpdateInterface(), *mSceneObject, clampedColor );
}
}
-const Vector4& TextAttachment::GetGradientColor() const
+Vector4 TextAttachment::GetTextColor() const
+{
+ Vector4 color;
+
+ if( NULL != mTextColor )
+ {
+ color = *mTextColor;
+ }
+ else
+ {
+ color = TextStyle::DEFAULT_TEXT_COLOR;
+ }
+
+ return color;
+}
+
+void TextAttachment::ResetTextColor()
{
- return mTextParameters->GetGradientColor();
+ if( NULL != mTextColor )
+ {
+ delete mTextColor;
+ mTextColor = NULL;
+
+ SetTextColorMessage( mStage->GetUpdateInterface(), *mSceneObject, TextStyle::DEFAULT_TEXT_COLOR );
+ }
}
-void TextAttachment::SetGradientStartPoint( const Vector2& position )
+void TextAttachment::SetWeight( TextStyle::Weight weight )
{
- AllocateTextParameters();
+ if( mStyle.IsFontWeightDefault() ||
+ ( mStyle.GetWeight() != weight ) )
+ {
+ mStyle.SetWeight( weight );
- if( mTextParameters->GetGradientStartPoint() != position )
+ CalculateWeightedSmoothing( weight, mStyle.GetSmoothEdge() );
+ }
+}
+
+TextStyle::Weight TextAttachment::GetWeight() const
+{
+ return mStyle.GetWeight();
+}
+
+void TextAttachment::ResetWeight()
+{
+ if( !mStyle.IsFontWeightDefault() )
{
- mTextParameters->SetGradientStartPoint( position );
+ mStyle.Reset( TextStyle::WEIGHT );
- SetGradientStartPointMessage( mStage->GetUpdateInterface(), *mSceneObject, position );
+ CalculateWeightedSmoothing( TextStyle::DEFAULT_FONT_WEIGHT, mStyle.GetSmoothEdge() );
}
}
-const Vector2& TextAttachment::GetGradientStartPoint() const
+void TextAttachment::SetSmoothEdge( float smoothEdge )
+{
+ if( mStyle.IsSmoothEdgeDefault() ||
+ ( fabsf( smoothEdge - mStyle.GetSmoothEdge() ) > Math::MACHINE_EPSILON_1000 ) )
+ {
+ mStyle.SetSmoothEdge( smoothEdge );
+ CalculateWeightedSmoothing( mStyle.GetWeight(), smoothEdge );
+ }
+}
+
+float TextAttachment::GetSmoothEdge() const
{
- return mTextParameters->GetGradientStartPoint();
+ return mStyle.GetSmoothEdge();
}
-void TextAttachment::SetGradientEndPoint( const Vector2& position )
+void TextAttachment::ResetSmoothEdge()
{
- AllocateTextParameters();
+ if( !mStyle.IsSmoothEdgeDefault() )
+ {
+ mStyle.Reset( TextStyle::SMOOTH );
- if( mTextParameters->GetGradientEndPoint() != position )
+ CalculateWeightedSmoothing( mStyle.GetWeight(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD );
+ }
+}
+
+void TextAttachment::SetItalics( Radian angle )
+{
+ if( mStyle.IsItalicsDefault() ||
+ ( Radian( mStyle.GetItalicsAngle() ) != angle ) )
{
- mTextParameters->SetGradientEndPoint( position );
+ mItalicsChanged = true;
- SetGradientEndPointMessage( mStage->GetUpdateInterface(), *mSceneObject, position );
+ const Radian radian0( 0.0f );
+ mStyle.SetItalics( ( radian0 != angle ), Degree( angle ) );
}
}
-const Vector2& TextAttachment::GetGradientEndPoint() const
+bool TextAttachment::GetItalics() const
{
- return mTextParameters->GetGradientEndPoint();
+ return mStyle.IsItalicsEnabled();
}
-void TextAttachment::SetSmoothEdge( float smoothEdge )
+Radian TextAttachment::GetItalicsAngle() const
{
- mSmoothing = smoothEdge;
- float weightedSmoothing = smoothEdge;
+ return Radian( mStyle.GetItalicsAngle() );
+}
- // Adjust edge smoothing for font weight
- const float BOLDER = 0.20f;
- const float LIGHTER = 1.65f;
- const float offset = 1.0f - ( ( 1.0f / Dali::TextStyle::EXTRABLACK ) * mWeight );
- weightedSmoothing *= BOLDER + ( ( LIGHTER - BOLDER ) * offset );
- weightedSmoothing = std::max( 0.0f, weightedSmoothing );
- weightedSmoothing = std::min( 1.0f, weightedSmoothing );
+void TextAttachment::ResetItalics()
+{
+ if( !mStyle.IsItalicsDefault() )
+ {
+ mStyle.Reset( TextStyle::ITALICS );
- SetSmoothEdgeMessage( mStage->GetUpdateInterface(), *mSceneObject, weightedSmoothing );
+ mItalicsChanged = true;
+ }
}
-float TextAttachment::GetSmoothEdge() const
+void TextAttachment::SetUnderline( bool enable, float thickness, float position )
+{
+ if( mStyle.IsUnderlineDefault() ||
+ ( mStyle.IsUnderlineEnabled() != enable ) ||
+ ( fabsf( mStyle.GetUnderlineThickness() - thickness ) > Math::MACHINE_EPSILON_1000 ) ||
+ ( fabsf( mStyle.GetUnderlinePosition() - position ) > Math::MACHINE_EPSILON_1000 ) )
+ {
+ mUnderlineChanged = true;
+
+ mStyle.SetUnderline( enable, thickness, position );
+ }
+}
+
+bool TextAttachment::GetUnderline() const
{
- return mSmoothing;
+ return mStyle.IsUnderlineEnabled();
}
-void TextAttachment::SetOutline( bool enable, const Vector4& color, const Vector2& thickness )
+float TextAttachment::GetUnderlineThickness() const
{
- AllocateTextParameters();
+ return mStyle.GetUnderlineThickness();
+}
- if (enable != mTextParameters->IsOutlineEnabled() || color != mTextParameters->GetOutlineColor() || thickness != mTextParameters->GetOutlineThickness() )
+float TextAttachment::GetUnderlinePosition() const
+{
+ return mStyle.GetUnderlinePosition();
+}
+
+void TextAttachment::ResetUnderline()
+{
+ if( !mStyle.IsUnderlineDefault() )
{
- mTextParameters->SetOutline( enable, color, thickness );
+ mStyle.Reset( TextStyle::UNDERLINE );
+
+ mUnderlineChanged = true;
+ }
+}
+
+void TextAttachment::SetOutline( bool enable, const Vector4& color, const Vector2& thickness )
+{
+ if( mStyle.IsOutlineDefault() ||
+ ( mStyle.IsOutlineEnabled() != enable ) ||
+ ( mStyle.GetOutlineColor() != color ) ||
+ ( mStyle.GetOutlineThickness() != thickness ) )
+ {
+ mStyle.SetOutline( enable, color, thickness );
SetOutlineMessage( mStage->GetUpdateInterface(), *mSceneObject, enable, color, thickness );
}
bool TextAttachment::GetOutline() const
{
- return mTextParameters->IsOutlineEnabled();
+ return mStyle.IsOutlineEnabled();
}
void TextAttachment::GetOutlineParams( Vector4& color, Vector2& thickness ) const
{
- color = mTextParameters->GetOutlineColor();
- thickness = mTextParameters->GetOutlineThickness();
+ color = mStyle.GetOutlineColor();
+ thickness = mStyle.GetOutlineThickness();
}
-void TextAttachment::SetGlow( bool enable, const Vector4& color, float intensity )
+void TextAttachment::ResetOutline()
{
- AllocateTextParameters();
+ if( !mStyle.IsOutlineDefault() )
+ {
+ mStyle.Reset( TextStyle::OUTLINE );
+
+ SetOutlineMessage( mStage->GetUpdateInterface(), *mSceneObject, false, TextStyle::DEFAULT_OUTLINE_COLOR, TextStyle::DEFAULT_OUTLINE_THICKNESS );
+ }
+}
- if (enable != mTextParameters->IsGlowEnabled() || color != mTextParameters->GetGlowColor() || fabsf(intensity - mTextParameters->GetGlowIntensity() ) > Math::MACHINE_EPSILON_1000)
+void TextAttachment::SetGlow( bool enable, const Vector4& color, float intensity )
+{
+ if( mStyle.IsGlowDefault() ||
+ ( mStyle.IsGlowEnabled() != enable ) ||
+ ( mStyle.GetGlowColor() != color ) ||
+ ( fabsf( mStyle.GetGlowIntensity() - intensity ) > Math::MACHINE_EPSILON_1000 ) )
{
- mTextParameters->SetGlow( enable, color, intensity );
+ mStyle.SetGlow( enable, color, intensity );
SetGlowMessage( mStage->GetUpdateInterface(), *mSceneObject, enable, color, intensity );
}
bool TextAttachment::GetGlow() const
{
- return mTextParameters->IsGlowEnabled();
+ return mStyle.IsGlowEnabled();
}
void TextAttachment::GetGlowParams( Vector4& color, float& intensity) const
{
- color = mTextParameters->GetGlowColor();
- intensity = mTextParameters->GetGlowIntensity();
+ color = mStyle.GetGlowColor();
+ intensity = mStyle.GetGlowIntensity();
}
-void TextAttachment::SetShadow(bool enable, const Vector4& color, const Vector2& offset, const float size)
+void TextAttachment::ResetGlow()
{
- AllocateTextParameters();
+ if( !mStyle.IsGlowDefault() )
+ {
+ mStyle.Reset( TextStyle::GLOW );
- if (enable != mTextParameters->IsDropShadowEnabled() ||
- color != mTextParameters->GetDropShadowColor() ||
- offset != mTextParameters->GetDropShadowOffset() ||
- fabsf(size - mTextParameters->GetDropShadowSize() ) > Math::MACHINE_EPSILON_1 )
+ SetGlowMessage( mStage->GetUpdateInterface(), *mSceneObject, false, TextStyle::DEFAULT_GLOW_COLOR, TextStyle::DEFAULT_GLOW_INTENSITY );
+ }
+}
+
+void TextAttachment::SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size )
+{
+ if( mStyle.IsShadowDefault() ||
+ ( mStyle.IsShadowEnabled() != enable ) ||
+ ( mStyle.GetShadowColor() != color ) ||
+ ( mStyle.GetShadowOffset() != offset ) ||
+ ( fabsf( mStyle.GetShadowSize() - size ) > Math::MACHINE_EPSILON_1000 ) )
{
- mTextParameters->SetShadow( enable, color, offset, size );
+ mStyle.SetShadow( enable, color, offset, size );
const float unitPointSize( 64.0f );
const float unitsToPixels( mFont->GetUnitsToPixels());
bool TextAttachment::GetShadow() const
{
- return mTextParameters->IsDropShadowEnabled();
+ return mStyle.IsShadowEnabled();
}
void TextAttachment::GetShadowParams( Vector4& color, Vector2& offset, float& size ) const
{
- color = mTextParameters->GetDropShadowColor();
- offset = mTextParameters->GetDropShadowOffset();
- size = mTextParameters->GetDropShadowSize();
+ color = mStyle.GetShadowColor();
+ offset = mStyle.GetShadowOffset();
+ size = mStyle.GetShadowSize();
}
-void TextAttachment::SetTextColor(const Vector4& color)
+void TextAttachment::ResetShadow()
{
- bool sendMessage( false );
+ if( !mStyle.IsShadowDefault() )
+ {
+ mStyle.Reset( TextStyle::SHADOW );
- Vector4 clampedColor = Clamp(color, 0.f, 1.f);
+ const float unitPointSize( 64.0f );
+ const float unitsToPixels( mFont->GetUnitsToPixels());
+ const float fontPointSize( mFont->GetPointSize() );
- if( NULL == mTextColor )
- {
- if( clampedColor != TextStyle::DEFAULT_TEXT_COLOR )
- {
- // A color (different from default) has been set, so allocate storage for the text color
- mTextColor = new Vector4( clampedColor );
- sendMessage = true;
- }
- }
- else
- {
- if( *mTextColor != clampedColor )
- {
- // text color has changed
- *mTextColor = clampedColor;
- sendMessage = true;
- }
- }
+ float shadowSize( ( TextStyle::DEFAULT_SHADOW_SIZE * 0.25f ) / unitsToPixels );
- if( sendMessage )
- {
- SetTextColorMessage( mStage->GetUpdateInterface(), *mSceneObject, clampedColor );
+ Vector2 shadowOffset( TextStyle::DEFAULT_SHADOW_OFFSET );
+ Vector2 maxOffset( fontPointSize / 4.5f, fontPointSize / 4.5f );
+ shadowOffset = Min( shadowOffset, maxOffset );
+ shadowOffset = Max( shadowOffset, -maxOffset );
+ shadowOffset *= unitPointSize / fontPointSize;
+ SetDropShadowMessage( mStage->GetUpdateInterface(), *mSceneObject, false, TextStyle::DEFAULT_SHADOW_COLOR, shadowOffset, shadowSize );
}
}
-Vector4 TextAttachment::GetTextColor() const
+void TextAttachment::SetGradient( const Vector4& color, const Vector2& startPoint, const Vector2& endPoint )
{
- Vector4 color;
-
- if( NULL != mTextColor )
+ if( mStyle.IsGradientDefault() ||
+ ( mStyle.GetGradientColor() != color ) ||
+ ( mStyle.GetGradientStartPoint() != startPoint ) ||
+ ( mStyle.GetGradientEndPoint() != endPoint ) )
{
- color = *mTextColor;
+ mStyle.SetGradient( true, color, startPoint, endPoint );
+ SetGradientMessage( mStage->GetUpdateInterface(), *mSceneObject, color, startPoint, endPoint );
}
- else
- {
- color = TextStyle::DEFAULT_TEXT_COLOR;
- }
-
- return color;
}
-void TextAttachment::SetItalics( const Radian& angle )
+const Vector4& TextAttachment::GetGradientColor() const
{
- if ( angle != mItalicsAngle )
- {
- mItalicsChanged = true;
- mItalicsAngle = angle;
- }
- Radian radian0( 0.0f );
-
- if( radian0 != mItalicsAngle )
- {
- mItalicsEnabled = true;
- }
- else
- {
- mItalicsEnabled = false;
- }
+ return mStyle.GetGradientColor();
}
-const Radian& TextAttachment::GetItalics() const
+const Vector2& TextAttachment::GetGradientStartPoint() const
{
- return mItalicsAngle;
+ return mStyle.GetGradientStartPoint();
}
-void TextAttachment::SetUnderline( bool enable, float thickness, float position )
+const Vector2& TextAttachment::GetGradientEndPoint() const
{
- if ( enable != mUnderlineEnabled )
- {
- mUnderlineEnabled = enable;
- mUnderlineChanged = true;
- }
+ return mStyle.GetGradientEndPoint();
+}
- if( mUnderlineEnabled )
+void TextAttachment::ResetGradient()
+{
+ if( !mStyle.IsGradientDefault() )
{
- if( fabsf( thickness - mUnderlineThickness ) > Math::MACHINE_EPSILON_0 )
- {
- mUnderlineThickness = thickness;
- mUnderlineChanged = true;
- }
+ mStyle.Reset( TextStyle::GRADIENT );
- if( fabsf( position - mUnderlinePosition ) > Math::MACHINE_EPSILON_0 )
- {
- mUnderlinePosition = position;
- mUnderlineChanged = true;
- }
+ SetGradientMessage( mStage->GetUpdateInterface(), *mSceneObject, TextStyle::DEFAULT_GRADIENT_COLOR, TextStyle::DEFAULT_GRADIENT_START_POINT, TextStyle::DEFAULT_GRADIENT_END_POINT );
}
}
-bool TextAttachment::GetUnderline() const
+void TextAttachment::GetTextStyle( TextStyle& style ) const
{
- return mUnderlineEnabled;
-}
+ style.Copy( mStyle );
-float TextAttachment::GetUnderlineThickness() const
-{
- return mUnderlineThickness;
-}
+ // Font name, font style, font point size and color are not store inside the mStyle, so they need to be copied after.
-float TextAttachment::GetUnderlinePosition() const
-{
- return mUnderlinePosition;
-}
-
-void TextAttachment::SetWeight( TextStyle::Weight weight )
-{
- mWeight = weight;
+ if( NULL != mTextColor )
+ {
+ style.SetTextColor( *mTextColor );
+ }
- SetSmoothEdge(mSmoothing);
-}
+ if( !mFont->IsDefaultSystemFont() )
+ {
+ style.SetFontName( mFont->GetName() );
+ style.SetFontStyle( mFont->GetStyle() );
+ }
-TextStyle::Weight TextAttachment::GetWeight() const
-{
- return mWeight;
+ if( !mFont->IsDefaultSystemSize() )
+ {
+ style.SetFontPointSize( PointSize( mFont->GetPointSize() ) );
+ }
}
Vector3 TextAttachment::MeasureText() const
mTextChanged = true;
}
- TextFormat format( mUnderlineEnabled, mIsLeftToRight, mItalicsEnabled, mItalicsAngle, mFont->GetPointSize(), mUnderlineThickness, mUnderlinePosition );
+ TextFormat format( mStyle.IsUnderlineEnabled(),
+ mIsLeftToRight,
+ mStyle.IsItalicsEnabled(),
+ Radian( mStyle.GetItalicsAngle() ),
+ mFont->GetPointSize(),
+ mStyle.GetUnderlineThickness(),
+ mStyle.GetUnderlinePosition() );
if ( mTextChanged && mFontChanged )
{
return loaded;
}
+void TextAttachment::CalculateWeightedSmoothing( TextStyle::Weight weight, float smoothEdge )
+{
+ float weightedSmoothing = smoothEdge;
+
+ // Adjust edge smoothing for font weight
+ const float BOLDER = 0.20f;
+ const float LIGHTER = 1.65f;
+ const float offset = 1.0f - ( ( 1.0f / Dali::TextStyle::EXTRABLACK ) * weight );
+ weightedSmoothing *= BOLDER + ( ( LIGHTER - BOLDER ) * offset );
+ weightedSmoothing = std::max( 0.0f, weightedSmoothing );
+ weightedSmoothing = std::min( 1.0f, weightedSmoothing );
+
+ SetSmoothEdgeMessage( mStage->GetUpdateInterface(), *mSceneObject, weightedSmoothing );
+}
+
void TextAttachment::TextureResized( const TextureIdList& oldTextureIds, unsigned int newTextureId )
{
bool matched( false );
return ( mTextChanged || mFontChanged || mUnderlineChanged || mItalicsChanged );
}
-void TextAttachment::AllocateTextParameters()
-{
- if( !mTextParameters )
- {
- mTextParameters = new TextParameters;
- }
-}
-
void TextAttachment::OnStageConnection2()
{
// do nothing
}
}
-
} // namespace Internal
} // namespace Dali
}
/**
- * @copydoc Dali::TextActor::SetGradientColor()
+ * Set the text color
+ * @param[in] color The text color
*/
- void SetGradientColor( const Vector4& color );
+ void SetTextColor(const Vector4& color);
/**
- * @copydoc Dali::TextActor::GetGradientColor()
+ * Get the text color
+ * @return The text color
*/
- const Vector4& GetGradientColor() const;
+ Vector4 GetTextColor() const;
/**
- * @copydoc Dali::TextActor::SetGradientStartPoint()
+ * Resets to default the text color.
*/
- void SetGradientStartPoint( const Vector2& position );
+ void ResetTextColor();
/**
- * @copydoc Dali::TextActor::GetGradientStartPoint()
+ * @copydoc Dali::TextActor::SetWeight()
*/
- const Vector2& GetGradientStartPoint() const;
+ void SetWeight( TextStyle::Weight weight );
/**
- * @copydoc Dali::TextActor::SetGradientEndPoint()
+ * @copydoc Dali::TextActor::GetWeight()
*/
- void SetGradientEndPoint( const Vector2& position );
+ TextStyle::Weight GetWeight() const;
/**
- * @copydoc Dali::TextActor::GetGradientEndPoint()
+ * Resets to default the text weight.
*/
- const Vector2& GetGradientEndPoint() const;
+ void ResetWeight();
/**
* @copydoc Dali::TextActor::SetSmoothEdge(const float)
*/
- void SetSmoothEdge(const float smoothEdge);
+ void SetSmoothEdge( float smoothEdge );
/**
* Retrieve the smooth edge value.
float GetSmoothEdge() const;
/**
+ * Resets to default the smooth edge.
+ */
+ void ResetSmoothEdge();
+
+ /**
+ * Enable italics on the text actor, the text will be sheared by the given angle.
+ * @param[in] angle Italics angle in radians.
+ */
+ void SetItalics( Radian angle );
+
+ /**
+ * @copydoc Dali::TextActor::GetItalics()
+ */
+ bool GetItalics() const;
+
+ /**
+ * @copydoc Dali::TextActor::GetItalicsAngle()
+ */
+ Radian GetItalicsAngle() const;
+
+ /**
+ * Resets to default the italics.
+ */
+ void ResetItalics();
+
+ /**
+ * @copydoc Dali::TextActor::SetUnderline()
+ */
+ void SetUnderline( bool enable, float thickness, float position );
+
+ /**
+ * @copydoc Dali::TextActor::GetUnderline()
+ */
+ bool GetUnderline() const;
+
+ /**
+ * @copydoc Internal::TextActor::GetUnderlineThickness()
+ */
+ float GetUnderlineThickness() const;
+
+ /**
+ * @copydoc Internal::TextActor::GetUnderlinePosition()
+ */
+ float GetUnderlinePosition() const;
+
+ /**
+ * Resets to default the text underline.
+ */
+ void ResetUnderline();
+
+ /**
* @copydoc Dali::TextActor::SetOutline(const bool,const Vector4&,const Vector2&)
*/
void SetOutline( bool enable, const Vector4& color, const Vector2& thickness );
void GetOutlineParams( Vector4& color, Vector2& thickness ) const;
/**
+ * Resets to default the text outline.
+ */
+ void ResetOutline();
+
+ /**
* @copydoc Dali::TextActor::SetGlow(const bool,const Vector4&,const float)
*/
- void SetGlow( bool enable, const Vector4& color, const float intensity);
+ void SetGlow( bool enable, const Vector4& color, float intensity );
/**
* Get glow state.
void GetGlowParams( Vector4& color, float& intensity ) const;
/**
+ * Resets to default the text glow.
+ */
+ void ResetGlow();
+
+ /**
* @copydoc Dali::TextActor::SetShadow(const bool,const Vector4&,const Vector2&,const float)
*/
- void SetShadow( bool enable, const Vector4& color, const Vector2& offset, const float size);
+ void SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size );
/**
* Retrieve the shadow state.
void GetShadowParams( Vector4& color, Vector2& offset, float& size ) const;
/**
- * Set the text color
- * @param[in] color The text color
+ * Resets to default the text shadow.
*/
- void SetTextColor(const Vector4& color);
+ void ResetShadow();
/**
- * Get the text color
- * @return The text color
+ * @see Dali::TextActor::SetGradientColor()
+ * @see Dali::TextActor::SetGradientStartPoint()
+ * @see Dali::TextActor::SetGradientEndPoint()
*/
- Vector4 GetTextColor() const;
+ void SetGradient( const Vector4& color, const Vector2& startPoint, const Vector2& endPoint );
/**
- * Enable italics on the text actor, the text will be sheared by the given angle.
- * @param[in] angle Italics angle in radians.
- */
- void SetItalics( const Radian& angle );
-
- /**
- * @copydoc Dali::TextActor::GetItalics()
- */
- const Radian& GetItalics() const;
-
- /**
- * @copydoc Dali::TextActor::SetUnderline()
- */
- void SetUnderline( bool enable, float thickness, float position );
-
- /**
- * @copydoc Dali::TextActor::GetUnderline()
+ * @copydoc Dali::TextActor::GetGradientColor()
*/
- bool GetUnderline() const;
+ const Vector4& GetGradientColor() const;
/**
- * @copydoc Internal::TextActor::GetUnderlineThickness()
+ * @copydoc Dali::TextActor::GetGradientStartPoint()
*/
- float GetUnderlineThickness() const;
+ const Vector2& GetGradientStartPoint() const;
/**
- * @copydoc Internal::TextActor::GetUnderlinePosition()
+ * @copydoc Dali::TextActor::GetGradientEndPoint()
*/
- float GetUnderlinePosition() const;
+ const Vector2& GetGradientEndPoint() const;
/**
- * @copydoc Dali::TextActor::SetWeight()
+ * Resets to default the text gradient.
*/
- void SetWeight( TextStyle::Weight weight );
+ void ResetGradient();
/**
- * @copydoc Dali::TextActor::GetWeight()
+ * Retrieves the text style.
+ *
+ * @param[out] style The text style.
*/
- TextStyle::Weight GetWeight() const;
+ void GetTextStyle( TextStyle& style ) const;
/**
* Measure the natural size of a text string, as displayed in this font.
*/
bool IsTextLoaded();
+ /**
+ * Calculates the weighted smoothing value.
+ */
+ void CalculateWeightedSmoothing( TextStyle::Weight weight, float smoothEdge );
+
public: // glyph texture observer
/**
bool IsTextModified();
/**
- * Allocate a TextParameters object on this TextAttachment if one does not exist
- */
- void AllocateTextParameters();
-
- /**
* First stage construction of a TextAttachment.
* @param[in] stage Used to send messages to scene-graph.
*/
*/
void SetTextChanges();
- /**
- * Send new texture-id message
- */
- void SendTextureIdMessage();
-
- /**
- * Make a request to load the current text
- * @param uniqueText the text to request to be loaded
- */
- void RequestText( const TextArray& uniqueText );
-
protected:
/**
const SceneGraph::TextAttachment* mSceneObject; ///< Not owned
- TextRequestHelper mTextRequestHelper; ///< Text request helper
- FontPointer mFont; ///< The font resource
-
+ TextRequestHelper mTextRequestHelper; ///< Text request helper
+ FontPointer mFont; ///< The font resource
+ Vector4* mTextColor; ///< on demand storage for text color
+ TextStyle mStyle; ///< on demand storage for text effects parameters ( do not store font parameters and color )
+ ///< Font parameters are stored in the FontPointer member. Inside the TextStyle, font parameters and color are allocated in the same struct,
+ ///< so store the text color in the style will allocate space for the font parameters as well, wasting space.
// Cached values for public getters
TextArray mText;
- bool mUnderlineEnabled:1; ///< whether the text is underlined
bool mIsLeftToRight:1; ///< whether the text is left to right
bool mTextChanged:1; ///< whether the text has changed
bool mFontChanged:1; ///< whether the font has changed
bool mUnderlineChanged:1; ///< whether the underline has changed
bool mItalicsChanged:1; ///< whether the italics has changed
- bool mItalicsEnabled:1; ///< whether italics are enabled
bool mTextureIdSet:1; ///< flag to signify if the texture id has been set on the scene-graph text-attachment
unsigned int mTextureId; ///< the texture id of the glyph atlas being used
- float mSmoothing; ///< edge smoothing for the font
- Radian mItalicsAngle; ///< font italics angle
- float mUnderlineThickness; ///< The underline's thickness.
- float mUnderlinePosition; ///< The underline's position.
Vector2 mTextSize; ///< text natural size
- TextStyle::Weight mWeight; ///< font weight
OwnerPointer< TextVertexBuffer > mVertexBuffer; ///< vertex data to display the text
- OwnerPointer< TextParameters > mTextParameters; ///< on demand storage for text effect parameters
- Vector4* mTextColor; ///< on demand storage for text color
};
} // namespace Internal
void TextActor::SetGradientColor( const Vector4& color )
{
- mTextAttachment->SetGradientColor( color );
+ mTextAttachment->SetGradient( color, mTextAttachment->GetGradientStartPoint(), mTextAttachment->GetGradientEndPoint() );
}
const Vector4& TextActor::GetGradientColor() const
void TextActor::SetGradientStartPoint( const Vector2& position )
{
- mTextAttachment->SetGradientStartPoint( position );
+ mTextAttachment->SetGradient( mTextAttachment->GetGradientColor(), position, mTextAttachment->GetGradientEndPoint() );
}
const Vector2& TextActor::GetGradientStartPoint() const
void TextActor::SetGradientEndPoint( const Vector2& position )
{
- mTextAttachment->SetGradientEndPoint( position );
+ mTextAttachment->SetGradient( mTextAttachment->GetGradientColor(), mTextAttachment->GetGradientStartPoint(), position );
}
const Vector2& TextActor::GetGradientEndPoint() const
return mTextAttachment->GetGradientEndPoint();
}
+void TextActor::SetGradient( const Vector4& color, const Vector2& startPoint, const Vector2& endPoint )
+{
+ mTextAttachment->SetGradient( color, startPoint, endPoint );
+}
+
void TextActor::SetTextStyle( const TextStyle& style, TextRequestMode mode )
{
// Set font.
}
// Set color.
- SetTextColor( style.GetTextColor() );
+ if( !style.IsTextColorDefault() )
+ {
+ SetTextColor( style.GetTextColor() );
+ }
+ else
+ {
+ mTextAttachment->ResetTextColor();
+ }
// Italics
- SetItalics( style.GetItalics() ? Radian( style.GetItalicsAngle() ) : Radian( 0.0f ) );
+ if( !style.IsItalicsDefault() )
+ {
+ SetItalics( style.IsItalicsEnabled() ? Radian( style.GetItalicsAngle() ) : Radian( 0.0f ) );
+ }
+ else
+ {
+ mTextAttachment->ResetItalics();
+ }
// Underline
- SetUnderline( style.GetUnderline(), style.GetUnderlineThickness(), style.GetUnderlinePosition() );
+ if( !style.IsUnderlineDefault() )
+ {
+ SetUnderline( style.IsUnderlineEnabled(), style.GetUnderlineThickness(), style.GetUnderlinePosition() );
+ }
+ else
+ {
+ mTextAttachment->ResetUnderline();
+ }
// Shadow
- SetShadow( style.GetShadow(), style.GetShadowColor(), style.GetShadowOffset(), style.GetShadowSize() );
+ if( !style.IsShadowDefault() )
+ {
+ SetShadow( style.IsShadowEnabled(), style.GetShadowColor(), style.GetShadowOffset(), style.GetShadowSize() );
+ }
+ else
+ {
+ mTextAttachment->ResetShadow();
+ }
// Glow
- SetGlow( style.GetGlow(), style.GetGlowColor(), style.GetGlowIntensity() );
+ if( !style.IsGlowDefault() )
+ {
+ SetGlow( style.IsGlowEnabled(), style.GetGlowColor(), style.GetGlowIntensity() );
+ }
+ else
+ {
+ mTextAttachment->ResetGlow();
+ }
// Soft Smooth edge.
- SetSmoothEdge( style.GetSmoothEdge() );
+ if( !style.IsSmoothEdgeDefault() )
+ {
+ SetSmoothEdge( style.GetSmoothEdge() );
+ }
+ else
+ {
+ mTextAttachment->ResetSmoothEdge();
+ }
// Outline
- SetOutline( style.GetOutline(), style.GetOutlineColor(), style.GetOutlineThickness() );
+ if( !style.IsOutlineDefault() )
+ {
+ SetOutline( style.IsOutlineEnabled(), style.GetOutlineColor(), style.GetOutlineThickness() );
+ }
+ else
+ {
+ mTextAttachment->ResetOutline();
+ }
// Weight
- SetWeight( style.GetWeight() );
-}
-
-TextStyle TextActor::GetTextStyle() const
-{
- // Reset to default values.
- TextStyle textStyle;
-
- // Font parameters.
- const Font& font = mTextAttachment->GetFont();
-
- if( !font.IsDefaultSystemFont() )
+ if( !style.IsFontWeightDefault() )
{
- textStyle.SetFontName( font.GetName() );
- textStyle.SetFontStyle( font.GetStyle() );
+ SetWeight( style.GetWeight() );
}
-
- if( !font.IsDefaultSystemSize() )
+ else
{
- textStyle.SetFontPointSize( PointSize( font.GetPointSize() ) );
+ mTextAttachment->ResetWeight();
}
- // Color.
- textStyle.SetTextColor( GetTextColor() );
-
- // Italics
- textStyle.SetItalics( Radian( 0.f ) != GetItalics() );
- textStyle.SetItalicsAngle( Degree( GetItalics() ) );
-
- // Underline
- textStyle.SetUnderline( GetUnderline() );
- textStyle.SetUnderlinePosition( GetUnderlinePosition() );
- textStyle.SetUnderlineThickness( GetUnderlineThickness() );
-
- // Shadow
- Vector4 shadowColor;
- Vector2 shadowOffset;
- float shadowSize;
- mTextAttachment->GetShadowParams( shadowColor, shadowOffset, shadowSize );
- textStyle.SetShadow( mTextAttachment->GetShadow(), shadowColor, shadowOffset, shadowSize );
-
- // Glow
- Vector4 glowColor;
- float glowOffset(0.0f);
- mTextAttachment->GetGlowParams( glowColor, glowOffset );
- textStyle.SetGlow( mTextAttachment->GetGlow(), glowColor, glowOffset );
-
- // Soft Smooth edge.
- textStyle.SetSmoothEdge( mTextAttachment->GetSmoothEdge() );
-
- // Outline
- Vector4 outlineColor;
- Vector2 outlineOffset;
- mTextAttachment->GetOutlineParams( outlineColor, outlineOffset );
- textStyle.SetOutline( mTextAttachment->GetOutline(), outlineColor, outlineOffset );
+ //Gradient
+ if( !style.IsGradientDefault() )
+ {
+ if( style.IsGradientEnabled() )
+ {
+ SetGradient( style.GetGradientColor(), style.GetGradientStartPoint(), style.GetGradientEndPoint() );
+ }
+ else
+ {
+ SetGradient( TextStyle::DEFAULT_GRADIENT_COLOR, TextStyle::DEFAULT_GRADIENT_START_POINT, TextStyle::DEFAULT_GRADIENT_END_POINT );
+ }
+ }
+ else
+ {
+ mTextAttachment->ResetGradient();
+ }
+}
- // Weight
- textStyle.SetWeight( mTextAttachment->GetWeight() );
+TextStyle TextActor::GetTextStyle() const
+{
+ TextStyle textStyle;
+ mTextAttachment->GetTextStyle( textStyle );
return textStyle;
}
return mTextAttachment->GetTextColor();
}
-void TextActor::SetSmoothEdge(const float smoothEdge)
+void TextActor::SetSmoothEdge( float smoothEdge )
{
mTextAttachment->SetSmoothEdge(smoothEdge);
}
-void TextActor::SetOutline(const bool enable, const Vector4& color, const Vector2& offset)
+void TextActor::SetOutline( bool enable, const Vector4& color, const Vector2& offset )
{
mTextAttachment->SetOutline(enable, color, offset);
}
-void TextActor::SetGlow(const bool enable, const Vector4& color, const float intensity)
+void TextActor::SetGlow( bool enable, const Vector4& color, float intensity )
{
mTextAttachment->SetGlow(enable, color, intensity);
}
-void TextActor::SetShadow(const bool enable, const Vector4& color, const Vector2& offset, const float size)
+void TextActor::SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size )
{
mTextAttachment->SetShadow(enable, color, offset, size);
}
-void TextActor::SetItalics( const Radian& angle )
+void TextActor::SetItalics( Radian angle )
{
mTextAttachment->SetItalics( angle );
TextChanged();
}
-const Radian& TextActor::GetItalics() const
+bool TextActor::GetItalics() const
{
return mTextAttachment->GetItalics();
}
-void TextActor::SetUnderline( const bool enable, float thickness, float position )
+Radian TextActor::GetItalicsAngle() const
+{
+ return mTextAttachment->GetItalicsAngle();
+}
+
+void TextActor::SetUnderline( bool enable, float thickness, float position )
{
mTextAttachment->SetUnderline( enable, thickness, position );
}
case Dali::TextActor::GRADIENT_COLOR:
{
- mTextAttachment->SetGradientColor( propertyValue.Get<Vector4>() );
+ mTextAttachment->SetGradient( propertyValue.Get<Vector4>(), mTextAttachment->GetGradientStartPoint(), mTextAttachment->GetGradientEndPoint() );
break;
}
case Dali::TextActor::GRADIENT_START_POINT:
{
- mTextAttachment->SetGradientStartPoint( propertyValue.Get<Vector2>() );
+ mTextAttachment->SetGradient( mTextAttachment->GetGradientColor(), propertyValue.Get<Vector2>(), mTextAttachment->GetGradientEndPoint() );
break;
}
case Dali::TextActor::GRADIENT_END_POINT:
{
- mTextAttachment->SetGradientEndPoint( propertyValue.Get<Vector2>() );
+ mTextAttachment->SetGradient( mTextAttachment->GetGradientColor(), mTextAttachment->GetGradientStartPoint(), propertyValue.Get<Vector2>() );
break;
}
case Dali::TextActor::TEXT_COLOR:
const Vector2& GetGradientEndPoint() const;
/**
+ * @see Dali::TextActor::SetGradientColor()
+ * @see Dali::TextActor::SetGradientStartPoint()
+ * @see Dali::TextActor::SetGradientEndPoint()
+ */
+ void SetGradient( const Vector4& color, const Vector2& startPoint, const Vector2& endPoint );
+
+ /**
* @copydoc Dali::TextActor::SetTextStyle( const TextStyle& style )
* @param mode whether new text should be requested
*/
/**
* @copydoc Dali::TextActor::SetSmoothEdge(const float)
*/
- void SetSmoothEdge(const float smoothEdge);
+ void SetSmoothEdge( float smoothEdge );
/**
- * @copydoc Dali::TextActor::SetOutline(const bool,const Vector4&,const Vector2&)
+ * @copydoc Dali::TextActor::SetOutline( bool,const Vector4&,const Vector2&)
*/
- void SetOutline(const bool enable, const Vector4& color, const Vector2& thickness);
+ void SetOutline( bool enable, const Vector4& color, const Vector2& thickness );
/**
* @copydoc Dali::TextActor::SetGlow(const bool,const Vector4&,const float)
*/
- void SetGlow(const bool enable, const Vector4& color, const float intensity);
+ void SetGlow( bool enable, const Vector4& color, float intensity );
/**
* @copydoc Dali::TextActor::SetShadow(const bool,const Vector4&,const Vector2&,const float)
*/
- void SetShadow(const bool enable, const Vector4& color, const Vector2& offset, const float size);
+ void SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size );
/**
* Enable italics on the text actor, the text will be sheared by the given angle.
* @param[in] angle Italics angle in radians.
*/
- void SetItalics( const Radian& angle );
+ void SetItalics( Radian angle );
/**
* @copydoc Dali::TextActor::GetItalics()
*/
- const Radian& GetItalics() const;
+ bool GetItalics() const;
+
+ /**
+ * @copydoc Dali::TextActor::GetItalicsAngle()
+ */
+ Radian GetItalicsAngle() const;
/**
* @copydoc Dali::TextActor::SetUnderline()
mPixelSize = pixelSize;
}
-void TextRenderer::SetGradientColor( const Vector4& color )
+void TextRenderer::SetGradient( const Vector4& color, const Vector2& startPoint, const Vector2& endPoint )
{
AllocateTextParameters();
- mTextParameters->SetGradientColor( color );
-}
-
-void TextRenderer::SetGradientStartPoint( const Vector2& position )
-{
- AllocateTextParameters();
- mTextParameters->SetGradientStartPoint( position );
- mTextParameters->SetGradientEnabled( mTextParameters->GetGradientEndPoint() != mTextParameters->GetGradientStartPoint() );
-}
-
-void TextRenderer::SetGradientEndPoint( const Vector2& position )
-{
- AllocateTextParameters();
- mTextParameters->SetGradientEndPoint( position );
- mTextParameters->SetGradientEnabled( mTextParameters->GetGradientEndPoint() != mTextParameters->GetGradientStartPoint() );
+ mTextParameters->SetGradient( color, startPoint, endPoint );
}
void TextRenderer::SetTextColor( const Vector4& color )
void SetFontSize( float pixelSize );
/**
- * @copydoc Dali::TextActor::SetGradientColor()
+ * @see Dali::TextActor::SetGradientColor()
+ * @see Dali::TextActor::SetGradientStartPoint()
+ * @see Dali::TextActor::SetGradientEndPoint()
*/
- void SetGradientColor( const Vector4& color );
-
- /**
- * @copydoc Dali::TextActor::SetGradientStartPoint()
- */
- void SetGradientStartPoint( const Vector2& position );
-
- /**
- * @copydoc Dali::TextActor::SetGradientEndPoint()
- */
- void SetGradientEndPoint( const Vector2& position );
+ void SetGradient( const Vector4& color, const Vector2& startPoint, const Vector2& endPoint );
/**
* @copydoc Dali::TextActor::SetTextColor()
new (slot) DerivedType( mTextRenderer, &TextRenderer::SetFontSize, pixelSize );
}
-void TextAttachment::SetGradientColor( BufferIndex updateBufferIndex, const Vector4& color )
+void TextAttachment::SetGradient( BufferIndex updateBufferIndex, const Vector4& color, const Vector2& startPoint, const Vector2& endPoint )
{
DALI_ASSERT_DEBUG(mSceneController);
- typedef MessageValue1< TextRenderer, Vector4 > DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( mTextRenderer, &TextRenderer::SetGradientColor, color );
-}
-
-void TextAttachment::SetGradientStartPoint( BufferIndex updateBufferIndex, const Vector2& position )
-{
- DALI_ASSERT_DEBUG(mSceneController);
-
- typedef MessageValue1< TextRenderer, Vector2 > DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( mTextRenderer, &TextRenderer::SetGradientStartPoint, position );
-}
-
-void TextAttachment::SetGradientEndPoint( BufferIndex updateBufferIndex, const Vector2& position )
-{
- DALI_ASSERT_DEBUG(mSceneController);
-
- typedef MessageValue1< TextRenderer, Vector2 > DerivedType;
+ typedef MessageValue3< TextRenderer, Vector4, Vector2, Vector2 > DerivedType;
// Reserve some memory inside the render queue
unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( mTextRenderer, &TextRenderer::SetGradientEndPoint, position );
+ new (slot) DerivedType( mTextRenderer, &TextRenderer::SetGradient, color, startPoint, endPoint );
}
void TextAttachment::SetTextColor( BufferIndex updateBufferIndex, const Vector4& color )
void SetTextFontSize( BufferIndex updateBufferIndex, float pixelSize );
/**
- * Set the color associated with the gradient end point.
+ * Sets the gradient start point, the gradient end point and the color associated with the gradient end point.
* @param[in] updateBufferIndex The current update buffer index.
* @param[in] color The gradient color (end-point color)
+ * @param[in] startPoint The relative position of the gradient start point.
+ * @param[in] endPoint The relative position of the gradient end point.
*/
- void SetGradientColor( BufferIndex updateBufferIndex, const Vector4& color );
-
- /**
- * Set the gradient start point.
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] position The relative position of the gradient start point.
- */
- void SetGradientStartPoint( BufferIndex updateBufferIndex, const Vector2& position );
-
- /**
- * Set the gradient end point.
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] position The relative position of the gradient end point.
- */
- void SetGradientEndPoint( BufferIndex updateBufferIndex, const Vector2& position );
+ void SetGradient( BufferIndex updateBufferIndex, const Vector4& color, const Vector2& startPoint, const Vector2& endPoint );
/**
* Set the text color.
new (slot) LocalType( &attachment, &TextAttachment::SetTextFontSize, pixelSize );
}
-inline void SetGradientColorMessage( EventToUpdate& eventToUpdate, const TextAttachment& attachment, const Vector4& color )
-{
- typedef MessageDoubleBuffered1< TextAttachment, Vector4 > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &attachment, &TextAttachment::SetGradientColor, color );
-}
-
-inline void SetGradientStartPointMessage( EventToUpdate& eventToUpdate, const TextAttachment& attachment, const Vector2& position )
-{
- typedef MessageDoubleBuffered1< TextAttachment, Vector2 > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &attachment, &TextAttachment::SetGradientStartPoint, position );
-}
-
-inline void SetGradientEndPointMessage( EventToUpdate& eventToUpdate, const TextAttachment& attachment, const Vector2& position )
+inline void SetGradientMessage( EventToUpdate& eventToUpdate, const TextAttachment& attachment, const Vector4& color, const Vector2& startPoint, const Vector2& endPoint )
{
- typedef MessageDoubleBuffered1< TextAttachment, Vector2 > LocalType;
+ typedef MessageDoubleBuffered3< TextAttachment, Vector4, Vector2, Vector2 > LocalType;
// Reserve some memory inside the message queue
unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &attachment, &TextAttachment::SetGradientEndPoint, position );
+ new (slot) LocalType( &attachment, &TextAttachment::SetGradient, color, startPoint, endPoint );
}
inline void SetTextColorMessage( EventToUpdate& eventToUpdate, const TextAttachment& attachment, const Vector4& color )
return GetImplementation(*this).GetTextColor();
}
-void TextActor::SetSmoothEdge(const float smoothEdge)
+void TextActor::SetSmoothEdge( float smoothEdge )
{
GetImplementation(*this).SetSmoothEdge(smoothEdge);
}
-void TextActor::SetOutline(const bool enable, const Vector4& color, const Vector2& thickness)
+void TextActor::SetOutline( bool enable, const Vector4& color, const Vector2& thickness )
{
GetImplementation(*this).SetOutline(enable, color, thickness);
}
-void TextActor::SetGlow(const bool enable, const Vector4& color, const float intensity)
+void TextActor::SetGlow( bool enable, const Vector4& color, float intensity )
{
GetImplementation(*this).SetGlow(enable, color, intensity);
}
-void TextActor::SetShadow(const bool enable, const Vector4& color, const Vector2& offset, const float size)
+void TextActor::SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size )
{
GetImplementation(*this).SetShadow(enable, color, offset, size);
}
-void TextActor::SetItalics( const bool enabled, const Degree& angle )
+void TextActor::SetItalics( bool enabled, Degree angle )
{
GetImplementation(*this).SetItalics( enabled ? Radian(angle) : Radian( 0.0f ) );
}
-void TextActor::SetItalics( const bool enabled, const Radian& angle )
+void TextActor::SetItalics( bool enabled, Radian angle )
{
GetImplementation(*this).SetItalics( enabled ? angle : Radian( 0.0f ) );
}
bool TextActor::GetItalics() const
{
- return GetImplementation(*this).GetItalics() != Radian(0.0f);/* parasoft-suppress MISRA2004-13_3_DMC "Comparing with constant value" */
+ return GetImplementation(*this).GetItalics();
}
-const Radian& TextActor::GetItalicsAngle() const
+Radian TextActor::GetItalicsAngle() const
{
- return GetImplementation(*this).GetItalics();
+ return GetImplementation(*this).GetItalicsAngle();
}
-void TextActor::SetUnderline( const bool enable )
+void TextActor::SetUnderline( bool enable )
{
GetImplementation(*this).SetUnderline( enable, 0.f, 0.f );
}
#include <dali/public-api/common/constants.h>
#include <dali/public-api/text/font.h>
+#include <dali/public-api/common/dali-vector.h>
+
+// EXTERNAL INCLUDES
+
+#include <stdint.h>
namespace Dali
{
-const Degree TextStyle::DEFAULT_ITALICS_ANGLE( 20.0f );
-const float TextStyle::DEFAULT_UNDERLINE_THICKNESS( 0.f );
-const float TextStyle::DEFAULT_UNDERLINE_POSITION( 0.f );
-const Vector4 TextStyle::DEFAULT_TEXT_COLOR( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); // cannot use Color::WHITE because it may or may not be initialized yet
-const Vector4 TextStyle::DEFAULT_SHADOW_COLOR( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) ); // cannot use Color::BLACK because it may or may not be initialized yet
-const Vector2 TextStyle::DEFAULT_SHADOW_OFFSET( 1.0f, 1.0f );
-const float TextStyle::DEFAULT_SHADOW_SIZE( 0.0f );
-const Vector4 TextStyle::DEFAULT_GLOW_COLOR( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) ); // cannot use Color::YELLOW because it may or may not be initialized yet
-const float TextStyle::DEFAULT_GLOW_INTENSITY( 0.05f );
-const float TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD( 0.46f );
-const Vector4 TextStyle::DEFAULT_OUTLINE_COLOR( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) ); // cannot use Color::BLACK because it may or may not be initialized yet
-const Vector2 TextStyle::DEFAULT_OUTLINE_THICKNESS( 0.51f, 0.00f );
-const Vector4 TextStyle::DEFAULT_GRADIENT_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ); // cannot use Color::WHI|TE because it may or may not be initialized yet
-const Vector2 TextStyle::DEFAULT_GRADIENT_START_POINT( 0.0f, 0.0f );
-const Vector2 TextStyle::DEFAULT_GRADIENT_END_POINT( 0.0f, 0.0f );
+class TextStyleContainer
+{
+private:
-const std::string DEFAULT_NAME;
+ // Number of bits for an index mask - increase if more attributes are added...
+ static const unsigned int PARAMETER_BITS;
+ // Set mask for this number of bits
+ static const uint64_t PARAMETER_MASK;
+
+ // Shift values for attribute indices
+ static const unsigned int COMMON_INDEX_SHIFT;
+ static const unsigned int WEIGHT_INDEX_SHIFT;
+ static const unsigned int ITALICS_INDEX_SHIFT;
+ static const unsigned int UNDERLINE_INDEX_SHIFT;
+ static const unsigned int DROP_SHADOW_INDEX_SHIFT;
+ static const unsigned int GLOW_INDEX_SHIFT;
+ static const unsigned int OUTLINE_INDEX_SHIFT;
+ static const unsigned int GRADIENT_INDEX_SHIFT;
+ static const unsigned int PARAMETER_FLAGS;
+
+ // Position in flags for attribute index
+ static const uint64_t COMMON_INDEX;
+ static const uint64_t WEIGHT_INDEX;
+ static const uint64_t ITALICS_INDEX;
+ static const uint64_t UNDERLINE_INDEX;
+ static const uint64_t DROP_SHADOW_INDEX;
+ static const uint64_t GLOW_INDEX;
+ static const uint64_t OUTLINE_INDEX;
+ static const uint64_t GRADIENT_INDEX;
+
+ // Flag positions and enables for attributes
+ static const uint64_t ITALICS_ENABLED;
+ static const uint64_t UNDERLINE_ENABLED;
+ static const uint64_t DROP_SHADOW_ENABLED;
+ static const uint64_t GLOW_ENABLED;
+ static const uint64_t OUTLINE_ENABLED;
+ static const uint64_t GRADIENT_ENABLED;
+
+ static const uint64_t FONT_NAME_EXISTS;
+ static const uint64_t FONT_STYLE_EXISTS;
+ static const uint64_t FONT_SIZE_EXISTS;
+ static const uint64_t TEXT_COLOR_EXISTS;
+ static const uint64_t COMMON_PARAMETERS_EXISTS;
+ static const uint64_t FONT_WEIGHT_EXISTS;
+ static const uint64_t SMOOTH_EDGE_EXISTS;
+ static const uint64_t SMOOTH_WEIGHT_EXISTS;
+ static const uint64_t ITALICS_EXISTS;
+ static const uint64_t UNDERLINE_EXISTS;
+ static const uint64_t DROP_SHADOW_EXISTS;
+ static const uint64_t GLOW_EXISTS;
+ static const uint64_t OUTLINE_EXISTS;
+ static const uint64_t GRADIENT_EXISTS;
+ static const uint64_t ATTRIBUTE_END;
+
+ TextStyleContainer()
+ : mFlags( 0 )
+ {
+ }
+
+ ~TextStyleContainer()
+ {
+ if( mFlags & COMMON_PARAMETERS_EXISTS )
+ {
+ StyleCommonAttributes* attrPtr = reinterpret_cast<StyleCommonAttributes*>( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) );
+ delete attrPtr;
+ }
+ if( mFlags & SMOOTH_WEIGHT_EXISTS )
+ {
+ StyleWeightAttributes* attrPtr = reinterpret_cast<StyleWeightAttributes*>( *( mParameters.Begin() + ( ( mFlags >> WEIGHT_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ delete attrPtr;
+ }
+ if( mFlags & ITALICS_EXISTS )
+ {
+ StyleItalicsAttributes* attrPtr = reinterpret_cast<StyleItalicsAttributes*>( *( mParameters.Begin() + ( ( mFlags >> ITALICS_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ delete attrPtr;
+ }
+ if( mFlags & UNDERLINE_EXISTS )
+ {
+ StyleUnderlineAttributes* attrPtr = reinterpret_cast<StyleUnderlineAttributes*>( *( mParameters.Begin() + ( ( mFlags >> UNDERLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ delete attrPtr;
+ }
+ if( mFlags & DROP_SHADOW_EXISTS )
+ {
+ StyleShadowAttributes* attrPtr = reinterpret_cast<StyleShadowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ delete attrPtr;
+ }
+ if( mFlags & GLOW_EXISTS )
+ {
+ StyleGlowAttributes* attrPtr = reinterpret_cast<StyleGlowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ delete attrPtr;
+ }
+ if( mFlags & OUTLINE_EXISTS )
+ {
+ StyleOutlineAttributes* attrPtr = reinterpret_cast<StyleOutlineAttributes*>( *( mParameters.Begin() + ( ( mFlags >> OUTLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ delete attrPtr;
+ }
+ if( mFlags & GRADIENT_EXISTS )
+ {
+ StyleGradientAttributes* attrPtr = reinterpret_cast<StyleGradientAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ delete attrPtr;
+ }
+ }
+
+ struct StyleCommonAttributes
+ {
+ StyleCommonAttributes()
+ : mFontPointSize( 0.0f )
+ {}
-struct TextStyle::Impl
-{
- Impl()
- : mFontName(),
- mFontStyle(),
- mFontPointSize( 0.f ),
- mWeight( REGULAR ),
- mTextColor( DEFAULT_TEXT_COLOR ),
- mItalics( false ),
- mUnderline( false ),
- mShadow( false ),
- mGlow( false ),
- mOutline( false ),
- mItalicsAngle( DEFAULT_ITALICS_ANGLE ),
- mUnderlineThickness( DEFAULT_UNDERLINE_THICKNESS ),
- mUnderlinePosition( DEFAULT_UNDERLINE_POSITION ),
- mShadowColor( DEFAULT_SHADOW_COLOR ),
- mShadowOffset( DEFAULT_SHADOW_OFFSET ),
- mShadowSize( DEFAULT_SHADOW_SIZE ),
- mGlowColor( DEFAULT_GLOW_COLOR ),
- mGlowIntensity( DEFAULT_GLOW_INTENSITY ),
- mSmoothEdge( DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD ),
- mOutlineColor( DEFAULT_OUTLINE_COLOR ),
- mOutlineThickness( DEFAULT_OUTLINE_THICKNESS )
- {
- }
-
- Impl( const std::string& fontName,
- const std::string& fontStyle,
- PointSize fontPointSize,
- Weight weight,
- const Vector4& textColor,
- bool italics,
- bool underline,
- bool shadow,
- bool glow,
- bool outline,
- Degree italicsAngle,
- float underlineThickness,
- float underlinePosition,
- const Vector4& shadowColor,
- const Vector2& shadowOffset,
- const float shadowSize,
- const Vector4& glowColor,
- float glowIntensity,
- float smoothEdge,
- const Vector4& outlineColor,
- const Vector2& outlineThickness )
- : mFontName( fontName ),
- mFontStyle( fontStyle ),
- mFontPointSize( fontPointSize ),
- mWeight( weight ),
- mTextColor( textColor ),
- mItalics( italics ),
- mUnderline( underline ),
- mShadow( shadow ),
- mGlow( glow ),
- mOutline( outline ),
- mItalicsAngle( italicsAngle ),
- mUnderlineThickness( underlineThickness ),
- mUnderlinePosition( underlinePosition ),
- mShadowColor( shadowColor ),
- mShadowOffset( shadowOffset ),
- mShadowSize( shadowSize ),
- mGlowColor( glowColor ),
- mGlowIntensity( glowIntensity ),
- mSmoothEdge( smoothEdge ),
- mOutlineColor( outlineColor ),
- mOutlineThickness( outlineThickness )
- {
- }
-
- std::string mFontName; ///< Font family name.
- std::string mFontStyle; ///< Font style.
- PointSize mFontPointSize; ///< Size of the font in points.
- Weight mWeight; ///< Style weight.
- Vector4 mTextColor; ///< Color of the text.
- bool mItalics:1; ///< Whether the text is in italics or not.
- bool mUnderline:1; ///< Whether the text is underlined or not.
- bool mShadow:1; ///< Whether the text has a shadow or not.
- bool mGlow:1; ///< Whether the text has a glow or not.
- bool mOutline:1; ///< Whether the text has an outline or not.
- Degree mItalicsAngle; ///< The italics angle.
- float mUnderlineThickness; ///< The underline's thickness.
- float mUnderlinePosition; ///< The underline's position.
- Vector4 mShadowColor; ///< The color of the shadow.
- Vector2 mShadowOffset; ///< The shadow offset in pixels.
- float mShadowSize; ///< The shadow size in pixels
- Vector4 mGlowColor; ///< The color of the glow.
- float mGlowIntensity; ///< Determines the amount of glow around text.
- float mSmoothEdge; ///< Specify the distance field value for the center of the text edge.
- Vector4 mOutlineColor; ///< The color of the outline.
- Vector2 mOutlineThickness; ///< The outline's thickness.
+ std::string mFontName;
+ std::string mFontStyle;
+ PointSize mFontPointSize;
+ Vector4 mTextColor;
+ };
+
+ struct StyleWeightAttributes
+ {
+ StyleWeightAttributes()
+ : mWeight( TextStyle::DEFAULT_FONT_WEIGHT ),
+ mSmoothEdge( 0.0f )
+ {}
+
+ TextStyle::Weight mWeight;
+ float mSmoothEdge;
+ };
+
+ struct StyleItalicsAttributes
+ {
+ StyleItalicsAttributes()
+ : mItalicsAngle( Degree( 0.0f ) )
+ {}
+ Degree mItalicsAngle;
+ };
+
+ struct StyleUnderlineAttributes
+ {
+ float mUnderlineThickness;
+ float mUnderlinePosition;
+ };
+
+ struct StyleShadowAttributes
+ {
+ Vector4 mShadowColor;
+ Vector2 mShadowOffset;
+ float mShadowSize;
+ };
+
+ struct StyleGlowAttributes
+ {
+ Vector4 mGlowColor;
+ float mGlowIntensity;
+ };
+
+ struct StyleOutlineAttributes
+ {
+ Vector4 mOutlineColor;
+ Vector2 mOutlineThickness;
+ };
+
+ struct StyleGradientAttributes
+ {
+ Vector4 mColor;
+ Vector2 mStartPoint;
+ Vector2 mEndPoint;
+ };
+
+ void SetCommonDefaults( StyleCommonAttributes* attr );
+ void SetFontName( const std::string& fontName );
+ void SetFontStyle( const std::string& fontStyle );
+ void SetFontPointSize( PointSize fontPointSize );
+ void SetTextColor( const Vector4& textColor );
+ void SetWeight( TextStyle::Weight weight );
+ void SetSmoothEdge( float smoothEdge );
+ void SetItalics( bool enable, Degree angle );
+ void SetUnderline( bool enable, float thickness, float position );
+ void SetShadow( bool enable, const Vector4& shadowColor, const Vector2& shadowOffset, float shadowSize );
+ void SetGlow( bool enable, const Vector4& glowColor, float glowIntensity );
+ void SetOutline( bool enable, const Vector4& outlineColor, const Vector2& outlineThickness );
+ void SetGradient( bool enable, const Vector4& color, const Vector2& startPosition, const Vector2& endPosition );
+
+ const std::string& GetFontName() const;
+ const std::string& GetFontStyle() const;
+ PointSize GetFontPointSize() const;
+ const Vector4& GetTextColor() const;
+ TextStyle::Weight GetWeight() const;
+ float GetSmoothEdge() const;
+ Degree GetItalicsAngle() const;
+ float GetUnderlineThickness() const;
+ float GetUnderlinePosition() const;
+ const Vector4& GetShadowColor() const;
+ const Vector2& GetShadowOffset() const;
+ float GetShadowSize() const;
+ const Vector4& GetGlowColor() const;
+ float GetGlowIntensity() const;
+ const Vector2& GetOutlineThickness() const;
+ const Vector4& GetOutlineColor() const;
+ const Vector4& GetGradientColor() const;
+ const Vector2& GetGradientStartPoint() const;
+ const Vector2& GetGradientEndPoint() const;
+
+ void UpdateIndex( std::size_t index );
+ void ResetFontName();
+ void ResetFontStyle();
+ void ResetFontSize();
+ void ResetTextColor();
+ void ResetFontWeight();
+ void ResetSmoothEdge();
+ void ResetItalics();
+ void ResetUnderline();
+ void ResetShadow();
+ void ResetGlow();
+ void ResetOutline();
+ void ResetGradient();
+
+ // Private and not implemented.
+ TextStyleContainer( const TextStyleContainer& );
+ TextStyleContainer& operator=( const TextStyleContainer& );
+
+ Vector< char* > mParameters; ///< container for used style parameters.
+ uint64_t mFlags; ///< flags for used attributes, packed with position in container
+ friend class TextStyle;
};
+// Number of bits for an index mask - increase if more attributes are added...
+const unsigned int TextStyleContainer::PARAMETER_BITS = 3u;
+const uint64_t ONE = 1lu;
+
+// Set mask for this number of bits
+const uint64_t TextStyleContainer::PARAMETER_MASK = ~( -1l << TextStyleContainer::PARAMETER_BITS );
+
+// Shift values for attribute indices
+const unsigned int TextStyleContainer::COMMON_INDEX_SHIFT = 0u; // starts at bit 0
+const unsigned int TextStyleContainer::WEIGHT_INDEX_SHIFT = TextStyleContainer::PARAMETER_BITS * 1; // starts at bit 3
+const unsigned int TextStyleContainer::ITALICS_INDEX_SHIFT = TextStyleContainer::PARAMETER_BITS * 2; // starts at bit 6
+const unsigned int TextStyleContainer::UNDERLINE_INDEX_SHIFT = TextStyleContainer::PARAMETER_BITS * 3; // starts at bit 9
+const unsigned int TextStyleContainer::DROP_SHADOW_INDEX_SHIFT = TextStyleContainer::PARAMETER_BITS * 4; // starts at bit 12
+const unsigned int TextStyleContainer::GLOW_INDEX_SHIFT = TextStyleContainer::PARAMETER_BITS * 5; // starts at bit 15
+const unsigned int TextStyleContainer::OUTLINE_INDEX_SHIFT = TextStyleContainer::PARAMETER_BITS * 6; // starts at bit 18
+const unsigned int TextStyleContainer::GRADIENT_INDEX_SHIFT = TextStyleContainer::PARAMETER_BITS * 7; // starts at bit 21
+const unsigned int TextStyleContainer::PARAMETER_FLAGS = TextStyleContainer::PARAMETER_BITS * 8; // 24 == 3 x 8
+
+// Position in flags for attribute index
+const uint64_t TextStyleContainer::COMMON_INDEX = 0lu; // bits 0 .. 2
+const uint64_t TextStyleContainer::WEIGHT_INDEX = TextStyleContainer::PARAMETER_MASK << TextStyleContainer::WEIGHT_INDEX_SHIFT; // bits 3 .. 5
+const uint64_t TextStyleContainer::ITALICS_INDEX = TextStyleContainer::PARAMETER_MASK << TextStyleContainer::ITALICS_INDEX_SHIFT; // bits 6 .. 8
+const uint64_t TextStyleContainer::UNDERLINE_INDEX = TextStyleContainer::PARAMETER_MASK << TextStyleContainer::UNDERLINE_INDEX_SHIFT; // bits 9 .. 11
+const uint64_t TextStyleContainer::DROP_SHADOW_INDEX = TextStyleContainer::PARAMETER_MASK << TextStyleContainer::DROP_SHADOW_INDEX_SHIFT; // bits 12 .. 14
+const uint64_t TextStyleContainer::GLOW_INDEX = TextStyleContainer::PARAMETER_MASK << TextStyleContainer::GLOW_INDEX_SHIFT; // bits 15 .. 17
+const uint64_t TextStyleContainer::OUTLINE_INDEX = TextStyleContainer::PARAMETER_MASK << TextStyleContainer::OUTLINE_INDEX_SHIFT; // bits 18 .. 20
+const uint64_t TextStyleContainer::GRADIENT_INDEX = TextStyleContainer::PARAMETER_MASK << TextStyleContainer::GRADIENT_INDEX_SHIFT; // bits 21 .. 23
+
+// Flag positions and enables for attributes
+const uint64_t TextStyleContainer::ITALICS_ENABLED = ONE << TextStyleContainer::PARAMETER_FLAGS; // bit 24
+const uint64_t TextStyleContainer::UNDERLINE_ENABLED = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 1 ); // bit 25
+const uint64_t TextStyleContainer::DROP_SHADOW_ENABLED = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 2 ); // bit 26
+const uint64_t TextStyleContainer::GLOW_ENABLED = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 3 ); // bit 27
+const uint64_t TextStyleContainer::OUTLINE_ENABLED = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 4 ); // bit 28
+const uint64_t TextStyleContainer::GRADIENT_ENABLED = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 5 ); // bit 29
+
+const uint64_t TextStyleContainer::FONT_NAME_EXISTS = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 6 ); // bit 30
+const uint64_t TextStyleContainer::FONT_STYLE_EXISTS = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 7 ); // bit 31
+const uint64_t TextStyleContainer::FONT_SIZE_EXISTS = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 8 ); // bit 32
+const uint64_t TextStyleContainer::TEXT_COLOR_EXISTS = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 9 ); // bit 33
+const uint64_t TextStyleContainer::COMMON_PARAMETERS_EXISTS = ( TextStyleContainer::FONT_NAME_EXISTS | TextStyleContainer::FONT_STYLE_EXISTS | TextStyleContainer::FONT_SIZE_EXISTS | TextStyleContainer::TEXT_COLOR_EXISTS );
+const uint64_t TextStyleContainer::FONT_WEIGHT_EXISTS = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 10 ); // bit 34
+const uint64_t TextStyleContainer::SMOOTH_EDGE_EXISTS = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 11 ); // bit 35
+const uint64_t TextStyleContainer::SMOOTH_WEIGHT_EXISTS = ( TextStyleContainer::FONT_WEIGHT_EXISTS | TextStyleContainer::SMOOTH_EDGE_EXISTS );
+const uint64_t TextStyleContainer::ITALICS_EXISTS = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 12 ); // bit 36
+const uint64_t TextStyleContainer::UNDERLINE_EXISTS = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 13 ); // bit 37
+const uint64_t TextStyleContainer::DROP_SHADOW_EXISTS = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 14 ); // bit 38
+const uint64_t TextStyleContainer::GLOW_EXISTS = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 15 ); // bit 39
+const uint64_t TextStyleContainer::OUTLINE_EXISTS = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 16 ); // bit 40
+const uint64_t TextStyleContainer::GRADIENT_EXISTS = ONE << ( TextStyleContainer::PARAMETER_FLAGS + 17 ); // bit 41
+const uint64_t TextStyleContainer::ATTRIBUTE_END = TextStyleContainer::GRADIENT_EXISTS;
+
+const Vector4 TextStyle::DEFAULT_TEXT_COLOR( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); // cannot use Color::WHITE because it may or may not be initialized yet.
+const TextStyle::Weight TextStyle::DEFAULT_FONT_WEIGHT( TextStyle::REGULAR );
+const float TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD( 0.46f );
+const Degree TextStyle::DEFAULT_ITALICS_ANGLE( 20.0f );
+const float TextStyle::DEFAULT_UNDERLINE_THICKNESS( 0.f );
+const float TextStyle::DEFAULT_UNDERLINE_POSITION( 0.f );
+const Vector4 TextStyle::DEFAULT_SHADOW_COLOR( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) ); // cannot use Color::BLACK because it may or may not be initialized yet.
+const Vector2 TextStyle::DEFAULT_SHADOW_OFFSET( 1.0f, 1.0f );
+const float TextStyle::DEFAULT_SHADOW_SIZE( 0.0f );
+const Vector4 TextStyle::DEFAULT_GLOW_COLOR( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) ); // cannot use Color::YELLOW because it may or may not be initialized yet.
+const float TextStyle::DEFAULT_GLOW_INTENSITY( 0.05f );
+const Vector4 TextStyle::DEFAULT_OUTLINE_COLOR( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) ); // cannot use Color::BLACK because it may or may not be initialized yet.
+const Vector2 TextStyle::DEFAULT_OUTLINE_THICKNESS( 0.51f, 0.00f );
+const Vector4 TextStyle::DEFAULT_GRADIENT_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ); // cannot use Color::WHITE because it may or may not be initialized yet.
+const Vector2 TextStyle::DEFAULT_GRADIENT_START_POINT( 0.0f, 0.0f );
+const Vector2 TextStyle::DEFAULT_GRADIENT_END_POINT( 0.0f, 0.0f );
+
+namespace
+{
+const std::string DEFAULT_NAME;
+const PointSize DEFAULT_FONT_POINT_SIZE( 0.f );
+} // namespace
TextStyle::TextStyle()
-: mImpl( NULL )
+: mContainer( NULL )
{
}
-TextStyle::TextStyle( const TextStyle& textStyle )
-: mImpl( NULL )
-{
-
- if ( textStyle.mImpl )
- {
- mImpl = new TextStyle::Impl( textStyle.mImpl->mFontName,
- textStyle.mImpl->mFontStyle,
- textStyle.mImpl->mFontPointSize,
- textStyle.mImpl->mWeight,
- textStyle.mImpl->mTextColor,
- textStyle.mImpl->mItalics,
- textStyle.mImpl->mUnderline,
- textStyle.mImpl->mShadow,
- textStyle.mImpl->mGlow,
- textStyle.mImpl->mOutline,
- textStyle.mImpl->mItalicsAngle,
- textStyle.mImpl->mUnderlineThickness,
- textStyle.mImpl->mUnderlinePosition,
- textStyle.mImpl->mShadowColor,
- textStyle.mImpl->mShadowOffset,
- textStyle.mImpl->mShadowSize,
- textStyle.mImpl->mGlowColor,
- textStyle.mImpl->mGlowIntensity,
- textStyle.mImpl->mSmoothEdge,
- textStyle.mImpl->mOutlineColor,
- textStyle.mImpl->mOutlineThickness );
- }
-}
TextStyle::~TextStyle()
{
- delete mImpl;
+ delete mContainer;
+}
+
+TextStyle::TextStyle( const TextStyle& textStyle )
+: mContainer( NULL )
+{
+ TextStyle::operator=( textStyle );
}
TextStyle& TextStyle::operator=( const TextStyle& textStyle )
{
- if( &textStyle != this )
- {
- // Is the source object current set to defaults?
- if ( textStyle.mImpl == NULL )
- {
- // Yes, so delete our current implementation and set to defaults (ie/ no implementation)
- delete mImpl;
- mImpl = NULL;
- return *this;
- }
-
- CreateImplementationJustInTime();
- mImpl->mFontName = textStyle.mImpl->mFontName;
- mImpl->mFontStyle = textStyle.mImpl->mFontStyle;
- mImpl->mFontPointSize = textStyle.mImpl->mFontPointSize;
- mImpl->mWeight = textStyle.mImpl->mWeight;
- mImpl->mTextColor = textStyle.mImpl->mTextColor;
- mImpl->mItalics = textStyle.mImpl->mItalics;
- mImpl->mUnderline = textStyle.mImpl->mUnderline;
- mImpl->mShadow = textStyle.mImpl->mShadow;
- mImpl->mGlow = textStyle.mImpl->mGlow;
- mImpl->mOutline = textStyle.mImpl->mOutline;
- mImpl->mItalicsAngle = textStyle.mImpl->mItalicsAngle;
- mImpl->mUnderlineThickness = textStyle.mImpl->mUnderlineThickness;
- mImpl->mUnderlinePosition = textStyle.mImpl->mUnderlinePosition;
- mImpl->mShadowColor = textStyle.mImpl->mShadowColor;
- mImpl->mShadowOffset = textStyle.mImpl->mShadowOffset;
- mImpl->mShadowSize = textStyle.mImpl->mShadowSize;
- mImpl->mGlowColor = textStyle.mImpl->mGlowColor;
- mImpl->mGlowIntensity = textStyle.mImpl->mGlowIntensity;
- mImpl->mSmoothEdge = textStyle.mImpl->mSmoothEdge;
- mImpl->mOutlineColor = textStyle.mImpl->mOutlineColor;
- mImpl->mOutlineThickness = textStyle.mImpl->mOutlineThickness;
+ if( this == &textStyle )
+ {
+ // Return 'this' if trying to assign the object itself.
+ return *this;
+ }
+
+ if ( textStyle.mContainer == NULL )
+ {
+ // If text-style to be assigned is default, delete the container to make 'this' default.
+ delete mContainer;
+ mContainer = NULL;
+ return *this;
+ }
+ else
+ {
+ int resetMask = TextStyle::NONE;
+
+ if( textStyle.IsFontNameDefault() )
+ {
+ if( !IsFontNameDefault() )
+ {
+ resetMask |= TextStyle::FONT;
+ }
+ }
+ else
+ {
+ SetFontName( textStyle.GetFontName() );
+ }
+
+ if( textStyle.IsFontStyleDefault() )
+ {
+ if( !IsFontStyleDefault() )
+ {
+ resetMask |= TextStyle::STYLE;
+ }
+ }
+ else
+ {
+ SetFontStyle( textStyle.GetFontStyle() );
+ }
+
+ if( textStyle.IsFontSizeDefault() )
+ {
+ if( !IsFontSizeDefault() )
+ {
+ resetMask |= TextStyle::SIZE;
+ }
+ }
+ else
+ {
+ SetFontPointSize( textStyle.GetFontPointSize() );
+ }
+
+ if( textStyle.IsTextColorDefault() )
+ {
+ if( !IsTextColorDefault() )
+ {
+ resetMask |= TextStyle::COLOR;
+ }
+ }
+ else
+ {
+ SetTextColor( textStyle.GetTextColor() );
+ }
+
+ if( textStyle.IsFontWeightDefault() )
+ {
+ if( !IsFontWeightDefault() )
+ {
+ resetMask |= TextStyle::WEIGHT;
+ }
+ }
+ else
+ {
+ SetWeight( textStyle.GetWeight() );
+ }
+
+ if( textStyle.IsSmoothEdgeDefault() )
+ {
+ if( !IsSmoothEdgeDefault() )
+ {
+ resetMask |= TextStyle::SMOOTH;
+ }
+ }
+ else
+ {
+ SetSmoothEdge( textStyle.GetSmoothEdge() );
+ }
+
+ if( textStyle.IsItalicsDefault() )
+ {
+ if( !IsItalicsDefault() )
+ {
+ resetMask |= TextStyle::ITALICS;
+ }
+ }
+ else
+ {
+ SetItalics( textStyle.IsItalicsEnabled(), textStyle.GetItalicsAngle() );
+ }
+
+ if( textStyle.IsUnderlineDefault() )
+ {
+ if( !IsUnderlineDefault() )
+ {
+ resetMask |= TextStyle::UNDERLINE;
+ }
+ }
+ else
+ {
+ SetUnderline( textStyle.IsUnderlineEnabled(), textStyle.GetUnderlineThickness(), textStyle.GetUnderlinePosition() );
+ }
+
+ if ( textStyle.IsShadowDefault() )
+ {
+ if( !IsShadowDefault() )
+ {
+ resetMask |= TextStyle::SHADOW;
+ }
+ }
+ else
+ {
+ SetShadow( textStyle.IsShadowEnabled(), textStyle.GetShadowColor(), textStyle.GetShadowOffset(), textStyle.GetShadowSize() );
+ }
+
+ if ( textStyle.IsGlowDefault() )
+ {
+ if( !IsGlowDefault() )
+ {
+ resetMask |= TextStyle::GLOW;
+ }
+ }
+ else
+ {
+ SetGlow( textStyle.IsGlowEnabled(), textStyle.GetGlowColor(), textStyle.GetGlowIntensity() );
+ }
+
+ if ( textStyle.IsOutlineDefault() )
+ {
+ if( !IsOutlineDefault() )
+ {
+ resetMask |= TextStyle::OUTLINE;
+ }
+ }
+ else
+ {
+ SetOutline( textStyle.IsOutlineEnabled(), textStyle.GetOutlineColor(), textStyle.GetOutlineThickness() );
+ }
+
+ if ( textStyle.IsGradientDefault() )
+ {
+ if( !IsGradientDefault() )
+ {
+ resetMask |= TextStyle::GRADIENT;
+ }
+ }
+ else
+ {
+ SetGradient( textStyle.IsGradientEnabled(), textStyle.GetGradientColor(), textStyle.GetGradientStartPoint(), textStyle.GetGradientEndPoint() );
+ }
+
+ Reset( static_cast<TextStyle::Mask>( resetMask ) );
}
return *this;
bool TextStyle::operator==( const TextStyle& textStyle ) const
{
// If both Implementations are uninitialized then return equal
- if ( mImpl == NULL && textStyle.mImpl == NULL )
+ if ( mContainer == NULL && textStyle.mContainer == NULL )
{
return true;
}
// Otherwise if either one of the Implemetations are uninitialized then return not equal
- else if ( mImpl == NULL || textStyle.mImpl == NULL )
+ else if ( mContainer == NULL || textStyle.mContainer == NULL )
+ {
+ return false;
+ }
+ // If the number of style parameters set are different or
+ // different flags are set, without taking into account the indices, then return not equal.
+ // Two equal styles can have different indices if the parameters have been set in different order.
+ else if( ( mContainer->mParameters.Size() != textStyle.mContainer->mParameters.Size() ) ||
+ ( mContainer->mFlags >> TextStyleContainer::PARAMETER_FLAGS ) != ( textStyle.mContainer->mFlags >> TextStyleContainer::PARAMETER_FLAGS ) )
+ {
+ return false;
+ }
+
+ if( ( !IsFontWeightDefault() &&
+ ( GetWeight() != textStyle.GetWeight() ) ) ||
+
+ ( !IsFontSizeDefault() &&
+ ( fabsf( GetFontPointSize() - textStyle.GetFontPointSize() ) > Math::MACHINE_EPSILON_1000 ) ) ||
+
+ ( !IsItalicsDefault() &&
+ ( GetItalicsAngle() != textStyle.GetItalicsAngle() ) ) ||
+
+ ( !IsSmoothEdgeDefault() &&
+ ( fabsf( GetSmoothEdge() - textStyle.GetSmoothEdge() ) > Math::MACHINE_EPSILON_1000 ) ) ||
+
+ ( !IsUnderlineDefault() &&
+ ( ( fabsf( GetUnderlineThickness() - textStyle.GetUnderlineThickness() ) > Math::MACHINE_EPSILON_1000 ) ||
+ ( fabsf( GetUnderlinePosition() - textStyle.GetUnderlinePosition() ) > Math::MACHINE_EPSILON_1000 ) ) ) ||
+
+ ( !IsFontNameDefault() &&
+ ( GetFontName() != textStyle.GetFontName() ) ) ||
+
+ ( !IsFontStyleDefault() &&
+ ( GetFontStyle() != textStyle.GetFontStyle() ) ) ||
+
+ ( !IsTextColorDefault() &&
+ ( GetTextColor() != textStyle.GetTextColor() ) ) ||
+
+ ( !IsGlowDefault() &&
+ ( ( fabsf( GetGlowIntensity() - textStyle.GetGlowIntensity() ) > Math::MACHINE_EPSILON_1000 ) ||
+ ( GetGlowColor() != textStyle.GetGlowColor() ) ) ) ||
+
+ ( !IsOutlineDefault() &&
+ ( ( GetOutlineThickness() != textStyle.GetOutlineThickness() ) ||
+ ( GetOutlineColor() != textStyle.GetOutlineColor() ) ) ) ||
+
+ ( !IsShadowDefault() &&
+ ( ( fabsf( GetShadowSize() - textStyle.GetShadowSize() ) > Math::MACHINE_EPSILON_1000 ) ||
+ ( GetShadowOffset() != textStyle.GetShadowOffset() ) ||
+ ( GetShadowColor() != textStyle.GetShadowColor() ) ) ) ||
+
+ ( !IsGradientDefault() &&
+ ( ( GetGradientStartPoint() != textStyle.GetGradientStartPoint() ) ||
+ ( GetGradientEndPoint() != textStyle.GetGradientEndPoint() ) ||
+ ( GetGradientColor() != textStyle.GetGradientColor() ) ) ) )
{
return false;
}
- return ( ( mImpl->mFontName == textStyle.mImpl->mFontName ) &&
- ( mImpl->mFontStyle == textStyle.mImpl->mFontStyle ) &&
- ( fabsf( mImpl->mFontPointSize - textStyle.mImpl->mFontPointSize ) < GetRangedEpsilon( mImpl->mFontPointSize, textStyle.mImpl->mFontPointSize ) ) &&
- ( mImpl->mWeight == textStyle.mImpl->mWeight ) &&
- ( mImpl->mTextColor == textStyle.mImpl->mTextColor ) &&
- ( mImpl->mItalics == textStyle.mImpl->mItalics ) &&
- ( mImpl->mUnderline == textStyle.mImpl->mUnderline ) &&
- ( mImpl->mShadow == textStyle.mImpl->mShadow ) &&
- ( mImpl->mGlow == textStyle.mImpl->mGlow ) &&
- ( mImpl->mOutline == textStyle.mImpl->mOutline ) &&
- ( mImpl->mItalicsAngle == textStyle.mImpl->mItalicsAngle ) &&
- ( fabsf( mImpl->mUnderlineThickness - textStyle.mImpl->mUnderlineThickness ) < GetRangedEpsilon( mImpl->mUnderlineThickness, textStyle.mImpl->mUnderlineThickness ) ) &&
- ( fabsf( mImpl->mUnderlinePosition - textStyle.mImpl->mUnderlinePosition ) < GetRangedEpsilon( mImpl->mUnderlinePosition, textStyle.mImpl->mUnderlinePosition ) ) &&
- ( mImpl->mShadowColor == textStyle.mImpl->mShadowColor ) &&
- ( mImpl->mShadowOffset == textStyle.mImpl->mShadowOffset ) &&
- ( fabsf( mImpl->mShadowSize - textStyle.mImpl->mShadowSize ) < GetRangedEpsilon( mImpl->mShadowSize, textStyle.mImpl->mShadowSize ) ) &&
- ( mImpl->mGlowColor == textStyle.mImpl->mGlowColor ) &&
- ( fabsf( mImpl->mGlowIntensity - textStyle.mImpl->mGlowIntensity ) < GetRangedEpsilon( mImpl->mGlowIntensity, textStyle.mImpl->mGlowIntensity ) ) &&
- ( fabsf( mImpl->mSmoothEdge - textStyle.mImpl->mSmoothEdge ) < GetRangedEpsilon( mImpl->mSmoothEdge, textStyle.mImpl->mSmoothEdge ) ) &&
- ( mImpl->mOutlineColor == textStyle.mImpl->mOutlineColor ) &&
- ( mImpl->mOutlineThickness == textStyle.mImpl->mOutlineThickness ) );
+
+ return true;
}
bool TextStyle::operator!=( const TextStyle& textStyle ) const
return !( *this == textStyle );
}
-void TextStyle::Copy( const TextStyle& textStyle, const Mask mask )
+void TextStyle::Copy( const TextStyle& textStyle, Mask mask )
{
// If we're attemping to copy ourselves then just return
if ( this == &textStyle )
}
// Check to see if we're copying a default style ?
- if ( textStyle.mImpl == NULL )
+ if ( textStyle.mContainer == NULL )
{
// Yes, so if we're coping entirely then re-create a default style, else the mask resets attributes to defaults
- if ( mImpl && mask == ALL )
+ if ( mContainer && mask == ALL )
{
- delete mImpl;
- mImpl = NULL;
+ delete mContainer;
+ mContainer = NULL;
}
else
{
- if ( mImpl )
+ if( NULL != mContainer )
{
+ int resetMask = TextStyle::NONE;
+
if( mask & FONT )
{
- mImpl->mFontName = DEFAULT_NAME;
+ resetMask |= FONT;
}
if( mask & STYLE )
{
- mImpl->mFontStyle = DEFAULT_NAME;
+ resetMask |= STYLE;
}
if( mask & SIZE )
{
- mImpl->mFontPointSize = static_cast<PointSize>( 0.f );
+ resetMask |= SIZE;
+ }
+ if( mask & COLOR )
+ {
+ resetMask |= COLOR;
}
if( mask & WEIGHT )
{
- mImpl->mWeight = REGULAR;
- mImpl->mSmoothEdge = DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD;
+ resetMask |= WEIGHT;
}
- if( mask & COLOR )
+ if( mask & SMOOTH )
{
- mImpl->mTextColor = DEFAULT_TEXT_COLOR;
+ resetMask |= SMOOTH;
}
if( mask & ITALICS )
{
- mImpl->mItalics = false;
- mImpl->mItalicsAngle = DEFAULT_ITALICS_ANGLE;
+ resetMask |= ITALICS;
}
if( mask & UNDERLINE )
{
- mImpl->mUnderline = false;
- mImpl->mUnderlineThickness = DEFAULT_UNDERLINE_THICKNESS;
- mImpl->mUnderlinePosition = DEFAULT_UNDERLINE_POSITION;
+ resetMask |= UNDERLINE;
}
if ( mask & SHADOW )
{
- mImpl->mShadow = false;
- mImpl->mShadowColor = DEFAULT_SHADOW_COLOR;
- mImpl->mShadowOffset = DEFAULT_SHADOW_OFFSET;
- mImpl->mShadowSize = DEFAULT_SHADOW_SIZE;
+ resetMask |= SHADOW;
}
if ( mask & GLOW )
{
- mImpl->mGlow = false;
- mImpl->mGlowColor = DEFAULT_GLOW_COLOR;
- mImpl->mGlowIntensity = DEFAULT_GLOW_INTENSITY;
+ resetMask |= GLOW;
}
if ( mask & OUTLINE )
{
- mImpl->mOutline = false;
- mImpl->mOutlineColor = DEFAULT_OUTLINE_COLOR;
- mImpl->mOutlineThickness = DEFAULT_OUTLINE_THICKNESS;
+ resetMask |= OUTLINE;
}
+ if ( mask & GRADIENT )
+ {
+ resetMask |= GRADIENT;
+ }
+
+ Reset( static_cast<TextStyle::Mask>( resetMask ) );
}
}
return;
}
- // Source has an implementation and so the target also needs one
- CreateImplementationJustInTime();
+ // Source has a container, so the target will also need one
+ CreateContainerJustInTime();
+
if( mask == ALL )
{
*this = textStyle;
}
else
{
+ int resetMask = TextStyle::NONE;
+
if( mask & FONT )
{
- mImpl->mFontName = textStyle.mImpl->mFontName;
+ if( textStyle.IsFontNameDefault() )
+ {
+ resetMask |= FONT;
+ }
+ else
+ {
+ SetFontName( textStyle.GetFontName() );
+ }
}
if( mask & STYLE )
{
- mImpl->mFontStyle = textStyle.mImpl->mFontStyle;
+ if( textStyle.IsFontStyleDefault() )
+ {
+ resetMask |= STYLE;
+ }
+ else
+ {
+ SetFontStyle( textStyle.GetFontStyle() );
+ }
}
if( mask & SIZE )
{
- mImpl->mFontPointSize = textStyle.mImpl->mFontPointSize;
+ if( textStyle.IsFontSizeDefault() )
+ {
+ resetMask |= SIZE;
+ }
+ else
+ {
+ SetFontPointSize( textStyle.GetFontPointSize() );
+ }
+ }
+ if( mask & COLOR )
+ {
+ if( textStyle.IsTextColorDefault() )
+ {
+ resetMask |= COLOR;
+ }
+ else
+ {
+ SetTextColor( textStyle.GetTextColor() ) ;
+ }
}
if( mask & WEIGHT )
{
- mImpl->mWeight = textStyle.mImpl->mWeight;
- mImpl->mSmoothEdge = textStyle.mImpl->mSmoothEdge;
+ if( textStyle.IsFontWeightDefault() )
+ {
+ resetMask |= WEIGHT;
+ }
+ else
+ {
+ SetWeight( textStyle.GetWeight() );
+ }
}
- if( mask & COLOR )
+ if( mask & SMOOTH )
{
- mImpl->mTextColor = textStyle.mImpl->mTextColor;
+ if( textStyle.IsSmoothEdgeDefault() )
+ {
+ resetMask |= SMOOTH;
+ }
+ else
+ {
+ SetSmoothEdge( textStyle.GetSmoothEdge() );
+ }
}
if( mask & ITALICS )
{
- mImpl->mItalics = textStyle.mImpl->mItalics;
- mImpl->mItalicsAngle = textStyle.mImpl->mItalicsAngle;
+ if( textStyle.IsItalicsDefault() )
+ {
+ resetMask |= ITALICS;
+ }
+ else
+ {
+ SetItalics( textStyle.IsItalicsEnabled(), textStyle.GetItalicsAngle() );
+ }
}
if( mask & UNDERLINE )
{
- mImpl->mUnderline = textStyle.mImpl->mUnderline;
- mImpl->mUnderlineThickness = textStyle.mImpl->mUnderlineThickness;
- mImpl->mUnderlinePosition = textStyle.mImpl->mUnderlinePosition;
+ if( textStyle.IsUnderlineDefault() )
+ {
+ resetMask |= UNDERLINE;
+ }
+ else
+ {
+ SetUnderline( textStyle.IsUnderlineEnabled(), textStyle.GetUnderlineThickness(), textStyle.GetUnderlinePosition() );
+ }
}
if ( mask & SHADOW )
{
- mImpl->mShadow = textStyle.mImpl->mShadow;
- mImpl->mShadowColor = textStyle.mImpl->mShadowColor;
- mImpl->mShadowOffset = textStyle.mImpl->mShadowOffset;
- mImpl->mShadowSize = textStyle.mImpl->mShadowSize;
+ if( textStyle.IsShadowDefault() )
+ {
+ resetMask |= SHADOW;
+ }
+ else
+ {
+ SetShadow( textStyle.IsShadowEnabled(), textStyle.GetShadowColor(), textStyle.GetShadowOffset(), textStyle.GetShadowSize() );
+ }
}
if ( mask & GLOW )
{
- mImpl->mGlow = textStyle.mImpl->mGlow;
- mImpl->mGlowColor = textStyle.mImpl->mGlowColor;
- mImpl->mGlowIntensity = textStyle.mImpl->mGlowIntensity;
+ if( textStyle.IsGlowDefault() )
+ {
+ resetMask |= GLOW;
+ }
+ else
+ {
+ SetGlow( textStyle.IsGlowEnabled(), textStyle.GetGlowColor(), textStyle.GetGlowIntensity() );
+ }
}
if ( mask & OUTLINE )
{
- mImpl->mOutline = textStyle.mImpl->mOutline;
- mImpl->mOutlineColor = textStyle.mImpl->mOutlineColor;
- mImpl->mOutlineThickness = textStyle.mImpl->mOutlineThickness;
+ if( textStyle.IsOutlineDefault() )
+ {
+ resetMask |= OUTLINE;
+ }
+ else
+ {
+ SetOutline( textStyle.IsOutlineEnabled(), textStyle.GetOutlineColor(), textStyle.GetOutlineThickness() );
+ }
+ }
+ if ( mask & GRADIENT )
+ {
+ if( textStyle.IsGradientDefault() )
+ {
+ resetMask |= GRADIENT;
+ }
+ else
+ {
+ SetGradient( textStyle.IsGradientEnabled(), textStyle.GetGradientColor(), textStyle.GetGradientStartPoint(), textStyle.GetGradientEndPoint() );
+ }
}
+
+ Reset( static_cast<TextStyle::Mask>( resetMask ) );
+ }
+}
+
+void TextStyle::Reset( Mask mask )
+{
+ if( NULL == mContainer )
+ {
+ // nothing to do if any text-style parameter is set.
+ return;
+ }
+
+ if( TextStyle::NONE == mask )
+ {
+ // nothing to do if the mask is NONE.
+ return;
+ }
+
+ // Check first if all text-style parameters are going to be reset.
+
+ // Reset all if the mask is the default (ALL).
+ bool resetAll = ALL == mask;
+
+ if( !resetAll )
+ {
+ resetAll = true;
+
+ // Checks if a style parameter is set in the style but is not in the mask.
+ if( ( mContainer->mFlags & TextStyleContainer::FONT_NAME_EXISTS ) && !( mask & FONT ) )
+ {
+ resetAll = false;
+ }
+ else if( ( mContainer->mFlags & TextStyleContainer::FONT_STYLE_EXISTS ) && !( mask & STYLE ) )
+ {
+ resetAll = false;
+ }
+ else if( ( mContainer->mFlags & TextStyleContainer::FONT_SIZE_EXISTS ) && !( mask & SIZE ) )
+ {
+ resetAll = false;
+ }
+ else if( ( mContainer->mFlags & TextStyleContainer::TEXT_COLOR_EXISTS ) && !( mask & COLOR ) )
+ {
+ resetAll = false;
+ }
+ else if( ( mContainer->mFlags & TextStyleContainer::FONT_WEIGHT_EXISTS ) && !( mask & WEIGHT ) )
+ {
+ resetAll = false;
+ }
+ else if( ( mContainer->mFlags & TextStyleContainer::SMOOTH_EDGE_EXISTS ) && !( mask & SMOOTH ) )
+ {
+ resetAll = false;
+ }
+ else if( ( mContainer->mFlags & TextStyleContainer::ITALICS_EXISTS ) && !( mask & ITALICS ) )
+ {
+ resetAll = false;
+ }
+ else if( ( mContainer->mFlags & TextStyleContainer::UNDERLINE_EXISTS ) && !( mask & UNDERLINE ) )
+ {
+ resetAll = false;
+ }
+ else if( ( mContainer->mFlags & TextStyleContainer::DROP_SHADOW_EXISTS ) && !( mask & SHADOW ) )
+ {
+ resetAll = false;
+ }
+ else if( ( mContainer->mFlags & TextStyleContainer::GLOW_EXISTS ) && !( mask & GLOW ) )
+ {
+ resetAll = false;
+ }
+ else if( ( mContainer->mFlags & TextStyleContainer::OUTLINE_EXISTS ) && !( mask & OUTLINE ) )
+ {
+ resetAll = false;
+ }
+ else if( ( mContainer->mFlags & TextStyleContainer::GRADIENT_EXISTS ) && !( mask & GRADIENT ) )
+ {
+ resetAll = false;
+ }
+ }
+
+ if( resetAll )
+ {
+ // delete the container if all text-style parametes are reset.
+ delete mContainer;
+ mContainer = NULL;
+
+ return;
+ }
+
+ if( mask & FONT )
+ {
+ mContainer->ResetFontName();
+ }
+ if( mask & STYLE )
+ {
+ mContainer->ResetFontStyle();
+ }
+ if( mask & SIZE )
+ {
+ mContainer->ResetFontSize();
+ }
+ if( mask & COLOR )
+ {
+ mContainer->ResetTextColor();
+ }
+ if( mask & WEIGHT )
+ {
+ mContainer->ResetFontWeight();
+ }
+ if( mask & SMOOTH )
+ {
+ mContainer->ResetSmoothEdge();
+ }
+ if( mask & ITALICS )
+ {
+ mContainer->ResetItalics();
+ }
+ if( mask & UNDERLINE )
+ {
+ mContainer->ResetUnderline();
+ }
+ if ( mask & SHADOW )
+ {
+ mContainer->ResetShadow();
+ }
+ if ( mask & GLOW )
+ {
+ mContainer->ResetGlow();
+ }
+ if ( mask & OUTLINE )
+ {
+ mContainer->ResetOutline();
+ }
+ if ( mask & GRADIENT )
+ {
+ mContainer->ResetGradient();
+ }
+}
+
+const std::string& TextStyle::GetFontName() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetFontName();
+ }
+ else
+ {
+ return DEFAULT_NAME;
+ }
+}
+
+void TextStyle::SetFontName( const std::string& fontName )
+{
+ CreateContainerJustInTime();
+ mContainer->SetFontName( fontName );
+}
+
+const std::string& TextStyle::GetFontStyle() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetFontStyle();
+ }
+ else
+ {
+ return DEFAULT_NAME;
+ }
+}
+
+void TextStyle::SetFontStyle( const std::string& fontStyle )
+{
+ CreateContainerJustInTime();
+ mContainer->SetFontStyle( fontStyle );
+}
+
+PointSize TextStyle::GetFontPointSize() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetFontPointSize();
+ }
+ else
+ {
+ return DEFAULT_FONT_POINT_SIZE;
+ }
+}
+
+void TextStyle::SetFontPointSize( PointSize fontPointSize )
+{
+ CreateContainerJustInTime();
+ mContainer->SetFontPointSize( fontPointSize );
+}
+
+const Vector4& TextStyle::GetTextColor() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetTextColor();
+ }
+ else
+ {
+ return DEFAULT_TEXT_COLOR;
+ }
+}
+
+void TextStyle::SetTextColor( const Vector4& textColor )
+{
+ CreateContainerJustInTime();
+ mContainer->SetTextColor( textColor );
+}
+
+TextStyle::Weight TextStyle::GetWeight() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetWeight();
+ }
+ else
+ {
+ return TextStyle::DEFAULT_FONT_WEIGHT;
+ }
+}
+
+void TextStyle::SetWeight( TextStyle::Weight weight )
+{
+ CreateContainerJustInTime();
+ mContainer->SetWeight( weight );
+}
+
+float TextStyle::GetSmoothEdge() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetSmoothEdge();
+ }
+ else
+ {
+ return DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD;
+ }
+}
+
+void TextStyle::SetSmoothEdge( float smoothEdge )
+{
+ CreateContainerJustInTime();
+ mContainer->SetSmoothEdge( smoothEdge );
+}
+
+bool TextStyle::IsItalicsEnabled() const
+{
+ if ( mContainer )
+ {
+ return ( ( mContainer->mFlags & TextStyleContainer::ITALICS_ENABLED ) != 0 );
+ }
+ else
+ {
+ return false;
+ }
+}
+
+Degree TextStyle::GetItalicsAngle() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetItalicsAngle();
+ }
+ else
+ {
+ return DEFAULT_ITALICS_ANGLE;
+ }
+}
+
+void TextStyle::SetItalics( bool enable, Degree angle )
+{
+ CreateContainerJustInTime();
+ mContainer->SetItalics( enable, angle );
+}
+
+bool TextStyle::GetItalics() const
+{
+ // Deprecated.
+ return IsItalicsEnabled();
+}
+
+void TextStyle::SetItalics( bool italics )
+{
+ // Deprecated
+ CreateContainerJustInTime();
+ mContainer->SetItalics( italics, GetItalicsAngle() );
+}
+
+void TextStyle::SetItalicsAngle( Degree angle )
+{
+ // Deprecated
+ CreateContainerJustInTime();
+ mContainer->SetItalics( IsItalicsEnabled(), angle );
+}
+
+bool TextStyle::IsUnderlineEnabled() const
+{
+ if ( mContainer )
+ {
+ return ( ( mContainer->mFlags & TextStyleContainer::UNDERLINE_ENABLED ) != 0 );
+ }
+ else
+ {
+ return false;
+ }
+}
+
+float TextStyle::GetUnderlineThickness() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetUnderlineThickness();
+ }
+ else
+ {
+ return DEFAULT_UNDERLINE_THICKNESS;
+ }
+}
+
+float TextStyle::GetUnderlinePosition() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetUnderlinePosition();
+ }
+ else
+ {
+ return DEFAULT_UNDERLINE_POSITION;
+ }
+}
+
+void TextStyle::SetUnderline( bool enable, float thickness, float position )
+{
+ CreateContainerJustInTime();
+ mContainer->SetUnderline( enable, thickness, position );
+}
+
+bool TextStyle::GetUnderline() const
+{
+ // Deprecated
+ return IsUnderlineEnabled();
+}
+
+void TextStyle::SetUnderline( bool underline )
+{
+ // Deprecated
+ CreateContainerJustInTime();
+ mContainer->SetUnderline( underline, GetUnderlineThickness(), GetUnderlinePosition() );
+}
+
+void TextStyle::SetUnderlineThickness( float thickness )
+{
+ // Deprecated.
+ CreateContainerJustInTime();
+ mContainer->SetUnderline( IsUnderlineEnabled(), thickness, GetUnderlinePosition() );
+}
+
+void TextStyle::SetUnderlinePosition( float position )
+{
+ // Deprecated.
+ CreateContainerJustInTime();
+ mContainer->SetUnderline( IsUnderlineEnabled(), GetUnderlineThickness(), position );
+}
+
+bool TextStyle::IsShadowEnabled() const
+{
+ if ( mContainer )
+ {
+ return ( ( mContainer->mFlags & TextStyleContainer::DROP_SHADOW_ENABLED ) != 0 );
+ }
+ else
+ {
+ return false;
+ }
+}
+
+const Vector4& TextStyle::GetShadowColor() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetShadowColor();
+ }
+ else
+ {
+ return DEFAULT_SHADOW_COLOR;
+ }
+}
+
+const Vector2& TextStyle::GetShadowOffset() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetShadowOffset();
+ }
+ else
+ {
+ return DEFAULT_SHADOW_OFFSET;
+ }
+}
+
+float TextStyle::GetShadowSize() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetShadowSize();
+ }
+ else
+ {
+ return DEFAULT_SHADOW_SIZE;
+ }
+}
+
+void TextStyle::SetShadow( bool enabled, const Vector4& shadowColor, const Vector2& shadowOffset, float shadowSize )
+{
+ CreateContainerJustInTime();
+ mContainer->SetShadow( enabled, shadowColor, shadowOffset, shadowSize );
+}
+
+bool TextStyle::GetShadow() const
+{
+ // Deprecated
+ return IsShadowEnabled();
+}
+
+bool TextStyle::IsGlowEnabled() const
+{
+ if ( mContainer )
+ {
+ return ( ( mContainer->mFlags & TextStyleContainer::GLOW_ENABLED ) != 0 );
+ }
+ else
+ {
+ return false;
+ }
+}
+
+const Vector4& TextStyle::GetGlowColor() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetGlowColor();
+ }
+ else
+ {
+ return DEFAULT_GLOW_COLOR;
+ }
+}
+
+float TextStyle::GetGlowIntensity() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetGlowIntensity();
+ }
+ else
+ {
+ return DEFAULT_GLOW_INTENSITY;
+ }
+}
+
+void TextStyle::SetGlow( bool enabled, const Vector4& glowColor, float glowIntensity )
+{
+ CreateContainerJustInTime();
+ mContainer->SetGlow( enabled, glowColor, glowIntensity );
+}
+
+bool TextStyle::GetGlow() const
+{
+ // Deprecated
+ return IsGlowEnabled();
+}
+
+bool TextStyle::IsOutlineEnabled() const
+{
+ if ( mContainer )
+ {
+ return ( ( mContainer->mFlags & TextStyleContainer::OUTLINE_ENABLED ) != 0 );
+ }
+ else
+ {
+ return false;
+ }
+}
+
+const Vector2& TextStyle::GetOutlineThickness() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetOutlineThickness();
+ }
+ else
+ {
+ return DEFAULT_OUTLINE_THICKNESS;
+ }
+}
+
+const Vector4& TextStyle::GetOutlineColor() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetOutlineColor();
+ }
+ else
+ {
+ return DEFAULT_OUTLINE_COLOR;
+ }
+}
+
+void TextStyle::SetOutline( bool enabled, const Vector4& outlineColor, const Vector2& outlineThickness )
+{
+ CreateContainerJustInTime();
+ mContainer->SetOutline( enabled, outlineColor, outlineThickness );
+}
+
+bool TextStyle::GetOutline() const
+{
+ // Deprecated
+ return IsOutlineEnabled();
+}
+
+bool TextStyle::IsGradientEnabled() const
+{
+ if ( mContainer )
+ {
+ return ( ( mContainer->mFlags & TextStyleContainer::GRADIENT_ENABLED ) != 0 );
+ }
+ else
+ {
+ return false;
+ }
+}
+
+const Vector4& TextStyle::GetGradientColor() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetGradientColor();
+ }
+ else
+ {
+ return DEFAULT_GRADIENT_COLOR;
+ }
+}
+
+const Vector2& TextStyle::GetGradientStartPoint() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetGradientStartPoint();
+ }
+ else
+ {
+ return DEFAULT_GRADIENT_START_POINT;
+ }
+}
+
+const Vector2& TextStyle::GetGradientEndPoint() const
+{
+ if ( mContainer )
+ {
+ return mContainer->GetGradientEndPoint();
+ }
+ else
+ {
+ return DEFAULT_GRADIENT_END_POINT;
+ }
+}
+
+void TextStyle::SetGradient( bool enabled, const Vector4& color, const Vector2& startPoint, const Vector2& endPoint )
+{
+ CreateContainerJustInTime();
+ mContainer->SetGradient( enabled, color, startPoint, endPoint );
+}
+
+bool TextStyle::IsFontNameDefault() const
+{
+ if( mContainer )
+ {
+ return( ( mContainer->mFlags & TextStyleContainer::FONT_NAME_EXISTS ) == 0 );
+ }
+ else
+ {
+ return true;
+ }
+}
+
+bool TextStyle::IsFontStyleDefault() const
+{
+ if( mContainer )
+ {
+ return( ( mContainer->mFlags & TextStyleContainer::FONT_STYLE_EXISTS ) == 0 );
+ }
+ else
+ {
+ return true;
+ }
+}
+
+bool TextStyle::IsFontSizeDefault() const
+{
+ if( mContainer )
+ {
+ return( ( mContainer->mFlags & TextStyleContainer::FONT_SIZE_EXISTS ) == 0 );
+ }
+ else
+ {
+ return true;
+ }
+}
+
+bool TextStyle::IsTextColorDefault() const
+{
+ if( mContainer )
+ {
+ return( ( mContainer->mFlags & TextStyleContainer::TEXT_COLOR_EXISTS ) == 0 );
+ }
+ else
+ {
+ return true;
+ }
+}
+
+bool TextStyle::IsFontWeightDefault() const
+{
+ if( mContainer )
+ {
+ return( ( mContainer->mFlags & TextStyleContainer::FONT_WEIGHT_EXISTS ) == 0 );
+ }
+ else
+ {
+ return true;
+ }
+}
+
+bool TextStyle::IsSmoothEdgeDefault() const
+{
+ if( mContainer )
+ {
+ return ( ( mContainer->mFlags & TextStyleContainer::SMOOTH_EDGE_EXISTS ) == 0 );
+ }
+ else
+ {
+ return true;
+ }
+}
+
+bool TextStyle::IsItalicsDefault() const
+{
+ if( mContainer )
+ {
+ return( ( mContainer->mFlags & TextStyleContainer::ITALICS_EXISTS ) == 0 );
+ }
+ else
+ {
+ return true;
+ }
+}
+
+bool TextStyle::IsUnderlineDefault() const
+{
+ if( mContainer )
+ {
+ return( ( mContainer->mFlags & TextStyleContainer::UNDERLINE_EXISTS ) == 0 );
+ }
+ else
+ {
+ return true;
+ }
+}
+
+bool TextStyle::IsShadowDefault() const
+{
+ if( mContainer )
+ {
+ return( ( mContainer->mFlags & TextStyleContainer::DROP_SHADOW_EXISTS ) == 0 );
+ }
+ else
+ {
+ return true;
+ }
+}
+
+bool TextStyle::IsGlowDefault() const
+{
+ if( mContainer )
+ {
+ return( ( mContainer->mFlags & TextStyleContainer::GLOW_EXISTS ) == 0 );
+ }
+ else
+ {
+ return true;
+ }
+}
+
+bool TextStyle::IsOutlineDefault() const
+{
+ if( mContainer )
+ {
+ return( ( mContainer->mFlags & TextStyleContainer::OUTLINE_EXISTS ) == 0 );
+ }
+ else
+ {
+ return true;
+ }
+}
+
+bool TextStyle::IsGradientDefault() const
+{
+ if( mContainer )
+ {
+ return( ( mContainer->mFlags & TextStyleContainer::GRADIENT_EXISTS ) == 0 );
+ }
+ else
+ {
+ return true;
+ }
+}
+
+//--------------------------------------------------------------
+
+void TextStyle::CreateContainerJustInTime()
+{
+ if ( !mContainer )
+ {
+ mContainer = new TextStyleContainer;
+ }
+}
+
+//--------------------------------------------------------------
+
+void TextStyleContainer::SetCommonDefaults( StyleCommonAttributes* attr )
+{
+ attr->mFontName = DEFAULT_NAME;
+ attr->mFontStyle = DEFAULT_NAME;
+ attr->mFontPointSize = DEFAULT_FONT_POINT_SIZE;
+ attr->mTextColor = TextStyle::DEFAULT_TEXT_COLOR;
+}
+
+void TextStyleContainer::SetFontName( const std::string& fontName )
+{
+ if ( mFlags & COMMON_PARAMETERS_EXISTS )
+ {
+ StyleCommonAttributes* attrPtr = reinterpret_cast<StyleCommonAttributes*>( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) );
+ attrPtr->mFontName = fontName;
+ mFlags |= FONT_NAME_EXISTS;
+ }
+ else
+ {
+ StyleCommonAttributes* attr = new StyleCommonAttributes();
+ SetCommonDefaults( attr );
+ attr->mFontName = fontName;
+ mFlags |= ( mFlags & ~COMMON_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) | FONT_NAME_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
+ }
+}
+
+void TextStyleContainer::SetFontStyle( const std::string& fontStyle )
+{
+ if ( mFlags & COMMON_PARAMETERS_EXISTS )
+ {
+ StyleCommonAttributes* attrPtr = reinterpret_cast<StyleCommonAttributes*>( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) );
+ attrPtr->mFontStyle = fontStyle;
+ mFlags |= FONT_STYLE_EXISTS;
+ }
+ else
+ {
+ StyleCommonAttributes* attr = new StyleCommonAttributes();
+ SetCommonDefaults( attr );
+ attr->mFontStyle = fontStyle;
+ mFlags |= ( mFlags & ~COMMON_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) | FONT_STYLE_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
+ }
+}
+
+void TextStyleContainer::SetFontPointSize( PointSize fontPointSize )
+{
+ if ( mFlags & COMMON_PARAMETERS_EXISTS )
+ {
+ StyleCommonAttributes* attrPtr = reinterpret_cast<StyleCommonAttributes*>( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) );
+ attrPtr->mFontPointSize = fontPointSize;
+ mFlags |= FONT_SIZE_EXISTS;
+ }
+ else
+ {
+ StyleCommonAttributes* attr = new StyleCommonAttributes();
+ SetCommonDefaults( attr );
+ attr->mFontPointSize = fontPointSize;
+ mFlags |= ( mFlags & ~COMMON_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) | FONT_SIZE_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
+ }
+}
+
+void TextStyleContainer::SetTextColor( const Vector4& textColor )
+{
+ if ( mFlags & COMMON_PARAMETERS_EXISTS )
+ {
+ StyleCommonAttributes* attrPtr = reinterpret_cast<StyleCommonAttributes*>( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) );
+ attrPtr->mTextColor = textColor;
+ mFlags |= TEXT_COLOR_EXISTS;
+ }
+ else
+ {
+ StyleCommonAttributes* attr = new StyleCommonAttributes();
+ SetCommonDefaults( attr );
+ attr->mTextColor = textColor;
+ mFlags |= ( mFlags & ~COMMON_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) | TEXT_COLOR_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
+ }
+}
+
+void TextStyleContainer::SetWeight( TextStyle::Weight weight )
+{
+ if ( mFlags & SMOOTH_WEIGHT_EXISTS )
+ {
+ StyleWeightAttributes* attrPtr = reinterpret_cast<StyleWeightAttributes*>( *( mParameters.Begin() + ( ( mFlags >> WEIGHT_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ attrPtr->mWeight = weight;
+ mFlags |= FONT_WEIGHT_EXISTS;
+ }
+ else
+ {
+ StyleWeightAttributes* attr = new StyleWeightAttributes();
+ attr->mSmoothEdge = TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD;
+ attr->mWeight = weight;
+ mFlags |= ( ( mFlags & ~WEIGHT_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << WEIGHT_INDEX_SHIFT ) | FONT_WEIGHT_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
+ }
+}
+
+void TextStyleContainer::SetSmoothEdge( float smoothEdge )
+{
+ if ( mFlags & SMOOTH_WEIGHT_EXISTS )
+ {
+ StyleWeightAttributes* attrPtr = reinterpret_cast<StyleWeightAttributes*>( *( mParameters.Begin() + ( ( mFlags >> WEIGHT_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ attrPtr->mSmoothEdge = smoothEdge;
+ mFlags |= SMOOTH_EDGE_EXISTS;
+ }
+ else
+ {
+ StyleWeightAttributes* attr = new StyleWeightAttributes();
+ attr->mSmoothEdge = smoothEdge;
+ attr->mWeight = TextStyle::DEFAULT_FONT_WEIGHT;
+ mFlags |= ( ( mFlags & ~WEIGHT_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << WEIGHT_INDEX_SHIFT ) | SMOOTH_EDGE_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
+ }
+}
+
+void TextStyleContainer::SetItalics( bool enable, Degree angle )
+{
+ if ( mFlags & ITALICS_EXISTS )
+ {
+ StyleItalicsAttributes* attrPtr = reinterpret_cast<StyleItalicsAttributes*>( *( mParameters.Begin() + ( ( mFlags >> ITALICS_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ attrPtr->mItalicsAngle = angle;
+ }
+ else
+ {
+ StyleItalicsAttributes* attr = new StyleItalicsAttributes();
+ attr->mItalicsAngle = angle;
+ mFlags |= ( ( mFlags & ~ITALICS_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << ITALICS_INDEX_SHIFT ) | ITALICS_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
+ }
+
+ if( enable )
+ {
+ mFlags |= ITALICS_ENABLED;
+ }
+ else
+ {
+ mFlags &= ~ITALICS_ENABLED;
+ }
+}
+
+void TextStyleContainer::SetUnderline( bool enable, float thickness, float position )
+{
+ if ( mFlags & UNDERLINE_EXISTS )
+ {
+ StyleUnderlineAttributes* attrPtr = reinterpret_cast<StyleUnderlineAttributes*>( *( mParameters.Begin() + ( ( mFlags >> UNDERLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ attrPtr->mUnderlineThickness = thickness;
+ attrPtr->mUnderlinePosition = position;
+ }
+ else
+ {
+ StyleUnderlineAttributes* attr = new StyleUnderlineAttributes();
+ attr->mUnderlineThickness = thickness;
+ attr->mUnderlinePosition = position;
+ mFlags |= ( ( mFlags & ~UNDERLINE_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << UNDERLINE_INDEX_SHIFT ) | UNDERLINE_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
+ }
+
+ if( enable )
+ {
+ mFlags |= UNDERLINE_ENABLED;
+ }
+ else
+ {
+ mFlags &= ~UNDERLINE_ENABLED;
+ }
+}
+
+void TextStyleContainer::SetShadow( bool enable, const Vector4& shadowColor, const Vector2& shadowOffset, float shadowSize )
+{
+ if ( mFlags & DROP_SHADOW_EXISTS )
+ {
+ StyleShadowAttributes* attrPtr = reinterpret_cast<StyleShadowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ attrPtr->mShadowColor = shadowColor;
+ attrPtr->mShadowOffset = shadowOffset;
+ attrPtr->mShadowSize = shadowSize;
+ }
+ else
+ {
+ StyleShadowAttributes* attr = new StyleShadowAttributes();
+ attr->mShadowColor = shadowColor;
+ attr->mShadowOffset = shadowOffset;
+ attr->mShadowSize = shadowSize;
+ mFlags |= ( ( mFlags & ~DROP_SHADOW_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << DROP_SHADOW_INDEX_SHIFT ) | DROP_SHADOW_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
+ }
+
+ if( enable )
+ {
+ mFlags |= DROP_SHADOW_ENABLED;
+ }
+ else
+ {
+ mFlags &= ~DROP_SHADOW_ENABLED;
+ }
+}
+
+void TextStyleContainer::SetGlow( bool enable, const Vector4& glowColor, float glowIntensity )
+{
+ if ( mFlags & GLOW_EXISTS )
+ {
+ StyleGlowAttributes* attrPtr = reinterpret_cast<StyleGlowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ attrPtr->mGlowColor = glowColor;
+ attrPtr->mGlowIntensity = glowIntensity;
+ }
+ else
+ {
+ StyleGlowAttributes* attr = new StyleGlowAttributes();
+ attr->mGlowColor = glowColor;
+ attr->mGlowIntensity = glowIntensity;
+ mFlags |= ( ( mFlags & ~GLOW_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << GLOW_INDEX_SHIFT ) | GLOW_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
+ }
+
+ if( enable )
+ {
+ mFlags |= GLOW_ENABLED;
+ }
+ else
+ {
+ mFlags &= ~GLOW_ENABLED;
+ }
+}
+
+void TextStyleContainer::SetOutline( bool enable, const Vector4& outlineColor, const Vector2& outlineThickness )
+{
+ if ( mFlags & OUTLINE_EXISTS )
+ {
+ StyleOutlineAttributes* attrPtr = reinterpret_cast<StyleOutlineAttributes*>( *( mParameters.Begin() + ( ( mFlags >> OUTLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ attrPtr->mOutlineColor = outlineColor;
+ attrPtr->mOutlineThickness = outlineThickness;
+ }
+ else
+ {
+ StyleOutlineAttributes* attr = new StyleOutlineAttributes();
+ attr->mOutlineColor = outlineColor;
+ attr->mOutlineThickness = outlineThickness;
+ mFlags |= ( ( mFlags & ~OUTLINE_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << OUTLINE_INDEX_SHIFT ) | OUTLINE_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
}
-}
-const std::string& TextStyle::GetFontName() const
-{
- if ( !mImpl )
+ if( enable )
{
- return DEFAULT_NAME;
+ mFlags |= OUTLINE_ENABLED;
}
else
{
- return mImpl->mFontName;
+ mFlags &= ~OUTLINE_ENABLED;
}
}
-void TextStyle::SetFontName( const std::string& fontName )
+void TextStyleContainer::SetGradient( bool enable, const Vector4& color, const Vector2& startPoint, const Vector2& endPoint )
{
- CreateImplementationJustInTime();
- mImpl->mFontName = fontName;
-}
+ if ( mFlags & GRADIENT_EXISTS )
+ {
+ StyleGradientAttributes* attrPtr = reinterpret_cast<StyleGradientAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ attrPtr->mColor = color;
+ attrPtr->mStartPoint = startPoint;
+ attrPtr->mEndPoint = endPoint;
+ }
+ else
+ {
+ StyleGradientAttributes* attr = new StyleGradientAttributes();
+ attr->mColor = color;
+ attr->mStartPoint = startPoint;
+ attr->mEndPoint = endPoint;
+ mFlags |= ( ( mFlags & ~GRADIENT_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << GRADIENT_INDEX_SHIFT ) | GRADIENT_EXISTS );
+ mParameters.PushBack( reinterpret_cast<char*>( attr ) );
+ }
-const std::string& TextStyle::GetFontStyle() const
-{
- if ( !mImpl )
+ if( enable )
{
- return DEFAULT_NAME;
+ mFlags |= GRADIENT_ENABLED;
}
else
{
- return mImpl->mFontStyle;
+ mFlags &= ~GRADIENT_ENABLED;
}
}
-void TextStyle::SetFontStyle( const std::string& fontStyle )
+//-----------------------------------
+
+const std::string& TextStyleContainer::GetFontName() const
{
- CreateImplementationJustInTime();
- mImpl->mFontStyle = fontStyle;
+ if ( mFlags & FONT_NAME_EXISTS )
+ {
+ const StyleCommonAttributes* attrPtr = reinterpret_cast<StyleCommonAttributes*>( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) );
+ return attrPtr->mFontName;
+ }
+ else
+ {
+ return DEFAULT_NAME;
+ }
}
-PointSize TextStyle::GetFontPointSize() const
+const std::string& TextStyleContainer::GetFontStyle() const
{
- if ( !mImpl )
+ if ( mFlags & FONT_STYLE_EXISTS )
{
- return static_cast<PointSize>( 0.f );
+ const StyleCommonAttributes* attrPtr = reinterpret_cast<StyleCommonAttributes*>( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) );
+ return attrPtr->mFontStyle;
}
else
{
- return mImpl->mFontPointSize;
+ return DEFAULT_NAME;
}
}
-void TextStyle::SetFontPointSize( PointSize fontPointSize )
+PointSize TextStyleContainer::GetFontPointSize() const
{
- CreateImplementationJustInTime();
- mImpl->mFontPointSize = fontPointSize;
+ if ( mFlags & FONT_SIZE_EXISTS )
+ {
+ const StyleCommonAttributes* attrPtr = reinterpret_cast<StyleCommonAttributes*>( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) );
+ return attrPtr->mFontPointSize;
+ }
+ else
+ {
+ return ( static_cast<PointSize>( 0.f ) );
+ }
}
-TextStyle::Weight TextStyle::GetWeight() const
+const Vector4& TextStyleContainer::GetTextColor() const
{
- if ( !mImpl )
+ if ( mFlags & TEXT_COLOR_EXISTS )
{
- return REGULAR;
+ const StyleCommonAttributes* attrPtr = reinterpret_cast<StyleCommonAttributes*>( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) );
+ return attrPtr->mTextColor;
}
else
{
- return mImpl->mWeight ;
+ return TextStyle::DEFAULT_TEXT_COLOR;
}
}
-void TextStyle::SetWeight( TextStyle::Weight weight )
+TextStyle::Weight TextStyleContainer::GetWeight() const
{
- CreateImplementationJustInTime();
- mImpl->mWeight = weight;
+ if ( mFlags & FONT_WEIGHT_EXISTS )
+ {
+ const StyleWeightAttributes* attrPtr = reinterpret_cast<StyleWeightAttributes*>( *( mParameters.Begin() + ( ( mFlags >> WEIGHT_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mWeight;
+ }
+ else
+ {
+ return TextStyle::DEFAULT_FONT_WEIGHT;
+ }
}
-const Vector4& TextStyle::GetTextColor() const
+float TextStyleContainer::GetSmoothEdge() const
{
- if ( !mImpl )
+ if ( mFlags & SMOOTH_EDGE_EXISTS )
{
- return DEFAULT_TEXT_COLOR;
+ const StyleWeightAttributes* attrPtr = reinterpret_cast<StyleWeightAttributes*>( *( mParameters.Begin() + ( ( mFlags >> WEIGHT_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mSmoothEdge;
}
else
{
- return mImpl->mTextColor;
+ return TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD;
}
}
-void TextStyle::SetTextColor( const Vector4& textColor )
+Degree TextStyleContainer::GetItalicsAngle() const
{
- CreateImplementationJustInTime();
- mImpl->mTextColor = textColor;
+ if ( mFlags & ITALICS_EXISTS )
+ {
+ const StyleItalicsAttributes* attrPtr = reinterpret_cast<StyleItalicsAttributes*>( *( mParameters.Begin() +( ( mFlags >> ITALICS_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mItalicsAngle;
+ }
+ else
+ {
+ return TextStyle::DEFAULT_ITALICS_ANGLE;
+ }
}
-bool TextStyle::GetItalics() const
+float TextStyleContainer::GetUnderlineThickness() const
{
- if ( !mImpl )
+ if ( mFlags & UNDERLINE_EXISTS )
{
- return false;
+ const StyleUnderlineAttributes* attrPtr = reinterpret_cast<StyleUnderlineAttributes*>( *( mParameters.Begin() + ( ( mFlags >> UNDERLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mUnderlineThickness;
+ }
+ else
+ {
+ return TextStyle::DEFAULT_UNDERLINE_THICKNESS;
}
- return mImpl->mItalics;
}
-void TextStyle::SetItalics( bool italics )
+float TextStyleContainer::GetUnderlinePosition() const
{
- CreateImplementationJustInTime();
- mImpl->mItalics = italics;
+ if ( mFlags & UNDERLINE_EXISTS )
+ {
+ const StyleUnderlineAttributes* attrPtr = reinterpret_cast<StyleUnderlineAttributes*>( *( mParameters.Begin() +( ( mFlags >> UNDERLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mUnderlinePosition;
+ }
+ else
+ {
+ return TextStyle::DEFAULT_UNDERLINE_POSITION;
+ }
}
-Degree TextStyle::GetItalicsAngle() const
+const Vector4& TextStyleContainer::GetShadowColor() const
{
- if ( !mImpl )
+ if ( mFlags & DROP_SHADOW_EXISTS )
{
- return DEFAULT_ITALICS_ANGLE;
+ const StyleShadowAttributes* attrPtr = reinterpret_cast<StyleShadowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mShadowColor;
}
else
{
- return mImpl->mItalicsAngle;
+ return TextStyle::DEFAULT_SHADOW_COLOR;
}
}
-void TextStyle::SetItalicsAngle( Degree angle )
+const Vector2& TextStyleContainer::GetShadowOffset() const
{
- CreateImplementationJustInTime();
- mImpl->mItalicsAngle = angle;
+ if ( mFlags & DROP_SHADOW_EXISTS )
+ {
+ const StyleShadowAttributes* attrPtr = reinterpret_cast<StyleShadowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mShadowOffset;
+ }
+ else
+ {
+ return TextStyle::DEFAULT_SHADOW_OFFSET;
+ }
}
-bool TextStyle::GetUnderline() const
+float TextStyleContainer::GetShadowSize() const
{
- if ( !mImpl )
+ if ( mFlags & DROP_SHADOW_EXISTS )
{
- return false;
+ const StyleShadowAttributes* attrPtr = reinterpret_cast<StyleShadowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mShadowSize;
}
else
{
- return mImpl->mUnderline;
+ return TextStyle::DEFAULT_SHADOW_SIZE;
}
}
-void TextStyle::SetUnderline( bool underline )
+const Vector4& TextStyleContainer::GetGlowColor() const
{
- CreateImplementationJustInTime();
- mImpl->mUnderline = underline;
+ if ( mFlags & GLOW_EXISTS )
+ {
+ const StyleGlowAttributes* attrPtr = reinterpret_cast<StyleGlowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mGlowColor;
+ }
+ else
+ {
+ return TextStyle::DEFAULT_GLOW_COLOR;
+ }
}
-float TextStyle::GetUnderlineThickness() const
+float TextStyleContainer::GetGlowIntensity() const
{
- if ( !mImpl )
+ if ( mFlags & GLOW_EXISTS )
{
- return DEFAULT_UNDERLINE_THICKNESS;
+ const StyleGlowAttributes* attrPtr = reinterpret_cast<StyleGlowAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mGlowIntensity;
}
else
{
- return mImpl->mUnderlineThickness;
+ return TextStyle::DEFAULT_GLOW_INTENSITY;
}
}
-void TextStyle::SetUnderlineThickness( float thickness )
+const Vector2& TextStyleContainer::GetOutlineThickness() const
{
- CreateImplementationJustInTime();
- mImpl->mUnderlineThickness = thickness;
+ if ( mFlags & OUTLINE_EXISTS )
+ {
+ const StyleOutlineAttributes* attrPtr = reinterpret_cast<StyleOutlineAttributes*>( *( mParameters.Begin() + ( ( mFlags >> OUTLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mOutlineThickness;
+ }
+ else
+ {
+ return TextStyle::DEFAULT_OUTLINE_THICKNESS;
+ }
}
-float TextStyle::GetUnderlinePosition() const
+const Vector4& TextStyleContainer::GetOutlineColor() const
{
- if ( !mImpl )
+ if ( mFlags & OUTLINE_EXISTS )
{
- return DEFAULT_UNDERLINE_POSITION;
+ const StyleOutlineAttributes* attrPtr = reinterpret_cast<StyleOutlineAttributes*>( *( mParameters.Begin() + ( ( mFlags >> OUTLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mOutlineColor;
}
else
{
- return mImpl->mUnderlinePosition;
+ return TextStyle::DEFAULT_OUTLINE_COLOR;
}
}
-void TextStyle::SetUnderlinePosition( float position )
+const Vector4& TextStyleContainer::GetGradientColor() const
{
- CreateImplementationJustInTime();
- mImpl->mUnderlinePosition = position;
+ if ( mFlags & GRADIENT_EXISTS )
+ {
+ const StyleGradientAttributes* attrPtr = reinterpret_cast<StyleGradientAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mColor;
+ }
+ else
+ {
+ return TextStyle::DEFAULT_GRADIENT_COLOR;
+ }
}
-bool TextStyle::GetShadow() const
+const Vector2& TextStyleContainer::GetGradientStartPoint() const
{
- if ( !mImpl )
+ if ( mFlags & GRADIENT_EXISTS )
{
- return false;
+ const StyleGradientAttributes* attrPtr = reinterpret_cast<StyleGradientAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mStartPoint;
}
else
{
- return mImpl->mShadow;
+ return TextStyle::DEFAULT_GRADIENT_START_POINT;
}
}
-const Vector4& TextStyle::GetShadowColor() const
+const Vector2& TextStyleContainer::GetGradientEndPoint() const
{
- if ( !mImpl )
+ if ( mFlags & GRADIENT_EXISTS )
{
- return DEFAULT_SHADOW_COLOR;
+ const StyleGradientAttributes* attrPtr = reinterpret_cast<StyleGradientAttributes*>( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & PARAMETER_MASK ) ) );
+ return attrPtr->mEndPoint;
+ }
+ else
+ {
+ return TextStyle::DEFAULT_GRADIENT_END_POINT;
}
- return mImpl->mShadowColor;
}
-const Vector2& TextStyle::GetShadowOffset() const
+void TextStyleContainer::UpdateIndex( std::size_t index )
{
- if ( !mImpl )
+ // If a style parameter is reset to default, the value is removed from the vector.
+ // To remove a value (pointed by index) from the vector, it's swapped with the
+ // value of the last position. The index in the mFlag needs to be swapped as well.
+
+ // Find where in the flag is pointing to the last position of the vector
+
+ const std::size_t lastIndex = mParameters.Size() - 1u;
+ bool found = false;
+
+ for( uint64_t flagIndex = mFlags, mask = PARAMETER_MASK; !found; flagIndex = flagIndex >> PARAMETER_BITS, mask = mask << PARAMETER_BITS, index = index << PARAMETER_BITS )
{
- return DEFAULT_SHADOW_OFFSET;
+ if( ( flagIndex & PARAMETER_MASK ) == lastIndex )
+ {
+ mFlags &= ~mask;
+ mFlags |= index;
+ found = true;
+ }
}
- return mImpl->mShadowOffset;
}
-float TextStyle::GetShadowSize() const
+void TextStyleContainer::ResetFontName()
{
- if ( !mImpl )
+ if( !( mFlags & FONT_NAME_EXISTS ) )
{
- return DEFAULT_SHADOW_SIZE;
+ // nothing to do if the font name is not set.
+ return;
+ }
+
+ const std::size_t fontNameIndex = mFlags & PARAMETER_MASK;
+
+ // Check whether the other parameters stored in the same index are default.
+ if( ( mFlags & FONT_STYLE_EXISTS ) ||
+ ( mFlags & FONT_SIZE_EXISTS ) ||
+ ( mFlags & TEXT_COLOR_EXISTS ) )
+ {
+ // Style, size or color exist, so just set the default font name ("").
+ StyleCommonAttributes* attrPtr = reinterpret_cast<StyleCommonAttributes*>( *( mParameters.Begin() + fontNameIndex ) );
+ attrPtr->mFontName = DEFAULT_NAME;
}
else
{
- return mImpl->mShadowSize;
+ if( fontNameIndex < mParameters.Size() - 1u )
+ {
+ // The index of the moved value needs to be updated.
+ UpdateIndex( fontNameIndex );
+ }
+
+ // Reset the common index.
+ mFlags &= ~PARAMETER_MASK;
+
+ Vector<char*>::Iterator index = mParameters.Begin() + fontNameIndex;
+ char* toDelete = *index;
+
+ // Swaps the index to be removed with the last one and removes it.
+ mParameters.Remove( index );
+
+ delete reinterpret_cast<StyleCommonAttributes*>( toDelete );
}
-}
-void TextStyle::SetShadow( bool shadow, const Vector4& shadowColor, const Vector2& shadowOffset, const float shadowSize )
-{
- CreateImplementationJustInTime();
- mImpl->mShadow = shadow;
- mImpl->mShadowColor = shadowColor;
- mImpl->mShadowOffset = shadowOffset;
- mImpl->mShadowSize = shadowSize;
+ // Reset the FONT_NAME_EXISTS flag
+ mFlags &= ~FONT_NAME_EXISTS;
}
-bool TextStyle::GetGlow() const
+void TextStyleContainer::ResetFontStyle()
{
- if ( !mImpl )
+ if( !( mFlags & FONT_STYLE_EXISTS ) )
{
- return false;
+ // nothing to do if the font style is not set.
+ return;
+ }
+
+ const std::size_t fontStyleIndex = mFlags & PARAMETER_MASK;
+
+ // Check whether the other parameters stored in the same index are default.
+ if( ( mFlags & FONT_NAME_EXISTS ) ||
+ ( mFlags & FONT_SIZE_EXISTS ) ||
+ ( mFlags & TEXT_COLOR_EXISTS ) )
+ {
+ // Name, size or color exist, so just set the default font style ("") and reset the FONT_STYLE_EXISTS flag.
+ StyleCommonAttributes* attrPtr = reinterpret_cast<StyleCommonAttributes*>( *( mParameters.Begin() + fontStyleIndex ) );
+ attrPtr->mFontStyle = DEFAULT_NAME;
+ }
+ else
+ {
+ if( fontStyleIndex < mParameters.Size() - 1u )
+ {
+ // The index of the moved value needs to be updated.
+ UpdateIndex( fontStyleIndex );
+ }
+
+ // Reset the common index.
+ mFlags &= ~PARAMETER_MASK;
+
+ Vector<char*>::Iterator index = mParameters.Begin() + fontStyleIndex;
+ char* toDelete = *index;
+
+ // Swaps the index to be removed with the last one and removes it.
+ mParameters.Remove( index );
+
+ delete reinterpret_cast<StyleCommonAttributes*>( toDelete );
}
- return mImpl->mGlow;
+
+ // Reset the FONT_STYLE_EXISTS flag
+ mFlags &= ~FONT_STYLE_EXISTS;
}
-const Vector4& TextStyle::GetGlowColor() const
+void TextStyleContainer::ResetFontSize()
{
- if ( !mImpl )
+ if( !( mFlags & FONT_SIZE_EXISTS ) )
{
- return DEFAULT_GLOW_COLOR;
+ // nothing to do if the font size is not set.
+ return;
+ }
+
+ const std::size_t fontSizeIndex = mFlags & PARAMETER_MASK;
+
+ // Check whether the other parameters stored in the same index are default.
+ if( ( mFlags & FONT_NAME_EXISTS ) ||
+ ( mFlags & FONT_STYLE_EXISTS ) ||
+ ( mFlags & TEXT_COLOR_EXISTS ) )
+ {
+ // Name, style or color exist, so just set the default font size (0.0) and reset the FONT_SIZE_EXISTS flag.
+ StyleCommonAttributes* attrPtr = reinterpret_cast<StyleCommonAttributes*>( *( mParameters.Begin() + fontSizeIndex ) );
+ attrPtr->mFontPointSize = DEFAULT_FONT_POINT_SIZE;
}
else
{
- return mImpl->mGlowColor;
+ if( fontSizeIndex < mParameters.Size() - 1u )
+ {
+ // The index of the moved value needs to be updated.
+ UpdateIndex( fontSizeIndex );
+ }
+
+ // Reset the common index.
+ mFlags &= ~PARAMETER_MASK;
+
+ Vector<char*>::Iterator index = mParameters.Begin() + fontSizeIndex;
+ char* toDelete = *index;
+
+ // Swaps the index to be removed with the last one and removes it.
+ mParameters.Remove( index );
+
+ delete reinterpret_cast<StyleCommonAttributes*>( toDelete );
}
+
+ // Reset the FONT_SIZE_EXISTS flag
+ mFlags &= ~FONT_SIZE_EXISTS;
}
-float TextStyle::GetGlowIntensity() const
+void TextStyleContainer::ResetTextColor()
{
- if ( !mImpl )
+ if( !( mFlags & TEXT_COLOR_EXISTS ) )
{
- return DEFAULT_GLOW_INTENSITY;
+ // nothing to do if the text color is not set.
+ return;
+ }
+
+ const std::size_t textColorIndex = mFlags & PARAMETER_MASK;
+
+ // Check whether the other parameters stored in the same index are default.
+ if( ( mFlags & FONT_NAME_EXISTS ) ||
+ ( mFlags & FONT_STYLE_EXISTS ) ||
+ ( mFlags & FONT_SIZE_EXISTS ) )
+ {
+ // Name, style or size exist, so just set the default color (WHITE) and reset the TEXT_COLOR_EXISTS flag.
+ StyleCommonAttributes* attrPtr = reinterpret_cast<StyleCommonAttributes*>( *( mParameters.Begin() + textColorIndex ) );
+ attrPtr->mTextColor = TextStyle::DEFAULT_TEXT_COLOR;
}
else
{
- return mImpl->mGlowIntensity;
+ if( textColorIndex < mParameters.Size() - 1u )
+ {
+ // The index of the moved value needs to be updated.
+ UpdateIndex( textColorIndex );
+ }
+
+ // Reset the common index.
+ mFlags &= ~PARAMETER_MASK;
+
+ Vector<char*>::Iterator index = mParameters.Begin() + textColorIndex;
+ char* toDelete = *index;
+
+ // Swaps the index to be removed with the last one and removes it.
+ mParameters.Remove( index );
+
+ delete reinterpret_cast<StyleCommonAttributes*>( toDelete );
}
+
+ // Reset the TEXT_COLOR_EXISTS flag
+ mFlags &= ~TEXT_COLOR_EXISTS;
}
-void TextStyle::SetGlow( bool glow, const Vector4& glowColor, float glowIntensity )
+void TextStyleContainer::ResetFontWeight()
{
- CreateImplementationJustInTime();
- mImpl->mGlow = glow;
- mImpl->mGlowColor = glowColor;
- mImpl->mGlowIntensity = glowIntensity;
+ if( !( mFlags & FONT_WEIGHT_EXISTS ) )
+ {
+ // nothing to do if the font weight is not set.
+ return;
+ }
+
+ const std::size_t fontWeightIndex = ( mFlags >> WEIGHT_INDEX_SHIFT ) & PARAMETER_MASK;
+
+ // Check whether the smooth edge exists
+ if( mFlags & SMOOTH_EDGE_EXISTS )
+ {
+ StyleWeightAttributes* attrPtr = reinterpret_cast<StyleWeightAttributes*>( *( mParameters.Begin() + fontWeightIndex ) );
+ attrPtr->mWeight = TextStyle::DEFAULT_FONT_WEIGHT;
+ }
+ else
+ {
+ if( fontWeightIndex < mParameters.Size() - 1u )
+ {
+ // The index of the moved value needs to be updated.
+ UpdateIndex( fontWeightIndex );
+ }
+
+ // Reset the font weight index.
+ const uint64_t weightMask = PARAMETER_MASK << WEIGHT_INDEX_SHIFT;
+ mFlags &= ~weightMask;
+
+ Vector<char*>::Iterator index = mParameters.Begin() + fontWeightIndex;
+ char* toDelete = *index;
+
+ // Swaps the index to be removed with the last one and removes it.
+ mParameters.Remove( index );
+
+ delete reinterpret_cast<StyleWeightAttributes*>( toDelete );
+ }
+
+ // Reset the FONT_WEIGHT_EXISTS flag
+ mFlags &= ~FONT_WEIGHT_EXISTS;
}
-float TextStyle::GetSmoothEdge() const
+void TextStyleContainer::ResetSmoothEdge()
{
- if ( !mImpl )
+ if( !( mFlags & SMOOTH_EDGE_EXISTS ) )
{
- return DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD;
+ // nothing to do if the smooth edge is not set.
+ return;
+ }
+
+ const std::size_t smoothEdgeIndex = ( mFlags >> WEIGHT_INDEX_SHIFT ) & PARAMETER_MASK;
+
+ // Check whether the weight exists
+ if( mFlags & FONT_WEIGHT_EXISTS )
+ {
+ StyleWeightAttributes* attrPtr = reinterpret_cast<StyleWeightAttributes*>( *( mParameters.Begin() + smoothEdgeIndex ) );
+ attrPtr->mSmoothEdge = TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD;
}
else
{
- return mImpl->mSmoothEdge;
+ if( smoothEdgeIndex < mParameters.Size() - 1u )
+ {
+ // The index of the moved value needs to be updated.
+ UpdateIndex( smoothEdgeIndex );
+ }
+
+ // Reset the font weight index. (The smooth edge is stored with the weight)
+ const uint64_t weightMask = PARAMETER_MASK << WEIGHT_INDEX_SHIFT;
+ mFlags &= ~weightMask;
+
+ Vector<char*>::Iterator index = mParameters.Begin() + smoothEdgeIndex;
+ char* toDelete = *index;
+
+ // Swaps the index to be removed with the last one and removes it.
+ mParameters.Remove( index );
+
+ delete reinterpret_cast<StyleWeightAttributes*>( toDelete );
}
+
+ // Reset the SMOOTH_EDGE_EXISTS flag
+ mFlags &= ~SMOOTH_EDGE_EXISTS;
}
-void TextStyle::SetSmoothEdge( float smoothEdge )
+void TextStyleContainer::ResetItalics()
{
- CreateImplementationJustInTime();
- mImpl->mSmoothEdge = smoothEdge;
+ if( !( mFlags & ITALICS_EXISTS ) )
+ {
+ // nothing to do if the italics is not set.
+ return;
+ }
+
+ const std::size_t italicIndex = ( mFlags >> ITALICS_INDEX_SHIFT ) & PARAMETER_MASK;
+
+ if( italicIndex < mParameters.Size() - 1u )
+ {
+ // The index of the moved value needs to be updated.
+ UpdateIndex( italicIndex );
+ }
+
+ // Reset the italics index, the ITALICS_EXISTS and the ITALICS_ENABLED flags.
+ const uint64_t italicsMask = PARAMETER_MASK << ITALICS_INDEX_SHIFT;
+ mFlags &= ~( italicsMask | ITALICS_EXISTS | ITALICS_ENABLED );
+
+ Vector<char*>::Iterator index = mParameters.Begin() + italicIndex;
+ char* toDelete = *index;
+
+ // Swaps the index to be removed with the last one and removes it.
+ mParameters.Remove( index );
+
+ delete reinterpret_cast<StyleItalicsAttributes*>( toDelete );
}
-bool TextStyle::GetOutline() const
+void TextStyleContainer::ResetUnderline()
{
- if ( !mImpl )
+ if( !( mFlags & UNDERLINE_EXISTS ) )
{
- return false;
+ // nothing to do if the underline is not set.
+ return;
}
- else
+
+ const std::size_t underlineIndex = ( mFlags >> UNDERLINE_INDEX_SHIFT ) & PARAMETER_MASK;
+
+ if( underlineIndex < mParameters.Size() - 1u )
{
- return mImpl->mOutline;
+ // The index of the moved value needs to be updated.
+ UpdateIndex( underlineIndex );
}
+
+ // Reset the underline index and the UNDERLINE_EXISTS and the UNDERLINE_ENABLED flags.
+ const uint64_t underlineMask = PARAMETER_MASK << UNDERLINE_INDEX_SHIFT;
+ mFlags &= ~( underlineMask | UNDERLINE_EXISTS | UNDERLINE_ENABLED );
+
+ Vector<char*>::Iterator index = mParameters.Begin() + underlineIndex;
+ char* toDelete = *index;
+
+ // Swaps the index to be removed with the last one and removes it.
+ mParameters.Remove( index );
+
+ delete reinterpret_cast<StyleUnderlineAttributes*>( toDelete );
}
-const Vector4& TextStyle::GetOutlineColor() const
+void TextStyleContainer::ResetShadow()
{
- if ( !mImpl )
+ if( !( mFlags & DROP_SHADOW_EXISTS ) )
{
- return DEFAULT_OUTLINE_COLOR;
+ // nothing to do if the shadow is not set.
+ return;
}
- else
+
+ const std::size_t shadowIndex = ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & PARAMETER_MASK;
+
+ if( shadowIndex < mParameters.Size() - 1u )
{
- return mImpl->mOutlineColor;
+ // The index of the moved value needs to be updated.
+ UpdateIndex( shadowIndex );
}
+
+ // Reset the shadow index and the DROP_SHADOW_EXISTS and the DROP_SHADOW_ENABLED flags.
+ const uint64_t shadowMask = PARAMETER_MASK << DROP_SHADOW_INDEX_SHIFT;
+ mFlags &= ~( shadowMask | DROP_SHADOW_EXISTS | DROP_SHADOW_ENABLED );
+
+ Vector<char*>::Iterator index = mParameters.Begin() + shadowIndex;
+ char* toDelete = *index;
+
+ // Swaps the index to be removed with the last one and removes it.
+ mParameters.Remove( index );
+
+ delete reinterpret_cast<StyleShadowAttributes*>( toDelete );
}
-const Vector2& TextStyle::GetOutlineThickness() const
+void TextStyleContainer::ResetGlow()
{
- if ( !mImpl )
+ if( !( mFlags & GLOW_EXISTS ) )
{
- return DEFAULT_OUTLINE_THICKNESS;
+ // nothing to do if the glow is not set.
+ return;
}
- else
+
+ const std::size_t glowIndex = ( mFlags >> GLOW_INDEX_SHIFT ) & PARAMETER_MASK;
+
+ if( glowIndex < mParameters.Size() - 1u )
{
- return mImpl->mOutlineThickness;
+ // The index of the moved value needs to be updated.
+ UpdateIndex( glowIndex );
}
+
+ // Reset the glow index and the GLOW_EXISTS and the GLOW_ENABLED flags.
+ const uint64_t glowMask = PARAMETER_MASK << GLOW_INDEX_SHIFT;
+ mFlags &= ~( glowMask | GLOW_EXISTS | GLOW_ENABLED );
+
+ Vector<char*>::Iterator index = mParameters.Begin() + glowIndex;
+ char* toDelete = *index;
+
+ // Swaps the index to be removed with the last one and removes it.
+ mParameters.Remove( index );
+
+ delete reinterpret_cast<StyleGlowAttributes*>( toDelete );
}
-void TextStyle::SetOutline( bool outline, const Vector4& outlineColor, const Vector2& outlineThickness )
+void TextStyleContainer::ResetOutline()
{
- CreateImplementationJustInTime();
- mImpl->mOutline = outline;
- mImpl->mOutlineColor = outlineColor;
- mImpl->mOutlineThickness = outlineThickness;
+ if( !( mFlags & OUTLINE_EXISTS ) )
+ {
+ // nothing to do if the outline is not set.
+ return;
+ }
+
+ const std::size_t outlineIndex = ( mFlags >> OUTLINE_INDEX_SHIFT ) & PARAMETER_MASK;
+
+ if( outlineIndex < mParameters.Size() - 1u )
+ {
+ // The index of the moved value needs to be updated.
+ UpdateIndex( outlineIndex );
+ }
+
+ // Reset the outline index and the OUTLINE_EXISTS and the OUTLINE_ENABLED flags.
+ const uint64_t outlineMask = PARAMETER_MASK << OUTLINE_INDEX_SHIFT;
+ mFlags &= ~( outlineMask | OUTLINE_EXISTS | OUTLINE_ENABLED );
+
+ Vector<char*>::Iterator index = mParameters.Begin() + outlineIndex;
+ char* toDelete = *index;
+
+ // Swaps the index to be removed with the last one and removes it.
+ mParameters.Remove( index );
+
+ delete reinterpret_cast<StyleOutlineAttributes*>( toDelete );
}
-void TextStyle::CreateImplementationJustInTime()
+void TextStyleContainer::ResetGradient()
{
- if ( mImpl == NULL )
+ if( !( mFlags & GRADIENT_EXISTS ) )
{
- mImpl = new TextStyle::Impl();
+ // nothing to do if the gradient is not set.
+ return;
}
-}
+ const std::size_t gradientIndex = ( mFlags >> GRADIENT_INDEX_SHIFT ) & PARAMETER_MASK;
+
+ if( gradientIndex < mParameters.Size() - 1u )
+ {
+ // The index of the moved value needs to be updated.
+ UpdateIndex( gradientIndex );
+ }
+
+ // Reset the gradient index and the GRADIENT_EXISTS and the GRADIENT_ENABLED flags.
+ const uint64_t gradientMask = PARAMETER_MASK << GRADIENT_INDEX_SHIFT;
+ mFlags &= ~( gradientMask | GRADIENT_EXISTS | GRADIENT_ENABLED );
+
+ Vector<char*>::Iterator index = mParameters.Begin() + gradientIndex;
+ char* toDelete = *index;
+
+ // Swaps the index to be removed with the last one and removes it.
+ mParameters.Remove( index );
+
+ delete reinterpret_cast<StyleGradientAttributes*>( toDelete );
+}
} // namespace Dali