feat: enable tooltip orientation

This commit is contained in:
Jonathan Rainville 2021-03-25 13:37:25 -04:00 committed by Iuri Matias
parent 0478a04db9
commit d09f049e77
1 changed files with 27 additions and 6 deletions

View File

@ -6,6 +6,8 @@ import "../../shared"
ToolTip { ToolTip {
id: tooltip id: tooltip
property int maxWidth: 800 property int maxWidth: 800
property string orientation: "top"
implicitWidth: Math.min(maxWidth, textContent.implicitWidth + Style.current.bigPadding) implicitWidth: Math.min(maxWidth, textContent.implicitWidth + Style.current.bigPadding)
leftPadding: Style.current.smallPadding leftPadding: Style.current.smallPadding
rightPadding: Style.current.smallPadding rightPadding: Style.current.smallPadding
@ -23,13 +25,32 @@ ToolTip {
} }
Rectangle { Rectangle {
color: tooltipContentBg.color color: tooltipContentBg.color
height: 24 height: orientation === "top" || orientation === "bottom" ? 24 : 24
width: 24 width: orientation === "top" || orientation === "bottom" ? 24 : 24
rotation: 135 rotation: 45
radius: 1 radius: 1
x: tooltipBg.width / 2 - width / 2 x: {
anchors.top: tooltipContentBg.bottom if (orientation === "top" || orientation === "bottom") {
anchors.topMargin: -20 return tooltipBg.width / 2 - width / 2
}
if (orientation === "left") {
return tooltipContentBg.width - (width / 2) - 4
}
if (orientation === "right") {
return -width/2 + 4
}
}
y: {
if (orientation === "bottom") {
return -height / 2
}
if (orientation === "top") {
return tooltipBg.height - height
}
if (orientation === "left" || orientation === "right") {
return tooltipContentBg.height / 2 - (height / 2)
}
}
} }
} }
contentItem: StyledText { contentItem: StyledText {