2021-02-25 19:04:14 +08:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.5
|
2021-03-18 11:27:26 +08:00
|
|
|
|
2021-03-16 15:20:46 +08:00
|
|
|
import "util.mjs" as Util
|
2021-03-18 11:27:26 +08:00
|
|
|
import "gravity.mjs" as Gravity
|
2021-02-25 19:04:14 +08:00
|
|
|
|
2021-03-15 15:30:17 +08:00
|
|
|
Rectangle {
|
2021-04-06 16:14:43 +08:00
|
|
|
property var wrapper
|
2021-03-19 16:13:02 +08:00
|
|
|
|
2021-03-16 15:20:46 +08:00
|
|
|
property var uuid: Util.uuidv4()
|
|
|
|
property int childrenRectWidth: childrenRect.width
|
|
|
|
property int childrenRectHeight: childrenRect.width
|
2021-03-15 15:30:17 +08:00
|
|
|
color: 'transparent'
|
|
|
|
|
2021-03-16 15:20:46 +08:00
|
|
|
property var tag: "Text"
|
|
|
|
|
|
|
|
onWidthChanged: () => {
|
|
|
|
console.log(tag, uuid + " onWidthChanged: " + this.width)
|
|
|
|
}
|
|
|
|
|
|
|
|
onHeightChanged: () => {
|
|
|
|
console.log(tag, uuid + " onHeightChanged: " + this.height)
|
|
|
|
}
|
|
|
|
|
|
|
|
onChildrenRectChanged: () => {
|
2021-03-16 15:33:24 +08:00
|
|
|
console.log(tag, uuid + " onChildrenRectChanged: " + childrenRect)
|
2021-03-16 15:20:46 +08:00
|
|
|
this.childrenRectWidth = childrenRect.width
|
|
|
|
this.childrenRectHeight = childrenRect.height
|
|
|
|
|
2021-03-16 16:01:38 +08:00
|
|
|
if (this.width < this.childrenRectWidth) {
|
2021-03-16 15:20:46 +08:00
|
|
|
this.width = this.childrenRectWidth
|
|
|
|
}
|
2021-03-16 16:01:38 +08:00
|
|
|
if (this.height < this.childrenRectHeight) {
|
2021-03-16 15:20:46 +08:00
|
|
|
this.height = this.childrenRectHeight
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-04 17:44:54 +08:00
|
|
|
Text {
|
2021-03-18 11:27:26 +08:00
|
|
|
property int textAlignment: 0
|
|
|
|
|
|
|
|
onTextAlignmentChanged: {
|
|
|
|
let gravity = Gravity.enumerate()
|
|
|
|
let result = this.textAlignment | gravity.CENTER_Y
|
|
|
|
console.log(tag, uuid + " onTextAlignmentChanged: " + this.textAlignment)
|
|
|
|
switch(result) {
|
|
|
|
case gravity.CENTER:
|
|
|
|
this.anchors.horizontalCenter = parent.horizontalCenter
|
|
|
|
this.anchors.verticalCenter = parent.verticalCenter
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2021-03-04 17:44:54 +08:00
|
|
|
}
|
2021-03-18 11:49:52 +08:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
2021-03-19 16:13:02 +08:00
|
|
|
mouseAreaBridge.onClick(wrapper)
|
2021-03-18 11:49:52 +08:00
|
|
|
}
|
|
|
|
}
|
2021-02-25 19:04:14 +08:00
|
|
|
}
|