Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/tinyText into lp:ubuntu-ui-toolkit/staging

Proposed by Cris Dywan
Status: Work in progress
Proposed branch: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/tinyText
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 506 lines (+288/-41) (has conflicts)
10 files modified
src/Ubuntu/Components/1.3/InputHandler.qml (+5/-2)
src/Ubuntu/Components/1.3/TextArea.qml (+2/-1)
src/Ubuntu/Components/1.3/TextArea14.qml (+77/-0)
src/Ubuntu/Components/1.3/TextCursor.qml (+6/-30)
src/Ubuntu/Components/1.3/TextField.qml (+2/-0)
src/Ubuntu/Components/1.3/TextField14.qml (+108/-0)
src/Ubuntu/Components/ComponentModule.pro (+2/-0)
src/Ubuntu/Components/Themes/Ambiance/1.3/TextAreaStyle.qml (+0/-2)
src/Ubuntu/Components/qmldir (+4/-2)
tests/unit_x11/tst_components/tst_textinput_common13.qml (+82/-4)
Text conflict in tests/unit_x11/tst_components/tst_textinput_common13.qml
To merge this branch: bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/tinyText
Reviewer Review Type Date Requested Status
Ubuntu SDK team Pending
Review via email: mp+295710@code.launchpad.net

Commit message

Tiny Text* components for experimenting

To post a comment you must log in.

Unmerged revisions

1980. By Cris Dywan

Simplify TextArea14 and add a reference ScrollView/Flickable/TextEdit

1979. By Cris Dywan

Tiny Text* components for experimenting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/1.3/InputHandler.qml'
2--- src/Ubuntu/Components/1.3/InputHandler.qml 2016-05-09 08:12:31 +0000
3+++ src/Ubuntu/Components/1.3/InputHandler.qml 2016-05-25 12:39:37 +0000
4@@ -90,10 +90,13 @@
5 {
6 if (flickable.moving || flickable.flicking)
7 return;
8+ //flickable.contentX = MathUtils.clamp(flickable.contentX, flickable.originX, flickable.originX + flickable.contentWidth - flickable.width);
9+ return;
10 if (flickable.contentX >= rect.x)
11 flickable.contentX = rect.x;
12- else if (flickable.contentX + flickable.width <= rect.x + rect.width)
13- flickable.contentX = rect.x + rect.width - flickable.width;
14+ else if (flickable.contentX + flickable.contentWidth <= rect.x + rect.width)
15+ flickable.contentX = rect.x + rect.width - flickable.contentWidth;
16+ return;
17 if (flickable.contentY >= rect.y)
18 flickable.contentY = rect.y;
19 else if (flickable.contentY + flickable.height <= rect.y + rect.height)
20
21=== modified file 'src/Ubuntu/Components/1.3/TextArea.qml'
22--- src/Ubuntu/Components/1.3/TextArea.qml 2016-05-12 16:30:27 +0000
23+++ src/Ubuntu/Components/1.3/TextArea.qml 2016-05-25 12:39:37 +0000
24@@ -884,9 +884,10 @@
25 anchors.topMargin: -internal.frameSpacing
26 anchors.rightMargin: -internal.frameSpacing
27 anchors.bottomMargin: -internal.frameSpacing
28+ __alwaysOnScrollbars: true
29 Ubuntu.StyleHints {
30 // No background color
31- troughColorSteppersStyle: Qt.rgba(0, 0, 0, 0)
32+ // troughColorSteppersStyle: Qt.rgba(0, 0, 0, 0)
33 }
34 }
35
36
37=== added file 'src/Ubuntu/Components/1.3/TextArea14.qml'
38--- src/Ubuntu/Components/1.3/TextArea14.qml 1970-01-01 00:00:00 +0000
39+++ src/Ubuntu/Components/1.3/TextArea14.qml 2016-05-25 12:39:37 +0000
40@@ -0,0 +1,77 @@
41+import QtQuick 2.4
42+import Ubuntu.Components 1.3 as Ubuntu
43+
44+Ubuntu.StyledItem {
45+ id: main
46+ implicitWidth: units.gu(30)
47+ implicitHeight: units.gu(4) * 5
48+
49+ property alias text: input.text
50+ property string placeholderText //FIXME: placeHolder is a placeHolder for now
51+
52+ styleName: "TextAreaStyle"
53+ Keys.forwardTo: [input]
54+ // FIXME: property alias activeFocusOnPress: input.activeFocusOnPress
55+ activeFocusOnPress: true
56+
57+ ScrollView {
58+ anchors.fill: parent
59+ Flickable {
60+ id: flickable
61+ anchors {
62+ fill: parent
63+ }
64+ property real spacing: main.__styleInstance.frameSpacing
65+ topMargin: spacing
66+ leftMargin: spacing
67+ boundsBehavior: Flickable.StopAtBounds
68+ clip: true
69+ contentX: -spacing
70+ contentY: -spacing
71+ contentWidth: input.paintedWidth + spacing
72+ contentHeight: input.paintedHeight + spacing
73+ interactive: contentHeight > height
74+ flickableDirection: Flickable.VerticalFlick
75+
76+ TextEdit {
77+ id: input
78+ width: flickable.width - flickable.spacing * 2
79+ height: Math.max(flickable.height - flickable.spacing * 2, contentHeight + flickable.spacing * 2)
80+ wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
81+
82+ color: main.__styleInstance.color
83+ selectedTextColor: main.__styleInstance.selectedTextColor
84+ selectionColor: main.__styleInstance.selectionColor
85+ font.pixelSize: FontUtils.sizeToPixels("medium")
86+
87+ // FIXME: WIP
88+ Ubuntu.Mouse.forwardTo: [main]
89+ // activeFocusOnPress: false
90+ onFocusChanged: if (focus) main.forceActiveFocus()
91+
92+ Keys.onPressed: cursorVisible = true
93+ selectByMouse: true
94+ mouseSelectionMode: TextInput.SelectWords
95+ cursorDelegate: Component {
96+ Rectangle {
97+ color: theme.palette.normal.activity
98+ width: units.dp(2)
99+ height: input.cursorRectangle.height
100+ visible: main.activeFocus
101+ }
102+ }
103+ /* cursorDelegate: TextCursor {
104+ handler: handler
105+ }
106+
107+ InputHandler {
108+ id: handler
109+ anchors.fill: parent
110+ main: main
111+ input: input
112+ flickable: flickable
113+ } */
114+ }
115+ }
116+ }
117+}
118
119=== modified file 'src/Ubuntu/Components/1.3/TextCursor.qml'
120--- src/Ubuntu/Components/1.3/TextCursor.qml 2015-12-09 19:59:50 +0000
121+++ src/Ubuntu/Components/1.3/TextCursor.qml 2016-05-25 12:39:37 +0000
122@@ -51,21 +51,13 @@
123 }
124 property int absY: {
125 // Take parent flickable movement into account
126- var flickable = handler.main;
127+ var flickable = handler.flickable;
128 do {
129 flickable = flickable.parent;
130 } while (flickable && !flickable.contentY && flickable != fakeCursor.parent);
131 return fakeCursor.parent.mapFromItem(handler.main, cursorItem.x, cursorItem.y).y
132 }
133
134- // Returns "x" or "y" relative to the item handlers are a child of
135- function mappedCursorPosition(coordinate) {
136- var cpos = cursorItem["abs" + coordinate.toUpperCase()];
137- cpos += handler.frameDistance[coordinate];
138- cpos += handler.input[coordinate];
139- cpos -= handler.flickable["content" + coordinate.toUpperCase()];
140- return cpos;
141- }
142 /*
143 The function opens the text input popover setting the text cursor as caller.
144 */
145@@ -158,7 +150,6 @@
146 property Item draggedItem: Item {
147 objectName: cursorItem.positionProperty + "_draggeditem"
148 width: caret.width + units.gu(2)
149- onWidthChanged: draggedItem.moveToCaret()
150 height: cursorItem.height + caret.height + threshold
151 property real threshold: units.gu(4)
152 parent: fakeCursor.parent
153@@ -177,12 +168,6 @@
154 preventStealing: true
155 cursorShape: Qt.IBeamCursor
156 enabled: parent.width && parent.height && parent.visible && !handler.doubleTapInProgress
157- onPressedChanged: {
158- if (!pressed) {
159- // when the dragging ends, reposition the dragger back to caret
160- draggedItem.moveToCaret();
161- }
162- }
163 Ubuntu.Mouse.forwardTo: [dragger]
164 Ubuntu.Mouse.onClicked: openPopover()
165 Ubuntu.Mouse.onPressAndHold: {
166@@ -201,16 +186,9 @@
167 }
168 }
169
170- // aligns the draggedItem to the caret and resets the dragger
171- function moveToCaret() {
172- if (!caret) {
173- return;
174- }
175- // The style may render handlers either on top or bottom
176- var flip = caret.rotation == 180;
177- draggedItem.x = fakeCursor.x + (flip ? -caret.width : -draggedItem.width + caret.width);
178- draggedItem.y = fakeCursor.y + caret.y + caret.height - threshold;
179- }
180+ property bool flip: caret.rotation == 180
181+ x: fakeCursor.x + (flip ? -caret.width : -draggedItem.width + caret.width)
182+ y: fakeCursor.y + caret.y + caret.height - threshold
183 // positions caret to the dragged position
184 function positionCaret() {
185 if (dragger.dragActive) {
186@@ -303,10 +281,8 @@
187 height: cursorItem.height
188 Component.onCompleted: caret.parent = fakeCursor
189
190- x: mappedCursorPosition("x")
191- y: mappedCursorPosition("y")
192- onXChanged: draggedItem.moveToCaret()
193- onYChanged: draggedItem.moveToCaret()
194+ x: cursorItem.absX + handler.frameDistance.x + handler.input.x - handler.flickable.contentX
195+ y: cursorItem.absY + handler.frameDistance.y + handler.input.y - handler.flickable.contentY
196
197 // manual clipping: the caret should be visible only while the cursor's
198 // top/bottom falls into the text area
199
200=== modified file 'src/Ubuntu/Components/1.3/TextField.qml'
201--- src/Ubuntu/Components/1.3/TextField.qml 2016-05-02 18:27:11 +0000
202+++ src/Ubuntu/Components/1.3/TextField.qml 2016-05-25 12:39:37 +0000
203@@ -999,6 +999,8 @@
204 verticalCenter: parent.verticalCenter
205 }
206 topMargin: internal.spacing
207+ leftMargin: internal.spacing
208+ rightMargin: internal.spacing
209 bottomMargin: internal.spacing
210 // do not allow rebounding
211 boundsBehavior: Flickable.StopAtBounds
212
213=== added file 'src/Ubuntu/Components/1.3/TextField14.qml'
214--- src/Ubuntu/Components/1.3/TextField14.qml 1970-01-01 00:00:00 +0000
215+++ src/Ubuntu/Components/1.3/TextField14.qml 2016-05-25 12:39:37 +0000
216@@ -0,0 +1,108 @@
217+import QtQuick 2.4
218+import Ubuntu.Components 1.3 as Ubuntu
219+
220+Ubuntu.ActionItem {
221+ id: main
222+ implicitWidth: units.gu(25)
223+ implicitHeight: units.gu(4)
224+
225+ property alias primaryItem: primary.data
226+ Item {
227+ id: primary
228+ anchors {
229+ left: parent.left
230+ leftMargin: flickable.spacing
231+ }
232+ height: parent.height
233+ width: childrenRect.width
234+ z: 1
235+ onChildrenChanged: adjustChildren(primary)
236+ function adjustChildren(newParent) {
237+ for (var i = 0; i < children.length; i++) {
238+ var child = children[i];
239+ child.parent = newParent;
240+ child.anchors.verticalCenter = verticalCenter;
241+ }
242+ }
243+ }
244+ property alias secondaryItem: secondary.data
245+ Item {
246+ id: secondary
247+ anchors {
248+ right: parent.right
249+ rightMargin: flickable.spacing
250+ }
251+ height: parent.height
252+ width: childrenRect.width
253+ z: 1
254+ onChildrenChanged: primary.adjustChildren(secondary)
255+ }
256+ property alias echoMode: input.echoMode
257+ property alias text: input.text
258+ property string placeholderText //FIXME: placeHolder is a placeHolder for now
259+
260+ styleName: "TextFieldStyle"
261+ Keys.forwardTo: [input]
262+ // FIXME: property alias activeFocusOnPress: input.activeFocusOnPress
263+ activeFocusOnPress: true
264+
265+ Flickable {
266+ id: flickable
267+ anchors {
268+ left: primary.right
269+ right: secondary.left
270+ margins: spacing
271+ verticalCenter: parent.verticalCenter
272+ }
273+ property real spacing: main.__styleInstance.frameSpacing
274+ topMargin: spacing
275+ leftMargin: spacing
276+ rightMargin: spacing
277+ bottomMargin: spacing
278+ boundsBehavior: Flickable.StopAtBounds
279+ clip: true
280+ contentWidth: input.contentWidth
281+ contentHeight: input.contentHeight
282+ height: input.contentHeight
283+
284+ TextInput {
285+ id: input
286+ width: parent.width
287+ height: parent.height
288+
289+ color: main.__styleInstance.color
290+ selectedTextColor: main.__styleInstance.selectedTextColor
291+ selectionColor: main.__styleInstance.selectionColor
292+ font.pixelSize: FontUtils.sizeToPixels("medium")
293+ passwordCharacter: "\u2022"
294+
295+ // FIXME: WIP
296+ Ubuntu.Mouse.forwardTo: [main]
297+ // activeFocusOnPress: false
298+ onFocusChanged: if (focus) main.forceActiveFocus()
299+
300+ Keys.onPressed: cursorVisible = true
301+ selectByMouse: true
302+ mouseSelectionMode: TextInput.SelectWords
303+ cursorDelegate: Component {
304+ Rectangle {
305+ color: theme.palette.normal.activity
306+ width: units.dp(2)
307+ height: input.cursorRectangle.height
308+ visible: main.activeFocus
309+ }
310+ }
311+ /* cursorDelegate: TextCursor {
312+ handler: handler
313+ }
314+
315+ InputHandler {
316+ id: handler
317+ anchors.fill: parent
318+ main: main
319+ input: input
320+ flickable: flickable
321+ } */
322+ }
323+ }
324+}
325
326=== modified file 'src/Ubuntu/Components/ComponentModule.pro'
327--- src/Ubuntu/Components/ComponentModule.pro 2016-02-16 11:39:32 +0000
328+++ src/Ubuntu/Components/ComponentModule.pro 2016-05-25 12:39:37 +0000
329@@ -112,8 +112,10 @@
330 1.3/Tab.qml \
331 1.3/Tabs.qml \
332 1.3/TextArea.qml \
333+ 1.3/TextArea14.qml \
334 1.3/TextCursor.qml \
335 1.3/TextField.qml \
336+ 1.3/TextField14.qml \
337 1.3/TextInputPopover.qml \
338 1.3/Toolbar.qml \
339 1.3/ToolbarButton.qml \
340
341=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/TextAreaStyle.qml'
342--- src/Ubuntu/Components/Themes/Ambiance/1.3/TextAreaStyle.qml 2016-05-10 12:08:32 +0000
343+++ src/Ubuntu/Components/Themes/Ambiance/1.3/TextAreaStyle.qml 2016-05-25 12:39:37 +0000
344@@ -54,8 +54,6 @@
345 anchors.fill: parent
346 objectName: "textarea_style"
347
348- z: -1
349-
350 /*!
351 Text input background
352 */
353
354=== modified file 'src/Ubuntu/Components/qmldir'
355--- src/Ubuntu/Components/qmldir 2016-02-16 11:39:32 +0000
356+++ src/Ubuntu/Components/qmldir 2016-05-25 12:39:37 +0000
357@@ -110,8 +110,10 @@
358 Tabs 1.3 1.3/Tabs.qml
359 ActivityIndicator 1.3 1.3/ActivityIndicator.qml
360 ProgressBar 1.3 1.3/ProgressBar.qml
361-TextField 1.3 1.3/TextField.qml
362-TextArea 1.3 1.3/TextArea.qml
363+# TextField 1.3 1.3/TextField.qml
364+TextField 1.3 1.3/TextField14.qml
365+# TextArea 1.3 1.3/TextArea.qml
366+TextArea 1.3 1.3/TextArea14.qml
367 Switch 1.3 1.3/Switch.qml
368 CheckBox 1.3 1.3/CheckBox.qml
369 Slider 1.3 1.3/Slider.qml
370
371=== modified file 'tests/unit_x11/tst_components/tst_textinput_common13.qml'
372--- tests/unit_x11/tst_components/tst_textinput_common13.qml 2016-05-11 10:59:50 +0000
373+++ tests/unit_x11/tst_components/tst_textinput_common13.qml 2016-05-25 12:39:37 +0000
374@@ -18,12 +18,17 @@
375 import QtTest 1.0
376 import Ubuntu.Test 1.3
377 import Ubuntu.Components 1.3
378+import Ubuntu.Components.Private 1.3
379 import Ubuntu.Components.Popups 1.3
380
381 Item {
382 id: testMain
383 width: units.gu(40)
384+<<<<<<< TREE
385 height: units.gu(70)
386+=======
387+ height: units.gu(90)
388+>>>>>>> MERGE-SOURCE
389
390 Component {
391 id: popoverComponent
392@@ -95,6 +100,8 @@
393
394 TextField {
395 id: textField
396+ text: i18n.tr("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.")
397+ height: units.gu(6)
398 }
399
400 FocusScope {
401@@ -126,21 +133,32 @@
402
403 TextField {
404 id: customTextField
405- text: 'Lorem ipsum dolor sit amet'
406+ text: i18n.tr("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.")
407 primaryItem: AbstractButton {
408 id: primaryButton
409- height: parent.height
410+ height: parent.height / 1.7
411 width: height
412 Image {
413 anchors.fill: parent
414 anchors.margins: units.gu(0.5)
415 source: 'image://theme/torch-on'
416 }
417+ Frame {
418+ anchors.fill: parent
419+ anchors.margins: -units.gu(0.46)
420+ thickness: units.gu(0.21)
421+ radius: units.gu(1.7)
422+ color: theme.palette.normal.focus
423+ visible: parent.keyNavigationFocus
424+ }
425+ // FIXME: activeFocusOnTab: true
426+ Component.onCompleted: activeFocusOnTab = true
427 }
428- secondaryItem: AbstractButton {
429+ secondaryItem: /*Abstract*/Button {
430 id: secondaryButton
431- height: parent.height
432+ height: parent.height / 1.7
433 width: height
434+ color: activeFocus ? UbuntuColors.orange : UbuntuColors.blue
435 Image {
436 anchors.fill: parent
437 anchors.margins: units.gu(0.5)
438@@ -148,8 +166,68 @@
439 }
440 }
441 }
442+
443+ AbstractButton {
444+ width: units.gu(10)
445+ height: units.gu(5)
446+ Component.onCompleted: activeFocusOnTab = true
447+ Frame {
448+ anchors.fill: parent
449+ anchors.margins: units.gu(0.46)
450+ thickness: units.gu(0.21)
451+ radius: units.gu(1.7)
452+ color: parent.keyNavigationFocus ? theme.palette.normal.focus : theme.palette.normal.foreground
453+
454+ AbstractButton {
455+ anchors.verticalCenter: parent.verticalCenter
456+ anchors.right: parent.right
457+ width: height
458+ height: parent.height / 1.2
459+ Component.onCompleted: activeFocusOnTab = true
460+ Frame {
461+ anchors.fill: parent
462+ anchors.margins: units.gu(0.46)
463+ thickness: units.gu(0.21)
464+ radius: units.gu(1.7)
465+ color: parent.keyNavigationFocus ? theme.palette.normal.focus : theme.palette.normal.foreground
466+ }
467+ }
468+ }
469+ }
470+
471 TextArea {
472 id: textArea
473+ text: i18n.tr("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.")
474+ + i18n.tr("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.")
475+ + i18n.tr("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.")
476+ + i18n.tr("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.")
477+ }
478+ ScrollView {
479+ width: units.gu(30)
480+ height: units.gu(12)
481+ Flickable {
482+ id: flickable
483+ anchors.fill: parent
484+ contentWidth: textInput.paintedWidth
485+ contentHeight: textInput.paintedHeight
486+ topMargin: units.gu(2)
487+ leftMargin: units.gu(2)
488+ contentX: leftMargin
489+ contentY: topMargin
490+ TextEdit {
491+ id: textInput
492+ text: textArea.text
493+ width: flickable.width
494+ height: flickable.height
495+ wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
496+ }
497+ Rectangle {
498+ anchors.fill: parent
499+ opacity: 0.3
500+ color: UbuntuColors.blue // theme.palette.normal.field
501+ }
502+
503+ }
504 }
505 TextField {
506 id: password

Subscribers

People subscribed via source and target branches