Changeset View
Changeset View
Standalone View
Standalone View
source/qml/lib/Ruler.qml
| Show All 20 Lines | |||||
| 21 | import QtQuick.Controls 2.2 | 21 | import QtQuick.Controls 2.2 | ||
| 22 | import org.kde.kirigami 2.4 as Kirigami | 22 | import org.kde.kirigami 2.4 as Kirigami | ||
| 23 | import "tools.js" as T | 23 | import "tools.js" as T | ||
| 24 | 24 | | |||
| 25 | // Draw a ruler for highlighting alignment | 25 | // Draw a ruler for highlighting alignment | ||
| 26 | Item { | 26 | Item { | ||
| 27 | id: canvas | 27 | id: canvas | ||
| 28 | anchors.fill: parent; | 28 | anchors.fill: parent; | ||
| 29 | property int rx; | 29 | property int offset; | ||
| 30 | property int ry; | | |||
| 31 | property bool horizontal: true; | 30 | property bool horizontal: true; | ||
| 32 | property string stroke: "rgba(41,128,185, 1)" | 31 | property string stroke: "rgba(41,128,185, 1)" | ||
| 33 | property double scale: T.getScale(canvas) | 32 | property double scale: T.getScale(canvas) | ||
| 34 | 33 | | |||
| 35 | // using Rectangles because they scale smooth | 34 | // using Rectangles because they scale smooth | ||
| 36 | Row { | 35 | Row { | ||
| 37 | y: canvas.ry | 36 | y: canvas.offset | ||
| 38 | x: 0 | 37 | x: 0 | ||
| 39 | id: hackRow | 38 | id: hackRow | ||
| 40 | visible: canvas.horizontal | 39 | visible: canvas.horizontal | ||
| 41 | spacing: Kirigami.Units.smallSpacing / scale | 40 | spacing: Kirigami.Units.smallSpacing / scale | ||
| 42 | Repeater { | 41 | Repeater { | ||
| 43 | model: new Array(Math.floor(canvas.width / hackRow.spacing / 2)) | 42 | model: new Array(Math.floor(canvas.width / hackRow.spacing / 2)) | ||
| 44 | Rectangle { | 43 | Rectangle { | ||
| 45 | width: Kirigami.Units.smallSpacing / scale | 44 | width: Kirigami.Units.smallSpacing / scale | ||
| 46 | height: 2 / scale | 45 | height: 2 / scale | ||
| 47 | color: "#2980b9" | 46 | color: "#2980b9" | ||
| 48 | } | 47 | } | ||
| 49 | } | 48 | } | ||
| 50 | } | 49 | } | ||
| 51 | Column { | 50 | Column { | ||
| 52 | x: canvas.rx | 51 | x: canvas.offset | ||
| 53 | y: 0 | 52 | y: 0 | ||
| 54 | id: hackColumn | 53 | id: hackColumn | ||
| 55 | visible: !canvas.horizontal | 54 | visible: !canvas.horizontal | ||
| 56 | spacing: Kirigami.Units.smallSpacing / scale | 55 | spacing: Kirigami.Units.smallSpacing / scale | ||
| 57 | Repeater { | 56 | Repeater { | ||
| 58 | model: new Array(Math.floor(canvas.height / hackColumn.spacing / 2)) | 57 | model: new Array(Math.floor(canvas.height / hackColumn.spacing / 2)) | ||
| 59 | Rectangle { | 58 | Rectangle { | ||
| 60 | height: Kirigami.Units.smallSpacing / scale | 59 | height: Kirigami.Units.smallSpacing / scale | ||
| 61 | width: 1 / scale | 60 | width: 1 / scale | ||
| 62 | color: "#2980b9" | 61 | color: "#2980b9" | ||
| 63 | } | 62 | } | ||
| 64 | } | 63 | } | ||
| 65 | } | 64 | } | ||
| 66 | } | 65 | } | ||