From 77a31b18a427cfc72cb17f0b14925694ea638851 Mon Sep 17 00:00:00 2001 From: "taeyoon0.lee" Date: Wed, 29 Nov 2017 18:15:09 +0900 Subject: [PATCH] Added text direction property - The property is read-only - The property gets "RightToLeft" or "LeftToRight" Change-Id: I3dba003762a21ff1ba0e09a98f154d25e9919ca4 --- .../src/dali-toolkit/utc-Dali-TextLabel.cpp | 25 +++++++ .../controls/text-controls/text-label-devel.h | 84 ++++++++++++++++++++++ .../devel-api/text/text-enumerations-devel.h | 47 ++++++++++++ .../controls/text-controls/text-label-impl.cpp | 11 +++ dali-toolkit/internal/text/text-controller.cpp | 11 +++ dali-toolkit/internal/text/text-controller.h | 8 +++ 6 files changed, 186 insertions(+) create mode 100644 dali-toolkit/devel-api/controls/text-controls/text-label-devel.h create mode 100644 dali-toolkit/devel-api/text/text-enumerations-devel.h diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index 93a644b..45214f8 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -21,6 +21,8 @@ #include #include +#include +#include using namespace Dali; using namespace Toolkit; @@ -1154,3 +1156,26 @@ int UtcDaliToolkitTextlabelMultiline(void) END_TEST; } + +int UtcDaliToolkitTextlabelTextDirection(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextlabelTextDirection"); + + TextLabel label = TextLabel::New(); + label.SetProperty( TextLabel::Property::TEXT, "Hello world" ); + label.SetProperty( TextLabel::Property::POINT_SIZE, 20 ); + Stage::GetCurrent().Add( label ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION ); + + label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" ); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION ); + + END_TEST; +} diff --git a/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h b/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h new file mode 100644 index 0000000..2838a00 --- /dev/null +++ b/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h @@ -0,0 +1,84 @@ +#ifndef DALI_TOOLKIT_TEXT_LABEL_DEVEL_H +#define DALI_TOOLKIT_TEXT_LABEL_DEVEL_H + +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace DevelTextLabel +{ + +namespace Property +{ + enum Type + { + RENDERING_BACKEND = Dali::Toolkit::TextLabel::Property::RENDERING_BACKEND, + TEXT = Dali::Toolkit::TextLabel::Property::TEXT, + FONT_FAMILY = Dali::Toolkit::TextLabel::Property::FONT_FAMILY, + FONT_STYLE = Dali::Toolkit::TextLabel::Property::FONT_STYLE, + POINT_SIZE = Dali::Toolkit::TextLabel::Property::POINT_SIZE, + MULTI_LINE = Dali::Toolkit::TextLabel::Property::MULTI_LINE, + HORIZONTAL_ALIGNMENT = Dali::Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, + VERTICAL_ALIGNMENT = Dali::Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, + UNUSED_PROPERTY_TEXT_COLOR = Dali::Toolkit::TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR, + SHADOW_OFFSET = Dali::Toolkit::TextLabel::Property::SHADOW_OFFSET, + SHADOW_COLOR = Dali::Toolkit::TextLabel::Property::SHADOW_COLOR, + UNDERLINE_ENABLED = Dali::Toolkit::TextLabel::Property::UNDERLINE_ENABLED, + UNDERLINE_COLOR = Dali::Toolkit::TextLabel::Property::UNDERLINE_COLOR, + UNDERLINE_HEIGHT = Dali::Toolkit::TextLabel::Property::UNDERLINE_HEIGHT, + ENABLE_MARKUP = Dali::Toolkit::TextLabel::Property::ENABLE_MARKUP, + ENABLE_AUTO_SCROLL = Dali::Toolkit::TextLabel::Property::ENABLE_AUTO_SCROLL, + AUTO_SCROLL_SPEED = Dali::Toolkit::TextLabel::Property::AUTO_SCROLL_SPEED, + AUTO_SCROLL_LOOP_COUNT = Dali::Toolkit::TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, + AUTO_SCROLL_GAP = Dali::Toolkit::TextLabel::Property::AUTO_SCROLL_GAP, + LINE_SPACING = Dali::Toolkit::TextLabel::Property::LINE_SPACING, + UNDERLINE = Dali::Toolkit::TextLabel::Property::UNDERLINE, + SHADOW = Dali::Toolkit::TextLabel::Property::SHADOW, + EMBOSS = Dali::Toolkit::TextLabel::Property::EMBOSS, + OUTLINE = Dali::Toolkit::TextLabel::Property::OUTLINE, + PIXEL_SIZE = Dali::Toolkit::TextLabel::Property::PIXEL_SIZE, + ELLIPSIS = Dali::Toolkit::TextLabel::Property::ELLIPSIS, + AUTO_SCROLL_LOOP_DELAY = Dali::Toolkit::TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, + AUTO_SCROLL_STOP_MODE = Dali::Toolkit::TextLabel::Property::AUTO_SCROLL_STOP_MODE, + LINE_COUNT = Dali::Toolkit::TextLabel::Property::LINE_COUNT, + LINE_WRAP_MODE = Dali::Toolkit::TextLabel::Property::LINE_WRAP_MODE, + + /** + * @brief The direction of the layout. + * @details Name "textDirection", type Property::Integer, Read-Only. + * @see TextDirection::Type for supported values. + */ + TEXT_DIRECTION, + }; + +} // namespace Property + +} // namespace DevelTextLabel + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_TEXT_LABEL_DEVEL_H diff --git a/dali-toolkit/devel-api/text/text-enumerations-devel.h b/dali-toolkit/devel-api/text/text-enumerations-devel.h new file mode 100644 index 0000000..5062417 --- /dev/null +++ b/dali-toolkit/devel-api/text/text-enumerations-devel.h @@ -0,0 +1,47 @@ +#ifndef DALI_TOOLKIT_TEXT_ENUMERATIONS_DEVEL_H +#define DALI_TOOLKIT_TEXT_ENUMERATIONS_DEVEL_H + +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +namespace Dali +{ + +namespace Toolkit +{ + +namespace DevelText +{ + +namespace TextDirection +{ + +enum Type +{ + LEFT_TO_RIGHT, + RIGHT_TO_LEFT +}; + +} // namespace TextDirection + +} // namespace DevelText + +} // namespace Toolkit + +} // namespace Dali + +#endif //DALI_TOOLKIT_TEXT_ENUMERATIONS_DEVEL_H 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 94957db..cd96e00 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -44,6 +44,8 @@ #include #include +#include + using namespace Dali::Toolkit::Text; namespace Dali @@ -113,6 +115,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollLoopDelay", DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollStopMode", STRING, AUTO_SCROLL_STOP_MODE ) DALI_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextLabel, "lineCount", INTEGER, LINE_COUNT ) DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "lineWrapMode", INTEGER, LINE_WRAP_MODE ) +DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextLabel, "textDirection", INTEGER, TEXT_DIRECTION ) DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( Toolkit, TextLabel, "textColor", Color::BLACK, TEXT_COLOR ) DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, TextLabel, "textColorRed", TEXT_COLOR_RED, TEXT_COLOR, 0 ) DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, TextLabel, "textColorGreen", TEXT_COLOR_GREEN, TEXT_COLOR, 1 ) @@ -750,6 +753,14 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } break; } + case Toolkit::DevelTextLabel::Property::TEXT_DIRECTION: + { + if( impl.mController ) + { + value = impl.mController->GetTextDirection(); + } + break; + } } } diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 1745686..ff7de02 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -2099,6 +2099,17 @@ void Controller::GetPlaceholderProperty( Property::Map& map ) } } +Toolkit::DevelText::TextDirection::Type Controller::GetTextDirection() +{ + const LineRun* const firstline = mImpl->mModel->mVisualModel->mLines.Begin(); + if ( firstline && firstline->direction ) + { + return Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT; + } + + return Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT; +} + // public : Relayout. Controller::UpdateTextType Controller::Relayout( const Size& size ) diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index d5ec2ae..07d91be 100755 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -25,6 +25,8 @@ // INTERNAL INCLUDES #include #include +#include +#include #include #include #include @@ -1154,6 +1156,12 @@ public: // Queries & retrieves. */ void GetPlaceholderProperty( Property::Map& map ); + /** + * @brief Checks text direction. + * @return The text direction. + */ + Toolkit::DevelText::TextDirection::Type GetTextDirection(); + public: // Relayout. /** -- 2.7.4