It copies from a given text-style all parameters which are not default.
It's useful to merge parameters from different text-styles into one.
Change-Id: I36e8d481225f09fd5736ae4b8da7a3b78879760b
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
END_TEST;
}
+int UtcDaliTextStyleMerge(void)
+{
+ tet_infoline(" UtcDaliTextStyleMerge ");
+
+ TestApplication application;
+
+ TextStyle defaultStyle;
+
+ TextStyle style;
+
+ // Set a style different than default.
+ 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 );
+
+ // Test not to merge the same object. To increase coverage.
+
+ const TextStyle& same( style2 );
+
+ style2.Merge( same );
+
+ DALI_TEST_CHECK( same == style2 );
+
+ // Test merge two styles
+
+ style.Merge( style2 );
+
+ DALI_TEST_CHECK( style == style2 );
+
+ // Test merge a default style
+
+ style.Merge( defaultStyle );
+
+ DALI_TEST_CHECK( style == style2 );
+
+ // Tests to increase branch coverage.
+
+ style = defaultStyle;
+ style.SetFontName( FONT_FAMILY );
+
+ TextStyle style3;
+ style3.Merge( style );
+
+ DALI_TEST_CHECK( style == style3 );
+
+
+ END_TEST;
+}
+
int UtcDaliTextStyleReset(void)
{
tet_infoline(" UtcDaliTextStyleReset ");
}
}
+void TextStyle::Merge( const TextStyle& textStyle, Mask mask )
+{
+ // If we're attemping to merge ourselves then just return
+ if ( this == &textStyle )
+ {
+ return;
+ }
+
+ // Check to see if we're merging from default style ?
+ if ( textStyle.mContainer == NULL )
+ {
+ // nothing to merge.
+ return;
+ }
+
+ if( mask & FONT )
+ {
+ if( !textStyle.IsFontNameDefault() )
+ {
+ SetFontName( textStyle.GetFontName() );
+ }
+ }
+ if( mask & STYLE )
+ {
+ if( !textStyle.IsFontStyleDefault() )
+ {
+ SetFontStyle( textStyle.GetFontStyle() );
+ }
+ }
+ if( mask & SIZE )
+ {
+ if( !textStyle.IsFontSizeDefault() )
+ {
+ SetFontPointSize( textStyle.GetFontPointSize() );
+ }
+ }
+ if( mask & COLOR )
+ {
+ if( !textStyle.IsTextColorDefault() )
+ {
+ SetTextColor( textStyle.GetTextColor() ) ;
+ }
+ }
+ if( mask & WEIGHT )
+ {
+ if( !textStyle.IsFontWeightDefault() )
+ {
+ SetWeight( textStyle.GetWeight() );
+ }
+ }
+ if( mask & SMOOTH )
+ {
+ if( !textStyle.IsSmoothEdgeDefault() )
+ {
+ SetSmoothEdge( textStyle.GetSmoothEdge() );
+ }
+ }
+ if( mask & ITALICS )
+ {
+ if( !textStyle.IsItalicsDefault() )
+ {
+ SetItalics( textStyle.IsItalicsEnabled(), textStyle.GetItalicsAngle() );
+ }
+ }
+ if( mask & UNDERLINE )
+ {
+ if( !textStyle.IsUnderlineDefault() )
+ {
+ SetUnderline( textStyle.IsUnderlineEnabled(), textStyle.GetUnderlineThickness(), textStyle.GetUnderlinePosition() );
+ }
+ }
+ if( mask & SHADOW )
+ {
+ if( !textStyle.IsShadowDefault() )
+ {
+ SetShadow( textStyle.IsShadowEnabled(), textStyle.GetShadowColor(), textStyle.GetShadowOffset(), textStyle.GetShadowSize() );
+ }
+ }
+ if( mask & GLOW )
+ {
+ if( !textStyle.IsGlowDefault() )
+ {
+ SetGlow( textStyle.IsGlowEnabled(), textStyle.GetGlowColor(), textStyle.GetGlowIntensity() );
+ }
+ }
+ if( mask & OUTLINE )
+ {
+ if( !textStyle.IsOutlineDefault() )
+ {
+ SetOutline( textStyle.IsOutlineEnabled(), textStyle.GetOutlineColor(), textStyle.GetOutlineThickness() );
+ }
+ }
+ if( mask & GRADIENT )
+ {
+ if( !textStyle.IsGradientDefault() )
+ {
+ SetGradient( textStyle.IsGradientEnabled(), textStyle.GetGradientColor(), textStyle.GetGradientStartPoint(), textStyle.GetGradientEndPoint() );
+ }
+ }
+}
+
void TextStyle::Reset( Mask mask )
{
if( NULL == mContainer )
void Copy( const TextStyle& textStyle, Mask mask = ALL );
/**
+ * @brief Copies from the given text style those parameters specified in the given mask which are not default.
+ *
+ * @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 Merge( 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.