From e6c0595b2138929f5cb6199cde9c3d79d549e0ae Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 2 Jan 2017 12:35:35 +0100 Subject: Add advance property to QQuickText This is a step on the way to certain optimization possibilities for text in Qt Quick. Basically, to allow users the ability to split text into separate items (so that you can distinguish dynamic from static, and unshaped from shaped text), we also need a way to string those items together visually later. The advance property is required for this. [ChangeLog][QtQuick][Text] Added "advance" property to Text element. Task-number: QTBUG-56728 Change-Id: I8e7bf9bac410fa9c5553b48db90956431a2873f6 Reviewed-by: Simon Hausmann --- .../data/text/text_advance_bidi_ltr.qml | 56 ++++++++++++++++++++++ .../data/text/text_advance_hebrew.qml | 54 +++++++++++++++++++++ .../data/text/text_advance_latin.qml | 55 +++++++++++++++++++++ .../data/text/text_advance_multiline.qml | 55 +++++++++++++++++++++ .../data/text/text_advance_multiparagraph.qml | 39 +++++++++++++++ .../text_advance_multiparagraph_multifontsizes.qml | 39 +++++++++++++++ 6 files changed, 298 insertions(+) create mode 100644 tests/manual/scenegraph_lancelot/data/text/text_advance_bidi_ltr.qml create mode 100644 tests/manual/scenegraph_lancelot/data/text/text_advance_hebrew.qml create mode 100644 tests/manual/scenegraph_lancelot/data/text/text_advance_latin.qml create mode 100644 tests/manual/scenegraph_lancelot/data/text/text_advance_multiline.qml create mode 100644 tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph.qml create mode 100644 tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph_multifontsizes.qml (limited to 'tests/manual') diff --git a/tests/manual/scenegraph_lancelot/data/text/text_advance_bidi_ltr.qml b/tests/manual/scenegraph_lancelot/data/text/text_advance_bidi_ltr.qml new file mode 100644 index 0000000000..2f40aece89 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_advance_bidi_ltr.qml @@ -0,0 +1,56 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + property string firstWord: "One, שתיים, " + property string secondWord: "Three" + + Text { + id: referenceText + text: firstWord + secondWord + anchors.centerIn: parent + font.italic: true + font.pixelSize: 30 + } + + Text { + id: firstWordItem + anchors.left: referenceText.left + anchors.top: referenceText.bottom + text: firstWord + font: referenceText.font + } + + Text { + id: secondWordItem + anchors.left: firstWordItem.left + anchors.leftMargin: firstWordItem.advance.width + anchors.baseline: firstWordItem.baseline + anchors.baselineOffset: firstWordItem.advance.height + text: secondWord + font: referenceText.font + } + + Text { + id: firstWordItemRichText + anchors.left: referenceText.left + anchors.top: secondWordItem.bottom + text: firstWord + font: referenceText.font + textFormat: Text.RichText + } + + Text { + id: secondWordItemRichText + anchors.left: firstWordItemRichText.left + anchors.leftMargin: firstWordItemRichText.advance.width + anchors.baseline: firstWordItemRichText.baseline + anchors.baselineOffset: firstWordItemRichText.advance.height + text: secondWord + font: referenceText.font + textFormat: Text.RichText + } + +} diff --git a/tests/manual/scenegraph_lancelot/data/text/text_advance_hebrew.qml b/tests/manual/scenegraph_lancelot/data/text/text_advance_hebrew.qml new file mode 100644 index 0000000000..0a9dce4d82 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_advance_hebrew.qml @@ -0,0 +1,54 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + property string firstWord: "תורת רב־לשוני אנא " + property string secondWord: "של" + + Text { + id: referenceText + text: firstWord + secondWord + anchors.centerIn: parent + font.italic: true + font.pixelSize: 30 + } + + Text { + id: firstWordItem + anchors.right: referenceText.right + anchors.top: referenceText.bottom + text: firstWord + font: referenceText.font + } + + Text { + id: secondWordItem + anchors.right: firstWordItem.left + anchors.baseline: firstWordItem.baseline + anchors.baselineOffset: firstWordItem.advance.height + text: secondWord + font: referenceText.font + } + + Text { + id: firstWordItemRichText + anchors.right: referenceText.right + anchors.top: secondWordItem.bottom + text: firstWord + font: referenceText.font + textFormat: Text.RichText + } + + Text { + id: secondWordItemRichText + anchors.right: firstWordItemRichText.left + anchors.baseline: firstWordItemRichText.baseline + anchors.baselineOffset: firstWordItemRichText.advance.height + text: secondWord + font: referenceText.font + textFormat: Text.RichText + } + +} diff --git a/tests/manual/scenegraph_lancelot/data/text/text_advance_latin.qml b/tests/manual/scenegraph_lancelot/data/text/text_advance_latin.qml new file mode 100644 index 0000000000..ccab5d8c64 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_advance_latin.qml @@ -0,0 +1,55 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + property string firstWord: "Hello " + property string secondWord: "World" + + Text { + id: referenceText + text: firstWord + secondWord + anchors.centerIn: parent + font.italic: true + font.pixelSize: 30 + } + + Text { + id: firstWordItem + anchors.left: referenceText.left + anchors.top: referenceText.bottom + text: firstWord + font: referenceText.font + } + + Text { + id: secondWordItem + anchors.left: firstWordItem.left + anchors.leftMargin: firstWordItem.advance.width + anchors.baseline: firstWordItem.baseline + anchors.baselineOffset: firstWordItem.advance.height + text: secondWord + font: referenceText.font + } + + Text { + id: firstWordItemRichText + anchors.left: referenceText.left + anchors.top: secondWordItem.bottom + text: firstWord + font: referenceText.font + textFormat: Text.RichText + } + + Text { + id: secondWordItemRichText + anchors.left: firstWordItemRichText.left + anchors.leftMargin: firstWordItemRichText.advance.width + anchors.baseline: firstWordItemRichText.baseline + anchors.baselineOffset: firstWordItemRichText.advance.height + text: secondWord + font: referenceText.font + textFormat: Text.RichText + } +} diff --git a/tests/manual/scenegraph_lancelot/data/text/text_advance_multiline.qml b/tests/manual/scenegraph_lancelot/data/text/text_advance_multiline.qml new file mode 100644 index 0000000000..ae0f10718c --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_advance_multiline.qml @@ -0,0 +1,55 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + property string firstWord: "One,\nTwo, " + property string secondWord: "Three" + + Text { + id: referenceText + text: firstWord + secondWord + anchors.centerIn: parent + font.italic: true + font.pixelSize: 30 + } + + Text { + id: firstWordItem + anchors.left: referenceText.left + anchors.top: referenceText.bottom + text: firstWord + font: referenceText.font + } + + Text { + id: secondWordItem + anchors.left: firstWordItem.left + anchors.leftMargin: firstWordItem.advance.width + anchors.baseline: firstWordItem.baseline + anchors.baselineOffset: firstWordItem.advance.height + text: secondWord + font: referenceText.font + } + + Text { + id: firstWordItemRichText + anchors.left: referenceText.left + anchors.top: secondWordItem.bottom + text: firstWord + font: referenceText.font + textFormat: Text.RichText + } + + Text { + id: secondWordItemRichText + anchors.left: firstWordItemRichText.left + anchors.leftMargin: firstWordItemRichText.advance.width + anchors.baseline: firstWordItemRichText.baseline + anchors.baselineOffset: firstWordItemRichText.advance.height + text: secondWord + font: referenceText.font + textFormat: Text.RichText + } +} diff --git a/tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph.qml b/tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph.qml new file mode 100644 index 0000000000..76f0910680 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph.qml @@ -0,0 +1,39 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + property string firstWord: "

One,

Two, " + property string secondWord: "Three

" + + Text { + id: referenceText + text: firstWord + secondWord + anchors.centerIn: parent + font.italic: true + font.pixelSize: 30 + textFormat: Text.RichText + } + + + Text { + id: firstWordItemRichText + anchors.left: referenceText.left + anchors.top: referenceText.bottom + text: firstWord + font: referenceText.font + textFormat: Text.RichText + } + + Text { + id: secondWordItemRichText + anchors.left: firstWordItemRichText.left + anchors.leftMargin: firstWordItemRichText.advance.width + anchors.baseline: firstWordItemRichText.baseline + anchors.baselineOffset: firstWordItemRichText.advance.height + text: secondWord + font: referenceText.font + textFormat: Text.RichText + } +} diff --git a/tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph_multifontsizes.qml b/tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph_multifontsizes.qml new file mode 100644 index 0000000000..de33d65cdc --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph_multifontsizes.qml @@ -0,0 +1,39 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + property string firstWord: "

One,

Two, " + property string secondWord: "Three

" + + Text { + id: referenceText + text: firstWord + secondWord + anchors.centerIn: parent + font.italic: true + font.pixelSize: 30 + textFormat: Text.RichText + } + + + Text { + id: firstWordItemRichText + anchors.left: referenceText.left + anchors.top: referenceText.bottom + text: firstWord + font: referenceText.font + textFormat: Text.RichText + } + + Text { + id: secondWordItemRichText + anchors.left: firstWordItemRichText.left + anchors.leftMargin: firstWordItemRichText.advance.width + anchors.baseline: firstWordItemRichText.baseline + anchors.baselineOffset: firstWordItemRichText.advance.height + text: secondWord + font: referenceText.font + textFormat: Text.RichText + } +} -- cgit v1.2.3