// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/Math/Rectangle.h" /// /// Specifies the alignment of the text along horizontal or vertical direction in the layout box. /// API_ENUM() enum class TextAlignment { /// /// Align text near the edge. /// Near = 0, /// /// Align text to the center. /// Center, /// /// Align text to the far edge. /// Far, }; /// /// Specifies text wrapping to be used in a particular multiline paragraph. /// API_ENUM() enum class TextWrapping { /// /// No text wrapping. /// NoWrap = 0, /// /// Wrap only whole words that overflow. /// WrapWords, /// /// Wrap single characters that overflow. /// WrapChars, }; /// /// Structure which describes text layout properties. /// API_STRUCT(NoDefault) struct TextLayoutOptions { DECLARE_SCRIPTING_TYPE_MINIMAL(TextLayoutOptions); /// /// The layout rectangle (text bounds). /// API_FIELD(Attributes="EditorOrder(0)") Rectangle Bounds; /// /// The horizontal alignment mode. /// API_FIELD(Attributes="EditorOrder(10)") TextAlignment HorizontalAlignment; /// /// The vertical alignment mode. /// API_FIELD(Attributes="EditorOrder(20)") TextAlignment VerticalAlignment; /// /// The text wrapping mode. /// API_FIELD(Attributes="EditorOrder(30), DefaultValue(TextWrapping.NoWrap)") TextWrapping TextWrapping; /// /// The text scale factor. Default is 1. /// API_FIELD(Attributes="EditorOrder(40), DefaultValue(1.0f), Limit(-1000, 1000, 0.01f)") float Scale; /// /// Base line gap scale. Default is 1. /// API_FIELD(Attributes="EditorOrder(50), DefaultValue(1.0f), Limit(-1000, 1000, 0.01f)") float BaseLinesGapScale; /// /// Initializes a new instance of the struct. /// TextLayoutOptions() { Bounds = Rectangle(0, 0, MAX_float, MAX_float); HorizontalAlignment = TextAlignment::Near; VerticalAlignment = TextAlignment::Near; TextWrapping = TextWrapping::NoWrap; Scale = 1.0f; BaseLinesGapScale = 1.0f; } FORCE_INLINE bool operator==(const TextLayoutOptions& other) const { return Bounds == other.Bounds && HorizontalAlignment == other.HorizontalAlignment && VerticalAlignment == other.VerticalAlignment && TextWrapping == other.TextWrapping && Math::NearEqual(Scale, other.Scale) && Math::NearEqual(BaseLinesGapScale, other.BaseLinesGapScale); } FORCE_INLINE bool operator!=(const TextLayoutOptions& other) const { return !operator==(other); } };