[dali_2.3.22] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / input-style.h
index de3a1f2..1027903 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_TEXT_INPUT_STYLE_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/common/constants.h>
+#include <dali/public-api/math/math-utils.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/text-definitions.h>
@@ -37,18 +38,19 @@ struct InputStyle
 {
   enum Mask
   {
-    NONE               = 0x0000,
-    INPUT_COLOR        = 0x0001,
-    INPUT_FONT_FAMILY  = 0x0002,
-    INPUT_POINT_SIZE   = 0x0004,
-    INPUT_FONT_WEIGHT  = 0x0008,
-    INPUT_FONT_WIDTH   = 0x0010,
-    INPUT_FONT_SLANT   = 0x0020,
-    INPUT_LINE_SPACING = 0x0040,
-    INPUT_UNDERLINE    = 0x0080,
-    INPUT_SHADOW       = 0x0100,
-    INPUT_EMBOSS       = 0x0200,
-    INPUT_OUTLINE      = 0x0400
+    NONE                = 0x0000,
+    INPUT_COLOR         = 0x0001,
+    INPUT_FONT_FAMILY   = 0x0002,
+    INPUT_POINT_SIZE    = 0x0004,
+    INPUT_FONT_WEIGHT   = 0x0008,
+    INPUT_FONT_WIDTH    = 0x0010,
+    INPUT_FONT_SLANT    = 0x0020,
+    INPUT_LINE_SPACING  = 0x0040,
+    INPUT_UNDERLINE     = 0x0080,
+    INPUT_SHADOW        = 0x0100,
+    INPUT_EMBOSS        = 0x0200,
+    INPUT_OUTLINE       = 0x0400,
+    INPUT_STRIKETHROUGH = 0x0800
   };
 
   InputStyle()
@@ -63,6 +65,7 @@ struct InputStyle
     shadowProperties(),
     embossProperties(),
     outlineProperties(),
+    strikethroughProperties(),
     isDefaultColor(true),
     isFamilyDefined(false),
     isWeightDefined(false),
@@ -73,7 +76,8 @@ struct InputStyle
     isUnderlineDefined(false),
     isShadowDefined(false),
     isEmbossDefined(false),
-    isOutlineDefined(false)
+    isOutlineDefined(false),
+    isStrikethroughDefined(false)
   {
   }
 
@@ -118,6 +122,9 @@ struct InputStyle
 
     isOutlineDefined  = inputStyle.isOutlineDefined;
     outlineProperties = inputStyle.outlineProperties;
+
+    isStrikethroughDefined  = inputStyle.isStrikethroughDefined;
+    strikethroughProperties = inputStyle.strikethroughProperties;
   }
 
   /**
@@ -143,12 +150,13 @@ struct InputStyle
        (weight != inputStyle.weight) ||
        (width != inputStyle.width) ||
        (slant != inputStyle.slant) ||
-       (size != inputStyle.size) ||
-       (lineSpacing != inputStyle.lineSpacing) ||
+       (!Dali::Equals(size, inputStyle.size)) ||
+       (!Dali::Equals(lineSpacing, inputStyle.lineSpacing)) ||
        (underlineProperties != inputStyle.underlineProperties) ||
        (shadowProperties != inputStyle.shadowProperties) ||
        (embossProperties != inputStyle.embossProperties) ||
-       (outlineProperties != inputStyle.outlineProperties))
+       (outlineProperties != inputStyle.outlineProperties) ||
+       (isStrikethroughDefined != inputStyle.isStrikethroughDefined))
     {
       return false;
     }
@@ -180,11 +188,11 @@ struct InputStyle
     {
       mask = static_cast<Mask>(mask | INPUT_FONT_SLANT);
     }
-    if(size != inputStyle.size)
+    if(!Dali::Equals(size, inputStyle.size))
     {
       mask = static_cast<Mask>(mask | INPUT_POINT_SIZE);
     }
-    if(lineSpacing != inputStyle.lineSpacing)
+    if(!Dali::Equals(lineSpacing, inputStyle.lineSpacing))
     {
       mask = static_cast<Mask>(mask | INPUT_LINE_SPACING);
     }
@@ -204,6 +212,10 @@ struct InputStyle
     {
       mask = static_cast<Mask>(mask | INPUT_OUTLINE);
     }
+    if(strikethroughProperties != inputStyle.strikethroughProperties)
+    {
+      mask = static_cast<Mask>(mask | INPUT_STRIKETHROUGH);
+    }
 
     return mask;
   }
@@ -217,10 +229,11 @@ struct InputStyle
 
   float lineSpacing; ///< The line's spacing.
 
-  std::string underlineProperties; ///< The underline properties string.
-  std::string shadowProperties;    ///< The shadow properties string.
-  std::string embossProperties;    ///< The emboss properties string.
-  std::string outlineProperties;   ///< The outline properties string.
+  std::string underlineProperties;     ///< The underline properties string.
+  std::string shadowProperties;        ///< The shadow properties string.
+  std::string embossProperties;        ///< The emboss properties string.
+  std::string outlineProperties;       ///< The outline properties string.
+  std::string strikethroughProperties; ///< The strikethrough properties string.
 
   bool isDefaultColor : 1;  ///< Whether the text's color is the default.
   bool isFamilyDefined : 1; ///< Whether the font's family is defined.
@@ -229,11 +242,12 @@ struct InputStyle
   bool isSlantDefined : 1;  ///< Whether the font's slant is defined.
   bool isSizeDefined : 1;   ///< Whether the font's size is defined.
 
-  bool isLineSpacingDefined : 1; ///< Whether the line spacing is defined.
-  bool isUnderlineDefined : 1;   ///< Whether the underline parameters are defined.
-  bool isShadowDefined : 1;      ///< Whether the shadow parameters are defined.
-  bool isEmbossDefined : 1;      ///< Whether the emboss parameters are defined.
-  bool isOutlineDefined : 1;     ///< Whether the outline parameters are defined.
+  bool isLineSpacingDefined : 1;   ///< Whether the line spacing is defined.
+  bool isUnderlineDefined : 1;     ///< Whether the underline parameters are defined.
+  bool isShadowDefined : 1;        ///< Whether the shadow parameters are defined.
+  bool isEmbossDefined : 1;        ///< Whether the emboss parameters are defined.
+  bool isOutlineDefined : 1;       ///< Whether the outline parameters are defined.
+  bool isStrikethroughDefined : 1; ///< Whether the strikethrough parameters are defined.
 };
 
 } // namespace Text