~zsombi/ubuntu-ui-toolkit/listitemSelectModeBugs

« back to all changes in this revision

Viewing changes to src/Ubuntu/Components/1.3/TextCursor.qml

  • Committer: Zsombor Egri
  • Date: 2015-11-16 06:35:05 UTC
  • mfrom: (1664.1.1 listitemSelectModeBugs)
  • Revision ID: zsombor.egri@canonical.com-20151116063505-cwn2qfks7qzk10g9
re-sync

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
                                           handler.main.cursorDelegate :
42
42
                                           __styleInstance.cursorDelegate
43
43
 
44
 
    theme.version: Ubuntu.Ubuntu.toolkitVersion
45
44
    styleName: "TextCursorStyle"
46
45
 
47
46
    objectName: "textCursor"
158
157
    //dragged item
159
158
    property Item draggedItem: Item {
160
159
        objectName: cursorItem.positionProperty + "_draggeditem"
161
 
        width: caret.width + units.gu(4)
 
160
        width: caret.width + units.gu(2)
162
161
        onWidthChanged: draggedItem.moveToCaret()
163
 
        height: caret.height + units.gu(4)
 
162
        height: cursorItem.height + caret.height + units.gu(2)
164
163
        parent: fakeCursor.parent
165
164
        visible: caret.visible
166
165
 
206
205
            if (!caret) {
207
206
                return;
208
207
            }
209
 
            draggedItem.x = fakeCursor.x - draggedItem.width / 2;
210
 
            draggedItem.y = fakeCursor.y + caret.y - caret.height / 2;
 
208
            // The style may render handlers either on top or bottom
 
209
            var flip = caret.rotation == 180;
 
210
            draggedItem.x = fakeCursor.x + (flip ? -units.gu(1) : -draggedItem.width + units.gu(1));
 
211
            draggedItem.y = fakeCursor.y - caret.height - units.gu(0.5);
211
212
        }
212
213
        // positions caret to the dragged position
213
214
        function positionCaret() {
216
217
                var dy = dragger.dragStartY + dragger.dragAmountY + handler.flickable.contentY;
217
218
                dx -= handler.frameDistance.x;
218
219
                dy -= handler.frameDistance.y;
219
 
                dy -= draggedItem.height / 2;
220
220
                handler.positionCaret(positionProperty, dx, dy);
221
221
            }
222
222
        }