Requests asynchronous rendering with the maximum available width using the given widthConstraint.
If the width of the text content is smaller than the widthConstraint, the width will be determined by the width of the text.
If the width of the text content is larger than the widthConstraint, the width will be determined by the widthConstraint.
The height is determined by the content of the text when rendered with the given width.
In this case, the result will be the same as the height returned by GetHeightForWidth.
Change-Id: I375b70172267d24468eb9c9bbfd60e98ce80d190
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
GetImpl(textLabel).RequestAsyncRenderWithFixedWidth(width);
}
+void RequestAsyncRenderWithConstraint(TextLabel textLabel, float widthConstraint)
+{
+ GetImpl(textLabel).RequestAsyncRenderWithConstraint(widthConstraint);
+}
+
} // namespace DevelTextLabel
} // namespace Toolkit
DALI_TOOLKIT_API void RequestAsyncRenderWithFixedWidth(TextLabel textLabel, float width);
/**
+ * @brief Requests asynchronous rendering with the maximum available width using the given widthConstraint.
+ *
+ * If the width of the text content is smaller than the widthConstraint, the width will be determined by the width of the text.
+ * If the width of the text content is larger than the widthConstraint, the width will be determined by the widthConstraint.
+ * The height is determined by the content of the text when rendered with the given width.
+ * In this case, the result will be the same as the height returned by GetHeightForWidth.
+ *
+ * @param[in] textLabel The instance of TextLabel.
+ * @param[in] widthConstraint The maximum available width of text to render.
+ */
+DALI_TOOLKIT_API void RequestAsyncRenderWithConstraint(TextLabel textLabel, float widthConstraint);
+
+/**
* @brief Anchor clicked signal type.
*
* @note Signal
}
AsyncTextParameters parameters = GetAsyncTextParameters(contentSize, padding, layoutDirection);
+ parameters.renderType = AsyncTextParameters::FIXED_SIZE;
+
TextVisual::UpdateAsyncRenderer(mVisual, parameters);
mTextUpdateNeeded = false;
mIsPropertyUpdated = false;
}
AsyncTextParameters parameters = GetAsyncTextParameters(contentSize, padding, layoutDirection);
- parameters.isFixedSize = false;
- parameters.isFixedWidth = true;
+ parameters.renderType = AsyncTextParameters::FIXED_WIDTH;
+
+ TextVisual::UpdateAsyncRenderer(mVisual, parameters);
+ mTextUpdateNeeded = false;
+ mIsPropertyUpdated = false;
+}
+
+void TextLabel::RequestAsyncRenderWithConstraint(float widthConstraint)
+{
+ DALI_LOG_RELEASE_INFO("Request width constraint : %f\n", widthConstraint);
+
+ if(!mController->IsAsyncTextLoadEnabled())
+ {
+ DALI_LOG_WARNING("IsAsyncTextLoadEnabled is false\n");
+ return;
+ }
+
+ Actor self = Self();
+
+ Extents padding;
+ padding = self.GetProperty<Extents>(Toolkit::Control::Property::PADDING);
+
+ Vector2 contentSize(widthConstraint - (padding.start + padding.end), 0.0f);
+
+ // Support Right-To-Left
+ Dali::LayoutDirection::Type layoutDirection = mController->GetLayoutDirection(self);
+
+ // Support Right-To-Left of padding
+ if(Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection)
+ {
+ std::swap(padding.start, padding.end);
+ }
+
+ AsyncTextParameters parameters = GetAsyncTextParameters(contentSize, padding, layoutDirection);
+ parameters.renderType = AsyncTextParameters::CONSTRAINT;
TextVisual::UpdateAsyncRenderer(mVisual, parameters);
mTextUpdateNeeded = false;
*/
void RequestAsyncRenderWithFixedSize(float width, float height);
-/**
- * @brief Requests asynchronous text rendering with a fixed width.
- * The height is determined by the content of the text when rendered with the given width.
- * The result will be the same as the height returned by GetHeightForWidth.
- *
- * @param[in] width The width of text to render.
- */
+ /**
+ * @brief Requests asynchronous text rendering with a fixed width.
+ * The height is determined by the content of the text when rendered with the given width.
+ * The result will be the same as the height returned by GetHeightForWidth.
+ *
+ * @param[in] width The width of text to render.
+ */
void RequestAsyncRenderWithFixedWidth(float width);
+ /**
+ * @brief Requests asynchronous rendering with the maximum available width using the given widthConstraint.
+ *
+ * If the width of the text content is smaller than the widthConstraint, the width will be determined by the width of the text.
+ * If the width of the text content is larger than the widthConstraint, the width will be determined by the widthConstraint.
+ * The height is determined by the content of the text when rendered with the given width.
+ * In this case, the result will be the same as the height returned by GetHeightForWidth.
+ *
+ * @param[in] widthConstraint The maximum available width of text to render.
+ */
+ void RequestAsyncRenderWithConstraint(float widthConstraint);
+
+
private: // From Control
/**
* @copydoc Control::OnInitialize()
{
renderInfo.renderedSize = Size(static_cast<float>(renderInfo.width), static_cast<float>(renderInfo.height));
}
- else if(parameters.isFixedSize || parameters.isFixedWidth)
+ else
{
renderInfo.renderedSize = Size(static_cast<float>(parameters.textWidth), static_cast<float>(parameters.textHeight));
}
{
DALI_LOG_RELEASE_INFO("-->AsyncTextLoader::RenderText\n");
- if(parameters.isFixedWidth)
+ if(parameters.renderType == AsyncTextParameters::CONSTRAINT)
+ {
+ Size textNaturalSize = ComputeNaturalSize(parameters);
+ // textWidth is widthConstraint
+ if(parameters.textWidth > textNaturalSize.width)
+ {
+ parameters.textWidth = static_cast<uint32_t>(textNaturalSize.width);
+ }
+ }
+
+ if(parameters.renderType == AsyncTextParameters::FIXED_WIDTH || parameters.renderType == AsyncTextParameters::CONSTRAINT)
{
uint32_t height = ComputeHeightForWidth(parameters, parameters.textWidth);
parameters.textHeight = height;
textNaturalSize.width += (parameters.padding.start + parameters.padding.end);
textNaturalSize.height += (parameters.padding.top + parameters.padding.bottom);
- if(parameters.isFixedWidth)
+ if(parameters.renderType == AsyncTextParameters::FIXED_WIDTH || parameters.renderType == AsyncTextParameters::CONSTRAINT)
{
// In case of a fixed width, textHeight is zero.
// The height calculated during layout should be set.
AsyncTextRenderInfo AsyncTextLoader::RenderTextFit(AsyncTextParameters& parameters)
{
- if(parameters.isFixedWidth)
+ if(parameters.renderType == AsyncTextParameters::CONSTRAINT)
+ {
+ Size textNaturalSize = ComputeNaturalSize(parameters);
+ // textWidth is widthConstraint
+ if(parameters.textWidth > textNaturalSize.width)
+ {
+ parameters.textWidth = static_cast<uint32_t>(textNaturalSize.width);
+ }
+ }
+
+ if(parameters.renderType == AsyncTextParameters::FIXED_WIDTH || parameters.renderType == AsyncTextParameters::CONSTRAINT)
{
uint32_t height = ComputeHeightForWidth(parameters, parameters.textWidth);
parameters.textHeight = height;
struct AsyncTextParameters
{
+ enum RenderType
+ {
+ FIXED_SIZE,
+ FIXED_WIDTH,
+ CONSTRAINT
+ };
+
AsyncTextParameters()
- : isFixedSize{true},
- isFixedWidth{false},
+ : renderType{FIXED_SIZE},
maxTextureSize{0},
text{},
fontSize{0.f},
{
}
- bool isFixedSize;
- bool isFixedWidth;
+ RenderType renderType;
int maxTextureSize; ///< The maximum size of texture.
mAsyncTextInterface->AsyncLoadComplete(renderInfo);
}
+ // Ignore current result when user re-request async load during load complete callback.
+ if(mIsTaskRunning)
+ {
+ // Remove the texture set and any renderer previously set.
+ RemoveRenderer(control, true);
+ return;
+ }
}
else
{
return;
}
- if(!parameters.isFixedWidth && ((fabsf(parameters.textWidth) < Math::MACHINE_EPSILON_1000) || (fabsf(parameters.textHeight) < Math::MACHINE_EPSILON_1000) || parameters.text.empty()))
+ if(parameters.renderType == Text::AsyncTextParameters::FIXED_SIZE &&
+ ((fabsf(parameters.textWidth) < Math::MACHINE_EPSILON_1000) || (fabsf(parameters.textHeight) < Math::MACHINE_EPSILON_1000) || parameters.text.empty()))
{
// Remove the texture set and any renderer previously set.
RemoveRenderer(control, true);