Merge "Fix VD prevent issues" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 28 Aug 2015 16:48:45 +0000 (09:48 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Fri, 28 Aug 2015 16:48:46 +0000 (09:48 -0700)
22 files changed:
automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp
dali-toolkit/devel-api/styling/style-manager.cpp
dali-toolkit/devel-api/styling/style-manager.h
dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.cpp
dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.h
dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/styling/style-manager-impl.cpp
dali-toolkit/internal/styling/style-manager-impl.h
dali-toolkit/internal/text/decorator/text-decorator.cpp
dali-toolkit/internal/text/layouts/layout-engine.cpp
dali-toolkit/internal/text/layouts/layout-engine.h
dali-toolkit/internal/text/metrics.h [new file with mode: 0644]
dali-toolkit/internal/text/multi-language-support-impl.cpp
dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller-impl.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h
dali-toolkit/public-api/dali-toolkit-version.cpp
packaging/dali-toolkit.spec

index d5baabb..cf3e163 100644 (file)
@@ -1324,8 +1324,11 @@ int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
   currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 105, false);
   overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
   overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
-  DALI_TEST_CHECK(overshootXValue > 0.49f && overshootXValue < 0.51f);
-  DALI_TEST_CHECK(overshootYValue > 0.49f && overshootYValue < 0.51f);
+  // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
+  // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
+  float correctOvershootValue = 50.0f / 105.f;
+  DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION );
+  DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION );
 
   // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
   currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
@@ -1373,7 +1376,8 @@ int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
   Wait(application);
   // Try a vertical swipe.
   PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
-  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(10.0f, -50.0f), TEST_LOCATION );
+  // Take into account resampling done when prediction is off.
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
 
   scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
 
@@ -1389,7 +1393,7 @@ int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
   Wait(application);
   // Try a vertical swipe.
   PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
-  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(10.0f, -50.0f), TEST_LOCATION );
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
 
   END_TEST;
 }
@@ -1423,7 +1427,8 @@ int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
   Wait(application);
   // Try a vertical swipe.
   PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
-  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(10.0f, -50.0f), TEST_LOCATION );
+  // Take into account resampling done when prediction is off.
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
 
   END_TEST;
 }
index b3a0028..19e2f1f 100644 (file)
@@ -58,6 +58,11 @@ void StyleManager::SetOrientation( Orientation orientation )
   GetImpl(*this).SetOrientation( orientation );
 }
 
+std::string StyleManager::GetDefaultFontFamily() const
+{
+  return GetImpl(*this).GetDefaultFontFamily();
+}
+
 Orientation StyleManager::GetOrientation()
 {
   return GetImpl(*this).GetOrientation();
index a568bba..a1596e1 100644 (file)
@@ -115,6 +115,12 @@ public:
   Orientation GetOrientation();
 
   /**
+   * @brief Retrieves the default font family.
+   * @return The default font family.
+   */
+  std::string GetDefaultFontFamily() const;
+
+  /**
    * @brief Make a request to set the theme JSON file to one that exists in the Toolkit package.
    *
    * Multiple requests per event processing cycle can be made, but only the final one will be acted
index 592fefc..0420830 100644 (file)
@@ -112,18 +112,6 @@ void ScrollOvershootIndicator::SetOvershootEffectColor( const Vector4& color )
   }
 }
 
-void ScrollOvershootIndicator::ClearOvershoot()
-{
-  if(mEffectX)
-  {
-    mEffectX->SetOvershoot(0.0f);
-  }
-  if(mEffectY)
-  {
-    mEffectY->SetOvershoot(0.0f);
-  }
-}
-
 ScrollOvershootEffect::ScrollOvershootEffect( bool vertical ) :
     mVertical(vertical)
 {
index f19e39c..7eebe4b 100644 (file)
@@ -76,11 +76,6 @@ public:
   void Reset();
 
   /**
-   * Clears the overshoot
-   */
-  void ClearOvershoot();
-
-  /**
    * Create an initialized ScrollOvershootIndicator
    *
    * @return A pointer to the created ScrollOvershootIndicator.
index 86e9173..a8bd61e 100644 (file)
@@ -2439,11 +2439,6 @@ void ScrollView::OnPan( const PanGesture& gesture )
         {
           mScrollMainInternalPrePositionConstraint.Remove();
         }
-
-        if( mOvershootIndicator )
-        {
-          mOvershootIndicator->ClearOvershoot();
-        }
       }
       else
       {
index d633e9b..eb12543 100644 (file)
@@ -149,6 +149,9 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
 {
   Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
 
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField SetProperty\n");
+
+
   if( textField )
   {
     TextField& impl( GetImpl( textField ) );
@@ -210,7 +213,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
 
           if( impl.mController->GetDefaultFontFamily() != fontFamily )
           {
-            impl.mController->SetDefaultFontFamily( fontFamily );
+            impl.mController->SetDefaultFontFamily( fontFamily, true ); // "true" as SetProperty means user defined font so don't change when system font changes.
           }
         }
         break;
@@ -234,7 +237,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
         if( impl.mController )
         {
           const float pointSize = value.Get< float >();
-          DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_STYLE %f\n", impl.mController.Get(), pointSize );
+          DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize );
 
           if( !Equals( impl.mController->GetDefaultPointSize(), pointSize ) )
           {
@@ -929,12 +932,10 @@ void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::
    {
      case StyleChange::DEFAULT_FONT_CHANGE:
      {
-       DALI_LOG_INFO( gLogFilter, Debug::General, "TextField::OnStyleChange StyleChange::DEFAULT_FONT_CHANGE\n");
-       if ( mController->GetDefaultFontFamily() == "" )
-       {
-         // Property system did not set the font so should update it.
-         // todo instruct text-controller to update model
-       }
+       DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n");
+       std::string newFont = styleManager.GetDefaultFontFamily();
+       // Property system did not set the font so should update it.
+       mController->UpdateAfterFontChange( newFont );
        break;
      }
 
@@ -969,6 +970,8 @@ float TextField::GetHeightForWidth( float width )
 
 void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField OnRelayout\n");
+
   if( mController->Relayout( size ) ||
       !mRenderer )
   {
@@ -1130,7 +1133,15 @@ void TextField::OnPan( const PanGesture& gesture )
 
 void TextField::OnLongPress( const LongPressGesture& gesture )
 {
+  // Show the keyboard if it was hidden.
+  if (!VirtualKeyboard::IsVisible())
+  {
+    VirtualKeyboard::Show();
+  }
+
   mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y );
+
+  SetKeyInputFocus();
 }
 
 bool TextField::OnKeyEvent( const KeyEvent& event )
index 81a5c97..ce08f89 100644 (file)
@@ -151,7 +151,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
 
           if( impl.mController->GetDefaultFontFamily() != fontFamily )
           {
-            impl.mController->SetDefaultFontFamily( fontFamily );
+            impl.mController->SetDefaultFontFamily( fontFamily, true );
           }
         }
         break;
index 08d61fd..41f20e3 100644 (file)
@@ -100,6 +100,7 @@ Toolkit::StyleManager StyleManager::Get()
 StyleManager::StyleManager()
 : mOrientationDegrees( 0 ),  // Portrait
   mDefaultFontSize( -1 ),
+  mDefaultFontFamily(""),
   mThemeFile( DEFAULT_THEME ),
   mFeedbackStyle( NULL )
 {
@@ -155,6 +156,11 @@ void StyleManager::SetOrientation( Orientation orientation )
   }
 }
 
+std::string StyleManager::GetDefaultFontFamily() const
+{
+  return mDefaultFontFamily;
+}
+
 Orientation StyleManager::GetOrientation()
 {
   return mOrientation;
@@ -417,6 +423,7 @@ void StyleManager::StyleMonitorChange( StyleMonitor styleMonitor, StyleChange::T
   {
     case StyleChange::DEFAULT_FONT_CHANGE:
     {
+      mDefaultFontFamily = styleMonitor.GetDefaultFontFamily();
       break;
     }
 
index 86c6d4c..ab5e24d 100644 (file)
@@ -81,6 +81,11 @@ public:
   Orientation GetOrientation();
 
   /**
+   * @copydoc Toolkit::StyleManager::GetDefaultFontFamily
+   */
+  std::string GetDefaultFontFamily() const;
+
+  /**
    * @copydoc Toolkit::StyleManager::SetStyleConstant
    */
   void SetStyleConstant( const std::string& key, const Property::Value& value );
@@ -254,6 +259,8 @@ private:
 
   int mDefaultFontSize;               ///< Logical size, not a point-size
 
+  std::string mDefaultFontFamily;
+
   std::string mThemeFile;             ///< The full path of the current theme file
 
   Property::Map mThemeBuilderConstants;   ///< Contants to give the theme builder
index 9ec055e..69ecac3 100644 (file)
@@ -410,7 +410,6 @@ struct Decorator::Impl : public ConnectionTracker
     mHandle[ LEFT_SELECTION_HANDLE ].position += scrollOffset;
     mHandle[ RIGHT_SELECTION_HANDLE ].position += scrollOffset;
     mHighlightPosition += scrollOffset;
-    DeterminePositionPopup();
   }
 
   void ShowPopup()
index 5ee4992..9062b07 100644 (file)
@@ -105,7 +105,6 @@ struct LayoutEngine::Impl
     mCursorWidth( CURSOR_WIDTH ),
     mEllipsisEnabled( false )
   {
-    mFontClient = TextAbstraction::FontClient::Get();
   }
 
   /**
@@ -117,7 +116,7 @@ struct LayoutEngine::Impl
   void UpdateLineHeight( FontId fontId, LineLayout& lineLayout )
   {
     Text::FontMetrics fontMetrics;
-    mFontClient.GetFontMetrics( fontId, fontMetrics );
+    mMetrics->GetFontMetrics( fontId, fontMetrics );
 
     // Sets the maximum ascender.
     if( fontMetrics.ascender > lineLayout.ascender )
@@ -634,7 +633,7 @@ struct LayoutEngine::Impl
           const GlyphInfo& glyphInfo = *( layoutParameters.glyphsBuffer + layoutParameters.totalNumberOfGlyphs - 1u );
 
           Text::FontMetrics fontMetrics;
-          mFontClient.GetFontMetrics( glyphInfo.fontId, fontMetrics );
+          mMetrics->GetFontMetrics( glyphInfo.fontId, fontMetrics );
 
           LineRun lineRun;
           lineRun.glyphRun.glyphIndex = 0u;
@@ -821,7 +820,7 @@ struct LayoutEngine::Impl
   LayoutEngine::VerticalAlignment mVerticalAlignment;
   float mCursorWidth;
 
-  TextAbstraction::FontClient mFontClient;
+  IntrusivePtr<Metrics> mMetrics;
 
   bool mEllipsisEnabled:1;
 };
@@ -837,6 +836,11 @@ LayoutEngine::~LayoutEngine()
   delete mImpl;
 }
 
+void LayoutEngine::SetMetrics( MetricsPtr& metrics )
+{
+  mImpl->mMetrics = metrics;
+}
+
 void LayoutEngine::SetLayout( Layout layout )
 {
   mImpl->mLayout = layout;
index d0f1ab6..f866f3e 100644 (file)
@@ -24,6 +24,7 @@
 
 // INTERNAL INCLUDE
 #include <dali-toolkit/internal/text/line-run.h>
+#include <dali-toolkit/internal/text/metrics.h>
 
 namespace Dali
 {
@@ -74,6 +75,13 @@ public:
   ~LayoutEngine();
 
   /**
+   * @brief Provide the wrapper around FontClient used to get metrics
+   *
+   * @param[in] metrics Used to get metrics
+   */
+  void SetMetrics( MetricsPtr& metrics );
+
+  /**
    * @brief Choose the required layout.
    *
    * @param[in] layout The required layout.
diff --git a/dali-toolkit/internal/text/metrics.h b/dali-toolkit/internal/text/metrics.h
new file mode 100644 (file)
index 0000000..147ae79
--- /dev/null
@@ -0,0 +1,134 @@
+#ifndef __DALI_TOOLKIT_TEXT_METRICS_H__
+#define __DALI_TOOLKIT_TEXT_METRICS_H__
+
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
+#include <dali/devel-api/text-abstraction/font-client.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+class Metrics;
+typedef IntrusivePtr<Metrics> MetricsPtr;
+
+/**
+ * @brief A wrapper around FontClient used to get metrics & potentially down-scaled Emoji metrics.
+ */
+class Metrics : public RefObject
+{
+public:
+
+  /**
+   * Create a new Metrics object
+   */
+  static Metrics* New( TextAbstraction::FontClient& fontClient )
+  {
+    return new Metrics( fontClient );
+  }
+
+  /**
+   * @brief Set the maximum Emoji size.
+   *
+   * @param[in] emojiSize Emoticons will be scaled to fit this size in pixels.
+   */
+  void SetMaxEmojiSize( int emojiSize )
+  {
+    mEmojiSize = emojiSize;
+  }
+
+  /**
+   * @brief Get the maximum Emoji size.
+   *
+   * @return The maximum Emoji size.
+   */
+  int GetMaxEmojiSize() const
+  {
+    return mEmojiSize;
+  }
+
+  /**
+   * @brief Query the metrics for a font.
+   *
+   * @param[in] fontId The ID of the font for the required glyph.
+   * @param[out] metrics The font metrics.
+   */
+  void GetFontMetrics( FontId fontId, FontMetrics& metrics )
+  {
+    mFontClient.GetFontMetrics( fontId, metrics, mEmojiSize ); // inline for performance
+  }
+
+  /**
+   * @brief Retrieve the metrics for a series of glyphs.
+   *
+   * @param[in,out] array An array of glyph-info structures with initialized FontId & GlyphIndex values.
+   * It may contain the advance and an offset set into the bearing from the shaping tool.
+   * On return, the glyph's size value will be initialized. The bearing value will be updated by adding the font's glyph bearing to the one set by the shaping tool.
+   * @param[in] size The size of the array.
+   * @return True if all of the requested metrics were found.
+   */
+  bool GetGlyphMetrics( GlyphInfo* array, uint32_t size )
+  {
+    return mFontClient.GetGlyphMetrics( array, size, true, mEmojiSize ); // inline for performance
+  }
+
+protected:
+
+  /**
+   * A reference counted object may only be deleted by calling Unreference()
+   */
+  virtual ~Metrics() {}
+
+private:
+
+  /**
+   * Constructor.
+   */
+  Metrics( TextAbstraction::FontClient& fontClient )
+  : mFontClient( fontClient ),
+    mEmojiSize( 0 )
+  {
+  }
+
+  // Undefined
+  Metrics(const Metrics&);
+
+  // Undefined
+  Metrics& operator=(const Metrics& rhs);
+
+private:
+
+  TextAbstraction::FontClient mFontClient;
+
+  int mEmojiSize;
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_TEXT_METRICS_H__
index d730c9e..bb33981 100644 (file)
@@ -363,7 +363,7 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
 
   // Copy the fonts set by application developers.
   const Length numberOfFontRuns = fonts.Count();
-  const Vector<FontRun> definedFonts = fonts;
+  const Vector<FontRun> userSetFonts = fonts;
   fonts.Clear();
 
   // Traverse the characters and validate/set the fonts.
@@ -386,8 +386,8 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
 
   // Iterators of the font and script runs.
-  Vector<FontRun>::ConstIterator fontRunIt = definedFonts.Begin();
-  Vector<FontRun>::ConstIterator fontRunEndIt = definedFonts.End();
+  Vector<FontRun>::ConstIterator fontRunIt = userSetFonts.Begin();
+  Vector<FontRun>::ConstIterator fontRunEndIt = userSetFonts.End();
   Vector<ScriptRun>::ConstIterator scriptRunIt = scripts.Begin();
   Vector<ScriptRun>::ConstIterator scriptRunEndIt = scripts.End();
 
index a4fc1d8..026b4d6 100644 (file)
@@ -331,6 +331,16 @@ struct AtlasRenderer::Impl : public ConnectionTracker
         textCacheEntry.mIndex = glyph.index;
         newTextCache.PushBack( textCacheEntry );
 
+        // Adjust the vertices if the fixed-size font should be down-scaled
+        if( glyph.scaleFactor > 0 )
+        {
+          for( unsigned int i=0; i<newMesh.mVertices.Count(); ++i )
+          {
+            newMesh.mVertices[i].mPosition.x = position.x + ( ( newMesh.mVertices[i].mPosition.x - position.x ) * glyph.scaleFactor );
+            newMesh.mVertices[i].mPosition.y = position.y + ( ( newMesh.mVertices[i].mPosition.y - position.y ) * glyph.scaleFactor );
+          }
+        }
+
         // Find an existing mesh data object to attach to ( or create a new one, if we can't find one using the same atlas)
         StitchTextMesh( meshContainer,
                         newMesh,
index 5e64f87..f90d014 100644 (file)
@@ -78,20 +78,20 @@ namespace Text
  * @param[in] numberOfGlyphs The number of glyphs.
  * @param[out] glyphMetrics Some glyph metrics (font height, advance, ascender and x bearing).
  * @param[in] visualModel The visual model.
- * @param[in] fontClient The font client.
+ * @param[in] metrics Used to access metrics from FontClient.
  */
 void GetGlyphsMetrics( GlyphIndex glyphIndex,
                        Length numberOfGlyphs,
                        GlyphMetrics& glyphMetrics,
-                       VisualModelPtr visualModel,
-                       TextAbstraction::FontClient& fontClient )
+                       VisualModelPtr& visualModel,
+                       MetricsPtr& metrics )
 {
   const GlyphInfo* glyphsBuffer = visualModel->mGlyphs.Begin();
 
   const GlyphInfo& firstGlyph = *( glyphsBuffer + glyphIndex );
 
   Text::FontMetrics fontMetrics;
-  fontClient.GetFontMetrics( firstGlyph.fontId, fontMetrics );
+  metrics->GetFontMetrics( firstGlyph.fontId, fontMetrics );
 
   glyphMetrics.fontHeight = fontMetrics.height;
   glyphMetrics.advance = firstGlyph.advance;
@@ -423,7 +423,7 @@ void Controller::Impl::UpdateModel( OperationsMask operationsRequired )
   if( GET_GLYPH_METRICS & operations )
   {
     GlyphInfo* glyphsBuffer = glyphs.Begin();
-    mFontClient.GetGlyphMetrics( glyphsBuffer, numberOfGlyphs );
+    mMetrics->GetGlyphMetrics( glyphsBuffer, numberOfGlyphs );
 
     // Update the width and advance of all new paragraph characters.
     for( Vector<GlyphIndex>::ConstIterator it = newParagraphGlyphs.Begin(), endIt = newParagraphGlyphs.End(); it != endIt; ++it )
@@ -487,7 +487,7 @@ float Controller::Impl::GetDefaultFontLineHeight()
   }
 
   Text::FontMetrics fontMetrics;
-  mFontClient.GetFontMetrics( defaultFontId, fontMetrics );
+  mMetrics->GetFontMetrics( defaultFontId, fontMetrics );
 
   return( fontMetrics.ascender - fontMetrics.descender );
 }
@@ -1462,7 +1462,7 @@ CharacterIndex Controller::Impl::GetClosestCursorIndex( float visualX,
                       numberOfGlyphs,
                       glyphMetrics,
                       mVisualModel,
-                      mFontClient );
+                      mMetrics );
 
     const Vector2& position = *( positionsBuffer + glyphLogicalOrderIndex );
 
@@ -1601,7 +1601,7 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical,
                     primaryNumberOfGlyphs,
                     glyphMetrics,
                     mVisualModel,
-                    mFontClient );
+                    mMetrics );
 
   // Whether to add the glyph's advance to the cursor position.
   // i.e if the paragraph is left to right and the logical cursor is zero, the position is the position of the first glyph and the advance is not added,
@@ -1691,7 +1691,7 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical,
                       secondaryNumberOfGlyphs,
                       glyphMetrics,
                       mVisualModel,
-                      mFontClient );
+                      mMetrics );
 
     // Set the secondary cursor's position.
     cursorInfo.secondaryPosition.x = -glyphMetrics.xBearing + secondaryPosition.x + ( isCurrentRightToLeft ? 0.f : glyphMetrics.advance );
@@ -1777,7 +1777,7 @@ void Controller::Impl::UpdateCursorPosition()
     }
 
     Text::FontMetrics fontMetrics;
-    mFontClient.GetFontMetrics( defaultFontId, fontMetrics );
+    mMetrics->GetFontMetrics( defaultFontId, fontMetrics );
 
     lineHeight = fontMetrics.ascender - fontMetrics.descender;
 
index 3073611..e60fe37 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/clipboard.h>
 #include <dali/devel-api/text-abstraction/font-client.h>
+#include <iostream>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
@@ -174,7 +175,9 @@ struct ModifyEvent
 struct FontDefaults
 {
   FontDefaults()
-  : mDefaultPointSize(0.0f),
+  : mDefaultFontFamily(""),
+    mDefaultFontStyle(""),
+    mDefaultPointSize(0.0f),
     mFontId(0u)
   {
   }
@@ -207,13 +210,15 @@ struct Controller::Impl
     mFontClient(),
     mClipboard(),
     mView(),
+    mMetrics(),
     mLayoutEngine(),
     mModifyEvents(),
     mTextColor( Color::BLACK ),
     mAlignmentOffset(),
     mOperationsPending( NO_OPERATION ),
     mMaximumNumberOfCharacters( 50 ),
-    mRecalculateNaturalSize( true )
+    mRecalculateNaturalSize( true ),
+    mUserDefinedFontFamily( false)
   {
     mLogicalModel = LogicalModel::New();
     mVisualModel  = VisualModel::New();
@@ -223,6 +228,10 @@ struct Controller::Impl
 
     mView.SetVisualModel( mVisualModel );
 
+    // Use this to access FontClient i.e. to get down-scaled Emoji metrics.
+    mMetrics = Metrics::New( mFontClient );
+    mLayoutEngine.SetMetrics( mMetrics );
+
     // Set the text properties to default
     mVisualModel->SetUnderlineEnabled( false );
     mVisualModel->SetUnderlineHeight( 0.0f );
@@ -468,15 +477,18 @@ struct Controller::Impl
   FontDefaults* mFontDefaults;             ///< Avoid allocating this when the user does not specify a font.
   EventData* mEventData;                   ///< Avoid allocating everything for text input until EnableTextInput().
   TextAbstraction::FontClient mFontClient; ///< Handle to the font client.
-  Clipboard mClipboard;                   ///< Handle to the system clipboard
+  Clipboard mClipboard;                    ///< Handle to the system clipboard
   View mView;                              ///< The view interface to the rendering back-end.
+  MetricsPtr mMetrics;                     ///< A wrapper around FontClient used to get metrics & potentially down-scaled Emoji metrics.
   LayoutEngine mLayoutEngine;              ///< The layout engine.
   std::vector<ModifyEvent> mModifyEvents;  ///< Temporary stores the text set until the next relayout.
   Vector4 mTextColor;                      ///< The regular text color
   Vector2 mAlignmentOffset;                ///< Vertical and horizontal offset of the whole text inside the control due to alignment.
   OperationsMask mOperationsPending;       ///< Operations pending to be done to layout the text.
   Length mMaximumNumberOfCharacters;       ///< Maximum number of characters that can be inserted.
+
   bool mRecalculateNaturalSize:1;          ///< Whether the natural size needs to be recalculated.
+  bool mUserDefinedFontFamily:1;           ///< Whether the Font family was Set by the user instead of being left as sytem default
 };
 
 } // namespace Text
index e3b29bd..47afc96 100644 (file)
@@ -38,6 +38,7 @@ namespace
 #endif
 
 const float MAX_FLOAT = std::numeric_limits<float>::max();
+const unsigned int POINTS_PER_INCH = 72;
 
 const std::string EMPTY_STRING("");
 
@@ -73,6 +74,8 @@ void Controller::EnableTextInput( DecoratorPtr decorator )
 
 void Controller::SetText( const std::string& text )
 {
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText\n" );
+
   // Remove the previously set text
   ResetText();
 
@@ -222,7 +225,7 @@ int Controller::GetMaximumNumberOfCharacters()
   return mImpl->mMaximumNumberOfCharacters;
 }
 
-void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily )
+void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily, bool userDefined )
 {
   if( !mImpl->mFontDefaults )
   {
@@ -230,7 +233,7 @@ void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily )
   }
 
   mImpl->mFontDefaults->mDefaultFontFamily = defaultFontFamily;
-
+  mImpl->mUserDefinedFontFamily = userDefined;
   // Clear the font-specific data
   ClearFontData();
 
@@ -287,6 +290,15 @@ void Controller::SetDefaultPointSize( float pointSize )
 
   mImpl->mFontDefaults->mDefaultPointSize = pointSize;
 
+  unsigned int horizontalDpi( 0u );
+  unsigned int verticalDpi( 0u );
+  mImpl->mFontClient.GetDpi( horizontalDpi, verticalDpi );
+
+  // Adjust the metrics if the fixed-size font should be down-scaled
+  int maxEmojiSize( pointSize/POINTS_PER_INCH * verticalDpi );
+  DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultPointSize %p setting MaxEmojiSize %d\n", this, maxEmojiSize );
+  mImpl->mMetrics->SetMaxEmojiSize( maxEmojiSize );
+
   // Clear the font-specific data
   ClearFontData();
 
@@ -306,6 +318,23 @@ float Controller::GetDefaultPointSize() const
   return 0.0f;
 }
 
+void Controller::UpdateAfterFontChange( std::string& newDefaultFont )
+{
+  DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange");
+
+  ClearFontData();
+
+  if ( !mImpl->mUserDefinedFontFamily ) // If user defined font then should not update when system font changes
+  {
+    DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange newDefaultFont(%s)\n", newDefaultFont.c_str() );
+    mImpl->mFontDefaults->mDefaultFontFamily=newDefaultFont;
+    mImpl->UpdateModel( ALL_OPERATIONS );
+    mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
+    mImpl->mRecalculateNaturalSize = true;
+    mImpl->RequestRelayout();
+  }
+}
+
 void Controller::SetTextColor( const Vector4& textColor )
 {
   mImpl->mTextColor = textColor;
@@ -641,11 +670,24 @@ bool Controller::Relayout( const Size& size )
   // Do not re-do any operation until something changes.
   mImpl->mOperationsPending = NO_OPERATION;
 
+  // Keep the current offset and alignment as it will be used to update the decorator's positions.
+  Vector2 offset;
+  if( mImpl->mEventData )
+  {
+    offset = mImpl->mAlignmentOffset + mImpl->mEventData->mScrollPosition;
+  }
+
   // After doing the text layout, the alignment offset to place the actor in the desired position can be calculated.
   CalculateTextAlignment( size );
 
   if( mImpl->mEventData )
   {
+    // If there is a nex size, the scroll position needs to be clamped.
+    mImpl->ClampHorizontalScroll( layoutSize );
+
+    // Update the decorator's positions.
+    mImpl->mEventData->mDecorator->UpdatePositions( mImpl->mAlignmentOffset + mImpl->mEventData->mScrollPosition - offset );
+
     // Move the cursor, grab handle etc.
     updated = mImpl->ProcessInputEvents() || updated;
   }
index 99c2ab0..fa4f966 100644 (file)
@@ -178,8 +178,9 @@ public:
    * @brief Set the default font family.
    *
    * @param[in] defaultFontFamily The default font family.
+   * @param[in] userDefined If set by the user
    */
-  void SetDefaultFontFamily( const std::string& defaultFontFamily );
+  void SetDefaultFontFamily( const std::string& defaultFontFamily, bool userDefined );
 
   /**
    * @brief Retrieve the default font family.
@@ -217,6 +218,12 @@ public:
   float GetDefaultPointSize() const;
 
   /**
+   * @ brief Update the text after a font change
+   * @param[in] newDefaultFont The new font to change to
+   */
+  void UpdateAfterFontChange( std::string& newDefaultFont );
+
+  /**
    * @brief Set the text color
    *
    * @param textColor The text color
index c58a5b4..a0b3e1e 100644 (file)
@@ -31,7 +31,7 @@ namespace Toolkit
 
 const unsigned int TOOLKIT_MAJOR_VERSION = 1;
 const unsigned int TOOLKIT_MINOR_VERSION = 1;
-const unsigned int TOOLKIT_MICRO_VERSION = 0;
+const unsigned int TOOLKIT_MICRO_VERSION = 1;
 const char * const TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index e41073c..634d8e4 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali-toolkit
 Summary:    The OpenGLES Canvas Core Library Toolkit
-Version:    1.1.0
+Version:    1.1.1
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0, BSD-2.0, MIT