Fix text AutoScroll ellipsis issue
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / layouts / layout-engine.h
index e672c53..9fa22c6 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__
-#define __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__
+#ifndef DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H
+#define DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H
 
 /*
- * Copyright (c) 2015 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.
  */
 
 // EXTERNAL INCLUDE
+#include <dali/public-api/actors/actor-enumerations.h>
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/math/vector2.h>
 
 // INTERNAL INCLUDE
 #include <dali-toolkit/internal/text/line-run.h>
 #include <dali-toolkit/internal/text/metrics.h>
+#include <dali-toolkit/public-api/text/text-enumerations.h>
+
+//DEVEL INCLUDE
+#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 namespace Text
 {
-
-struct LayoutParameters;
+namespace Layout
+{
+struct Parameters;
 
 /**
  * @brief LayoutEngine is responsible for calculating the visual position of glyphs in layout.
  */
-class LayoutEngine
+class Engine
 {
 public:
-
-  enum Layout
+  enum Type
   {
     SINGLE_LINE_BOX,
     MULTI_LINE_BOX
   };
 
-  enum HorizontalAlignment
-  {
-    HORIZONTAL_ALIGN_BEGIN,
-    HORIZONTAL_ALIGN_CENTER,
-    HORIZONTAL_ALIGN_END
-  };
-
-  enum VerticalAlignment
-  {
-    VERTICAL_ALIGN_TOP,
-    VERTICAL_ALIGN_CENTER,
-    VERTICAL_ALIGN_BOTTOM
-  };
-
   /**
    * @brief Create a new instance of a LayoutEngine.
    */
-  LayoutEngine();
+  Engine();
 
   /**
    * @brief Virtual destructor.
    */
-  ~LayoutEngine();
+  ~Engine();
 
   /**
    * @brief Provide the wrapper around FontClient used to get metrics
    *
    * @param[in] metrics Used to get metrics
    */
-  void SetMetrics( MetricsPtr& metrics );
+  void SetMetrics(MetricsPtr& metrics);
 
   /**
    * @brief Choose the required layout.
    *
    * @param[in] layout The required layout.
    */
-  void SetLayout( Layout layout );
+  void SetLayout(Type layout);
 
   /**
    * @brief Query the required layout.
    *
    * @return The required layout.
    */
-  Layout GetLayout() const;
+  Type GetLayout() const;
 
   /**
-   * @brief Enable or disable the text ellipsis.
+   * @brief Sets the width of the cursor.
    *
-   * @param[in] enabled Whether to enable the text ellipsis.
-   */
-  void SetTextEllipsisEnabled( bool enabled );
-
-  /**
-   * @return Whether the text ellipsis is enabled.
+   * @param[in] width The width of the cursor in pixels.
    */
-  bool GetTextEllipsisEnabled() const;
+  void SetCursorWidth(int width);
 
   /**
-   * @brief Choose the required text horizontal alignment.
+   * @brief Retrieves the width of the cursor.
    *
-   * @param[in] alignment The required alignment.
+   * @return The width of the cursor in pixels.
    */
-  void SetHorizontalAlignment( HorizontalAlignment alignment );
+  int GetCursorWidth() const;
 
   /**
-   * @brief Query the required text horizontal alignment.
+   * @brief Store the visual position of glyphs in the VisualModel.
+   *
+   * Builds the bidirectional info and reorders RTL lines.
    *
-   * @return The required alignment.
+   * @param[in,out] layoutParameters The parameters needed to layout the text.
+   * @param[out] layoutSize The size of the text after it has been laid-out.
+   * @param[in] elideTextEnabled Whether the text elide is enabled.
+   * @param[in,out] isAutoScrollEnabled If the isAutoScrollEnabled is true and the height of the text exceeds the boundaries of the control the text is elided and the isAutoScrollEnabled is set to false to disable the autoscroll
+   * @param[in] isAutoScrollMaxTextureExceeded If isAutoScrollMaxTextureExceeded is true, enable ellipsis during auro scroll.
+   * @param[in] ellipsisPosition The location of the text ellipsis
+   *
+   * @return \e true if the text has been re-laid-out. \e false means the given width is too small to layout even a single character.
    */
-  HorizontalAlignment GetHorizontalAlignment() const;
+  bool LayoutText(Parameters&                       layoutParameters,
+                  Size&                             layoutSize,
+                  bool                              elideTextEnabled,
+                  bool&                             isAutoScrollEnabled,
+                  bool                              isAutoScrollMaxTextureExceeded,
+                  DevelText::EllipsisPosition::Type ellipsisPosition);
 
   /**
-   * @brief Choose the required text vertical alignment.
+   * @brief Aligns the laid out lines.
    *
-   * @param[in] alignment The required alignment.
+   * @param[in] size The size of the container where the text is laid-out.
+   * @param[in] startIndex Character index of the line from where the lines are aligned.
+   * @param[in] numberOfCharacters The number of characters.
+   * @param[in] horizontalAlignment The horizontal alignment.
+   * @param[in,out] lines The laid-out lines.
+   * @param[out] alignmentOffset The alignment offset.
+   * @param[in] layoutDirection The direction of the layout.
+   * @param[in] matchLayoutDirection Whether match align for layout direction or not.
    */
-  void SetVerticalAlignment( VerticalAlignment alignment );
+  void Align(const Size&                     size,
+             CharacterIndex                  startIndex,
+             Length                          numberOfCharacters,
+             Text::HorizontalAlignment::Type horizontalAlignment,
+             Vector<LineRun>&                lines,
+             float&                          alignmentOffset,
+             Dali::LayoutDirection::Type     layoutDirection,
+             bool                            matchLayoutDirection);
 
   /**
-   * @brief Query the required text vertical alignment.
+   * @brief Sets the default line spacing.
    *
-   * @return The required alignment.
+   * @param[in] lineSpacing The line spacing.
    */
-  VerticalAlignment GetVerticalAlignment() const;
+  void SetDefaultLineSpacing(float lineSpacing);
 
   /**
-   * @brief Sets the width of the cursor.
+   * @brief Retrieves the default line spacing.
    *
-   * @param[in] width The width of the cursor in pixels.
+   * @return The line spacing.
    */
-  void SetCursorWidth( int width );
+  float GetDefaultLineSpacing() const;
 
   /**
-   * @brief Retrieves the width of the cursor.
+   * @brief Sets the default line size.
    *
-   * @return The width of the cursor in pixels.
+   * @param[in] lineSize The line size.
    */
-  int GetCursorWidth() const;
+  void SetDefaultLineSize(float lineSize);
 
   /**
-   * @brief Store the visual position of glyphs in the VisualModel.
-   *
-   * @param[in] layoutParameters The parameters needed to layout the text.
-   * @param[out] glyphPositions The positions of all the glyphs.
-   * @param[out] lines The laid-out lines.
-   * @param[out] layoutSize The size of the text after it has been laid-out.
+   * @brief Retrieves the default line size.
    *
-   * @return \e true if the text has been re-laid-out. \e false means the given width is too small to layout even a single character.
+   * @return The line size.
    */
-  bool LayoutText( const LayoutParameters& layoutParameters,
-                   Vector<Vector2>& glyphPositions,
-                   Vector<LineRun>& lines,
-                   Size& layoutSize );
+  float GetDefaultLineSize() const;
 
   /**
-   * @brief Re-lays out those lines with right to left characters.
-   *
-   * It doesn't change the phisical position of the glyphs in the model but sets their new position.
+   * @brief Sets relative line size to the original line size.
    *
-   * @param[in] layoutParameters The parameters needed to layout the text.
-   * @param[in] startIndex Character index of the line from where the lines are reordered.
-   * @param[in] numberOfCharacters The number of characters.
-   * @param[in,out] glyphPositions The positions of all the glyphs.
+   * @param[in] relativeLineSize The relative line size.
    */
-  void ReLayoutRightToLeftLines( const LayoutParameters& layoutParameters,
-                                 CharacterIndex startIndex,
-                                 Length numberOfCharacters,
-                                 Vector<Vector2>& glyphPositions );
+  void SetRelativeLineSize(float relativeLineSize);
 
   /**
-   * @brief Aligns the laid out lines.
+   * @brief Retrieves the relative line size.
    *
-   * @param[in] size The size of the container where the text is laid-out.
-   * @param[in] startIndex Character index of the line from where the lines are aligned.
-   * @param[in] numberOfCharacters The number of characters.
-   * @param[in,out] lines The laid-out lines.
+   * @return The relative line size.
    */
-  void Align( const Size& size,
-              CharacterIndex startIndex,
-              Length numberOfCharacters,
-              Vector<LineRun>& lines );
+  float GetRelativeLineSize() const;
 
 private:
-
   // Undefined
-  LayoutEngine( const LayoutEngine& handle );
+  Engine(const Engine& handle);
 
   // Undefined
-  LayoutEngine& operator=( const LayoutEngine& handle );
+  Engine& operator=(const Engine& handle);
 
 private:
-
   struct Impl;
   Impl* mImpl;
 };
+
+} // namespace Layout
+
 } // namespace Text
 
 } // namespace Toolkit
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__
+#endif // DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H