Text - Small fixes. 68/65468/1
authorVictor Cebollada <v.cebollada@samsung.com>
Mon, 11 Apr 2016 07:56:41 +0000 (08:56 +0100)
committerVictor Cebollada <v.cebollada@samsung.com>
Mon, 11 Apr 2016 08:12:07 +0000 (09:12 +0100)
* Some comments updated.
* const's added.
* numberOfChars --> numberOfCharacters
* include guard changed in text-run-container.h

Change-Id: I91081f5ad2de071aff294435ab43b09e782f5ca7
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
dali-toolkit/internal/text/shaper.cpp
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h
dali-toolkit/internal/text/text-run-container.h

index 5313d0c..cd0b1d7 100644 (file)
@@ -175,7 +175,7 @@ void ShapeText( const Vector<Character>& text,
     shaping.GetGlyphs( tmpGlyphs.Begin(),
                        tmpGlyphToCharacterMap.Begin() );
 
-    // Update the indices.
+    // Update the new indices of the glyph to character map.
     if( 0u != totalNumberOfGlyphs )
     {
       for( Vector<CharacterIndex>::Iterator it = tmpGlyphToCharacterMap.Begin(),
index 153a36c..ab41790 100644 (file)
@@ -466,7 +466,7 @@ float Controller::GetDefaultPointSize() const
   return 0.0f;
 }
 
-void Controller::UpdateAfterFontChange( std::string& newDefaultFont )
+void Controller::UpdateAfterFontChange( const std::string& newDefaultFont )
 {
   DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange");
 
@@ -499,7 +499,7 @@ const Vector4& Controller::GetTextColor() const
   return mImpl->mTextColor;
 }
 
-bool Controller::RemoveText( int cursorOffset, int numberOfChars )
+bool Controller::RemoveText( int cursorOffset, int numberOfCharacters )
 {
   bool removed = false;
 
@@ -508,8 +508,8 @@ bool Controller::RemoveText( int cursorOffset, int numberOfChars )
     return removed;
   }
 
-  DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfChars %d\n",
-                 this, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfChars );
+  DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfCharacters %d\n",
+                 this, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfCharacters );
 
   if( !mImpl->IsShowingPlaceholderText() )
   {
@@ -525,12 +525,12 @@ bool Controller::RemoveText( int cursorOffset, int numberOfChars )
       cursorIndex = oldCursorIndex + cursorOffset;
     }
 
-    if( ( cursorIndex + numberOfChars ) > currentText.Count() )
+    if( ( cursorIndex + numberOfCharacters ) > currentText.Count() )
     {
-      numberOfChars = currentText.Count() - cursorIndex;
+      numberOfCharacters = currentText.Count() - cursorIndex;
     }
 
-    if( ( cursorIndex + numberOfChars ) <= currentText.Count() )
+    if( ( cursorIndex + numberOfCharacters ) <= currentText.Count() )
     {
       // Update the input style and remove the text's style before removing the text.
 
@@ -541,18 +541,18 @@ bool Controller::RemoveText( int cursorOffset, int numberOfChars )
       mImpl->mLogicalModel->RetrieveStyle( cursorIndex, mImpl->mEventData->mInputStyle );
 
       // Remove the text's style before removing the text.
-      mImpl->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfChars );
+      mImpl->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfCharacters );
 
       // Remove the characters.
       Vector<Character>::Iterator first = currentText.Begin() + cursorIndex;
-      Vector<Character>::Iterator last  = first + numberOfChars;
+      Vector<Character>::Iterator last  = first + numberOfCharacters;
 
       currentText.Erase( first, last );
 
       // Cursor position retreat
       oldCursorIndex = cursorIndex;
 
-      DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfChars );
+      DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfCharacters );
       removed = true;
     }
   }
@@ -1776,14 +1776,14 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ
 
   // Remove the previous IMF pre-edit (predicitive text)
   if( mImpl->mEventData->mPreEditFlag &&
-      ( 0 != mImpl->mEventData->mPreEditLength ) )
+      ( 0u != mImpl->mEventData->mPreEditLength ) )
   {
-    CharacterIndex offset = mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition;
+    const CharacterIndex offset = mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition;
 
-    removedPrevious = RemoveText( -static_cast<int>(offset), mImpl->mEventData->mPreEditLength );
+    removedPrevious = RemoveText( -static_cast<int>( offset ), mImpl->mEventData->mPreEditLength );
 
     mImpl->mEventData->mPrimaryCursorPosition = mImpl->mEventData->mPreEditStartPosition;
-    mImpl->mEventData->mPreEditLength = 0;
+    mImpl->mEventData->mPreEditLength = 0u;
   }
   else
   {
@@ -1842,7 +1842,7 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ
 
     const Length numberOfCharactersInModel = mImpl->mLogicalModel->mText.Count();
 
-    // Restrict new text to fit within Maximum characters setting
+    // Restrict new text to fit within Maximum characters setting.
     Length maxSizeOfNewText = std::min( ( mImpl->mMaximumNumberOfCharacters - numberOfCharactersInModel ), characterCount );
     maxLengthReached = ( characterCount > maxSizeOfNewText );
 
@@ -2514,7 +2514,7 @@ void Controller::ShowPlaceholderText()
 
     // Transform a text array encoded in utf8 into an array encoded in utf32.
     // It returns the actual number of characters.
-    Length characterCount = Utf8ToUtf32( utf8, size, utf32Characters.Begin() );
+    const Length characterCount = Utf8ToUtf32( utf8, size, utf32Characters.Begin() );
     utf32Characters.Resize( characterCount );
 
     // Reset the cursor position
index d239d13..7e22134 100644 (file)
@@ -151,10 +151,10 @@ public:
    * @brief Remove a given number of characters
    *
    * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
-   * @param[in] numberOfChars The number of characters to delete from the cursorOffset.
+   * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
    * @return True if the remove was successful.
    */
-  bool RemoveText( int cursorOffset, int numberOfChars );
+  bool RemoveText( int cursorOffset, int numberOfCharacters );
 
   /**
    * @brief Retrieve the current cursor position.
@@ -283,7 +283,7 @@ public:
    * @ brief Update the text after a font change
    * @param[in] newDefaultFont The new font to change to
    */
-  void UpdateAfterFontChange( std::string& newDefaultFont );
+  void UpdateAfterFontChange( const std::string& newDefaultFont );
 
   /**
    * @brief Set the text color
index 37d7b00..ecac39d 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TOOLKIT_TEXT_STYLE_RUN_CONTAINER_H__
-#define __DALI_TOOLKIT_TEXT_STYLE_RUN_CONTAINER_H__
+#ifndef __DALI_TOOLKIT_TEXT_RUN_CONTAINER_H__
+#define __DALI_TOOLKIT_TEXT_RUN_CONTAINER_H__
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
@@ -300,6 +300,7 @@ void ClearGlyphRuns( GlyphIndex startIndex,
         ( startIndex >= run->glyphRun.glyphIndex + run->glyphRun.numberOfGlyphs ) )
     {
       // Run found. Nothing else to do.
+      break;
     }
 
     ++run;
@@ -352,4 +353,4 @@ void ClearGlyphRuns( GlyphIndex startIndex,
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_TEXT_STYLE_RUN_CONTAINER_H__
+#endif // __DALI_TOOLKIT_TEXT_RUN_CONTAINER_H__