charactersToGlyph.Begin(),
glyphsPerCharacter.Begin(),
numberOfGlyphs,
- Layout::HORIZONTAL_ALIGN_BEGIN );
+ Layout::HORIZONTAL_ALIGN_BEGIN,
+ Layout::LineWrap::WORD );
Vector<LineRun>& lines = visualModel->mLines;
visualModel->mCharactersToGlyph.Begin(),
visualModel->mGlyphsPerCharacter.Begin(),
totalNumberOfGlyphs,
- Layout::HORIZONTAL_ALIGN_BEGIN );
+ Layout::HORIZONTAL_ALIGN_BEGIN,
+ Layout::LineWrap::WORD );
layoutParameters.isLastNewParagraph = isLastNewParagraph;
visualModel->mCharactersToGlyph.Begin(),
visualModel->mGlyphsPerCharacter.Begin(),
visualModel->mGlyphs.Count(),
- Layout::HORIZONTAL_ALIGN_BEGIN );
+ Layout::HORIZONTAL_ALIGN_BEGIN,
+ Layout::LineWrap::WORD );
layoutParameters.numberOfBidirectionalInfoRuns = logicalModel->mBidirectionalLineInfo.Count();
layoutParameters.lineBidirectionalInfoRunsBuffer = logicalModel->mBidirectionalLineInfo.Begin();
END_TEST;
}
+int UtcDaliToolkitTextEditorTextWarpMode(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
+
+ int lineCount =0 ;
+
+ TextEditor editor = TextEditor::New();
+ editor.SetSize( 150.0f, 300.f );
+ editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
+
+ Stage::GetCurrent().Add( editor );
+
+ editor.SetProperty( DevelTextEditor::Property::LINE_WRAP_MODE, "WORD" );
+
+ application.SendNotification();
+ application.Render();
+
+ lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
+ DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
+
+
+
+ editor.SetProperty( DevelTextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
+
+ application.SendNotification();
+ application.Render();
+
+
+ lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
+ DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
+
+ END_TEST;
+}
END_TEST;
}
+
+int UtcDaliToolkitTextlabelTextWarpMode(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
+
+ int lineCount =0 ;
+
+ TextLabel label = TextLabel::New();
+ label.SetSize( 300.0f, 300.f );
+ label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
+ label.SetProperty( TextLabel::Property::MULTI_LINE, true );
+
+
+
+ //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
+ Stage::GetCurrent().Add( label );
+
+ label.SetProperty( DevelTextLabel::Property::LINE_WRAP_MODE, "WRAP_MODE_WORD" );
+
+ application.SendNotification();
+ application.Render();
+
+ lineCount = label.GetProperty<int>( DevelTextLabel::Property::LINE_COUNT );
+ DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
+
+
+
+ label.SetProperty( DevelTextLabel::Property::LINE_WRAP_MODE, "WRAP_MODE_CHARACTER" );
+
+ application.SendNotification();
+ application.Render();
+
+
+ lineCount = label.GetProperty<int>( DevelTextLabel::Property::LINE_COUNT );
+ DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
+
+ END_TEST;
+}
*
* @details name "placeholder", type MAP
*/
- PLACEHOLDER
+ PLACEHOLDER,
+
+ /**
+ * @brief line wrap mode when the text lines over layout width.
+ * @details name "lineWrapMode", type string.
+ */
+ LINE_WRAP_MODE
};
} // namespace Property
* @details name "lineCount", type int
* @node this property is read-only.
*/
- LINE_COUNT = OUTLINE + 5
+ LINE_COUNT = OUTLINE + 5,
+
+ /**
+ * @brief line wrap mode when the text lines over layout width.
+ * @details name "lineWrapMode", type string.
+ */
+ LINE_WRAP_MODE = OUTLINE + 6
};
} // namespace Property
};
const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
+
+const Scripting::StringEnum LINE_WRAP_MODE_STRING_TABLE[] =
+{
+ { "WORD", Toolkit::Text::Layout::LineWrap::WORD },
+ { "CHARACTER", Toolkit::Text::Layout::LineWrap::CHARACTER }
+};
+const unsigned int LINE_WRAP_MODE_STRING_TABLE_COUNT = sizeof( LINE_WRAP_MODE_STRING_TABLE ) / sizeof( LINE_WRAP_MODE_STRING_TABLE[0] );
+
const char* const SCROLL_BAR_POSITION("sourcePosition");
const char* const SCROLL_BAR_POSITION_MIN("sourcePositionMin");
const char* const SCROLL_BAR_POSITION_MAX("sourcePositionMax");
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderTextColor", VECTOR4, PLACEHOLDER_TEXT_COLOR )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableSelection", BOOLEAN, ENABLE_SELECTION )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholder", MAP, PLACEHOLDER )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "lineWrapMode", STRING, LINE_WRAP_MODE )
DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED )
}
break;
}
+ case Toolkit::DevelTextEditor::Property::LINE_WRAP_MODE:
+ {
+ const std::string& wrapModeStr = value.Get< std::string >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p LINE_WRAP_MODE %s\n", impl.mController.Get(), wrapModeStr.c_str() );
+
+ Layout::LineWrap::Mode lineWrapMode( Layout::LineWrap::WORD );
+ if( Scripting::GetEnumeration< Layout::LineWrap::Mode >( wrapModeStr.c_str(),
+ LINE_WRAP_MODE_STRING_TABLE,
+ LINE_WRAP_MODE_STRING_TABLE_COUNT,
+ lineWrapMode ) )
+ {
+ impl.mController->SetLineWrapMode( lineWrapMode );
+ }
+ break;
+ }
} // switch
} // texteditor
}
value = map;
break;
}
+ case Toolkit::DevelTextEditor::Property::LINE_WRAP_MODE:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetLineWrapMode();
+ }
+ }
} //switch
}
};
const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
+const Scripting::StringEnum LINE_WRAP_MODE_STRING_TABLE[] =
+{
+ { "WRAP_MODE_WORD", Toolkit::Text::Layout::LineWrap::WORD },
+ { "WRAP_MODE_CHARACTER", Toolkit::Text::Layout::LineWrap::CHARACTER }
+};
+const unsigned int LINE_WRAP_MODE_STRING_TABLE_COUNT = sizeof( LINE_WRAP_MODE_STRING_TABLE ) / sizeof( LINE_WRAP_MODE_STRING_TABLE[0] );
+
// Type registration
BaseHandle Create()
{
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollLoopDelay", FLOAT, AUTO_SCROLL_LOOP_DELAY )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollStopMode", STRING, AUTO_SCROLL_STOP_MODE )
DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextLabel, "lineCount", INTEGER, LINE_COUNT )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "lineWrapMode", STRING, LINE_WRAP_MODE )
DALI_TYPE_REGISTRATION_END()
}
break;
}
+ case Toolkit::DevelTextLabel::Property::LINE_WRAP_MODE:
+ {
+ const std::string& wrapModeStr = value.Get< std::string >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel %p LINE_WRAP_MODE %s\n", impl.mController.Get(), wrapModeStr.c_str() );
+
+ Layout::LineWrap::Mode lineWrapMode( Layout::LineWrap::WORD );
+ if( Scripting::GetEnumeration< Layout::LineWrap::Mode >( wrapModeStr.c_str(),
+ LINE_WRAP_MODE_STRING_TABLE,
+ LINE_WRAP_MODE_STRING_TABLE_COUNT,
+ lineWrapMode ) )
+ {
+ impl.mController->SetLineWrapMode( lineWrapMode );
+ }
+ break;
+ }
}
}
}
}
break;
}
+ case Toolkit::DevelTextLabel::Property::LINE_WRAP_MODE:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetLineWrapMode();
+ }
+ break;
+ }
case Toolkit::DevelTextLabel::Property::LINE_COUNT:
{
if( impl.mController )
LineLayout tmpLineLayout;
const bool isMultiline = mLayout == MULTI_LINE_BOX;
+ const bool isWordLaidOut = parameters.lineWrapMode == Layout::LineWrap::WORD;
// The last glyph to be laid-out.
const GlyphIndex lastGlyphOfParagraphPlusOne = parameters.startGlyphIndex + parameters.numberOfGlyphs;
if( isMultiline &&
( TextAbstraction::WORD_BREAK == wordBreakInfo ) )
{
- oneWordLaidOut = true;
+ oneWordLaidOut = isWordLaidOut;
DALI_LOG_INFO( gLogFilter, Debug::Verbose, " One word laid-out\n" );
// Current glyph is the last one of the current word.
// INTERNAL INCLUDES
#include <dali-toolkit/internal/text/text-definitions.h>
+#include <dali-toolkit/internal/text/layouts/layout-wrap-mode.h>
namespace Dali
{
* @param[in] glyphsPerCharacterBuffer Vector with the number of glyphs shaped from the character.
* @param[in] totalNumberOfGlyphs The number of glyphs.
* @param[in] horizontalAlignment The horizontal alignment.
+ * @param[in] lineWrapMode The text wrap mode.
*/
Parameters( const Vector2& boundingBox,
const Character* const textBuffer,
const GlyphIndex* const charactersToGlyphsBuffer,
const Length* const glyphsPerCharacterBuffer,
Length totalNumberOfGlyphs,
- HorizontalAlignment horizontalAlignment )
+ HorizontalAlignment horizontalAlignment,
+ LineWrap::Mode lineWrapMode )
: boundingBox( boundingBox ),
textBuffer( textBuffer ),
lineBreakInfoBuffer( lineBreakInfoBuffer ),
horizontalAlignment( horizontalAlignment ),
startLineIndex( 0u ),
estimatedNumberOfLines( 0u ),
+ lineWrapMode( lineWrapMode ),
isLastNewParagraph( false )
{}
HorizontalAlignment horizontalAlignment; ///< The horizontal alignment.
LineIndex startLineIndex; ///< The line index where to insert the new lines.
Length estimatedNumberOfLines; ///< The estimated number of lines.
+ LineWrap::Mode lineWrapMode; ///< The line wrap mode for moving to next line.
bool isLastNewParagraph; ///< Whether the last character is a new paragraph character.
};
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_LAYOUT_WRAPMODE_H
+#define DALI_TOOLKIT_TEXT_LAYOUT_WRAPMODE_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.
+ *
+ */
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+namespace Layout
+{
+
+/**
+ * @brief Unit of wrapping for moving to next line
+ *
+ * If layout width too short to show full text,
+ * WRAP_MODE_WORD mode will move word to next line,
+ * +---------+
+ * |HELLO |
+ * |WORLLD |
+ * +---------+
+ *
+ * but WRAP_MODE_CHARACTER mode will move character by character to next line
+ * +---------+
+ * |HELLO WOR|
+ * |LD |
+ * +---------+
+ */
+
+namespace LineWrap {
+
+enum Mode
+{
+ WORD,
+ CHARACTER
+};
+
+} // namespace LineWrap
+
+} // namespace Layout
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_LAYOUT_WRAPMODE_H
return mImpl->mModel->mVerticalAlignment;
}
+void Controller::SetLineWrapMode( Layout::LineWrap::Mode lineWrapMode )
+{
+ if( lineWrapMode != mImpl->mModel->mLineWrapMode )
+ {
+ // Set the text wrap mode.
+ mImpl->mModel->mLineWrapMode = lineWrapMode;
+
+
+ // Update Text layout for applying wrap mode
+ mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
+ ALIGN |
+ LAYOUT |
+ UPDATE_LAYOUT_SIZE |
+ REORDER );
+ mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
+
+ // Request relayout
+ mImpl->RequestRelayout();
+ }
+}
+
+Layout::LineWrap::Mode Controller::GetLineWrapMode() const
+{
+ return mImpl->mModel->mLineWrapMode;
+}
+
void Controller::SetTextElideEnabled( bool enabled )
{
mImpl->mModel->mElideEnabled = enabled;
charactersToGlyphBuffer,
glyphsPerCharacterBuffer,
totalNumberOfGlyphs,
- mImpl->mModel->mHorizontalAlignment );
+ mImpl->mModel->mHorizontalAlignment,
+ mImpl->mModel->mLineWrapMode );
// Resize the vector of positions to have the same size than the vector of glyphs.
Vector<Vector2>& glyphPositions = mImpl->mModel->mVisualModel->mGlyphPositions;
#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/layouts/layout-wrap-mode.h>
#include <dali-toolkit/internal/text/hidden-text.h>
#include <dali-toolkit/internal/text/text-model-interface.h>
+
namespace Dali
{
Layout::VerticalAlignment GetVerticalAlignment() const;
/**
+ * @brief Sets the text's wrap mode
+ * @param[in] text wrap mode The unit of wrapping
+ */
+ void SetLineWrapMode( Layout::LineWrap::Mode textWarpMode );
+
+ /**
+ * @brief Retrieve text wrap mode previously set.
+ * @return text wrap mode
+ */
+ Layout::LineWrap::Mode GetLineWrapMode() const;
+
+ /**
* @brief Enable or disable the text elide.
*
* @param[in] enabled Whether to enable the text elide.
mScrollPositionLast(),
mHorizontalAlignment( Layout::HORIZONTAL_ALIGN_BEGIN ),
mVerticalAlignment( Layout::VERTICAL_ALIGN_TOP ),
+ mLineWrapMode( Layout::LineWrap::WORD ),
mAlignmentOffset( 0.0f ),
mElideEnabled( false )
{
// INTERNAL INCLUDES
#include <dali-toolkit/internal/text/layouts/layout-alignment.h>
+#include <dali-toolkit/internal/text/layouts/layout-wrap-mode.h>
#include <dali-toolkit/internal/text/logical-model-impl.h>
#include <dali-toolkit/internal/text/text-model-interface.h>
#include <dali-toolkit/internal/text/visual-model-impl.h>
Vector2 mScrollPositionLast; ///< The last offset value of mScrollPosition
Layout::HorizontalAlignment mHorizontalAlignment; ///< The layout's horizontal alignment.
Layout::VerticalAlignment mVerticalAlignment; ///< The layout's vertical alignment.
+ Layout::LineWrap::Mode mLineWrapMode; ///< The text wrap mode
float mAlignmentOffset; ///< The alignment offset.
bool mElideEnabled:1; ///< Whether the text's elide is enabled.
};