mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
split ToolbarButton.qml into a stateful image part
This commit is contained in:
parent
182050c4b9
commit
b0518feee4
2 changed files with 35 additions and 29 deletions
34
interface/resources/qml/hifi/toolbars/StateImage.qml
Normal file
34
interface/resources/qml/hifi/toolbars/StateImage.qml
Normal file
|
@ -0,0 +1,34 @@
|
|||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
|
||||
Item {
|
||||
property alias imageURL: image.source
|
||||
property alias alpha: image.opacity
|
||||
property var subImage;
|
||||
property int yOffset: 0
|
||||
property int buttonState: 0
|
||||
property real size: 50
|
||||
width: size; height: size
|
||||
property bool pinned: false
|
||||
clip: true
|
||||
|
||||
function updateYOffset() { yOffset = size * buttonState; }
|
||||
onButtonStateChanged: updateYOffset();
|
||||
|
||||
Component.onCompleted: {
|
||||
if (subImage) {
|
||||
if (subImage.y) {
|
||||
yOffset = subImage.y;
|
||||
return;
|
||||
}
|
||||
}
|
||||
updateYOffset();
|
||||
}
|
||||
|
||||
Image {
|
||||
id: image
|
||||
y: -parent.yOffset;
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +1,13 @@
|
|||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
|
||||
Item {
|
||||
StateImage {
|
||||
id: button
|
||||
property alias imageURL: image.source
|
||||
property alias alpha: image.opacity
|
||||
property var subImage;
|
||||
property int yOffset: 0
|
||||
property int buttonState: 0
|
||||
property int hoverState: -1
|
||||
property int defaultState: -1
|
||||
property var toolbar;
|
||||
property real size: 50 // toolbar ? toolbar.buttonSize : 50
|
||||
width: size; height: size
|
||||
property bool pinned: false
|
||||
clip: true
|
||||
|
||||
onButtonStateChanged: {
|
||||
yOffset = size * buttonState;
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (subImage) {
|
||||
if (subImage.y) {
|
||||
yOffset = subImage.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signal clicked()
|
||||
|
||||
Image {
|
||||
id: image
|
||||
y: -button.yOffset;
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: asyncClickSender
|
||||
interval: 10
|
||||
|
|
Loading…
Reference in a new issue