The MATCH_SYSTEM_LANGUAGE_DIRECTION property defaults to true.
When the layout direction of TextLabel, TextField, or TextEditor is changed,
LTR/RTL alignment of text follows the layout direction of each control.
If you set MATCH_SYSTEM_LANGUAGE_DIRECTION to false
As before, LTR/RTL is determined according to the language of the text.
Change-Id: Ie97654a2309ffd4c30bec2c1b95d6337d8f4c674
// Set the layout parameters.
textModel->mHorizontalAlignment = Text::HorizontalAlignment::BEGIN;
textModel->mIgnoreSpacesAfterText = true;
- textModel->mMatchSystemLanguageDirection = false;
Layout::Parameters layoutParameters( textArea,
textModel );
controller->SetTextElideEnabled( true );
// Disable match system language direction
- controller->SetMatchSystemLanguageDirection(false);
+ controller->SetMatchLayoutDirection(DevelText::MatchLayoutDirection::CONTENTS);
}
void ConfigureTextField( ControllerPtr controller )
controller->SetTextElideEnabled( false );
// Disable match system language direction
- controller->SetMatchSystemLanguageDirection(false);
+ controller->SetMatchLayoutDirection(DevelText::MatchLayoutDirection::CONTENTS);
}
void ConfigureTextEditor( ControllerPtr controller )
controller->SetTextElideEnabled( false );
// Disable match system language direction
- controller->SetMatchSystemLanguageDirection(false);
+ controller->SetMatchLayoutDirection(DevelText::MatchLayoutDirection::CONTENTS);
}
} // namespace Text
textModel->mHorizontalAlignment = Text::HorizontalAlignment::BEGIN;
textModel->mLineWrapMode = LineWrap::WORD;
textModel->mIgnoreSpacesAfterText = true;
- textModel->mMatchSystemLanguageDirection = false;
Layout::Parameters layoutParameters( data.textArea,
textModel );
/**
* @brief Modifies the default text alignment to match the direction of the system language.
* @details Name "matchSystemLanguageDirection", type (Property::BOOLEAN), Read/Write
- * @note The default value is false
+ * @note The default value is true
*/
MATCH_SYSTEM_LANGUAGE_DIRECTION,
/**
* @brief Modifies the default text alignment to match the direction of the system language.
* @details Name "matchSystemLanguageDirection", type (Property::BOOLEAN), Read/Write
- * @note The default value is false
+ * @note The default value is true
*/
MATCH_SYSTEM_LANGUAGE_DIRECTION = ELLIPSIS + 3,
/**
* @brief Modifies the default text alignment to match the direction of the system language.
* @details Name "matchSystemLanguageDirection", type (Property::BOLEAN), Read/Write
- * @note The default value is false
+ * @note The default value is true
*
* If MATCH_SYSTEM_LANGUAGE_DIRECTION property set true, the default text alignment to match the direction of the system language.
*
*
* | TextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION |
* |-----------------------------------------------------------------------
- * | false (default) | true |
+ * | false | true (default) |
* |-----------------------------------|----------------------------------|
* | Hello world | Hello world |
- * | ﻡﺮﺤﺑﺍ. | ﻡﺮﺤﺑﺍ. |
+ * | ﻡﺮﺤﺑﺍ. | ﻡﺮﺤﺑﺍ. |
*
*/
MATCH_SYSTEM_LANGUAGE_DIRECTION,
* - fontSize: 10pt, fontSizeScale: 1.5
*/
FONT_SIZE_SCALE,
+
};
} // namespace Property
} // namespace LineWrap
+/**
+ * A enum for defining text layout directions.
+ * It can also be inherited (from a parent) or deduced from the default language script of a locale.
+ * And it can be the direction of the text ifself.
+ */
+enum class MatchLayoutDirection
+{
+ INHERIT, // The text layout direction is inherited. If you change the layout direction, it will be aligned with the changed layout direction.
+ LOCALE, // The text layout direction is determined by the locale of the system language.
+ CONTENTS // The text layout direction is determined by the text itself.
+};
+
} // namespace DevelText
} // namespace Toolkit
// Resize the vector of positions to have the same size than the vector of glyphs.
rendererParameters.positions.Resize(numberOfGlyphs);
- textModel->mLineWrapMode = Text::LineWrap::WORD;
- textModel->mIgnoreSpacesAfterText = false;
- textModel->mMatchSystemLanguageDirection = false;
+ textModel->mLineWrapMode = Text::LineWrap::WORD;
+ textModel->mIgnoreSpacesAfterText = false;
Text::Layout::Parameters layoutParameters(internalDataModel.textLayoutArea,
textModel);
// EXTERNAL INCLUDES
#include <dali/devel-api/actors/actor-devel.h>
-#include <dali/devel-api/adaptor-framework/window-devel.h>
#include <dali/devel-api/common/stage.h>
#include <dali/devel-api/object/property-helper-devel.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
}
case Toolkit::DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
{
- impl.mController->SetMatchSystemLanguageDirection(value.Get<bool>());
+ impl.mController->SetMatchLayoutDirection(value.Get<bool>() ? DevelText::MatchLayoutDirection::LOCALE : DevelText::MatchLayoutDirection::CONTENTS);
break;
}
case Toolkit::DevelTextEditor::Property::MAX_LENGTH:
}
case Toolkit::DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
{
- value = impl.mController->IsMatchSystemLanguageDirection();
+ value = impl.mController->GetMatchLayoutDirection() != DevelText::MatchLayoutDirection::CONTENTS;
break;
}
case Toolkit::DevelTextEditor::Property::MAX_LENGTH:
Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>(stage.GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
mController->SetLayoutDirection(layoutDirection);
+ self.LayoutDirectionChangedSignal().Connect(this, &TextEditor::OnLayoutDirectionChanged);
+
// Forward input events to controller
EnableGestureDetection(static_cast<GestureType::Value>(GestureType::TAP | GestureType::PAN | GestureType::LONG_PRESS));
GetTapGestureDetector().SetMaximumTapsRequired(2);
Vector2 contentSize(size.x - (padding.start + padding.end), size.y - (padding.top + padding.bottom));
// Support Right-To-Left of padding
- Dali::LayoutDirection::Type layoutDirection;
- if(mController->IsMatchSystemLanguageDirection())
- {
- layoutDirection = static_cast<Dali::LayoutDirection::Type>(DevelWindow::Get(self).GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
- }
- else
- {
- layoutDirection = static_cast<Dali::LayoutDirection::Type>(self.GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
- }
+ Dali::LayoutDirection::Type layoutDirection = mController->GetLayoutDirection(self);
+
if(Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection)
{
std::swap(padding.start, padding.end);
}
}
+void TextEditor::OnLayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
+{
+ mController->ChangedLayoutDirection();
+}
+
TextEditor::TextEditor()
: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
mAnimationPeriod(0.0f, 0.0f),
void OnScrollIndicatorAnimationFinished(Animation& animation);
/**
+ * @brief Callback function for when the layout is changed.
+ * @param[in] actor The actor whose layoutDirection is changed.
+ * @param[in] type The layoutDirection.
+ */
+ void OnLayoutDirectionChanged(Actor actor, LayoutDirection::Type type);
+
+ /**
* Construct a new TextEditor.
*/
TextEditor();
// EXTERNAL INCLUDES
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/devel-api/adaptor-framework/key-devel.h>
-#include <dali/devel-api/adaptor-framework/window-devel.h>
#include <dali/devel-api/common/stage.h>
#include <dali/devel-api/object/property-helper-devel.h>
#include <dali/integration-api/debug.h>
}
case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
{
- impl.mController->SetMatchSystemLanguageDirection(value.Get<bool>());
+ impl.mController->SetMatchLayoutDirection(value.Get<bool>() ? DevelText::MatchLayoutDirection::LOCALE : DevelText::MatchLayoutDirection::CONTENTS);
break;
}
case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
}
case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
{
- value = impl.mController->IsMatchSystemLanguageDirection();
+ value = impl.mController->GetMatchLayoutDirection() != DevelText::MatchLayoutDirection::CONTENTS;
break;
}
case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>(stage.GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
mController->SetLayoutDirection(layoutDirection);
+ self.LayoutDirectionChangedSignal().Connect(this, &TextField::OnLayoutDirectionChanged);
+
// Forward input events to controller
EnableGestureDetection(static_cast<GestureType::Value>(GestureType::TAP | GestureType::PAN | GestureType::LONG_PRESS));
GetTapGestureDetector().SetMaximumTapsRequired(2);
Vector2 contentSize(size.x - (padding.start + padding.end), size.y - (padding.top + padding.bottom));
// Support Right-To-Left of padding
- Dali::LayoutDirection::Type layoutDirection;
- if(mController->IsMatchSystemLanguageDirection())
- {
- layoutDirection = static_cast<Dali::LayoutDirection::Type>(DevelWindow::Get(self).GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
- }
- else
- {
- layoutDirection = static_cast<Dali::LayoutDirection::Type>(self.GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
- }
+ Dali::LayoutDirection::Type layoutDirection = mController->GetLayoutDirection(self);
+
if(Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection)
{
std::swap(padding.start, padding.end);
return false;
}
+void TextField::OnLayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
+{
+ mController->ChangedLayoutDirection();
+}
+
void TextField::OnIdleSignal()
{
// Emits the change of input style signals.
void EmitTextChangedSignal();
/**
+ * @brief Callback function for when the layout is changed.
+ * @param[in] actor The actor whose layoutDirection is changed.
+ * @param[in] type The layoutDirection.
+ */
+ void OnLayoutDirectionChanged(Actor actor, LayoutDirection::Type type);
+
+ /**
* Construct a new TextField.
*/
TextField();
// EXTERNAL INCLUDES
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/devel-api/adaptor-framework/image-loading.h>
-#include <dali/devel-api/adaptor-framework/window-devel.h>
#include <dali/devel-api/common/stage.h>
#include <dali/devel-api/object/property-helper-devel.h>
#include <dali/integration-api/debug.h>
}
case Toolkit::DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
{
- impl.mController->SetMatchSystemLanguageDirection(value.Get<bool>());
+ impl.mController->SetMatchLayoutDirection(value.Get<bool>() ? DevelText::MatchLayoutDirection::LOCALE : DevelText::MatchLayoutDirection::CONTENTS);
break;
}
case Toolkit::DevelTextLabel::Property::TEXT_FIT:
}
case Toolkit::DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
{
- value = impl.mController->IsMatchSystemLanguageDirection();
+ value = impl.mController->GetMatchLayoutDirection() != DevelText::MatchLayoutDirection::CONTENTS;
break;
}
case Toolkit::DevelTextLabel::Property::TEXT_FIT:
Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>(stage.GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
mController->SetLayoutDirection(layoutDirection);
+ self.LayoutDirectionChangedSignal().Connect(this, &TextLabel::OnLayoutDirectionChanged);
+
// Forward input events to controller
EnableGestureDetection(static_cast<GestureType::Value>(GestureType::TAP));
GetTapGestureDetector().SetMaximumTapsRequired(1);
{
DALI_LOG_INFO(gLogFilter, Debug::General, "TextLabel::OnRelayout\n");
+ Actor self = Self();
+
Extents padding;
- padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
+ padding = self.GetProperty<Extents>(Toolkit::Control::Property::PADDING);
Vector2 contentSize(size.x - (padding.start + padding.end), size.y - (padding.top + padding.bottom));
}
// Support Right-To-Left
- Dali::LayoutDirection::Type layoutDirection;
- if(mController->IsMatchSystemLanguageDirection())
- {
- layoutDirection = static_cast<Dali::LayoutDirection::Type>(DevelWindow::Get(Self()).GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
- }
- else
- {
- layoutDirection = static_cast<Dali::LayoutDirection::Type>(Self().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
- }
+ Dali::LayoutDirection::Type layoutDirection = mController->GetLayoutDirection(self);
+
const Text::Controller::UpdateTextType updateTextType = mController->Relayout(contentSize, layoutDirection);
if((Text::Controller::NONE_UPDATED != (Text::Controller::MODEL_UPDATED & updateTextType)) || mTextUpdateNeeded)
RequestTextRelayout();
}
+void TextLabel::OnLayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
+{
+ mController->ChangedLayoutDirection();
+}
+
TextLabel::TextLabel()
: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
mRenderingBackend(DEFAULT_RENDERING_BACKEND),
return mTextScroller;
}
+ /**
+ * @brief Callback function for when the layout is changed.
+ * @param[in] actor The actor whose layoutDirection is changed.
+ * @param[in] type The layoutDirection.
+ */
+ void OnLayoutDirectionChanged(Actor actor, LayoutDirection::Type type);
+
private: // Data
Text::ControllerPtr mController;
Text::TextScrollerPtr mTextScroller;
CharacterIndex startIndex,
Length numberOfCharacters,
Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
- bool matchSystemLanguageDirection,
+ bool matchLayoutDirection,
Dali::LayoutDirection::Type layoutDirection)
{
// Find where to insert the new paragraphs.
// Create the bidirectional info for the whole paragraph and store the index to the table with this info in the run.
bidirectionalRun.bidirectionalInfoIndex = bidirectionalSupport.CreateInfo(textBuffer + bidirectionalRun.characterRun.characterIndex,
bidirectionalRun.characterRun.numberOfCharacters,
- matchSystemLanguageDirection,
+ matchLayoutDirection,
layoutDirection);
bidirectionalRun.direction = bidirectionalSupport.GetParagraphDirection(bidirectionalRun.bidirectionalInfoIndex);
* @param[in] startIndex The character from where the bidirectional info is set.
* @param[in] numberOfCharacters The number of characters.
* @param[out] bidirectionalInfo Vector with the bidirectional infor for each paragraph.
- * @param[in] matchSystemLanguageDirection Whether match for system language direction or not.
- * @param[in] layoutDirection The direction of the system language.
+ * @param[in] matchLayoutDirection Whether match for layout direction or not.
+ * @param[in] layoutDirection The direction of the layout.
*/
void SetBidirectionalInfo(const Vector<Character>& text,
const Vector<ScriptRun>& scripts,
CharacterIndex startIndex,
Length numberOfCharacters,
Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
- bool matchSystemLanguageDirection = false,
- Dali::LayoutDirection::Type layoutDirection = LayoutDirection::LEFT_TO_RIGHT);
+ bool matchLayoutDirection = false,
+ Dali::LayoutDirection::Type layoutDirection = LayoutDirection::LEFT_TO_RIGHT);
/**
* @brief Sets the visual to logical map table for a given line.
Vector<LineRun>& lines,
float& alignmentOffset,
Dali::LayoutDirection::Type layoutDirection,
- bool matchSystemLanguageDirection)
+ bool matchLayoutDirection)
{
const CharacterIndex lastCharacterPlusOne = startIndex + numberOfCharacters;
horizontalAlignment,
line,
layoutDirection,
- matchSystemLanguageDirection);
+ matchLayoutDirection);
// Updates the alignment offset.
alignmentOffset = std::min(alignmentOffset, line.alignmentOffset);
HorizontalAlignment::Type horizontalAlignment,
LineRun& line,
Dali::LayoutDirection::Type layoutDirection,
- bool matchSystemLanguageDirection)
+ bool matchLayoutDirection)
{
line.alignmentOffset = 0.f;
const bool isLineRTL = RTL == line.direction;
float lineLength = line.width;
// match align for system language direction
- if(matchSystemLanguageDirection)
+ if(matchLayoutDirection)
{
// Swap the alignment type if the line is right to left.
isLayoutRTL = layoutDirection == LayoutDirection::RIGHT_TO_LEFT;
Vector<LineRun>& lines,
float& alignmentOffset,
Dali::LayoutDirection::Type layoutDirection,
- bool matchSystemLanguageDirection)
+ bool matchLayoutDirection)
{
mImpl->Align(size,
startIndex,
lines,
alignmentOffset,
layoutDirection,
- matchSystemLanguageDirection);
+ matchLayoutDirection);
}
void Engine::SetDefaultLineSpacing(float lineSpacing)
* @param[in] horizontalAlignment The horizontal alignment.
* @param[in,out] lines The laid-out lines.
* @param[out] alignmentOffset The alignment offset.
- * @param[in] layoutDirection The direction of the system language.
- * @param[in] matchSystemLanguageDirection Whether match align for system language direction or not.
+ * @param[in] layoutDirection The direction of the layout.
+ * @param[in] matchLayoutDirection Whether match align for layout direction or not.
*/
void Align(const Size& size,
CharacterIndex startIndex,
Vector<LineRun>& lines,
float& alignmentOffset,
Dali::LayoutDirection::Type layoutDirection,
- bool matchSystemLanguageDirection);
+ bool matchLayoutDirection);
/**
* @brief Sets the default line spacing.
startIndex,
requestedNumberOfCharacters,
bidirectionalInfo,
- mModel->mMatchSystemLanguageDirection,
+ (mModel->mMatchLayoutDirection != DevelText::MatchLayoutDirection::CONTENTS),
mLayoutDirection);
if(0u != bidirectionalInfo.Count())
cursorInfo.primaryCursorHeight = cursorInfo.lineHeight;
bool isRTL = false;
- if(mModel->mMatchSystemLanguageDirection)
+ if(mModel->mMatchLayoutDirection != DevelText::MatchLayoutDirection::CONTENTS)
{
isRTL = mLayoutDirection == LayoutDirection::RIGHT_TO_LEFT;
}
mTextFitMaxSize(DEFAULT_TEXTFIT_MAX),
mTextFitStepSize(DEFAULT_TEXTFIT_STEP),
mTextFitEnabled(false),
- mFontSizeScale(DEFAULT_FONT_SIZE_SCALE)
+ mFontSizeScale(DEFAULT_FONT_SIZE_SCALE),
+ mIsLayoutDirectionChanged(false)
{
mModel = Model::New();
Shader mShaderBackground; ///< The shader for text background.
- float mTextFitMinSize; ///< Minimum Font Size for text fit. Default 10
- float mTextFitMaxSize; ///< Maximum Font Size for text fit. Default 100
- float mTextFitStepSize; ///< Step Size for font intervalse. Default 1
- bool mTextFitEnabled : 1; ///< Whether the text's fit is enabled.
- float mFontSizeScale; ///< Scale value for Font Size. Default 1.0
+ float mTextFitMinSize; ///< Minimum Font Size for text fit. Default 10
+ float mTextFitMaxSize; ///< Maximum Font Size for text fit. Default 100
+ float mTextFitStepSize; ///< Step Size for font intervalse. Default 1
+ bool mTextFitEnabled : 1; ///< Whether the text's fit is enabled.
+ float mFontSizeScale; ///< Scale value for Font Size. Default 1.0
+ bool mIsLayoutDirectionChanged : 1; ///< Whether the layout has changed.
private:
friend ControllerImplEventHandler;
textUpdateInfo.mCharacterIndex = 0u;
}
- if(model->mMatchSystemLanguageDirection && impl.mLayoutDirection != layoutDirection)
+ if(impl.mLayoutDirection != layoutDirection)
{
// Clear the update info. This info will be set the next time the text is updated.
textUpdateInfo.mClearAll = true;
GET_GLYPH_METRICS |
SHAPE_TEXT |
UPDATE_DIRECTION |
+ ALIGN |
LAYOUT |
BIDI_INFO |
REORDER);
lines,
impl.mModel->mAlignmentOffset,
impl.mLayoutDirection,
- impl.mModel->mMatchSystemLanguageDirection);
+ (impl.mModel->mMatchLayoutDirection != DevelText::MatchLayoutDirection::CONTENTS));
viewUpdated = true;
}
#include <dali-toolkit/internal/text/text-controller.h>
// EXTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali/devel-api/adaptor-framework/window-devel.h>
#include <dali/integration-api/debug.h>
#include <memory.h>
#include <cmath>
mImpl->mModel->mIgnoreSpacesAfterText = ignore;
}
-bool Controller::IsMatchSystemLanguageDirection() const
+void Controller::ChangedLayoutDirection()
{
- return mImpl->mModel->mMatchSystemLanguageDirection;
+ mImpl->mIsLayoutDirectionChanged = true;
}
-void Controller::SetMatchSystemLanguageDirection(bool match)
+void Controller::SetMatchLayoutDirection(DevelText::MatchLayoutDirection type)
{
- mImpl->mModel->mMatchSystemLanguageDirection = match;
+ mImpl->mModel->mMatchLayoutDirection = type;
+}
+
+DevelText::MatchLayoutDirection Controller::GetMatchLayoutDirection() const
+{
+ return mImpl->mModel->mMatchLayoutDirection;
}
void Controller::SetLayoutDirection(Dali::LayoutDirection::Type layoutDirection)
mImpl->mLayoutDirection = layoutDirection;
}
+Dali::LayoutDirection::Type Controller::GetLayoutDirection(Dali::Actor& actor) const
+{
+ if(mImpl->mModel->mMatchLayoutDirection == DevelText::MatchLayoutDirection::LOCALE ||
+ (mImpl->mModel->mMatchLayoutDirection == DevelText::MatchLayoutDirection::INHERIT && !mImpl->mIsLayoutDirectionChanged))
+ {
+ return static_cast<Dali::LayoutDirection::Type>(DevelWindow::Get(actor).GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
+ }
+ else
+ {
+ return static_cast<Dali::LayoutDirection::Type>(actor.GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
+ }
+}
+
bool Controller::IsShowingRealText() const
{
return mImpl->IsShowingRealText();
void SetIgnoreSpacesAfterText(bool ignore);
/**
- * @brief Retrieves matchSystemLanguageDirection value from model
- * @return The value of matchSystemLanguageDirection
+ * @brief Sets SetMatchLayoutDirection value to model
+ * @param[in] match The value of matchLayoutDirection for the text
*/
- bool IsMatchSystemLanguageDirection() const;
+ void SetMatchLayoutDirection(DevelText::MatchLayoutDirection type);
/**
- * @brief Sets matchSystemLanguageDirection value to model
- * @param[in] match The value of matchSystemLanguageDirection for the text
+ * @brief Retrieves matchLayoutDirection value from model
+ * @return The value of matchLayoutDirection
*/
- void SetMatchSystemLanguageDirection(bool match);
+ DevelText::MatchLayoutDirection GetMatchLayoutDirection() const;
/**
- * @brief Sets layoutDirection value
- * @param[in] layoutDirection The value of system language direction
+ * @brief Sets layoutDirection type value.
+ * @param[in] layoutDirection The value of the layout direction type.
*/
void SetLayoutDirection(Dali::LayoutDirection::Type layoutDirection);
/**
+ * @brief Gets layoutDirection type value.
+ * @param[in] actor The actor which will get the layout direction type.
+ * @return The value of the layout direction type.
+ */
+ Dali::LayoutDirection::Type GetLayoutDirection(Dali::Actor& actor) const;
+
+ /**
+ * @brief Sets the layout direction changed.
+ */
+ void ChangedLayoutDirection();
+
+ /**
* @brief Retrieves if showing real text or not.
* @return The value of showing real text.
*/
mAlignmentOffset(0.0f),
mElideEnabled(false),
mIgnoreSpacesAfterText(true),
- mMatchSystemLanguageDirection(true)
+ mMatchLayoutDirection(DevelText::MatchLayoutDirection::INHERIT)
{
mLogicalModel = LogicalModel::New();
mVisualModel = VisualModel::New();
// Check environment variable for DALI_MATCH_SYSTEM_LANGUAGE_DIRECTION
- auto match = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_MATCH_SYSTEM_LANGUAGE_DIRECTION);
- mMatchSystemLanguageDirection = match ? (std::atoi(match) == 0 ? false : true) : mMatchSystemLanguageDirection;
+ auto match = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_MATCH_SYSTEM_LANGUAGE_DIRECTION);
+ if(match && (std::atoi(match) == 0))
+ {
+ mMatchLayoutDirection = DevelText::MatchLayoutDirection::CONTENTS;
+ }
}
Model::~Model()
* 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
* Typically this will have a negative value with scrolling occurs.
*/
- Vector2 mScrollPosition; ///< The text is offset by this position when scrolling.
- Vector2 mScrollPositionLast; ///< The last offset value of mScrollPosition
- HorizontalAlignment::Type mHorizontalAlignment; ///< The layout's horizontal alignment.
- VerticalAlignment::Type mVerticalAlignment; ///< The layout's vertical alignment.
- DevelText::VerticalLineAlignment::Type mVerticalLineAlignment; ///< The layout's vertical line alignment.
- Text::LineWrap::Mode mLineWrapMode; ///< The text wrap mode
- float mAlignmentOffset; ///< The alignment offset.
- bool mElideEnabled : 1; ///< Whether the text's elide is enabled.
- bool mIgnoreSpacesAfterText : 1; ///< Whether ignoring spaces after text or not. Default is true.
- bool mMatchSystemLanguageDirection : 1; ///< Whether match align for system language direction or not. Default is false.
+ Vector2 mScrollPosition; ///< The text is offset by this position when scrolling.
+ Vector2 mScrollPositionLast; ///< The last offset value of mScrollPosition
+ HorizontalAlignment::Type mHorizontalAlignment; ///< The layout's horizontal alignment.
+ VerticalAlignment::Type mVerticalAlignment; ///< The layout's vertical alignment.
+ DevelText::VerticalLineAlignment::Type mVerticalLineAlignment; ///< The layout's vertical line alignment.
+ Text::LineWrap::Mode mLineWrapMode; ///< The text wrap mode
+ float mAlignmentOffset; ///< The alignment offset.
+ bool mElideEnabled : 1; ///< Whether the text's elide is enabled.
+ bool mIgnoreSpacesAfterText : 1; ///< Whether ignoring spaces after text or not. Default is true.
+ DevelText::MatchLayoutDirection mMatchLayoutDirection; ///< Whether to match text alignment with layout direction or not.
};
} // namespace Text
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/image-loading.h>
-#include <dali/devel-api/adaptor-framework/window-devel.h>
#include <dali/devel-api/images/pixel-data-devel.h>
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
return;
}
- Dali::LayoutDirection::Type layoutDirection;
- if(mController->IsMatchSystemLanguageDirection())
- {
- layoutDirection = static_cast<Dali::LayoutDirection::Type>(DevelWindow::Get(control).GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
- }
- else
- {
- layoutDirection = static_cast<Dali::LayoutDirection::Type>(control.GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
- }
+ Dali::LayoutDirection::Type layoutDirection = mController->GetLayoutDirection(control);
const Text::Controller::UpdateTextType updateTextType = mController->Relayout(relayoutSize, layoutDirection);