| 1 |
/* |
| 2 |
* Copyright 2012 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.2 |
| 19 |
|
| 20 |
/*! |
| 21 |
\qmltype ThinDivider |
| 22 |
\inqmlmodule Lomiri.Components.ListItems 1.0 |
| 23 |
\ingroup lomiri-listitems |
| 24 |
\brief Narrow line used as a divider between ListItems. |
| 25 |
|
| 26 |
ListItems will usually include this line at the bottom of the item |
| 27 |
to give a visually pleasing list of items. But a divider line can |
| 28 |
also be inserted manually using this component. |
| 29 |
|
| 30 |
Examples: |
| 31 |
\qml |
| 32 |
import Lomiri.Components.ListItems 1.0 as ListItem |
| 33 |
Column { |
| 34 |
width: 250 |
| 35 |
ListItem.ThinDivider {} //can be used as header for list |
| 36 |
ListItem.Standard { |
| 37 |
text: "List Item without thin divider line" |
| 38 |
showDivider: false |
| 39 |
} |
| 40 |
ListItem.ThinDivider {} // manually inserted divider line |
| 41 |
ListItem.Standard { |
| 42 |
text: "ListItem with thin divider line" |
| 43 |
} |
| 44 |
} |
| 45 |
\endqml |
| 46 |
*/ |
| 47 |
Rectangle { |
| 48 |
anchors { |
| 49 |
left: (parent) ? parent.left : null |
| 50 |
right: (parent) ? parent.right : null |
| 51 |
} |
| 52 |
height: (visible) ? units.dp(2) : 0 |
| 53 |
// a private property to catch theme background color change |
| 54 |
// use private property instead of embedding it into a QtObject to avoid further |
| 55 |
// performance decrease |
| 56 |
property bool __lightBackground: ColorUtils.luminance(Theme.palette.normal.background) > 0.85 |
| 57 |
// use a gradient of 4 steps instead of instantiating two Rectangles for performance reasons |
| 58 |
gradient: Gradient { |
| 59 |
GradientStop { position: 0.0; color: __lightBackground ? Qt.rgba(0, 0, 0, 0.1) : Qt.rgba(0, 0, 0, 0.4) } |
| 60 |
GradientStop { position: 0.49; color: __lightBackground ? Qt.rgba(0, 0, 0, 0.1) : Qt.rgba(0, 0, 0, 0.4) } |
| 61 |
GradientStop { position: 0.5; color: __lightBackground ? Qt.rgba(1, 1, 1, 0.4) : Qt.rgba(1, 1, 1, 0.1) } |
| 62 |
GradientStop { position: 1.0; color: __lightBackground ? Qt.rgba(1, 1, 1, 0.4) : Qt.rgba(1, 1, 1, 0.1) } |
| 63 |
} |
| 64 |
} |