From: ANZ1217 Date: Wed, 12 Jun 2024 06:24:13 +0000 (+0900) Subject: Fix TextLabel's padding was not applied during Cutout. X-Git-Tag: dali_2.3.29~11^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7c4ac9df5becaaa2613ffbbb2824882683f527a;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Fix TextLabel's padding was not applied during Cutout. Change-Id: I8aa0f35d2214aeb748efa874c9b524a365925f72 --- diff --git a/dali-toolkit/internal/text/controller/text-controller.cpp b/dali-toolkit/internal/text/controller/text-controller.cpp index ca2c5f2..7b87c2f 100644 --- a/dali-toolkit/internal/text/controller/text-controller.cpp +++ b/dali-toolkit/internal/text/controller/text-controller.cpp @@ -1568,6 +1568,11 @@ const Vector4 Controller::GetBackgroundColorWithCutout() const return mImpl->mModel->mVisualModel->GetBackgroundColorWithCutout(); } +void Controller::SetOffsetWithCutout(const Vector2& offset) +{ + mImpl->mModel->mVisualModel->SetOffsetWithCutout(offset); +} + Controller::UpdateTextType Controller::Relayout(const Size& size, Dali::LayoutDirection::Type layoutDirection) { return Relayouter::Relayout(*this, size, layoutDirection); diff --git a/dali-toolkit/internal/text/controller/text-controller.h b/dali-toolkit/internal/text/controller/text-controller.h index 20ad0f0..c9ab3c0 100644 --- a/dali-toolkit/internal/text/controller/text-controller.h +++ b/dali-toolkit/internal/text/controller/text-controller.h @@ -1704,6 +1704,13 @@ public: // Default style & Input style */ const Vector4 GetBackgroundColorWithCutout() const; + /** + * @brief Sets offset with cutout. + * + * @param[in] offset The offset. + */ + void SetOffsetWithCutout(const Vector2& offset); + public: // Queries & retrieves. /** * @brief Return the layout engine. diff --git a/dali-toolkit/internal/text/rendering/text-typesetter.cpp b/dali-toolkit/internal/text/rendering/text-typesetter.cpp index ec6dce2..ef8b7ca 100644 --- a/dali-toolkit/internal/text/rendering/text-typesetter.cpp +++ b/dali-toolkit/internal/text/rendering/text-typesetter.cpp @@ -1011,6 +1011,14 @@ Devel::PixelBuffer Typesetter::RenderWithPixelBuffer(const Vector2& size, Toolki } } + const bool isCutoutEnabled = mModel->IsCutoutEnabled(); + if(isCutoutEnabled) + { + Vector2 offset = mModel->GetOffsetWithCutout(); + penX += offset.x; + penY += offset.y; + } + // Generate the image buffers of the text for each different style first, // then combine all of them together as one final image buffer. We try to // do all of these in CPU only, so that once the final texture is generated, diff --git a/dali-toolkit/internal/text/rendering/view-model.cpp b/dali-toolkit/internal/text/rendering/view-model.cpp index 7e3a4e3..0c31c04 100644 --- a/dali-toolkit/internal/text/rendering/view-model.cpp +++ b/dali-toolkit/internal/text/rendering/view-model.cpp @@ -794,6 +794,11 @@ const Vector4& ViewModel::GetBackgroundColorWithCutout() const return mModel->GetBackgroundColorWithCutout(); } +const Vector2& ViewModel::GetOffsetWithCutout() const +{ + return mModel->GetOffsetWithCutout(); +} + } // namespace Text } // namespace Toolkit diff --git a/dali-toolkit/internal/text/rendering/view-model.h b/dali-toolkit/internal/text/rendering/view-model.h index dc7363d..1b3ec1a 100644 --- a/dali-toolkit/internal/text/rendering/view-model.h +++ b/dali-toolkit/internal/text/rendering/view-model.h @@ -413,6 +413,11 @@ public: */ const Vector4& GetBackgroundColorWithCutout() const override; + /** + * @copydoc ModelInterface::GetOffsetWithCutout() + */ + const Vector2& GetOffsetWithCutout() const override; + private: const ModelInterface* const mModel; ///< Pointer to the text's model. Vector mElidedGlyphs; ///< Stores the glyphs of the elided text. diff --git a/dali-toolkit/internal/text/text-model-interface.h b/dali-toolkit/internal/text/text-model-interface.h index ba9f6ca..5083b0f 100644 --- a/dali-toolkit/internal/text/text-model-interface.h +++ b/dali-toolkit/internal/text/text-model-interface.h @@ -543,6 +543,13 @@ public: * @return The color of the background with cutout. */ virtual const Vector4& GetBackgroundColorWithCutout() const = 0; + + /** + * @brief Retrieves the left and top offset with cutout. + * + * @return The offset with cutout. + */ + virtual const Vector2& GetOffsetWithCutout() const = 0; }; } // namespace Text diff --git a/dali-toolkit/internal/text/text-model.cpp b/dali-toolkit/internal/text/text-model.cpp index bbe126b..9a4e761 100644 --- a/dali-toolkit/internal/text/text-model.cpp +++ b/dali-toolkit/internal/text/text-model.cpp @@ -381,6 +381,11 @@ const Vector4& Model::GetBackgroundColorWithCutout() const return mVisualModel->GetBackgroundColorWithCutout(); } +const Vector2& Model::GetOffsetWithCutout() const +{ + return mVisualModel->GetOffsetWithCutout(); +} + Model::Model() : mLogicalModel(), mVisualModel(), diff --git a/dali-toolkit/internal/text/text-model.h b/dali-toolkit/internal/text/text-model.h index 5661035..c94362d 100644 --- a/dali-toolkit/internal/text/text-model.h +++ b/dali-toolkit/internal/text/text-model.h @@ -399,6 +399,11 @@ public: */ const Vector4& GetBackgroundColorWithCutout() const override; + /** + * @copydoc ModelInterface::GetOffsetWithCutout() + */ + const Vector2& GetOffsetWithCutout() const override; + private: // Private contructors & copy operator. /** * @brief Private constructor. diff --git a/dali-toolkit/internal/text/visual-model-impl.cpp b/dali-toolkit/internal/text/visual-model-impl.cpp index 3fdd6b8..2f3ea3e 100644 --- a/dali-toolkit/internal/text/visual-model-impl.cpp +++ b/dali-toolkit/internal/text/visual-model-impl.cpp @@ -695,6 +695,16 @@ const Vector4& VisualModel::GetBackgroundColorWithCutout() const return mBackgroundColorWithCutout; } +void VisualModel::SetOffsetWithCutout(const Vector2& offset) +{ + mOffsetWithCutout = offset; +} + +const Vector2& VisualModel::GetOffsetWithCutout() const +{ + return mOffsetWithCutout; +} + VisualModel::~VisualModel() { } diff --git a/dali-toolkit/internal/text/visual-model-impl.h b/dali-toolkit/internal/text/visual-model-impl.h index 7ef55b5..e391113 100644 --- a/dali-toolkit/internal/text/visual-model-impl.h +++ b/dali-toolkit/internal/text/visual-model-impl.h @@ -704,6 +704,20 @@ public: */ const Vector4& GetBackgroundColorWithCutout() const; + /** + * @brief Sets the left and top offset with cutout. + * + * @param[in] offset The offset to set. + */ + void SetOffsetWithCutout(const Vector2& offset); + + /** + * @brief Retrieves the left and top offset with cutout. + * + * @return The offset. + */ + const Vector2& GetOffsetWithCutout() const; + protected: /** * @brief A reference counted object may only be deleted by calling Unreference(). @@ -750,11 +764,12 @@ public: float mDashedUnderlineWidth; ///< The width of the dashes of the dashed underline. float mDashedUnderlineGap; ///< The gap between the dashes of the dashed underline. float mShadowBlurRadius; ///< Blur radius of shadow, 0 indicates no blur. - float mOutlineBlurRadius; ///< Blur radius of outline, 0 indicates no blur. + float mOutlineBlurRadius; ///< Blur radius of outline, 0 indicates no blur. uint16_t mOutlineWidth; ///< Width of outline. Vector mStrikethroughRuns; ///< Runs of glyphs that have strikethrough. Vector mCharacterSpacingRuns; ///< Runs of glyphs that have character-spacing. Vector4 mBackgroundColorWithCutout; ///< Background color with cutout. + Vector2 mOffsetWithCutout; ///< Left and top offset when cutout. private: Size mNaturalSize; ///< Size of the text with no line wrapping. diff --git a/dali-toolkit/internal/visuals/text/text-visual.cpp b/dali-toolkit/internal/visuals/text/text-visual.cpp index 55296d6..e1c2d0f 100644 --- a/dali-toolkit/internal/visuals/text/text-visual.cpp +++ b/dali-toolkit/internal/visuals/text/text-visual.cpp @@ -590,11 +590,21 @@ void TextVisual::UpdateRenderer() if(cutoutEnabled) { - relayoutSize = Vector2(controlWidth, controlHeight); - mImpl->mTransform.mSize.width = controlWidth; + // mTransform stores the size and offset of the current visual. + // padding and alignment information is stored in mOffset. + // When Cutout Enabled, the current visual must draw the entire control. + // so set the size to controlSize and offset to 0. + + relayoutSize = Vector2(controlWidth, controlHeight); + mImpl->mTransform.mSize.width = controlWidth; mImpl->mTransform.mSize.height = controlHeight; - mImpl->mTransform.mOffset.x = 0; - mImpl->mTransform.mOffset.y = 0; + + // Relayout to the original size has been completed, so save only the offset information and use it in typesetter. + + Vector2 originOffset = Vector2(mImpl->mTransform.mOffset.x, mImpl->mTransform.mOffset.y); + mController->SetOffsetWithCutout(originOffset); + mImpl->mTransform.mOffset.x = 0; + mImpl->mTransform.mOffset.y = 0; } AddRenderer(control, relayoutSize, hasMultipleTextColors, containsColorGlyph, styleEnabled, isOverlayStyle);