summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Gottfried <sebastiangottfried@web.de>2016-09-29 15:58:24 (GMT)
committerSebastian Gottfried <sebastiangottfried@web.de>2016-09-29 15:58:24 (GMT)
commita99a1cc845e1db69f1b86601c0bde2a20c3b1936 (patch)
tree5db5816a0e8d23680147ae2a6cbff4323c8c7d4f
parent9045bd318d945f308369522eb8f6cc722a8ee54c (diff)
Balloon.qml: Small Fixes And Improvements
* fix rendering of tip if balloon is positioned above its target * render drop shadow as as a layer effect of the whole item
-rw-r--r--src/qml/Balloon.qml140
1 files changed, 68 insertions, 72 deletions
diff --git a/src/qml/Balloon.qml b/src/qml/Balloon.qml
index 333d566..c915f62 100644
--- a/src/qml/Balloon.qml
+++ b/src/qml/Balloon.qml
@@ -43,6 +43,13 @@ Loader {
id: dismissArea
anchors.fill: parent
opacity: root.active && (root.status == 'open' || root.status =='opening')? 1 : 0
+ layer.enabled: true
+ layer.effect: DropShadow {
+ anchors.fill: parent
+ source: internalWrapper
+ radius: 5
+ samples: 11
+ }
Behavior on opacity {
SequentialAnimation {
@@ -65,89 +72,78 @@ Loader {
colorGroup: SystemPalette.Active
}
- Item {
- id: internalWrapper
- anchors.fill: parent
- visible: false
-
- Rectangle {
- id: internal
- color: palette.alternateBase
- radius: 5
-
- property variant parentPos: root.visualParent? root.visualParent.mapToItem(dismissArea, 0, 0): Qt.point(0, 0)
- property bool under: root.visualParent ? internal.parentPos.y + root.visualParent.height + height < dismissArea.height : true
+ Rectangle {
+ id: internal
+ color: palette.alternateBase
+ radius: 5
- //bindings won't work inside anchors definition
- onUnderChanged: {
- if (under) {
- balloonTip.anchors.top = undefined
- balloonTip.anchors.bottom = balloonTip.parent.top
- } else {
- balloonTip.anchors.bottom = undefined
- balloonTip.anchors.top = balloonTip.parent.bottom
- }
+ property variant parentPos: root.visualParent? root.visualParent.mapToItem(dismissArea, 0, 0): Qt.point(0, 0)
+ property bool under: root.visualParent ? internal.parentPos.y + root.visualParent.height + height < dismissArea.height : true
+
+ //bindings won't work inside anchors definition
+ onUnderChanged: {
+ if (under) {
+ balloonTip.anchors.top = undefined
+ balloonTip.anchors.bottom = balloonTip.parent.top
+ } else {
+ balloonTip.anchors.bottom = undefined
+ balloonTip.anchors.top = balloonTip.parent.bottom
}
+ }
- property int preferedX: internal.parentPos.x - internal.width/2 + root.visualParent.width/2
- x: Math.round(Math.max(radius, Math.min(dismissArea.width - internal.width - radius, preferedX)))
- y: {
- if (root.visualParent) {
- if (under) {
- Math.round(internal.parentPos.y + root.visualParent.height + balloonTip.height + radius)
- } else {
- Math.round(internal.parentPos.y - internal.height - balloonTip.height - radius)
- }
+ property int preferedX: internal.parentPos.x - internal.width/2 + root.visualParent.width/2
+ x: Math.round(Math.max(radius, Math.min(dismissArea.width - internal.width - radius, preferedX)))
+ y: {
+ if (root.visualParent) {
+ if (under) {
+ Math.round(internal.parentPos.y + root.visualParent.height + balloonTip.height + radius)
} else {
- Math.round(dismissArea.height/2 - internal.height/2)
+ Math.round(internal.parentPos.y - internal.height - balloonTip.height - radius)
}
+ } else {
+ Math.round(dismissArea.height/2 - internal.height/2)
}
- width: contentItem.width + 2 * internal.radius
- height: contentItem.height + 2 * internal.radius
-
- Rectangle {
- id: balloonTip
- color: internal.color
- anchors {
- horizontalCenter: parent.horizontalCenter
- horizontalCenterOffset: internal.preferedX - internal.x
- }
- width: 10
- height: 10
- visible: false
- }
-
- Image {
- id: balloonTipMask
- anchors.fill: balloonTip
- visible: false
- source: utils.findImage("balloontip.svgz")
- sourceSize: Qt.size(width, height)
- }
+ }
+ width: contentItem.width + 2 * internal.radius
+ height: contentItem.height + 2 * internal.radius
- OpacityMask {
- anchors.fill: balloonTip
- visible: root.visualParent != null
- source: balloonTip
- maskSource: balloonTipMask
+ Rectangle {
+ id: balloonTip
+ color: internal.color
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ horizontalCenterOffset: internal.preferedX - internal.x
+ top: parent.bottom
}
+ width: 10
+ height: 10
+ visible: false
}
- }
- DropShadow {
- anchors.fill: parent
- source: internalWrapper
- radius: 5
- samples: 11
- }
+ Image {
+ id: balloonTipMask
+ anchors.fill: balloonTip
+ visible: false
+ source: utils.findImage("balloontip.svgz")
+ sourceSize: Qt.size(width, height)
+ }
+
+ OpacityMask {
+ anchors.fill: balloonTip
+ visible: root.visualParent != null
+ source: balloonTip
+ maskSource: balloonTipMask
+ rotation: internal.under? 0: 180
+ }
- Item {
- id: contentItem
- x: internal.x + internal.radius
- y: internal.y + internal.radius
- width: childrenRect.width
- height: childrenRect.height + 2
- data: root.data
+ Item {
+ id: contentItem
+ x: internal.radius
+ y: internal.radius
+ width: childrenRect.width
+ height: childrenRect.height + 2
+ data: root.data
+ }
}
onClicked: {