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

Proposed by Cris Dywan
Status: Work in progress
Proposed branch: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/inputFlickableContentWidth
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 174 lines (+64/-57)
3 files modified
examples/ubuntu-ui-toolkit-gallery/TextInputs.qml (+12/-0)
src/Ubuntu/Components/1.3/InputHandler.qml (+6/-5)
src/Ubuntu/Components/1.3/TextField.qml (+46/-52)
To merge this branch: bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/inputFlickableContentWidth
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu SDK team Pending
Review via email: mp+275888@code.launchpad.net

Commit message

InputHandler.ensureVisible needs to take flickable contentWidth into account

Description of the change

InputHandler.ensureVisible needs to take flickable contentWidth into account

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

Validation of the state of this MR:

r1694 slightly improves the problem but effectively hides the handlers and moves them offscreen. It can suffer from a binding race where handlers move offscreen in a non-recoverable way.
r1695 removes the Flickable - in theory it simplifies and improves scrolling, in practise it still suffers from the same binding race.
^^ For reference the diff suffers less visibly from the binding race, but it also doesn't improve much on the bug, and the handlers remain largely offscreen as before.

Unmerged revisions

1695. By Cris Dywan

Scrollable TextField without Flickable

1694. By Cris Dywan

InputHandler.ensureVisible needs to take flickable contentWidth into account

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/ubuntu-ui-toolkit-gallery/TextInputs.qml'
2--- examples/ubuntu-ui-toolkit-gallery/TextInputs.qml 2015-04-25 08:18:45 +0000
3+++ examples/ubuntu-ui-toolkit-gallery/TextInputs.qml 2015-10-28 17:48:25 +0000
4@@ -87,6 +87,18 @@
5 }
6
7 TemplateRow {
8+ title: i18n.tr("Website")
9+
10+ TextField {
11+ objectName: "textfield_url"
12+ text: 'http://max-skizzen-blog.blogspot.de/2009/10/hessen-eine-geschichte-von-robert.html?m=1'
13+ width: parent.width
14+ horizontalAlignment: TextInput.AlignHCenter
15+ inputMethodHints: Qt.ImhUrlCharactersOnly
16+ }
17+ }
18+
19+ TemplateRow {
20 title: i18n.tr("Disabled")
21
22 TextField {
23
24=== modified file 'src/Ubuntu/Components/1.3/InputHandler.qml'
25--- src/Ubuntu/Components/1.3/InputHandler.qml 2015-08-11 17:15:59 +0000
26+++ src/Ubuntu/Components/1.3/InputHandler.qml 2015-10-28 17:48:25 +0000
27@@ -31,12 +31,13 @@
28 // the input instance
29 property Item input
30 // the Flickable holding the input instance
31- property Flickable flickable
32+ property var flickable
33
34 // item filling the visible text input area used to check handler visibility
35 property Item visibleArea: Item {
36 parent: flickable
37 anchors.fill: parent
38+ anchors.margins: -flickable.margins
39 }
40
41 // line size and spacing
42@@ -81,8 +82,8 @@
43 readonly property bool scrollingDisabled: main && main.hasOwnProperty("autoSize") ?
44 (main.autoSize && (main.maximumLineCount <= 0)) : false
45 onScrollingDisabledChanged: if (state == "") flickable.interactive = !scrollingDisabled
46- readonly property Flickable grandScroller: firstFlickableParent(main)
47- readonly property Flickable scroller: (scrollingDisabled && grandScroller) ? grandScroller : flickable
48+ readonly property var grandScroller: firstFlickableParent(main)
49+ readonly property var scroller: (scrollingDisabled && grandScroller) ? grandScroller : flickable
50
51 // ensures the text cursorRectangle is always in the internal Flickable's visible area
52 function ensureVisible(rect)
53@@ -91,8 +92,8 @@
54 return;
55 if (flickable.contentX >= rect.x)
56 flickable.contentX = rect.x;
57- else if (flickable.contentX + flickable.width <= rect.x + rect.width)
58- flickable.contentX = rect.x + rect.width - flickable.width;
59+ else if (flickable.contentX + flickable.contentWidth <= rect.x + rect.width)
60+ flickable.contentX = rect.x + rect.width - flickable.contentWidth;
61 if (flickable.contentY >= rect.y)
62 flickable.contentY = rect.y;
63 else if (flickable.contentY + flickable.height <= rect.y + rect.height)
64
65=== modified file 'src/Ubuntu/Components/1.3/TextField.qml'
66--- src/Ubuntu/Components/1.3/TextField.qml 2015-09-28 14:36:54 +0000
67+++ src/Ubuntu/Components/1.3/TextField.qml 2015-10-28 17:48:25 +0000
68@@ -950,61 +950,55 @@
69
70
71 // text input
72- Flickable {
73- id: flicker
74- objectName: "input_scroller"
75- anchors {
76- left: leftPane.right
77- right: clearButton.left
78- top: parent.top
79- bottom: parent.bottom
80- margins: internal.spacing
81+ TextInput {
82+ id: editor
83+ objectName: "text_input"
84+ // FocusScope will forward focus to this component
85+ focus: true
86+ verticalAlignment: TextInput.AlignVCenter
87+ cursorDelegate: TextCursor {
88+ handler: inputHandler
89 }
90- topMargin: internal.spacing
91- // do not allow rebounding
92- boundsBehavior: Flickable.StopAtBounds
93- // need to forward events as events occurred on topMargin area are not grabbed by the MouseArea.
94- Ubuntu.Mouse.forwardTo: [inputHandler]
95+ color: control.__styleInstance.color
96+ selectedTextColor: control.__styleInstance.selectedTextColor
97+ selectionColor: control.__styleInstance.selectionColor
98+ font.pixelSize: FontUtils.sizeToPixels("medium")
99+ passwordCharacter: "\u2022"
100+ // forward keys to the root element so it can be captured outside of it
101+ // as well as to InputHandler to handle PageUp/PageDown keys
102+ Keys.forwardTo: [control, inputHandler]
103+
104+ // overrides
105+ selectByMouse: true
106+ activeFocusOnPress: control.activeFocusOnPress
107+ onActiveFocusChanged: if (!activeFocus && inputHandler.popover) PopupUtils.close(inputHandler.popover)
108+ // Implement fake Flickable interface for InputHandler
109+ property real contentX: x
110+ property real contentY: y
111+ property bool moving: false
112+ property bool flicking: false
113+ property bool interactive: autoScroll
114+ signal flickStarted()
115+ signal movementStarted()
116+ signal movementEnded()
117
118 clip: true
119- contentWidth: editor.contentWidth
120- contentHeight: editor.contentHeight
121-
122- TextInput {
123- id: editor
124- objectName: "text_input"
125- // FocusScope will forward focus to this component
126- focus: true
127- anchors.verticalCenter: parent.verticalCenter
128- verticalAlignment: TextInput.AlignVCenter
129- width: flicker.width
130- height: flicker.height
131- cursorDelegate: TextCursor {
132- handler: inputHandler
133- }
134- color: control.__styleInstance.color
135- selectedTextColor: control.__styleInstance.selectedTextColor
136- selectionColor: control.__styleInstance.selectionColor
137- font.pixelSize: FontUtils.sizeToPixels("medium")
138- passwordCharacter: "\u2022"
139- // forward keys to the root element so it can be captured outside of it
140- // as well as to InputHandler to handle PageUp/PageDown keys
141- Keys.forwardTo: [control, inputHandler]
142-
143- // overrides
144- selectByMouse: true
145- activeFocusOnPress: control.activeFocusOnPress
146- onActiveFocusChanged: if (!activeFocus && inputHandler.popover) PopupUtils.close(inputHandler.popover)
147-
148- // input selection and navigation handling
149- Ubuntu.Mouse.forwardTo: [inputHandler]
150- InputHandler {
151- id: inputHandler
152- anchors.fill: parent
153- main: control
154- input: editor
155- flickable: flicker
156- }
157+ anchors {
158+ left: leftPane.right
159+ right: clearButton.left
160+ verticalCenter: parent.verticalCenter
161+ margins: internal.spacing
162+ }
163+
164+ // input selection and navigation handling
165+ Ubuntu.Mouse.forwardTo: [inputHandler]
166+ InputHandler {
167+ id: inputHandler
168+ anchors.fill: parent
169+ main: control
170+ input: editor
171+ flickable: editor
172+ frameDistance: Qt.point(control.x, control.y)
173 }
174 }
175

Subscribers

People subscribed via source and target branches