(TextLabel) Added component properties for Text Color 67/145767/6
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 23 Aug 2017 15:25:55 +0000 (16:25 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 23 Aug 2017 16:41:19 +0000 (17:41 +0100)
Also fixed the getter for TEXT_COLOR

Change-Id: I993ff3c289ccb703d1c95874001f882fd4a3e7eb

automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp
dali-toolkit/devel-api/controls/text-controls/text-label-devel.h
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp

index 6972fb1..beba3a6 100644 (file)
@@ -959,3 +959,34 @@ int UtcDaliToolkitTextlabelTextWarpMode(void)
 
   END_TEST;
 }
 
   END_TEST;
 }
+
+int UtcDaliToolkitTextLabelColorComponents(void)
+{
+  ToolkitTestApplication application;
+
+  TextLabel label = TextLabel::New();
+  label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::RED );
+  DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_RED ),   1.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
+
+  label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::GREEN );
+  DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
+
+  label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::BLUE );
+  DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_BLUE ),  1.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
+
+  label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
+  DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
+  DALI_TEST_EQUALS( label.GetProperty< Vector4 >( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
+  DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
+
+  END_TEST;
+}
index c609d34..dfcd279 100644 (file)
@@ -44,78 +44,113 @@ namespace Property
 {
   enum Type
   {
 {
   enum Type
   {
-      RENDERING_BACKEND = Dali::Toolkit::TextLabel::Property::RENDERING_BACKEND,
-      TEXT = Dali::Toolkit::TextLabel::Property::TEXT,
-      FONT_FAMILY = Dali::Toolkit::TextLabel::Property::FONT_FAMILY,
-      FONT_STYLE = Dali::Toolkit::TextLabel::Property::FONT_STYLE,
-      POINT_SIZE = Dali::Toolkit::TextLabel::Property::POINT_SIZE,
-      MULTI_LINE = Dali::Toolkit::TextLabel::Property::MULTI_LINE,
-      HORIZONTAL_ALIGNMENT = Dali::Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT,
-      VERTICAL_ALIGNMENT = Dali::Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT,
-      TEXT_COLOR = Dali::Toolkit::TextLabel::Property::TEXT_COLOR,
-      SHADOW_OFFSET = Dali::Toolkit::TextLabel::Property::SHADOW_OFFSET,
-      SHADOW_COLOR = Dali::Toolkit::TextLabel::Property::SHADOW_COLOR,
-      UNDERLINE_ENABLED = Dali::Toolkit::TextLabel::Property::UNDERLINE_ENABLED,
-      UNDERLINE_COLOR = Dali::Toolkit::TextLabel::Property::UNDERLINE_COLOR,
-      UNDERLINE_HEIGHT = Dali::Toolkit::TextLabel::Property::UNDERLINE_HEIGHT,
-      ENABLE_MARKUP = Dali::Toolkit::TextLabel::Property::ENABLE_MARKUP,
-      ENABLE_AUTO_SCROLL = Dali::Toolkit::TextLabel::Property::ENABLE_AUTO_SCROLL,
-      AUTO_SCROLL_SPEED = Dali::Toolkit::TextLabel::Property::AUTO_SCROLL_SPEED,
-      AUTO_SCROLL_LOOP_COUNT = Dali::Toolkit::TextLabel::Property::AUTO_SCROLL_LOOP_COUNT,
-      AUTO_SCROLL_GAP = Dali::Toolkit::TextLabel::Property::AUTO_SCROLL_GAP,
-      LINE_SPACING = Dali::Toolkit::TextLabel::Property::LINE_SPACING,
-      UNDERLINE = Dali::Toolkit::TextLabel::Property::UNDERLINE,
-      SHADOW = Dali::Toolkit::TextLabel::Property::SHADOW,
-      EMBOSS = Dali::Toolkit::TextLabel::Property::EMBOSS,
-      OUTLINE = Dali::Toolkit::TextLabel::Property::OUTLINE,
-
-      /**
-       * @brief The size of font in pixels.
-       *
-       * Conversion from Point size to Pixel size :
-       *  Pixel size = Point size * DPI / 72
-       * @details name "pixelSize", type float
-       */
-      PIXEL_SIZE = OUTLINE + 1,
-
-      /**
-       * @brief Enable or disable the ellipsis.
-       * @details name "ellipsis", type bool
-       */
-      ELLIPSIS = OUTLINE + 2,
-
-      /**
-       * @brief delay starting time of auto scrolling and further loops
-       * @details name "autoScrollLoopDelay", type float.
-       */
-      AUTO_SCROLL_LOOP_DELAY = OUTLINE + 3,
-
-      /**
-       * @brief Auto scrolling stop behaviour.
-       * @details name "autoScrollStopMode", type [Type](@ref Dali::Toolkit::DevelTextLabel::AutoScrollStopMode::Type) (Property::INTEGER) or Property::STRING.
-       *          values FINISH_LOOP, IMMEDIATE, defualt FINISH_LOOP
-       */
-      AUTO_SCROLL_STOP_MODE = OUTLINE + 4,
-
-      /*
-       * @brief The line count of text.
-       * @details name "lineCount", type int
-       * @node this property is read-only.
-       */
-      LINE_COUNT = OUTLINE + 5,
-
-      /**
-       * @brief line wrap mode when the text lines over layout width.
-       * @details name "lineWrapMode", type string.
-       */
-      LINE_WRAP_MODE = OUTLINE + 6,
-
-      /*
-       * @brief Animatable text color
-       * @details text color property to use if required to animate the text color
-       */
-      TEXT_COLOR_ANIMATABLE = ANIMATABLE_PROPERTY_START_INDEX
-
+    ///////////////////////////////////////////////////////////////////////////////
+    // Event side (non-animatable) properties
+    ///////////////////////////////////////////////////////////////////////////////
+
+    RENDERING_BACKEND = Dali::Toolkit::TextLabel::Property::RENDERING_BACKEND,
+    TEXT = Dali::Toolkit::TextLabel::Property::TEXT,
+    FONT_FAMILY = Dali::Toolkit::TextLabel::Property::FONT_FAMILY,
+    FONT_STYLE = Dali::Toolkit::TextLabel::Property::FONT_STYLE,
+    POINT_SIZE = Dali::Toolkit::TextLabel::Property::POINT_SIZE,
+    MULTI_LINE = Dali::Toolkit::TextLabel::Property::MULTI_LINE,
+    HORIZONTAL_ALIGNMENT = Dali::Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT,
+    VERTICAL_ALIGNMENT = Dali::Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT,
+    TEXT_COLOR = Dali::Toolkit::TextLabel::Property::TEXT_COLOR,
+    SHADOW_OFFSET = Dali::Toolkit::TextLabel::Property::SHADOW_OFFSET,
+    SHADOW_COLOR = Dali::Toolkit::TextLabel::Property::SHADOW_COLOR,
+    UNDERLINE_ENABLED = Dali::Toolkit::TextLabel::Property::UNDERLINE_ENABLED,
+    UNDERLINE_COLOR = Dali::Toolkit::TextLabel::Property::UNDERLINE_COLOR,
+    UNDERLINE_HEIGHT = Dali::Toolkit::TextLabel::Property::UNDERLINE_HEIGHT,
+    ENABLE_MARKUP = Dali::Toolkit::TextLabel::Property::ENABLE_MARKUP,
+    ENABLE_AUTO_SCROLL = Dali::Toolkit::TextLabel::Property::ENABLE_AUTO_SCROLL,
+    AUTO_SCROLL_SPEED = Dali::Toolkit::TextLabel::Property::AUTO_SCROLL_SPEED,
+    AUTO_SCROLL_LOOP_COUNT = Dali::Toolkit::TextLabel::Property::AUTO_SCROLL_LOOP_COUNT,
+    AUTO_SCROLL_GAP = Dali::Toolkit::TextLabel::Property::AUTO_SCROLL_GAP,
+    LINE_SPACING = Dali::Toolkit::TextLabel::Property::LINE_SPACING,
+    UNDERLINE = Dali::Toolkit::TextLabel::Property::UNDERLINE,
+    SHADOW = Dali::Toolkit::TextLabel::Property::SHADOW,
+    EMBOSS = Dali::Toolkit::TextLabel::Property::EMBOSS,
+    OUTLINE = Dali::Toolkit::TextLabel::Property::OUTLINE,
+
+    /**
+     * @brief The size of font in pixels.
+     * @details Name "pixelSize", type Property::FLOAT.
+     *          Conversion from Point size to Pixel size:
+     *            Pixel size = Point size * DPI / 72
+     */
+    PIXEL_SIZE = OUTLINE + 1,
+
+    /**
+     * @brief Enable or disable the ellipsis.
+     * @details Name "ellipsis", type Property::BOOLEAN.
+     */
+    ELLIPSIS = OUTLINE + 2,
+
+    /**
+     * @brief delay starting time of auto scrolling and further loops
+     * @details Name "autoScrollLoopDelay", type Property::FLOAT.
+     */
+    AUTO_SCROLL_LOOP_DELAY = OUTLINE + 3,
+
+    /**
+     * @brief Auto scrolling stop behaviour.
+     * @details Name "autoScrollStopMode", type [Type](@ref Dali::Toolkit::DevelTextLabel::AutoScrollStopMode::Type) (Property::INTEGER) or Property::STRING.
+     *          Values FINISH_LOOP, IMMEDIATE, default FINISH_LOOP
+     */
+    AUTO_SCROLL_STOP_MODE = OUTLINE + 4,
+
+    /*
+     * @brief The line count of text.
+     * @details name "lineCount", type int
+     * @node This property is read-only.
+     */
+    LINE_COUNT = OUTLINE + 5,
+
+    /**
+     * @brief line wrap mode when the text lines over layout width.
+     * @details Name "lineWrapMode", type Property::STRING.
+     */
+    LINE_WRAP_MODE = OUTLINE + 6,
+
+    ///////////////////////////////////////////////////////////////////////////////
+    // Animatable Properties
+    ///////////////////////////////////////////////////////////////////////////////
+
+    /*
+     * @brief Animatable text color.
+     * @details Name "textColorAnimatable", type Property::VECTOR4.
+     *          Text color property to use if required to animate the text color.
+     */
+    TEXT_COLOR_ANIMATABLE = ANIMATABLE_PROPERTY_START_INDEX,
+
+    /**
+     * @brief The red component of the text color.
+     * @details Name "textColorRed", type Property::FLOAT.
+     * @see TEXT_COLOR_ANIMATABLE
+     */
+    TEXT_COLOR_RED = ANIMATABLE_PROPERTY_START_INDEX + 1,
+
+    /**
+     * @brief The green component of the text color.
+     * @details Name "textColorGreen", type Property::FLOAT.
+     * @see TEXT_COLOR_ANIMATABLE
+     */
+    TEXT_COLOR_GREEN = ANIMATABLE_PROPERTY_START_INDEX + 2,
+
+    /**
+     * @brief The blue component of the text color.
+     * @details Name "textColorBlue", type Property::FLOAT.
+     * @see TEXT_COLOR_ANIMATABLE
+     */
+    TEXT_COLOR_BLUE = ANIMATABLE_PROPERTY_START_INDEX + 3,
+
+    /**
+     * @brief The alpha component of the text color.
+     * @details Name "textColorAlpha", type Property::FLOAT.
+     * @see TEXT_COLOR_ANIMATABLE
+     */
+    TEXT_COLOR_ALPHA = ANIMATABLE_PROPERTY_START_INDEX + 4,
   };
 } // namespace Property
 
   };
 } // namespace Property
 
index 5ca841f..d92b1cd 100644 (file)
@@ -135,6 +135,10 @@ DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollStopMode",  STR
 DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextLabel, "lineCount", INTEGER, LINE_COUNT             )
 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "lineWrapMode",        STRING,  LINE_WRAP_MODE         )
 DALI_DEVEL_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( Toolkit, TextLabel, "textColorAnimatable", Color::BLACK, TEXT_COLOR_ANIMATABLE )
 DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextLabel, "lineCount", INTEGER, LINE_COUNT             )
 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "lineWrapMode",        STRING,  LINE_WRAP_MODE         )
 DALI_DEVEL_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( Toolkit, TextLabel, "textColorAnimatable", Color::BLACK, TEXT_COLOR_ANIMATABLE )
+DALI_DEVEL_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, TextLabel, "textColorRed",   TEXT_COLOR_RED,   TEXT_COLOR_ANIMATABLE, 0)
+DALI_DEVEL_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, TextLabel, "textColorGreen", TEXT_COLOR_GREEN, TEXT_COLOR_ANIMATABLE, 1)
+DALI_DEVEL_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, TextLabel, "textColorBlue",  TEXT_COLOR_BLUE,  TEXT_COLOR_ANIMATABLE, 2)
+DALI_DEVEL_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, TextLabel, "textColorAlpha", TEXT_COLOR_ALPHA, TEXT_COLOR_ANIMATABLE, 3)
 DALI_TYPE_REGISTRATION_END()
 
 } // namespace
 DALI_TYPE_REGISTRATION_END()
 
 } // namespace
@@ -601,12 +605,8 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
         break;
       }
       case Toolkit::TextLabel::Property::TEXT_COLOR:
         break;
       }
       case Toolkit::TextLabel::Property::TEXT_COLOR:
-      case Toolkit::DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE:
       {
       {
-        if ( impl.mController )
-        {
-          value = impl.mController->GetDefaultColor();
-        }
+        value = label.GetProperty( Toolkit::DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE );
         break;
       }
       case Toolkit::TextLabel::Property::SHADOW_OFFSET:
         break;
       }
       case Toolkit::TextLabel::Property::SHADOW_OFFSET: