Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.0;
- Item {
- id: button;
- width: Math.max (label.contentWidth + 20, 120);
- height: Math.max (label.contentHeight + 20, 40);
- property int roundness : Math.floor (height / 2);
- property color baseColor : "green";
- property alias value : label.text;
- property alias pressed : clicker.pressed;
- signal clicked ();
- Rectangle {
- id: rectAura;
- color: "gray";
- opacity: 0.15;
- antialiasing: true;
- radius: (button.roundness - anchors.margins);
- anchors {
- fill: parent;
- margins: -4;
- }
- }
- Rectangle {
- id: rectShadow;
- color: "black";
- opacity: 0.85;
- antialiasing: true;
- radius: (button.roundness - anchors.margins);
- anchors {
- fill: parent;
- topMargin: (button.pressed ? 0 : +1);
- bottomMargin: (button.pressed ? 0 : -1);
- }
- }
- Rectangle {
- id: rectColor;
- radius: button.roundness;
- antialiasing: true;
- border {
- width: 2;
- color: Qt.darker (button.baseColor, 1.65);
- }
- gradient: Gradient {
- GradientStop { position: (button.pressed ? 1.0 : 0.0); color: Qt.lighter (button.baseColor, 1.45); }
- GradientStop { position: (button.pressed ? 0.0 : 1.0); color: Qt.darker (button.baseColor, 1.45); }
- }
- anchors {
- fill: parent;
- topMargin: (button.pressed ? +1 : 0);
- bottomMargin: (button.pressed ? -1 : 0);
- }
- Rectangle {
- id: rectTangoHighlight;
- color: "transparent";
- opacity: 0.35;
- antialiasing: true;
- radius: (parent.radius - anchors.margins);
- border {
- width: 1;
- color: "white";
- }
- anchors {
- fill: parent;
- margins: parent.border.width;
- }
- }
- Text {
- id: label;
- text: qsTr ("Nice button !");
- renderType: Text.QtRendering;
- color: "white";
- font {
- bold: true;
- pixelSize: 16;
- family: "Calibri";
- }
- anchors.centerIn: parent;
- Text {
- id: textShadow;
- z: -1;
- color: "black";
- opacity: 0.65;
- text: parent.text;
- font: parent.font;
- visible: (offset !== 0);
- anchors {
- fill: parent;
- topMargin: offset;
- leftMargin: offset;
- rightMargin: -offset;
- bottomMargin: -offset;
- }
- property int offset : 1;
- }
- }
- }
- MouseArea {
- id: clicker;
- anchors.fill: parent;
- onClicked: { button.clicked (); }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement