| 1 |
/* |
| 2 |
* Copyright 2015 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 |
| 19 |
import Lomiri.Components.ListItems |
| 20 |
|
| 21 |
Item { |
| 22 |
id: control |
| 23 |
// style properties |
| 24 |
/*! |
| 25 |
Specifies the background color |
| 26 |
*/ |
| 27 |
property color backgroundColor: styledItem.enabled |
| 28 |
? theme.palette.normal.base |
| 29 |
: theme.palette.disabled.foreground |
| 30 |
/*! |
| 31 |
Background color for highlight. |
| 32 |
*/ |
| 33 |
property color highlightBackgroundColor: theme.palette.normal.raised |
| 34 |
/*! |
| 35 |
Highlight color. |
| 36 |
*/ |
| 37 |
property color highlightColor: theme.palette.normal.raisedText |
| 38 |
/*! |
| 39 |
Scale of the highlight item |
| 40 |
*/ |
| 41 |
property real highlightScaleFactor: 1.2 |
| 42 |
/*! |
| 43 |
Thickness of the highlight component |
| 44 |
*/ |
| 45 |
property real highlightThickness: styledItem.itemHeight + units.gu(1) |
| 46 |
|
| 47 |
/*! |
| 48 |
The content holder exposed to the Picker so tumbler list can be reparented to it. |
| 49 |
*/ |
| 50 |
property alias tumblerHolder: content |
| 51 |
|
| 52 |
/*! |
| 53 |
\internal |
| 54 |
View instance listing the model |
| 55 |
*/ |
| 56 |
property Item view: Item{} |
| 57 |
|
| 58 |
anchors.fill: parent |
| 59 |
implicitWidth: units.gu(8) |
| 60 |
implicitHeight: units.gu(20) |
| 61 |
|
| 62 |
// frame |
| 63 |
LomiriShape { |
| 64 |
anchors.fill: parent |
| 65 |
radius: "medium" |
| 66 |
backgroundColor: theme.palette.normal.overlay |
| 67 |
source: shapeSource |
| 68 |
} |
| 69 |
|
| 70 |
ShaderEffectSource { |
| 71 |
id: shapeSource |
| 72 |
sourceItem: background |
| 73 |
hideSource: true |
| 74 |
// FIXME: visible: false prevents rendering so make it a nearly |
| 75 |
// transparent 1x1 pixel instead |
| 76 |
opacity: 0.01 |
| 77 |
width: 1 |
| 78 |
height: 1 |
| 79 |
} |
| 80 |
|
| 81 |
Rectangle { |
| 82 |
id: background |
| 83 |
anchors.fill: parent |
| 84 |
|
| 85 |
MouseArea { |
| 86 |
anchors.fill: parent |
| 87 |
} |
| 88 |
// background |
| 89 |
color: backgroundColor |
| 90 |
|
| 91 |
Item { |
| 92 |
id: content |
| 93 |
anchors.fill: parent |
| 94 |
} |
| 95 |
|
| 96 |
// highlight |
| 97 |
Rectangle { |
| 98 |
id: highlightItem |
| 99 |
y: (content.height - control.highlightThickness) / 2 |
| 100 |
anchors { |
| 101 |
left: content.left |
| 102 |
right: content.right |
| 103 |
} |
| 104 |
height: control.highlightThickness |
| 105 |
color: highlightBackgroundColor |
| 106 |
} |
| 107 |
ThinDivider { |
| 108 |
anchors { |
| 109 |
left: content.left |
| 110 |
right: content.right |
| 111 |
bottom: highlightItem.top |
| 112 |
} |
| 113 |
} |
| 114 |
ThinDivider { |
| 115 |
anchors { |
| 116 |
left: content.left |
| 117 |
right: content.right |
| 118 |
top: highlightItem.bottom |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
ShaderEffectSource { |
| 123 |
id: effectSource |
| 124 |
visible: false |
| 125 |
sourceItem: view |
| 126 |
|
| 127 |
property real sourceRectMultiplier: 2.0 |
| 128 |
// XXX: This works because the parent of magnifier is the same as sourceItem |
| 129 |
// in this case. Otherwise coordinate transformations will be needed. |
| 130 |
sourceRect: Qt.rect(highlightItem.x, highlightItem.y, highlightItem.width, highlightItem.height) |
| 131 |
textureSize: Qt.size(highlightItem.width*sourceRectMultiplier, highlightItem.height*sourceRectMultiplier) |
| 132 |
} |
| 133 |
HighlightMagnifier { |
| 134 |
anchors.fill: highlightItem |
| 135 |
scaleFactor: control.highlightScaleFactor |
| 136 |
outputColor: control.highlightColor |
| 137 |
source: effectSource |
| 138 |
} |
| 139 |
} |
| 140 |
} |