Added "text-wrap" property

This commit is contained in:
anoshenko 2024-06-06 17:33:55 +03:00
parent d0d81907eb
commit 658142d3f1
7 changed files with 76 additions and 0 deletions

View File

@ -2,6 +2,7 @@
* Can use ListAdapter as "content" property value of ListLayout
* The IsListItemEnabled method of the ListAdapter interface has been made optional
* Can use GridAdapter as "content" property value of GridLayout
* Added "text-wrap" property and GetGetTextWrap function
* Bug fixing
# v0.15.0

View File

@ -1572,6 +1572,24 @@ radius необходимо передать nil
Свойство "tab-size" (константа TabSize) типа int задает размер символа табуляции (U+0009) в пробелах.
Значение свойства "tab-size" должно быть больше 0.
#### Свойство "text-wrap"
Свойство "text-wrap" (константа TextWrap) типа int управляет переносом текста внутри View. Допустимые значения:
0 (константа TextWrapOn, имя "wrap") — текст переносится по строкам через соответствующие символы (например, пробелы в таких языках, как английский, в которых используются разделители пробелов), чтобы минимизировать переполнение. Это значение по умолчанию.
1 (константа TextWrapOff, имя "nowrap") — текст не переносится по строкам. Он переполнит содержащий его элемент, а не перейдет на новую строку.
2 (константа TextWrapBalance, имя "balance") — текст переносится таким образом,
чтобы наилучшим образом сбалансировать количество символов в каждой строке, улучшая качество и разборчивость макета.
Поскольку подсчет символов и их балансировка по нескольким строкам требует больших вычислительных затрат,
это значение поддерживается только для блоков текста, охватывающих ограниченное количество строк
(шесть или меньше для Chromium и десять или меньше для Firefox).
Получить значение этого свойства можно с помощью функции
func GetTextWrap(view View, subviewID ...string) int
#### Свойство "word-break"
Свойство "word-break" (константа WordBreak) типа int определяет, где будет установлен перевод

View File

@ -1551,6 +1551,25 @@ The table below shows the behavior of various values of the "white-space" proper
The "tab-size" int property (TabSize constant) specifies the size of the tab character (U+0009) in spaces.
The value of the "tab-size" property must be greater than 0. The default value is 8
#### "text-wrap" property
The "text-wrap" int property (TextWrap constant) controls how text inside a View is wrapped. Valid values are:
0 (TextWrapOn constant, "wrap" name) - text is wrapped across lines at appropriate characters
(for example spaces, in languages like English that use space separators) to minimize overflow. This is the default value.
1 (TextWrapOff constant, "nowrap" name) - text does not wrap across lines.
It will overflow its containing element rather than breaking onto a new line.
2 (TextWrapBalance constant, "balance" name) - text is wrapped in a way that best balances the number of characters on each line,
enhancing layout quality and legibility.
Because counting characters and balancing them across multiple lines is computationally expensive,
this value is only supported for blocks of text spanning a limited number of lines (six or less for Chromium and ten or less for Firefox).
You can get the value of this property using the function
func GetTextWrap(view View, subviewID ...string) int
#### "word-break" property
The "word-break" int property (WordBreak constant) determines where the newline will be set if the text exceeds the block boundaries.

View File

@ -363,6 +363,14 @@ const (
// This is an inherited property, i.e. if it is not defined, then the value of the parent view is used.
TextShadow = "text-shadow"
// TextWrap is the constant for the "text-wrap" property tag.
// The "text-wrap" int property controls how text inside a View is wrapped.
// Valid values are:
// * TextWrapOn / 0 / "wrap" - text is wrapped across lines at appropriate characters (for example spaces, in languages like English that use space separators) to minimize overflow. This is the default value.
// * TextWrapOff / 1 / "nowrap" - text does not wrap across lines. It will overflow its containing element rather than breaking onto a new line.
// * TextWrapBalance / 2 / "balance" - text is wrapped in a way that best balances the number of characters on each line, enhancing layout quality and legibility. Because counting characters and balancing them across multiple lines is computationally expensive, this value is only supported for blocks of text spanning a limited number of lines (six or less for Chromium and ten or less for Firefox).
TextWrap = "text-wrap"
// TabSize is the constant for the "tab-size" property tag.
// The "tab-size" int property sets the width of tab characters (U+0009) in spaces.
// This is an inherited property, i.e. if it is not defined, then the value of the parent view is used.

View File

@ -221,6 +221,11 @@ var enumProperties = map[string]struct {
TextOverflow,
[]string{"clip", "ellipsis"},
},
TextWrap: {
[]string{"wrap", "nowrap", "balance"},
TextWrap,
[]string{"wrap", "nowrap", "balance"},
},
WritingMode: {
[]string{"horizontal-top-to-bottom", "horizontal-bottom-to-top", "vertical-right-to-left", "vertical-left-to-right"},
WritingMode,

View File

@ -395,4 +395,20 @@ const (
// ColumnFillAuto - value of the "column-fill" property:
// Columns are filled sequentially. Content takes up only the room it needs, possibly resulting in some columns remaining empty.
ColumnFillAuto = 1
// TextWrapOn - value of the "text-wrap" property:
// text is wrapped across lines at appropriate characters (for example spaces,
// in languages like English that use space separators) to minimize overflow.
TextWrapOn = 0
// TextWrapOff - value of the "text-wrap" property: text does not wrap across lines.
// It will overflow its containing element rather than breaking onto a new line.
TextWrapOff = 1
// TextWrapBalance - value of the "text-wrap" property: text is wrapped in a way
// that best balances the number of characters on each line, enhancing layout quality
// and legibility. Because counting characters and balancing them across multiple lines
// is computationally expensive, this value is only supported for blocks of text
// spanning a limited number of lines (six or less for Chromium and ten or less for Firefox).
TextWrapBalance = 2
)

View File

@ -419,6 +419,15 @@ func GetTextAlign(view View, subviewID ...string) int {
return enumStyledProperty(view, subviewID, TextAlign, LeftAlign, true)
}
// GetTextAlign returns how text inside of the subview is wrapped. Returns one of next values:
//
// TextWrapOn = 0, TextWrapOff = 1, TextWrapBalance = 3
//
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTextWrap(view View, subviewID ...string) int {
return enumStyledProperty(view, subviewID, TextWrap, TextWrapOn, true)
}
// GetTextIndent returns a text indent of the subview.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetTextIndent(view View, subviewID ...string) SizeUnit {