83 lines
1.6 KiB
QML
Raw Normal View History

import QtQuick 2.13
import QtQuick.Controls.Material 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.13
Item {
2019-07-29 15:29:07 +03:00
id: imageView
property int size: 50
property double ratio: 1
2019-07-29 15:29:07 +03:00
property string drawItem: ""
property bool hovered: false
property bool hold: false
signal clicked();
width: size * ratio
height: size
Image {
id: img
fillMode: Image.PreserveAspectCrop
2019-07-29 15:29:07 +03:00
source: drawItem
sourceSize: Qt.size(parent.width, parent.height)
smooth: true
visible: false
}
DropShadow {
anchors.fill: img
horizontalOffset: (hold)? 20: (hovered)? 10: 5
verticalOffset: (hold)? 20: (hovered)? 10: 5
radius: 8.0
samples: 17
Behavior on horizontalOffset {
ColorAnimation {
duration: 200
}
}
Behavior on verticalOffset {
ColorAnimation {
duration: 200
}
}
Behavior on color {
ColorAnimation {
duration: 200
}
}
color: (hold)? "#80000000": (hovered)? "#40000000": "#20000000"
source: img
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: {
parent.hovered = true;
}
onExited: {
parent.hovered = false;
}
onReleased: {
parent.hold = false;
2019-07-29 15:29:07 +03:00
imageView.clicked();
}
2019-07-29 15:29:07 +03:00
onPressed: {
parent.hold = true;
}
}
}