Merge "Update position & size of web view." into devel/master
authorJIYUN YANG <ji.yang@samsung.com>
Mon, 1 Feb 2021 08:47:18 +0000 (08:47 +0000)
committerGerrit Code Review <gerrit@review>
Mon, 1 Feb 2021 08:47:18 +0000 (08:47 +0000)
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h
dali-toolkit/devel-api/builder/builder.h
dali-toolkit/internal/builder/builder-impl.cpp
dali-toolkit/internal/controls/web-view/web-view-impl.cpp
dali-toolkit/internal/text/rendering/view-model.cpp
dali-toolkit/public-api/dali-toolkit-version.cpp
packaging/dali-toolkit.spec

index f243f08..fc4f9ac 100755 (executable)
@@ -572,6 +572,24 @@ int UtcDaliTextViewModelElideText01(void)
   DALI_TEST_CHECK( NULL != glyphs );
   DALI_TEST_CHECK( NULL != layouts );
 
+  // When the ellipsis is enabled, at least a glyph has to be rendered.
+  // Even if the given width is too narrow for rendering an ellipsis glyph.
+  controller->SetText( "…" );
+  Vector3 sizeEllipsis = controller->GetNaturalSize();
+  controller->SetText( "A" );
+  Vector3 sizeA = controller->GetNaturalSize();
+  float testWidth = sizeA.width < sizeEllipsis.width ? sizeA.width : sizeEllipsis.width - 1.0;
+
+  controller->SetText( "AB" );
+  Vector3 sizeAB = controller->GetNaturalSize();
+
+  controller->Relayout( Size(testWidth, sizeAB.height) );
+
+  // Elide the glyphs.
+  model->ElideGlyphs();
+  DALI_TEST_EQUALS( 1u, model->GetNumberOfGlyphs(), TEST_LOCATION );
+  DALI_TEST_EQUALS( 1u, model->GetNumberOfLines(), TEST_LOCATION );
+
   tet_result(TET_PASS);
   END_TEST;
 }
index a4b45c9..c6e63e7 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TEST_SUITE_UTILS_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -417,25 +417,25 @@ inline void DALI_TEST_PRINT_ASSERT(DaliException& e)
  * @param expressions code to execute
  * @param except the exception expected in the assert
  */
-#define DALI_TEST_THROWS(expressions, except)                                                               \
-  try                                                                                                       \
-  {                                                                                                         \
-    TestApplication::EnableLogging(false);                                                                  \
-    expressions;                                                                                            \
-    TestApplication::EnableLogging(true);                                                                   \
-    fprintf(stderr, "Test failed in %s, expected exception: '%s' didn't occur\n", __FILELINE__, #except);   \
-    tet_result(TET_FAIL);                                                                                   \
-    throw("TET_FAIL");                                                                                      \
-  }                                                                                                         \
-  catch(except &)                                                                                           \
-  {                                                                                                         \
-    tet_result(TET_PASS);                                                                                   \
-  }                                                                                                         \
-  catch(...)                                                                                                \
-  {                                                                                                         \
-    fprintf(stderr, "Test failed in %s, unexpected exception\n", __FILELINE__);                             \
-    tet_result(TET_FAIL);                                                                                   \
-    throw;                                                                                                  \
+#define DALI_TEST_THROWS(expressions, except)                                                             \
+  try                                                                                                     \
+  {                                                                                                       \
+    TestApplication::EnableLogging(false);                                                                \
+    expressions;                                                                                          \
+    TestApplication::EnableLogging(true);                                                                 \
+    fprintf(stderr, "Test failed in %s, expected exception: '%s' didn't occur\n", __FILELINE__, #except); \
+    tet_result(TET_FAIL);                                                                                 \
+    throw("TET_FAIL");                                                                                    \
+  }                                                                                                       \
+  catch(except&)                                                                                          \
+  {                                                                                                       \
+    tet_result(TET_PASS);                                                                                 \
+  }                                                                                                       \
+  catch(...)                                                                                              \
+  {                                                                                                       \
+    fprintf(stderr, "Test failed in %s, unexpected exception\n", __FILELINE__);                           \
+    tet_result(TET_FAIL);                                                                                 \
+    throw;                                                                                                \
   }
 
 // Functor to test whether an Applied signal is emitted
index f10f037..b255c11 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_UIBUILDER_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -163,9 +163,23 @@ public:
    * @brief Adds user defined constants to all future style template or animation expansions
    *
    * e.g.
-   *   Property::Map map;
-   *   map["IMAGE_DIRECTORY"] = "/usr/share/images";
-   *   builder.AddConstants( map );
+   * @code
+   * Property::Map map;
+   * map["IMAGE_DIRECTORY"] = "/usr/share/images";
+   * builder.AddConstants( map );
+   * @endcode
+   *
+   * The following shows a list of constants available by default:
+   *
+   *  Constant                     | Description
+   * ----------------------------- | ----------------------------------------------------------------------------------------------------
+   *   DALI_IMAGE_DIR              | The Image Directory used by Toolkit.
+   *   DALI_SOUND_DIR              | The Sound Directory used by Toolkit.
+   *   DALI_STYLE_DIR              | The Style directory that the Toolkit uses.
+   *   DALI_STYLE_IMAGE_DIR        | The directory that stores all the images used by Toolkit's style.
+   *   DALI_SHADER_VERSION_PREFIX  | For use in custom shaders to prepend the shader version in use. @ref Shader::GetShaderVersionPrefix
+   *   DALI_VERTEX_SHADER_PREFIX   | For use in custom vertex shaders to preprocessor prefix used. @ref Shader::GetVertexShaderPrefix
+   *   DALI_FRAGMENT_SHADER_PREFIX | For use in custom vertex shaders to preprocessor prefix used. @ref Shader::GetFragmentShaderPrefix()
    *
    * @pre The Builder has been initialized.
    * @param map The user defined constants used in template expansions.
@@ -180,6 +194,8 @@ public:
    * builder.AddConstant( "IMAGE_DIRECTORY", "/usr/share/images" );
    * @endcode
    *
+   * @see AddConstants(const Property::Map&) for builder pre-defined default constants.
+   *
    * @pre The Builder has been initialized.
    * @param key The constant name to add or update
    * @param value The new value for the constant.
index 8bcdff1..88c51b6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -28,6 +28,7 @@
 #include <dali/public-api/object/type-info.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/render-tasks/render-task-list.h>
+#include <dali/public-api/rendering/shader.h>
 #include <dali/public-api/signals/functor-delegate.h>
 #include <dali/devel-api/common/stage.h>
 #include <dali/devel-api/scripting/scripting.h>
@@ -156,13 +157,16 @@ Builder::Builder()
 {
   mParser = Dali::Toolkit::JsonParser::New();
 
-  Property::Map defaultDirs;
-  defaultDirs[TOKEN_STRING(DALI_IMAGE_DIR)]       = AssetManager::GetDaliImagePath();
-  defaultDirs[TOKEN_STRING(DALI_SOUND_DIR)]       = AssetManager::GetDaliSoundPath();
-  defaultDirs[TOKEN_STRING(DALI_STYLE_DIR)]       = AssetManager::GetDaliStylePath();
-  defaultDirs[TOKEN_STRING(DALI_STYLE_IMAGE_DIR)] = AssetManager::GetDaliStyleImagePath();
+  Property::Map defaultConstants;
+  defaultConstants[TOKEN_STRING(DALI_IMAGE_DIR)]              = AssetManager::GetDaliImagePath();
+  defaultConstants[TOKEN_STRING(DALI_SOUND_DIR)]              = AssetManager::GetDaliSoundPath();
+  defaultConstants[TOKEN_STRING(DALI_STYLE_DIR)]              = AssetManager::GetDaliStylePath();
+  defaultConstants[TOKEN_STRING(DALI_STYLE_IMAGE_DIR)]        = AssetManager::GetDaliStyleImagePath();
+  defaultConstants[TOKEN_STRING(DALI_SHADER_VERSION_PREFIX)]  = Shader::GetShaderVersionPrefix();
+  defaultConstants[TOKEN_STRING(DALI_VERTEX_SHADER_PREFIX)]   = Shader::GetVertexShaderPrefix();
+  defaultConstants[TOKEN_STRING(DALI_FRAGMENT_SHADER_PREFIX)] = Shader::GetFragmentShaderPrefix();
 
-  AddConstants( defaultDirs );
+  AddConstants(defaultConstants);
 }
 
 void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::UIFormat format )
index 27fee70..9e31e46 100755 (executable)
@@ -223,7 +223,7 @@ Dali::Toolkit::ImageView& WebView::GetFavicon()
     Dali::PixelData pixelData = mWebEngine.GetFavicon();
     std::string url = Dali::Toolkit::Image::GenerateUrl( pixelData );
     mFaviconView = Dali::Toolkit::ImageView::New( url );
-    mFaviconView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+    mFaviconView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
     mFaviconView.SetProperty( Dali::Actor::Property::SIZE, Vector2( pixelData.GetWidth(), pixelData.GetHeight() ) );
   }
   return mFaviconView;
index 3046f45..0e8dc61 100755 (executable)
@@ -335,7 +335,8 @@ void ViewModel::ElideGlyphs()
             // Calculate the width of the ellipsis glyph and check if it fits.
             const float ellipsisGlyphWidth = ellipsisGlyph.width + ellipsisGlyph.xBearing;
 
-            if( ellipsisGlyphWidth < removedGlypsWidth )
+            // If it is the last glyph to remove, add the ellipsis glyph without checking its width.
+            if( ( ellipsisGlyphWidth < removedGlypsWidth ) || ( index == 0u ) )
             {
               GlyphInfo& glyphInfo = *( elidedGlyphsBuffer + index );
               Vector2& position = *( elidedPositionsBuffer + index );
@@ -347,7 +348,11 @@ void ViewModel::ElideGlyphs()
               // Change the 'x' and 'y' position of the ellipsis glyph.
               if( position.x > firstPenX )
               {
-                position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth;
+                position.x = firstPenX;
+                if (ellipsisGlyphWidth < removedGlypsWidth)
+                {
+                  position.x += removedGlypsWidth - ellipsisGlyphWidth;
+                }
               }
 
               position.x += ellipsisGlyph.xBearing;
index 844fd5d..384c67e 100644 (file)
@@ -29,7 +29,7 @@ namespace Toolkit
 {
 const unsigned int TOOLKIT_MAJOR_VERSION = 2;
 const unsigned int TOOLKIT_MINOR_VERSION = 0;
-const unsigned int TOOLKIT_MICRO_VERSION = 10;
+const unsigned int TOOLKIT_MICRO_VERSION = 11;
 const char* const  TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 041c023..e7e130a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali2-toolkit
 Summary:    Dali 3D engine Toolkit
-Version:    2.0.10
+Version:    2.0.11
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT