Use visual model's GetHeightForWidth instead of GetLayoutSize.
In the case of text label,
the height of the layout is used when returning the cached value of GetHeightForWidth.
But, this value is the height of the layout that has been Ellipsis processed.
It's not the height of the entire Text.
So, the intended height cannot be obtained.
This patch simply stores calculated values.
Change-Id: I0494fb476964fb1207d35e3c8e6eb25ece972025
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
VisualModelPtr& visualModel = model->mVisualModel;
TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo;
- Size layoutSize;
+ // Get cached value.
+ Size layoutSize = visualModel->GetHeightForWidth();
- if(fabsf(width - visualModel->mControlSize.width) > Math::MACHINE_EPSILON_1000 ||
+ if(fabsf(width - layoutSize.width) > Math::MACHINE_EPSILON_1000 ||
textUpdateInfo.mFullRelayoutNeeded ||
textUpdateInfo.mClearAll)
{
layoutSize = CalculateLayoutSizeOnRequiredControllerSize(controller, sizeRequestedWidthAndMaxHeight, requestedOperationsMask);
+ // The calculated layout width may not be the same as the requested width.
+ // For cache efficiency, the requested width is stored.
+ layoutSize.width = width;
+ visualModel->SetHeightForWidth(layoutSize);
+
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth calculated %f\n", layoutSize.height);
}
else
{
- layoutSize = visualModel->GetLayoutSize();
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth cached %f\n", layoutSize.height);
}
return mLayoutSize;
}
+void VisualModel::SetHeightForWidth(const Vector2& size)
+{
+ mHeightForWidth = size;
+}
+
+const Vector2& VisualModel::GetHeightForWidth() const
+{
+ return mHeightForWidth;
+}
+
void VisualModel::SetTextColor(const Vector4& textColor)
{
mTextColor = textColor;
mOutlineWidth(0u),
mNaturalSize(),
mLayoutSize(),
+ mHeightForWidth(0.0f, 0.0f),
mCachedLineIndex(0u),
mEllipsisPosition(DevelText::EllipsisPosition::END),
mStartIndexOfElidedGlyphs(0u),
*/
const Vector2& GetLayoutSize() const;
+ /**
+ * @brief Sets the size of height for width.
+ *
+ * @param[in] size The text's height for width size.
+ */
+ void SetHeightForWidth(const Vector2& size);
+
+ /**
+ * @brief Retrieves the height for width size.
+ *
+ * @return The text's height for width size.
+ */
+ const Vector2& GetHeightForWidth() const;
+
/**
* @brief Set the text's color
*
Vector<CharacterSpacingGlyphRun> mCharacterSpacingRuns; ///< Runs of glyphs that have character-spacing.
private:
- Size mNaturalSize; ///< Size of the text with no line wrapping.
- Size mLayoutSize; ///< Size of the laid-out text considering the layout properties set.
+ Size mNaturalSize; ///< Size of the text with no line wrapping.
+ Size mLayoutSize; ///< Size of the laid-out text considering the layout properties set.
+ Size mHeightForWidth; ///< Size of the text last calculated using GetHeightForWidth.
// Caches to increase performance in some consecutive operations.
LineIndex mCachedLineIndex; ///< Used to increase performance in consecutive calls to GetLineOfGlyph() or GetLineOfCharacter() with consecutive glyphs or characters.