| 1 |
/* |
| 2 |
* Copyright 2016 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.4 |
| 18 |
import Lomiri.Components 1.3 |
| 19 |
import QtGraphicalEffects 1.0 |
| 20 |
|
| 21 |
// FIXME: Replace this once LomiriShape support for gradients and shading has landed |
| 22 |
Rectangle { |
| 23 |
anchors.fill: parent |
| 24 |
radius: width / 2 |
| 25 |
antialiasing: true |
| 26 |
|
| 27 |
property real offset : units.gu(0.2) |
| 28 |
|
| 29 |
property color dialerColor: theme.palette.normal.base |
| 30 |
|
| 31 |
gradient: Gradient { |
| 32 |
GradientStop { position: 0.0; color: dialerColor } |
| 33 |
GradientStop { position: 0.25; color: Qt.darker(dialerColor, 1.0) } |
| 34 |
GradientStop { position: 0.5; color: Qt.darker(dialerColor, 1.1) } |
| 35 |
GradientStop { position: 0.75; color: Qt.darker(dialerColor, 1.2) } |
| 36 |
GradientStop { position: 1.0; color: Qt.darker(dialerColor, 1.3) } |
| 37 |
} |
| 38 |
// draws the outter shadow/highlight |
| 39 |
Rectangle { |
| 40 |
id: sourceOutter |
| 41 |
anchors { fill: parent; margins: -offset } |
| 42 |
radius: (width / 2) |
| 43 |
antialiasing: true |
| 44 |
gradient: Gradient { |
| 45 |
GradientStop { position: 0.0; color: "black" } |
| 46 |
GradientStop { position: 0.5; color: "transparent" } |
| 47 |
GradientStop { position: 1.0; color: "white" } |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
// mask for outer 3D effect |
| 52 |
Rectangle { |
| 53 |
id: maskOutter |
| 54 |
anchors.fill: sourceOutter |
| 55 |
color: "transparent" |
| 56 |
radius: (width / 2) |
| 57 |
antialiasing: true |
| 58 |
border { width: offset; color: "black" } |
| 59 |
} |
| 60 |
|
| 61 |
// outter effect |
| 62 |
OpacityMask { |
| 63 |
anchors.fill: sourceOutter |
| 64 |
opacity: 0.65 |
| 65 |
source: ShaderEffectSource { |
| 66 |
sourceItem: sourceOutter |
| 67 |
hideSource: true |
| 68 |
} |
| 69 |
maskSource: ShaderEffectSource { |
| 70 |
sourceItem: maskOutter |
| 71 |
hideSource: true |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
// center item |
| 76 |
// FIXME: Replace this once LomiriShape support for gradients and shading has landed |
| 77 |
Rectangle { |
| 78 |
parent: styledItem.centerItem.parent |
| 79 |
anchors.fill: parent |
| 80 |
radius: width / 2; |
| 81 |
antialiasing: true; |
| 82 |
|
| 83 |
gradient: Gradient { |
| 84 |
GradientStop { position: 0.0; color: dialerColor } |
| 85 |
GradientStop { position: 0.25; color: Qt.darker(dialerColor, 1.0) } |
| 86 |
GradientStop { position: 0.5; color: Qt.darker(dialerColor, 1.1) } |
| 87 |
GradientStop { position: 0.75; color: Qt.darker(dialerColor, 1.2) } |
| 88 |
GradientStop { position: 1.0; color: Qt.darker(dialerColor, 1.3) } |
| 89 |
} |
| 90 |
|
| 91 |
// draws the inner highlight / shadow |
| 92 |
Rectangle { |
| 93 |
id: sourceInner; |
| 94 |
anchors { fill: parent; margins: -offset } |
| 95 |
radius: (width / 2) |
| 96 |
antialiasing: true |
| 97 |
gradient: Gradient { |
| 98 |
GradientStop { position: 0.0; color: "white" } |
| 99 |
GradientStop { position: 0.5; color: "transparent" } |
| 100 |
GradientStop { position: 1.0; color: "black" } |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
// mask for inner 3D effect |
| 105 |
Rectangle { |
| 106 |
id: maskInner |
| 107 |
color: "transparent" |
| 108 |
anchors.fill: sourceInner |
| 109 |
radius: (width / 2) |
| 110 |
antialiasing: true |
| 111 |
border { width: offset; color: "black" } |
| 112 |
} |
| 113 |
|
| 114 |
// inner effect |
| 115 |
OpacityMask { |
| 116 |
opacity: 0.65 |
| 117 |
anchors.fill: sourceInner |
| 118 |
source: ShaderEffectSource { |
| 119 |
sourceItem: sourceInner |
| 120 |
hideSource: true |
| 121 |
} |
| 122 |
maskSource: ShaderEffectSource { |
| 123 |
sourceItem: maskInner |
| 124 |
hideSource: true |
| 125 |
} |
| 126 |
} |
| 127 |
} |
| 128 |
} |