handle line space for text node

This commit is contained in:
王劲鹏 2021-05-27 16:07:09 +08:00 committed by osborn
parent 6f5174df60
commit 861082dbac
2 changed files with 17 additions and 17 deletions

View File

@ -5,7 +5,13 @@ import QtGraphicalEffects 1.12
import "util.mjs" as Util
import "gravity.mjs" as Gravity
TextArea {
Text {
Rectangle {
id: bg
color: 'transparent'
z: -1
}
FontLoader { id: webFont }
property var wrapper
@ -14,8 +20,6 @@ TextArea {
property var tag: "Text"
readOnly: true
leftPadding: 0
topPadding: 0
rightPadding: 0
@ -43,11 +47,6 @@ TextArea {
}
}
background: Rectangle {
id: bg
color: 'transparent'
}
property var backgroundColor
onBackgroundColorChanged: {
@ -72,19 +71,11 @@ TextArea {
onWidthChanged: {
bg.implicitWidth = width
console.log(tag, uuid + " onWidthChanged: " + this.width)
let tempText = this.text
this.text = ""
this.text = tempText
}
onHeightChanged: {
bg.implicitHeight = height
console.log(tag, uuid + " onHeightChanged: " + this.height)
let tempText = this.text
this.text = ""
this.text = tempText
}
onTextChanged: {
@ -146,4 +137,13 @@ TextArea {
onUnderlineChanged: {
font.underline = underline
}
property var lineSpacing: -1
onLineSpacingChanged: {
if (lineSpacing > 0) {
lineHeightMode = Text.FixedHeight
lineHeight = lineSpacing
}
}
}

View File

@ -92,7 +92,7 @@ void DoricTextNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
} else if (name == "underline") {
view->setProperty("underline", prop.toBool());
} else if (name == "lineSpacing") {
view->setProperty("lineSpacing", prop.toDouble());
} else {
DoricViewNode::blend(view, name, prop);
}