Details
-
Suggestion
-
Resolution: Done
-
P2: Important
-
None
-
None
Description
Overview
We want to improve text handling in general and allow more advanced visual effects.
The goal is to be able to do the effects common in presentation programs and a simple ebook reader entirely in QML.
Current thoughts
We want to separate the layout process from the visual Text element.
- a TextLayout QML or JS object would do the layout (possibly in a separate thread) and provide an imperative JS API to manipulate the different elements of the text (paragraphs, lines, words, characters).
- the Text element would become a simple view of a TextLayout.
Status
A TextLayout takes some text and a width and layouts the text accordingly.
TextLayout {
id: textLayout
text: "..."
width: 450
}
A Text element can refer to the layout and display the text.
Text {
layout: textLayout
color: "white"
}
It is possible to get a list of line elements (currently QObjects) through JS and set properties on them (currently x, y, color).
for (var i = 0; i < textLayout.lineCount; ++i) { var line = textLayout.lineAt(i); line.x = i * 10 line.y = 25 line.color = "red" }