Debian Codegraph @

src/imports/Components/Themes/Ambiance/2.0/TextAreaStyle.qml

raw
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
20 // frame
21 // FIXME: stabilize API
22 Item {
23 id: visuals
24 // style properties
25 // FIXME: needs type checking in themes to define the proper type to be used
26 // if color type is used, alpha value gets lost
27
28 property color color: styledItem.enabled
29 ? ((styledItem.activeFocus || styledItem.highlighted)
30 ? theme.palette.selected.fieldText
31 : theme.palette.normal.fieldText)
32 : theme.palette.disabled.fieldText
33 property color selectedTextColor: styledItem.enabled ? theme.palette.selected.selectionText : theme.palette.disabled.selectionText
34 property color selectionColor: styledItem.enabled ? theme.palette.selected.selection : theme.palette.disabled.selection
35 /*!
36 Background fill color
37 */
38 property color borderColor: theme.palette.normal.base
39 property color backgroundColor: styledItem.enabled
40 ? ((styledItem.activeFocus || styledItem.highlighted)
41 ? theme.palette.selected.field
42 : theme.palette.normal.field)
43 : theme.palette.disabled.field
44 property color errorColor: styledItem.enabled ? theme.palette.normal.negative : theme.palette.disabled.negative
45
46 /*!
47 Spacing between the frame and the text editor area
48 */
49 property real frameSpacing: units.gu(1)
50 // Obsolete
51 property alias overlaySpacing: visuals.frameSpacing
52
53 // style body
54 anchors.fill: parent
55 objectName: "textarea_style"
56
57 z: -1
58
59 /*!
60 Text input background
61 */
62 FocusShape {
63 }
64
65 property Component background: LomiriShape {
66 property bool error: (styledItem.hasOwnProperty("errorHighlight") && styledItem.errorHighlight && !styledItem.acceptableInput)
67 onErrorChanged: (error) ? visuals.errorColor : visuals.backgroundColor;
68 backgroundColor: visuals.borderColor
69 aspect: LomiriShape.Flat
70 visible: !styledItem.readOnly
71 anchors.fill: parent
72
73 LomiriShape {
74 anchors.fill: parent
75 anchors.margins: parent.visible ? units.dp(0.5) : 0
76 radius: units.gu(1.7)
77 backgroundColor: visuals.backgroundColor
78 aspect: LomiriShape.Flat
79 source: ShaderEffectSource {
80 sourceItem: styledItem.__rightScrollbar ? styledItem.__rightScrollbar : null
81 hideSource: true
82 }
83 sourceFillMode: LomiriShape.Pad
84 sourceHorizontalAlignment: LomiriShape.AlignRight
85 }
86 }
87
88 Loader {
89 id: backgroundLoader
90 sourceComponent: background
91 anchors.fill: parent
92 }
93 }