Copy text from Spanned-Text into TextController and apply styles on it.
void SetSpannedText(TextController textController, const Spanned& spannedText);
TextController: TextLabel, TextEditor or TextField
This patch should be preceded by the patch below:
https://review.tizen.org/gerrit/c/platform/core/uifw/dali-toolkit/+/282806
//Example:
Dali::Toolkit::Text::SpannableString ss = Dali::Toolkit::Text::SpannableString::New("Hello مرحبا");
auto isAddedBlue = ss.AttachSpan(
Dali::Toolkit::Text::ForegroundColorSpan::New(Color::BLUE),
Dali::Toolkit::Text::Range::New(2u, 4u));
Dali::Toolkit::Text::SetSpannedText(textLabel, ss);
Change-Id: I03202eb27376d78403050a284a1448f01c4ac120
utc-Dali-Text-MultiLanguage.cpp
utc-Dali-Text-Segmentation.cpp
utc-Dali-Text-Shaping.cpp
+ utc-Dali-Text-TextSpannable.cpp
utc-Dali-Text-Typesetter.cpp
utc-Dali-Text-ViewModel.cpp
utc-Dali-TextField-internal.cpp
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <iostream>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-spannable.h>
+#include <dali-toolkit/devel-api/text/spannable-string.h>
+#include <dali-toolkit/devel-api/text/spans/foreground-color-span.h>
+#include <dali-toolkit/internal/controls/text-controls/text-editor-impl.h>
+#include <dali-toolkit/internal/controls/text-controls/text-field-impl.h>
+#include <dali-toolkit/internal/controls/text-controls/text-label-impl.h>
+
+using namespace Dali;
+using namespace Toolkit;
+
+Text::SpannableString CreateSpannableStringForForegroundColorSpan()
+{
+ Text::SpannableString spannableString = Text::SpannableString::New("Hello مرحبا");
+ DALI_TEST_CHECK(spannableString);
+
+ auto isAddedGreen = spannableString.AttachSpan(
+ Text::ForegroundColorSpan::New(Color::GREEN),
+ Text::Range::New(5u, 7u));
+ DALI_TEST_CHECK(isAddedGreen);
+
+ auto isAddedBlue = spannableString.AttachSpan(
+ Text::ForegroundColorSpan::New(Color::BLUE),
+ Text::Range::New(1u, 2u));
+ DALI_TEST_CHECK(isAddedBlue);
+
+ return spannableString;
+}
+
+void CheckColorIndices(const Text::ColorIndex* const colorIndicesBuffer,
+ uint32_t numberOfIndices,
+ std::vector<uint32_t> indicesToCheck,
+ std::vector<uint32_t> expectedValues)
+{
+ DALI_TEST_CHECK(colorIndicesBuffer);
+
+ for(uint32_t i = 0u; i < numberOfIndices; i++)
+ {
+ DALI_TEST_EQUALS(colorIndicesBuffer[indicesToCheck[i]], expectedValues[i], TEST_LOCATION);
+ }
+}
+
+int UtcDaliToolkitTextLabelSetSpannedText(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextLabelSetSpannedText");
+
+ TextLabel textLabel = TextLabel::New();
+ DALI_TEST_CHECK(textLabel);
+ application.GetScene().Add(textLabel);
+
+ Text::SpannableString spannableString = CreateSpannableStringForForegroundColorSpan();
+
+ Text::SetSpannedText(textLabel, spannableString);
+
+ application.SendNotification();
+ application.Render();
+
+ Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel);
+ const Text::ColorIndex* const colorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetColorIndices();
+
+ CheckColorIndices(colorIndicesBuffer, 6u, {0u, 1u, 2u, 5u, 7u, 10u}, {0u, 2u, 2u, 1u, 1u, 0u});
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextEditorSetSpannedText(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextEditorSetSpannedText");
+
+ TextEditor textEditor = TextEditor::New();
+ DALI_TEST_CHECK(textEditor);
+ application.GetScene().Add(textEditor);
+
+ Text::SpannableString spannableString = CreateSpannableStringForForegroundColorSpan();
+
+ Text::SetSpannedText(textEditor, spannableString);
+
+ application.SendNotification();
+ application.Render();
+
+ Toolkit::Internal::TextEditor& labelImpl = GetImpl(textEditor);
+ const Text::ColorIndex* const colorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetColorIndices();
+
+ CheckColorIndices(colorIndicesBuffer, 6u, {0u, 1u, 2u, 5u, 7u, 10u}, {0u, 2u, 2u, 1u, 1u, 0u});
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextFieldSetSpannedText(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextFieldSetSpannedText");
+
+ TextField textField = TextField::New();
+ DALI_TEST_CHECK(textField);
+ application.GetScene().Add(textField);
+
+ Text::SpannableString spannableString = CreateSpannableStringForForegroundColorSpan();
+
+ Text::SetSpannedText(textField, spannableString);
+
+ application.SendNotification();
+ application.Render();
+
+ Toolkit::Internal::TextField& labelImpl = GetImpl(textField);
+ const Text::ColorIndex* const colorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetColorIndices();
+
+ CheckColorIndices(colorIndicesBuffer, 6u, {0u, 1u, 2u, 5u, 7u, 10u}, {0u, 2u, 2u, 1u, 1u, 0u});
+
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/text-controls/text-spannable.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
+#include <dali-toolkit/internal/controls/text-controls/text-editor-impl.h>
+#include <dali-toolkit/internal/controls/text-controls/text-field-impl.h>
+#include <dali-toolkit/internal/controls/text-controls/text-label-impl.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+void SetSpannedText(TextLabel textLabel, const Spanned& spannedText)
+{
+ return GetImpl(textLabel).SetSpannedText(spannedText);
+}
+
+void SetSpannedText(TextField textField, const Spanned& spannedText)
+{
+ return GetImpl(textField).SetSpannedText(spannedText);
+}
+
+void SetSpannedText(TextEditor textEditor, const Spanned& spannedText)
+{
+ return GetImpl(textEditor).SetSpannedText(spannedText);
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_TEXT_SPANNABLE_H
+#define DALI_TOOLKIT_TEXT_TEXT_SPANNABLE_H
+
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/text/spanned.h>
+#include <dali-toolkit/public-api/controls/text-controls/text-editor.h>
+#include <dali-toolkit/public-api/controls/text-controls/text-field.h>
+#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+/**
+ * @brief Set the @p spannedText into @p textLabel
+ * the spanned text contains content (text) and format (spans with ranges)
+ * the text is copied into text-controller and the spans are applied on ranges
+ *
+ * @note the TEXT in @p textLabel will be replaced with text from @p spannedText
+ * and all the applied styles @p textLabel will be replaced the styles from @p spannedText
+ * in-case there are styles were applied from markup-processor will be removed
+ *
+ *
+ * @param[in] textLabel The instance of TextLabel.
+ * @param[in] spannedText the text with spans.
+ */
+DALI_TOOLKIT_API void SetSpannedText(TextLabel textLabel, const Spanned& spannedText);
+
+/**
+ * @brief Set the @p spannedText into @p textField
+ * the spanned text contains content (text) and format (spans with ranges)
+ * the text is copied into text-controller and the spans are applied on ranges
+ *
+ * @note the TEXT in @p textField will be replaced with text from @p spannedText
+ * and all the applied styles @p textField will be replaced the styles from @p spannedText
+ * in-case there are styles were applied from markup-processor will be removed
+ *
+ *
+ * @param[in] textField The instance of TextField.
+ * @param[in] spannedText the text with spans.
+ */
+DALI_TOOLKIT_API void SetSpannedText(TextField textField, const Spanned& spannedText);
+
+/**
+ * @brief Set the @p spannedText into @p textEditor
+ * the spanned text contains content (text) and format (spans with ranges)
+ * the text is copied into text-controller and the spans are applied on ranges
+ *
+ * @note the TEXT in @p textEditor will be replaced with text from @p spannedText
+ * and all the applied styles @p textEditor will be replaced the styles from @p spannedText
+ * in-case there are styles were applied from markup-processor will be removed
+ *
+ *
+ * @param[in] textEditor The instance of TextEditor.
+ * @param[in] spannedText the text with spans.
+ */
+DALI_TOOLKIT_API void SetSpannedText(TextEditor textEditor, const Spanned& spannedText);
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_TEXT_SPANNABLE_H
${devel_api_src_dir}/controls/text-controls/text-editor-devel.cpp
${devel_api_src_dir}/controls/text-controls/text-field-devel.cpp
${devel_api_src_dir}/controls/text-controls/text-label-devel.cpp
+ ${devel_api_src_dir}/controls/text-controls/text-spannable.cpp
${devel_api_src_dir}/controls/text-controls/text-selection-popup.cpp
${devel_api_src_dir}/controls/text-controls/text-selection-toolbar.cpp
${devel_api_src_dir}/controls/tool-bar/tool-bar.cpp
${devel_api_src_dir}/controls/text-controls/text-editor-devel.h
${devel_api_src_dir}/controls/text-controls/text-field-devel.h
${devel_api_src_dir}/controls/text-controls/text-label-devel.h
+ ${devel_api_src_dir}/controls/text-controls/text-spannable.h
${devel_api_src_dir}/controls/text-controls/text-selection-popup.h
${devel_api_src_dir}/controls/text-controls/text-selection-toolbar.h
${devel_api_src_dir}/controls/text-controls/text-style-properties-devel.h
return mController->GetCharacterBoundingRectangle(charIndex);
}
+void TextEditor::SetSpannedText(const Text::Spanned& spannedText)
+{
+ mController->SetSpannedText(spannedText);
+}
+
string TextEditor::GetSelectedText() const
{
string selectedText = "";
mController->AnchorEvent(localPoint.x - padding.start, localPoint.y - padding.top);
Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get();
- if (keyboardFocusManager)
+ if(keyboardFocusManager)
{
keyboardFocusManager.SetCurrentFocusActor(Self());
}
if(event.GetState() == KeyEvent::UP)
{
Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get();
- if (keyboardFocusManager)
+ if(keyboardFocusManager)
{
keyboardFocusManager.ClearFocus();
}
#include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
#include <dali-toolkit/internal/controls/text-controls/common-text-utils.h>
+#include <dali-toolkit/internal/text/controller/text-controller.h>
#include <dali-toolkit/internal/text/decorator/text-decorator.h>
#include <dali-toolkit/internal/text/rendering/text-renderer.h>
#include <dali-toolkit/internal/text/text-anchor-control-interface.h>
#include <dali-toolkit/internal/text/text-control-interface.h>
-#include <dali-toolkit/internal/text/controller/text-controller.h>
#include <dali-toolkit/internal/text/text-editable-control-interface.h>
#include <dali-toolkit/internal/text/text-selectable-control-interface.h>
#include <dali-toolkit/internal/text/text-vertical-scroller.h>
Rect<float> GetCharacterBoundingRectangle(const uint32_t charIndex) const;
/**
+ * @brief Set the @p spannedText into current textEditor
+ * the spanned text contains content (text) and format (spans with ranges)
+ * the text is copied into text-controller and the spans are applied on ranges
+ *
+ * @param[in] spannedText the text with spans.
+ */
+ void SetSpannedText(const Text::Spanned& spannedText);
+
+ /**
* @copydoc Text::SelectableControlInterface::GetSelectedText()
*/
string GetSelectedText() const override;
mController->AnchorEvent(localPoint.x - padding.start, localPoint.y - padding.top);
Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get();
- if (keyboardFocusManager)
+ if(keyboardFocusManager)
{
keyboardFocusManager.SetCurrentFocusActor(Self());
}
if(event.GetState() == KeyEvent::UP)
{
Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get();
- if (keyboardFocusManager)
+ if(keyboardFocusManager)
{
keyboardFocusManager.ClearFocus();
}
return mController->GetCharacterBoundingRectangle(charIndex);
}
+void TextField::SetSpannedText(const Text::Spanned& spannedText)
+{
+ mController->SetSpannedText(spannedText);
+}
+
std::string TextField::TextFieldAccessible::GetName() const
{
if(IsHiddenInput())
#include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
#include <dali-toolkit/internal/controls/text-controls/common-text-utils.h>
+#include <dali-toolkit/internal/text/controller/text-controller.h>
#include <dali-toolkit/internal/text/decorator/text-decorator.h>
#include <dali-toolkit/internal/text/rendering/text-renderer.h>
#include <dali-toolkit/internal/text/text-anchor-control-interface.h>
#include <dali-toolkit/internal/text/text-control-interface.h>
-#include <dali-toolkit/internal/text/controller/text-controller.h>
#include <dali-toolkit/internal/text/text-editable-control-interface.h>
#include <dali-toolkit/internal/text/text-selectable-control-interface.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
// From SelectableControlInterface
public:
-
/**
* @copydoc Text::SelectableControlInterface::SetTextSelectionRange()
*/
*/
Rect<float> GetCharacterBoundingRectangle(const uint32_t charIndex) const;
+ /**
+ * @brief Set the @p spannedText into current textField
+ * the spanned text contains content (text) and format (spans with ranges)
+ * the text is copied into text-controller and the spans are applied on ranges
+ *
+ * @param[in] spannedText the text with spans.
+ */
+ void SetSpannedText(const Text::Spanned& spannedText);
+
private: // Implementation
/**
* @copydoc Dali::Toolkit::Text::Controller::(InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent)
return mController->GetCharacterBoundingRectangle(charIndex);
}
+void TextLabel::SetSpannedText(const Text::Spanned& spannedText)
+{
+ mController->SetSpannedText(spannedText);
+}
+
std::string TextLabel::TextLabelAccessible::GetNameRaw() const
{
return GetWholeText();
#include <dali/public-api/object/property-map.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/text/spanned.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
#include <dali-toolkit/internal/controls/text-controls/common-text-utils.h>
+#include <dali-toolkit/internal/text/controller/text-controller.h>
#include <dali-toolkit/internal/text/rendering/text-renderer.h>
#include <dali-toolkit/internal/text/text-anchor-control-interface.h>
#include <dali-toolkit/internal/text/text-control-interface.h>
-#include <dali-toolkit/internal/text/controller/text-controller.h>
#include <dali-toolkit/internal/text/text-scroller-interface.h>
#include <dali-toolkit/internal/text/text-scroller.h>
#include <dali-toolkit/internal/visuals/text/text-visual.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
-
namespace Dali
{
namespace Toolkit
*/
Rect<float> GetCharacterBoundingRectangle(const uint32_t charIndex) const;
+ /**
+ * @brief Set the @p spannedText into current textLabel
+ * the spanned text contains content (text) and format (spans with ranges)
+ * the text is copied into text-controller and the spans are applied on ranges
+ *
+ * @param[in] spannedText the text with spans.
+ */
+ void SetSpannedText(const Text::Spanned& spannedText);
+
private: // From Control
/**
* @copydoc Control::OnInitialize()
${toolkit_src_dir}/text/controller/text-controller-placeholder-handler.cpp
${toolkit_src_dir}/text/controller/text-controller-relayouter.cpp
${toolkit_src_dir}/text/controller/text-controller-text-updater.cpp
+ ${toolkit_src_dir}/text/controller/text-controller-spannable-handler.cpp
${toolkit_src_dir}/text/layouts/layout-engine-helper-functions.cpp
${toolkit_src_dir}/text/layouts/layout-engine.cpp
${toolkit_src_dir}/text/markup-processor/markup-processor.cpp
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/text/controller/text-controller-spannable-handler.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <memory.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/controller/text-controller-impl.h>
+#include <dali-toolkit/internal/text/controller/text-controller-text-updater.h>
+#include <dali-toolkit/internal/text/logical-model-impl.h>
+#include <dali-toolkit/internal/text/spannable/spans/base-span-impl.h>
+
+namespace
+{
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS");
+#endif
+
+} // namespace
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+void Controller::SpannableHandler::SetSpannedText(Controller& controller, const Text::Spanned& spannedText)
+{
+ // Copy content(text)
+ const std::string& text = spannedText.ToString();
+ Controller::TextUpdater::SetText(controller, text);
+
+ Controller::Impl& impl = *controller.mImpl;
+ LogicalModelPtr& logicalModel = impl.mModel->mLogicalModel;
+
+ // Set spanned-text
+ logicalModel->mSpannedTextPlaced = true;
+
+ std::vector<Dali::Toolkit::Text::BaseSpan> spans;
+ std::vector<Dali::Toolkit::Text::Range> ranges;
+ spannedText.RetrieveAllSpansAndRanges(spans, ranges);
+
+ for(std::vector<Dali::Toolkit::Text::BaseSpan>::size_type i = 0; i < spans.size(); i++)
+ {
+ GetImplementation(spans[i]).CreateStyleCharacterRun(logicalModel, ranges[i]);
+ }
+}
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_SPANNABLE_HANDLER_H
+#define DALI_TOOLKIT_TEXT_SPANNABLE_HANDLER_H
+
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/controller/text-controller.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+/**
+ * @brief Methods that update the text
+ */
+struct Controller::SpannableHandler
+{
+ /// @copydoc Text::Contoller::SetSpannedText
+ /// @param[in] controller The controller
+ static void SetSpannedText(Controller& controller, const Text::Spanned& spannedText);
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_SPANNABLE_HANDLER_H
Controller::Impl& impl = *controller.mImpl;
LogicalModelPtr& logicalModel = impl.mModel->mLogicalModel;
+ // Reset spanned-text
+ logicalModel->mSpannedTextPlaced = false;
+
// Reset buffers.
logicalModel->mText.Clear();
#include <dali-toolkit/internal/text/controller/text-controller-input-properties.h>
#include <dali-toolkit/internal/text/controller/text-controller-placeholder-handler.h>
#include <dali-toolkit/internal/text/controller/text-controller-relayouter.h>
+#include <dali-toolkit/internal/text/controller/text-controller-spannable-handler.h>
#include <dali-toolkit/internal/text/controller/text-controller-text-updater.h>
#include <dali-toolkit/internal/text/text-editable-control-interface.h>
#include <dali-toolkit/internal/text/text-geometry.h>
mImpl->GetText(text);
}
+void Controller::SetSpannedText(const Text::Spanned& spannedText)
+{
+ SpannableHandler::SetSpannedText(*this, spannedText);
+}
+
void Controller::SetPlaceholderText(PlaceholderType type, const std::string& text)
{
PlaceholderHandler::SetPlaceholderText(*this, type, text);
*/
// EXTERNAL INCLUDES
+#include <dali-toolkit/devel-api/text/spanned.h>
#include <dali/devel-api/adaptor-framework/input-method-context.h>
#include <dali/public-api/events/gesture.h>
void GetText(std::string& text) const;
/**
+ * @brief Set the @p spannedText
+ * the spanned text contains content (text) and format (spans with ranges)
+ * the text is copied into text-controller and the spans are applied on ranges
+ *
+ * @param[in] spannedText the text with spans.
+ */
+ void SetSpannedText(const Text::Spanned& spannedText);
+
+ /**
* @brief Replaces any placeholder text previously set.
*
* @param[in] type Different placeholder-text can be shown when the control is active/inactive.
struct PlaceholderHandler;
struct Relayouter;
struct TextUpdater;
+ struct SpannableHandler;
Impl* mImpl;
};
}
LogicalModel::LogicalModel()
-: mBidirectionalLineIndex(0u)
+: mBidirectionalLineIndex(0u),
+ mSpannedTextPlaced(false)
{
}
Vector<CharacterSpacingCharacterRun> mCharacterSpacingCharacterRuns; ///< The character-spacing character run from markup-processor.
BidirectionalLineRunIndex mBidirectionalLineIndex; ///< The last fetched bidirectional line info.
+ bool mSpannedTextPlaced : 1; ///< Whether the spanned-text is placed.
};
} // namespace Text
#include <memory>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/text/range.h>
#include <dali-toolkit/devel-api/text/spans/base-span.h>
#include <dali-toolkit/internal/text/text-definitions.h>
#include <dali/public-api/object/base-object.h>
*/
virtual ~BaseSpan();
+public: //Methods for internal only
+ /**
+ * @brief Create an instance for specific style character run and add it to its logicalModel run.
+ *
+ * @param[in] logicalModel The logical model.
+ * @param[in] range The range.
+ */
+ virtual void CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const = 0;
+
}; // class BaseSpan
} // namespace Internal
mImpl->mForegroundColorDefined = true;
}
+void ForegroundColorSpan::CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const
+{
+ ColorRun colorRun;
+ colorRun.characterRun.characterIndex = range.GetStartIndex();
+ colorRun.characterRun.numberOfCharacters = range.GetNumberOfIndices();
+
+ colorRun.color = mImpl->mForegroundColor;
+ logicalModel->mColorRuns.PushBack(colorRun);
+}
+
} // namespace Internal
} // namespace Text
#include <memory>
// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/logical-model-impl.h>
#include <dali-toolkit/internal/text/spannable/spans/base-span-impl.h>
#include <dali/public-api/math/vector4.h>
*/
void SetForegroundColor(Vector4 color);
+public: //Methods for internal only
+ /**
+ * @copydoc Dali::Toolkit::Text::BaseSpan::CreateStyleCharacterRun
+ */
+ void CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const override;
+
private:
struct Impl;
std::unique_ptr<Impl> mImpl{nullptr};