Skip to content

Commit

Permalink
Should fix #346, also prevents #355
Browse files Browse the repository at this point in the history
  • Loading branch information
janschopohl committed Apr 27, 2017
1 parent 32bbe94 commit a70ec1f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions source/ui/Components/editor/Editor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ ScrollView {
id: item
anchors.fill: parent

property alias zoom: scale.zoom

// Scaling transofmation for zooming
transform: Scale {
id: scale
Expand Down
22 changes: 11 additions & 11 deletions source/ui/Components/editor/TextRegion.qml
Original file line number Diff line number Diff line change
Expand Up @@ -178,36 +178,36 @@ TextEdit {
}

function scrollUp(cursor) {
if (cursor.y < (scrollView.flickableItem.contentY / scale.zoom)) {
scrollView.flickableItem.contentY = (cursor.y - textMargin) * scale.zoom;
if (cursor.y < (scrollView.flickableItem.contentY / item.zoom)) {
scrollView.flickableItem.contentY = (cursor.y - textMargin) * item.zoom;
}
}

function scrollDown(cursor) {
var viewportHeight = scrollView.viewport.height / scale.zoom;
var bottomBoundary = scrollView.flickableItem.contentY / scale.zoom
var viewportHeight = scrollView.viewport.height / item.zoom;
var bottomBoundary = scrollView.flickableItem.contentY / item.zoom
+ viewportHeight - textMargin;
if (cursor.y + cursor.height >= bottomBoundary) {
var newY = cursor.y + cursor.height - viewportHeight + textMargin;
scrollview.flickableItem.contentY = newY * scale.zoom;
scrollView.flickableItem.contentY = newY * item.zoom;
}
}

function scrollLeft(cursor) {
if (cursor.x < scrollView.flickableItem.contentX / scale.zoom) {
scrollView.flickableItem.contentX = (cursor.x - textMargin) * scale.zoom;
if (cursor.x < scrollView.flickableItem.contentX / item.zoom) {
scrollView.flickableItem.contentX = (cursor.x - textMargin) * item.zoom;
}
}

function scrollRight(cursor) {
var topBoundary = (scrollView.flickableItem.contentX / scale.zoom)
+ (scrollView.viewport.width / scale.zoom)
var topBoundary = (scrollView.flickableItem.contentX / item.zoom)
+ (scrollView.viewport.width / item.zoom)
- textMargin;
if (cursor.x + textRegion.x >= topBoundary) {
var newX = cursor.x
- (scrollView.viewport.width / scale.zoom)
- (scrollView.viewport.width / item.zoom)
+ textRegion.x + textMargin;
scrollView.flickableItem.contentX = newX * scale.zoom;
scrollView.flickableItem.contentX = newX * item.zoom;
}
}

Expand Down
2 changes: 1 addition & 1 deletion third-party/googletest

0 comments on commit a70ec1f

Please sign in to comment.