Merge "dali-swig in ubuntu crash fix" into devel/master
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 30 Mar 2017 08:58:23 +0000 (01:58 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 30 Mar 2017 08:58:24 +0000 (01:58 -0700)
12 files changed:
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
dali-toolkit/devel-api/controls/text-controls/hidden-input-properties.h [new file with mode: 0644]
dali-toolkit/devel-api/controls/text-controls/text-field-devel.h [new file with mode: 0644]
dali-toolkit/devel-api/file.list [changed mode: 0755->0644]
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/file.list [changed mode: 0755->0644]
dali-toolkit/internal/text/hidden-text.cpp [new file with mode: 0644]
dali-toolkit/internal/text/hidden-text.h [new file with mode: 0644]
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

index 5f53c6f..54185ff 100644 (file)
@@ -27,6 +27,8 @@
 #include <dali/integration-api/events/long-press-gesture-event.h>
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/text-controls/hidden-input-properties.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
 #include "toolkit-clipboard.h"
 
 using namespace Dali;
@@ -94,6 +96,8 @@ const char* const PROPERTY_NAME_INPUT_EMBOSS                         = "inputEmb
 const char* const PROPERTY_NAME_OUTLINE                              = "outline";
 const char* const PROPERTY_NAME_INPUT_OUTLINE                        = "inputOutline";
 
+const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS                = "hiddenInputSettings";
+
 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
 
 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
@@ -315,19 +319,39 @@ bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Ma
     {
       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
 
-      Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
-      if( NULL != valueSet )
+      if( valueGet.first.type == Property::Key::STRING )
       {
-        if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
+        Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
+        if( NULL != valueSet )
+        {
+          if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
+          {
+            tet_printf( "  Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
+            return false;
+          }
+        }
+        else
         {
-          tet_printf( "  Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
+          tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
           return false;
         }
       }
       else
       {
-        tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
-        return false;
+        Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
+        if( NULL != valueSet )
+        {
+          if( valueGet.second.Get<int>() != valueSet->Get<int>() )
+          {
+            tet_printf( "  Integer Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
+            return false;
+          }
+        }
+        else
+        {
+          tet_printf( "  The Int key %d doesn't exist.", valueGet.first.indexKey );
+          return false;
+        }
       }
     }
   }
@@ -474,6 +498,7 @@ int UtcDaliTextFieldGetPropertyP(void)
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
+  DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
 
   END_TEST;
 }
@@ -795,6 +820,19 @@ int UtcDaliTextFieldSetPropertyP(void)
   field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
 
+  // Check the hidden input settings property
+  Property::Map hiddenMapSet;
+  Property::Map hiddenMapGet;
+  hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
+  hiddenMapSet[ HiddenInput::Property::SHOW_DURATION ] = 2;
+  hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
+  hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
+  field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
+
+  hiddenMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
+  DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
+
   END_TEST;
 }
 
@@ -1964,6 +2002,92 @@ int utcDaliTextFieldEvent08(void)
   END_TEST;
 }
 
+int utcDaliTextFieldEvent09(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" utcDaliTextFieldEvent09");
+
+  TextField field = TextField::New();
+  DALI_TEST_CHECK( field );
+  Stage::GetCurrent().Add( field );
+  LoadMarkerImages(application, field);
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  field.SetProperty( TextField::Property::TEXT, "Hello" );
+  field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
+  field.SetSize( 300.f, 50.f );
+  field.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  // Create a tap event to touch the text field.
+  application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
+  application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
+  application.SendNotification();
+  application.Render();
+
+  Property::Map map;
+  map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
+  field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
+  application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down ) );
+  application.SendNotification();
+  application.Render();
+
+  map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
+  map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
+  field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
+  application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down ) );
+  application.SendNotification();
+  application.Render();
+
+  map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
+  map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
+  field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
+  for( unsigned int index = 0u; index < 5u; ++index )
+  {
+    application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down ) );
+    application.SendNotification();
+    application.Render();
+  }
+
+  map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
+  map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
+  field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
+  for( unsigned int index = 0u; index < 5u; ++index )
+  {
+    application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down ) );
+    application.SendNotification();
+    application.Render();
+  }
+
+  map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
+  map[ HiddenInput::Property::SHOW_DURATION ] = 0;
+  field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
+  application.SendNotification();
+  application.Render();
+  application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down ) );
+  application.SendNotification();
+  application.Render();
+
+  map[ HiddenInput::Property::SHOW_DURATION ] = 100;
+  field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
+  application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down ) );
+  application.SendNotification();
+  application.Render();
+
+  Property::Map mapGet;
+  mapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
+  DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
+  END_TEST;
+}
+
+
 int utcDaliTextFieldStyleWhilstSelected(void)
 {
   ToolkitTestApplication application;
diff --git a/dali-toolkit/devel-api/controls/text-controls/hidden-input-properties.h b/dali-toolkit/devel-api/controls/text-controls/hidden-input-properties.h
new file mode 100644 (file)
index 0000000..4cbafaa
--- /dev/null
@@ -0,0 +1,111 @@
+#ifndef __DALI_HIDDEN_TEXT_PROPERTIES_H__
+#define __DALI_HIDDEN_TEXT_PROPERTIES_H__
+
+/*
+ * Copyright (c) 2017 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
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace HiddenInput
+{
+
+/**
+ * @brief HiddenInput Property
+ * @SINCE_1_2.33
+ */
+namespace Property
+{
+
+/**
+ * @brief HiddenInput Property
+ * @SINCE_1_2.33
+ */
+enum
+{
+  /**
+   * @brief The mode for input text display.
+   * @details Name "mode", type HiddenInput::Mode or INTEGER.
+   * @SINCE_1_2.33
+   * @note Optional.
+   * @see HiddenInput::Mode
+   */
+  MODE,
+
+  /**
+   * @brief All input characters are substituted by this character.
+   * @details Name "substituteCharacter", type INTEGER.
+   * @SINCE_1_2.33
+   * @note Optional.
+   */
+  SUBSTITUTE_CHARACTER,
+
+  /**
+   * @brief Length of text to show or hide, available when HIDE_COUNT/SHOW_COUNT mode is used.
+   * @details Name "substituteCount", type INTEGER.
+   * @SINCE_1_2.33
+   * @note Optional.
+   */
+  SUBSTITUTE_COUNT,
+
+  /**
+   * @brief Hide last character after this duration, available when SHOW_LAST_CHARACTER mode.
+   * @details Name "showDuration", type INTEGER.
+   * @SINCE_1_2.33
+   * @note Optional.
+   */
+  SHOW_DURATION
+};
+
+} // namespace Property
+
+/**
+ * @brief The type for HiddenInput::Property::MODE.
+ * @SINCE_1_2.33
+ */
+namespace Mode
+{
+
+/**
+ * @brief The type for HiddenInput::Property::MODE.
+ * @SINCE_1_2.33
+ */
+enum Type
+{
+  HIDE_NONE,  ///< Don't hide text
+  HIDE_ALL,   ///< Hide all the input text
+  HIDE_COUNT,  ///< Hide n characters from start
+  SHOW_COUNT,  ///< Show n characters from start
+  SHOW_LAST_CHARACTER  ///< Show last character for the duration(use SHOW_DURATION property to modify duration)
+};
+
+} // namespace Mode
+
+} // namespace HiddenInput
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_HIDDEN_TEXT_PROPERTIES_H__
diff --git a/dali-toolkit/devel-api/controls/text-controls/text-field-devel.h b/dali-toolkit/devel-api/controls/text-controls/text-field-devel.h
new file mode 100644 (file)
index 0000000..eacd5aa
--- /dev/null
@@ -0,0 +1,102 @@
+#ifndef DALI_TOOLKIT_TEXT_FIELD_DEVEL_H
+#define DALI_TOOLKIT_TEXT_FIELD_DEVEL_H
+
+/*
+ * Copyright (c) 2017 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/text-controls/text-field.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace DevelTextField
+{
+
+namespace Property
+{
+  enum Type
+  {
+      RENDERING_BACKEND = Dali::Toolkit::TextField::Property::RENDERING_BACKEND,
+      TEXT = Dali::Toolkit::TextField::Property::TEXT,
+      PLACEHOLDER_TEXT = Dali::Toolkit::TextField::Property::PLACEHOLDER_TEXT,
+      PLACEHOLDER_TEXT_FOCUSED = Dali::Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED,
+      FONT_FAMILY = Dali::Toolkit::TextField::Property::FONT_FAMILY,
+      FONT_STYLE = Dali::Toolkit::TextField::Property::FONT_STYLE,
+      POINT_SIZE = Dali::Toolkit::TextField::Property::POINT_SIZE,
+      MAX_LENGTH = Dali::Toolkit::TextField::Property::MAX_LENGTH,
+      EXCEED_POLICY = Dali::Toolkit::TextField::Property::EXCEED_POLICY,
+      HORIZONTAL_ALIGNMENT = Dali::Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT,
+      VERTICAL_ALIGNMENT = Dali::Toolkit::TextField::Property::VERTICAL_ALIGNMENT,
+      TEXT_COLOR = Dali::Toolkit::TextField::Property::TEXT_COLOR,
+      PLACEHOLDER_TEXT_COLOR = Dali::Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR,
+      SHADOW_OFFSET = Dali::Toolkit::TextField::Property::SHADOW_OFFSET,
+      SHADOW_COLOR = Dali::Toolkit::TextField::Property::SHADOW_COLOR,
+      PRIMARY_CURSOR_COLOR = Dali::Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR,
+      SECONDARY_CURSOR_COLOR = Dali::Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR,
+      ENABLE_CURSOR_BLINK = Dali::Toolkit::TextField::Property::ENABLE_CURSOR_BLINK,
+      CURSOR_BLINK_INTERVAL = Dali::Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL,
+      CURSOR_BLINK_DURATION = Dali::Toolkit::TextField::Property::CURSOR_BLINK_DURATION,
+      CURSOR_WIDTH = Dali::Toolkit::TextField::Property::CURSOR_WIDTH,
+      GRAB_HANDLE_IMAGE = Dali::Toolkit::TextField::Property::GRAB_HANDLE_IMAGE,
+      GRAB_HANDLE_PRESSED_IMAGE = Dali::Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE,
+      SCROLL_THRESHOLD = Dali::Toolkit::TextField::Property::SCROLL_THRESHOLD,
+      SCROLL_SPEED = Dali::Toolkit::TextField::Property::SCROLL_SPEED,
+      SELECTION_HANDLE_IMAGE_LEFT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT,
+      SELECTION_HANDLE_IMAGE_RIGHT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT,
+      SELECTION_HANDLE_PRESSED_IMAGE_LEFT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT,
+      SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT,
+      SELECTION_HANDLE_MARKER_IMAGE_LEFT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT,
+      SELECTION_HANDLE_MARKER_IMAGE_RIGHT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT,
+      SELECTION_HIGHLIGHT_COLOR = Dali::Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR,
+      DECORATION_BOUNDING_BOX = Dali::Toolkit::TextField::Property::DECORATION_BOUNDING_BOX,
+      INPUT_METHOD_SETTINGS = Dali::Toolkit::TextField::Property::INPUT_METHOD_SETTINGS,
+      INPUT_COLOR = Dali::Toolkit::TextField::Property::INPUT_COLOR,
+      ENABLE_MARKUP = Dali::Toolkit::TextField::Property::ENABLE_MARKUP,
+      INPUT_FONT_FAMILY = Dali::Toolkit::TextField::Property::INPUT_FONT_FAMILY,
+      INPUT_FONT_STYLE = Dali::Toolkit::TextField::Property::INPUT_FONT_STYLE,
+      INPUT_POINT_SIZE = Dali::Toolkit::TextField::Property::INPUT_POINT_SIZE,
+      UNDERLINE = Dali::Toolkit::TextField::Property::UNDERLINE,
+      INPUT_UNDERLINE = Dali::Toolkit::TextField::Property::INPUT_UNDERLINE,
+      SHADOW = Dali::Toolkit::TextField::Property::SHADOW,
+      INPUT_SHADOW = Dali::Toolkit::TextField::Property::INPUT_SHADOW,
+      EMBOSS = Dali::Toolkit::TextField::Property::EMBOSS,
+      INPUT_EMBOSS = Dali::Toolkit::TextField::Property::INPUT_EMBOSS,
+      OUTLINE = Dali::Toolkit::TextField::Property::OUTLINE,
+      INPUT_OUTLINE = Dali::Toolkit::TextField::Property::INPUT_OUTLINE,
+
+      /**
+       * @brief Hides the input characters and instead shows a default character for password or pin entry.
+       * @details name "hiddenInputSettings", type map.
+       * @SINCE_1_2.33
+       * @note Optional.
+       * @see HiddenInput
+       */
+      HIDDEN_INPUT_SETTINGS = INPUT_OUTLINE + 1,
+  };
+} // namespace Property
+
+} // namespace DevelText
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_FIELD_DEVEL_H
old mode 100755 (executable)
new mode 100644 (file)
index 7e66e66..d7c45f5
@@ -129,7 +129,9 @@ devel_api_super_blur_view_header_files = \
   $(devel_api_src_dir)/controls/super-blur-view/super-blur-view.h
 
 devel_api_text_controls_header_files = \
+  $(devel_api_src_dir)/controls/text-controls/hidden-input-properties.h \
   $(devel_api_src_dir)/controls/text-controls/text-editor-devel.h \
+  $(devel_api_src_dir)/controls/text-controls/text-field-devel.h \
   $(devel_api_src_dir)/controls/text-controls/text-selection-popup.h \
   $(devel_api_src_dir)/controls/text-controls/text-selection-toolbar.h
 
index 2e300b1..a7bfc38 100644 (file)
@@ -23,6 +23,7 @@
 #include <dali/public-api/adaptor-framework/key.h>
 #include <dali/public-api/common/stage.h>
 #include <dali/public-api/images/resource-image.h>
+#include <dali/devel-api/object/property-helper-devel.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/integration-api/adaptors/adaptor.h>
 #include <dali/integration-api/debug.h>
@@ -32,6 +33,7 @@
 #include <dali-toolkit/public-api/visuals/color-visual-properties.h>
 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/internal/text/rendering/text-backend.h>
 #include <dali-toolkit/internal/text/text-effects-style.h>
@@ -135,6 +137,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "emboss",
 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputEmboss",                          MAP,       INPUT_EMBOSS                         )
 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "outline",                              MAP,       OUTLINE                              )
 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputOutline",                         MAP,       INPUT_OUTLINE                        )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "hiddenInputSettings",            MAP,       HIDDEN_INPUT_SETTINGS                )
 
 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged",        SIGNAL_TEXT_CHANGED )
 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached",   SIGNAL_MAX_LENGTH_REACHED )
@@ -723,6 +726,15 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
         }
         break;
       }
+      case Toolkit::DevelTextField::Property::HIDDEN_INPUT_SETTINGS:
+      {
+        const Property::Map* map = value.GetMap();
+        if (map)
+        {
+          impl.mController->SetHiddenInputOption(*map);
+        }
+        break;
+      }
     } // switch
   } // textfield
 }
@@ -1086,6 +1098,13 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde
         GetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
         break;
       }
+      case Toolkit::DevelTextField::Property::HIDDEN_INPUT_SETTINGS:
+      {
+        Property::Map map;
+        impl.mController->GetHiddenInputOption(map);
+        value = map;
+        break;
+      }
     } //switch
   }
 
old mode 100755 (executable)
new mode 100644 (file)
index 12c2274..0799c9e
@@ -111,6 +111,7 @@ toolkit_src_files = \
    $(toolkit_src_dir)/text/markup-processor-font.cpp \
    $(toolkit_src_dir)/text/markup-processor-helper-functions.cpp \
    $(toolkit_src_dir)/text/multi-language-support.cpp \
+   $(toolkit_src_dir)/text/hidden-text.cpp \
    $(toolkit_src_dir)/text/property-string-parser.cpp \
    $(toolkit_src_dir)/text/segmentation.cpp \
    $(toolkit_src_dir)/text/shaper.cpp \
diff --git a/dali-toolkit/internal/text/hidden-text.cpp b/dali-toolkit/internal/text/hidden-text.cpp
new file mode 100644 (file)
index 0000000..f938430
--- /dev/null
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2017 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/text/hidden-text.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
+
+using namespace Dali::Toolkit;
+
+const uint32_t STAR = 0x2A;   // Set default substitute character as '*'
+const int DEFAULT_SHOW_DURATION = 1000;
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+const char * const PROPERTY_MODE                      = "mode";
+const char * const PROPERTY_SUBSTITUTE_CHARACTER      = "substituteCharacter";
+const char * const PROPERTY_SUBSTITUTE_COUNT          = "substituteCount";
+const char * const PROPERTY_SHOW_DURATION             = "showDuration";
+
+HiddenText::HiddenText( Observer* observer )
+: mObserver( observer ),
+  mHideMode( static_cast< int >( Toolkit::HiddenInput::Mode::HIDE_NONE ) ),
+  mSubstituteText( STAR ),
+  mDisplayDuration( DEFAULT_SHOW_DURATION ),
+  mSubstituteCount( 0 ),
+  mPreviousTextCount( 0 )
+{
+  mTimer = Timer::New( mDisplayDuration );
+  mTimer.TickSignal().Connect( this, &HiddenText::OnTick );
+}
+
+void HiddenText::SetProperties( const Property::Map& map )
+{
+    const Property::Map::SizeType count = map.Count();
+
+    for ( Property::Map::SizeType position = 0; position < count; ++position )
+    {
+      KeyValuePair keyValue = map.GetKeyValue( position );
+      Property::Key& key = keyValue.first;
+      Property::Value& value = keyValue.second;
+
+      if( key == Toolkit::HiddenInput::Property::MODE || key == PROPERTY_MODE )
+      {
+        value.Get( mHideMode );
+      }
+      else if( key == Toolkit::HiddenInput::Property::SUBSTITUTE_CHARACTER || key == PROPERTY_SUBSTITUTE_CHARACTER )
+      {
+        value.Get( mSubstituteText );
+      }
+      else if( key == Toolkit::HiddenInput::Property::SUBSTITUTE_COUNT || key == PROPERTY_SUBSTITUTE_COUNT )
+      {
+        value.Get( mSubstituteCount );
+      }
+      else if( key == Toolkit::HiddenInput::Property::SHOW_DURATION || key == PROPERTY_SHOW_DURATION )
+      {
+        value.Get( mDisplayDuration );
+      }
+    }
+}
+
+void HiddenText::GetProperties( Property::Map& map )
+{
+  map[Toolkit::HiddenInput::Property::MODE] = mHideMode;
+  map[Toolkit::HiddenInput::Property::SUBSTITUTE_CHARACTER] = mSubstituteText;
+  map[Toolkit::HiddenInput::Property::SUBSTITUTE_COUNT] = mSubstituteCount;
+  map[Toolkit::HiddenInput::Property::SHOW_DURATION] = mDisplayDuration;
+}
+
+void HiddenText::Substitute( const Vector<Character>& source, Vector<Character>& destination )
+{
+  const Length characterCount = source.Count();
+
+  destination.Resize( characterCount );
+
+  uint32_t* begin = destination.Begin();
+  uint32_t* end = begin + characterCount;
+  uint32_t* hideStart = NULL;
+  uint32_t* hideEnd = NULL;
+  uint32_t* sourcePos = source.Begin();
+
+  switch ( mHideMode )
+  {
+    case Toolkit::HiddenInput::Mode::HIDE_NONE:
+    {
+      hideStart = NULL;
+      hideEnd = NULL;
+      break;
+    }
+    case Toolkit::HiddenInput::Mode::HIDE_ALL:
+    {
+      hideStart = begin;
+      hideEnd = end;
+      break;
+    }
+    case Toolkit::HiddenInput::Mode::HIDE_COUNT:
+    {
+      hideStart = begin;
+      hideEnd = begin + mSubstituteCount;
+      break;
+    }
+    case Toolkit::HiddenInput::Mode::SHOW_COUNT:
+    {
+      hideStart = begin + mSubstituteCount;
+      hideEnd = end;
+      break;
+    }
+    case Toolkit::HiddenInput::Mode::SHOW_LAST_CHARACTER:
+    {
+      if (mPreviousTextCount < characterCount)
+      {
+        hideStart = begin;
+        hideEnd = end-1;
+        if ( mDisplayDuration > 0 )
+        {
+          mTimer.SetInterval( mDisplayDuration );
+          mTimer.Start();
+        }
+        else
+        {
+          OnTick();
+        }
+      }
+      else
+      {
+        hideStart = begin;
+        hideEnd = end;
+      }
+      break;
+    }
+  }
+  for (; begin < end; ++begin )
+  {
+    if (begin >= hideStart && begin < hideEnd)
+    {
+      *begin = static_cast<uint32_t>(mSubstituteText);
+      sourcePos++;
+    }
+    else
+    {
+      *begin = *sourcePos++;
+    }
+  }
+  mPreviousTextCount = characterCount;
+}
+
+bool HiddenText::OnTick()
+{
+  if( mObserver != NULL )
+  {
+    mObserver->DisplayTimeExpired();
+  }
+
+  return false;
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/text/hidden-text.h b/dali-toolkit/internal/text/hidden-text.h
new file mode 100644 (file)
index 0000000..10d1f54
--- /dev/null
@@ -0,0 +1,103 @@
+#ifndef __DALI_HIDDEN_TEXT_H__
+#define __DALI_HIDDEN_TEXT_H__
+
+/*
+ * Copyright (c) 2017 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/adaptor-framework/timer.h>
+#include <dali/public-api/object/property-map.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/text-controls/hidden-input-properties.h>
+#include <dali-toolkit/internal/text/text-definitions.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+/**
+ * Class to handle the hidden text
+ */
+class HiddenText : public ConnectionTracker
+{
+public:
+  class Observer
+  {
+  public:
+
+    /**
+     * @brief Invoked when the time to show last character is expired
+     */
+    virtual void DisplayTimeExpired() = 0;
+  };
+
+  /**
+   * @brief Constructor
+   * @param[in] observer The Observer pointer.
+   */
+  HiddenText( Observer* observer );
+
+public: // Intended for internal use
+
+  /**
+   * @brief Used to set options of hidden text
+   * @param[in] map The property map describing the option
+   */
+  void SetProperties( const Property::Map& map );
+
+  /**
+   * @brief Retrieve property map of hidden text options
+   * @param[out] map The hidden text option
+   */
+  void GetProperties( Property::Map& map );
+
+  /**
+   * @brief Convert source text to destination text according to current option
+   * @param[in] source The original text
+   * @param[out] destination The applied text
+   */
+  void Substitute( const Vector<Character>& source, Vector<Character>& destination );
+
+  /**
+   * @brief Invoked when the timer is expired
+   */
+  bool OnTick();
+
+private:
+
+  Timer mTimer;
+  Observer* mObserver;
+  int mHideMode;
+  int mSubstituteText;
+  int mDisplayDuration;
+  int mSubstituteCount;
+  Length mPreviousTextCount;
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_HIDDEN_TEXT_H__
index 05f3536..d09e1ed 100644 (file)
@@ -55,7 +55,6 @@ struct SelectionBoxInfo
 const float MAX_FLOAT = std::numeric_limits<float>::max();
 const float MIN_FLOAT = std::numeric_limits<float>::min();
 const Dali::Toolkit::Text::CharacterDirection LTR = false; ///< Left To Right direction
-const uint32_t STAR = 0x2A;
 
 } // namespace
 
@@ -789,24 +788,16 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
     return false;
   }
 
-  Vector<Character> utf32CharactersStar;
-  const Length characterCount = mModel->mLogicalModel->mText.Count();
-  const bool isPasswordInput = ( mEventData != NULL && mEventData->mPasswordInput &&
-        !mEventData->mIsShowingPlaceholderText && characterCount > 0 );
-
-  if (isPasswordInput)
+  Vector<Character>& srcCharacters = mModel->mLogicalModel->mText;
+  Vector<Character> displayCharacters;
+  bool useHiddenText = false;
+  if ( mHiddenInput && mEventData != NULL && !mEventData->mIsShowingPlaceholderText)
   {
-    utf32CharactersStar.Resize( characterCount );
-
-    uint32_t* begin = utf32CharactersStar.Begin();
-    uint32_t* end = begin + characterCount;
-    while ( begin < end )
-    {
-      *begin++ = STAR;
-    }
+    mHiddenInput->Substitute( srcCharacters,displayCharacters );
+    useHiddenText = true;
   }
 
-  Vector<Character>& utf32Characters = isPasswordInput ? utf32CharactersStar : mModel->mLogicalModel->mText;
+  Vector<Character>& utf32Characters = useHiddenText ? displayCharacters : srcCharacters;
   const Length numberOfCharacters = utf32Characters.Count();
 
   // Index to the first character of the first paragraph to be updated.
index 37e5e5f..f317fb3 100644 (file)
@@ -309,6 +309,7 @@ struct Controller::Impl
     mTextUpdateInfo(),
     mOperationsPending( NO_OPERATION ),
     mMaximumNumberOfCharacters( 50u ),
+    mHiddenInput( NULL ),
     mRecalculateNaturalSize( true ),
     mMarkupProcessorEnabled( false ),
     mClipboardHideEnabled( true ),
@@ -333,6 +334,8 @@ struct Controller::Impl
 
   ~Impl()
   {
+    delete mHiddenInput;
+
     delete mFontDefaults;
     delete mUnderlineDefaults;
     delete mShadowDefaults;
@@ -710,6 +713,7 @@ public:
   TextUpdateInfo mTextUpdateInfo;          ///< Info of the characters updated.
   OperationsMask mOperationsPending;       ///< Operations pending to be done to layout the text.
   Length mMaximumNumberOfCharacters;       ///< Maximum number of characters that can be inserted.
+  HiddenText* mHiddenInput;                ///< Avoid allocating this when the user does not specify hidden input mode.
 
   bool mRecalculateNaturalSize:1;          ///< Whether the natural size needs to be recalculated.
   bool mMarkupProcessorEnabled:1;          ///< Whether the mark-up procesor is enabled.
index b79430a..d18f556 100644 (file)
@@ -1550,6 +1550,23 @@ bool Controller::GetTextScrollInfo( float& scrollPosition, float& controlHeight,
   return isScrolled;
 }
 
+void Controller::SetHiddenInputOption(const Property::Map& options )
+{
+  if( NULL == mImpl->mHiddenInput )
+  {
+    mImpl->mHiddenInput = new HiddenText( this );
+  }
+  mImpl->mHiddenInput->SetProperties(options);
+}
+
+void Controller::GetHiddenInputOption(Property::Map& options )
+{
+  if( NULL != mImpl->mHiddenInput )
+  {
+    mImpl->mHiddenInput->GetProperties(options);
+  }
+}
+
 // public : Relayout.
 
 Controller::UpdateTextType Controller::Relayout( const Size& size )
@@ -2301,6 +2318,15 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt
   }
 }
 
+void Controller::DisplayTimeExpired()
+{
+  mImpl->mEventData->mUpdateCursorPosition = true;
+  // Apply modifications to the model
+  mImpl->mOperationsPending = ALL_OPERATIONS;
+
+  mImpl->RequestRelayout();
+}
+
 // private : Update.
 
 void Controller::InsertText( const std::string& text, Controller::InsertType type )
index 5005d8e..96856ef 100644 (file)
@@ -26,6 +26,7 @@
 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
+#include <dali-toolkit/internal/text/hidden-text.h>
 #include <dali-toolkit/internal/text/text-model-interface.h>
 
 namespace Dali
@@ -56,7 +57,7 @@ typedef IntrusivePtr<Controller> ControllerPtr;
  *
  * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
  */
-class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface
+class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer
 {
 public: // Enumerated types.
 
@@ -347,7 +348,7 @@ public: // Configure the text controller.
   /**
    * @brief Sets input type to password
    *
-   * @note The string is displayed continuous "*"
+   * @note The string is displayed hidden character
    *
    * @param[in] passwordInput True if password input is enabled.
    */
@@ -887,6 +888,16 @@ public: // Queries & retrieves.
    */
   bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
 
+  /**
+   * @brief Used to set the hidden input option
+   */
+  void SetHiddenInputOption( const Property::Map& options );
+
+  /**
+   * @brief Used to get the hidden input option
+   */
+  void GetHiddenInputOption( Property::Map& options );
+
 public: // Relayout.
 
   /**
@@ -1002,6 +1013,13 @@ protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
    */
   virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
 
+protected: // Inherit from HiddenText.
+
+  /**
+   * @brief Invoked from HiddenText when showing time of the last character was expired
+   */
+  virtual void DisplayTimeExpired();
+
 private: // Update.
 
   /**