From c813c4ae683991df95c5c2218811830c88292d30 Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Mon, 2 Feb 2015 12:10:34 +0000 Subject: [PATCH] Text segmentation interface added. Change-Id: I4053be3ea15a685278f28929d273ccc6a45e54ee Signed-off-by: Victor Cebollada --- base/dali-toolkit/public-api/file.list | 5 ++ .../dali-toolkit/public-api/text/logical-model.cpp | 32 ++++++++ base/dali-toolkit/public-api/text/logical-model.h | 92 ++++++++++++++++++++++ base/dali-toolkit/public-api/text/segmentation.cpp | 42 ++++++++++ base/dali-toolkit/public-api/text/segmentation.h | 63 +++++++++++++++ .../public-api/text/text-definitions.h | 2 + optional/dali-toolkit/dali-toolkit.h | 5 ++ 7 files changed, 241 insertions(+) create mode 100644 base/dali-toolkit/public-api/text/segmentation.cpp create mode 100644 base/dali-toolkit/public-api/text/segmentation.h diff --git a/base/dali-toolkit/public-api/file.list b/base/dali-toolkit/public-api/file.list index b2c438d..0c43428 100755 --- a/base/dali-toolkit/public-api/file.list +++ b/base/dali-toolkit/public-api/file.list @@ -41,6 +41,7 @@ public_api_base_src_files = \ $(public_api_base_src_dir)/text/character-set-conversion.cpp \ $(public_api_base_src_dir)/text/logical-model.cpp \ $(public_api_base_src_dir)/text/multi-language-support.cpp \ + $(public_api_base_src_dir)/text/segmentation.cpp \ $(public_api_base_src_dir)/text/text-controller.cpp \ $(public_api_base_src_dir)/text/text-view.cpp \ $(public_api_base_src_dir)/text/text-view-interface.cpp \ @@ -123,9 +124,13 @@ public_api_base_text_controls_header_files = \ $(public_api_base_src_dir)/controls/text-controls/text-label.h public_api_base_text_header_files = \ + $(public_api_base_src_dir)/text/character-run.h \ $(public_api_base_src_dir)/text/character-set-conversion.h \ + $(public_api_base_src_dir)/text/font-run.h \ $(public_api_base_src_dir)/text/logical-model.h \ $(public_api_base_src_dir)/text/multi-language-support.h \ + $(public_api_base_src_dir)/text/script.h \ + $(public_api_base_src_dir)/text/segmentation.h \ $(public_api_base_src_dir)/text/text-controller.h \ $(public_api_base_src_dir)/text/text-definitions.h \ $(public_api_base_src_dir)/text/text-view.h \ diff --git a/base/dali-toolkit/public-api/text/logical-model.cpp b/base/dali-toolkit/public-api/text/logical-model.cpp index 4547f99..6d7694a 100644 --- a/base/dali-toolkit/public-api/text/logical-model.cpp +++ b/base/dali-toolkit/public-api/text/logical-model.cpp @@ -233,6 +233,38 @@ FontId LogicalModel::GetFont( CharacterIndex characterIndex ) const return 0u; } +void LogicalModel::SetLineBreakInfo( const LineBreakInfo* const lineBreakInfo, + Length length ) +{ +} + +void LogicalModel::GetLineBreakInfo( LineBreakInfo* lineBreakInfo, + CharacterIndex characterIndex, + Length numberOfItems ) const +{ +} + +LineBreakInfo LogicalModel::GetLineBreakInfo( CharacterIndex characterIndex ) const +{ + return 0; +} + +void LogicalModel::SetWordBreakInfo( const WordBreakInfo* const wordBreakInfo, + Length length ) +{ +} + +void LogicalModel::GetWordBreakInfo( WordBreakInfo* wordBreakInfo, + CharacterIndex characterIndex, + Length numberOfItems ) const +{ +} + +WordBreakInfo LogicalModel::GetWordBreakInfo( CharacterIndex characterIndex ) const +{ + return 0; +} + LogicalModel::~LogicalModel() { delete mImpl; diff --git a/base/dali-toolkit/public-api/text/logical-model.h b/base/dali-toolkit/public-api/text/logical-model.h index d8f6617..2d8a66a 100644 --- a/base/dali-toolkit/public-api/text/logical-model.h +++ b/base/dali-toolkit/public-api/text/logical-model.h @@ -185,6 +185,98 @@ public: */ FontId GetFont( CharacterIndex characterIndex ) const; + // Break info interface. + + /** + * Sets the line break info. + * + * See GetLineBreakInfo() to get how the line break info is encoded. + * + * Replaces any line break info previously set. + * + * @param[in] lineBreakInfo Pointer to a buffer with the line break info. + * @param[in] length The size of the buffer. + */ + void SetLineBreakInfo( const LineBreakInfo* const lineBreakInfo, + Length length ); + + /** + * Retrieves the line break info in the given buffer. + * + * The size of the @p lineBreakInfo buffer needs to be big enough to copy the @p numberOfItems. + * + * Possible values for LineBreakInfo are: + * + * - 0 is a LINE_MUST_BREAK. Text must be broken into a new line. + * - 1 is a LINE_ALLOW_BREAK. Is possible to break the text into a new line. + * - 2 is a LINE_NO_BREAK. Text can't be broken into a new line. + * + @verbatim + i.e. Hello big\nworld produces: + 2222212220 22220 + @endverbatim + * + * @param[out] lineBreakInfo Pointer to a buffer where the line break info is copied. + * @param[in] characterIndex Index to the first line break info item. + * @param[in] numberOfItems The number of items to be copied. + */ + void GetLineBreakInfo( LineBreakInfo* lineBreakInfo, + CharacterIndex characterIndex, + Length numberOfItems ) const; + + /** + * Retrieves the line break info for the given item index. + * + * @param[in] characterIndex Index to the line break info item. + */ + LineBreakInfo GetLineBreakInfo( CharacterIndex characterIndex ) const; + + /** + * Sets the word break info. + * + * See GetWordBreakInfo() to get how the word break info is encoded. + * + * Replaces any word break info previously set. + * + * @param[in] wordBreakInfo Pointer to a buffer with the word break info. + * @param[in] length The size of the buffer. + */ + void SetWordBreakInfo( const WordBreakInfo* const wordBreakInfo, + Length length ); + + /** + * Retrieves the word break info in the given buffer. + * + * The size of the @p wordBreakInfo buffer needs to be big enough to copy the @p numberOfItems. + * + * The size of the buffer has to be big enough to store the whole word break info per character. + * Call GetNumberOfCharacters() to get the number of characters. + * + * Possible values for WordBreakInfo are: + * + * - 0 is a WORD_BREAK. Text can be broken into a new word. + * - 1 is a WORD_NO_BREAK. Text can't be broken into a new word. + * + @verbatim + i.e. Hello big\nworld produces: + 1111001100 11110 + @endverbatim + * + * @param[out] wordBreakInfo Pointer to a buffer where the word break info is copied. + * @param[in] characterIndex Index to the first word break info item. + * @param[in] numberOfItems The number of items to be copied. + */ + void GetWordBreakInfo( WordBreakInfo* wordBreakInfo, + CharacterIndex characterIndex, + Length numberOfItems ) const; + + /** + * Retrieves the word break info for the given item index. + * + * @param[in] characterIndex Index to the word break info item. + */ + WordBreakInfo GetWordBreakInfo( CharacterIndex characterIndex ) const; + protected: /** diff --git a/base/dali-toolkit/public-api/text/segmentation.cpp b/base/dali-toolkit/public-api/text/segmentation.cpp new file mode 100644 index 0000000..88455d2 --- /dev/null +++ b/base/dali-toolkit/public-api/text/segmentation.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015 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 + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +void SetLineBreakInfo( LogicalModel& model ) +{ +} + +void SetWordBreakInfo( LogicalModel& model ) +{ +} + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali diff --git a/base/dali-toolkit/public-api/text/segmentation.h b/base/dali-toolkit/public-api/text/segmentation.h new file mode 100644 index 0000000..85198c5 --- /dev/null +++ b/base/dali-toolkit/public-api/text/segmentation.h @@ -0,0 +1,63 @@ +#ifndef __DALI_TOOLKIT_TEXT_SEGMENTATION_H__ +#define __DALI_TOOLKIT_TEXT_SEGMENTATION_H__ + +/* + * Copyright (c) 2015 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 + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +class LogicalModel; + +/** + * Sets line break info. + * + * Any line break info previously set is removed. + * + * @pre The @p model needs to have a text set. + * + * @param[in,out] model The text's logical model. + */ +void SetLineBreakInfo( LogicalModel& model ); + +/** + * Sets word break info. + * + * Any word break info previously set is removed. + * + * @pre The @p model needs to have a text set. + * + * @param[in,out] model The text's logical model. + */ +void SetWordBreakInfo( LogicalModel& model ); + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali + +#endif // __DALI_TOOLKIT_TEXT_SEGMENTATION_H__ diff --git a/base/dali-toolkit/public-api/text/text-definitions.h b/base/dali-toolkit/public-api/text/text-definitions.h index 47bfd9c..0ec2554 100644 --- a/base/dali-toolkit/public-api/text/text-definitions.h +++ b/base/dali-toolkit/public-api/text/text-definitions.h @@ -41,6 +41,8 @@ typedef TextAbstraction::CharacterIndex CharacterIndex; ///< An index into an typedef TextAbstraction::Length Length; ///< The length of an array typedef TextAbstraction::BidiInfoIndex BidiInfoIndex; ///< Index to the bidirectional info for a paragraph. typedef TextAbstraction::Script Script; ///< The character's script. +typedef TextAbstraction::LineBreakInfo LineBreakInfo; ///< Line break info (must break, allow break, no break). Possible values are: LINE_MUST_BREAK, LINE_ALLOW_BREAK and LINE_NO_BREAK (in the TextAbstraction namespace). +typedef TextAbstraction::WordBreakInfo WordBreakInfo; ///< Word break info (break, no break). Possible values are: WORD_BREAK and WORD_NO_BREAK (in the TextAbstraction namespace). typedef uint32_t GlyphIndex; ///< An index into an array of glyphs diff --git a/optional/dali-toolkit/dali-toolkit.h b/optional/dali-toolkit/dali-toolkit.h index fa4837a..09a9421 100644 --- a/optional/dali-toolkit/dali-toolkit.h +++ b/optional/dali-toolkit/dali-toolkit.h @@ -58,8 +58,13 @@ #include #include #include +#include #include +#include #include +#include +#include +#include #include #include #include -- 2.7.4