handle line space for text node
This commit is contained in:
parent
6f5174df60
commit
861082dbac
@ -5,7 +5,13 @@ import QtGraphicalEffects 1.12
|
|||||||
import "util.mjs" as Util
|
import "util.mjs" as Util
|
||||||
import "gravity.mjs" as Gravity
|
import "gravity.mjs" as Gravity
|
||||||
|
|
||||||
TextArea {
|
Text {
|
||||||
|
Rectangle {
|
||||||
|
id: bg
|
||||||
|
color: 'transparent'
|
||||||
|
z: -1
|
||||||
|
}
|
||||||
|
|
||||||
FontLoader { id: webFont }
|
FontLoader { id: webFont }
|
||||||
|
|
||||||
property var wrapper
|
property var wrapper
|
||||||
@ -14,8 +20,6 @@ TextArea {
|
|||||||
|
|
||||||
property var tag: "Text"
|
property var tag: "Text"
|
||||||
|
|
||||||
readOnly: true
|
|
||||||
|
|
||||||
leftPadding: 0
|
leftPadding: 0
|
||||||
topPadding: 0
|
topPadding: 0
|
||||||
rightPadding: 0
|
rightPadding: 0
|
||||||
@ -43,11 +47,6 @@ TextArea {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
background: Rectangle {
|
|
||||||
id: bg
|
|
||||||
color: 'transparent'
|
|
||||||
}
|
|
||||||
|
|
||||||
property var backgroundColor
|
property var backgroundColor
|
||||||
|
|
||||||
onBackgroundColorChanged: {
|
onBackgroundColorChanged: {
|
||||||
@ -72,19 +71,11 @@ TextArea {
|
|||||||
onWidthChanged: {
|
onWidthChanged: {
|
||||||
bg.implicitWidth = width
|
bg.implicitWidth = width
|
||||||
console.log(tag, uuid + " onWidthChanged: " + this.width)
|
console.log(tag, uuid + " onWidthChanged: " + this.width)
|
||||||
|
|
||||||
let tempText = this.text
|
|
||||||
this.text = ""
|
|
||||||
this.text = tempText
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onHeightChanged: {
|
onHeightChanged: {
|
||||||
bg.implicitHeight = height
|
bg.implicitHeight = height
|
||||||
console.log(tag, uuid + " onHeightChanged: " + this.height)
|
console.log(tag, uuid + " onHeightChanged: " + this.height)
|
||||||
|
|
||||||
let tempText = this.text
|
|
||||||
this.text = ""
|
|
||||||
this.text = tempText
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
@ -146,4 +137,13 @@ TextArea {
|
|||||||
onUnderlineChanged: {
|
onUnderlineChanged: {
|
||||||
font.underline = underline
|
font.underline = underline
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property var lineSpacing: -1
|
||||||
|
|
||||||
|
onLineSpacingChanged: {
|
||||||
|
if (lineSpacing > 0) {
|
||||||
|
lineHeightMode = Text.FixedHeight
|
||||||
|
lineHeight = lineSpacing
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ void DoricTextNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
|
|||||||
} else if (name == "underline") {
|
} else if (name == "underline") {
|
||||||
view->setProperty("underline", prop.toBool());
|
view->setProperty("underline", prop.toBool());
|
||||||
} else if (name == "lineSpacing") {
|
} else if (name == "lineSpacing") {
|
||||||
|
view->setProperty("lineSpacing", prop.toDouble());
|
||||||
} else {
|
} else {
|
||||||
DoricViewNode::blend(view, name, prop);
|
DoricViewNode::blend(view, name, prop);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user