* Creates an interface to access the text's model from the text rendering modules.
* In the case the text is elided, it stores a copy of the elided text,
the ellipsis glyph and the modified layout.
* It creates a basic Text::RenderingController class which stores the
pointer to the text's model.
Change-Id: Ied29583a0e1648dab9d78575dcbc042353c949dc
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
utc-Dali-VisualFactoryResolveUrl.cpp
utc-Dali-Visuals.cpp
utc-Dali-Text-Markup.cpp
+ utc-Dali-Text-Typesetter.cpp
+ utc-Dali-Text-ViewModel.cpp
)
# Append list of test harness files (Won't get parsed for test cases)
../dali-toolkit/dali-toolkit-test-utils/test-render-controller.cpp
../dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp
../dali-toolkit/dali-toolkit-test-utils/test-native-image.cpp
- dali-toolkit-test-utils/toolkit-text-model.cpp
+ dali-toolkit-test-utils/toolkit-text-utils.cpp
)
*
*/
-#include "toolkit-text-model.h"
+// FILE HEADER
+#include "toolkit-text-utils.h"
// EXTERNAL INCLUDES
+#include <limits>
#include <dali/devel-api/text-abstraction/font-client.h>
// INTERNAL INCLUDES
}
// 9) Layout the text
- LayoutEngine layoutEngine;
+ Layout::Engine layoutEngine;
layoutEngine.SetMetrics( metrics );
- layoutEngine.SetLayout( LayoutEngine::MULTI_LINE_BOX );
+ layoutEngine.SetLayout( Layout::Engine::MULTI_LINE_BOX );
// Set the layout parameters.
const Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph;
const Vector<Length>& glyphsPerCharacter = visualModel->mGlyphsPerCharacter;
- LayoutParameters layoutParameters( textArea,
- utf32Characters.Begin(),
- lineBreakInfo.Begin(),
- wordBreakInfo.Begin(),
- ( 0u != characterDirections.Count() ) ? characterDirections.Begin() : NULL,
- glyphs.Begin(),
- glyphsToCharactersMap.Begin(),
- charactersPerGlyph.Begin(),
- charactersToGlyph.Begin(),
- glyphsPerCharacter.Begin(),
- numberOfGlyphs );
+ Layout::Parameters layoutParameters( textArea,
+ utf32Characters.Begin(),
+ lineBreakInfo.Begin(),
+ wordBreakInfo.Begin(),
+ ( 0u != characterDirections.Count() ) ? characterDirections.Begin() : NULL,
+ glyphs.Begin(),
+ glyphsToCharactersMap.Begin(),
+ charactersPerGlyph.Begin(),
+ charactersToGlyph.Begin(),
+ glyphsPerCharacter.Begin(),
+ numberOfGlyphs,
+ Layout::HORIZONTAL_ALIGN_BEGIN );
Vector<LineRun>& lines = visualModel->mLines;
layoutEngine.LayoutText( layoutParameters,
glyphPositions,
lines,
- layoutSize );
+ layoutSize,
+ false );
// 10) Reorder the lines
if( 0u != bidirectionalInfo.Count() )
layoutEngine.Align( textArea,
0u,
numberOfCharacters,
+ Layout::HORIZONTAL_ALIGN_BEGIN,
lines );
}
}
+void ConfigureTextLabel( ControllerPtr controller )
+{
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.SetDpi( 93u, 93u );
+
+ // Set the text layout as multi-line.
+ controller->GetLayoutEngine().SetLayout( Layout::Engine::MULTI_LINE_BOX );
+
+ // Set cursor's width to zero.
+ controller->GetLayoutEngine().SetCursorWidth( 0 );
+
+ // Disables the text input.
+ controller->EnableTextInput( NULL );
+
+ // Disables the vertical scrolling.
+ controller->SetVerticalScrollEnabled( false );
+
+ // Disables the horizontal scrolling.
+ controller->SetHorizontalScrollEnabled( false );
+
+ // Enable the text elide.
+ controller->SetTextElideEnabled( true );
+}
+
+void ConfigureTextField( ControllerPtr controller )
+{
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.SetDpi( 93u, 93u );
+
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+
+ // Set the text layout as multi-line.
+ controller->GetLayoutEngine().SetLayout( Layout::Engine::SINGLE_LINE_BOX );
+
+ // Enables the text input.
+ controller->EnableTextInput( decorator );
+
+ // Enables the vertical scrolling after the text input has been enabled.
+ controller->SetVerticalScrollEnabled( false );
+
+ // Disables the horizontal scrolling.
+ controller->SetHorizontalScrollEnabled( true );
+
+ // No maximum number of characters.
+ controller->SetMaximumNumberOfCharacters( 50u );
+
+ // Disable the text elide.
+ controller->SetTextElideEnabled( false );
+}
+
+void ConfigureTextEditor( ControllerPtr controller )
+{
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.SetDpi( 93u, 93u );
+
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+
+ // Set the text layout as multi-line.
+ controller->GetLayoutEngine().SetLayout( Layout::Engine::MULTI_LINE_BOX );
+
+ // Enables the text input.
+ controller->EnableTextInput( decorator );
+
+ // Enables the vertical scrolling after the text input has been enabled.
+ controller->SetVerticalScrollEnabled( true );
+
+ // Disables the horizontal scrolling.
+ controller->SetHorizontalScrollEnabled( false );
+
+ // No maximum number of characters.
+ controller->SetMaximumNumberOfCharacters( std::numeric_limits<Length>::max() );
+
+ // Disable the text elide.
+ controller->SetTextElideEnabled( false );
+}
+
} // namespace Text
} // namespace Toolkit
-#ifndef __DALI_TOOLKIT_TEXT_MODEL_H__
-#define __DALI_TOOLKIT_TEXT_MODEL_H__
+#ifndef __DALI_TOOLKIT_TEXT_UTILS_H__
+#define __DALI_TOOLKIT_TEXT_UTILS_H__
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
*/
-// EXTERNAL INCLUDES
-
// INTERNAL INCLUDES
#include <dali-toolkit/internal/text/logical-model-impl.h>
#include <dali-toolkit/internal/text/metrics.h>
#include <dali-toolkit/internal/text/visual-model-impl.h>
+#include <dali-toolkit/internal/text/text-controller.h>
namespace Dali
{
VisualModelPtr& visualModel,
MetricsPtr& metrics );
+/**
+ * @brief Configures the text @p controller similarly to the one configured by the text-label.
+ *
+ * @param[in,out] The text controller to configure.
+ */
+void ConfigureTextLabel( ControllerPtr controller );
+
+/**
+ * @brief Configures the text @p controller similarly to the one configured by the text-field.
+ *
+ * @param[in,out] The text controller to configure.
+ */
+void ConfigureTextField( ControllerPtr controller );
+
+/**
+ * @brief Configures the text @p controller similarly to the one configured by the text-editor.
+ *
+ * @param[in,out] The text controller to configure.
+ */
+void ConfigureTextEditor( ControllerPtr controller );
+
} // namespace Text
} // namespace Toolkit
} // namespace Dali
-#endif // __DALI_TOOLKIT_TEXT_MODEL_H__
+#endif // __DALI_TOOLKIT_TEXT_UTILS_H__
#include <dali-toolkit/internal/text/text-run-container.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
using namespace Dali;
using namespace Toolkit;
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/internal/text/text-run-container.h>
#include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
using namespace Dali;
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <toolkit-text-utils.h>
#include <dali-toolkit/internal/text/text-controller.h>
#include <dali-toolkit/internal/text/text-control-interface.h>
#include <dali-toolkit/internal/text/text-editable-control-interface.h>
const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
-class ControlImpl : public ControlInterface, public Text::EditableControlInterface
-{
-public:
- ControlImpl()
- : ControlInterface()
- {}
-
- virtual ~ControlImpl()
- {}
-
- virtual void AddDecoration( Actor& actor, bool needsClipping )
- {}
-
- virtual void RequestTextRelayout()
- {}
-
- virtual void TextChanged()
- {}
-
- virtual void MaxLengthReached()
- {}
-
- virtual void InputStyleChanged( InputStyle::Mask inputStyleMask )
- {}
-};
-
std::string gClipboardText;
void ContentSelectedCallback( ClipboardEventNotifier& notifier )
{
// Creates a text controller.
ControllerPtr controller = Controller::New();
+ DALI_TEST_CHECK( controller );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextControllerSetGetScrollEnabled(void)
+{
+ tet_infoline(" UtcDaliTextControllerSetGetScrollEnabled");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+ DALI_TEST_CHECK( controller );
+
+ // Configures the text controller similarly to the text-editor.
+ ConfigureTextEditor( controller );
+ DALI_TEST_CHECK( !controller->IsHorizontalScrollEnabled() );
+ DALI_TEST_CHECK( controller->IsVerticalScrollEnabled() );
+
+ // Configures the text controller similarly to the text-field.
+ ConfigureTextField( controller );
+
+ DALI_TEST_CHECK( controller->IsHorizontalScrollEnabled() );
+ DALI_TEST_CHECK( !controller->IsVerticalScrollEnabled() );
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel( controller );
+
+ DALI_TEST_CHECK( !controller->IsHorizontalScrollEnabled() );
+ DALI_TEST_CHECK( !controller->IsVerticalScrollEnabled() );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextControllerSetIsTextElide(void)
+{
+ tet_infoline(" UtcDaliTextControllerSetIsTextElide");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
DALI_TEST_CHECK( controller );
+ // Configures the text controller similarly to the text-editor.
+ ConfigureTextEditor( controller );
+ DALI_TEST_EQUALS( false, controller->IsTextElideEnabled(), TEST_LOCATION );
+
+ controller->SetTextElideEnabled( true );
+ DALI_TEST_EQUALS( true, controller->IsTextElideEnabled(), TEST_LOCATION );
+
+ // Configures the text controller similarly to the text-field.
+ ConfigureTextField( controller );
+ DALI_TEST_EQUALS( false, controller->IsTextElideEnabled(), TEST_LOCATION );
+
+ controller->SetTextElideEnabled( true );
+ DALI_TEST_EQUALS( true, controller->IsTextElideEnabled(), TEST_LOCATION );
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel( controller );
+ DALI_TEST_EQUALS( true, controller->IsTextElideEnabled(), TEST_LOCATION );
+
+ controller->SetTextElideEnabled( false );
+ DALI_TEST_EQUALS( false, controller->IsTextElideEnabled(), TEST_LOCATION );
+
tet_result(TET_PASS);
END_TEST;
}
// Creates a text controller.
ControllerPtr controller = Controller::New();
-
DALI_TEST_CHECK( controller );
// There is no text input enabled.
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/internal/text/cursor-helper-functions.h>
#include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
using namespace Dali;
#include <dali-toolkit/internal/text/text-run-container.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
using namespace Dali;
using namespace Toolkit;
float* positions;
unsigned int numberOfLines;
LineRun* lines;
- LayoutEngine::Layout layout;
+ Layout::Engine::Type layout;
unsigned int startIndex;
unsigned int numberOfGlyphs;
bool ellipsis:1;
glyphPositions.Begin() + data.startIndex + data.numberOfGlyphs );
// 3) Layout
- LayoutEngine engine;
+ Layout::Engine engine;
engine.SetMetrics( metrics );
- engine.SetTextEllipsisEnabled( data.ellipsis );
engine.SetLayout( data.layout );
const Length totalNumberOfGlyphs = visualModel->mGlyphs.Count();
- LayoutParameters layoutParameters( data.textArea,
- logicalModel->mText.Begin(),
- logicalModel->mLineBreakInfo.Begin(),
- logicalModel->mWordBreakInfo.Begin(),
- ( 0u != logicalModel->mCharacterDirections.Count() ) ? logicalModel->mCharacterDirections.Begin() : NULL,
- visualModel->mGlyphs.Begin(),
- visualModel->mGlyphsToCharacters.Begin(),
- visualModel->mCharactersPerGlyph.Begin(),
- visualModel->mCharactersToGlyph.Begin(),
- visualModel->mGlyphsPerCharacter.Begin(),
- totalNumberOfGlyphs );
+ Layout::Parameters layoutParameters( data.textArea,
+ logicalModel->mText.Begin(),
+ logicalModel->mLineBreakInfo.Begin(),
+ logicalModel->mWordBreakInfo.Begin(),
+ ( 0u != logicalModel->mCharacterDirections.Count() ) ? logicalModel->mCharacterDirections.Begin() : NULL,
+ visualModel->mGlyphs.Begin(),
+ visualModel->mGlyphsToCharacters.Begin(),
+ visualModel->mCharactersPerGlyph.Begin(),
+ visualModel->mCharactersToGlyph.Begin(),
+ visualModel->mGlyphsPerCharacter.Begin(),
+ totalNumberOfGlyphs,
+ Layout::HORIZONTAL_ALIGN_BEGIN );
layoutParameters.isLastNewParagraph = isLastNewParagraph;
const bool updated = engine.LayoutText( layoutParameters,
glyphPositions,
lines,
- layoutSize );
+ layoutSize,
+ data.ellipsis );
// 4) Compare the results.
metrics );
// 2) Call the ReLayoutRightToLeftLines() method.
- LayoutEngine engine;
+ Layout::Engine engine;
engine.SetMetrics( metrics );
- LayoutParameters layoutParameters( data.textArea,
- logicalModel->mText.Begin(),
- logicalModel->mLineBreakInfo.Begin(),
- logicalModel->mWordBreakInfo.Begin(),
- ( 0u != logicalModel->mCharacterDirections.Count() ) ? logicalModel->mCharacterDirections.Begin() : NULL,
- visualModel->mGlyphs.Begin(),
- visualModel->mGlyphsToCharacters.Begin(),
- visualModel->mCharactersPerGlyph.Begin(),
- visualModel->mCharactersToGlyph.Begin(),
- visualModel->mGlyphsPerCharacter.Begin(),
- visualModel->mGlyphs.Count() );
+ Layout::Parameters layoutParameters( data.textArea,
+ logicalModel->mText.Begin(),
+ logicalModel->mLineBreakInfo.Begin(),
+ logicalModel->mWordBreakInfo.Begin(),
+ ( 0u != logicalModel->mCharacterDirections.Count() ) ? logicalModel->mCharacterDirections.Begin() : NULL,
+ visualModel->mGlyphs.Begin(),
+ visualModel->mGlyphsToCharacters.Begin(),
+ visualModel->mCharactersPerGlyph.Begin(),
+ visualModel->mCharactersToGlyph.Begin(),
+ visualModel->mGlyphsPerCharacter.Begin(),
+ visualModel->mGlyphs.Count(),
+ Layout::HORIZONTAL_ALIGN_BEGIN );
layoutParameters.numberOfBidirectionalInfoRuns = logicalModel->mBidirectionalLineInfo.Count();
layoutParameters.lineBidirectionalInfoRunsBuffer = logicalModel->mBidirectionalLineInfo.Begin();
struct AlignData
{
- std::string description;
- std::string text;
- Size textArea;
- unsigned int numberOfFonts;
- FontDescriptionRun* fontDescriptions;
- LayoutEngine::HorizontalAlignment horizontalAlignment;
- LayoutEngine::VerticalAlignment verticalAlignment;
- unsigned int startIndex;
- unsigned int numberOfCharacters;
- unsigned int numberOfLines;
- float* lineOffsets;
+ std::string description;
+ std::string text;
+ Size textArea;
+ unsigned int numberOfFonts;
+ FontDescriptionRun* fontDescriptions;
+ Layout::HorizontalAlignment horizontalAlignment;
+ Layout::VerticalAlignment verticalAlignment;
+ unsigned int startIndex;
+ unsigned int numberOfCharacters;
+ unsigned int numberOfLines;
+ float* lineOffsets;
};
bool AlignTest( const AlignData& data )
metrics );
// Call the Align method.
- LayoutEngine engine;
+ Layout::Engine engine;
engine.SetMetrics( metrics );
- engine.SetHorizontalAlignment( data.horizontalAlignment );
- engine.SetVerticalAlignment( data.verticalAlignment );
-
engine.Align( data.textArea,
data.startIndex,
data.numberOfCharacters,
+ data.horizontalAlignment,
visualModel->mLines );
// Compare results.
ToolkitTestApplication application;
tet_infoline(" UtcDaliTextLayoutSetGetLayout");
- LayoutEngine engine;
-
- DALI_TEST_CHECK( LayoutEngine::SINGLE_LINE_BOX == engine.GetLayout() );
-
- engine.SetLayout( LayoutEngine::MULTI_LINE_BOX );
- DALI_TEST_CHECK( LayoutEngine::MULTI_LINE_BOX == engine.GetLayout() );
-
- tet_result(TET_PASS);
- END_TEST;
-}
-
-int UtcDaliTextLayoutSetGetTextEllipsisEnabled(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliTextLayoutSetGetTextEllipsisEnabled");
-
- LayoutEngine engine;
-
- DALI_TEST_CHECK( !engine.GetTextEllipsisEnabled() );
-
- engine.SetTextEllipsisEnabled( true );
- DALI_TEST_CHECK( engine.GetTextEllipsisEnabled() );
-
- tet_result(TET_PASS);
- END_TEST;
-}
-
-int UtcDaliTextLayoutSetGetHorizontalAlignment(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" ");
-
- LayoutEngine engine;
+ Layout::Engine engine;
- DALI_TEST_CHECK( LayoutEngine::HORIZONTAL_ALIGN_BEGIN == engine.GetHorizontalAlignment() );
-
- engine.SetHorizontalAlignment( LayoutEngine::HORIZONTAL_ALIGN_END );
- DALI_TEST_CHECK( LayoutEngine::HORIZONTAL_ALIGN_END == engine.GetHorizontalAlignment() );
-
- tet_result(TET_PASS);
- END_TEST;
-}
-
-int UtcDaliTextLayoutSetGetVerticalAlignment(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliTextLayoutSetGetVerticalAlignment");
-
- LayoutEngine engine;
-
- DALI_TEST_CHECK( LayoutEngine::VERTICAL_ALIGN_TOP == engine.GetVerticalAlignment() );
-
- engine.SetVerticalAlignment( LayoutEngine::VERTICAL_ALIGN_TOP );
- DALI_TEST_CHECK( LayoutEngine::VERTICAL_ALIGN_TOP == engine.GetVerticalAlignment() );
+ DALI_TEST_CHECK( Layout::Engine::SINGLE_LINE_BOX == engine.GetLayout() );
+ engine.SetLayout( Layout::Engine::MULTI_LINE_BOX );
+ DALI_TEST_CHECK( Layout::Engine::MULTI_LINE_BOX == engine.GetLayout() );
tet_result(TET_PASS);
END_TEST;
ToolkitTestApplication application;
tet_infoline(" ");
- LayoutEngine engine;
+ Layout::Engine engine;
DALI_TEST_EQUALS( 1, engine.GetCursorWidth(), TEST_LOCATION );
NULL,
0u,
NULL,
- LayoutEngine::MULTI_LINE_BOX,
+ Layout::Engine::MULTI_LINE_BOX,
0u,
0u,
false,
NULL,
0u,
NULL,
- LayoutEngine::MULTI_LINE_BOX,
+ Layout::Engine::MULTI_LINE_BOX,
0u,
11u,
false,
positions,
1u,
lines.Begin(),
- LayoutEngine::SINGLE_LINE_BOX,
+ Layout::Engine::SINGLE_LINE_BOX,
0u,
11u,
false,
positions,
5u,
lines.Begin(),
- LayoutEngine::MULTI_LINE_BOX,
+ Layout::Engine::MULTI_LINE_BOX,
0u,
48u,
false,
positions,
6u,
lines.Begin(),
- LayoutEngine::MULTI_LINE_BOX,
+ Layout::Engine::MULTI_LINE_BOX,
0u,
55u,
false,
positions,
3u,
lines.Begin(),
- LayoutEngine::MULTI_LINE_BOX,
+ Layout::Engine::MULTI_LINE_BOX,
0u,
29u,
false,
positions,
2u,
lines.Begin(),
- LayoutEngine::MULTI_LINE_BOX,
+ Layout::Engine::MULTI_LINE_BOX,
0u,
13u,
false,
positions,
2u,
lines.Begin(),
- LayoutEngine::MULTI_LINE_BOX,
+ Layout::Engine::MULTI_LINE_BOX,
0u,
17u,
false,
positions,
19u,
lines.Begin(),
- LayoutEngine::MULTI_LINE_BOX,
+ Layout::Engine::MULTI_LINE_BOX,
0u,
64u,
false,
positions,
19u,
lines.Begin(),
- LayoutEngine::MULTI_LINE_BOX,
+ Layout::Engine::MULTI_LINE_BOX,
64u,
64u,
false,
positions,
19u,
lines.Begin(),
- LayoutEngine::MULTI_LINE_BOX,
+ Layout::Engine::MULTI_LINE_BOX,
128u,
64u,
false,
positions,
1u,
lines.Begin(),
- LayoutEngine::SINGLE_LINE_BOX,
+ Layout::Engine::SINGLE_LINE_BOX,
0u,
51u,
true,
positions,
2u,
lines.Begin(),
- LayoutEngine::MULTI_LINE_BOX,
+ Layout::Engine::MULTI_LINE_BOX,
0u,
51u,
true,
positions,
1u,
lines.Begin(),
- LayoutEngine::SINGLE_LINE_BOX,
+ Layout::Engine::SINGLE_LINE_BOX,
0u,
72u,
true,
positions,
2u,
lines.Begin(),
- LayoutEngine::MULTI_LINE_BOX,
+ Layout::Engine::MULTI_LINE_BOX,
0u,
72u,
true,
positions,
1u,
lines.Begin(),
- LayoutEngine::MULTI_LINE_BOX,
+ Layout::Engine::MULTI_LINE_BOX,
0u,
11u,
true,
textArea,
6u,
fontDescriptionRuns.Begin(),
- LayoutEngine::HORIZONTAL_ALIGN_BEGIN,
- LayoutEngine::VERTICAL_ALIGN_TOP,
+ Layout::HORIZONTAL_ALIGN_BEGIN,
+ Layout::VERTICAL_ALIGN_TOP,
0u,
22u,
6u,
textArea,
6u,
fontDescriptionRuns.Begin(),
- LayoutEngine::HORIZONTAL_ALIGN_BEGIN,
- LayoutEngine::VERTICAL_ALIGN_TOP,
+ Layout::HORIZONTAL_ALIGN_BEGIN,
+ Layout::VERTICAL_ALIGN_TOP,
22u,
26u,
6u,
textArea,
6u,
fontDescriptionRuns.Begin(),
- LayoutEngine::HORIZONTAL_ALIGN_BEGIN,
- LayoutEngine::VERTICAL_ALIGN_TOP,
+ Layout::HORIZONTAL_ALIGN_BEGIN,
+ Layout::VERTICAL_ALIGN_TOP,
48u,
26u,
6u,
textArea,
6u,
fontDescriptionRuns.Begin(),
- LayoutEngine::HORIZONTAL_ALIGN_CENTER,
- LayoutEngine::VERTICAL_ALIGN_TOP,
+ Layout::HORIZONTAL_ALIGN_CENTER,
+ Layout::VERTICAL_ALIGN_TOP,
0u,
22u,
6u,
textArea,
6u,
fontDescriptionRuns.Begin(),
- LayoutEngine::HORIZONTAL_ALIGN_CENTER,
- LayoutEngine::VERTICAL_ALIGN_TOP,
+ Layout::HORIZONTAL_ALIGN_CENTER,
+ Layout::VERTICAL_ALIGN_TOP,
22u,
26u,
6u,
textArea,
6u,
fontDescriptionRuns.Begin(),
- LayoutEngine::HORIZONTAL_ALIGN_CENTER,
- LayoutEngine::VERTICAL_ALIGN_TOP,
+ Layout::HORIZONTAL_ALIGN_CENTER,
+ Layout::VERTICAL_ALIGN_TOP,
48u,
26u,
6u,
textArea,
6u,
fontDescriptionRuns.Begin(),
- LayoutEngine::HORIZONTAL_ALIGN_END,
- LayoutEngine::VERTICAL_ALIGN_TOP,
+ Layout::HORIZONTAL_ALIGN_END,
+ Layout::VERTICAL_ALIGN_TOP,
0u,
22u,
6u,
textArea,
6u,
fontDescriptionRuns.Begin(),
- LayoutEngine::HORIZONTAL_ALIGN_END,
- LayoutEngine::VERTICAL_ALIGN_TOP,
+ Layout::HORIZONTAL_ALIGN_END,
+ Layout::VERTICAL_ALIGN_TOP,
22u,
26u,
6u,
textArea,
6u,
fontDescriptionRuns.Begin(),
- LayoutEngine::HORIZONTAL_ALIGN_END,
- LayoutEngine::VERTICAL_ALIGN_TOP,
+ Layout::HORIZONTAL_ALIGN_END,
+ Layout::VERTICAL_ALIGN_TOP,
48u,
26u,
6u,
tet_result(TET_PASS);
END_TEST;
}
+
+int UtcDaliTextLayoutSetGetDefaultLineSpacing(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextLayoutSetGetDefaultLineSpacing");
+
+ Layout::Engine engine;
+ DALI_TEST_EQUALS( 0.f, engine.GetDefaultLineSpacing(), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ engine.SetDefaultLineSpacing( 10.f );
+ DALI_TEST_EQUALS( 10.f, engine.GetDefaultLineSpacing(), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
#include <dali-toolkit/internal/text/markup-processor.h>
#include <dali-toolkit/internal/text/markup-processor-helper-functions.h>
#include <dali-toolkit/internal/text/color-run.h>
#include <dali-toolkit/internal/text/shaper.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
using namespace Dali;
using namespace Toolkit;
--- /dev/null
+/*
+ * 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.
+ * 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.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <limits>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/internal/text/rendering/text-typesetter.h>
+#include <dali-toolkit/internal/text/rendering/view-model.h>
+#include <dali-toolkit/internal/text/text-controller.h>
+
+using namespace Dali;
+using namespace Toolkit;
+using namespace Text;
+
+int UtcDaliTextTypesetter(void)
+{
+ tet_infoline(" UtcDaliTextTypesetter");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+ DALI_TEST_CHECK( typesetter );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextTypesetterGetViewModel(void)
+{
+ tet_infoline(" UtcDaliTextTypesetter");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+ DALI_TEST_CHECK( typesetter );
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK( NULL != model );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
--- /dev/null
+/*
+ * 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.
+ * 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.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <toolkit-text-utils.h>
+#include <dali-toolkit/internal/text/font-description-run.h>
+#include <dali-toolkit/internal/text/rendering/text-typesetter.h>
+#include <dali-toolkit/internal/text/rendering/view-model.h>
+#include <dali-toolkit/internal/text/text-controller.h>
+
+using namespace Dali;
+using namespace Toolkit;
+using namespace Text;
+
+namespace
+{
+
+const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
+
+const Size CONTROL_SIZE( 200.f, 400.f );
+const Size CONTROL_SMALL_SIZE( 50.f, 100.f );
+const char* LOREM_IPSUM = "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.\n"
+ "Usu ne nisl maiorum iudicabit, veniam epicurei oporteat eos an.\n"
+ "Ne nec nulla regione albucius, mea doctus delenit ad!\n"
+ "Et everti blandit adversarium mei, eam porro neglegentur suscipiantur an.\n"
+ "Quidam corpora at duo. An eos possim scripserit?\n\n"
+ "Aťqui dicant sěnťenťíae aň vel!\n"
+ "Vis viris médiocrem elaboraret ét, verear civibus moderatius ex duo!\n"
+ "Án veri laborě iňtěgré quó, mei aď poššit lobortis, mei prompťa čonsťitůťó eů.\n"
+ "Aliquip sanctůs delicáta quí ěá, et natum aliquam est?\n"
+ "Asšúm sapěret usu ůť.\n"
+ "Síť ut apeirián laboramúš percipitur, sůas hařum ín éos?\n";
+const Vector2 LOREM_SCROLL_POSITION( 0.f, -208.f );
+const Length LOREM_NUMBER_OF_LINES = 32u;
+const Length LOREM_NUMBER_OF_LINES_ELIDED = 21u;
+const Length LOREM_NUMBER_OF_GLYPHS = 632;
+const Length LOREM_NUMBER_OF_GLYPHS_ELIDED = 397u;
+
+// The expected layout size for UtcDaliTextViewModelGetLayoutSize
+const Size LAYOUT_SIZE( 190.f, 48.f );
+
+// The expected color indices for UtcDaliTextViewModelGetColors
+const ColorIndex COLOR_INDICES[] = { 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 2u, 2u, 2u, 2u, 2u, 1u, 1u, 1u, 1u, 1u, 3u, 1u, 1u, 1u, 0u, 0u, 0u, 0u };
+const Length NUMBER_OF_COLORS = 3u;
+const Vector4 COLORS[] = { Color::RED, Color::BLUE, Color::GREEN };
+
+struct ElideData
+{
+ std::string description;
+ std::string text;
+ Vector2 size;
+ unsigned int numberOfLines;
+ unsigned int numberOfGlyphs;
+ float* positions;
+};
+
+bool ElideTest( const ElideData& data )
+{
+ std::cout << " testing : " << data.description << std::endl;
+
+ // Load some fonts.
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.SetDpi( 93u, 93u );
+
+ char* pathNamePtr = get_current_dir_name();
+ const std::string pathName( pathNamePtr );
+ free( pathNamePtr );
+
+ fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
+ fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
+ fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+ DALI_TEST_CHECK( typesetter );
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK( NULL != model );
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel( controller );
+
+ // Sets a text and relais-out.
+ controller->SetMarkupProcessorEnabled( true );
+
+ controller->SetText( data.text );
+ controller->Relayout( data.size );
+
+ // Elide the glyphs.
+ model->ElideGlyphs();
+
+ if( data.numberOfLines != model->GetNumberOfLines() )
+ {
+ std::cout << " different number of lines : " << model->GetNumberOfLines() << ", expected : " << data.numberOfLines << std::endl;
+ return false;
+ }
+
+ if( data.numberOfGlyphs != model->GetNumberOfGlyphs() )
+ {
+ std::cout << " different number of glyphs : " << model->GetNumberOfGlyphs() << ", expected : " << data.numberOfGlyphs << std::endl;
+ return false;
+ }
+
+ const Vector2* const layoutBuffer = model->GetLayout();
+ const Length numberOfLines = model->GetNumberOfLines();
+
+ if( numberOfLines != 0u )
+ {
+ const LineRun& lastLine = *( model->GetLines() + numberOfLines - 1u );
+ const Length numberOfLastLineGlyphs = data.numberOfGlyphs - lastLine.glyphRun.glyphIndex;
+
+ std::cout << " last line alignment offset : " << lastLine.alignmentOffset << std::endl;
+
+ for( unsigned int index = 0u; index < numberOfLastLineGlyphs; ++index )
+ {
+ if( *( data.positions + index ) != ( lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + index ) ).x ) )
+ {
+ std::cout << " different layout :";
+ for( unsigned int i = 0; i < numberOfLastLineGlyphs; ++i )
+ {
+ std::cout << " " << ( lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + i ) ).x );
+ }
+ std::cout << std::endl;
+ std::cout << " expected :";
+ for( unsigned int i = 0; i < numberOfLastLineGlyphs; ++i )
+ {
+ std::cout << " " << *( data.positions + i );
+ }
+ std::cout << std::endl;
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+} // namespace
+
+int UtcDaliTextViewModel(void)
+{
+ tet_infoline(" UtcDaliTextViewModel");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+ DALI_TEST_CHECK( typesetter );
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK( NULL != model );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextViewModelGetControlSize(void)
+{
+ tet_infoline(" UtcDaliTextViewModelGetControlSize");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+ DALI_TEST_CHECK( typesetter );
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK( NULL != model );
+
+ // Configures the text controller similarly to the text-editor.
+ ConfigureTextEditor( controller );
+
+ // The text has not been laid-out. The stored control's size should be zero.
+ DALI_TEST_EQUALS( Size::ZERO, model->GetControlSize(), TEST_LOCATION );
+
+ // Sets a text and relais-out.
+ controller->SetText( "Hello world" );
+ controller->Relayout( CONTROL_SIZE );
+
+ // The control's size should be stored now.
+ DALI_TEST_EQUALS( CONTROL_SIZE, model->GetControlSize(), TEST_LOCATION );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextViewModelGetLayoutSize(void)
+{
+ tet_infoline(" UtcDaliTextViewModelGetLayoutSize");
+ ToolkitTestApplication application;
+
+ // Load some fonts.
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.SetDpi( 93u, 93u );
+
+ char* pathNamePtr = get_current_dir_name();
+ const std::string pathName( pathNamePtr );
+ free( pathNamePtr );
+
+ fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+ DALI_TEST_CHECK( typesetter );
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK( NULL != model );
+
+ // Configures the text controller similarly to the text-editor.
+ ConfigureTextEditor( controller );
+
+ // The text has not been laid-out. The stored control's size should be zero.
+ DALI_TEST_EQUALS( Size::ZERO, model->GetLayoutSize(), TEST_LOCATION );
+
+ // Sets a text and relais-out.
+ controller->SetMarkupProcessorEnabled( true );
+ controller->SetText( "<font family='TizenSansRegular' size='10'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>" );
+ controller->Relayout( CONTROL_SIZE );
+
+ // The control's size should be stored now.
+ DALI_TEST_EQUALS( LAYOUT_SIZE, model->GetLayoutSize(), TEST_LOCATION );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextViewModelGetScrollPosition(void)
+{
+ tet_infoline(" UtcDaliTextViewModelGetScrollPosition");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+ DALI_TEST_CHECK( typesetter );
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK( NULL != model );
+
+ // Configures the text controller similarly to the text-editor.
+ ConfigureTextEditor( controller );
+
+ // No text has been set. The scroll position should be zero.
+ DALI_TEST_EQUALS( Vector2::ZERO, model->GetScrollPosition(), TEST_LOCATION );
+
+ // Gains the keyboard focus, sets a big text and relais-out.
+ controller->KeyboardFocusGainEvent();
+ controller->SetText( LOREM_IPSUM );
+ controller->Relayout( CONTROL_SIZE );
+
+ // The text should be scrolled to the end.
+ DALI_TEST_EQUALS( LOREM_SCROLL_POSITION, model->GetScrollPosition(), TEST_LOCATION );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextViewModelGetAlignment(void)
+{
+ tet_infoline(" UtcDaliTextViewModelGetAlignment");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+ DALI_TEST_CHECK( typesetter );
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK( NULL != model );
+
+ DALI_TEST_EQUALS( Layout::HORIZONTAL_ALIGN_BEGIN, model->GetHorizontalAlignment(), TEST_LOCATION );
+ DALI_TEST_EQUALS( Layout::VERTICAL_ALIGN_TOP, model->GetVerticalAlignment(), TEST_LOCATION );
+
+ controller->SetHorizontalAlignment( Layout::HORIZONTAL_ALIGN_CENTER );
+ controller->SetVerticalAlignment( Layout::VERTICAL_ALIGN_CENTER );
+
+ DALI_TEST_EQUALS( Layout::HORIZONTAL_ALIGN_CENTER, model->GetHorizontalAlignment(), TEST_LOCATION );
+ DALI_TEST_EQUALS( Layout::VERTICAL_ALIGN_CENTER, model->GetVerticalAlignment(), TEST_LOCATION );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextViewModelIsTextElideEnabled(void)
+{
+ tet_infoline(" UtcDaliTextViewModelIsTextElideEnabled");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+ DALI_TEST_CHECK( typesetter );
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK( NULL != model );
+
+ // Configures the text controller similarly to the text-editor.
+ ConfigureTextEditor( controller );
+
+ // Elide text should be disabled.
+ DALI_TEST_CHECK( !model->IsTextElideEnabled() );
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel( controller );
+
+ // Elide text should be enabled.
+ DALI_TEST_CHECK( model->IsTextElideEnabled() );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextViewModelGetLines(void)
+{
+ tet_infoline(" UtcDaliTextViewModelGetLines");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+ DALI_TEST_CHECK( typesetter );
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK( NULL != model );
+
+ // Configures the text controller similarly to the text-editor.
+ ConfigureTextEditor( controller );
+
+ // The number of lines should be zero.
+ DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION );
+ DALI_TEST_CHECK( NULL == model->GetLines() );
+
+ // Sets a text and relais-out.
+ controller->SetText( LOREM_IPSUM );
+ controller->Relayout( CONTROL_SIZE );
+
+ DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES, model->GetNumberOfLines(), TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != model->GetLines() );
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel( controller );
+
+ // Relais-out for the text-label configuration.
+ controller->Relayout( Size( 100.f, 100.f) ); // Change the size to force a relayout.
+ controller->Relayout( CONTROL_SIZE );
+
+ DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES_ELIDED, model->GetNumberOfLines(), TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != model->GetLines() );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextViewModelGetGlyphsLayout(void)
+{
+ tet_infoline(" UtcDaliTextViewModelGetGlyphsLayout");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+ DALI_TEST_CHECK( typesetter );
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK( NULL != model );
+
+ // Configures the text controller similarly to the text-editor.
+ ConfigureTextEditor( controller );
+
+ // The number of glyphs should be zero.
+ DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
+ DALI_TEST_CHECK( NULL == model->GetGlyphs() );
+ DALI_TEST_CHECK( NULL == model->GetLayout() );
+
+ // Sets a text and relais-out.
+ controller->SetText( LOREM_IPSUM );
+ controller->Relayout( CONTROL_SIZE );
+
+ DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS, model->GetNumberOfGlyphs(), TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != model->GetGlyphs() );
+ DALI_TEST_CHECK( NULL != model->GetLayout() );
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel( controller );
+
+ // Relais-out for the text-label configuration.
+ controller->Relayout( Size( 100.f, 100.f) ); // Change the size to force a relayout.
+ controller->Relayout( CONTROL_SIZE );
+
+ // Elide the glyphs.
+ model->ElideGlyphs();
+
+ DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS_ELIDED, model->GetNumberOfGlyphs(), TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != model->GetGlyphs() );
+ DALI_TEST_CHECK( NULL != model->GetLayout() );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextViewModelGetColors(void)
+{
+ tet_infoline(" UtcDaliTextViewModelGetColors");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+ DALI_TEST_CHECK( typesetter );
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK( NULL != model );
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel( controller );
+
+ // Sets a text and relais-out.
+ controller->SetMarkupProcessorEnabled( true );
+ controller->SetText( "Lorem <color value='red'>ips<color value='blue'>um do</color>lor s<color value='green'>i</color>t a</color>met." );
+ controller->Relayout( CONTROL_SIZE );
+
+ DALI_TEST_EQUALS( Color::BLACK, model->GetDefaultColor(), TEST_LOCATION );
+
+ const ColorIndex* const colorIndicesBuffer = model->GetColorIndices();
+
+ const Length numberOfGlyphs = model->GetNumberOfGlyphs();
+ for( ColorIndex index = 0u; index < numberOfGlyphs; ++index )
+ {
+ DALI_TEST_EQUALS( COLOR_INDICES[index], *( colorIndicesBuffer + index ), TEST_LOCATION );
+ }
+
+ const Vector4* const colors = model->GetColors();
+ for( unsigned int index = 0u; index < NUMBER_OF_COLORS; ++index )
+ {
+ DALI_TEST_EQUALS( COLORS[index], *( colors + index ), TEST_LOCATION );
+ }
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextViewModelElideText01(void)
+{
+ tet_infoline(" UtcDaliTextViewModelElideText01");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+ DALI_TEST_CHECK( typesetter );
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK( NULL != model );
+
+ // Configures the text controller similarly to the text-editor.
+ ConfigureTextEditor( controller );
+
+ // The number of glyphs should be zero.
+ DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION );
+ DALI_TEST_CHECK( NULL == model->GetGlyphs() );
+ DALI_TEST_CHECK( NULL == model->GetLayout() );
+
+ // Sets a text and relais-out.
+ controller->SetText( LOREM_IPSUM );
+ controller->Relayout( CONTROL_SIZE );
+
+ // Keep the pointers to the glyphs and layout.
+ // As the text is not elided with this configuration, the pointers shoud be the same after calling the ElideGlyphs() method.
+ const GlyphInfo* const glyphsModel = model->GetGlyphs();
+ const Vector2* layoutsModel = model->GetLayout();
+
+ // Elide the glyphs. Text shouldn't be elided with this configuration.
+ model->ElideGlyphs();
+
+ DALI_TEST_CHECK( glyphsModel == model->GetGlyphs() );
+ DALI_TEST_CHECK( layoutsModel == model->GetLayout() );
+
+ DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS, model->GetNumberOfGlyphs(), TEST_LOCATION );
+ DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES, model->GetNumberOfLines(), TEST_LOCATION );
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel( controller );
+
+ // Clear the text and relais-out.
+ controller->SetText( "" );
+ controller->Relayout( CONTROL_SIZE );
+
+ DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION );
+
+ // Elide the glyphs. Should not add the ellipsis glyph.
+ model->ElideGlyphs();
+
+ DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
+
+ // Sets a text that doesn't need to be elided.
+ controller->SetText( "Hello\n" );
+ controller->Relayout( CONTROL_SIZE );
+
+ // Elide the glyphs.
+ model->ElideGlyphs();
+
+ DALI_TEST_EQUALS( 6u, model->GetNumberOfGlyphs(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 2u, model->GetNumberOfLines(), TEST_LOCATION );
+
+ // Sets a text and relais-out.
+ controller->SetText( LOREM_IPSUM );
+ controller->Relayout( CONTROL_SIZE );
+
+ // Elide the glyphs.
+ model->ElideGlyphs();
+
+ DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS_ELIDED, model->GetNumberOfGlyphs(), TEST_LOCATION );
+ DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES_ELIDED, model->GetNumberOfLines(), TEST_LOCATION );
+ const GlyphInfo* const glyphs = model->GetGlyphs();
+ const Vector2* layouts = model->GetLayout();
+ DALI_TEST_CHECK( NULL != glyphs );
+ DALI_TEST_CHECK( NULL != layouts );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextViewModelElideText02(void)
+{
+ tet_infoline(" UtcDaliTextViewModelElideText02");
+
+ Size textSize00( 100.f, 100.f );
+
+ Size textSize01( 80.f, 100.f );
+ float positions01[] = { 0.f, 10.f, 16.f, 26.f, 35.f, 38.f, 46.f, 56.f };
+
+ Size textSize02( 80.f, 100.f );
+ float positions02[] = { 72.f, 63.f, 54.f, 50.f, 43.f, 38.f, 30.f, 11.f };
+
+ Size textSize03( 80.f, 100.f );
+ float positions03[] = { 77.f, 76.f, 71.f, 62.f, 60.f, 52.f, 47.f, 42.f, 39.f, 35.f, 32.f, 13.f };
+
+ Size textSize04( 80.f, 10.f );
+ float positions04[] = { 2.f };
+
+ struct ElideData data[] =
+ {
+ {
+ "void text",
+ "",
+ textSize00,
+ 0u,
+ 0u,
+ NULL
+ },
+ {
+ "Latin script",
+ "<font family='TizenSans'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>",
+ textSize01,
+ 5u,
+ 42u,
+ positions01
+ },
+ {
+ "Hebrew script",
+ "<font family='TizenSansHebrew'>צעד על לשון המלצת לאחרונה, אם לכאן שנורו סרבול מדע, קרן דת שפות להפוך.</font>",
+ textSize02,
+ 5u,
+ 49u,
+ positions02
+ },
+ {
+ "Arabic script",
+ "<font family='TizenSansArabic'>عل النفط ديسمبر الإمداد بال, بين وترك شعار هو. لمّ من المبرمة النفط بالسيطرة, أم يتم تحرّك وبغطاء, عدم في لإعادة وإقامة رجوعهم.</font>",
+ textSize03,
+ 5u,
+ 79u,
+ positions03
+ },
+ {
+ "Small control size, no line fits.",
+ "<font family='TizenSans'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>",
+ textSize04,
+ 1u,
+ 1u,
+ positions04
+ }
+ };
+ const unsigned int numberOfTests = 5u;
+
+ for( unsigned int index = 0u; index < numberOfTests; ++index )
+ {
+ ToolkitTestApplication application;
+ if( !ElideTest( data[index] ) )
+ {
+ tet_result(TET_FAIL);
+ }
+ }
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
using namespace Dali;
END_TEST;
}
+
+int utcDaliTextEditorEvent04(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorEvent04");
+
+ // Checks if the highlight actor is created.
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK( editor );
+
+ Stage::GetCurrent().Add( editor );
+
+ editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
+ editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
+ editor.SetSize( 100.f, 50.f );
+ editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap on the text editor
+ application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
+ application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Move at the end of the text.
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ for( unsigned int index = 0u; index < 10u; ++index )
+ {
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ }
+
+ // Add a character
+ application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
+
+ // Add some key events
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ for( unsigned int index = 0u; index < 10u; ++index )
+ {
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ }
+
+ // Add a character
+ application.ProcessEvent( GenerateKey( " ", " ", 0, 0, 0, Integration::KeyEvent::Down ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
+
+ END_TEST;
+}
const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
{
- { "BEGIN", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN },
- { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
- { "END", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END },
+ { "BEGIN", Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN },
+ { "CENTER", Toolkit::Text::Layout::HORIZONTAL_ALIGN_CENTER },
+ { "END", Toolkit::Text::Layout::HORIZONTAL_ALIGN_END },
};
const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
{
if( impl.mController )
{
- const std::string text = value.Get< std::string >();
+ const std::string& text = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p TEXT %s\n", impl.mController.Get(), text.c_str() );
impl.mController->SetText( text );
{
if( impl.mController )
{
- const Vector4 textColor = value.Get< Vector4 >();
+ const Vector4& textColor = value.Get< Vector4 >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
- if( impl.mController->GetTextColor() != textColor )
+ if( impl.mController->GetDefaultColor() != textColor )
{
- impl.mController->SetTextColor( textColor );
+ impl.mController->SetDefaultColor( textColor );
impl.mController->SetInputColor( textColor );
impl.mRenderer.Reset();
}
{
if( impl.mController )
{
- const std::string fontFamily = value.Get< std::string >();
+ const std::string& fontFamily = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
impl.mController->SetDefaultFontFamily( fontFamily );
}
{
if( impl.mController )
{
- const std::string alignStr = value.Get< std::string >();
+ const std::string& alignStr = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p HORIZONTAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() );
- LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN );
- if( Scripting::GetEnumeration< LayoutEngine::HorizontalAlignment >( alignStr.c_str(),
- HORIZONTAL_ALIGNMENT_STRING_TABLE,
- HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
- alignment ) )
+ Layout::HorizontalAlignment alignment( Layout::HORIZONTAL_ALIGN_BEGIN );
+ if( Scripting::GetEnumeration< Layout::HorizontalAlignment >( alignStr.c_str(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
+ alignment ) )
{
impl.mController->SetHorizontalAlignment( alignment );
}
{
if( impl.mDecorator )
{
- const Vector4 color = value.Get< Vector4 >();
+ const Vector4& color = value.Get< Vector4 >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color );
{
if( impl.mDecorator )
{
- const Vector4 color = value.Get< Vector4 >();
+ const Vector4& color = value.Get< Vector4 >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color );
{
if( impl.mDecorator )
{
- const Rect<int> box = value.Get< Rect<int> >();
+ const Rect<int>& box = value.Get< Rect<int> >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p DECORATION_BOUNDING_BOX %d,%d %dx%d\n", impl.mController.Get(), box.x, box.y, box.width, box.height );
impl.mDecorator->SetBoundingBox( box );
{
if( impl.mController )
{
- const Vector4 inputColor = value.Get< Vector4 >();
+ const Vector4& inputColor = value.Get< Vector4 >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p INPUT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), inputColor.r, inputColor.g, inputColor.b, inputColor.a );
impl.mController->SetInputColor( inputColor );
{
if( impl.mController )
{
- const std::string fontFamily = value.Get< std::string >();
+ const std::string& fontFamily = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
impl.mController->SetInputFontFamily( fontFamily );
}
{
if ( impl.mController )
{
- value = impl.mController->GetTextColor();
+ value = impl.mController->GetDefaultColor();
}
break;
}
{
if( impl.mController )
{
- const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
- HORIZONTAL_ALIGNMENT_STRING_TABLE,
- HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+ const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
if( name )
{
value = std::string( name );
mDecorator = Text::Decorator::New( *mController,
*mController );
- mController->GetLayoutEngine().SetLayout( LayoutEngine::MULTI_LINE_BOX );
+ mController->GetLayoutEngine().SetLayout( Layout::Engine::MULTI_LINE_BOX );
// Enables the text input.
mController->EnableTextInput( mDecorator );
if( mRenderableActor )
{
- const Vector2& scrollOffset = mController->GetScrollPosition();
+ const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
{
- { "BEGIN", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN },
- { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
- { "END", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END },
+ { "BEGIN", Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN },
+ { "CENTER", Toolkit::Text::Layout::HORIZONTAL_ALIGN_CENTER },
+ { "END", Toolkit::Text::Layout::HORIZONTAL_ALIGN_END },
};
const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
const Scripting::StringEnum VERTICAL_ALIGNMENT_STRING_TABLE[] =
{
- { "TOP", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP },
- { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
- { "BOTTOM", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_BOTTOM },
+ { "TOP", Toolkit::Text::Layout::VERTICAL_ALIGN_TOP },
+ { "CENTER", Toolkit::Text::Layout::VERTICAL_ALIGN_CENTER },
+ { "BOTTOM", Toolkit::Text::Layout::VERTICAL_ALIGN_BOTTOM },
};
const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
{
if( impl.mController )
{
- const std::string text = value.Get< std::string >();
+ const std::string& text = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT %s\n", impl.mController.Get(), text.c_str() );
impl.mController->SetText( text );
{
if( impl.mController )
{
- const std::string text = value.Get< std::string >();
+ const std::string& text = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() );
impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
{
if( impl.mController )
{
- const std::string text = value.Get< std::string >();
+ const std::string& text = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str() );
impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
{
if( impl.mController )
{
- const std::string fontFamily = value.Get< std::string >();
+ const std::string& fontFamily = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
impl.mController->SetDefaultFontFamily( fontFamily );
}
{
if( impl.mController )
{
- const std::string alignStr = value.Get< std::string >();
+ const std::string& alignStr = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() );
- LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN );
- if( Scripting::GetEnumeration< LayoutEngine::HorizontalAlignment >( alignStr.c_str(),
- HORIZONTAL_ALIGNMENT_STRING_TABLE,
- HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
- alignment ) )
+ Layout::HorizontalAlignment alignment( Layout::HORIZONTAL_ALIGN_BEGIN );
+ if( Scripting::GetEnumeration< Layout::HorizontalAlignment >( alignStr.c_str(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
+ alignment ) )
{
impl.mController->SetHorizontalAlignment( alignment );
}
{
if( impl.mController )
{
- const std::string alignStr = value.Get< std::string >();
+ const std::string& alignStr = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() );
- LayoutEngine::VerticalAlignment alignment( LayoutEngine::VERTICAL_ALIGN_BOTTOM );
- if( Scripting::GetEnumeration< LayoutEngine::VerticalAlignment >( alignStr.c_str(),
- VERTICAL_ALIGNMENT_STRING_TABLE,
- VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
- alignment ) )
+ Layout::VerticalAlignment alignment( Layout::VERTICAL_ALIGN_BOTTOM );
+ if( Scripting::GetEnumeration< Layout::VerticalAlignment >( alignStr.c_str(),
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
+ alignment ) )
{
impl.mController->SetVerticalAlignment( alignment );
}
{
if( impl.mController )
{
- const Vector4 textColor = value.Get< Vector4 >();
+ const Vector4& textColor = value.Get< Vector4 >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
- if( impl.mController->GetTextColor() != textColor )
+ if( impl.mController->GetDefaultColor() != textColor )
{
- impl.mController->SetTextColor( textColor );
+ impl.mController->SetDefaultColor( textColor );
impl.mController->SetInputColor( textColor );
impl.mRenderer.Reset();
}
{
if( impl.mController )
{
- const Vector4 textColor = value.Get< Vector4 >();
+ const Vector4& textColor = value.Get< Vector4 >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
if( impl.mController->GetPlaceholderTextColor() != textColor )
{
if( impl.mController )
{
- const Vector2 shadowOffset = value.Get< Vector2 >();
+ const Vector2& shadowOffset = value.Get< Vector2 >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_OFFSET %f,%f\n", impl.mController.Get(), shadowOffset.x, shadowOffset.y );
if ( impl.mController->GetShadowOffset() != shadowOffset )
{
if( impl.mController )
{
- const Vector4 shadowColor = value.Get< Vector4 >();
+ const Vector4& shadowColor = value.Get< Vector4 >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_COLOR %f,%f,%f,%f\n", impl.mController.Get(), shadowColor.r, shadowColor.g, shadowColor.b, shadowColor.a );
if ( impl.mController->GetShadowColor() != shadowColor )
{
if( impl.mDecorator )
{
- const Vector4 color = value.Get< Vector4 >();
+ const Vector4& color = value.Get< Vector4 >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color );
{
if( impl.mDecorator )
{
- const Vector4 color = value.Get< Vector4 >();
+ const Vector4& color = value.Get< Vector4 >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color );
{
if( impl.mController )
{
- const std::string fontFamily = value.Get< std::string >();
+ const std::string& fontFamily = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
impl.mController->SetInputFontFamily( fontFamily );
}
{
if( impl.mController )
{
- const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
- HORIZONTAL_ALIGNMENT_STRING_TABLE,
- HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+ const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
if( name )
{
value = std::string( name );
}
case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
{
- if( impl.mController )
+ if( impl.mController )
{
- const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetLayoutEngine().GetVerticalAlignment(),
- VERTICAL_ALIGNMENT_STRING_TABLE,
- VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+ const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( impl.mController->GetVerticalAlignment(),
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
if( name )
{
value = std::string( name );
{
if ( impl.mController )
{
- value = impl.mController->GetTextColor();
+ value = impl.mController->GetDefaultColor();
}
break;
}
mDecorator = Text::Decorator::New( *mController,
*mController );
- mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX );
+ mController->GetLayoutEngine().SetLayout( Layout::Engine::SINGLE_LINE_BOX );
// Enables the text input.
mController->EnableTextInput( mDecorator );
if( mRenderableActor )
{
- const Vector2& scrollOffset = mController->GetScrollPosition();
+ const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
#include <dali-toolkit/internal/text/text-definitions.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
-using Dali::Toolkit::Text::LayoutEngine;
+using namespace Dali::Toolkit::Text;
namespace Dali
{
const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
{
- { "BEGIN", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN },
- { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
- { "END", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END },
+ { "BEGIN", Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN },
+ { "CENTER", Toolkit::Text::Layout::HORIZONTAL_ALIGN_CENTER },
+ { "END", Toolkit::Text::Layout::HORIZONTAL_ALIGN_END },
};
const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
const Scripting::StringEnum VERTICAL_ALIGNMENT_STRING_TABLE[] =
{
- { "TOP", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP },
- { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
- { "BOTTOM", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_BOTTOM },
+ { "TOP", Toolkit::Text::Layout::VERTICAL_ALIGN_TOP },
+ { "CENTER", Toolkit::Text::Layout::VERTICAL_ALIGN_CENTER },
+ { "BOTTOM", Toolkit::Text::Layout::VERTICAL_ALIGN_BOTTOM },
};
const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
{
if( impl.mController )
{
- const std::string fontFamily = value.Get< std::string >();
+ const std::string& fontFamily = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextLabel::SetProperty Property::FONT_FAMILY newFont(%s)\n", fontFamily.c_str() );
impl.mController->SetDefaultFontFamily( fontFamily );
{
if( impl.mController )
{
- LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN );
- if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( value.Get< std::string >().c_str(),
- HORIZONTAL_ALIGNMENT_STRING_TABLE,
- HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
- alignment ) )
+ Layout::HorizontalAlignment alignment( Layout::HORIZONTAL_ALIGN_BEGIN );
+ if( Scripting::GetEnumeration< Toolkit::Text::Layout::HorizontalAlignment >( value.Get< std::string >().c_str(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
+ alignment ) )
{
impl.mController->SetHorizontalAlignment( alignment );
}
{
if( impl.mController )
{
- LayoutEngine::VerticalAlignment alignment( LayoutEngine::VERTICAL_ALIGN_BOTTOM );
- if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( value.Get< std::string >().c_str(),
- VERTICAL_ALIGNMENT_STRING_TABLE,
- VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
- alignment ) )
+ Layout::VerticalAlignment alignment( Layout::VERTICAL_ALIGN_BOTTOM );
+ if( Scripting::GetEnumeration< Toolkit::Text::Layout::VerticalAlignment >( value.Get< std::string >().c_str(),
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
+ alignment ) )
{
impl.mController->SetVerticalAlignment( alignment );
}
{
if( impl.mController )
{
- const Vector4 textColor = value.Get< Vector4 >();
- if( impl.mController->GetTextColor() != textColor )
+ const Vector4& textColor = value.Get< Vector4 >();
+ if( impl.mController->GetDefaultColor() != textColor )
{
- impl.mController->SetTextColor( textColor );
+ impl.mController->SetDefaultColor( textColor );
impl.mRenderer.Reset();
}
}
{
if( impl.mController )
{
- const Vector2 shadowOffset = value.Get< Vector2 >();
+ const Vector2& shadowOffset = value.Get< Vector2 >();
if ( impl.mController->GetShadowOffset() != shadowOffset )
{
impl.mController->SetShadowOffset( shadowOffset );
{
if( impl.mController )
{
- const Vector4 shadowColor = value.Get< Vector4 >();
+ const Vector4& shadowColor = value.Get< Vector4 >();
if ( impl.mController->GetShadowColor() != shadowColor )
{
impl.mController->SetShadowColor( shadowColor );
{
if( impl.mController )
{
- const Vector4 color = value.Get< Vector4 >();
+ const Vector4& color = value.Get< Vector4 >();
if ( impl.mController->GetUnderlineColor() != color )
{
impl.mController->SetUnderlineColor( color );
// If request is enable (true) then start autoscroll as not already running
else
{
- impl.mController->GetLayoutEngine().SetTextEllipsisEnabled( false );
+ impl.mController->SetTextElideEnabled( false );
impl.mController->SetAutoScrollEnabled( enableAutoScroll );
}
}
{
if( impl.mController )
{
- const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(),
- HORIZONTAL_ALIGNMENT_STRING_TABLE,
- HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+ const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
if( name )
{
value = std::string( name );
{
if( impl.mController )
{
- const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetVerticalAlignment(),
- VERTICAL_ALIGNMENT_STRING_TABLE,
- VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+ const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( impl.mController->GetVerticalAlignment(),
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
if( name )
{
value = std::string( name );
{
if ( impl.mController )
{
- value = impl.mController->GetTextColor();
+ value = impl.mController->GetDefaultColor();
}
break;
}
self.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
// Enable the text ellipsis.
- LayoutEngine& engine = mController->GetLayoutEngine();
+ mController->SetTextElideEnabled( true ); // If false then text larger than control will overflow
- engine.SetTextEllipsisEnabled( true ); // If false then text larger than control will overflow
+ Layout::Engine& engine = mController->GetLayoutEngine();
engine.SetCursorWidth( 0u ); // Do not layout space for the cursor.
self.OnStageSignal().Connect( this, &TextLabel::OnStageConnect );
if( renderableActor )
{
- const Vector2& scrollOffset = mController->GetScrollPosition();
+ const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
renderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
self.Add( renderableActor );
// Pure Virtual from TextScroller Interface
DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::ScrollingFinished\n");
mController->SetAutoScrollEnabled( false );
- mController->GetLayoutEngine().SetTextEllipsisEnabled( true );
+ mController->SetTextElideEnabled( true );
RequestTextRelayout();
}
$(toolkit_src_dir)/text/text-effects-style.cpp \
$(toolkit_src_dir)/text/text-font-style.cpp \
$(toolkit_src_dir)/text/text-io.cpp \
+ $(toolkit_src_dir)/text/text-model.cpp \
$(toolkit_src_dir)/text/text-scroller.cpp \
$(toolkit_src_dir)/text/text-scroller-interface.cpp \
$(toolkit_src_dir)/text/text-view.cpp \
$(toolkit_src_dir)/text/rendering/atlas/atlas-manager-impl.cpp \
$(toolkit_src_dir)/text/rendering/atlas/atlas-mesh-factory.cpp \
$(toolkit_src_dir)/text/rendering/text-backend-impl.cpp \
+ $(toolkit_src_dir)/text/rendering/text-typesetter.cpp \
+ $(toolkit_src_dir)/text/rendering/view-model.cpp \
$(toolkit_src_dir)/transition-effects/cube-transition-effect-impl.cpp \
$(toolkit_src_dir)/transition-effects/cube-transition-cross-effect-impl.cpp \
$(toolkit_src_dir)/transition-effects/cube-transition-fold-effect-impl.cpp \
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_LAYOUT_ALIGNMENT_H
+#define DALI_TOOLKIT_TEXT_LAYOUT_ALIGNMENT_H
+
+/*
+ * 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.
+ * 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 Speficies the horizontal alignment.
+ *
+ * BEGIN is on the left for Left To Right languages whereas is right for Right To Left.
+ * Similarly, END is on the right for Left To Right languages and left for Right To Left.
+ */
+enum HorizontalAlignment
+{
+ HORIZONTAL_ALIGN_BEGIN,
+ HORIZONTAL_ALIGN_CENTER,
+ HORIZONTAL_ALIGN_END
+};
+
+/**
+ * @brief Speficies the vertical alignment.
+ */
+enum VerticalAlignment
+{
+ VERTICAL_ALIGN_TOP,
+ VERTICAL_ALIGN_CENTER,
+ VERTICAL_ALIGN_BOTTOM
+};
+
+} // namespace Layout
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_LAYOUT_ALIGNMENT_H
namespace Text
{
+namespace Layout
+{
+
namespace
{
float descender; ///< The minimum descender of all fonts in the line.
};
-struct LayoutEngine::Impl
+struct Engine::Impl
{
Impl()
- : mLayout( LayoutEngine::SINGLE_LINE_BOX ),
- mHorizontalAlignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN ),
- mVerticalAlignment( LayoutEngine::VERTICAL_ALIGN_TOP ),
+ : mLayout( Layout::Engine::SINGLE_LINE_BOX ),
mCursorWidth( CURSOR_WIDTH ),
- mDefaultLineSpacing( LINE_SPACING ),
- mEllipsisEnabled( false )
+ mDefaultLineSpacing( LINE_SPACING )
{
}
* @param[in,out] paragraphDirection in: the current paragraph's direction, out: the next paragraph's direction. Is set after a must break.
* @param[in] completelyFill Whether to completely fill the line ( even if the last word exceeds the boundaries ).
*/
- void GetLineLayoutForBox( const LayoutParameters& parameters,
+ void GetLineLayoutForBox( const Parameters& parameters,
LineLayout& lineLayout,
CharacterDirection& paragraphDirection,
bool completelyFill )
*
* return Whether the line is ellipsized.
*/
- bool EllipsisLine( const LayoutParameters& layoutParameters,
+ bool EllipsisLine( const Parameters& layoutParameters,
const LineLayout& layout,
Size& layoutSize,
LineRun* linesBuffer,
* @param[in,out] numberOfLines The number of laid-out lines.
* @param[in] isLastLine Whether the laid-out line is the last one.
*/
- void UpdateTextLayout( const LayoutParameters& layoutParameters,
+ void UpdateTextLayout( const Parameters& layoutParameters,
const LineLayout& layout,
Size& layoutSize,
LineRun* linesBuffer,
* @param[in,out] linesBuffer Pointer to the line's buffer.
* @param[in,out] numberOfLines The number of laid-out lines.
*/
- void UpdateTextLayout( const LayoutParameters& layoutParameters,
+ void UpdateTextLayout( const Parameters& layoutParameters,
CharacterIndex characterIndex,
GlyphIndex glyphIndex,
Size& layoutSize,
* @param[in] characterOffset The offset to be added to the runs of characters.
* @param[in] glyphOffset The offset to be added to the runs of glyphs.
*/
- void UpdateLineIndexOffsets( const LayoutParameters& layoutParameters,
+ void UpdateLineIndexOffsets( const Parameters& layoutParameters,
Vector<LineRun>& lines,
Length characterOffset,
Length glyphOffset )
}
}
- bool LayoutText( const LayoutParameters& layoutParameters,
+ bool LayoutText( const Parameters& layoutParameters,
Vector<Vector2>& glyphPositions,
Vector<LineRun>& lines,
- Size& layoutSize )
+ Size& layoutSize,
+ bool elideTextEnabled )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->LayoutText\n" );
DALI_LOG_INFO( gLogFilter, Debug::Verbose, " box size %f, %f\n", layoutParameters.boundingBox.width, layoutParameters.boundingBox.height );
DALI_LOG_INFO( gLogFilter, Debug::Verbose, " pen y %f\n", penY );
bool ellipsis = false;
- if( mEllipsisEnabled )
+ if( elideTextEnabled )
{
// Does the ellipsis of the last line.
ellipsis = EllipsisLine( layoutParameters,
return true;
}
- void ReLayoutRightToLeftLines( const LayoutParameters& layoutParameters,
+ void ReLayoutRightToLeftLines( const Parameters& layoutParameters,
CharacterIndex startIndex,
Length numberOfCharacters,
Vector<Vector2>& glyphPositions )
void Align( const Size& size,
CharacterIndex startIndex,
Length numberOfCharacters,
+ HorizontalAlignment horizontalAlignment,
Vector<LineRun>& lines )
{
const CharacterIndex lastCharacterPlusOne = startIndex + numberOfCharacters;
// Calculate the line's alignment offset accordingly with the align option,
// the box width, line length, and the paragraph's direction.
CalculateHorizontalAlignment( size.width,
+ horizontalAlignment,
line );
}
}
void CalculateHorizontalAlignment( float boxWidth,
+ HorizontalAlignment horizontalAlignment,
LineRun& line )
{
line.alignmentOffset = 0.f;
const bool isRTL = RTL == line.direction;
float lineLength = line.width;
- HorizontalAlignment alignment = mHorizontalAlignment;
+ HorizontalAlignment alignment = horizontalAlignment;
if( isRTL )
{
// Swap the alignment type if the line is right to left.
line.ellipsis = false;
}
- LayoutEngine::Layout mLayout;
- LayoutEngine::HorizontalAlignment mHorizontalAlignment;
- LayoutEngine::VerticalAlignment mVerticalAlignment;
+ Type mLayout;
float mCursorWidth;
float mDefaultLineSpacing;
IntrusivePtr<Metrics> mMetrics;
-
- bool mEllipsisEnabled:1;
};
-LayoutEngine::LayoutEngine()
+Engine::Engine()
: mImpl( NULL )
{
- mImpl = new LayoutEngine::Impl();
+ mImpl = new Engine::Impl();
}
-LayoutEngine::~LayoutEngine()
+Engine::~Engine()
{
delete mImpl;
}
-void LayoutEngine::SetMetrics( MetricsPtr& metrics )
+void Engine::SetMetrics( MetricsPtr& metrics )
{
mImpl->mMetrics = metrics;
}
-void LayoutEngine::SetLayout( Layout layout )
+void Engine::SetLayout( Type layout )
{
mImpl->mLayout = layout;
}
-LayoutEngine::Layout LayoutEngine::GetLayout() const
+Engine::Type Engine::GetLayout() const
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "GetLayout[%d]\n", mImpl->mLayout);
return mImpl->mLayout;
}
-void LayoutEngine::SetTextEllipsisEnabled( bool enabled )
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->LayoutEngine::SetTextEllipsisEnabled[%s]\n", (enabled)?"true":"false" );
- mImpl->mEllipsisEnabled = enabled;
-}
-
-bool LayoutEngine::GetTextEllipsisEnabled() const
-{
- return mImpl->mEllipsisEnabled;
-}
-
-void LayoutEngine::SetHorizontalAlignment( HorizontalAlignment alignment )
-{
- mImpl->mHorizontalAlignment = alignment;
-}
-
-LayoutEngine::HorizontalAlignment LayoutEngine::GetHorizontalAlignment() const
-{
- return mImpl->mHorizontalAlignment;
-}
-
-void LayoutEngine::SetVerticalAlignment( VerticalAlignment alignment )
-{
- mImpl->mVerticalAlignment = alignment;
-}
-
-LayoutEngine::VerticalAlignment LayoutEngine::GetVerticalAlignment() const
-{
- return mImpl->mVerticalAlignment;
-}
-
-void LayoutEngine::SetCursorWidth( int width )
+void Engine::SetCursorWidth( int width )
{
mImpl->mCursorWidth = static_cast<float>( width );
}
-int LayoutEngine::GetCursorWidth() const
+int Engine::GetCursorWidth() const
{
return static_cast<int>( mImpl->mCursorWidth );
}
-bool LayoutEngine::LayoutText( const LayoutParameters& layoutParameters,
- Vector<Vector2>& glyphPositions,
- Vector<LineRun>& lines,
- Size& layoutSize )
+bool Engine::LayoutText( const Parameters& layoutParameters,
+ Vector<Vector2>& glyphPositions,
+ Vector<LineRun>& lines,
+ Size& layoutSize,
+ bool elideTextEnabled )
{
return mImpl->LayoutText( layoutParameters,
glyphPositions,
lines,
- layoutSize );
+ layoutSize,
+ elideTextEnabled );
}
-void LayoutEngine::ReLayoutRightToLeftLines( const LayoutParameters& layoutParameters,
- CharacterIndex startIndex,
- Length numberOfCharacters,
- Vector<Vector2>& glyphPositions )
+void Engine::ReLayoutRightToLeftLines( const Parameters& layoutParameters,
+ CharacterIndex startIndex,
+ Length numberOfCharacters,
+ Vector<Vector2>& glyphPositions )
{
mImpl->ReLayoutRightToLeftLines( layoutParameters,
startIndex,
glyphPositions );
}
-void LayoutEngine::Align( const Size& size,
- CharacterIndex startIndex,
- Length numberOfCharacters,
- Vector<LineRun>& lines )
+void Engine::Align( const Size& size,
+ CharacterIndex startIndex,
+ Length numberOfCharacters,
+ Layout::HorizontalAlignment horizontalAlignment,
+ Vector<LineRun>& lines )
{
mImpl->Align( size,
startIndex,
numberOfCharacters,
+ horizontalAlignment,
lines );
}
-void LayoutEngine::SetDefaultLineSpacing( float lineSpacing )
+void Engine::SetDefaultLineSpacing( float lineSpacing )
{
mImpl->mDefaultLineSpacing = lineSpacing;
}
-float LayoutEngine::GetDefaultLineSpacing() const
+float Engine::GetDefaultLineSpacing() const
{
return mImpl->mDefaultLineSpacing;
}
+} // namespace Layout
+
} // namespace Text
} // namespace Toolkit
-#ifndef __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__
-#define __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__
+#ifndef DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H
+#define DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_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.
#include <dali/public-api/math/vector2.h>
// INTERNAL INCLUDE
+#include <dali-toolkit/internal/text/layouts/layout-alignment.h>
#include <dali-toolkit/internal/text/line-run.h>
#include <dali-toolkit/internal/text/metrics.h>
namespace Text
{
-struct LayoutParameters;
+namespace Layout
+{
+
+struct Parameters;
/**
* @brief LayoutEngine is responsible for calculating the visual position of glyphs in layout.
*/
-class LayoutEngine
+class Engine
{
public:
- enum Layout
+ enum Type
{
SINGLE_LINE_BOX,
MULTI_LINE_BOX
};
- enum HorizontalAlignment
- {
- HORIZONTAL_ALIGN_BEGIN,
- HORIZONTAL_ALIGN_CENTER,
- HORIZONTAL_ALIGN_END
- };
-
- enum VerticalAlignment
- {
- VERTICAL_ALIGN_TOP,
- VERTICAL_ALIGN_CENTER,
- VERTICAL_ALIGN_BOTTOM
- };
-
/**
* @brief Create a new instance of a LayoutEngine.
*/
- LayoutEngine();
+ Engine();
/**
* @brief Virtual destructor.
*/
- ~LayoutEngine();
+ ~Engine();
/**
* @brief Provide the wrapper around FontClient used to get metrics
*
* @param[in] layout The required layout.
*/
- void SetLayout( Layout layout );
+ void SetLayout( Type layout );
/**
* @brief Query the required layout.
*
* @return The required layout.
*/
- Layout GetLayout() const;
-
- /**
- * @brief Enable or disable the text ellipsis.
- *
- * @param[in] enabled Whether to enable the text ellipsis.
- */
- void SetTextEllipsisEnabled( bool enabled );
-
- /**
- * @return Whether the text ellipsis is enabled.
- */
- bool GetTextEllipsisEnabled() const;
-
- /**
- * @brief Choose the required text horizontal alignment.
- *
- * @param[in] alignment The required alignment.
- */
- void SetHorizontalAlignment( HorizontalAlignment alignment );
-
- /**
- * @brief Query the required text horizontal alignment.
- *
- * @return The required alignment.
- */
- HorizontalAlignment GetHorizontalAlignment() const;
-
- /**
- * @brief Choose the required text vertical alignment.
- *
- * @param[in] alignment The required alignment.
- */
- void SetVerticalAlignment( VerticalAlignment alignment );
-
- /**
- * @brief Query the required text vertical alignment.
- *
- * @return The required alignment.
- */
- VerticalAlignment GetVerticalAlignment() const;
+ Type GetLayout() const;
/**
* @brief Sets the width of the cursor.
* @param[out] glyphPositions The positions of all the glyphs.
* @param[out] lines The laid-out lines.
* @param[out] layoutSize The size of the text after it has been laid-out.
+ * @param[in] elideTextEnabled Whether the text elide is enabled.
*
* @return \e true if the text has been re-laid-out. \e false means the given width is too small to layout even a single character.
*/
- bool LayoutText( const LayoutParameters& layoutParameters,
+ bool LayoutText( const Parameters& layoutParameters,
Vector<Vector2>& glyphPositions,
Vector<LineRun>& lines,
- Size& layoutSize );
+ Size& layoutSize,
+ bool elideTextEnabled );
/**
* @brief Re-lays out those lines with right to left characters.
* @param[in] numberOfCharacters The number of characters.
* @param[in,out] glyphPositions The positions of all the glyphs.
*/
- void ReLayoutRightToLeftLines( const LayoutParameters& layoutParameters,
+ void ReLayoutRightToLeftLines( const Parameters& layoutParameters,
CharacterIndex startIndex,
Length numberOfCharacters,
Vector<Vector2>& glyphPositions );
* @param[in] size The size of the container where the text is laid-out.
* @param[in] startIndex Character index of the line from where the lines are aligned.
* @param[in] numberOfCharacters The number of characters.
+ * @param[in] horizontalAlignment The horizontal alignment.
* @param[in,out] lines The laid-out lines.
*/
void Align( const Size& size,
CharacterIndex startIndex,
Length numberOfCharacters,
+ Layout::HorizontalAlignment horizontalAlignment,
Vector<LineRun>& lines );
/**
private:
// Undefined
- LayoutEngine( const LayoutEngine& handle );
+ Engine( const Engine& handle );
// Undefined
- LayoutEngine& operator=( const LayoutEngine& handle );
+ Engine& operator=( const Engine& handle );
private:
struct Impl;
Impl* mImpl;
};
+
+} // namespace Layout
+
} // namespace Text
} // namespace Toolkit
} // namespace Dali
-#endif // __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__
+#endif // DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H
-#ifndef __DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H__
-#define __DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H__
+#ifndef DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H
+#define DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_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.
struct BidirectionalLineInfoRun;
+namespace Layout
+{
+
/**
* @brief Struct used to pass parameters.
*/
-struct LayoutParameters
+struct Parameters
{
/**
* Constructor with the needed parameters to layout the text.
* @param[in] charactersToGlyphsBuffer Vector with indices pointing the first glyph of each character.
* @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.
*/
- LayoutParameters( const Vector2& boundingBox,
- const Character* const textBuffer,
- const LineBreakInfo* const lineBreakInfoBuffer,
- const WordBreakInfo* const wordBreakInfoBuffer,
- const CharacterDirection* const characterDirectionBuffer,
- const GlyphInfo* const glyphsBuffer,
- const CharacterIndex* const glyphsToCharactersBuffer,
- const Length* const charactersPerGlyphBuffer,
- const GlyphIndex* const charactersToGlyphsBuffer,
- const Length* const glyphsPerCharacterBuffer,
- Length totalNumberOfGlyphs )
+ Parameters( const Vector2& boundingBox,
+ const Character* const textBuffer,
+ const LineBreakInfo* const lineBreakInfoBuffer,
+ const WordBreakInfo* const wordBreakInfoBuffer,
+ const CharacterDirection* const characterDirectionBuffer,
+ const GlyphInfo* const glyphsBuffer,
+ const CharacterIndex* const glyphsToCharactersBuffer,
+ const Length* const charactersPerGlyphBuffer,
+ const GlyphIndex* const charactersToGlyphsBuffer,
+ const Length* const glyphsPerCharacterBuffer,
+ Length totalNumberOfGlyphs,
+ HorizontalAlignment horizontalAlignment )
: boundingBox( boundingBox ),
textBuffer( textBuffer ),
lineBreakInfoBuffer( lineBreakInfoBuffer ),
startGlyphIndex( 0u ),
numberOfGlyphs( 0u ),
totalNumberOfGlyphs( totalNumberOfGlyphs ),
+ horizontalAlignment( horizontalAlignment ),
startLineIndex( 0u ),
estimatedNumberOfLines( 0u ),
isLastNewParagraph( false )
GlyphIndex startGlyphIndex; ///< Index to the first glyph to layout.
Length numberOfGlyphs; ///< The number of glyphs to layout.
Length totalNumberOfGlyphs; ///< The number of glyphs.
+ HorizontalAlignment horizontalAlignment; ///< The horizontal alignment.
LineIndex startLineIndex; ///< The line index where to insert the new lines.
Length estimatedNumberOfLines; ///< The estimated number of lines.
bool isLastNewParagraph; ///< Whether the last character is a new paragraph character.
};
+} // namespace Layout
+
} // namespace Text
} // namespace Toolkit
} // namespace Dali
-#endif // __DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H__
+#endif // DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H
--- /dev/null
+/*
+ * 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.
+ * 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/rendering/text-typesetter.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/rendering/view-model.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+TypesetterPtr Typesetter::New( const ModelInterface* const model )
+{
+ return TypesetterPtr( new Typesetter( model ) );
+}
+
+ViewModel* Typesetter::GetViewModel()
+{
+ return mModel;
+}
+
+Typesetter::Typesetter( const ModelInterface* const model )
+: mModel( new ViewModel( model ) )
+{
+}
+
+Typesetter::~Typesetter()
+{
+ delete mModel;
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_TYPESETTER_H
+#define DALI_TOOLKIT_TEXT_TYPESETTER_H
+
+/*
+ * 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.
+ * 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/public-api/object/ref-object.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+class ModelInterface;
+class ViewModel;
+class Typesetter;
+
+typedef IntrusivePtr<Typesetter> TypesetterPtr;
+
+/**
+ * @brief This class is responsible of controlling the data flow of the text's rendering process.
+ */
+class Typesetter : public RefObject
+{
+public: // Constructor.
+ /**
+ * @brief Creates a Typesetter instance.
+ *
+ * The typesetter composes the final text retrieving the glyphs and the
+ * styles from the text's model.
+ *
+ * @param[in] model Pointer to the text's data model.
+ */
+ static TypesetterPtr New( const ModelInterface* const model );
+
+public:
+ /**
+ * @brief Retrieves the pointer to the view model.
+ *
+ * @return A pointer to the view model.
+ */
+ ViewModel* GetViewModel();
+
+private:
+ /**
+ * @brief Private constructor.
+ *
+ * @param[in] model Pointer to the text's data model.
+ */
+ Typesetter( const ModelInterface* const model );
+
+ // Declared private and left undefined to avoid copies.
+ Typesetter( const Typesetter& handle );
+
+ // Declared private and left undefined to avoid copies.
+ Typesetter& operator=( const Typesetter& handle );
+
+protected:
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ *
+ * Destroys the visual model.
+ */
+ virtual ~Typesetter();
+
+private:
+ ViewModel* mModel;
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_TYPESETTER_H
--- /dev/null
+/*
+ * 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.
+ * 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/rendering/view-model.h>
+
+// EXTERNAL INCLUDES
+#include <memory.h>
+#include <dali/devel-api/text-abstraction/font-client.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/line-run.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+ViewModel::ViewModel( const ModelInterface* const model )
+: mModel( model ),
+ mElidedGlyphs(),
+ mElidedLayout(),
+ mIsTextElided( false )
+{
+}
+
+ViewModel::~ViewModel()
+{
+}
+
+const Size& ViewModel::GetControlSize() const
+{
+ return mModel->GetControlSize();
+}
+
+const Size& ViewModel::GetLayoutSize() const
+{
+ return mModel->GetLayoutSize();
+}
+
+const Vector2& ViewModel::GetScrollPosition() const
+{
+ return mModel->GetScrollPosition();
+}
+
+Layout::HorizontalAlignment ViewModel::GetHorizontalAlignment() const
+{
+ return mModel->GetHorizontalAlignment();
+}
+
+Layout::VerticalAlignment ViewModel::GetVerticalAlignment() const
+{
+ return mModel->GetVerticalAlignment();
+}
+
+bool ViewModel::IsTextElideEnabled() const
+{
+ return mModel->IsTextElideEnabled();
+}
+
+Length ViewModel::GetNumberOfLines() const
+{
+ return mModel->GetNumberOfLines();
+}
+
+const LineRun* const ViewModel::GetLines() const
+{
+ return mModel->GetLines();
+}
+
+Length ViewModel::GetNumberOfGlyphs() const
+{
+ if( mIsTextElided && mModel->IsTextElideEnabled() )
+ {
+ return mElidedGlyphs.Count();
+ }
+ else
+ {
+ return mModel->GetNumberOfGlyphs();
+ }
+
+ return 0u;
+}
+
+const GlyphInfo* const ViewModel::GetGlyphs() const
+{
+ if( mIsTextElided && mModel->IsTextElideEnabled() )
+ {
+ return mElidedGlyphs.Begin();
+ }
+ else
+ {
+ return mModel->GetGlyphs();
+ }
+
+ return NULL;
+}
+
+const Vector2* const ViewModel::GetLayout() const
+{
+ if( mIsTextElided && mModel->IsTextElideEnabled() )
+ {
+ return mElidedLayout.Begin();
+ }
+ else
+ {
+ return mModel->GetLayout();
+ }
+
+ return NULL;
+}
+
+const Vector4* const ViewModel::GetColors() const
+{
+ return mModel->GetColors();
+}
+
+const ColorIndex* const ViewModel::GetColorIndices() const
+{
+ return mModel->GetColorIndices();
+}
+
+const Vector4& ViewModel::GetDefaultColor() const
+{
+ return mModel->GetDefaultColor();
+}
+
+void ViewModel::ElideGlyphs()
+{
+ mIsTextElided = false;
+
+ if( mModel->IsTextElideEnabled() )
+ {
+ const Length numberOfLines = mModel->GetNumberOfLines();
+ if( 0u != numberOfLines )
+ {
+ const LineRun* const lines = mModel->GetLines();
+
+ const LineRun& lastLine = *( lines + ( numberOfLines - 1u ) );
+ const Length numberOfLaidOutGlyphs = lastLine.glyphRun.glyphIndex + lastLine.glyphRun.numberOfGlyphs;
+
+ if( lastLine.ellipsis && ( 0u != numberOfLaidOutGlyphs ) )
+ {
+ mIsTextElided = true;
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+
+ const GlyphInfo* const glyphs = mModel->GetGlyphs();
+ const Vector2* const positions = mModel->GetLayout();
+
+ // Copy the glyphs to be elided.
+ mElidedGlyphs.Resize( numberOfLaidOutGlyphs );
+ mElidedLayout.Resize( numberOfLaidOutGlyphs );
+
+ GlyphInfo* elidedGlyphsBuffer = mElidedGlyphs.Begin();
+ Vector2* elidedPositionsBuffer = mElidedLayout.Begin();
+
+ memcpy( elidedGlyphsBuffer, glyphs, numberOfLaidOutGlyphs * sizeof( GlyphInfo ) );
+ memcpy( elidedPositionsBuffer, positions, numberOfLaidOutGlyphs * sizeof( Vector2 ) );
+
+ const Size& controlSize = mModel->GetControlSize();
+
+ if( ( 1u == numberOfLines ) &&
+ ( lastLine.ascender - lastLine.descender > controlSize.height ) )
+ {
+ // Get the first glyph which is going to be replaced and the ellipsis glyph.
+ GlyphInfo& glyphToRemove = *elidedGlyphsBuffer;
+ const GlyphInfo& ellipsisGlyph = fontClient.GetEllipsisGlyph( fontClient.GetPointSize( glyphToRemove.fontId ) );
+
+ // Change the 'x' and 'y' position of the ellipsis glyph.
+ Vector2& position = *elidedPositionsBuffer;
+
+ position.x = ellipsisGlyph.xBearing;
+ position.y = -lastLine.ascender + controlSize.height - ellipsisGlyph.yBearing;
+
+ // Replace the glyph by the ellipsis glyph and resize the buffers.
+ glyphToRemove = ellipsisGlyph;
+
+ mElidedGlyphs.Resize( 1u );
+ mElidedLayout.Resize( 1u );
+
+ return;
+ }
+
+ // firstPenX, penY and firstPenSet are used to position the ellipsis glyph if needed.
+ float firstPenX = 0.f; // Used if rtl text is elided.
+ float penY = 0.f;
+ bool firstPenSet = false;
+
+ // Add the ellipsis glyph.
+ bool inserted = false;
+ float removedGlypsWidth = 0.f;
+ Length numberOfRemovedGlyphs = 0u;
+ GlyphIndex index = numberOfLaidOutGlyphs - 1u;
+
+ // The ellipsis glyph has to fit in the place where the last glyph(s) is(are) removed.
+ while( !inserted )
+ {
+ const GlyphInfo& glyphToRemove = *( elidedGlyphsBuffer + index );
+
+ if( 0u != glyphToRemove.fontId )
+ {
+ // i.e. The font id of the glyph shaped from the '\n' character is zero.
+
+ // Need to reshape the glyph as the font may be different in size.
+ const GlyphInfo& ellipsisGlyph = fontClient.GetEllipsisGlyph( fontClient.GetPointSize( glyphToRemove.fontId ) );
+
+ if( !firstPenSet )
+ {
+ const Vector2& position = *( elidedPositionsBuffer + index );
+
+ // Calculates the penY of the current line. It will be used to position the ellipsis glyph.
+ penY = position.y + glyphToRemove.yBearing;
+
+ // Calculates the first penX which will be used if rtl text is elided.
+ firstPenX = position.x - glyphToRemove.xBearing;
+ if( firstPenX < -ellipsisGlyph.xBearing )
+ {
+ // Avoids to exceed the bounding box when rtl text is elided.
+ firstPenX = -ellipsisGlyph.xBearing;
+ }
+
+ removedGlypsWidth = -ellipsisGlyph.xBearing;
+
+ firstPenSet = true;
+ }
+
+ removedGlypsWidth += std::min( glyphToRemove.advance, ( glyphToRemove.xBearing + glyphToRemove.width ) );
+
+ // Calculate the width of the ellipsis glyph and check if it fits.
+ const float ellipsisGlyphWidth = ellipsisGlyph.width + ellipsisGlyph.xBearing;
+
+ if( ellipsisGlyphWidth < removedGlypsWidth )
+ {
+ GlyphInfo& glyphInfo = *( elidedGlyphsBuffer + index );
+ Vector2& position = *( elidedPositionsBuffer + index );
+ position.x -= ( 0.f > glyphInfo.xBearing ) ? glyphInfo.xBearing : 0.f;
+
+ // Replace the glyph by the ellipsis glyph.
+ glyphInfo = ellipsisGlyph;
+
+ // Change the 'x' and 'y' position of the ellipsis glyph.
+
+ if( position.x > firstPenX )
+ {
+ position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth;
+ }
+
+ position.x += ellipsisGlyph.xBearing;
+ position.y = penY - ellipsisGlyph.yBearing;
+
+ inserted = true;
+ }
+ }
+
+ if( !inserted )
+ {
+ if( index > 0u )
+ {
+ --index;
+ }
+ else
+ {
+ // No space for the ellipsis.
+ inserted = true;
+ }
+ ++numberOfRemovedGlyphs;
+ }
+ } // while( !inserted )
+
+ // 'Removes' all the glyphs after the ellipsis glyph.
+ const Length numberOfGlyphs = numberOfLaidOutGlyphs - numberOfRemovedGlyphs;
+ mElidedGlyphs.Resize( numberOfGlyphs );
+ mElidedLayout.Resize( numberOfGlyphs );
+ }
+ }
+ }
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_VIEW_MODEL_H
+#define DALI_TOOLKIT_TEXT_VIEW_MODEL_H
+
+/*
+ * 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.
+ * 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/dali-vector.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/text-model-interface.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+/**
+ * @brief Responsible of creating and store temporary modifications of the text model.
+ * i.e. The elide of text.
+ */
+class ViewModel : public ModelInterface
+{
+public:
+ /**
+ * @brief Constructor.
+ *
+ * Keeps the pointer to the text's model. It initializes all the members of the class to their defaults.
+ *
+ * @param[in] model Pointer to the text's model interface.
+ */
+ ViewModel( const ModelInterface* const model );
+
+ /**
+ * @brief Virtual destructor.
+ *
+ * It's a default destructor.
+ */
+ virtual ~ViewModel();
+
+ /**
+ * @copydoc ModelInterface::GetControlSize()
+ */
+ virtual const Size& GetControlSize() const;
+
+ /**
+ * @copydoc ModelInterface::GetLayoutSize()
+ */
+ virtual const Size& GetLayoutSize() const;
+
+ /**
+ * @copydoc ModelInterface::GetScrollPosition()
+ */
+ virtual const Vector2& GetScrollPosition() const;
+
+ /**
+ * @copydoc ModelInterface::GetHorizontalAlignment()
+ */
+ virtual Layout::HorizontalAlignment GetHorizontalAlignment() const;
+
+ /**
+ * @copydoc ModelInterface::GetVerticalAlignment()
+ */
+ virtual Layout::VerticalAlignment GetVerticalAlignment() const;
+
+ /**
+ * @copydoc ModelInterface::IsTextElideEnabled()
+ */
+ virtual bool IsTextElideEnabled() const;
+
+ /**
+ * @copydoc ModelInterface::GetNumberOfLines()
+ */
+ virtual Length GetNumberOfLines() const;
+
+ /**
+ * @copydoc ModelInterface::GetLines()
+ */
+ virtual const LineRun* const GetLines() const;
+
+ /**
+ * @copydoc ModelInterface::GetNumberOfGlyphs()
+ */
+ virtual Length GetNumberOfGlyphs() const;
+
+ /**
+ * @copydoc ModelInterface::GetGlyphs()
+ */
+ virtual const GlyphInfo* const GetGlyphs() const;
+
+ /**
+ * @copydoc ModelInterface::GetLayout()
+ */
+ virtual const Vector2* const GetLayout() const;
+
+ /**
+ * @copydoc ModelInterface::GetColors()
+ */
+ virtual const Vector4* const GetColors() const;
+
+ /**
+ * @copydoc ModelInterface::GetColorIndices()
+ */
+ virtual const ColorIndex* const GetColorIndices() const;
+
+ /**
+ * @copydoc ModelInterface::GetDefaultColor()
+ */
+ virtual const Vector4& GetDefaultColor() const;
+
+ /**
+ * @brief Does the text elide.
+ *
+ * It stores a copy of the visible glyphs and removes as many glyphs as needed
+ * from the last visible line to add the ellipsis glyph.
+ *
+ * It stores as well a copy of the positions for each visible glyph.
+ */
+ void ElideGlyphs();
+
+private:
+ const ModelInterface* const mModel; ///< Pointer to the text's model.
+ Vector<GlyphInfo> mElidedGlyphs; ///< Stores the glyphs of the elided text.
+ Vector<Vector2> mElidedLayout; ///< Stores the positions of each glyph of the elided text.
+ bool mIsTextElided : 1; ///< Whether the text has been elided.
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_VIEW_MODEL_H
const CharacterIndex styleIndex = ( mEventData->mPrimaryCursorPosition > 0u ) ? mEventData->mPrimaryCursorPosition - 1u : 0u;
// Retrieve the style from the style runs stored in the logical model.
- mLogicalModel->RetrieveStyle( styleIndex, mEventData->mInputStyle );
+ mModel->mLogicalModel->RetrieveStyle( styleIndex, mEventData->mInputStyle );
// Compare if the input style has changed.
const bool hasInputStyleChanged = !currentInputStyle.Equal( mEventData->mInputStyle );
{
if ( mEventData )
{
- LayoutEngine::Layout layout = mLayoutEngine.GetLayout();
- mEventData->mImfManager.NotifyTextInputMultiLine( layout == LayoutEngine::MULTI_LINE_BOX );
+ Text::Layout::Engine::Type layout = mLayoutEngine.GetLayout();
+ mEventData->mImfManager.NotifyTextInputMultiLine( layout == Text::Layout::Engine::MULTI_LINE_BOX );
}
}
Length numberOfWhiteSpaces = 0u;
// Get the buffer to the text.
- Character* utf32CharacterBuffer = mLogicalModel->mText.Begin();
+ Character* utf32CharacterBuffer = mModel->mLogicalModel->mText.Begin();
- const Length totalNumberOfCharacters = mLogicalModel->mText.Count();
+ const Length totalNumberOfCharacters = mModel->mLogicalModel->mText.Count();
for( ; index < totalNumberOfCharacters; ++index, ++numberOfWhiteSpaces )
{
if( !TextAbstraction::IsWhiteSpace( *( utf32CharacterBuffer + index ) ) )
void Controller::Impl::GetText( CharacterIndex index, std::string& text ) const
{
// Get the total number of characters.
- Length numberOfCharacters = mLogicalModel->mText.Count();
+ Length numberOfCharacters = mModel->mLogicalModel->mText.Count();
// Retrieve the text.
if( 0u != numberOfCharacters )
{
- Utf32ToUtf8( mLogicalModel->mText.Begin() + index, numberOfCharacters - index, text );
+ Utf32ToUtf8( mModel->mLogicalModel->mText.Begin() + index, numberOfCharacters - index, text );
}
}
mTextUpdateInfo.mStartLineIndex = 0u;
numberOfCharacters = 0u;
- const Length numberOfParagraphs = mLogicalModel->mParagraphInfo.Count();
+ const Length numberOfParagraphs = mModel->mLogicalModel->mParagraphInfo.Count();
if( 0u == numberOfParagraphs )
{
mTextUpdateInfo.mParagraphCharacterIndex = 0u;
numberOfCharacters = 0u;
mTextUpdateInfo.mRequestedNumberOfCharacters = mTextUpdateInfo.mNumberOfCharactersToAdd - mTextUpdateInfo.mNumberOfCharactersToRemove;
- mTextUpdateInfo.mStartGlyphIndex = mVisualModel->mGlyphs.Count();
- mTextUpdateInfo.mStartLineIndex = mVisualModel->mLines.Count() - 1u;
+ mTextUpdateInfo.mStartGlyphIndex = mModel->mVisualModel->mGlyphs.Count();
+ mTextUpdateInfo.mStartLineIndex = mModel->mVisualModel->mLines.Count() - 1u;
// Nothing else to do;
return;
{
numberOfCharactersToUpdate = ( mTextUpdateInfo.mNumberOfCharactersToRemove > 0u ) ? mTextUpdateInfo.mNumberOfCharactersToRemove : 1u;
}
- mLogicalModel->FindParagraphs( mTextUpdateInfo.mCharacterIndex,
- numberOfCharactersToUpdate,
- paragraphsToBeUpdated );
+ mModel->mLogicalModel->FindParagraphs( mTextUpdateInfo.mCharacterIndex,
+ numberOfCharactersToUpdate,
+ paragraphsToBeUpdated );
}
if( 0u != paragraphsToBeUpdated.Count() )
{
const ParagraphRunIndex firstParagraphIndex = *( paragraphsToBeUpdated.Begin() );
- const ParagraphRun& firstParagraph = *( mLogicalModel->mParagraphInfo.Begin() + firstParagraphIndex );
+ const ParagraphRun& firstParagraph = *( mModel->mLogicalModel->mParagraphInfo.Begin() + firstParagraphIndex );
mTextUpdateInfo.mParagraphCharacterIndex = firstParagraph.characterRun.characterIndex;
ParagraphRunIndex lastParagraphIndex = *( paragraphsToBeUpdated.End() - 1u );
- const ParagraphRun& lastParagraph = *( mLogicalModel->mParagraphInfo.Begin() + lastParagraphIndex );
+ const ParagraphRun& lastParagraph = *( mModel->mLogicalModel->mParagraphInfo.Begin() + lastParagraphIndex );
if( ( mTextUpdateInfo.mNumberOfCharactersToRemove > 0u ) && // Some character are removed.
( lastParagraphIndex < numberOfParagraphs - 1u ) && // There is a next paragraph.
( mTextUpdateInfo.mCharacterIndex + mTextUpdateInfo.mNumberOfCharactersToRemove ) ) )
{
// The new paragraph character of the last updated paragraph has been removed so is going to be merged with the next one.
- const ParagraphRun& lastParagraph = *( mLogicalModel->mParagraphInfo.Begin() + lastParagraphIndex + 1u );
+ const ParagraphRun& lastParagraph = *( mModel->mLogicalModel->mParagraphInfo.Begin() + lastParagraphIndex + 1u );
numberOfCharacters = lastParagraph.characterRun.characterIndex + lastParagraph.characterRun.numberOfCharacters - mTextUpdateInfo.mParagraphCharacterIndex;
}
}
mTextUpdateInfo.mRequestedNumberOfCharacters = numberOfCharacters + mTextUpdateInfo.mNumberOfCharactersToAdd - mTextUpdateInfo.mNumberOfCharactersToRemove;
- mTextUpdateInfo.mStartGlyphIndex = *( mVisualModel->mCharactersToGlyph.Begin() + mTextUpdateInfo.mParagraphCharacterIndex );
+ mTextUpdateInfo.mStartGlyphIndex = *( mModel->mVisualModel->mCharactersToGlyph.Begin() + mTextUpdateInfo.mParagraphCharacterIndex );
}
void Controller::Impl::ClearFullModelData( OperationsMask operations )
{
if( NO_OPERATION != ( GET_LINE_BREAKS & operations ) )
{
- mLogicalModel->mLineBreakInfo.Clear();
- mLogicalModel->mParagraphInfo.Clear();
+ mModel->mLogicalModel->mLineBreakInfo.Clear();
+ mModel->mLogicalModel->mParagraphInfo.Clear();
}
if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) )
{
- mLogicalModel->mLineBreakInfo.Clear();
+ mModel->mLogicalModel->mLineBreakInfo.Clear();
}
if( NO_OPERATION != ( GET_SCRIPTS & operations ) )
{
- mLogicalModel->mScriptRuns.Clear();
+ mModel->mLogicalModel->mScriptRuns.Clear();
}
if( NO_OPERATION != ( VALIDATE_FONTS & operations ) )
{
- mLogicalModel->mFontRuns.Clear();
+ mModel->mLogicalModel->mFontRuns.Clear();
}
- if( 0u != mLogicalModel->mBidirectionalParagraphInfo.Count() )
+ if( 0u != mModel->mLogicalModel->mBidirectionalParagraphInfo.Count() )
{
if( NO_OPERATION != ( BIDI_INFO & operations ) )
{
- mLogicalModel->mBidirectionalParagraphInfo.Clear();
- mLogicalModel->mCharacterDirections.Clear();
+ mModel->mLogicalModel->mBidirectionalParagraphInfo.Clear();
+ mModel->mLogicalModel->mCharacterDirections.Clear();
}
if( NO_OPERATION != ( REORDER & operations ) )
{
// Free the allocated memory used to store the conversion table in the bidirectional line info run.
- for( Vector<BidirectionalLineInfoRun>::Iterator it = mLogicalModel->mBidirectionalLineInfo.Begin(),
- endIt = mLogicalModel->mBidirectionalLineInfo.End();
+ for( Vector<BidirectionalLineInfoRun>::Iterator it = mModel->mLogicalModel->mBidirectionalLineInfo.Begin(),
+ endIt = mModel->mLogicalModel->mBidirectionalLineInfo.End();
it != endIt;
++it )
{
free( bidiLineInfo.visualToLogicalMap );
bidiLineInfo.visualToLogicalMap = NULL;
}
- mLogicalModel->mBidirectionalLineInfo.Clear();
+ mModel->mLogicalModel->mBidirectionalLineInfo.Clear();
}
}
if( NO_OPERATION != ( SHAPE_TEXT & operations ) )
{
- mVisualModel->mGlyphs.Clear();
- mVisualModel->mGlyphsToCharacters.Clear();
- mVisualModel->mCharactersToGlyph.Clear();
- mVisualModel->mCharactersPerGlyph.Clear();
- mVisualModel->mGlyphsPerCharacter.Clear();
- mVisualModel->mGlyphPositions.Clear();
+ mModel->mVisualModel->mGlyphs.Clear();
+ mModel->mVisualModel->mGlyphsToCharacters.Clear();
+ mModel->mVisualModel->mCharactersToGlyph.Clear();
+ mModel->mVisualModel->mCharactersPerGlyph.Clear();
+ mModel->mVisualModel->mGlyphsPerCharacter.Clear();
+ mModel->mVisualModel->mGlyphPositions.Clear();
}
if( NO_OPERATION != ( LAYOUT & operations ) )
{
- mVisualModel->mLines.Clear();
+ mModel->mVisualModel->mLines.Clear();
}
if( NO_OPERATION != ( COLOR & operations ) )
{
- mVisualModel->mColorIndices.Clear();
+ mModel->mVisualModel->mColorIndices.Clear();
}
}
if( NO_OPERATION != ( GET_LINE_BREAKS & operations ) )
{
// Clear the line break info.
- LineBreakInfo* lineBreakInfoBuffer = mLogicalModel->mLineBreakInfo.Begin();
+ LineBreakInfo* lineBreakInfoBuffer = mModel->mLogicalModel->mLineBreakInfo.Begin();
- mLogicalModel->mLineBreakInfo.Erase( lineBreakInfoBuffer + startIndex,
- lineBreakInfoBuffer + endIndexPlusOne );
+ mModel->mLogicalModel->mLineBreakInfo.Erase( lineBreakInfoBuffer + startIndex,
+ lineBreakInfoBuffer + endIndexPlusOne );
// Clear the paragraphs.
ClearCharacterRuns( startIndex,
endIndex,
- mLogicalModel->mParagraphInfo );
+ mModel->mLogicalModel->mParagraphInfo );
}
if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) )
{
// Clear the word break info.
- WordBreakInfo* wordBreakInfoBuffer = mLogicalModel->mWordBreakInfo.Begin();
+ WordBreakInfo* wordBreakInfoBuffer = mModel->mLogicalModel->mWordBreakInfo.Begin();
- mLogicalModel->mWordBreakInfo.Erase( wordBreakInfoBuffer + startIndex,
+ mModel->mLogicalModel->mWordBreakInfo.Erase( wordBreakInfoBuffer + startIndex,
wordBreakInfoBuffer + endIndexPlusOne );
}
// Clear the scripts.
ClearCharacterRuns( startIndex,
endIndex,
- mLogicalModel->mScriptRuns );
+ mModel->mLogicalModel->mScriptRuns );
}
if( NO_OPERATION != ( VALIDATE_FONTS & operations ) )
// Clear the fonts.
ClearCharacterRuns( startIndex,
endIndex,
- mLogicalModel->mFontRuns );
+ mModel->mLogicalModel->mFontRuns );
}
- if( 0u != mLogicalModel->mBidirectionalParagraphInfo.Count() )
+ if( 0u != mModel->mLogicalModel->mBidirectionalParagraphInfo.Count() )
{
if( NO_OPERATION != ( BIDI_INFO & operations ) )
{
// Clear the bidirectional paragraph info.
ClearCharacterRuns( startIndex,
endIndex,
- mLogicalModel->mBidirectionalParagraphInfo );
+ mModel->mLogicalModel->mBidirectionalParagraphInfo );
// Clear the character's directions.
- CharacterDirection* characterDirectionsBuffer = mLogicalModel->mCharacterDirections.Begin();
+ CharacterDirection* characterDirectionsBuffer = mModel->mLogicalModel->mCharacterDirections.Begin();
- mLogicalModel->mCharacterDirections.Erase( characterDirectionsBuffer + startIndex,
- characterDirectionsBuffer + endIndexPlusOne );
+ mModel->mLogicalModel->mCharacterDirections.Erase( characterDirectionsBuffer + startIndex,
+ characterDirectionsBuffer + endIndexPlusOne );
}
if( NO_OPERATION != ( REORDER & operations ) )
{
- uint32_t startRemoveIndex = mLogicalModel->mBidirectionalLineInfo.Count();
+ uint32_t startRemoveIndex = mModel->mLogicalModel->mBidirectionalLineInfo.Count();
uint32_t endRemoveIndex = startRemoveIndex;
ClearCharacterRuns( startIndex,
endIndex,
- mLogicalModel->mBidirectionalLineInfo,
+ mModel->mLogicalModel->mBidirectionalLineInfo,
startRemoveIndex,
endRemoveIndex );
- BidirectionalLineInfoRun* bidirectionalLineInfoBuffer = mLogicalModel->mBidirectionalLineInfo.Begin();
+ BidirectionalLineInfoRun* bidirectionalLineInfoBuffer = mModel->mLogicalModel->mBidirectionalLineInfo.Begin();
// Free the allocated memory used to store the conversion table in the bidirectional line info run.
for( Vector<BidirectionalLineInfoRun>::Iterator it = bidirectionalLineInfoBuffer + startRemoveIndex,
bidiLineInfo.visualToLogicalMap = NULL;
}
- mLogicalModel->mBidirectionalLineInfo.Erase( bidirectionalLineInfoBuffer + startRemoveIndex,
- bidirectionalLineInfoBuffer + endRemoveIndex );
+ mModel->mLogicalModel->mBidirectionalLineInfo.Erase( bidirectionalLineInfoBuffer + startRemoveIndex,
+ bidirectionalLineInfoBuffer + endRemoveIndex );
}
}
}
const Length numberOfCharactersRemoved = endIndexPlusOne - startIndex;
// Convert the character index to glyph index before deleting the character to glyph and the glyphs per character buffers.
- GlyphIndex* charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin();
- Length* glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin();
+ GlyphIndex* charactersToGlyphBuffer = mModel->mVisualModel->mCharactersToGlyph.Begin();
+ Length* glyphsPerCharacterBuffer = mModel->mVisualModel->mGlyphsPerCharacter.Begin();
const GlyphIndex endGlyphIndexPlusOne = *( charactersToGlyphBuffer + endIndex ) + *( glyphsPerCharacterBuffer + endIndex );
const Length numberOfGlyphsRemoved = endGlyphIndexPlusOne - mTextUpdateInfo.mStartGlyphIndex;
{
// Update the character to glyph indices.
for( Vector<GlyphIndex>::Iterator it = charactersToGlyphBuffer + endIndexPlusOne,
- endIt = charactersToGlyphBuffer + mVisualModel->mCharactersToGlyph.Count();
+ endIt = charactersToGlyphBuffer + mModel->mVisualModel->mCharactersToGlyph.Count();
it != endIt;
++it )
{
}
// Clear the character to glyph conversion table.
- mVisualModel->mCharactersToGlyph.Erase( charactersToGlyphBuffer + startIndex,
- charactersToGlyphBuffer + endIndexPlusOne );
+ mModel->mVisualModel->mCharactersToGlyph.Erase( charactersToGlyphBuffer + startIndex,
+ charactersToGlyphBuffer + endIndexPlusOne );
// Clear the glyphs per character table.
- mVisualModel->mGlyphsPerCharacter.Erase( glyphsPerCharacterBuffer + startIndex,
- glyphsPerCharacterBuffer + endIndexPlusOne );
+ mModel->mVisualModel->mGlyphsPerCharacter.Erase( glyphsPerCharacterBuffer + startIndex,
+ glyphsPerCharacterBuffer + endIndexPlusOne );
// Clear the glyphs buffer.
- GlyphInfo* glyphsBuffer = mVisualModel->mGlyphs.Begin();
- mVisualModel->mGlyphs.Erase( glyphsBuffer + mTextUpdateInfo.mStartGlyphIndex,
- glyphsBuffer + endGlyphIndexPlusOne );
+ GlyphInfo* glyphsBuffer = mModel->mVisualModel->mGlyphs.Begin();
+ mModel->mVisualModel->mGlyphs.Erase( glyphsBuffer + mTextUpdateInfo.mStartGlyphIndex,
+ glyphsBuffer + endGlyphIndexPlusOne );
- CharacterIndex* glyphsToCharactersBuffer = mVisualModel->mGlyphsToCharacters.Begin();
+ CharacterIndex* glyphsToCharactersBuffer = mModel->mVisualModel->mGlyphsToCharacters.Begin();
// Update the glyph to character indices.
for( Vector<CharacterIndex>::Iterator it = glyphsToCharactersBuffer + endGlyphIndexPlusOne,
- endIt = glyphsToCharactersBuffer + mVisualModel->mGlyphsToCharacters.Count();
+ endIt = glyphsToCharactersBuffer + mModel->mVisualModel->mGlyphsToCharacters.Count();
it != endIt;
++it )
{
}
// Clear the glyphs to characters buffer.
- mVisualModel->mGlyphsToCharacters.Erase( glyphsToCharactersBuffer + mTextUpdateInfo.mStartGlyphIndex,
- glyphsToCharactersBuffer + endGlyphIndexPlusOne );
+ mModel->mVisualModel->mGlyphsToCharacters.Erase( glyphsToCharactersBuffer + mTextUpdateInfo.mStartGlyphIndex,
+ glyphsToCharactersBuffer + endGlyphIndexPlusOne );
// Clear the characters per glyph buffer.
- Length* charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin();
- mVisualModel->mCharactersPerGlyph.Erase( charactersPerGlyphBuffer + mTextUpdateInfo.mStartGlyphIndex,
- charactersPerGlyphBuffer + endGlyphIndexPlusOne );
+ Length* charactersPerGlyphBuffer = mModel->mVisualModel->mCharactersPerGlyph.Begin();
+ mModel->mVisualModel->mCharactersPerGlyph.Erase( charactersPerGlyphBuffer + mTextUpdateInfo.mStartGlyphIndex,
+ charactersPerGlyphBuffer + endGlyphIndexPlusOne );
// Clear the positions buffer.
- Vector2* positionsBuffer = mVisualModel->mGlyphPositions.Begin();
- mVisualModel->mGlyphPositions.Erase( positionsBuffer + mTextUpdateInfo.mStartGlyphIndex,
- positionsBuffer + endGlyphIndexPlusOne );
+ Vector2* positionsBuffer = mModel->mVisualModel->mGlyphPositions.Begin();
+ mModel->mVisualModel->mGlyphPositions.Erase( positionsBuffer + mTextUpdateInfo.mStartGlyphIndex,
+ positionsBuffer + endGlyphIndexPlusOne );
}
if( NO_OPERATION != ( LAYOUT & operations ) )
{
// Clear the lines.
- uint32_t startRemoveIndex = mVisualModel->mLines.Count();
+ uint32_t startRemoveIndex = mModel->mVisualModel->mLines.Count();
uint32_t endRemoveIndex = startRemoveIndex;
ClearCharacterRuns( startIndex,
endIndex,
- mVisualModel->mLines,
+ mModel->mVisualModel->mLines,
startRemoveIndex,
endRemoveIndex );
// Will update the glyph runs.
- startRemoveIndex = mVisualModel->mLines.Count();
+ startRemoveIndex = mModel->mVisualModel->mLines.Count();
endRemoveIndex = startRemoveIndex;
ClearGlyphRuns( mTextUpdateInfo.mStartGlyphIndex,
endGlyphIndexPlusOne - 1u,
- mVisualModel->mLines,
+ mModel->mVisualModel->mLines,
startRemoveIndex,
endRemoveIndex );
// Set the line index from where to insert the new laid-out lines.
mTextUpdateInfo.mStartLineIndex = startRemoveIndex;
- LineRun* linesBuffer = mVisualModel->mLines.Begin();
- mVisualModel->mLines.Erase( linesBuffer + startRemoveIndex,
- linesBuffer + endRemoveIndex );
+ LineRun* linesBuffer = mModel->mVisualModel->mLines.Begin();
+ mModel->mVisualModel->mLines.Erase( linesBuffer + startRemoveIndex,
+ linesBuffer + endRemoveIndex );
}
if( NO_OPERATION != ( COLOR & operations ) )
{
- if( 0u != mVisualModel->mColorIndices.Count() )
+ if( 0u != mModel->mVisualModel->mColorIndices.Count() )
{
- ColorIndex* colorIndexBuffer = mVisualModel->mColorIndices.Begin();
- mVisualModel->mColorIndices.Erase( colorIndexBuffer + mTextUpdateInfo.mStartGlyphIndex,
- colorIndexBuffer + endGlyphIndexPlusOne );
+ ColorIndex* colorIndexBuffer = mModel->mVisualModel->mColorIndices.Begin();
+ mModel->mVisualModel->mColorIndices.Erase( colorIndexBuffer + mTextUpdateInfo.mStartGlyphIndex,
+ colorIndexBuffer + endGlyphIndexPlusOne );
}
}
}
}
// The estimated number of lines. Used to avoid reallocations when layouting.
- mTextUpdateInfo.mEstimatedNumberOfLines = std::max( mVisualModel->mLines.Count(), mLogicalModel->mParagraphInfo.Count() );
+ mTextUpdateInfo.mEstimatedNumberOfLines = std::max( mModel->mVisualModel->mLines.Count(), mModel->mLogicalModel->mParagraphInfo.Count() );
- mVisualModel->ClearCaches();
+ mModel->mVisualModel->ClearCaches();
}
bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
return false;
}
- Vector<Character>& utf32Characters = mLogicalModel->mText;
+ Vector<Character>& utf32Characters = mModel->mLogicalModel->mText;
const Length numberOfCharacters = utf32Characters.Count();
// Whether the model is updated.
bool updated = false;
- Vector<LineBreakInfo>& lineBreakInfo = mLogicalModel->mLineBreakInfo;
+ Vector<LineBreakInfo>& lineBreakInfo = mModel->mLogicalModel->mLineBreakInfo;
const Length requestedNumberOfCharacters = mTextUpdateInfo.mRequestedNumberOfCharacters;
if( NO_OPERATION != ( GET_LINE_BREAKS & operations ) )
lineBreakInfo );
// Create the paragraph info.
- mLogicalModel->CreateParagraphInfo( startIndex,
- requestedNumberOfCharacters );
+ mModel->mLogicalModel->CreateParagraphInfo( startIndex,
+ requestedNumberOfCharacters );
updated = true;
}
- Vector<WordBreakInfo>& wordBreakInfo = mLogicalModel->mWordBreakInfo;
+ Vector<WordBreakInfo>& wordBreakInfo = mModel->mLogicalModel->mWordBreakInfo;
if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) )
{
// Retrieves the word break info. The word break info is used to layout the text (where to wrap the text in lines).
const bool getScripts = NO_OPERATION != ( GET_SCRIPTS & operations );
const bool validateFonts = NO_OPERATION != ( VALIDATE_FONTS & operations );
- Vector<ScriptRun>& scripts = mLogicalModel->mScriptRuns;
- Vector<FontRun>& validFonts = mLogicalModel->mFontRuns;
+ Vector<ScriptRun>& scripts = mModel->mLogicalModel->mScriptRuns;
+ Vector<FontRun>& validFonts = mModel->mLogicalModel->mFontRuns;
if( getScripts || validateFonts )
{
if( validateFonts )
{
// Validate the fonts set through the mark-up string.
- Vector<FontDescriptionRun>& fontDescriptionRuns = mLogicalModel->mFontDescriptionRuns;
+ Vector<FontDescriptionRun>& fontDescriptionRuns = mModel->mLogicalModel->mFontDescriptionRuns;
// Get the default font's description.
TextAbstraction::FontDescription defaultFontDescription;
Vector<Character> mirroredUtf32Characters;
bool textMirrored = false;
- const Length numberOfParagraphs = mLogicalModel->mParagraphInfo.Count();
+ const Length numberOfParagraphs = mModel->mLogicalModel->mParagraphInfo.Count();
if( NO_OPERATION != ( BIDI_INFO & operations ) )
{
- Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mLogicalModel->mBidirectionalParagraphInfo;
+ Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mModel->mLogicalModel->mBidirectionalParagraphInfo;
bidirectionalInfo.Reserve( numberOfParagraphs );
// Calculates the bidirectional info for the whole paragraph if it contains right to left scripts.
if( 0u != bidirectionalInfo.Count() )
{
// Only set the character directions if there is right to left characters.
- Vector<CharacterDirection>& directions = mLogicalModel->mCharacterDirections;
+ Vector<CharacterDirection>& directions = mModel->mLogicalModel->mCharacterDirections;
GetCharactersDirection( bidirectionalInfo,
numberOfCharacters,
startIndex,
else
{
// There is no right to left characters. Clear the directions vector.
- mLogicalModel->mCharacterDirections.Clear();
+ mModel->mLogicalModel->mCharacterDirections.Clear();
}
updated = true;
}
- Vector<GlyphInfo>& glyphs = mVisualModel->mGlyphs;
- Vector<CharacterIndex>& glyphsToCharactersMap = mVisualModel->mGlyphsToCharacters;
- Vector<Length>& charactersPerGlyph = mVisualModel->mCharactersPerGlyph;
+ Vector<GlyphInfo>& glyphs = mModel->mVisualModel->mGlyphs;
+ Vector<CharacterIndex>& glyphsToCharactersMap = mModel->mVisualModel->mGlyphsToCharacters;
+ Vector<Length>& charactersPerGlyph = mModel->mVisualModel->mCharactersPerGlyph;
Vector<GlyphIndex> newParagraphGlyphs;
newParagraphGlyphs.Reserve( numberOfParagraphs );
newParagraphGlyphs );
// Create the 'number of glyphs' per character and the glyph to character conversion tables.
- mVisualModel->CreateGlyphsPerCharacterTable( startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters );
- mVisualModel->CreateCharacterToGlyphTable( startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters );
+ mModel->mVisualModel->CreateGlyphsPerCharacterTable( startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters );
+ mModel->mVisualModel->CreateCharacterToGlyphTable( startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters );
updated = true;
}
if( NO_OPERATION != ( COLOR & operations ) )
{
// Set the color runs in glyphs.
- SetColorSegmentationInfo( mLogicalModel->mColorRuns,
- mVisualModel->mCharactersToGlyph,
- mVisualModel->mGlyphsPerCharacter,
+ SetColorSegmentationInfo( mModel->mLogicalModel->mColorRuns,
+ mModel->mVisualModel->mCharactersToGlyph,
+ mModel->mVisualModel->mGlyphsPerCharacter,
startIndex,
mTextUpdateInfo.mStartGlyphIndex,
requestedNumberOfCharacters,
- mVisualModel->mColors,
- mVisualModel->mColorIndices );
+ mModel->mVisualModel->mColors,
+ mModel->mVisualModel->mColorIndices );
updated = true;
}
if( ( NULL != mEventData ) &&
mEventData->mPreEditFlag &&
- ( 0u != mVisualModel->mCharactersToGlyph.Count() ) )
+ ( 0u != mModel->mVisualModel->mCharactersToGlyph.Count() ) )
{
// Add the underline for the pre-edit text.
- const GlyphIndex* const charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin();
- const Length* const glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin();
+ const GlyphIndex* const charactersToGlyphBuffer = mModel->mVisualModel->mCharactersToGlyph.Begin();
+ const Length* const glyphsPerCharacterBuffer = mModel->mVisualModel->mGlyphsPerCharacter.Begin();
const GlyphIndex glyphStart = *( charactersToGlyphBuffer + mEventData->mPreEditStartPosition );
const CharacterIndex lastPreEditCharacter = mEventData->mPreEditStartPosition + ( ( mEventData->mPreEditLength > 0u ) ? mEventData->mPreEditLength - 1u : 0u );
underlineRun.numberOfGlyphs = 1u + glyphEnd - glyphStart;
// TODO: At the moment the underline runs are only for pre-edit.
- mVisualModel->mUnderlineRuns.PushBack( underlineRun );
+ mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun );
}
// The estimated number of lines. Used to avoid reallocations when layouting.
- mTextUpdateInfo.mEstimatedNumberOfLines = std::max( mVisualModel->mLines.Count(), mLogicalModel->mParagraphInfo.Count() );
+ mTextUpdateInfo.mEstimatedNumberOfLines = std::max( mModel->mVisualModel->mLines.Count(), mModel->mLogicalModel->mParagraphInfo.Count() );
// Set the previous number of characters for the next time the text is updated.
mTextUpdateInfo.mPreviousNumberOfCharacters = numberOfCharacters;
}
else if( Dali::DALI_KEY_CURSOR_RIGHT == keyCode )
{
- if( mLogicalModel->mText.Count() > mEventData->mPrimaryCursorPosition )
+ if( mModel->mLogicalModel->mText.Count() > mEventData->mPrimaryCursorPosition )
{
mEventData->mPrimaryCursorPosition = CalculateNewCursorIndex( mEventData->mPrimaryCursorPosition );
}
characterIndex = mEventData->mPrimaryCursorPosition - 1u;
}
- const LineIndex lineIndex = mVisualModel->GetLineOfCharacter( characterIndex );
+ const LineIndex lineIndex = mModel->mVisualModel->GetLineOfCharacter( characterIndex );
if( lineIndex > 0u )
{
cursorInfo );
// Get the line above.
- const LineRun& line = *( mVisualModel->mLines.Begin() + ( lineIndex - 1u ) );
+ const LineRun& line = *( mModel->mVisualModel->mLines.Begin() + ( lineIndex - 1u ) );
// Get the next hit 'y' point.
const float hitPointY = cursorInfo.lineOffset - 0.5f * ( line.ascender - line.descender );
// Use the cursor hook position 'x' and the next hit 'y' position to calculate the new cursor index.
- mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mVisualModel,
- mLogicalModel,
+ mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+ mModel->mLogicalModel,
mMetrics,
mEventData->mCursorHookPositionX,
hitPointY );
characterIndex = mEventData->mPrimaryCursorPosition - 1u;
}
- const LineIndex lineIndex = mVisualModel->GetLineOfCharacter( characterIndex );
+ const LineIndex lineIndex = mModel->mVisualModel->GetLineOfCharacter( characterIndex );
- if( lineIndex + 1u < mVisualModel->mLines.Count() )
+ if( lineIndex + 1u < mModel->mVisualModel->mLines.Count() )
{
// Retrieve the cursor position info.
CursorInfo cursorInfo;
cursorInfo );
// Get the line below.
- const LineRun& line = *( mVisualModel->mLines.Begin() + lineIndex + 1u );
+ const LineRun& line = *( mModel->mVisualModel->mLines.Begin() + lineIndex + 1u );
// Get the next hit 'y' point.
const float hitPointY = cursorInfo.lineOffset + cursorInfo.lineHeight + 0.5f * ( line.ascender - line.descender );
// Use the cursor hook position 'x' and the next hit 'y' position to calculate the new cursor index.
- mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mVisualModel,
- mLogicalModel,
+ mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+ mModel->mLogicalModel,
mMetrics,
mEventData->mCursorHookPositionX,
hitPointY );
if( IsShowingRealText() )
{
// Convert from control's coords to text's coords.
- const float xPosition = event.p2.mFloat - mScrollPosition.x;
- const float yPosition = event.p3.mFloat - mScrollPosition.y;
+ const float xPosition = event.p2.mFloat - mModel->mScrollPosition.x;
+ const float yPosition = event.p3.mFloat - mModel->mScrollPosition.y;
// Keep the tap 'x' position. Used to move the cursor.
mEventData->mCursorHookPositionX = xPosition;
- mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mVisualModel,
- mLogicalModel,
+ mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+ mModel->mLogicalModel,
mMetrics,
xPosition,
yPosition );
}
case Gesture::Continuing:
{
- const Vector2& layoutSize = mVisualModel->GetLayoutSize();
- const Vector2 currentScroll = mScrollPosition;
+ const Vector2& layoutSize = mModel->mVisualModel->GetLayoutSize();
+ const Vector2 currentScroll = mModel->mScrollPosition;
if( isHorizontalScrollEnabled )
{
const float displacementX = event.p2.mFloat;
- mScrollPosition.x += displacementX;
+ mModel->mScrollPosition.x += displacementX;
ClampHorizontalScroll( layoutSize );
}
if( isVerticalScrollEnabled )
{
const float displacementY = event.p3.mFloat;
- mScrollPosition.y += displacementY;
+ mModel->mScrollPosition.y += displacementY;
ClampVerticalScroll( layoutSize );
}
- mEventData->mDecorator->UpdatePositions( mScrollPosition - currentScroll );
+ mEventData->mDecorator->UpdatePositions( mModel->mScrollPosition - currentScroll );
break;
}
case Gesture::Finished:
if( HANDLE_PRESSED == state )
{
// Convert from decorator's coords to text's coords.
- const float xPosition = event.p2.mFloat - mScrollPosition.x;
- const float yPosition = event.p3.mFloat - mScrollPosition.y;
+ const float xPosition = event.p2.mFloat - mModel->mScrollPosition.x;
+ const float yPosition = event.p3.mFloat - mModel->mScrollPosition.y;
// Need to calculate the handle's new position.
- const CharacterIndex handleNewPosition = Text::GetClosestCursorIndex( mVisualModel,
- mLogicalModel,
+ const CharacterIndex handleNewPosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+ mModel->mLogicalModel,
mMetrics,
xPosition,
yPosition );
if( handleStopScrolling || isSmoothHandlePanEnabled )
{
// Convert from decorator's coords to text's coords.
- const float xPosition = event.p2.mFloat - mScrollPosition.x;
- const float yPosition = event.p3.mFloat - mScrollPosition.y;
+ const float xPosition = event.p2.mFloat - mModel->mScrollPosition.x;
+ const float yPosition = event.p3.mFloat - mModel->mScrollPosition.y;
- handlePosition = Text::GetClosestCursorIndex( mVisualModel,
- mLogicalModel,
+ handlePosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+ mModel->mLogicalModel,
mMetrics,
xPosition,
yPosition );
{
const float xSpeed = event.p2.mFloat;
const float ySpeed = event.p3.mFloat;
- const Vector2& layoutSize = mVisualModel->GetLayoutSize();
- const Vector2 currentScrollPosition = mScrollPosition;
+ const Vector2& layoutSize = mModel->mVisualModel->GetLayoutSize();
+ const Vector2 currentScrollPosition = mModel->mScrollPosition;
- mScrollPosition.x += xSpeed;
- mScrollPosition.y += ySpeed;
+ mModel->mScrollPosition.x += xSpeed;
+ mModel->mScrollPosition.y += ySpeed;
ClampHorizontalScroll( layoutSize );
ClampVerticalScroll( layoutSize );
bool endOfScroll = false;
- if( Vector2::ZERO == ( currentScrollPosition - mScrollPosition ) )
+ if( Vector2::ZERO == ( currentScrollPosition - mModel->mScrollPosition ) )
{
// Notify the decorator there is no more text to scroll.
// The decorator won't send more scroll events.
if( mEventData->mDecorator->IsHorizontalScrollEnabled() )
{
// Position the grag handle close to either the left or right edge.
- position.x = scrollRightDirection ? 0.f : mVisualModel->mControlSize.width;
+ position.x = scrollRightDirection ? 0.f : mModel->mVisualModel->mControlSize.width;
}
if( mEventData->mDecorator->IsVerticalScrollEnabled() )
position.x = mEventData->mCursorHookPositionX;
// Position the grag handle close to either the top or bottom edge.
- position.y = scrollBottomDirection ? 0.f : mVisualModel->mControlSize.height;
+ position.y = scrollBottomDirection ? 0.f : mModel->mVisualModel->mControlSize.height;
}
// Get the new handle position.
// The grab handle's position is in decorator's coords. Need to transforms to text's coords.
- const CharacterIndex handlePosition = Text::GetClosestCursorIndex( mVisualModel,
- mLogicalModel,
+ const CharacterIndex handlePosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+ mModel->mLogicalModel,
mMetrics,
- position.x - mScrollPosition.x,
- position.y - mScrollPosition.y );
+ position.x - mModel->mScrollPosition.x,
+ position.y - mModel->mScrollPosition.y );
if( mEventData->mPrimaryCursorPosition != handlePosition )
{
if( mEventData->mDecorator->IsHorizontalScrollEnabled() )
{
// Position the selection handle close to either the left or right edge.
- position.x = scrollRightDirection ? 0.f : mVisualModel->mControlSize.width;
+ position.x = scrollRightDirection ? 0.f : mModel->mVisualModel->mControlSize.width;
}
if( mEventData->mDecorator->IsVerticalScrollEnabled() )
position.x = mEventData->mCursorHookPositionX;
// Position the grag handle close to either the top or bottom edge.
- position.y = scrollBottomDirection ? 0.f : mVisualModel->mControlSize.height;
+ position.y = scrollBottomDirection ? 0.f : mModel->mVisualModel->mControlSize.height;
}
// Get the new handle position.
// The selection handle's position is in decorator's coords. Need to transform to text's coords.
- const CharacterIndex handlePosition = Text::GetClosestCursorIndex( mVisualModel,
- mLogicalModel,
+ const CharacterIndex handlePosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+ mModel->mLogicalModel,
mMetrics,
- position.x - mScrollPosition.x,
- position.y - mScrollPosition.y );
+ position.x - mModel->mScrollPosition.x,
+ position.y - mModel->mScrollPosition.y );
if( leftSelectionHandleEvent )
{
if( mEventData->mSelectionEnabled )
{
// Convert from control's coords to text's coords.
- const float xPosition = event.p2.mFloat - mScrollPosition.x;
- const float yPosition = event.p3.mFloat - mScrollPosition.y;
+ const float xPosition = event.p2.mFloat - mModel->mScrollPosition.x;
+ const float yPosition = event.p3.mFloat - mModel->mScrollPosition.y;
// Calculates the logical position from the x,y coords.
RepositionSelectionHandles( xPosition,
ChangeState( EventData::SELECTING );
mEventData->mLeftSelectionPosition = 0u;
- mEventData->mRightSelectionPosition = mLogicalModel->mText.Count();
+ mEventData->mRightSelectionPosition = mModel->mLogicalModel->mText.Count();
mEventData->mScrollAfterUpdatePosition = true;
mEventData->mUpdateLeftSelectionPosition = true;
const CharacterIndex startOfSelectedText = handlesCrossed ? mEventData->mRightSelectionPosition : mEventData->mLeftSelectionPosition;
const Length lengthOfSelectedText = ( handlesCrossed ? mEventData->mLeftSelectionPosition : mEventData->mRightSelectionPosition ) - startOfSelectedText;
- Vector<Character>& utf32Characters = mLogicalModel->mText;
+ Vector<Character>& utf32Characters = mModel->mLogicalModel->mText;
const Length numberOfCharacters = utf32Characters.Count();
// Validate the start and end selection points
currentInputStyle.Copy( mEventData->mInputStyle );
// Set as input style the style of the first deleted character.
- mLogicalModel->RetrieveStyle( startOfSelectedText, mEventData->mInputStyle );
+ mModel->mLogicalModel->RetrieveStyle( startOfSelectedText, mEventData->mInputStyle );
// Compare if the input style has changed.
const bool hasInputStyleChanged = !currentInputStyle.Equal( mEventData->mInputStyle );
mEventData->mInputStyleChangedQueue.PushBack( styleChangedMask );
}
- mLogicalModel->UpdateTextStyleRuns( startOfSelectedText, -static_cast<int>( lengthOfSelectedText ) );
+ mModel->mLogicalModel->UpdateTextStyleRuns( startOfSelectedText, -static_cast<int>( lengthOfSelectedText ) );
// Mark the paragraphs to be updated.
mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
mEventData->mDecorator->ClearHighlights();
- const GlyphIndex* const charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin();
- const Length* const glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin();
- const GlyphInfo* const glyphsBuffer = mVisualModel->mGlyphs.Begin();
- const Vector2* const positionsBuffer = mVisualModel->mGlyphPositions.Begin();
- const Length* const charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin();
- const CharacterIndex* const glyphToCharacterBuffer = mVisualModel->mGlyphsToCharacters.Begin();
- const CharacterDirection* const modelCharacterDirectionsBuffer = ( 0u != mLogicalModel->mCharacterDirections.Count() ) ? mLogicalModel->mCharacterDirections.Begin() : NULL;
+ const GlyphIndex* const charactersToGlyphBuffer = mModel->mVisualModel->mCharactersToGlyph.Begin();
+ const Length* const glyphsPerCharacterBuffer = mModel->mVisualModel->mGlyphsPerCharacter.Begin();
+ const GlyphInfo* const glyphsBuffer = mModel->mVisualModel->mGlyphs.Begin();
+ const Vector2* const positionsBuffer = mModel->mVisualModel->mGlyphPositions.Begin();
+ const Length* const charactersPerGlyphBuffer = mModel->mVisualModel->mCharactersPerGlyph.Begin();
+ const CharacterIndex* const glyphToCharacterBuffer = mModel->mVisualModel->mGlyphsToCharacters.Begin();
+ const CharacterDirection* const modelCharacterDirectionsBuffer = ( 0u != mModel->mLogicalModel->mCharacterDirections.Count() ) ? mModel->mLogicalModel->mCharacterDirections.Begin() : NULL;
- const bool isLastCharacter = selectionEnd >= mLogicalModel->mText.Count();
+ const bool isLastCharacter = selectionEnd >= mModel->mLogicalModel->mText.Count();
const CharacterDirection startDirection = ( ( NULL == modelCharacterDirectionsBuffer ) ? false : *( modelCharacterDirectionsBuffer + selectionStart ) );
const CharacterDirection endDirection = ( ( NULL == modelCharacterDirectionsBuffer ) ? false : *( modelCharacterDirectionsBuffer + ( selectionEnd - ( isLastCharacter ? 1u : 0u ) ) ) );
const GlyphIndex glyphEnd = *( charactersToGlyphBuffer + selectionEndMinusOne ) + ( ( numberOfGlyphs > 0 ) ? numberOfGlyphs - 1u : 0u );
// Get the lines where the glyphs are laid-out.
- const LineRun* lineRun = mVisualModel->mLines.Begin();
+ const LineRun* lineRun = mModel->mVisualModel->mLines.Begin();
LineIndex lineIndex = 0u;
Length numberOfLines = 0u;
- mVisualModel->GetNumberOfLines( glyphStart,
- 1u + glyphEnd - glyphStart,
- lineIndex,
- numberOfLines );
+ mModel->mVisualModel->GetNumberOfLines( glyphStart,
+ 1u + glyphEnd - glyphStart,
+ lineIndex,
+ numberOfLines );
const LineIndex firstLineIndex = lineIndex;
// Create the structure to store some selection box info.
// Retrieve the first line and get the line's vertical offset, the line's height and the index to the last glyph.
// The line's vertical offset of all the lines before the line where the first glyph is laid-out.
- selectionBoxInfo->lineOffset = CalculateLineOffset( mVisualModel->mLines,
+ selectionBoxInfo->lineOffset = CalculateLineOffset( mModel->mVisualModel->mLines,
firstLineIndex );
// Transform to decorator's (control) coords.
- selectionBoxInfo->lineOffset += mScrollPosition.y;
+ selectionBoxInfo->lineOffset += mModel->mScrollPosition.y;
lineRun += firstLineIndex;
// Check if the first glyph is a ligature that must be broken like Latin ff, fi, or Arabic ﻻ, etc which needs special code.
const Length numberOfCharactersStart = *( charactersPerGlyphBuffer + glyphStart );
- bool splitStartGlyph = ( numberOfCharactersStart > 1u ) && HasLigatureMustBreak( mLogicalModel->GetScript( selectionStart ) );
+ bool splitStartGlyph = ( numberOfCharactersStart > 1u ) && HasLigatureMustBreak( mModel->mLogicalModel->GetScript( selectionStart ) );
// Check if the last glyph is a ligature that must be broken like Latin ff, fi, or Arabic ﻻ, etc which needs special code.
const Length numberOfCharactersEnd = *( charactersPerGlyphBuffer + glyphEnd );
- bool splitEndGlyph = ( glyphStart != glyphEnd ) && ( numberOfCharactersEnd > 1u ) && HasLigatureMustBreak( mLogicalModel->GetScript( selectionEndMinusOne ) );
+ bool splitEndGlyph = ( glyphStart != glyphEnd ) && ( numberOfCharactersEnd > 1u ) && HasLigatureMustBreak( mModel->mLogicalModel->GetScript( selectionEndMinusOne ) );
// The number of quads of the selection box.
const unsigned int numberOfQuads = 1u + ( glyphEnd - glyphStart ) + ( ( numberOfLines > 1u ) ? 2u * numberOfLines : 0u );
// Calculate the number of characters selected.
const Length numberOfCharacters = ( glyphStart == glyphEnd ) ? ( selectionEnd - selectionStart ) : ( numberOfCharactersStart - interGlyphIndex );
- quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x + glyphAdvance * static_cast<float>( isCurrentRightToLeft ? ( numberOfCharactersStart - interGlyphIndex - numberOfCharacters ) : interGlyphIndex );
+ quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mModel->mScrollPosition.x + glyphAdvance * static_cast<float>( isCurrentRightToLeft ? ( numberOfCharactersStart - interGlyphIndex - numberOfCharacters ) : interGlyphIndex );
quad.y = selectionBoxInfo->lineOffset;
quad.z = quad.x + static_cast<float>( numberOfCharacters ) * glyphAdvance;
quad.w = selectionBoxInfo->lineOffset + selectionBoxInfo->lineHeight;
const Length numberOfCharacters = numberOfCharactersEnd - interGlyphIndex;
- quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x + ( isCurrentRightToLeft ? ( glyphAdvance * static_cast<float>( numberOfCharacters ) ) : 0.f );
+ quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mModel->mScrollPosition.x + ( isCurrentRightToLeft ? ( glyphAdvance * static_cast<float>( numberOfCharacters ) ) : 0.f );
quad.y = selectionBoxInfo->lineOffset;
quad.z = quad.x + static_cast<float>( interGlyphIndex ) * glyphAdvance;
quad.w = quad.y + selectionBoxInfo->lineHeight;
continue;
}
- quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x;
+ quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mModel->mScrollPosition.x;
quad.y = selectionBoxInfo->lineOffset;
quad.z = quad.x + glyph.advance;
quad.w = quad.y + selectionBoxInfo->lineHeight;
if( 1u < numberOfLines )
{
// Boxify the first line.
- lineRun = mVisualModel->mLines.Begin() + firstLineIndex;
+ lineRun = mModel->mVisualModel->mLines.Begin() + firstLineIndex;
const SelectionBoxInfo& firstSelectionBoxLineInfo = *( selectionBoxLinesInfo.Begin() );
bool boxifyBegin = ( LTR != lineRun->direction ) && ( LTR != startDirection );
{
quad.x = firstSelectionBoxLineInfo.maxX;
quad.y = firstSelectionBoxLineInfo.lineOffset;
- quad.z = mVisualModel->mControlSize.width;
+ quad.z = mModel->mVisualModel->mControlSize.width;
quad.w = firstSelectionBoxLineInfo.lineOffset + firstSelectionBoxLineInfo.lineHeight;
// Boxify at the end of the line.
++actualNumberOfQuads;
// Update the size of the highlighted text.
- maxHighlightX = mVisualModel->mControlSize.width;
+ maxHighlightX = mModel->mVisualModel->mControlSize.width;
}
// Boxify the central lines.
quad.x = info.maxX;
quad.y = info.lineOffset;
- quad.z = mVisualModel->mControlSize.width;
+ quad.z = mModel->mVisualModel->mControlSize.width;
quad.w = info.lineOffset + info.lineHeight;
mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
// Update the size of the highlighted text.
minHighlightX = 0.f;
- maxHighlightX = mVisualModel->mControlSize.width;
+ maxHighlightX = mModel->mVisualModel->mControlSize.width;
}
// Boxify the last line.
- lineRun = mVisualModel->mLines.Begin() + firstLineIndex + numberOfLines - 1u;
+ lineRun = mModel->mVisualModel->mLines.Begin() + firstLineIndex + numberOfLines - 1u;
const SelectionBoxInfo& lastSelectionBoxLineInfo = *( selectionBoxLinesInfo.End() - 1u );
boxifyBegin = ( LTR == lineRun->direction ) && ( LTR == endDirection );
{
quad.x = lastSelectionBoxLineInfo.maxX;
quad.y = lastSelectionBoxLineInfo.lineOffset;
- quad.z = mVisualModel->mControlSize.width;
+ quad.z = mModel->mVisualModel->mControlSize.width;
quad.w = lastSelectionBoxLineInfo.lineOffset + lastSelectionBoxLineInfo.lineHeight;
// Boxify at the end of the line.
++actualNumberOfQuads;
// Update the size of the highlighted text.
- maxHighlightX = mVisualModel->mControlSize.width;
+ maxHighlightX = mModel->mVisualModel->mControlSize.width;
}
}
GetCursorPosition( mEventData->mLeftSelectionPosition,
primaryCursorInfo );
- const Vector2 primaryPosition = primaryCursorInfo.primaryPosition + mScrollPosition;
+ const Vector2 primaryPosition = primaryCursorInfo.primaryPosition + mModel->mScrollPosition;
mEventData->mDecorator->SetPosition( LEFT_SELECTION_HANDLE,
primaryPosition.x,
- primaryCursorInfo.lineOffset + mScrollPosition.y,
+ primaryCursorInfo.lineOffset + mModel->mScrollPosition.y,
primaryCursorInfo.lineHeight );
CursorInfo secondaryCursorInfo;
GetCursorPosition( mEventData->mRightSelectionPosition,
secondaryCursorInfo );
- const Vector2 secondaryPosition = secondaryCursorInfo.primaryPosition + mScrollPosition;
+ const Vector2 secondaryPosition = secondaryCursorInfo.primaryPosition + mModel->mScrollPosition;
mEventData->mDecorator->SetPosition( RIGHT_SELECTION_HANDLE,
secondaryPosition.x,
- secondaryCursorInfo.lineOffset + mScrollPosition.y,
+ secondaryCursorInfo.lineOffset + mModel->mScrollPosition.y,
secondaryCursorInfo.lineHeight );
}
return;
}
- const Length numberOfGlyphs = mVisualModel->mGlyphs.Count();
- const Length numberOfLines = mVisualModel->mLines.Count();
+ const Length numberOfGlyphs = mModel->mVisualModel->mGlyphs.Count();
+ const Length numberOfLines = mModel->mVisualModel->mLines.Count();
if( ( 0 == numberOfGlyphs ) ||
( 0 == numberOfLines ) )
{
// Find which word was selected
CharacterIndex selectionStart( 0 );
CharacterIndex selectionEnd( 0 );
- const bool indicesFound = FindSelectionIndices( mVisualModel,
- mLogicalModel,
+ const bool indicesFound = FindSelectionIndices( mModel->mVisualModel,
+ mModel->mLogicalModel,
mMetrics,
visualX,
visualY,
}
else if( EventData::EDITING_WITH_POPUP == mEventData->mState )
{
- if( mLogicalModel->mText.Count() && !IsShowingPlaceholderText() )
+ if( mModel->mLogicalModel->mText.Count() && !IsShowingPlaceholderText() )
{
buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::SELECT | TextSelectionPopup::SELECT_ALL );
}
cursorInfo.lineHeight = GetDefaultFontLineHeight();
cursorInfo.primaryCursorHeight = cursorInfo.lineHeight;
- switch( mLayoutEngine.GetHorizontalAlignment() )
+ switch( mModel->mHorizontalAlignment )
{
- case LayoutEngine::HORIZONTAL_ALIGN_BEGIN:
+ case Layout::HORIZONTAL_ALIGN_BEGIN:
{
cursorInfo.primaryPosition.x = 0.f;
break;
}
- case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
+ case Layout::HORIZONTAL_ALIGN_CENTER:
{
- cursorInfo.primaryPosition.x = floorf( 0.5f * mVisualModel->mControlSize.width );
+ cursorInfo.primaryPosition.x = floorf( 0.5f * mModel->mVisualModel->mControlSize.width );
break;
}
- case LayoutEngine::HORIZONTAL_ALIGN_END:
+ case Layout::HORIZONTAL_ALIGN_END:
{
- cursorInfo.primaryPosition.x = mVisualModel->mControlSize.width - mEventData->mDecorator->GetCursorWidth();
+ cursorInfo.primaryPosition.x = mModel->mVisualModel->mControlSize.width - mEventData->mDecorator->GetCursorWidth();
break;
}
}
return;
}
- Text::GetCursorPosition( mVisualModel,
- mLogicalModel,
+ Text::GetCursorPosition( mModel->mVisualModel,
+ mModel->mLogicalModel,
mMetrics,
logical,
cursorInfo );
- if( LayoutEngine::MULTI_LINE_BOX == mLayoutEngine.GetLayout() )
+ if( Layout::Engine::MULTI_LINE_BOX == mLayoutEngine.GetLayout() )
{
// If the text is editable and multi-line, the cursor position after a white space shouldn't exceed the boundaries of the text control.
cursorInfo.primaryPosition.x = 0.f;
}
- const float edgeWidth = mVisualModel->mControlSize.width - static_cast<float>( mEventData->mDecorator->GetCursorWidth() );
+ const float edgeWidth = mModel->mVisualModel->mControlSize.width - static_cast<float>( mEventData->mDecorator->GetCursorWidth() );
if( cursorInfo.primaryPosition.x > edgeWidth )
{
cursorInfo.primaryPosition.x = edgeWidth;
CharacterIndex cursorIndex = mEventData->mPrimaryCursorPosition;
- const GlyphIndex* const charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin();
- const Length* const charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin();
+ const GlyphIndex* const charactersToGlyphBuffer = mModel->mVisualModel->mCharactersToGlyph.Begin();
+ const Length* const charactersPerGlyphBuffer = mModel->mVisualModel->mCharactersPerGlyph.Begin();
GlyphIndex glyphIndex = *( charactersToGlyphBuffer + index );
Length numberOfCharacters = *( charactersPerGlyphBuffer + glyphIndex );
if( numberOfCharacters > 1u )
{
- const Script script = mLogicalModel->GetScript( index );
+ const Script script = mModel->mLogicalModel->GetScript( index );
if( HasLigatureMustBreak( script ) )
{
// Prevents to jump the whole Latin ligatures like fi, ff, or Arabic ﻻ, ...
return;
}
- const Vector2 cursorPosition = cursorInfo.primaryPosition + mScrollPosition;
+ const Vector2 cursorPosition = cursorInfo.primaryPosition + mModel->mScrollPosition;
// Sets the cursor position.
mEventData->mDecorator->SetPosition( PRIMARY_CURSOR,
// Sets the grab handle position.
mEventData->mDecorator->SetPosition( GRAB_HANDLE,
cursorPosition.x,
- cursorInfo.lineOffset + mScrollPosition.y,
+ cursorInfo.lineOffset + mModel->mScrollPosition.y,
cursorInfo.lineHeight );
}
if( cursorInfo.isSecondaryCursor )
{
mEventData->mDecorator->SetPosition( SECONDARY_CURSOR,
- cursorInfo.secondaryPosition.x + mScrollPosition.x,
- cursorInfo.secondaryPosition.y + mScrollPosition.y,
+ cursorInfo.secondaryPosition.x + mModel->mScrollPosition.x,
+ cursorInfo.secondaryPosition.y + mModel->mScrollPosition.y,
cursorInfo.secondaryCursorHeight,
cursorInfo.lineHeight );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Secondary cursor position: %f,%f\n", cursorInfo.secondaryPosition.x + mScrollPosition.x, cursorInfo.secondaryPosition.y + mScrollPosition.y );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Secondary cursor position: %f,%f\n", cursorInfo.secondaryPosition.x + mModel->mScrollPosition.x, cursorInfo.secondaryPosition.y + mModel->mScrollPosition.y );
}
// Set which cursors are active according the state.
return;
}
- const Vector2 cursorPosition = cursorInfo.primaryPosition + mScrollPosition;
+ const Vector2 cursorPosition = cursorInfo.primaryPosition + mModel->mScrollPosition;
// Sets the handle's position.
mEventData->mDecorator->SetPosition( handleType,
cursorPosition.x,
- cursorInfo.lineOffset + mScrollPosition.y,
+ cursorInfo.lineOffset + mModel->mScrollPosition.y,
cursorInfo.lineHeight );
// If selection handle at start of the text and other at end of the text then all text is selected.
const CharacterIndex startOfSelection = std::min( mEventData->mLeftSelectionPosition, mEventData->mRightSelectionPosition );
const CharacterIndex endOfSelection = std::max ( mEventData->mLeftSelectionPosition, mEventData->mRightSelectionPosition );
- mEventData->mAllTextSelected = ( startOfSelection == 0 ) && ( endOfSelection == mLogicalModel->mText.Count() );
+ mEventData->mAllTextSelected = ( startOfSelection == 0 ) && ( endOfSelection == mModel->mLogicalModel->mText.Count() );
}
void Controller::Impl::ClampHorizontalScroll( const Vector2& layoutSize )
{
// Clamp between -space & 0.
- if( layoutSize.width > mVisualModel->mControlSize.width )
+ if( layoutSize.width > mModel->mVisualModel->mControlSize.width )
{
- const float space = ( layoutSize.width - mVisualModel->mControlSize.width );
- mScrollPosition.x = ( mScrollPosition.x < -space ) ? -space : mScrollPosition.x;
- mScrollPosition.x = ( mScrollPosition.x > 0.f ) ? 0.f : mScrollPosition.x;
+ const float space = ( layoutSize.width - mModel->mVisualModel->mControlSize.width );
+ mModel->mScrollPosition.x = ( mModel->mScrollPosition.x < -space ) ? -space : mModel->mScrollPosition.x;
+ mModel->mScrollPosition.x = ( mModel->mScrollPosition.x > 0.f ) ? 0.f : mModel->mScrollPosition.x;
mEventData->mDecoratorUpdated = true;
}
else
{
- mScrollPosition.x = 0.f;
+ mModel->mScrollPosition.x = 0.f;
}
}
void Controller::Impl::ClampVerticalScroll( const Vector2& layoutSize )
{
- if( LayoutEngine::SINGLE_LINE_BOX == mLayoutEngine.GetLayout() )
+ if( Layout::Engine::SINGLE_LINE_BOX == mLayoutEngine.GetLayout() )
{
// Nothing to do if the text is single line.
return;
}
// Clamp between -space & 0.
- if( layoutSize.height > mVisualModel->mControlSize.height )
+ if( layoutSize.height > mModel->mVisualModel->mControlSize.height )
{
- const float space = ( layoutSize.height - mVisualModel->mControlSize.height );
- mScrollPosition.y = ( mScrollPosition.y < -space ) ? -space : mScrollPosition.y;
- mScrollPosition.y = ( mScrollPosition.y > 0.f ) ? 0.f : mScrollPosition.y;
+ const float space = ( layoutSize.height - mModel->mVisualModel->mControlSize.height );
+ mModel->mScrollPosition.y = ( mModel->mScrollPosition.y < -space ) ? -space : mModel->mScrollPosition.y;
+ mModel->mScrollPosition.y = ( mModel->mScrollPosition.y > 0.f ) ? 0.f : mModel->mScrollPosition.y;
mEventData->mDecoratorUpdated = true;
}
else
{
- mScrollPosition.y = 0.f;
+ mModel->mScrollPosition.y = 0.f;
}
}
const float positionEndY = position.y + lineHeight;
// Transform the position to decorator coords.
- const float decoratorPositionBeginX = position.x + mScrollPosition.x;
- const float decoratorPositionEndX = positionEndX + mScrollPosition.x;
+ const float decoratorPositionBeginX = position.x + mModel->mScrollPosition.x;
+ const float decoratorPositionEndX = positionEndX + mModel->mScrollPosition.x;
- const float decoratorPositionBeginY = position.y + mScrollPosition.y;
- const float decoratorPositionEndY = positionEndY + mScrollPosition.y;
+ const float decoratorPositionBeginY = position.y + mModel->mScrollPosition.y;
+ const float decoratorPositionEndY = positionEndY + mModel->mScrollPosition.y;
if( decoratorPositionBeginX < 0.f )
{
- mScrollPosition.x = -position.x;
+ mModel->mScrollPosition.x = -position.x;
}
- else if( decoratorPositionEndX > mVisualModel->mControlSize.width )
+ else if( decoratorPositionEndX > mModel->mVisualModel->mControlSize.width )
{
- mScrollPosition.x = mVisualModel->mControlSize.width - positionEndX;
+ mModel->mScrollPosition.x = mModel->mVisualModel->mControlSize.width - positionEndX;
}
if( decoratorPositionBeginY < 0.f )
{
- mScrollPosition.y = -position.y;
+ mModel->mScrollPosition.y = -position.y;
}
- else if( decoratorPositionEndY > mVisualModel->mControlSize.height )
+ else if( decoratorPositionEndY > mModel->mVisualModel->mControlSize.height )
{
- mScrollPosition.y = mVisualModel->mControlSize.height - positionEndY;
+ mModel->mScrollPosition.y = mModel->mVisualModel->mControlSize.height - positionEndY;
}
}
const Vector2& currentCursorPosition = mEventData->mDecorator->GetPosition( PRIMARY_CURSOR );
// Calculate the offset to match the cursor position before the character was deleted.
- mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x;
- mScrollPosition.y = currentCursorPosition.y - cursorInfo.lineOffset;
+ mModel->mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x;
+ mModel->mScrollPosition.y = currentCursorPosition.y - cursorInfo.lineOffset;
- ClampHorizontalScroll( mVisualModel->GetLayoutSize() );
- ClampVerticalScroll( mVisualModel->GetLayoutSize() );
+ ClampHorizontalScroll( mModel->mVisualModel->GetLayoutSize() );
+ ClampVerticalScroll( mModel->mVisualModel->GetLayoutSize() );
// Makes the new cursor position visible if needed.
ScrollToMakePositionVisible( cursorInfo.primaryPosition, cursorInfo.lineHeight );
// INTERNAL INCLUDES
#include <dali-toolkit/internal/text/input-style.h>
-#include <dali-toolkit/internal/text/layouts/layout-engine.h>
-#include <dali-toolkit/internal/text/logical-model-impl.h>
#include <dali-toolkit/internal/text/text-controller.h>
+#include <dali-toolkit/internal/text/text-model.h>
#include <dali-toolkit/internal/text/text-view.h>
-#include <dali-toolkit/internal/text/visual-model-impl.h>
namespace Dali
{
EditableControlInterface* editableControlInterface )
: mControlInterface( controlInterface ),
mEditableControlInterface( editableControlInterface ),
- mLogicalModel(),
- mVisualModel(),
+ mModel(),
mFontDefaults( NULL ),
mUnderlineDefaults( NULL ),
mShadowDefaults( NULL ),
mClipboard(),
mView(),
mMetrics(),
- mLayoutEngine(),
mModifyEvents(),
mTextColor( Color::BLACK ),
- mScrollPosition(),
mTextUpdateInfo(),
mOperationsPending( NO_OPERATION ),
mMaximumNumberOfCharacters( 50u ),
mIsAutoScrollEnabled( false ),
mAutoScrollDirectionRTL( false )
{
- mLogicalModel = LogicalModel::New();
- mVisualModel = VisualModel::New();
+ mModel = Model::New();
mFontClient = TextAbstraction::FontClient::Get();
mClipboard = Clipboard::Get();
- mView.SetVisualModel( mVisualModel );
+ mView.SetVisualModel( mModel->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 );
+ mModel->mVisualModel->SetUnderlineEnabled( false );
+ mModel->mVisualModel->SetUnderlineHeight( 0.0f );
}
~Impl()
bool IsShowingRealText() const
{
return ( !IsShowingPlaceholderText() &&
- 0u != mLogicalModel->mText.Count() );
+ 0u != mModel->mLogicalModel->mText.Count() );
}
/**
mEventData->mIsShowingPlaceholderText = false;
// Remove mPlaceholderTextColor
- mVisualModel->SetTextColor( mTextColor );
+ mModel->mVisualModel->SetTextColor( mTextColor );
}
}
ControlInterface* mControlInterface; ///< Reference to the text controller.
EditableControlInterface* mEditableControlInterface; ///< Reference to the editable text controller.
- LogicalModelPtr mLogicalModel; ///< Pointer to the logical model.
- VisualModelPtr mVisualModel; ///< Pointer to the visual model.
+ ModelPtr mModel; ///< Pointer to the text's model.
FontDefaults* mFontDefaults; ///< Avoid allocating this when the user does not specify a font.
UnderlineDefaults* mUnderlineDefaults; ///< Avoid allocating this when the user does not specify underline parameters.
ShadowDefaults* mShadowDefaults; ///< Avoid allocating this when the user does not specify shadow parameters.
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.
+ Layout::Engine mLayoutEngine; ///< The layout engine.
Vector<ModifyEvent> mModifyEvents; ///< Temporary stores the text set until the next relayout.
Vector4 mTextColor; ///< The regular text color
- /**
- * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
- * Typically this will have a negative value with scrolling occurs.
- */
- Vector2 mScrollPosition; ///< The text is offset by this position when scrolling.
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.
void Controller::EnableTextInput( DecoratorPtr decorator )
{
+ if( !decorator )
+ {
+ delete mImpl->mEventData;
+ mImpl->mEventData = NULL;
+
+ // Nothing else to do.
+ return;
+ }
+
if( NULL == mImpl->mEventData )
{
mImpl->mEventData = new EventData( decorator );
void Controller::SetAutoScrollEnabled( bool enable )
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetAutoScrollEnabled[%s] SingleBox[%s]-> [%p]\n", (enable)?"true":"false", ( mImpl->mLayoutEngine.GetLayout() == LayoutEngine::SINGLE_LINE_BOX)?"true":"false", this );
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetAutoScrollEnabled[%s] SingleBox[%s]-> [%p]\n", (enable)?"true":"false", ( mImpl->mLayoutEngine.GetLayout() == Layout::Engine::SINGLE_LINE_BOX)?"true":"false", this );
- if( mImpl->mLayoutEngine.GetLayout() == LayoutEngine::SINGLE_LINE_BOX )
+ if( mImpl->mLayoutEngine.GetLayout() == Layout::Engine::SINGLE_LINE_BOX )
{
if( enable )
{
{
float offset = 0.f;
- if( mImpl->mVisualModel &&
- ( 0u != mImpl->mVisualModel->mLines.Count() ) )
+ if( mImpl->mModel->mVisualModel &&
+ ( 0u != mImpl->mModel->mVisualModel->mLines.Count() ) )
{
- offset = ( *mImpl->mVisualModel->mLines.Begin() ).alignmentOffset;
+ offset = ( *mImpl->mModel->mVisualModel->mLines.Begin() ).alignmentOffset;
}
return offset;
mImpl->mEventData->mDecorator->SetHorizontalScrollEnabled( enable );
}
}
-
bool Controller::IsHorizontalScrollEnabled() const
{
if( ( NULL != mImpl->mEventData ) &&
void Controller::SetMultiLineEnabled( bool enable )
{
- const LayoutEngine::Layout layout = enable ? LayoutEngine::MULTI_LINE_BOX : LayoutEngine::SINGLE_LINE_BOX;
+ const Layout::Engine::Type layout = enable ? Layout::Engine::MULTI_LINE_BOX : Layout::Engine::SINGLE_LINE_BOX;
if( layout != mImpl->mLayoutEngine.GetLayout() )
{
bool Controller::IsMultiLineEnabled() const
{
- return LayoutEngine::MULTI_LINE_BOX == mImpl->mLayoutEngine.GetLayout();
+ return Layout::Engine::MULTI_LINE_BOX == mImpl->mLayoutEngine.GetLayout();
}
-void Controller::SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment )
+void Controller::SetHorizontalAlignment( Layout::HorizontalAlignment alignment )
{
- if( alignment != mImpl->mLayoutEngine.GetHorizontalAlignment() )
+ if( alignment != mImpl->mModel->mHorizontalAlignment )
{
// Set the alignment.
- mImpl->mLayoutEngine.SetHorizontalAlignment( alignment );
+ mImpl->mModel->mHorizontalAlignment = alignment;
// Set the flag to redo the alignment operation.
mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
}
}
-LayoutEngine::HorizontalAlignment Controller::GetHorizontalAlignment() const
+Layout::HorizontalAlignment Controller::GetHorizontalAlignment() const
{
- return mImpl->mLayoutEngine.GetHorizontalAlignment();
+ return mImpl->mModel->mHorizontalAlignment;
}
-void Controller::SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment )
+void Controller::SetVerticalAlignment( Layout::VerticalAlignment alignment )
{
- if( alignment != mImpl->mLayoutEngine.GetVerticalAlignment() )
+ if( alignment != mImpl->mModel->mVerticalAlignment )
{
// Set the alignment.
- mImpl->mLayoutEngine.SetVerticalAlignment( alignment );
+ mImpl->mModel->mVerticalAlignment = alignment;
mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
}
}
-LayoutEngine::VerticalAlignment Controller::GetVerticalAlignment() const
+Layout::VerticalAlignment Controller::GetVerticalAlignment() const
+{
+ return mImpl->mModel->mVerticalAlignment;
+}
+
+void Controller::SetTextElideEnabled( bool enabled )
{
- return mImpl->mLayoutEngine.GetVerticalAlignment();
+ mImpl->mModel->mElideEnabled = enabled;
+}
+
+bool Controller::IsTextElideEnabled() const
+{
+ return mImpl->mModel->mElideEnabled;
}
// public : Update
if( !text.empty() )
{
- mImpl->mVisualModel->SetTextColor( mImpl->mTextColor );
+ mImpl->mModel->mVisualModel->SetTextColor( mImpl->mTextColor );
- MarkupProcessData markupProcessData( mImpl->mLogicalModel->mColorRuns,
- mImpl->mLogicalModel->mFontDescriptionRuns );
+ MarkupProcessData markupProcessData( mImpl->mModel->mLogicalModel->mColorRuns,
+ mImpl->mModel->mLogicalModel->mFontDescriptionRuns );
Length textSize = 0u;
const uint8_t* utf8 = NULL;
}
// Convert text into UTF-32
- Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
+ Vector<Character>& utf32Characters = mImpl->mModel->mLogicalModel->mText;
utf32Characters.Resize( textSize );
// Transform a text array encoded in utf8 into an array encoded in utf32.
utf32Characters.Resize( characterCount );
DALI_ASSERT_DEBUG( textSize >= characterCount && "Invalid UTF32 conversion length" );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText %p UTF8 size %d, UTF32 size %d\n", this, textSize, mImpl->mLogicalModel->mText.Count() );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText %p UTF8 size %d, UTF32 size %d\n", this, textSize, mImpl->mModel->mLogicalModel->mText.Count() );
// The characters to be added.
- mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mLogicalModel->mText.Count();
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
// To reset the cursor position
lastCursorIndex = characterCount;
// Update placeholder if there is no text
if( mImpl->IsShowingPlaceholderText() ||
- ( 0u == mImpl->mLogicalModel->mText.Count() ) )
+ ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) )
{
ShowPlaceholderText();
}
return 0.0f;
}
-void Controller::SetTextColor( const Vector4& textColor )
+void Controller::SetDefaultColor( const Vector4& color )
{
- mImpl->mTextColor = textColor;
+ mImpl->mTextColor = color;
if( !mImpl->IsShowingPlaceholderText() )
{
- mImpl->mVisualModel->SetTextColor( textColor );
+ mImpl->mModel->mVisualModel->SetTextColor( color );
mImpl->RequestRelayout();
}
}
-const Vector4& Controller::GetTextColor() const
+const Vector4& Controller::GetDefaultColor() const
{
return mImpl->mTextColor;
}
if( mImpl->IsShowingPlaceholderText() )
{
- mImpl->mVisualModel->SetTextColor( textColor );
+ mImpl->mModel->mVisualModel->SetTextColor( textColor );
mImpl->RequestRelayout();
}
}
void Controller::SetShadowOffset( const Vector2& shadowOffset )
{
- mImpl->mVisualModel->SetShadowOffset( shadowOffset );
+ mImpl->mModel->mVisualModel->SetShadowOffset( shadowOffset );
mImpl->RequestRelayout();
}
const Vector2& Controller::GetShadowOffset() const
{
- return mImpl->mVisualModel->GetShadowOffset();
+ return mImpl->mModel->mVisualModel->GetShadowOffset();
}
void Controller::SetShadowColor( const Vector4& shadowColor )
{
- mImpl->mVisualModel->SetShadowColor( shadowColor );
+ mImpl->mModel->mVisualModel->SetShadowColor( shadowColor );
mImpl->RequestRelayout();
}
const Vector4& Controller::GetShadowColor() const
{
- return mImpl->mVisualModel->GetShadowColor();
+ return mImpl->mModel->mVisualModel->GetShadowColor();
}
void Controller::SetUnderlineColor( const Vector4& color )
{
- mImpl->mVisualModel->SetUnderlineColor( color );
+ mImpl->mModel->mVisualModel->SetUnderlineColor( color );
mImpl->RequestRelayout();
}
const Vector4& Controller::GetUnderlineColor() const
{
- return mImpl->mVisualModel->GetUnderlineColor();
+ return mImpl->mModel->mVisualModel->GetUnderlineColor();
}
void Controller::SetUnderlineEnabled( bool enabled )
{
- mImpl->mVisualModel->SetUnderlineEnabled( enabled );
+ mImpl->mModel->mVisualModel->SetUnderlineEnabled( enabled );
mImpl->RequestRelayout();
}
bool Controller::IsUnderlineEnabled() const
{
- return mImpl->mVisualModel->IsUnderlineEnabled();
+ return mImpl->mModel->mVisualModel->IsUnderlineEnabled();
}
void Controller::SetUnderlineHeight( float height )
{
- mImpl->mVisualModel->SetUnderlineHeight( height );
+ mImpl->mModel->mVisualModel->SetUnderlineHeight( height );
mImpl->RequestRelayout();
}
float Controller::GetUnderlineHeight() const
{
- return mImpl->mVisualModel->GetUnderlineHeight();
+ return mImpl->mModel->mVisualModel->GetUnderlineHeight();
}
void Controller::SetDefaultEmbossProperties( const std::string& embossProperties )
const Length lengthOfSelectedText = ( handlesCrossed ? mImpl->mEventData->mLeftSelectionPosition : mImpl->mEventData->mRightSelectionPosition ) - startOfSelectedText;
// Add the color run.
- const VectorBase::SizeType numberOfRuns = mImpl->mLogicalModel->mColorRuns.Count();
- mImpl->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u );
+ const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mColorRuns.Count();
+ mImpl->mModel->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u );
- ColorRun& colorRun = *( mImpl->mLogicalModel->mColorRuns.Begin() + numberOfRuns );
+ ColorRun& colorRun = *( mImpl->mModel->mLogicalModel->mColorRuns.Begin() + numberOfRuns );
colorRun.color = color;
colorRun.characterRun.characterIndex = startOfSelectedText;
colorRun.characterRun.numberOfCharacters = lengthOfSelectedText;
CharacterIndex startOfSelectedText = 0u;
Length lengthOfSelectedText = 0u;
FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
- mImpl->mLogicalModel,
+ mImpl->mModel->mLogicalModel,
startOfSelectedText,
lengthOfSelectedText );
CharacterIndex startOfSelectedText = 0u;
Length lengthOfSelectedText = 0u;
FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
- mImpl->mLogicalModel,
+ mImpl->mModel->mLogicalModel,
startOfSelectedText,
lengthOfSelectedText );
CharacterIndex startOfSelectedText = 0u;
Length lengthOfSelectedText = 0u;
FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
- mImpl->mLogicalModel,
+ mImpl->mModel->mLogicalModel,
startOfSelectedText,
lengthOfSelectedText );
CharacterIndex startOfSelectedText = 0u;
Length lengthOfSelectedText = 0u;
FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
- mImpl->mLogicalModel,
+ mImpl->mModel->mLogicalModel,
startOfSelectedText,
lengthOfSelectedText );
CharacterIndex startOfSelectedText = 0u;
Length lengthOfSelectedText = 0u;
FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
- mImpl->mLogicalModel,
+ mImpl->mModel->mLogicalModel,
startOfSelectedText,
lengthOfSelectedText );
// public : Queries & retrieves.
-LayoutEngine& Controller::GetLayoutEngine()
+Layout::Engine& Controller::GetLayoutEngine()
{
return mImpl->mLayoutEngine;
}
return mImpl->mView;
}
-const Vector2& Controller::GetScrollPosition() const
-{
- return mImpl->mScrollPosition;
-}
-
Vector3 Controller::GetNaturalSize()
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetNaturalSize\n" );
// Set the update info to relayout the whole text.
mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
- mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mLogicalModel->mText.Count();
+ mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
// Store the actual control's size to restore later.
- const Size actualControlSize = mImpl->mVisualModel->mControlSize;
+ const Size actualControlSize = mImpl->mModel->mVisualModel->mControlSize;
DoRelayout( Size( MAX_FLOAT, MAX_FLOAT ),
static_cast<OperationsMask>( onlyOnceOperations |
// Stores the natural size to avoid recalculate it again
// unless the text/style changes.
- mImpl->mVisualModel->SetNaturalSize( naturalSize.GetVectorXY() );
+ mImpl->mModel->mVisualModel->SetNaturalSize( naturalSize.GetVectorXY() );
mImpl->mRecalculateNaturalSize = false;
mImpl->mTextUpdateInfo.Clear();
// Restore the actual control's size.
- mImpl->mVisualModel->mControlSize = actualControlSize;
+ mImpl->mModel->mVisualModel->mControlSize = actualControlSize;
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize calculated %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
}
else
{
- naturalSize = mImpl->mVisualModel->GetNaturalSize();
+ naturalSize = mImpl->mModel->mVisualModel->GetNaturalSize();
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize cached %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
}
ProcessModifyEvents();
Size layoutSize;
- if( fabsf( width - mImpl->mVisualModel->mControlSize.width ) > Math::MACHINE_EPSILON_1000 )
+ if( fabsf( width - mImpl->mModel->mVisualModel->mControlSize.width ) > Math::MACHINE_EPSILON_1000 )
{
// Operations that can be done only once until the text changes.
const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32 |
// Set the update info to relayout the whole text.
mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
- mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mLogicalModel->mText.Count();
+ mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
// Store the actual control's width.
- const float actualControlWidth = mImpl->mVisualModel->mControlSize.width;
+ const float actualControlWidth = mImpl->mModel->mVisualModel->mControlSize.width;
DoRelayout( Size( width, MAX_FLOAT ),
static_cast<OperationsMask>( onlyOnceOperations |
mImpl->mTextUpdateInfo.Clear();
// Restore the actual control's width.
- mImpl->mVisualModel->mControlSize.width = actualControlWidth;
+ mImpl->mModel->mVisualModel->mControlSize.width = actualControlWidth;
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth calculated %f\n", layoutSize.height );
}
else
{
- layoutSize = mImpl->mVisualModel->GetLayoutSize();
+ layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize();
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth cached %f\n", layoutSize.height );
}
return layoutSize.height;
}
+const ModelInterface* const Controller::GetTextModel() const
+{
+ return mImpl->mModel.Get();
+}
+
// public : Relayout.
Controller::UpdateTextType Controller::Relayout( const Size& size )
if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
{
- if( 0u != mImpl->mVisualModel->mGlyphPositions.Count() )
+ if( 0u != mImpl->mModel->mVisualModel->mGlyphPositions.Count() )
{
- mImpl->mVisualModel->mGlyphPositions.Clear();
+ mImpl->mModel->mVisualModel->mGlyphPositions.Clear();
updateTextType = MODEL_UPDATED;
}
}
// Whether a new size has been set.
- const bool newSize = ( size != mImpl->mVisualModel->mControlSize );
+ const bool newSize = ( size != mImpl->mModel->mVisualModel->mControlSize );
if( newSize )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mVisualModel->mControlSize.width, mImpl->mVisualModel->mControlSize.height );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mModel->mVisualModel->mControlSize.width, mImpl->mModel->mVisualModel->mControlSize.height );
// Layout operations that need to be done if the size changes.
mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
Vector2 offset;
if( newSize && isEditable )
{
- offset = mImpl->mScrollPosition;
+ offset = mImpl->mModel->mScrollPosition;
}
if( !isEditable || !IsMultiLineEnabled() )
mImpl->ClampHorizontalScroll( layoutSize );
// Update the decorator's positions is needed if there is a new size.
- mImpl->mEventData->mDecorator->UpdatePositions( mImpl->mScrollPosition - offset );
+ mImpl->mEventData->mDecorator->UpdatePositions( mImpl->mModel->mScrollPosition - offset );
}
// Move the cursor, grab handle etc.
if( textDeleted )
{
- if( ( 0u != mImpl->mLogicalModel->mText.Count() ) ||
+ if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) ||
!mImpl->IsPlaceholderAvailable() )
{
mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
void Controller::GetTargetSize( Vector2& targetSize )
{
- targetSize = mImpl->mVisualModel->mControlSize;
+ targetSize = mImpl->mModel->mVisualModel->mControlSize;
}
void Controller::AddDecoration( Actor& actor, bool needsClipping )
mImpl->SendSelectionToClipboard( true ); // Synchronous call to modify text
mImpl->mOperationsPending = ALL_OPERATIONS;
- if( ( 0u != mImpl->mLogicalModel->mText.Count() ) ||
+ if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) ||
!mImpl->IsPlaceholderAvailable() )
{
mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
mImpl->mEventData->mPrimaryCursorPosition, mImpl->mEventData->mPreEditFlag, mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
// TODO: At the moment the underline runs are only for pre-edit.
- mImpl->mVisualModel->mUnderlineRuns.Clear();
+ mImpl->mModel->mVisualModel->mUnderlineRuns.Clear();
// Keep the current number of characters.
- const Length currentNumberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mLogicalModel->mText.Count() : 0u;
+ const Length currentNumberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mModel->mLogicalModel->mText.Count() : 0u;
// Remove the previous IMF pre-edit.
if( mImpl->mEventData->mPreEditFlag && ( 0u != mImpl->mEventData->mPreEditLength ) )
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "mPreEditStartPosition %d mPreEditLength %d\n", mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
}
- const Length numberOfCharactersInModel = mImpl->mLogicalModel->mText.Count();
+ const Length numberOfCharactersInModel = mImpl->mModel->mLogicalModel->mText.Count();
// Restrict new text to fit within Maximum characters setting.
Length maxSizeOfNewText = std::min( ( mImpl->mMaximumNumberOfCharacters - numberOfCharactersInModel ), characterCount );
// Update the text's style.
// Updates the text style runs by adding characters.
- mImpl->mLogicalModel->UpdateTextStyleRuns( cursorIndex, maxSizeOfNewText );
+ mImpl->mModel->mLogicalModel->UpdateTextStyleRuns( cursorIndex, maxSizeOfNewText );
// Get the character index from the cursor index.
const CharacterIndex styleIndex = ( cursorIndex > 0u ) ? cursorIndex - 1u : 0u;
// Retrieve the text's style for the given index.
InputStyle style;
mImpl->RetrieveDefaultInputStyle( style );
- mImpl->mLogicalModel->RetrieveStyle( styleIndex, style );
+ mImpl->mModel->mLogicalModel->RetrieveStyle( styleIndex, style );
// Whether to add a new text color run.
const bool addColorRun = ( style.textColor != mImpl->mEventData->mInputStyle.textColor );
// Add style runs.
if( addColorRun )
{
- const VectorBase::SizeType numberOfRuns = mImpl->mLogicalModel->mColorRuns.Count();
- mImpl->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u );
+ const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mColorRuns.Count();
+ mImpl->mModel->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u );
- ColorRun& colorRun = *( mImpl->mLogicalModel->mColorRuns.Begin() + numberOfRuns );
+ ColorRun& colorRun = *( mImpl->mModel->mLogicalModel->mColorRuns.Begin() + numberOfRuns );
colorRun.color = mImpl->mEventData->mInputStyle.textColor;
colorRun.characterRun.characterIndex = cursorIndex;
colorRun.characterRun.numberOfCharacters = maxSizeOfNewText;
addFontSlantRun ||
addFontSizeRun )
{
- const VectorBase::SizeType numberOfRuns = mImpl->mLogicalModel->mFontDescriptionRuns.Count();
- mImpl->mLogicalModel->mFontDescriptionRuns.Resize( numberOfRuns + 1u );
+ const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Count();
+ mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Resize( numberOfRuns + 1u );
- FontDescriptionRun& fontDescriptionRun = *( mImpl->mLogicalModel->mFontDescriptionRuns.Begin() + numberOfRuns );
+ FontDescriptionRun& fontDescriptionRun = *( mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Begin() + numberOfRuns );
if( addFontNameRun )
{
}
// Insert at current cursor position.
- Vector<Character>& modifyText = mImpl->mLogicalModel->mText;
+ Vector<Character>& modifyText = mImpl->mModel->mLogicalModel->mText;
if( cursorIndex < numberOfCharactersInModel )
{
// Update the cursor index.
cursorIndex += maxSizeOfNewText;
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mModel->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition );
}
- const Length numberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mLogicalModel->mText.Count() : 0u;
+ const Length numberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mModel->mLogicalModel->mText.Count() : 0u;
- if( ( 0u == mImpl->mLogicalModel->mText.Count() ) &&
+ if( ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) &&
mImpl->IsPlaceholderAvailable() )
{
// Show place-holder if empty after removing the pre-edit text
if( maxLengthReached )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", mImpl->mLogicalModel->mText.Count() );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", mImpl->mModel->mLogicalModel->mText.Count() );
mImpl->ResetImfManager();
}
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 );
+ this, mImpl->mModel->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfCharacters );
if( !mImpl->IsShowingPlaceholderText() )
{
// Delete at current cursor position
- Vector<Character>& currentText = mImpl->mLogicalModel->mText;
+ Vector<Character>& currentText = mImpl->mModel->mLogicalModel->mText;
CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
CharacterIndex cursorIndex = oldCursorIndex;
mImpl->RetrieveDefaultInputStyle( mImpl->mEventData->mInputStyle );
// Update the input style.
- mImpl->mLogicalModel->RetrieveStyle( cursorIndex, mImpl->mEventData->mInputStyle );
+ mImpl->mModel->mLogicalModel->RetrieveStyle( cursorIndex, mImpl->mEventData->mInputStyle );
// Compare if the input style has changed.
const bool hasInputStyleChanged = !currentInputStyle.Equal( mImpl->mEventData->mInputStyle );
}
// Updates the text style runs by removing characters. Runs with no characters are removed.
- mImpl->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfCharacters );
+ mImpl->mModel->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfCharacters );
// Remove the characters.
Vector<Character>::Iterator first = currentText.Begin() + cursorIndex;
const Length requestedNumberOfCharacters = mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters;
// Get the current layout size.
- layoutSize = mImpl->mVisualModel->GetLayoutSize();
+ layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize();
if( NO_OPERATION != ( LAYOUT & operations ) )
{
// Fill the vectors again.
// Calculate the number of glyphs to layout.
- const Vector<GlyphIndex>& charactersToGlyph = mImpl->mVisualModel->mCharactersToGlyph;
- const Vector<Length>& glyphsPerCharacter = mImpl->mVisualModel->mGlyphsPerCharacter;
+ const Vector<GlyphIndex>& charactersToGlyph = mImpl->mModel->mVisualModel->mCharactersToGlyph;
+ const Vector<Length>& glyphsPerCharacter = mImpl->mModel->mVisualModel->mGlyphsPerCharacter;
const GlyphIndex* const charactersToGlyphBuffer = charactersToGlyph.Begin();
const Length* const glyphsPerCharacterBuffer = glyphsPerCharacter.Begin();
const CharacterIndex lastIndex = startIndex + ( ( requestedNumberOfCharacters > 0u ) ? requestedNumberOfCharacters - 1u : 0u );
const GlyphIndex startGlyphIndex = mImpl->mTextUpdateInfo.mStartGlyphIndex;
const Length numberOfGlyphs = ( requestedNumberOfCharacters > 0u ) ? *( charactersToGlyphBuffer + lastIndex ) + *( glyphsPerCharacterBuffer + lastIndex ) - startGlyphIndex : 0u;
- const Length totalNumberOfGlyphs = mImpl->mVisualModel->mGlyphs.Count();
+ const Length totalNumberOfGlyphs = mImpl->mModel->mVisualModel->mGlyphs.Count();
if( 0u == totalNumberOfGlyphs )
{
if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) )
{
- mImpl->mVisualModel->SetLayoutSize( Size::ZERO );
+ mImpl->mModel->mVisualModel->SetLayoutSize( Size::ZERO );
}
// Nothing else to do if there is no glyphs.
return true;
}
- const Vector<LineBreakInfo>& lineBreakInfo = mImpl->mLogicalModel->mLineBreakInfo;
- const Vector<WordBreakInfo>& wordBreakInfo = mImpl->mLogicalModel->mWordBreakInfo;
- const Vector<CharacterDirection>& characterDirection = mImpl->mLogicalModel->mCharacterDirections;
- const Vector<GlyphInfo>& glyphs = mImpl->mVisualModel->mGlyphs;
- const Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters;
- const Vector<Length>& charactersPerGlyph = mImpl->mVisualModel->mCharactersPerGlyph;
- const Character* const textBuffer = mImpl->mLogicalModel->mText.Begin();
+ const Vector<LineBreakInfo>& lineBreakInfo = mImpl->mModel->mLogicalModel->mLineBreakInfo;
+ const Vector<WordBreakInfo>& wordBreakInfo = mImpl->mModel->mLogicalModel->mWordBreakInfo;
+ const Vector<CharacterDirection>& characterDirection = mImpl->mModel->mLogicalModel->mCharacterDirections;
+ const Vector<GlyphInfo>& glyphs = mImpl->mModel->mVisualModel->mGlyphs;
+ const Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mModel->mVisualModel->mGlyphsToCharacters;
+ const Vector<Length>& charactersPerGlyph = mImpl->mModel->mVisualModel->mCharactersPerGlyph;
+ const Character* const textBuffer = mImpl->mModel->mLogicalModel->mText.Begin();
// Set the layout parameters.
- LayoutParameters layoutParameters( size,
- textBuffer,
- lineBreakInfo.Begin(),
- wordBreakInfo.Begin(),
- ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL,
- glyphs.Begin(),
- glyphsToCharactersMap.Begin(),
- charactersPerGlyph.Begin(),
- charactersToGlyphBuffer,
- glyphsPerCharacterBuffer,
- totalNumberOfGlyphs );
+ Layout::Parameters layoutParameters( size,
+ textBuffer,
+ lineBreakInfo.Begin(),
+ wordBreakInfo.Begin(),
+ ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL,
+ glyphs.Begin(),
+ glyphsToCharactersMap.Begin(),
+ charactersPerGlyph.Begin(),
+ charactersToGlyphBuffer,
+ glyphsPerCharacterBuffer,
+ totalNumberOfGlyphs,
+ mImpl->mModel->mHorizontalAlignment );
// Resize the vector of positions to have the same size than the vector of glyphs.
- Vector<Vector2>& glyphPositions = mImpl->mVisualModel->mGlyphPositions;
+ Vector<Vector2>& glyphPositions = mImpl->mModel->mVisualModel->mGlyphPositions;
glyphPositions.Resize( totalNumberOfGlyphs );
// Whether the last character is a new paragraph character.
- mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph = TextAbstraction::IsNewParagraph( *( textBuffer + ( mImpl->mLogicalModel->mText.Count() - 1u ) ) );
+ mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph = TextAbstraction::IsNewParagraph( *( textBuffer + ( mImpl->mModel->mLogicalModel->mText.Count() - 1u ) ) );
layoutParameters.isLastNewParagraph = mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph;
// The initial glyph and the number of glyphs to layout.
Size newLayoutSize;
viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters,
glyphPositions,
- mImpl->mVisualModel->mLines,
- newLayoutSize );
+ mImpl->mModel->mVisualModel->mLines,
+ newLayoutSize,
+ mImpl->mModel->mElideEnabled );
viewUpdated = viewUpdated || ( newLayoutSize != layoutSize );
{
layoutSize = newLayoutSize;
- if ( NO_OPERATION != ( UPDATE_DIRECTION & operations ) )
+ if( NO_OPERATION != ( UPDATE_DIRECTION & operations ) )
{
mImpl->mAutoScrollDirectionRTL = false;
}
// Reorder the lines
if( NO_OPERATION != ( REORDER & operations ) )
{
- Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mImpl->mLogicalModel->mBidirectionalParagraphInfo;
- Vector<BidirectionalLineInfoRun>& bidirectionalLineInfo = mImpl->mLogicalModel->mBidirectionalLineInfo;
+ Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mImpl->mModel->mLogicalModel->mBidirectionalParagraphInfo;
+ Vector<BidirectionalLineInfoRun>& bidirectionalLineInfo = mImpl->mModel->mLogicalModel->mBidirectionalLineInfo;
// Check first if there are paragraphs with bidirectional info.
if( 0u != bidirectionalInfo.Count() )
{
// Get the lines
- const Length numberOfLines = mImpl->mVisualModel->mLines.Count();
+ const Length numberOfLines = mImpl->mModel->mVisualModel->mLines.Count();
// Reorder the lines.
bidirectionalLineInfo.Reserve( numberOfLines ); // Reserve because is not known yet how many lines have right to left characters.
ReorderLines( bidirectionalInfo,
startIndex,
requestedNumberOfCharacters,
- mImpl->mVisualModel->mLines,
+ mImpl->mModel->mVisualModel->mLines,
bidirectionalLineInfo );
// Set the bidirectional info per line into the layout parameters.
if ( ( NO_OPERATION != ( UPDATE_DIRECTION & operations ) ) && ( numberOfLines > 0 ) )
{
- const LineRun* const firstline = mImpl->mVisualModel->mLines.Begin();
+ const LineRun* const firstline = mImpl->mModel->mVisualModel->mLines.Begin();
if ( firstline )
{
mImpl->mAutoScrollDirectionRTL = firstline->direction;
// Sets the layout size.
if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) )
{
- mImpl->mVisualModel->SetLayoutSize( layoutSize );
+ mImpl->mModel->mVisualModel->SetLayoutSize( layoutSize );
}
} // view updated
// Store the size used to layout the text.
- mImpl->mVisualModel->mControlSize = size;
+ mImpl->mModel->mVisualModel->mControlSize = size;
}
if( NO_OPERATION != ( ALIGN & operations ) )
{
// The laid-out lines.
- Vector<LineRun>& lines = mImpl->mVisualModel->mLines;
+ Vector<LineRun>& lines = mImpl->mModel->mVisualModel->mLines;
mImpl->mLayoutEngine.Align( size,
startIndex,
requestedNumberOfCharacters,
+ mImpl->mModel->mHorizontalAlignment,
lines );
viewUpdated = true;
void Controller::CalculateVerticalOffset( const Size& controlSize )
{
- Size layoutSize = mImpl->mVisualModel->GetLayoutSize();
+ Size layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize();
if( fabsf( layoutSize.height ) < Math::MACHINE_EPSILON_1000 )
{
layoutSize.height = mImpl->GetDefaultFontLineHeight();
}
- switch( mImpl->mLayoutEngine.GetVerticalAlignment() )
+ switch( mImpl->mModel->mVerticalAlignment )
{
- case LayoutEngine::VERTICAL_ALIGN_TOP:
+ case Layout::VERTICAL_ALIGN_TOP:
{
- mImpl->mScrollPosition.y = 0.f;
+ mImpl->mModel->mScrollPosition.y = 0.f;
break;
}
- case LayoutEngine::VERTICAL_ALIGN_CENTER:
+ case Layout::VERTICAL_ALIGN_CENTER:
{
- mImpl->mScrollPosition.y = floorf( 0.5f * ( controlSize.height - layoutSize.height ) ); // try to avoid pixel alignment.
+ mImpl->mModel->mScrollPosition.y = floorf( 0.5f * ( controlSize.height - layoutSize.height ) ); // try to avoid pixel alignment.
break;
}
- case LayoutEngine::VERTICAL_ALIGN_BOTTOM:
+ case Layout::VERTICAL_ALIGN_BOTTOM:
{
- mImpl->mScrollPosition.y = controlSize.height - layoutSize.height;
+ mImpl->mModel->mScrollPosition.y = controlSize.height - layoutSize.height;
break;
}
}
if( removed )
{
- if( ( 0u != mImpl->mLogicalModel->mText.Count() ) ||
+ if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) ||
!mImpl->IsPlaceholderAvailable() )
{
mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
void Controller::ResetText()
{
// Reset buffers.
- mImpl->mLogicalModel->mText.Clear();
+ mImpl->mModel->mLogicalModel->mText.Clear();
// We have cleared everything including the placeholder-text
mImpl->PlaceholderCleared();
mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
// Reset model for showing placeholder.
- mImpl->mLogicalModel->mText.Clear();
- mImpl->mVisualModel->SetTextColor( mImpl->mEventData->mPlaceholderTextColor );
+ mImpl->mModel->mLogicalModel->mText.Clear();
+ mImpl->mModel->mVisualModel->SetTextColor( mImpl->mEventData->mPlaceholderTextColor );
// Convert text into UTF-32
- Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
+ Vector<Character>& utf32Characters = mImpl->mModel->mLogicalModel->mText;
utf32Characters.Resize( size );
// This is a bit horrible but std::string returns a (signed) char*
// Set flags to update the model.
mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
- mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mLogicalModel->mText.Count();
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
mImpl->mTextUpdateInfo.mClearAll = true;
mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
void Controller::ClearStyleData()
{
- mImpl->mLogicalModel->mColorRuns.Clear();
- mImpl->mLogicalModel->ClearFontDescriptionRuns();
+ mImpl->mModel->mLogicalModel->mColorRuns.Clear();
+ mImpl->mModel->mLogicalModel->ClearFontDescriptionRuns();
}
void Controller::ResetCursorPosition( CharacterIndex cursorIndex )
if( NULL != mImpl->mEventData )
{
// Reset the scroll position.
- mImpl->mScrollPosition = Vector2::ZERO;
+ mImpl->mModel->mScrollPosition = Vector2::ZERO;
mImpl->mEventData->mScrollAfterUpdatePosition = true;
}
}
#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/text-model-interface.h>
namespace Dali
{
class ControlInterface;
class EditableControlInterface;
class View;
+class RenderingController;
typedef IntrusivePtr<Controller> ControllerPtr;
bool IsMultiLineEnabled() const;
/**
- * @copydoc Dali::Toolkit::Text::LayoutEngine::SetHorizontalAlignment()
+ * @brief Sets the text's horizontal alignment.
+ *
+ * @param[in] alignment The horizontal alignment.
+ */
+ void SetHorizontalAlignment( Layout::HorizontalAlignment alignment );
+
+ /**
+ * @copydoc ModelInterface::GetHorizontalAlignment()
*/
- void SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment );
+ Layout::HorizontalAlignment GetHorizontalAlignment() const;
/**
- * @copydoc Dali::Toolkit::Text::LayoutEngine::GetHorizontalAlignment()
+ * @brief Sets the text's vertical alignment.
+ *
+ * @param[in] alignment The vertical alignment.
*/
- LayoutEngine::HorizontalAlignment GetHorizontalAlignment() const;
+ void SetVerticalAlignment( Layout::VerticalAlignment alignment );
/**
- * @copydoc Dali::Toolkit::Text::LayoutEngine::SetVerticalAlignment()
+ * @copydoc ModelInterface::GetVerticalAlignment()
*/
- void SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment );
+ Layout::VerticalAlignment GetVerticalAlignment() const;
/**
- * @copydoc Dali::Toolkit::Text::LayoutEngine::GetVerticalAlignment()
+ * @brief Enable or disable the text elide.
+ *
+ * @param[in] enabled Whether to enable the text elide.
*/
- LayoutEngine::VerticalAlignment GetVerticalAlignment() const;
+ void SetTextElideEnabled( bool enabled );
+
+ /**
+ * @copydoc ModelInterface::IsTextElideEnabled()
+ */
+ bool IsTextElideEnabled() const;
public: // Update.
float GetDefaultPointSize() const;
/**
- * @brief Set the text color
+ * @brief Sets the text's default color.
*
- * @param textColor The text color
+ * @param color The default color.
*/
- void SetTextColor( const Vector4& textColor );
+ void SetDefaultColor( const Vector4& color );
/**
- * @brief Retrieve the text color
+ * @brief Retrieves the text's default color.
*
- * @return The text color
+ * @return The default color.
*/
- const Vector4& GetTextColor() const;
+ const Vector4& GetDefaultColor() const;
/**
* @brief Set the text color
*
* @return A reference to the layout engine.
*/
- LayoutEngine& GetLayoutEngine();
+ Layout::Engine& GetLayoutEngine();
/**
* @brief Return a view of the text.
View& GetView();
/**
- * @brief Query the current scroll position; the UI control is responsible for moving actors to this position.
- *
- * @return The scroll position.
- */
- const Vector2& GetScrollPosition() const;
-
- /**
* @copydoc Control::GetNaturalSize()
*/
Vector3 GetNaturalSize();
*/
float GetHeightForWidth( float width );
+ /**
+ * @brief Retrieves the text's model.
+ *
+ * @return A pointer to the text's model.
+ */
+ const ModelInterface* const GetTextModel() const;
+
public: // Relayout.
/**
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H
+#define DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H
+
+/*
+ * 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.
+ * 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/math/vector2.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/layouts/layout-alignment.h>
+#include <dali-toolkit/internal/text/line-run.h>
+#include <dali-toolkit/internal/text/text-definitions.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+/**
+ * @brief Interface class used to retrieve the text's model from the text-controller.
+ */
+class ModelInterface
+{
+public:
+ /**
+ * @brief Virtual destructor.
+ */
+ virtual ~ModelInterface()
+ {}
+
+ /**
+ * @brief Retrives the control's size.
+ *
+ * @return The control's size.
+ */
+ virtual const Size& GetControlSize() const = 0;
+
+ /**
+ * @brief Retrives the layout's size.
+ *
+ * @return The layout's size.
+ */
+ virtual const Size& GetLayoutSize() const = 0;
+
+ /**
+ * @brief Retrieves the text's scroll position.
+ *
+ * @return The scroll position.
+ */
+ virtual const Vector2& GetScrollPosition() const = 0;
+
+ /**
+ * @brief Retrieves the text's horizontal alignment.
+ *
+ * @return The horizontal alignment.
+ */
+ virtual Layout::HorizontalAlignment GetHorizontalAlignment() const = 0;
+
+ /**
+ * @brief Retrieves the text's vertical alignment.
+ *
+ * @return The vertical alignment.
+ */
+ virtual Layout::VerticalAlignment GetVerticalAlignment() const = 0;
+
+ /**
+ * @brief Whether the text elide property is enabled.
+ *
+ * @return @e true if the text elide property is enabled, @e false otherwise.
+ */
+ virtual bool IsTextElideEnabled() const = 0;
+
+ /**
+ * @brief Retrieves the number of laid-out lines.
+ *
+ * @return The number of laid-out lines.
+ */
+ virtual Length GetNumberOfLines() const = 0;
+
+ /**
+ * @brief Retrieves the laid-out lines.
+ *
+ * @return A pointer to the vector with the laid-out lines.
+ */
+ virtual const LineRun* const GetLines() const = 0;
+
+ /**
+ * @brief Retrieves the number of laid-out glyphs.
+ *
+ * @return The number of laid-out glyphs.
+ */
+ virtual Length GetNumberOfGlyphs() const = 0;
+
+ /**
+ * @brief Retrieves the laid-out glyphs.
+ *
+ * @return A pointer to the vector with the laid-out glyphs.
+ */
+ virtual const GlyphInfo* const GetGlyphs() const = 0;
+
+ /**
+ * @brief Retrieves the text layout.
+ *
+ * @return A pointer to the vector with the positions for each glyph.
+ */
+ virtual const Vector2* const GetLayout() const = 0;
+
+ /**
+ * @brief Retrieves the vector of colors.
+ *
+ * @return Pointer to the vector of colors.
+ */
+ virtual const Vector4* const GetColors() const = 0;
+
+ /**
+ * @brief Retrieves the vector of indices to the vector of colors.
+ *
+ * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
+ */
+ virtual const ColorIndex* const GetColorIndices() const = 0;
+
+ /**
+ * @brief Retrieves the text's default color.
+ *
+ * @return The default color.
+ */
+ virtual const Vector4& GetDefaultColor() const = 0;
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H
--- /dev/null
+/*
+ * 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.
+ * 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/text-model.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+ModelPtr Model::New()
+{
+ return ModelPtr( new Model() );
+}
+
+const Size& Model::GetControlSize() const
+{
+ return mVisualModel->mControlSize;
+}
+
+const Size& Model::GetLayoutSize() const
+{
+ return mVisualModel->GetLayoutSize();
+}
+
+const Vector2& Model::GetScrollPosition() const
+{
+ return mScrollPosition;
+}
+
+Layout::HorizontalAlignment Model::GetHorizontalAlignment() const
+{
+ return mHorizontalAlignment;
+}
+
+Layout::VerticalAlignment Model::GetVerticalAlignment() const
+{
+ return mVerticalAlignment;
+}
+
+bool Model::IsTextElideEnabled() const
+{
+ return mElideEnabled;
+}
+
+Length Model::GetNumberOfLines() const
+{
+ return mVisualModel->mLines.Count();
+}
+
+const LineRun* const Model::GetLines() const
+{
+ return mVisualModel->mLines.Begin();
+}
+
+Length Model::GetNumberOfGlyphs() const
+{
+ return mVisualModel->mGlyphs.Count();
+}
+
+const GlyphInfo* const Model::GetGlyphs() const
+{
+ return mVisualModel->mGlyphs.Begin();
+}
+
+const Vector2* const Model::GetLayout() const
+{
+ return mVisualModel->mGlyphPositions.Begin();
+}
+
+const Vector4* const Model::GetColors() const
+{
+ return mVisualModel->mColors.Begin();
+}
+
+const ColorIndex* const Model::GetColorIndices() const
+{
+ return mVisualModel->mColorIndices.Begin();
+}
+
+const Vector4& Model::GetDefaultColor() const
+{
+ return mVisualModel->mTextColor;
+}
+
+Model::Model()
+: mLogicalModel(),
+ mVisualModel(),
+ mScrollPosition(),
+ mHorizontalAlignment( Layout::HORIZONTAL_ALIGN_BEGIN ),
+ mVerticalAlignment( Layout::VERTICAL_ALIGN_TOP ),
+ mElideEnabled( false )
+{
+ mLogicalModel = LogicalModel::New();
+ mVisualModel = VisualModel::New();
+}
+
+Model::~Model()
+{
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_MODEL_H
+#define DALI_TOOLKIT_TEXT_MODEL_H
+
+/*
+ * 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.
+ * 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/object/ref-object.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/layouts/layout-alignment.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>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+// Forward declarations.
+class Model;
+
+typedef IntrusivePtr<Model> ModelPtr;
+
+/**
+ * @brief Implementation class used to retrieve the text's model from the text-controller.
+ */
+class Model : public RefObject, public ModelInterface
+{
+
+public: // Constructor.
+
+ /**
+ * @brief Create a new instance of a text Model.
+ *
+ * @return A pointer to a new text Model.
+ */
+ static ModelPtr New();
+
+public:
+
+ /**
+ * @copydoc ModelInterface::GetControlSize()
+ */
+ virtual const Size& GetControlSize() const;
+
+ /**
+ * @copydoc ModelInterface::GetLayoutSize()
+ */
+ virtual const Size& GetLayoutSize() const;
+
+ /**
+ * @copydoc ModelInterface::GetScrollPosition()
+ */
+ virtual const Vector2& GetScrollPosition() const;
+
+ /**
+ * @copydoc ModelInterface::GetHorizontalAlignment()
+ */
+ virtual Layout::HorizontalAlignment GetHorizontalAlignment() const;
+
+ /**
+ * @copydoc ModelInterface::GetVerticalAlignment()
+ */
+ virtual Layout::VerticalAlignment GetVerticalAlignment() const;
+
+ /**
+ * @copydoc ModelInterface::IsTextElideEnabled()
+ */
+ virtual bool IsTextElideEnabled() const;
+
+ /**
+ * @copydoc ModelInterface::GetNumberOfLines()
+ */
+ virtual Length GetNumberOfLines() const;
+
+ /**
+ * @copydoc ModelInterface::GetLines()
+ */
+ virtual const LineRun* const GetLines() const;
+
+ /**
+ * @copydoc ModelInterface::GetNumberOfGlyphs()
+ */
+ virtual Length GetNumberOfGlyphs() const;
+
+ /**
+ * @copydoc ModelInterface::GetGlyphs()
+ */
+ virtual const GlyphInfo* const GetGlyphs() const;
+
+ /**
+ * @copydoc ModelInterface::GetLayout()
+ */
+ virtual const Vector2* const GetLayout() const;
+
+ /**
+ * @copydoc ModelInterface::GetColors()
+ */
+ virtual const Vector4* const GetColors() const;
+
+ /**
+ * @copydoc ModelInterface::GetColorIndices()
+ */
+ virtual const ColorIndex* const GetColorIndices() const;
+
+ /**
+ * @copydoc ModelInterface::GetDefaultColor()
+ */
+ virtual const Vector4& GetDefaultColor() const;
+
+private: // Private contructors & copy operator.
+
+ /**
+ * @brief Private constructor.
+ */
+ Model();
+
+ // Undefined.
+ Model( const Model& handle );
+
+ // Undefined.
+ Model& operator=( const Model& handle );
+
+protected:
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ virtual ~Model();
+
+public:
+ LogicalModelPtr mLogicalModel; ///< Pointer to the logical model.
+ VisualModelPtr mVisualModel; ///< Pointer to the visual model.
+ /**
+ * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
+ * Typically this will have a negative value with scrolling occurs.
+ */
+ Vector2 mScrollPosition; ///< The text is offset by this position when scrolling.
+ Layout::HorizontalAlignment mHorizontalAlignment; ///< The layout's horizontal alignment.
+ Layout::VerticalAlignment mVerticalAlignment; ///< The layout's vertical alignment.
+ bool mElideEnabled:1; ///< Whether the text's elide is enabled.
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_MODEL_H
mTextColor( Color::BLACK ),
mShadowColor( Color::BLACK ),
mUnderlineColor( Color::BLACK ),
- mShadowOffset( Vector2::ZERO ),
+ mControlSize(),
+ mShadowOffset(),
mUnderlineHeight( 0.0f ),
mNaturalSize(),
mLayoutSize(),
Vector<Vector4> mColors; ///< Colors of the glyphs.
Vector<ColorIndex> mColorIndices; ///< Indices to the vector of colors for each glyphs.
- Vector2 mControlSize; ///< The size of the UI control the decorator is adding it's decorations to.
Vector4 mTextColor; ///< The text color
Vector4 mShadowColor; ///< Color of drop shadow
Vector4 mUnderlineColor; ///< Color of underline
+ Size mControlSize; ///< The size of the UI control.
Vector2 mShadowOffset; ///< Offset for drop shadow, 0 indicates no shadow
float mUnderlineHeight; ///< Fixed height for underline to override font metrics.
// EXTERNAL HEADER
#include <dali/devel-api/scripting/enum-helper.h>
-// #include <dali/devel-api/scripting/scripting.h>
// INTERNAL HEADER
#include <dali-toolkit/public-api/text/rendering-backend.h>
#include <dali-toolkit/public-api/visuals/text-visual-properties.h>
#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/internal/text/layouts/layout-alignment.h>
#include <dali-toolkit/internal/text/rendering/text-backend.h>
+#include <dali-toolkit/internal/text/text-effects-style.h>
+#include <dali-toolkit/internal/text/text-font-style.h>
#include <dali-toolkit/internal/text/text-view.h>
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
-#include <dali-toolkit/internal/text/text-font-style.h>
-#include <dali-toolkit/internal/text/text-effects-style.h>
-
-using Dali::Toolkit::Text::LayoutEngine;
namespace Dali
{
const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
{
- { "BEGIN", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN },
- { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
- { "END", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END },
+ { "BEGIN", Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN },
+ { "CENTER", Toolkit::Text::Layout::HORIZONTAL_ALIGN_CENTER },
+ { "END", Toolkit::Text::Layout::HORIZONTAL_ALIGN_END },
};
const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
const Scripting::StringEnum VERTICAL_ALIGNMENT_STRING_TABLE[] =
{
- { "TOP", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP },
- { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
- { "BOTTOM", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_BOTTOM },
+ { "TOP", Toolkit::Text::Layout::VERTICAL_ALIGN_TOP },
+ { "CENTER", Toolkit::Text::Layout::VERTICAL_ALIGN_CENTER },
+ { "BOTTOM", Toolkit::Text::Layout::VERTICAL_ALIGN_BOTTOM },
};
const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
-std::string GetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment )
+std::string GetHorizontalAlignment( Toolkit::Text::Layout::HorizontalAlignment alignment )
{
- const char* name = Scripting::GetEnumerationName<Toolkit::Text::LayoutEngine::HorizontalAlignment>( alignment,
- HORIZONTAL_ALIGNMENT_STRING_TABLE,
- HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+ const char* name = Scripting::GetEnumerationName<Toolkit::Text::Layout::HorizontalAlignment>( alignment,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
return std::string( name );
}
-std::string GetVerticalAlignment( LayoutEngine::VerticalAlignment alignment )
+std::string GetVerticalAlignment( Toolkit::Text::Layout::VerticalAlignment alignment )
{
- const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( alignment,
- VERTICAL_ALIGNMENT_STRING_TABLE,
- VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+ const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( alignment,
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
return std::string( name );
}
map.Insert( Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT, GetVerticalAlignment( mController->GetVerticalAlignment() ) );
- map.Insert( Toolkit::TextVisual::Property::TEXT_COLOR, mController->GetTextColor() );
+ map.Insert( Toolkit::TextVisual::Property::TEXT_COLOR, mController->GetDefaultColor() );
map.Insert( Toolkit::TextVisual::Property::ENABLE_MARKUP, mController->IsMarkupProcessorEnabled() );
}
}
- // Retrieve the layout engine to set whether to elide the text and set the cursor's width.
- Text::LayoutEngine& engine = mController->GetLayoutEngine();
-
// Elide the text if it exceeds the boundaries.
- engine.SetTextEllipsisEnabled( true );
+ mController->SetTextElideEnabled( true );
+
+ // Retrieve the layout engine to set the cursor's width.
+ Text::Layout::Engine& engine = mController->GetLayoutEngine();
// Sets 0 as cursor's width.
engine.SetCursorWidth( 0u ); // Do not layout space for the cursor.
}
case Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT:
{
- LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN );
- if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( propertyValue.Get< std::string >().c_str(),
- HORIZONTAL_ALIGNMENT_STRING_TABLE,
- HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
- alignment ) )
+ Toolkit::Text::Layout::HorizontalAlignment alignment( Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN );
+ if( Scripting::GetEnumeration< Toolkit::Text::Layout::HorizontalAlignment >( propertyValue.Get< std::string >().c_str(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
+ alignment ) )
{
mController->SetHorizontalAlignment( alignment );
}
}
case Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT:
{
- LayoutEngine::VerticalAlignment alignment( LayoutEngine::VERTICAL_ALIGN_BOTTOM );
- if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( propertyValue.Get< std::string >().c_str(),
- VERTICAL_ALIGNMENT_STRING_TABLE,
- VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
- alignment ) )
+ Toolkit::Text::Layout::VerticalAlignment alignment( Toolkit::Text::Layout::VERTICAL_ALIGN_BOTTOM );
+ if( Scripting::GetEnumeration< Toolkit::Text::Layout::VerticalAlignment >( propertyValue.Get< std::string >().c_str(),
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
+ alignment ) )
{
mController->SetVerticalAlignment( alignment );
}
}
case Toolkit::TextVisual::Property::TEXT_COLOR:
{
- const Vector4 textColor = propertyValue.Get< Vector4 >();
- if( mController->GetTextColor() != textColor )
+ const Vector4& textColor = propertyValue.Get< Vector4 >();
+ if( mController->GetDefaultColor() != textColor )
{
- mController->SetTextColor( textColor );
+ mController->SetDefaultColor( textColor );
mRenderer.Reset();
}
break;
{
case Property::VECTOR4:
{
- const Vector4 color = propertyValue.Get<Vector4>();
+ const Vector4& color = propertyValue.Get<Vector4>();
if( mController->GetUnderlineColor() != color )
{
mController->SetUnderlineColor( color );
{
case Property::VECTOR2:
{
- const Vector2 shadowOffset = propertyValue.Get<Vector2>();
+ const Vector2& shadowOffset = propertyValue.Get<Vector2>();
if( mController->GetShadowOffset() != shadowOffset )
{
mController->SetShadowOffset( shadowOffset );
}
case Property::VECTOR4:
{
- const Vector4 shadowColor = propertyValue.Get<Vector4>();
+ const Vector4& shadowColor = propertyValue.Get<Vector4>();
if( mController->GetShadowColor() != shadowColor )
{
mController->SetShadowColor( shadowColor );
}
case Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT:
{
- const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( mController->GetHorizontalAlignment(),
- HORIZONTAL_ALIGNMENT_STRING_TABLE,
- HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+ const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::HorizontalAlignment >( mController->GetHorizontalAlignment(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
if( name )
{
value = std::string( name );
}
case Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT:
{
- const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( mController->GetVerticalAlignment(),
- VERTICAL_ALIGNMENT_STRING_TABLE,
- VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+ const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( mController->GetVerticalAlignment(),
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
if( name )
{
value = std::string( name );
}
case Toolkit::TextVisual::Property::TEXT_COLOR:
{
- value = mController->GetTextColor();
+ value = mController->GetDefaultColor();
break;
}
case Toolkit::TextVisual::Property::ENABLE_MARKUP:
if( renderableActor )
{
- const Vector2& scrollOffset = mController->GetScrollPosition();
+ const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
renderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
self.Add( renderableActor );