diff options
author | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2016-02-01 15:20:59 +0100 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2016-02-09 11:26:46 +0000 |
commit | 01405a2515243d81b4a7718dacb879eb5fd7cc92 (patch) | |
tree | 2625539ae19c5c595667800b4448b9d71eb11b61 /wayland/democompositor/qml/MyButton.qml | |
parent | 19acec2796c26bd902472ddd87858fac4d20ada4 (diff) |
Initial implementation of Diana's design
Based on the screenshots. Not using exact values for sizes
and distances.
Change-Id: I37c9593b776f4fb6f98ab4b8b571357f182ee65a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'wayland/democompositor/qml/MyButton.qml')
-rw-r--r-- | wayland/democompositor/qml/MyButton.qml | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/wayland/democompositor/qml/MyButton.qml b/wayland/democompositor/qml/MyButton.qml index c0ac2bb..c8397a6 100644 --- a/wayland/democompositor/qml/MyButton.qml +++ b/wayland/democompositor/qml/MyButton.qml @@ -37,7 +37,6 @@ import QtQuick 2.6 Item { - //property alias color: rect.color property alias text: buttonText signal triggered() signal alternateTrigger() @@ -46,7 +45,15 @@ Item { property bool enableSlide: false property bool longPressed: false - property color buttonColor: "lightgray" + property bool sliding: enableSlide && mouser.drag.active + + property color buttonColor: "magenta" + property color pressedColor: "cyan" + property color textColor: "#ff0000" + property double iconSize: 10 + + property alias icon: iconImage + Rectangle { id: rect anchors.top: parent.top @@ -54,23 +61,36 @@ Item { anchors.left: parent.left anchors.right: parent.right - radius: 10 - color: (enableSlide && mouser.drag.active) ? "#df3f1f" : mouser.containsPress ? (longPressed ? "#3faf1f" : "steelblue") : buttonColor + color: mouser.containsPress && !mouser.drag.active ? (longPressed ? "#3faf1f" : pressedColor) : buttonColor + + Item { + id: iconRect + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.margins: 5 + width: iconSize + height: iconSize + Image { + anchors.centerIn: parent + id: iconImage + } + } Text { + color: textColor anchors.margins: 10 id: buttonText anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left + anchors.left: iconRect.right anchors.right: parent.right text: "[Uninitialized]" } + //opacity: (enableSlide && mouser.drag.active) ? (1.2 - (x/width)) : 1.0 } MouseArea { id: mouser anchors.fill: parent - onPressed: { if (enableSlide) { rect.anchors.left = undefined @@ -78,6 +98,8 @@ Item { } } + //onPositionChanged: console.log("Mouse move: " + mouse.x + ", " + mouse.y) + onPressAndHold: if (enableAlternate) parent.longPressed = true onReleased: { if (enableSlide && drag.active) { @@ -96,7 +118,8 @@ Item { rect.anchors.right = parent.right parent.longPressed = false } - + onEntered: console.log("Enter: " + buttonText.text) + onExited: console.log("Exit: " + buttonText.text) drag.target: rect drag.threshold: 5 drag.axis: Drag.XAxis |