2
* This file is part of Maliit plugins
4
* Copyright (C) 2012 Openismus GmbH
6
* Contact: maliit-discuss@lists.maliit.org
8
* Redistribution and use in source and binary forms, with or without modification,
9
* are permitted provided that the following conditions are met:
11
* Redistributions of source code must retain the above copyright notice, this list
12
* of conditions and the following disclaimer.
13
* Redistributions in binary form must reproduce the above copyright notice, this list
14
* of conditions and the following disclaimer in the documentation and/or other materials
15
* provided with the distribution.
16
* Neither the name of Nokia Corporation nor the names of its contributors may be
17
* used to endorse or promote products derived from this software without specific
18
* prior written permission.
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23
* THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
property alias layout: keyRepeater.model
37
property variant event_handler
38
property bool area_enabled // MouseArea has no id property so we cannot alias its enabled property.
39
property alias title: keyboard_title.text
41
visible: layout.visible
43
property bool shown: false;
44
property bool hideAnimationFinished: false;
45
property int pressedKeyIndex: -1;
46
property Item pressedKey;
53
console.debug("title:" + layout.title)
60
property int jumpBackThreshold: 170
62
drag.target: keyboardSurface
63
drag.axis: Drag.YAxis;
66
drag.filterChildren: true
77
anchors.bottom: keypadMouseArea.top
80
height: maliit_wordribbon.enabled ? layout.wordribbon_height : 0
87
top: wordRibbon.bottom
89
topMargin: layout.invisible_toucharea_height + (maliit_wordribbon.enabled ? layout.wordribbon_height : 0);
103
GradientStop { position: 0.0; color: "#f1f1f1" }
104
GradientStop { position: 1.0; color: "#e4e4e4" }
110
source: "styles/ubuntu/images/border_top.png"
112
anchors.top: parent.top.bottom
117
source: "styles/ubuntu/images/border_bottom.png"
119
anchors.bottom: background.bottom
125
anchors.top: borderTop.bottom
126
anchors.bottom: borderBottom.top
135
property alias text: key_text_item.text;
137
x: key_reactive_area.x
138
y: key_reactive_area.y
139
width: key_reactive_area.width
140
height: key_reactive_area.height
145
width: key_rectangle.width
146
height: key_rectangle.height
148
border.left: key_background_borders.x
149
border.top: key_background_borders.y
150
border.right: key_background_borders.width
151
border.bottom: key_background_borders.height
153
source: key_background
160
font.family: key_font
161
font.pixelSize: key_font_size
162
color: key_font_color
164
horizontalAlignment: Text.AlignHCenter
165
verticalAlignment: Text.AlignVCenter
166
visible: (key_text.length != 0)
170
anchors.centerIn: parent
172
visible: (key_icon.length != 0)
177
enabled: area_enabled
181
onEntered: event_handler.onEntered(index)
182
onExited: event_handler.onExited(index)
186
pressedKeyIndex = index;
187
event_handler.onEntered(index)
190
if (key_action_insert)
195
event_handler.onPressed(index)
196
mouse.accepted = false;
200
console.error("ON_RELEASED")
201
if (pressedKeyIndex == -1)
205
event_handler.onReleased(pressedKeyIndex);
207
event_handler.onExited(pressedKeyIndex)
208
pressedKeyIndex = -1;
212
onPressAndHold: event_handler.onPressAndHold(index)
225
// Keyboard title rendering
226
// TODO: Make separate component?
228
anchors.centerIn: parent
229
opacity: title_timeout.running ? 1.0 : 0.0
231
Behavior on opacity {
234
easing.type: Easing.InOutQuad
243
// TODO: Make title background part of styling profile.
245
anchors.centerIn: parent
247
// Manual padding of text:
248
width: keyboard_title.width * 1.2
249
height: keyboard_title.height * 1.2
251
//anchors.fill: keyboard_title
252
source: layout.background
253
z: 1000 // Move behind Text element but in front of rest.
255
border.left: layout.background_borders.x
256
border.top: layout.background_borders.y
257
border.right: layout.background_borders.width
258
border.bottom: layout.background_borders.height
263
anchors.centerIn: parent
268
// TODO: Make title font part of styling profile.
273
} // keyboardContainer
276
if (pressedKeyIndex == -1)
280
event_handler.onReleased(pressedKeyIndex);
282
event_handler.onExited(pressedKeyIndex)
283
pressedKeyIndex = -1;
290
if (y > jumpBackThreshold) {
291
canvas.shown = false;
293
bounceBackAnimation.from = y
294
bounceBackAnimation.start();
299
id: bounceBackAnimation
300
target: keyboardSurface
302
easing.type: Easing.OutBounce;
303
easing.overshoot: 2.0
315
PropertyChanges { target: canvas; y: 0; }
316
when: canvas.shown === true
317
onCompleted: canvas.hideAnimationFinished = false;
322
PropertyChanges { target: canvas; y: height; }
324
keyboardSurface.y = 0;
325
canvas.hideAnimationFinished = true;
327
when: canvas.shown === false
330
transitions: Transition {
331
PropertyAnimation { target: canvas; properties: "y"; easing.type: Easing.InOutQuad }