From 39fc99671f79f683a834406e24edf485752c600d Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Tue, 19 Apr 2016 15:54:23 +0100 Subject: [PATCH] APIs for text editor. Change-Id: Id18e9f4f8d24f0f1c25f833962ed4cfaf4f7fe02 Signed-off-by: Victor Cebollada --- .../src/dali-toolkit/utc-Dali-TextEditor.cpp | 68 +++- .../src/dali-toolkit/utc-Dali-TextField.cpp | 50 +++ .../src/dali-toolkit/utc-Dali-TextLabel.cpp | 35 +- dali-toolkit/dali-toolkit.h | 1 + dali-toolkit/devel-api/file.list | 2 - .../controls/text-controls/text-editor-impl.cpp | 159 +++++++++ .../controls/text-controls/text-editor-impl.h | 2 +- .../controls/text-controls/text-field-impl.cpp | 121 +++++++ .../controls/text-controls/text-label-impl.cpp | 81 +++++ dali-toolkit/internal/file.list | 2 + dali-toolkit/internal/text/input-style.h | 44 ++- .../internal/text/layouts/layout-engine.cpp | 13 + dali-toolkit/internal/text/layouts/layout-engine.h | 14 + .../internal/text/property-string-parser.cpp | 105 ++++++ .../internal/text/property-string-parser.h | 75 +++++ .../text/rendering/atlas/text-atlas-renderer.cpp | 6 +- dali-toolkit/internal/text/text-controller-impl.h | 36 ++ dali-toolkit/internal/text/text-controller.cpp | 181 ++++++++++ dali-toolkit/internal/text/text-controller.h | 156 +++++++++ dali-toolkit/internal/text/text-effects-style.cpp | 363 +++++++++++++++++++++ dali-toolkit/internal/text/text-effects-style.h | 132 ++++++++ dali-toolkit/internal/text/text-font-style.cpp | 65 +--- dali-toolkit/internal/text/text-font-style.h | 2 + .../controls/text-controls/text-editor.cpp | 2 +- .../controls/text-controls/text-editor.h | 70 ++-- .../public-api/controls/text-controls/text-field.h | 14 +- .../public-api/controls/text-controls/text-label.h | 54 ++- dali-toolkit/public-api/file.list | 2 + .../text-editor.md | 10 + .../text-field.md | 10 +- .../text-label.md | 21 +- 31 files changed, 1749 insertions(+), 147 deletions(-) create mode 100644 dali-toolkit/internal/text/property-string-parser.cpp create mode 100644 dali-toolkit/internal/text/property-string-parser.h create mode 100644 dali-toolkit/internal/text/text-effects-style.cpp create mode 100644 dali-toolkit/internal/text/text-effects-style.h rename dali-toolkit/{devel-api => public-api}/controls/text-controls/text-editor.cpp (95%) rename dali-toolkit/{devel-api => public-api}/controls/text-controls/text-editor.h (64%) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index 809b07b..b1cc593 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -22,7 +22,6 @@ #include #include #include -#include ///< @todo to be removed when text-editor is added to the dali-toolkit.h using namespace Dali; using namespace Toolkit; @@ -71,6 +70,17 @@ const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFon const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle"; const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize"; +const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing"; +const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing"; +const char* const PROPERTY_NAME_UNDERLINE = "underline"; +const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline"; +const char* const PROPERTY_NAME_SHADOW = "shadow"; +const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow"; +const char* const PROPERTY_NAME_EMBOSS = "emboss"; +const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss"; +const char* const PROPERTY_NAME_OUTLINE = "outline"; +const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline"; + const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND; const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color. @@ -180,7 +190,7 @@ int UtcDaliToolkitTextEditorCopyConstructorP(void) TextEditor copy( textEditor ); DALI_TEST_CHECK( copy ); - DALI_TEST_CHECK( copy.GetProperty( TextLabel::Property::TEXT ) == textEditor.GetProperty( TextLabel::Property::TEXT ) ); + DALI_TEST_CHECK( copy.GetProperty( TextEditor::Property::TEXT ) == textEditor.GetProperty( TextEditor::Property::TEXT ) ); END_TEST; } @@ -245,6 +255,18 @@ int UtcDaliTextEditorGetPropertyP(void) DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY ); DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE ); DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE ); + + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE ); + END_TEST; } @@ -362,6 +384,48 @@ int UtcDaliTextEditorSetPropertyP(void) editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f ); DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + // Check the line spacing property + DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f ); + DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + // Check the input line spacing property + DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f ); + DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + // Check the underline property + editor.SetProperty( TextEditor::Property::UNDERLINE, "Underline properties" ); + DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::UNDERLINE ), std::string("Underline properties"), TEST_LOCATION ); + + // Check the input underline property + editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" ); + DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION ); + + // Check the shadow property + editor.SetProperty( TextEditor::Property::SHADOW, "Shadow properties" ); + DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::SHADOW ), std::string("Shadow properties"), TEST_LOCATION ); + + // Check the input shadow property + editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" ); + DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION ); + + // Check the emboss property + editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" ); + DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION ); + + // Check the input emboss property + editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" ); + DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION ); + + // Check the outline property + editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" ); + DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION ); + + // Check the input outline property + editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" ); + DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION ); + END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index 2498c57..22bc525 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -79,6 +79,15 @@ const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFon const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle"; const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize"; +const char* const PROPERTY_NAME_UNDERLINE = "underline"; +const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline"; +const char* const PROPERTY_NAME_SHADOW = "shadow"; +const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow"; +const char* const PROPERTY_NAME_EMBOSS = "emboss"; +const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss"; +const char* const PROPERTY_NAME_OUTLINE = "outline"; +const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline"; + const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND; const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f ); @@ -271,6 +280,15 @@ int UtcDaliTextFieldGetPropertyP(void) DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE ); + DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE ); + DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE ); + DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW ); + DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW ); + DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS ); + DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS ); + DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE ); + DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE ); + END_TEST; } @@ -415,6 +433,38 @@ int UtcDaliTextFieldSetPropertyP(void) field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + // Check the underline property + field.SetProperty( TextField::Property::UNDERLINE, "Underline properties" ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::UNDERLINE ), std::string("Underline properties"), TEST_LOCATION ); + + // Check the input underline property + field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION ); + + // Check the shadow property + field.SetProperty( TextField::Property::SHADOW, "Shadow properties" ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::SHADOW ), std::string("Shadow properties"), TEST_LOCATION ); + + // Check the input shadow property + field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION ); + + // Check the emboss property + field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION ); + + // Check the input emboss property + field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION ); + + // Check the outline property + field.SetProperty( TextField::Property::OUTLINE, "Outline properties" ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION ); + + // Check the input outline property + field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION ); + END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index 08f085d..2f71832 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -56,6 +56,12 @@ const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed"; const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount"; const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap"; +const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing"; +const char* const PROPERTY_NAME_UNDERLINE = "underline"; +const char* const PROPERTY_NAME_SHADOW = "shadow"; +const char* const PROPERTY_NAME_EMBOSS = "emboss"; +const char* const PROPERTY_NAME_OUTLINE = "outline"; + const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND; } // namespace @@ -160,6 +166,11 @@ int UtcDaliToolkitTextLabelGetPropertyP(void) DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED ); DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ); DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP ); + DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING ); + DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE ); + DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW ); + DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS ); + DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE ); END_TEST; } @@ -215,7 +226,7 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED ); DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION ); label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); TextLabel label2 = TextLabel::New( "New text" ); DALI_TEST_CHECK( label2 ); @@ -240,6 +251,28 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION ); label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP ); DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION ); + + // Check the line spacing property + DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f ); + DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + // Check the underline property + label.SetProperty( TextLabel::Property::UNDERLINE, "Underline properties" ); + DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::UNDERLINE ), std::string("Underline properties"), TEST_LOCATION ); + + // Check the shadow property + label.SetProperty( TextLabel::Property::SHADOW, "Shadow properties" ); + DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::SHADOW ), std::string("Shadow properties"), TEST_LOCATION ); + + // Check the emboss property + label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" ); + DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION ); + + // Check the outline property + label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" ); + DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION ); + END_TEST; } diff --git a/dali-toolkit/dali-toolkit.h b/dali-toolkit/dali-toolkit.h index 637d534..1883e2f 100644 --- a/dali-toolkit/dali-toolkit.h +++ b/dali-toolkit/dali-toolkit.h @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include diff --git a/dali-toolkit/devel-api/file.list b/dali-toolkit/devel-api/file.list index e6b7576..e6d9397 100755 --- a/dali-toolkit/devel-api/file.list +++ b/dali-toolkit/devel-api/file.list @@ -15,7 +15,6 @@ devel_api_src_files = \ $(devel_api_src_dir)/controls/shadow-view/shadow-view.cpp \ $(devel_api_src_dir)/controls/slider/slider.cpp \ $(devel_api_src_dir)/controls/super-blur-view/super-blur-view.cpp \ - $(devel_api_src_dir)/controls/text-controls/text-editor.cpp \ $(devel_api_src_dir)/controls/text-controls/text-selection-popup.cpp \ $(devel_api_src_dir)/controls/text-controls/text-selection-toolbar.cpp \ $(devel_api_src_dir)/controls/tool-bar/tool-bar.cpp \ @@ -103,7 +102,6 @@ devel_api_super_blur_view_header_files = \ $(devel_api_src_dir)/controls/super-blur-view/super-blur-view.h devel_api_text_controls_header_files = \ - $(devel_api_src_dir)/controls/text-controls/text-editor.h \ $(devel_api_src_dir)/controls/text-controls/text-selection-popup.h \ $(devel_api_src_dir)/controls/text-controls/text-selection-toolbar.h diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index 57a66ca..52d3256 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -107,6 +108,16 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputColor", DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputFontFamily", STRING, INPUT_FONT_FAMILY ) DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputFontStyle", STRING, INPUT_FONT_STYLE ) DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputPointSize", FLOAT, INPUT_POINT_SIZE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "lineSpacing", FLOAT, LINE_SPACING ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputLineSpacing", FLOAT, INPUT_LINE_SPACING ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "underline", STRING, UNDERLINE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputUnderline", STRING, INPUT_UNDERLINE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "shadow", STRING, SHADOW ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputShadow", STRING, INPUT_SHADOW ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "emboss", STRING, EMBOSS ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputEmboss", STRING, INPUT_EMBOSS ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "outline", STRING, OUTLINE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputOutline", STRING, INPUT_OUTLINE ) DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED ) @@ -482,6 +493,98 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P } break; } + case Toolkit::TextEditor::Property::LINE_SPACING: + { + if( impl.mController ) + { + const float lineSpacing = value.Get(); + impl.mController->SetDefaultLineSpacing( lineSpacing ); + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_LINE_SPACING: + { + if( impl.mController ) + { + const float lineSpacing = value.Get(); + impl.mController->SetInputLineSpacing( lineSpacing ); + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::UNDERLINE: + { + const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_UNDERLINE: + { + const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::SHADOW: + { + const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_SHADOW: + { + const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::EMBOSS: + { + const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_EMBOSS: + { + const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::OUTLINE: + { + const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_OUTLINE: + { + const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } } // switch } // texteditor } @@ -727,6 +830,62 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind } break; } + case Toolkit::TextEditor::Property::LINE_SPACING: + { + if( impl.mController ) + { + value = impl.mController->GetDefaultLineSpacing(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_LINE_SPACING: + { + if( impl.mController ) + { + value = impl.mController->GetInputLineSpacing(); + } + break; + } + case Toolkit::TextEditor::Property::UNDERLINE: + { + GetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextEditor::Property::INPUT_UNDERLINE: + { + GetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT ); + break; + } + case Toolkit::TextEditor::Property::SHADOW: + { + GetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextEditor::Property::INPUT_SHADOW: + { + GetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT ); + break; + } + case Toolkit::TextEditor::Property::EMBOSS: + { + GetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextEditor::Property::INPUT_EMBOSS: + { + GetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT ); + break; + } + case Toolkit::TextEditor::Property::OUTLINE: + { + GetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextEditor::Property::INPUT_OUTLINE: + { + GetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT ); + break; + } } //switch } diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h index b10b78b..f00d66d 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h @@ -20,7 +20,7 @@ // INTERNAL INCLUDES #include -#include +#include #include #include #include diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index f88dcb7..8e09605 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -123,6 +124,14 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enableMarkup", DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputFontFamily", STRING, INPUT_FONT_FAMILY ) DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputFontStyle", STRING, INPUT_FONT_STYLE ) DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputPointSize", FLOAT, INPUT_POINT_SIZE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "underline", STRING, UNDERLINE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputUnderline", STRING, INPUT_UNDERLINE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadow", STRING, SHADOW ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputShadow", STRING, INPUT_SHADOW ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "emboss", STRING, EMBOSS ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputEmboss", STRING, INPUT_EMBOSS ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "outline", STRING, OUTLINE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputOutline", STRING, INPUT_OUTLINE ) DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED ) DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED ) @@ -618,6 +627,78 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr } break; } + case Toolkit::TextField::Property::UNDERLINE: + { + const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::INPUT_UNDERLINE: + { + const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::SHADOW: + { + const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::INPUT_SHADOW: + { + const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::EMBOSS: + { + const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::INPUT_EMBOSS: + { + const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::OUTLINE: + { + const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::INPUT_OUTLINE: + { + const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } } // switch } // textfield } @@ -938,6 +1019,46 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } break; } + case Toolkit::TextField::Property::UNDERLINE: + { + GetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextField::Property::INPUT_UNDERLINE: + { + GetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT ); + break; + } + case Toolkit::TextField::Property::SHADOW: + { + GetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextField::Property::INPUT_SHADOW: + { + GetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT ); + break; + } + case Toolkit::TextField::Property::EMBOSS: + { + GetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextField::Property::INPUT_EMBOSS: + { + GetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT ); + break; + } + case Toolkit::TextField::Property::OUTLINE: + { + GetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextField::Property::INPUT_OUTLINE: + { + GetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT ); + break; + } } //switch } diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index cefe7ad..2e3278b 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -25,7 +25,9 @@ // INTERNAL INCLUDES #include #include +#include #include +#include #include #include #include @@ -99,6 +101,11 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "enableAutoScroll", BOOLEAN, DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollSpeed", INTEGER, AUTO_SCROLL_SPEED ) DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollLoopCount", INTEGER, AUTO_SCROLL_LOOP_COUNT ) DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollGap", FLOAT, AUTO_SCROLL_GAP ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "lineSpacing", FLOAT, LINE_SPACING ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underline", STRING, UNDERLINE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "shadow", STRING, SHADOW ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "emboss", STRING, EMBOSS ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "outline", STRING, OUTLINE ) DALI_TYPE_REGISTRATION_END() @@ -372,6 +379,52 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr impl.mTextScroller->SetGap( value.Get() ); break; } + case Toolkit::TextLabel::Property::LINE_SPACING: + { + if( impl.mController ) + { + const float lineSpacing = value.Get(); + impl.mController->SetDefaultLineSpacing( lineSpacing ); + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextLabel::Property::UNDERLINE: + { + const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextLabel::Property::SHADOW: + { + const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextLabel::Property::EMBOSS: + { + const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextLabel::Property::OUTLINE: + { + const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } } } } @@ -553,6 +606,34 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } break; } + case Toolkit::TextLabel::Property::LINE_SPACING: + { + if( impl.mController ) + { + value = impl.mController->GetDefaultLineSpacing(); + } + break; + } + case Toolkit::TextLabel::Property::UNDERLINE: + { + GetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextLabel::Property::SHADOW: + { + GetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextLabel::Property::EMBOSS: + { + GetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextLabel::Property::OUTLINE: + { + GetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } } } diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index 7fba3eb..3c71f0b 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -100,11 +100,13 @@ toolkit_src_files = \ $(toolkit_src_dir)/text/markup-processor-font.cpp \ $(toolkit_src_dir)/text/markup-processor-helper-functions.cpp \ $(toolkit_src_dir)/text/multi-language-support.cpp \ + $(toolkit_src_dir)/text/property-string-parser.cpp \ $(toolkit_src_dir)/text/segmentation.cpp \ $(toolkit_src_dir)/text/shaper.cpp \ $(toolkit_src_dir)/text/text-control-interface.cpp \ $(toolkit_src_dir)/text/text-controller.cpp \ $(toolkit_src_dir)/text/text-controller-impl.cpp \ + $(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-scroller.cpp \ diff --git a/dali-toolkit/internal/text/input-style.h b/dali-toolkit/internal/text/input-style.h index 5d7aead..30ce38c 100644 --- a/dali-toolkit/internal/text/input-style.h +++ b/dali-toolkit/internal/text/input-style.h @@ -46,31 +46,45 @@ struct InputStyle width( TextAbstraction::FontWidth::NORMAL ), slant( TextAbstraction::FontSlant::NORMAL ), size( 0.f ), + lineSpacing( 0.f ), + underlineProperties(), + shadowProperties(), + embossProperties(), + outlineProperties(), isDefaultColor( true ), familyDefined( false ), weightDefined( false ), widthDefined( false ), slantDefined( false ), - sizeDefined( false ) + sizeDefined( false ), + lineSpacingDefined( false ) {} ~InputStyle() {}; - Vector4 textColor; ///< The text's color. - std::string fontStyle; ///< The font's style string. - std::string familyName; ///< The font's family name. - FontWeight weight; ///< The font's weight. - FontWidth width; ///< The font's width. - FontSlant slant; ///< The font's slant. - float size; ///< The font's size. - - bool isDefaultColor : 1; ///< Whether the text's color is the default. - bool familyDefined : 1; ///< Whether the font's family is defined. - bool weightDefined : 1; ///< Whether the font's weight is defined. - bool widthDefined : 1; ///< Whether the font's width is defined. - bool slantDefined : 1; ///< Whether the font's slant is defined. - bool sizeDefined : 1; ///< Whether the font's size is defined. + Vector4 textColor; ///< The text's color. + std::string fontStyle; ///< The font's style string. + std::string familyName; ///< The font's family name. + FontWeight weight; ///< The font's weight. + FontWidth width; ///< The font's width. + FontSlant slant; ///< The font's slant. + float size; ///< The font's size. + + float lineSpacing; ///< The line's spacing. + std::string underlineProperties; ///< The underline properties string. + std::string shadowProperties; ///< The shadow properties string. + std::string embossProperties; ///< The emboss properties string. + std::string outlineProperties; ///< The outline properties string. + + bool isDefaultColor : 1; ///< Whether the text's color is the default. + bool familyDefined : 1; ///< Whether the font's family is defined. + bool weightDefined : 1; ///< Whether the font's weight is defined. + bool widthDefined : 1; ///< Whether the font's width is defined. + bool slantDefined : 1; ///< Whether the font's slant is defined. + bool sizeDefined : 1; ///< Whether the font's size is defined. + + bool lineSpacingDefined : 1; ///< Whether the line spacing is defined. }; } // namespace Text diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index ac9110e..b992623 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -47,6 +47,7 @@ namespace const float MAX_FLOAT = std::numeric_limits::max(); const bool RTL = true; const float CURSOR_WIDTH = 1.f; +const float LINE_SPACING= 0.f; } //namespace @@ -104,6 +105,7 @@ struct LayoutEngine::Impl mHorizontalAlignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN ), mVerticalAlignment( LayoutEngine::VERTICAL_ALIGN_TOP ), mCursorWidth( CURSOR_WIDTH ), + mDefaultLineSpacing( LINE_SPACING ), mEllipsisEnabled( false ) { } @@ -1213,6 +1215,7 @@ struct LayoutEngine::Impl LayoutEngine::HorizontalAlignment mHorizontalAlignment; LayoutEngine::VerticalAlignment mVerticalAlignment; float mCursorWidth; + float mDefaultLineSpacing; IntrusivePtr mMetrics; @@ -1320,6 +1323,16 @@ void LayoutEngine::Align( const Size& size, lines ); } +void LayoutEngine::SetDefaultLineSpacing( float lineSpacing ) +{ + mImpl->mDefaultLineSpacing = lineSpacing; +} + +float LayoutEngine::GetDefaultLineSpacing() const +{ + return mImpl->mDefaultLineSpacing; +} + } // namespace Text } // namespace Toolkit diff --git a/dali-toolkit/internal/text/layouts/layout-engine.h b/dali-toolkit/internal/text/layouts/layout-engine.h index e672c53..79daa23 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.h +++ b/dali-toolkit/internal/text/layouts/layout-engine.h @@ -192,6 +192,20 @@ public: Length numberOfCharacters, Vector& lines ); + /** + * @brief Sets the default line spacing. + * + * @param[in] lineSpacing The line spacing. + */ + void SetDefaultLineSpacing( float lineSpacing ); + + /** + * @brief Retrieves the default line spacing. + * + * @return The line spacing. + */ + float GetDefaultLineSpacing() const; + private: // Undefined diff --git a/dali-toolkit/internal/text/property-string-parser.cpp b/dali-toolkit/internal/text/property-string-parser.cpp new file mode 100644 index 0000000..c120e00 --- /dev/null +++ b/dali-toolkit/internal/text/property-string-parser.cpp @@ -0,0 +1,105 @@ +/* + * 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. + * + */ + +// FILE HEADER +#include + +// EXTERNAL HEADERS +#include + +// INTERNAL INCLUDES +#include +#include +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +void CreatePropertyMap( const TreeNode* const node, Property::Map& map ) +{ + switch( node->GetType() ) + { + case TreeNode::IS_NULL: + case TreeNode::OBJECT: + case TreeNode::ARRAY: // FALL THROUGH + { + break; + } + case TreeNode::STRING: + { + map.Insert( node->GetName(), Property::Value( node->GetString() ) ); + break; + } + case TreeNode::INTEGER: + case TreeNode::FLOAT: + case TreeNode::BOOLEAN: // FALL THROUGH + { + break; + } + } + + for( TreeNode::ConstIterator it = node->CBegin(), endIt = node->CEnd(); it != endIt; ++it ) + { + const TreeNode::KeyNodePair& pair = *it; + CreatePropertyMap( &pair.second, map ); + } +} + +void ParsePropertyString( const std::string& property, Property::Map& map ) +{ + Toolkit::JsonParser parser = Toolkit::JsonParser::New(); + + if( parser.Parse( property ) ) + { + const TreeNode* const node = parser.GetRoot(); + + CreatePropertyMap( node, map ); + } +} + +void StringOffsetToVector2( const std::string& offsetStr, + Vector2& offset ) +{ + offset = Vector2::ZERO; + + unsigned int wsIndex = 0u; + for( std::string::const_iterator it = offsetStr.begin(), + endIt = offsetStr.end(); + it != endIt; + ++it, ++wsIndex ) + { + if( *it == ' ' ) + { + break; + } + } + + offset[0] = StringToFloat( offsetStr.c_str() ); + offset[1] = StringToFloat( offsetStr.c_str() + wsIndex ); +} + +} //namespace Text + +} //namespace Toolkit + +} //namespace Dali diff --git a/dali-toolkit/internal/text/property-string-parser.h b/dali-toolkit/internal/text/property-string-parser.h new file mode 100644 index 0000000..b6ebf27 --- /dev/null +++ b/dali-toolkit/internal/text/property-string-parser.h @@ -0,0 +1,75 @@ +#ifndef __DALI_TOOLKIT_PROPERTY_STRING_PARSER_H__ +#define __DALI_TOOLKIT_PROPERTY_STRING_PARSER_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 + +// INTERNAL INCLUDES + +namespace Dali +{ + +// Forward declaration +struct Vector2; + +namespace Toolkit +{ + +// Forward declaration +class TreeNode; + +namespace Text +{ + +/** + * @brief Creates a map with pairs 'key,value' with the property's parameters. + * + * @param[in] node Data structure with the property's parameters. + * @param[out] map A map with the property's parameters. + * + */ +void CreatePropertyMap( const TreeNode* const node, Property::Map& map ); + +/** + * @brief Parses a property string. + * + * @param[in] property A property string. + * @param[out] map A map with the property's parameters. + * + */ +void ParsePropertyString( const std::string& property, Property::Map& map ); + +/** + * @brief Converts an offset packed inside a string into a Vector2. + * + * @param[in] offsetStr The offset packed inside a string. + * @param[out] offset The offset packed in a Vector2. + * + */ +void StringOffsetToVector2( const std::string& offsetStr, + Vector2& offset ); + +} //namespace Text + +} //namespace Toolkit + +} //namespace Dali + +#endif //__DALI_TOOLKIT_PROPERTY_STRING_PARSER_H__ diff --git a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp index 32ab39b..f2e5596 100644 --- a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp +++ b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp @@ -689,22 +689,26 @@ struct AtlasRenderer::Impl vert.mPosition.y = baseLine; vert.mTexCoords.x = ZERO; vert.mTexCoords.y = ZERO; + vert.mColor = underlineColor; newMesh.mVertices.PushBack( vert ); vert.mPosition.x = brx; vert.mPosition.y = baseLine; vert.mTexCoords.x = u; + vert.mColor = underlineColor; newMesh.mVertices.PushBack( vert ); vert.mPosition.x = tlx; vert.mPosition.y = baseLine + thickness; vert.mTexCoords.x = ZERO; vert.mTexCoords.y = v; + vert.mColor = underlineColor; newMesh.mVertices.PushBack( vert ); vert.mPosition.x = brx; vert.mPosition.y = baseLine + thickness; vert.mTexCoords.x = u; + vert.mColor = underlineColor; newMesh.mVertices.PushBack( vert ); // Six indices in counter clockwise winding @@ -716,8 +720,6 @@ struct AtlasRenderer::Impl newMesh.mIndices.PushBack( faceIndex + 1u ); faceIndex += 4; - vert.mColor = underlineColor; - Toolkit::Internal::AtlasMeshFactory::AppendMesh( meshRecords[ index ].mMesh, newMesh ); } } diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index 2031ab5..dfc6293 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -259,6 +259,30 @@ struct TextUpdateInfo } }; +struct UnderlineDefaults +{ + std::string properties; + // TODO: complete with underline parameters. +}; + +struct ShadowDefaults +{ + std::string properties; + // TODO: complete with shadow parameters. +}; + +struct EmbossDefaults +{ + std::string properties; + // TODO: complete with emboss parameters. +}; + +struct OutlineDefaults +{ + std::string properties; + // TODO: complete with outline parameters. +}; + struct Controller::Impl { Impl( ControlInterface& controlInterface ) @@ -266,6 +290,10 @@ struct Controller::Impl mLogicalModel(), mVisualModel(), mFontDefaults( NULL ), + mUnderlineDefaults( NULL ), + mShadowDefaults( NULL ), + mEmbossDefaults( NULL ), + mOutlineDefaults( NULL ), mEventData( NULL ), mFontClient(), mClipboard(), @@ -304,6 +332,10 @@ struct Controller::Impl ~Impl() { delete mFontDefaults; + delete mUnderlineDefaults; + delete mShadowDefaults; + delete mEmbossDefaults; + delete mOutlineDefaults; delete mEventData; } @@ -616,6 +648,10 @@ public: LogicalModelPtr mLogicalModel; ///< Pointer to the logical model. VisualModelPtr mVisualModel; ///< Pointer to the visual 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. + EmbossDefaults* mEmbossDefaults; ///< Avoid allocating this when the user does not specify emboss parameters. + OutlineDefaults* mOutlineDefaults; ///< Avoid allocating this when the user does not specify outline parameters. EventData* mEventData; ///< Avoid allocating everything for text input until EnableTextInput(). TextAbstraction::FontClient mFontClient; ///< Handle to the font client. Clipboard mClipboard; ///< Handle to the system clipboard diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 09a4441..d99e982 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -672,6 +672,26 @@ const Vector4& Controller::GetShadowColor() const return mImpl->mVisualModel->GetShadowColor(); } +void Controller::SetDefaultShadowProperties( const std::string& shadowProperties ) +{ + if( NULL == mImpl->mShadowDefaults ) + { + mImpl->mShadowDefaults = new ShadowDefaults(); + } + + mImpl->mShadowDefaults->properties = shadowProperties; +} + +const std::string& Controller::GetDefaultShadowProperties() const +{ + if( NULL != mImpl->mShadowDefaults ) + { + return mImpl->mShadowDefaults->properties; + } + + return EMPTY_STRING; +} + void Controller::SetUnderlineColor( const Vector4& color ) { mImpl->mVisualModel->SetUnderlineColor( color ); @@ -708,6 +728,77 @@ float Controller::GetUnderlineHeight() const return mImpl->mVisualModel->GetUnderlineHeight(); } +void Controller::SetDefaultUnderlineProperties( const std::string& underlineProperties ) +{ + if( NULL == mImpl->mUnderlineDefaults ) + { + mImpl->mUnderlineDefaults = new UnderlineDefaults(); + } + + mImpl->mUnderlineDefaults->properties = underlineProperties; +} + +const std::string& Controller::GetDefaultUnderlineProperties() const +{ + if( NULL != mImpl->mUnderlineDefaults ) + { + return mImpl->mUnderlineDefaults->properties; + } + + return EMPTY_STRING; +} + +void Controller::SetDefaultEmbossProperties( const std::string& embossProperties ) +{ + if( NULL == mImpl->mEmbossDefaults ) + { + mImpl->mEmbossDefaults = new EmbossDefaults(); + } + + mImpl->mEmbossDefaults->properties = embossProperties; +} + +const std::string& Controller::GetDefaultEmbossProperties() const +{ + if( NULL != mImpl->mEmbossDefaults ) + { + return mImpl->mEmbossDefaults->properties; + } + + return EMPTY_STRING; +} + +void Controller::SetDefaultOutlineProperties( const std::string& outlineProperties ) +{ + if( NULL == mImpl->mOutlineDefaults ) + { + mImpl->mOutlineDefaults = new OutlineDefaults(); + } + + mImpl->mOutlineDefaults->properties = outlineProperties; +} + +const std::string& Controller::GetDefaultOutlineProperties() const +{ + if( NULL != mImpl->mOutlineDefaults ) + { + return mImpl->mOutlineDefaults->properties; + } + + return EMPTY_STRING; +} + +void Controller::SetDefaultLineSpacing( float lineSpacing ) +{ + //TODO finish implementation + mImpl->mLayoutEngine.SetDefaultLineSpacing( lineSpacing ); +} + +float Controller::GetDefaultLineSpacing() const +{ + return mImpl->mLayoutEngine.GetDefaultLineSpacing(); +} + void Controller::SetInputColor( const Vector4& color ) { if( NULL != mImpl->mEventData ) @@ -1044,6 +1135,96 @@ float Controller::GetInputFontPointSize() const return GetDefaultPointSize(); } +void Controller::SetInputLineSpacing( float lineSpacing ) +{ + if( NULL != mImpl->mEventData ) + { + mImpl->mEventData->mInputStyle.lineSpacing = lineSpacing; + } +} + +float Controller::GetInputLineSpacing() const +{ + if( NULL != mImpl->mEventData ) + { + return mImpl->mEventData->mInputStyle.lineSpacing; + } + + return 0.f; +} + +void Controller::SetInputShadowProperties( const std::string& shadowProperties ) +{ + if( NULL != mImpl->mEventData ) + { + mImpl->mEventData->mInputStyle.shadowProperties = shadowProperties; + } +} + +const std::string& Controller::GetInputShadowProperties() const +{ + if( NULL != mImpl->mEventData ) + { + return mImpl->mEventData->mInputStyle.shadowProperties; + } + + return GetDefaultShadowProperties(); +} + +void Controller::SetInputUnderlineProperties( const std::string& underlineProperties ) +{ + if( NULL != mImpl->mEventData ) + { + mImpl->mEventData->mInputStyle.underlineProperties = underlineProperties; + } +} + +const std::string& Controller::GetInputUnderlineProperties() const +{ + if( NULL != mImpl->mEventData ) + { + return mImpl->mEventData->mInputStyle.underlineProperties; + } + + return GetDefaultUnderlineProperties(); +} + +void Controller::SetInputEmbossProperties( const std::string& embossProperties ) +{ + if( NULL != mImpl->mEventData ) + { + mImpl->mEventData->mInputStyle.embossProperties = embossProperties; + } +} + +const std::string& Controller::GetInputEmbossProperties() const +{ + if( NULL != mImpl->mEventData ) + { + return mImpl->mEventData->mInputStyle.embossProperties; + } + + return GetDefaultEmbossProperties(); +} + +void Controller::SetInputOutlineProperties( const std::string& outlineProperties ) +{ + if( NULL != mImpl->mEventData ) + { + mImpl->mEventData->mInputStyle.outlineProperties = outlineProperties; + } +} + +const std::string& Controller::GetInputOutlineProperties() const +{ + if( NULL != mImpl->mEventData ) + { + return mImpl->mEventData->mInputStyle.outlineProperties; + } + + return GetDefaultOutlineProperties(); +} + void Controller::SetEnableCursorBlink( bool enable ) { DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "TextInput disabled" ); diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index 5a96349..d035397 100644 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -390,6 +390,22 @@ public: const Vector4& GetShadowColor() const; /** + * @brief Sets the shadow's properties string. + * + * @note The string is stored to be recovered. + * + * @param[in] shadowProperties The shadow's properties string. + */ + void SetDefaultShadowProperties( const std::string& shadowProperties ); + + /** + * @brief Retrieves the shadow's properties string. + * + * @return The shadow's properties string. + */ + const std::string& GetDefaultShadowProperties() const; + + /** * @brief Set the underline color. * * @param[in] color color of underline. @@ -432,6 +448,68 @@ public: float GetUnderlineHeight() const; /** + * @brief Sets the underline's properties string. + * + * @note The string is stored to be recovered. + * + * @param[in] underlineProperties The underline's properties string. + */ + void SetDefaultUnderlineProperties( const std::string& underlineProperties ); + + /** + * @brief Retrieves the underline's properties string. + * + * @return The underline's properties string. + */ + const std::string& GetDefaultUnderlineProperties() const; + + /** + * @brief Sets the emboss's properties string. + * + * @note The string is stored to be recovered. + * + * @param[in] embossProperties The emboss's properties string. + */ + void SetDefaultEmbossProperties( const std::string& embossProperties ); + + /** + * @brief Retrieves the emboss's properties string. + * + * @return The emboss's properties string. + */ + const std::string& GetDefaultEmbossProperties() const; + + /** + * @brief Sets the outline's properties string. + * + * @note The string is stored to be recovered. + * + * @param[in] outlineProperties The outline's properties string. + */ + void SetDefaultOutlineProperties( const std::string& outlineProperties ); + + /** + * @brief Retrieves the outline's properties string. + * + * @return The outline's properties string. + */ + const std::string& GetDefaultOutlineProperties() const; + + /** + * @brief Sets the default line spacing. + * + * @param[in] lineSpacing The line spacing. + */ + void SetDefaultLineSpacing( float lineSpacing ); + + /** + * @brief Retrieves the default line spacing. + * + * @return The line spacing. + */ + float GetDefaultLineSpacing() const; + + /** * @brief Sets the input text's color. * * @param[in] color The input text's color. @@ -530,6 +608,84 @@ public: float GetInputFontPointSize() const; /** + * @brief Sets the input line spacing. + * + * @param[in] lineSpacing The line spacing. + */ + void SetInputLineSpacing( float lineSpacing ); + + /** + * @brief Retrieves the input line spacing. + * + * @return The line spacing. + */ + float GetInputLineSpacing() const; + + /** + * @brief Sets the input shadow's properties string. + * + * @note The string is stored to be recovered. + * + * @param[in] shadowProperties The shadow's properties string. + */ + void SetInputShadowProperties( const std::string& shadowProperties ); + + /** + * @brief Retrieves the input shadow's properties string. + * + * @return The shadow's properties string. + */ + const std::string& GetInputShadowProperties() const; + + /** + * @brief Sets the input underline's properties string. + * + * @note The string is stored to be recovered. + * + * @param[in] underlineProperties The underline's properties string. + */ + void SetInputUnderlineProperties( const std::string& underlineProperties ); + + /** + * @brief Retrieves the input underline's properties string. + * + * @return The underline's properties string. + */ + const std::string& GetInputUnderlineProperties() const; + + /** + * @brief Sets the input emboss's properties string. + * + * @note The string is stored to be recovered. + * + * @param[in] embossProperties The emboss's properties string. + */ + void SetInputEmbossProperties( const std::string& embossProperties ); + + /** + * @brief Retrieves the input emboss's properties string. + * + * @return The emboss's properties string. + */ + const std::string& GetInputEmbossProperties() const; + + /** + * @brief Sets input the outline's properties string. + * + * @note The string is stored to be recovered. + * + * @param[in] outlineProperties The outline's properties string. + */ + void SetInputOutlineProperties( const std::string& outlineProperties ); + + /** + * @brief Retrieves the input outline's properties string. + * + * @return The outline's properties string. + */ + const std::string& GetInputOutlineProperties() const; + + /** * @brief Called to enable/disable cursor blink. * * @note Only editable controls should calls this. diff --git a/dali-toolkit/internal/text/text-effects-style.cpp b/dali-toolkit/internal/text/text-effects-style.cpp new file mode 100644 index 0000000..7172f23 --- /dev/null +++ b/dali-toolkit/internal/text/text-effects-style.cpp @@ -0,0 +1,363 @@ +/* + * 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. + * + */ + +// FILE HEADER +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +namespace +{ +const std::string COLOR_KEY( "color" ); +const std::string OFFSET_KEY( "offset" ); +const std::string THICKNESS_KEY( "thickness" ); +} + +bool SetUnderlineProperties( ControllerPtr controller, const Property::Value& value, EffectStyle::Type type ) +{ + bool update = false; + + if( controller ) + { + const std::string properties = value.Get< std::string >(); + + switch( type ) + { + case EffectStyle::DEFAULT: + { + // Stores the default underline's properties string to be recovered by the GetUnderlineProperties() function. + controller->SetDefaultUnderlineProperties( properties ); + break; + } + case EffectStyle::INPUT: + { + // Stores the input underline's properties string to be recovered by the GetUnderlineProperties() function. + controller->SetInputUnderlineProperties( properties ); + break; + } + } + + // Parses and applies the style. + Property::Map map; + ParsePropertyString( properties, map ); + + if( !map.Empty() ) + { + /// Color key + Property::Value* colorValue = map.Find( COLOR_KEY ); + + Vector4 color; + const bool colorDefined = colorValue != NULL; + if( colorDefined ) + { + const std::string colorStr = colorValue->Get(); + + ColorStringToVector4( colorStr.c_str(), colorStr.size(), color ); + } + + /// Thickness key + Property::Value* thicknessValue = map.Find( THICKNESS_KEY ); + + float thickness = 0.f; + const bool thicknessDefined = thicknessValue != NULL; + if( thicknessDefined ) + { + const std::string thicknessStr = thicknessValue->Get(); + + thickness = StringToFloat( thicknessStr.c_str() ); + } + + switch( type ) + { + case EffectStyle::DEFAULT: + { + if( !controller->IsUnderlineEnabled() ) + { + controller->SetUnderlineEnabled( true ); + update = true; + } + // Sets the default underline values. + if( colorDefined && ( controller->GetUnderlineColor() != color ) ) + { + controller->SetUnderlineColor( color ); + update = true; + } + + if( thicknessDefined && fabsf( controller->GetUnderlineHeight() - thickness ) > Math::MACHINE_EPSILON_1000 ) + { + controller->SetUnderlineHeight( thickness ); + update = true; + } + } + case EffectStyle::INPUT: + { + // Sets the input underline values. + // TODO: to be implemented. + break; + } + } + } + else + { + // Disable underline. + if( controller->IsUnderlineEnabled() ) + { + controller->SetUnderlineEnabled( false ); + update = true; + } + } + } + + return update; +} + +void GetUnderlineProperties( ControllerPtr controller, Property::Value& value, EffectStyle::Type type ) +{ + if( controller ) + { + switch( type ) + { + case EffectStyle::DEFAULT: + { + value = controller->GetDefaultUnderlineProperties(); + break; + } + case EffectStyle::INPUT: + { + value = controller->GetInputUnderlineProperties(); + break; + } + } + } +} + +bool SetShadowProperties( ControllerPtr controller, const Property::Value& value, EffectStyle::Type type ) +{ + bool update = false; + + if( controller ) + { + const std::string properties = value.Get< std::string >(); + + switch( type ) + { + case EffectStyle::DEFAULT: + { + // Stores the default shadow's properties string to be recovered by the GetShadowProperties() function. + controller->SetDefaultShadowProperties( properties ); + break; + } + case EffectStyle::INPUT: + { + // Stores the input shadow's properties string to be recovered by the GetShadowProperties() function. + controller->SetInputShadowProperties( properties ); + break; + } + } + + // Parses and applies the style. + Property::Map map; + ParsePropertyString( properties, map ); + + if( !map.Empty() ) + { + /// Color key + Property::Value* colorValue = map.Find( COLOR_KEY ); + + Vector4 color; + const bool colorDefined = colorValue != NULL; + if( colorDefined ) + { + const std::string colorStr = colorValue->Get(); + + ColorStringToVector4( colorStr.c_str(), colorStr.size(), color ); + } + + /// Offset key + Property::Value* offsetValue = map.Find( OFFSET_KEY ); + + Vector2 offset; + const bool offsetDefined = offsetValue != NULL; + if( offsetDefined ) + { + const std::string offsetStr = offsetValue->Get(); + + StringOffsetToVector2( offsetStr, offset ); + } + + switch( type ) + { + case EffectStyle::DEFAULT: + { + // Sets the default shadow values. + if( colorDefined && ( controller->GetShadowColor() != color ) ) + { + controller->SetShadowColor( color ); + update = true; + } + + if( offsetDefined && ( controller->GetShadowOffset() != offset ) ) + { + controller->SetShadowOffset( offset ); + update = true; + } + } + case EffectStyle::INPUT: + { + // Sets the input shadow values. + // TODO: to be implemented. + break; + } + } + } + } + + return update; +} + +void GetShadowProperties( ControllerPtr controller, Property::Value& value, EffectStyle::Type type ) +{ + if( controller ) + { + switch( type ) + { + case EffectStyle::DEFAULT: + { + value = controller->GetDefaultShadowProperties(); + break; + } + case EffectStyle::INPUT: + { + value = controller->GetInputShadowProperties(); + break; + } + } + } +} + +bool SetEmbossProperties( ControllerPtr controller, const Property::Value& value, EffectStyle::Type type ) +{ + bool update = false; + + if( controller ) + { + const std::string properties = value.Get< std::string >(); + + switch( type ) + { + case EffectStyle::DEFAULT: + { + // Stores the default emboss's properties string to be recovered by the GetEmbossProperties() function. + controller->SetDefaultEmbossProperties( properties ); + break; + } + case EffectStyle::INPUT: + { + // Stores the input emboss's properties string to be recovered by the GetEmbossProperties() function. + controller->SetInputEmbossProperties( properties ); + break; + } + } + } + + return update; +} + +void GetEmbossProperties( ControllerPtr controller, Property::Value& value, EffectStyle::Type type ) +{ + if( controller ) + { + switch( type ) + { + case EffectStyle::DEFAULT: + { + value = controller->GetDefaultEmbossProperties(); + break; + } + case EffectStyle::INPUT: + { + value = controller->GetInputEmbossProperties(); + break; + } + } + } +} + +bool SetOutlineProperties( ControllerPtr controller, const Property::Value& value, EffectStyle::Type type ) +{ + bool update = false; + + if( controller ) + { + const std::string properties = value.Get< std::string >(); + + switch( type ) + { + case EffectStyle::DEFAULT: + { + // Stores the default outline's properties string to be recovered by the GetOutlineProperties() function. + controller->SetDefaultOutlineProperties( properties ); + break; + } + case EffectStyle::INPUT: + { + // Stores the input outline's properties string to be recovered by the GetOutlineProperties() function. + controller->SetInputOutlineProperties( properties ); + break; + } + } + } + + return update; +} + +void GetOutlineProperties( ControllerPtr controller, Property::Value& value, EffectStyle::Type type ) +{ + if( controller ) + { + switch( type ) + { + case EffectStyle::DEFAULT: + { + value = controller->GetDefaultOutlineProperties(); + break; + } + case EffectStyle::INPUT: + { + value = controller->GetInputOutlineProperties(); + break; + } + } + } +} + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/internal/text/text-effects-style.h b/dali-toolkit/internal/text/text-effects-style.h new file mode 100644 index 0000000..9feb75c --- /dev/null +++ b/dali-toolkit/internal/text/text-effects-style.h @@ -0,0 +1,132 @@ +#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_EFFECTS_STYLE_H__ +#define __DALI_TOOLKIT_INTERNAL_TEXT_EFFECTS_STYLE_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 + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +namespace EffectStyle +{ + enum Type + { + DEFAULT, ///< The default text effect style. + INPUT ///< The input text effect style. + }; +}; + +/** + * @brief Sets the underline properties. + * + * @param[in] controller The text's controller. + * @param[in] value The values of the underline's properties. + * @param[in] type Whether the property is for the default underline or the input underline. + * + * @return Whether the underline properties have been updated. + */ +bool SetUnderlineProperties( ControllerPtr controller, const Property::Value& value, EffectStyle::Type type ); + +/** + * @brief Retrieves the underline's properties. + * + * @param[in] controller The text's controller. + * @param[out] value The value of the underline's properties. + * @param[in] type Whether the property is for the default underline or the input underline. + */ +void GetUnderlineProperties( ControllerPtr controller, Property::Value& value, EffectStyle::Type type ); + +/** + * @brief Sets the shadow properties. + * + * @param[in] controller The text's controller. + * @param[in] value The values of the shadow's style. + * @param[in] type Whether the property is for the default shadow's style or the input shadow's style. + * + * @return Whether the shadow properties have been updated. + */ +bool SetShadowProperties( ControllerPtr controller, const Property::Value& value, EffectStyle::Type type ); + +/** + * @brief Retrieves the shadow's properties. + * + * @param[in] controller The text's controller. + * @param[out] value The value of the shadow's properties. + * @param[in] type Whether the property is for the default shadow or the input shadow. + */ +void GetShadowProperties( ControllerPtr controller, Property::Value& value, EffectStyle::Type type ); + +/** + * @brief Sets the emboss properties. + * + * @param[in] controller The text's controller. + * @param[in] value The values of the emboss's properties. + * @param[in] type Whether the property is for the default emboss or the input emboss. + * + * @return Whether the emboss properties have been updated. + */ +bool SetEmbossProperties( ControllerPtr controller, const Property::Value& value, EffectStyle::Type type ); + +/** + * @brief Retrieves the emboss's properties. + * + * @param[in] controller The text's controller. + * @param[out] value The value of the emboss's properties. + * @param[in] type Whether the property is for the default emboss or the input emboss. + */ +void GetEmbossProperties( ControllerPtr controller, Property::Value& value, EffectStyle::Type type ); + +/** + * @brief Sets the outline properties. + * + * @param[in] controller The text's controller. + * @param[in] value The values of the outline's properties. + * @param[in] type Whether the property is for the default outline or the input outline. + * + * @return Whether the outline properties have been updated. + */ +bool SetOutlineProperties( ControllerPtr controller, const Property::Value& value, EffectStyle::Type type ); + +/** + * @brief Retrieves the outline's properties. + * + * @param[in] controller The text's controller. + * @param[out] value The value of the outline's properties. + * @param[in] type Whether the property is for the default outline or the input outline. + */ +void GetOutlineProperties( ControllerPtr controller, Property::Value& value, EffectStyle::Type type ); + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali + +#endif // __DALI_TOOLKIT_INTERNAL_TEXT_EFFECTS_STYLE_H__ diff --git a/dali-toolkit/internal/text/text-font-style.cpp b/dali-toolkit/internal/text/text-font-style.cpp index b346d90..b31decb 100644 --- a/dali-toolkit/internal/text/text-font-style.cpp +++ b/dali-toolkit/internal/text/text-font-style.cpp @@ -22,8 +22,7 @@ #include // INTERNAL INCLUDES -#include -#include +#include namespace Dali { @@ -40,7 +39,6 @@ const std::string STYLE_KEY( "style" ); const std::string WEIGHT_KEY( "weight" ); const std::string WIDTH_KEY( "width" ); const std::string SLANT_KEY( "slant" ); -const std::string EMPTY_STRING( "" ); #if defined(DEBUG_ENABLED) Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS"); @@ -48,65 +46,6 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_C } // namespace -/** - * @brief Creates a map with pairs 'key,value' with the font's style parameters. - * - * @param[in] node Data structure with the font's style parameters. - * @param[out] map A map with the font's style parameters. - * - */ -void CreateFontStyleMap( const TreeNode* const node, Property::Map& map ) -{ - switch( node->GetType() ) - { - case TreeNode::IS_NULL: - case TreeNode::OBJECT: - case TreeNode::ARRAY: // FALL THROUGH - { - break; - } - case TreeNode::STRING: - { - map.Insert( node->GetName(), Property::Value( node->GetString() ) ); - break; - } - case TreeNode::INTEGER: - case TreeNode::FLOAT: - case TreeNode::BOOLEAN: // FALL THROUGH - { - break; - } - } - - for( TreeNode::ConstIterator it = node->CBegin(), endIt = node->CEnd(); it != endIt; ++it ) - { - const TreeNode::KeyNodePair& pair = *it; - CreateFontStyleMap( &pair.second, map ); - } -} - -/** - * @brief Parses the font's style string. - * - * @param[in] style The font's style string. - * @param[out] map A map with the font's style parameters. - * - */ -void ParseFontStyleString( const std::string& style, Property::Map& map ) -{ - Toolkit::JsonParser parser = Toolkit::JsonParser::New(); - - if( parser.Parse( style ) ) - { - const TreeNode* const node = parser.GetRoot(); - - if( NULL != node ) - { - CreateFontStyleMap( node, map ); - } - } -} - void SetFontStyleProperty( ControllerPtr controller, const Property::Value& value, FontStyle::Type type ) { if( controller ) @@ -132,7 +71,7 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu // Parses and applies the style. Property::Map map; - ParseFontStyleString( style, map ); + ParsePropertyString( style, map ); if( !map.Empty() ) { diff --git a/dali-toolkit/internal/text/text-font-style.h b/dali-toolkit/internal/text/text-font-style.h index b87a8c9..425131d 100644 --- a/dali-toolkit/internal/text/text-font-style.h +++ b/dali-toolkit/internal/text/text-font-style.h @@ -94,6 +94,7 @@ namespace FontStyle * * @param[in] controller The text's controller. * @param[in] value The value of the font's style. + * @param[in] type Whether the property is for the default font's style or the input font's style. * */ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& value, FontStyle::Type type ); @@ -103,6 +104,7 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu * * @param[in] controller The text's controller. * @param[out] value The value of the font's style. + * @param[in] type Whether the property is for the default font's style or the input font's style. */ void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, FontStyle::Type type ); diff --git a/dali-toolkit/devel-api/controls/text-controls/text-editor.cpp b/dali-toolkit/public-api/controls/text-controls/text-editor.cpp similarity index 95% rename from dali-toolkit/devel-api/controls/text-controls/text-editor.cpp rename to dali-toolkit/public-api/controls/text-controls/text-editor.cpp index 70dc1f4..fa81f24 100644 --- a/dali-toolkit/devel-api/controls/text-controls/text-editor.cpp +++ b/dali-toolkit/public-api/controls/text-controls/text-editor.cpp @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include +#include // INTERNAL INCLUDES #include diff --git a/dali-toolkit/devel-api/controls/text-controls/text-editor.h b/dali-toolkit/public-api/controls/text-controls/text-editor.h similarity index 64% rename from dali-toolkit/devel-api/controls/text-controls/text-editor.h rename to dali-toolkit/public-api/controls/text-controls/text-editor.h index 0e1f9bb..1de3730 100644 --- a/dali-toolkit/devel-api/controls/text-controls/text-editor.h +++ b/dali-toolkit/public-api/controls/text-controls/text-editor.h @@ -65,36 +65,46 @@ public: { enum { - RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "renderingBackend", The type or rendering e.g. bitmap-based, type INT - TEXT, ///< name "text", The text to display in UTF-8 format, type STRING - TEXT_COLOR, ///< name "textColor", The text color, type VECTOR4 - FONT_FAMILY, ///< name "fontFamily", The requested font family, type STRING - FONT_STYLE, ///< name "fontStyle", The requested font style, type STRING - POINT_SIZE, ///< name "pointSize", The size of font in points, type FLOAT - HORIZONTAL_ALIGNMENT, ///< name "horizontalAlignment", The text horizontal alignment, type STRING, values "BEGIN", "CENTER", "END" - SCROLL_THRESHOLD, ///< name "scrollThreshold" Vertical scrolling will occur if the cursor is this close to the control border, type FLOAT - SCROLL_SPEED, ///< name "scrollSpeed" The scroll speed in pixels per second, type FLOAT - PRIMARY_CURSOR_COLOR, ///< name "primaryCursorColor", The color to apply to the primary cursor, type VECTOR4 - SECONDARY_CURSOR_COLOR, ///< name "secondaryCursorColor", The color to apply to the secondary cursor, type VECTOR4 - ENABLE_CURSOR_BLINK, ///< name "enableCursorBlink", Whether the cursor should blink or not, type BOOLEAN - CURSOR_BLINK_INTERVAL, ///< name "cursorBlinkInterval", The time interval in seconds between cursor on/off states, type FLOAT - CURSOR_BLINK_DURATION, ///< name "cursorBlinkDuration", The cursor will stop blinking after this number of seconds (if non-zero), type FLOAT - CURSOR_WIDTH, ///< name "cursorWidth", The cursor width, type INTEGER - GRAB_HANDLE_IMAGE, ///< name "grabHandleImage", The image to display for the grab handle, type STRING - GRAB_HANDLE_PRESSED_IMAGE, ///< name "grabHandlePressedImage", The image to display when the grab handle is pressed, type STRING - SELECTION_HANDLE_IMAGE_LEFT, ///< name "selectionHandleImageLeft", The image to display for the left selection handle, type MAP - SELECTION_HANDLE_IMAGE_RIGHT, ///< name "selectionHandleImageRight", The image to display for the right selection handle, type MAP - SELECTION_HANDLE_PRESSED_IMAGE_LEFT, ///< name "selectionHandlePressedImageLeft", The image to display when the left selection handle is pressed, type MAP - SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, ///< name "selectionHandlePressedImageRight", The image to display when the right selection handle is pressed, type MAP - SELECTION_HANDLE_MARKER_IMAGE_LEFT, ///< name "selectionHandleMarkerImageLeft", The image to display for the left selection handle marker, type MAP - SELECTION_HANDLE_MARKER_IMAGE_RIGHT, ///< name "selectionHandleMarkerImageRight", The image to display for the right selection handle marker, type MAP - SELECTION_HIGHLIGHT_COLOR, ///< name "selectionHighlightColor", The color of the selection highlight, type VECTOR4 - DECORATION_BOUNDING_BOX, ///< name "decorationBoundingBox", The decorations (handles etc) will positioned within this area on-screen, type RECTANGLE - ENABLE_MARKUP, ///< name "enableMarkup", Whether the mark-up processing is enabled. type BOOLEAN - INPUT_COLOR, ///< name "inputColor", The color of the new input text, type VECTOR4 - INPUT_FONT_FAMILY, ///< name "inputFontFamily", The font's family of the new input text, type STRING - INPUT_FONT_STYLE, ///< name "inputFontStyle", The font's style of the new input text, type STRING - INPUT_POINT_SIZE ///< name "inputPointSize", The font's size of the new input text in points, type FLOAT + RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "renderingBackend", The type or rendering e.g. bitmap-based, type INT @SINCE_1_1.37 + TEXT, ///< name "text", The text to display in UTF-8 format, type STRING @SINCE_1_1.37 + TEXT_COLOR, ///< name "textColor", The text color, type VECTOR4 @SINCE_1_1.37 + FONT_FAMILY, ///< name "fontFamily", The requested font family, type STRING @SINCE_1_1.37 + FONT_STYLE, ///< name "fontStyle", The requested font style, type STRING @SINCE_1_1.37 + POINT_SIZE, ///< name "pointSize", The size of font in points, type FLOAT @SINCE_1_1.37 + HORIZONTAL_ALIGNMENT, ///< name "horizontalAlignment", The text horizontal alignment, type STRING, values "BEGIN", "CENTER", "END" @SINCE_1_1.37 + SCROLL_THRESHOLD, ///< name "scrollThreshold" Vertical scrolling will occur if the cursor is this close to the control border, type FLOAT @SINCE_1_1.37 + SCROLL_SPEED, ///< name "scrollSpeed" The scroll speed in pixels per second, type FLOAT @SINCE_1_1.37 + PRIMARY_CURSOR_COLOR, ///< name "primaryCursorColor", The color to apply to the primary cursor, type VECTOR4 @SINCE_1_1.37 + SECONDARY_CURSOR_COLOR, ///< name "secondaryCursorColor", The color to apply to the secondary cursor, type VECTOR4 @SINCE_1_1.37 + ENABLE_CURSOR_BLINK, ///< name "enableCursorBlink", Whether the cursor should blink or not, type BOOLEAN @SINCE_1_1.37 + CURSOR_BLINK_INTERVAL, ///< name "cursorBlinkInterval", The time interval in seconds between cursor on/off states, type FLOAT @SINCE_1_1.37 + CURSOR_BLINK_DURATION, ///< name "cursorBlinkDuration", The cursor will stop blinking after this number of seconds (if non-zero), type FLOAT @SINCE_1_1.37 + CURSOR_WIDTH, ///< name "cursorWidth", The cursor width, type INTEGER @SINCE_1_1.37 + GRAB_HANDLE_IMAGE, ///< name "grabHandleImage", The image to display for the grab handle, type STRING @SINCE_1_1.37 + GRAB_HANDLE_PRESSED_IMAGE, ///< name "grabHandlePressedImage", The image to display when the grab handle is pressed, type STRING @SINCE_1_1.37 + SELECTION_HANDLE_IMAGE_LEFT, ///< name "selectionHandleImageLeft", The image to display for the left selection handle, type MAP @SINCE_1_1.37 + SELECTION_HANDLE_IMAGE_RIGHT, ///< name "selectionHandleImageRight", The image to display for the right selection handle, type MAP @SINCE_1_1.37 + SELECTION_HANDLE_PRESSED_IMAGE_LEFT, ///< name "selectionHandlePressedImageLeft", The image to display when the left selection handle is pressed, type MAP @SINCE_1_1.37 + SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, ///< name "selectionHandlePressedImageRight", The image to display when the right selection handle is pressed, type MAP @SINCE_1_1.37 + SELECTION_HANDLE_MARKER_IMAGE_LEFT, ///< name "selectionHandleMarkerImageLeft", The image to display for the left selection handle marker, type MAP @SINCE_1_1.37 + SELECTION_HANDLE_MARKER_IMAGE_RIGHT, ///< name "selectionHandleMarkerImageRight", The image to display for the right selection handle marker, type MAP @SINCE_1_1.37 + SELECTION_HIGHLIGHT_COLOR, ///< name "selectionHighlightColor", The color of the selection highlight, type VECTOR4 @SINCE_1_1.37 + DECORATION_BOUNDING_BOX, ///< name "decorationBoundingBox", The decorations (handles etc) will positioned within this area on-screen, type RECTANGLE @SINCE_1_1.37 + ENABLE_MARKUP, ///< name "enableMarkup", Whether the mark-up processing is enabled. type BOOLEAN @SINCE_1_1.37 + INPUT_COLOR, ///< name "inputColor", The color of the new input text, type VECTOR4 @SINCE_1_1.37 + INPUT_FONT_FAMILY, ///< name "inputFontFamily", The font's family of the new input text, type STRING @SINCE_1_1.37 + INPUT_FONT_STYLE, ///< name "inputFontStyle", The font's style of the new input text, type STRING @SINCE_1_1.37 + INPUT_POINT_SIZE, ///< name "inputPointSize", The font's size of the new input text in points, type FLOAT @SINCE_1_1.37 + LINE_SPACING, ///< name "lineSpacing", The default extra space between lines in points, type FLOAT @SINCE_1_1.37 + INPUT_LINE_SPACING, ///< name "inputLineSpacing" The extra space between lines in points. It affects the whole paragraph where the new input text is inserted, type FLOAT @SINCE_1_1.37 + UNDERLINE, ///< name "underline" The default underline parameters, type STRING @SINCE_1_1.37 + INPUT_UNDERLINE, ///< name "inputUnderline" The underline parameters of the new input text, type STRING @SINCE_1_1.37 + SHADOW, ///< name "shadow" The default shadow parameters, type STRING @SINCE_1_1.37 + INPUT_SHADOW, ///< name "inputShadow" The shadow parameters of the new input text, type STRING @SINCE_1_1.37 + EMBOSS, ///< name "emboss" The default emboss parameters, type STRING @SINCE_1_1.37 + INPUT_EMBOSS, ///< name "inputEmboss" The emboss parameters of the new input text, type STRING @SINCE_1_1.37 + OUTLINE, ///< name "outline" The default outline parameters, type STRING @SINCE_1_1.37 + INPUT_OUTLINE, ///< name "inputOutline" The outline parameters of the new input text, type STRING @SINCE_1_1.37 }; }; diff --git a/dali-toolkit/public-api/controls/text-controls/text-field.h b/dali-toolkit/public-api/controls/text-controls/text-field.h index e5115fe..fc29af4 100644 --- a/dali-toolkit/public-api/controls/text-controls/text-field.h +++ b/dali-toolkit/public-api/controls/text-controls/text-field.h @@ -82,8 +82,8 @@ public: VERTICAL_ALIGNMENT, ///< name "verticalAlignment", The line vertical alignment, type STRING, values "TOP", "CENTER", "BOTTOM" @SINCE_1_0.0 TEXT_COLOR, ///< name "textColor", The text color, type VECTOR4 @SINCE_1_0.0 PLACEHOLDER_TEXT_COLOR, ///< name "placeholderTextColor", The placeholder-text color, type VECTOR4 @SINCE_1_0.0 - SHADOW_OFFSET, ///< name "shadowOffset", The drop shadow offset 0 indicates no shadow, type VECTOR2 @SINCE_1_0.0 - SHADOW_COLOR, ///< name "shadowColor", The color of a drop shadow, type VECTOR4 @SINCE_1_0.0 + SHADOW_OFFSET, ///< name "shadowOffset", The drop shadow offset 0 indicates no shadow, type VECTOR2 @DEPRECATED_1_1.37 Use SHADOW instead. + SHADOW_COLOR, ///< name "shadowColor", The color of a drop shadow, type VECTOR4 @DEPRECATED_1_1.37 Use SHADOW instead. PRIMARY_CURSOR_COLOR, ///< name "primaryCursorColor", The color to apply to the primary cursor, type VECTOR4 @SINCE_1_0.0 SECONDARY_CURSOR_COLOR, ///< name "secondaryCursorColor", The color to apply to the secondary cursor, type VECTOR4 @SINCE_1_0.0 ENABLE_CURSOR_BLINK, ///< name "enableCursorBlink", Whether the cursor should blink or not, type BOOLEAN @SINCE_1_0.0 @@ -107,7 +107,15 @@ public: ENABLE_MARKUP, ///< name "enableMarkup", Whether the mark-up processing is enabled. type BOOLEAN @SINCE_1_0.0 INPUT_FONT_FAMILY, ///< name "inputFontFamily", The font's family of the new input text, type STRING @SINCE_1_0.0 INPUT_FONT_STYLE, ///< name "inputFontStyle", The font's style of the new input text, type STRING @SINCE_1_0.0 - INPUT_POINT_SIZE ///< name "inputPointSize", The font's size of the new input text in points, type FLOAT @SINCE_1_0.0 + INPUT_POINT_SIZE, ///< name "inputPointSize", The font's size of the new input text in points, type FLOAT @SINCE_1_0.0 + UNDERLINE, ///< name "underline" The default underline parameters, type STRING @SINCE_1_1.37 + INPUT_UNDERLINE, ///< name "inputUnderline" The underline parameters of the new input text, type STRING @SINCE_1_1.37 + SHADOW, ///< name "shadow" The default shadow parameters, type STRING @SINCE_1_1.37 + INPUT_SHADOW, ///< name "inputShadow" The shadow parameters of the new input text, type STRING @SINCE_1_1.37 + EMBOSS, ///< name "emboss" The default emboss parameters, type STRING @SINCE_1_1.37 + INPUT_EMBOSS, ///< name "inputEmboss" The emboss parameters of the new input text, type STRING @SINCE_1_1.37 + OUTLINE, ///< name "outline" The default outline parameters, type STRING @SINCE_1_1.37 + INPUT_OUTLINE, ///< name "inputOutline" The outline parameters of the new input text, type STRING @SINCE_1_1.37 }; }; diff --git a/dali-toolkit/public-api/controls/text-controls/text-label.h b/dali-toolkit/public-api/controls/text-controls/text-label.h index 33e95f1..105690a 100644 --- a/dali-toolkit/public-api/controls/text-controls/text-label.h +++ b/dali-toolkit/public-api/controls/text-controls/text-label.h @@ -53,16 +53,13 @@ class TextLabel; * | Property::HORIZONTAL_ALIGNMENT | horizontalAlignment | STRING | O | X | * | Property::VERTICAL_ALIGNMENT | verticalAlignment | STRING | O | X | * | Property::TEXT_COLOR | textColor | VECTOR4 | O | X | - * | Property::SHADOW_OFFSET | shadowOffset | VECTOR2 | O | X | - * | Property::SHADOW_COLOR | shadowColor | VECTOR4 | O | X | - * | Property::UNDERLINE_ENABLED | underlineEnabled | BOOLEAN | O | X | - * | Property::UNDERLINE_COLOR | underlineColor | VECTOR4 | O | X | - * | Property::UNDERLINE_HEIGHT | underlineHeight | FLOAT | O | X | * | Property::ENABLE_MARKUP | enableMarkup | BOOLEAN | O | X | * | Property::ENABLE_AUTO_SCROLL | enableAutoScroll | BOOLEAN | O | X | * | Property::AUTO_SCROLL_SPEED | autoScrollSpeed | INTEGER | O | X | * | Property::AUTO_SCROLL_LOOP_COUNT | autoScrollLoopCount | INTEGER | O | X | * | Property::AUTO_SCROLL_GAP | autoScrollGap | INTEGER | O | X | + * | Property::SHADOW | shadow | STRING | O | X | + * | Property::UNDERLINE | underline | STRING | O | X | * * @SINCE_1_0.0 */ @@ -154,35 +151,35 @@ public: /** * @brief The drop shadow offset 0 indicates no shadow * @details name "shadowOffset", type VECTOR4 - * @SINCE_1_0.0 + * @DEPRECATED_1_1.37 Use SHADOW instead */ SHADOW_OFFSET, /** * @brief The color of a drop shadow * @details name "shadowColor", type VECTOR4 - * @SINCE_1_0.0 + * @DEPRECATED_1_1.37 Use SHADOW instead */ SHADOW_COLOR, /** * @brief The underline enabled flag * @details name "underlineEnabled", type BOOLEAN - * @SINCE_1_0.0 + * @DEPRECATED_1_1.37 Use UNDERLINE instead */ UNDERLINE_ENABLED, /** * @brief The color of the underline * @details name "underlineColor", type VECTOR4 - * @SINCE_1_0.0 + * @DEPRECATED_1_1.37 Use UNDERLINE instead */ UNDERLINE_COLOR, /** * @brief Overrides the underline height from font metrics * @details name "underlineHeight", type FLOAT - * @SINCE_1_0.0 + * @DEPRECATED_1_1.37 Use UNDERLINE instead */ UNDERLINE_HEIGHT, @@ -219,7 +216,42 @@ public: * @details name "autoScrollGap", type INT, default in style sheet but can be overridden to prevent same text being show at start and end. * @SINCE_1_1.35 */ - AUTO_SCROLL_GAP + AUTO_SCROLL_GAP, + + /** + * @brief The default extra space between lines in points. + * @details name "lineSpacing", type FLOAT. + * @SINCE_1_1.37 + */ + LINE_SPACING, + + /** + * @brief The default underline parameters. + * @details name "underline", type STRING. + * @SINCE_1_1.37 + */ + UNDERLINE, + + /** + * @brief The default shadow parameters. + * @details name "shadow", type STRING. + * @SINCE_1_1.37 + */ + SHADOW, + + /** + * @brief The default emboss parameters. + * @details name "emboss", type STRING. + * @SINCE_1_1.37 + */ + EMBOSS, + + /** + * @brief The default outline parameters. + * @details name "outline", type STRING. + * @SINCE_1_1.37 + */ + OUTLINE, }; }; diff --git a/dali-toolkit/public-api/file.list b/dali-toolkit/public-api/file.list index a7b1a02..d7e7034 100755 --- a/dali-toolkit/public-api/file.list +++ b/dali-toolkit/public-api/file.list @@ -25,6 +25,7 @@ public_api_src_files = \ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view.cpp \ $(public_api_src_dir)/controls/scrollable/scrollable.cpp \ $(public_api_src_dir)/controls/table-view/table-view.cpp \ + $(public_api_src_dir)/controls/text-controls/text-editor.cpp \ $(public_api_src_dir)/controls/text-controls/text-label.cpp \ $(public_api_src_dir)/controls/text-controls/text-field.cpp \ $(public_api_src_dir)/controls/gaussian-blur-view/gaussian-blur-view.cpp \ @@ -100,6 +101,7 @@ public_api_table_view_header_files = \ $(public_api_src_dir)/controls/table-view/table-view.h public_api_text_controls_header_files = \ + $(public_api_src_dir)/controls/text-controls/text-editor.h \ $(public_api_src_dir)/controls/text-controls/text-label.h \ $(public_api_src_dir)/controls/text-controls/text-field.h diff --git a/docs/content/shared-javascript-and-cpp-documentation/text-editor.md b/docs/content/shared-javascript-and-cpp-documentation/text-editor.md index 0da1f43..707258e 100644 --- a/docs/content/shared-javascript-and-cpp-documentation/text-editor.md +++ b/docs/content/shared-javascript-and-cpp-documentation/text-editor.md @@ -128,6 +128,16 @@ editor.textColor = dali.COLOR_CYAN; inputFontFamily | INPUT_FONT_FAMILY | STRING | O | X inputFontStyle | INPUT_FONT_STYLE | STRING | O | X inputPointSize | INPUT_POINT_SIZE | FLOAT | O | X + lineSpacing | LINE_SPACING | FLOAT | O | X + inputLineSpacing | INPUT_LINE_SPACING | FLOAT | O | X + underline | UNDERLINE | STRING | O | X + inputUnderline | INPUT_UNDERLINE | STRING | O | X + shadow | SHADOW | STRING | O | X + inputShadow | INPUT_SHADOW | STRING | O | X + emboss | EMBOSS | STRING | O | X + inputEmboss | INPUT_EMBOSS | STRING | O | X + outline | OUTLINE | STRING | O | X + inputOutline | INPUT_OUTLINE | STRING | O | X @class TextEditor diff --git a/docs/content/shared-javascript-and-cpp-documentation/text-field.md b/docs/content/shared-javascript-and-cpp-documentation/text-field.md index f6c8ecc..74b8cfd 100644 --- a/docs/content/shared-javascript-and-cpp-documentation/text-field.md +++ b/docs/content/shared-javascript-and-cpp-documentation/text-field.md @@ -122,8 +122,6 @@ field.placeholderTextColor = dali.COLOR_BLACK; verticalAlignment | VERTICAL_ALIGNMENT | STRING | O | X textColor | TEXT_COLOR | VECTOR4 | O | X placeholderTextColor | PLACEHOLDER_TEXT_COLOR | VECTOR4 | O | X - shadowOffset | SHADOW_OFFSET | VECTOR2 | O | X - shadowColor | SHADOW_COLOR | VECTOR4 | O | X primaryCursorColor | PRIMARY_CURSOR_COLOR | VECTOR4 | O | X secondaryCursorColor | SECONDARY_CURSOR_COLOR | VECTOR4 | O | X enableCursorBlink | ENABLE_CURSOR_BLINK | BOOLEAN | O | X @@ -148,6 +146,14 @@ field.placeholderTextColor = dali.COLOR_BLACK; inputFontFamily | INPUT_FONT_FAMILY | STRING | O | X inputFontStyle | INPUT_FONT_STYLE | STRING | O | X inputPointSize | INPUT_POINT_SIZE | FLOAT | O | X + underline | UNDERLINE | STRING | O | X + inputUnderline | INPUT_UNDERLINE | STRING | O | X + shadow | SHADOW | STRING | O | X + inputShadow | INPUT_SHADOW | STRING | O | X + emboss | EMBOSS | STRING | O | X + inputEmboss | INPUT_EMBOSS | STRING | O | X + outline | OUTLINE | STRING | O | X + inputOutline | INPUT_OUTLINE | STRING | O | X @class TextField diff --git a/docs/content/shared-javascript-and-cpp-documentation/text-label.md b/docs/content/shared-javascript-and-cpp-documentation/text-label.md index ae03364..98734b2 100644 --- a/docs/content/shared-javascript-and-cpp-documentation/text-label.md +++ b/docs/content/shared-javascript-and-cpp-documentation/text-label.md @@ -207,8 +207,7 @@ label.textColor = dali.COLOR_RED; #### Drop Shadow -To add a drop-shadow to the text, simply set the SHADOW_OFFSET property with non-zero values. -The color can also be selected using the SHADOW_COLOR property. +To add a drop-shadow to the text, simply set the SHADOW property. Shadow parameters can be set through a json string, see the examples below. ~~~{.cpp} // C++ @@ -218,16 +217,13 @@ stage.SetBackgroundColor( Color::BLUE ); label1.SetProperty( TextLabel::Property::TEXT, "Plain Text" ); label2.SetProperty( TextLabel::Property::TEXT, "Text with Shadow" ); -label2.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) ); -label2.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK ); +label2.SetProperty( TextLabel::Property::SHADOW, "{\"offset\":\"1 1\",\"color\":\"black\"}" ); label3.SetProperty( TextLabel::Property::TEXT, "Text with Bigger Shadow" ); -label3.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 2.0f, 2.0f ) ); -label3.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK ); +label3.SetProperty( TextLabel::Property::SHADOW, "{\"offset\":\"2 2\",\"color\":\"black\"}" ); label4.SetProperty( TextLabel::Property::TEXT, "Text with Color Shadow" ); -label4.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) ); -label4.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::RED ); +label4.SetProperty( TextLabel::Property::SHADOW, "{\"offset\":\"1 1\",\"color\":\"red\"}" ); ~~~ ~~~{.js} @@ -239,16 +235,13 @@ label1.text = "Plain Text"; label2.text = "Text with Shadow"; -label2.shadowOffset = [1, 1]; -label2.shadowColor = dali.COLOR_BLACK; +label2.shadow = "{\"offset\":\"1 1\",\"color\":\"black\"}"; label3.text = "Text with Bigger Shadow"; -label3.shadowOffset = [2, 2]; -label3.shadowColor = dali.COLOR_BLACK; +label3.shadow = "{\"offset\":\"2 2\",\"color\":\"black\"}"; label4.SetProperty( TextLabel::Property::TEXT, "Text with Color Shadow" ); -label3.shadowOffset = [1, 1]; -label3.shadowColor = dali.COLOR_RED; +label3.shadow = "{\"offset\":\"1 1\",\"color\":\"red\"}"; ~~~ -- 2.7.4