Extending Text Styles - Adding Dashed/Double Underline
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / visual-model-impl.h
index c355c3c..710f0ab 100644 (file)
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/color-run.h>
 #include <dali-toolkit/internal/text/line-run.h>
+#include <dali-toolkit/public-api/text/text-enumerations.h>
+
+// DEVEL INCLUDES
+#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
 
 namespace Dali
 {
@@ -117,6 +121,13 @@ public:
   // Line interface.
 
   /**
+   * @brief Retrieves the total number of lines.
+   *
+   * @return The number of lines.
+   */
+  Length GetTotalNumberOfLines() const;
+
+  /**
    * @brief Retrieves the number of lines and the index to the first line where the given range of glyphs is laid out.
    *
    * @param[in] glyphIndex Index to the first glyph.
@@ -291,6 +302,27 @@ public:
   void SetUnderlineHeight(float height);
 
   /**
+   * @brief Set the override used for underline type.
+   *
+   * @param[in] underlineType The type of the underline.
+   */
+  void SetUnderlineType(Text::Underline::Type type);
+
+  /**
+   * @brief Set the override used for the width of the dashes of the dashed underline.
+   *
+   * @param[in] width width of the dashes.
+   */
+  void SetDashedUnderlineWidth(float width);
+
+  /**
+   * @brief Set the override used for the gap between the dashes of the dashed underline.
+   *
+   * @param[in] gap gap between the dashes.
+   */
+  void SetDashedUnderlineGap(float gap);
+
+  /**
    * @brief Retrieves the underline height override
    *
    * @return Returns the override height for an underline, 0 indicates that font metrics will determine the height
@@ -298,6 +330,27 @@ public:
   float GetUnderlineHeight() const;
 
   /**
+   * @brief Retrieves the underline type override.
+   *
+   * @return Returns the override type for the underline.
+   */
+  Text::Underline::Type GetUnderlineType() const;
+
+  /**
+   * @brief Retrieves the dashed underline width.
+   *
+   * @return Returns the override width for the dashed underline.
+   */
+  float GetDashedUnderlineWidth() const;
+
+  /**
+   * @brief Retrieves the dashed underline gap.
+   *
+   * @return Returns the override gap for the dashed underline.
+   */
+  float GetDashedUnderlineGap() const;
+
+  /**
    * @brief Retrieves the number of underline runs.
    *
    * @return The number of underline runs.
@@ -374,6 +427,131 @@ public:
    */
   bool IsMarkupProcessorEnabled() const;
 
+  /**
+   * @brief Sets ellipsis position
+   * @param[in] ellipsisPosition The ellipsis position for the text
+   */
+  void SetEllipsisPosition(Toolkit::DevelText::EllipsisPosition::Type ellipsisPosition);
+
+  /**
+   * @brief Retrieves ellipsis position for text.
+   *
+   * @return The ellipsis position.
+   */
+  Toolkit::DevelText::EllipsisPosition::Type GetEllipsisPosition() const;
+
+  /**
+   * @brief Enable or disable the text elide.
+   *
+   * @param[in] enabled Whether to enable the text elide.
+   */
+  void SetTextElideEnabled(bool enabled);
+
+  /**
+   * @brief Whether the text elide property is enabled.
+   *
+   * @return @e true if the text elide property is enabled, @e false otherwise.
+   */
+  bool IsTextElideEnabled() const;
+
+  /**
+   * @brief Sets the start index of laid-out glyphs.
+   *
+   * @param[in] startIndexOfElidedGlyphs The start index of laid-out glyphs.
+   */
+  void SetStartIndexOfElidedGlyphs(GlyphIndex startIndexOfElidedGlyphs);
+
+  /**
+   * @brief Sets the end index of elided glyphs.
+   *
+   * @param[in] endIndexOfElidedGlyphs The end index of elided glyphs.
+   */
+  void SetEndIndexOfElidedGlyphs(GlyphIndex endIndexOfElidedGlyphs);
+
+  /**
+   * @brief Sets the first middle index of elided glyphs, index before ellipsis of middle.
+   *
+   * @param[in] firstMiddleIndexOfElidedGlyphs The first middle index of elided glyphs, index before ellipsis of middle.
+   */
+  void SetFirstMiddleIndexOfElidedGlyphs(GlyphIndex firstMiddleIndexOfElidedGlyphs);
+
+  /**
+   * @brief Sets the second middle index of elided glyphs, index of ellipsis of middle.
+   *
+   * @param[in] secondMiddleIndexOfElidedGlyphs The second middle index of elided glyphs, index of ellipsis of middle.
+   */
+  void SetSecondMiddleIndexOfElidedGlyphs(GlyphIndex secondMiddleIndexOfElidedGlyphs);
+
+  /**
+   * @brief Retrieves the start index of laid-out glyphs.
+   *
+   * @return The start index of laid-out glyphs.
+   */
+  GlyphIndex GetStartIndexOfElidedGlyphs() const;
+
+  /**
+   * @brief Retrieves the end index of laid-out glyphs.
+   *
+   * @return The end index of laid-out glyphs.
+   */
+  GlyphIndex GetEndIndexOfElidedGlyphs() const;
+
+  /**
+   * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle.
+   *
+   * @return The first middle index of elided glyphs, index before ellipsis of middle.
+   */
+  GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const;
+
+  /**
+   * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle.
+   *
+   * @return The second middle index of elided glyphs, index of ellipsis of middle.
+   */
+  GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const;
+
+  /**
+   * @brief Sets the text's strikethrough color.
+   *
+   * @param[in] color The text's strikethrough color.
+   */
+  void SetStrikethroughColor(const Vector4& color);
+
+  /**
+   * @brief Retrieves the text's strikethrough color.
+   *
+   * @return The text's strikethrough color.
+   */
+  const Vector4& GetStrikethroughColor() const;
+
+  /**
+   * @brief Sets the text strikethrough flag.
+   *
+   * @param[in] enabled true if strikethrough.
+   */
+  void SetStrikethroughEnabled(bool enabled);
+
+  /**
+   * @brief Returns whether the text is strikethrough or not.
+   *
+   * @return strikethrough state.
+   */
+  bool IsStrikethroughEnabled() const;
+
+  /**
+   * @brief Set the override used for strikethrough height, 0 indicates height will be come from font metrics
+   *
+   * @param[in] height The height in pixels of the strikethrough
+   */
+  void SetStrikethroughHeight(float height);
+
+  /**
+   * @brief Retrieves the strikethrough height override
+   *
+   * @return Returns the override height for a strikethrough, 0 indicates that font metrics will determine the height
+   */
+  float GetStrikethroughHeight() const;
+
 protected:
   /**
    * @brief A reference counted object may only be deleted by calling Unreference().
@@ -405,17 +583,21 @@ public:
   Vector<ColorIndex>     mColorIndices;           ///< Indices to the vector of colors for each glyphs.
   Vector<Vector4>        mBackgroundColors;       ///< Background colors of the glyphs.
   Vector<ColorIndex>     mBackgroundColorIndices; ///< Indices to the vector of background colors for each glyphs.
-
-  Vector4  mTextColor;        ///< The text color
-  Vector4  mShadowColor;      ///< Color of drop shadow
-  Vector4  mUnderlineColor;   ///< Color of underline
-  Vector4  mOutlineColor;     ///< Color of outline
-  Vector4  mBackgroundColor;  ///< Color of text background
-  Size     mControlSize;      ///< The size of the UI control.
-  Vector2  mShadowOffset;     ///< Offset for drop shadow, 0 indicates no shadow
-  float    mUnderlineHeight;  ///< Fixed height for underline to override font metrics.
-  float    mShadowBlurRadius; ///< Blur radius of shadow, 0 indicates no blur.
-  uint16_t mOutlineWidth;     ///< Width of outline.
+  Vector4                mTextColor;              ///< The text color
+  Vector4                mShadowColor;            ///< Color of drop shadow
+  Vector4                mUnderlineColor;         ///< Color of underline
+  Vector4                mOutlineColor;           ///< Color of outline
+  Vector4                mBackgroundColor;        ///< Color of text background
+  Vector4                mStrikethroughColor;     ///< Color of text background
+  Size                   mControlSize;            ///< The size of the UI control.
+  Vector2                mShadowOffset;           ///< Offset for drop shadow, 0 indicates no shadow
+  float                  mUnderlineHeight;        ///< Fixed height for underline to override font metrics.
+  float                  mStrikethroughHeight;    ///< Fixed height for strikethrough to override font metrics.
+  Text::Underline::Type  mUnderlineType;          ///< The type of the underline.
+  float                  mDashedUnderlineWidth;   ///< The width of the dashes of the dashed underline.
+  float                  mDashedUnderlineGap;     ///< The gap between the dashes of the dashed underline.
+  float                  mShadowBlurRadius;       ///< Blur radius of shadow, 0 indicates no blur.
+  uint16_t               mOutlineWidth;           ///< Width of outline.
 
 private:
   Size mNaturalSize; ///< Size of the text with no line wrapping.
@@ -424,12 +606,20 @@ private:
   // Caches to increase performance in some consecutive operations.
   LineIndex mCachedLineIndex; ///< Used to increase performance in consecutive calls to GetLineOfGlyph() or GetLineOfCharacter() with consecutive glyphs or characters.
 
+  DevelText::EllipsisPosition::Type mEllipsisPosition;                ///< Where is the location the text elide
+  GlyphIndex                        mStartIndexOfElidedGlyphs;        ///< The start index of elided glyphs.
+  GlyphIndex                        mEndIndexOfElidedGlyphs;          ///< The end index of elided glyphs.
+  GlyphIndex                        mFirstMiddleIndexOfElidedGlyphs;  ///< The first end index of elided glyphs, index before ellipsis of middle.
+  GlyphIndex                        mSecondMiddleIndexOfElidedGlyphs; ///< The first end index of elided glyphs, index of ellipsis of middle.
+  bool                              mTextElideEnabled : 1;            ///< Whether the text's elide is enabled.
+
 public:
-  bool mUnderlineEnabled : 1;  ///< Underline enabled flag
-  bool mUnderlineColorSet : 1; ///< Has the underline color been explicitly set?
-  bool mBackgroundEnabled : 1; ///< Background enabled flag
-  bool mMarkupProcessorEnabled : 1; ///< Markup-processor enabled flag
-  HyphenInfo mHyphen; ///< Contains hyphen glyph info & the character index to draw hyphen after.
+  bool       mUnderlineEnabled : 1;       ///< Underline enabled flag
+  bool       mUnderlineColorSet : 1;      ///< Has the underline color been explicitly set?
+  bool       mBackgroundEnabled : 1;      ///< Background enabled flag
+  bool       mMarkupProcessorEnabled : 1; ///< Markup-processor enabled flag
+  HyphenInfo mHyphen;                     ///< Contains hyphen glyph info & the character index to draw hyphen after.
+  bool       mStrikethroughEnabled : 1;   ///< Strikethrough enabled flag
 };
 
 } // namespace Text