Squaby Demo
import QtQuick 2.0
import Felgo 4.0
Item {
id: mainMenuButton
x: __outslidedX
width: mainMenuButtonImage.width
height: mainMenuButtonImage.height
property int delay: 0
property string text
property int offsetX: 0
property int slideDuration: 800
property int __outslidedX: slideInFromRight ? -outslidedXBase * (1 + delay / slideDuration) : outslidedXBase * (1 + delay / slideDuration)
property int outslidedXBase: 384
property bool slideInFromRight: true
property alias textItem: textItem
signal clicked
signal pressed
signal released
signal canceled
property bool slidedOut: false
MultiResolutionImage {
id: mainMenuButtonImage
transformOrigin: Item.TopLeft
opacity: 0.75
source: Qt.resolvedUrl("../../assets/img/menuBar.png")
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
textItem.font.pixelSize = 42
mainMenuButton.clicked()
}
onPressed: {
textItem.font.pixelSize = 38
mainMenuButton.pressed()
mainMenuButtonImage.opacity = 0.9
}
onReleased: {
textItem.font.pixelSize = 42
mainMenuButton.released()
mainMenuButtonImage.opacity = 0.75
}
onCanceled: {
textItem.font.pixelSize = 42
mainMenuButton.canceled()
}
}
}
Text {
id: textItem
text: mainMenuButton.text
color: "white"
font.family: jellyFont.name
font.pixelSize: 42
anchors.right: mainMenuButton.right
anchors.rightMargin: 15
anchors.verticalCenter: mainMenuButton.verticalCenter
}
Behavior on x {
SmoothedAnimation { duration: slideDuration; easing.type: Easing.InOutQuad }
}
function slideIn() {
mainMenuButton.slidedOut = false
if(slideInFromRight) {
x = -200 + offsetX
} else {
x = __outslidedX+200-offsetX-384
}
}
function slideOut() {
mainMenuButton.slidedOut = true
if(slideInFromRight) {
x = __outslidedX
} else {
x = __outslidedX
}