| 1 | import QtQuick |
| 2 | |
| 3 | // History as a dot matrix (cpu): one column per sample, the top lit dot white, the ones under it grey, the rest unlit. |
| 4 | // Parts from glyph-rice (GPL-3.0), home/Home.qml (system widget). |
| 5 | Item { |
| 6 | id: s |
| 7 | property var values: [] |
| 8 | property int slots: 40 |
| 9 | readonly property real gap: 3 |
| 10 | readonly property real d: Math.max(2, (width - (slots - 1) * gap) / slots) |
| 11 | readonly property int rows: Math.max(3, Math.floor((height + gap) / (d + gap))) |
| 12 | implicitHeight: 44 |
| 13 | |
| 14 | Grid { |
| 15 | columns: s.slots |
| 16 | spacing: s.gap |
| 17 | Repeater { |
| 18 | model: s.slots * s.rows |
| 19 | Rectangle { |
| 20 | required property int index |
| 21 | readonly property int col: index % s.slots |
| 22 | readonly property int up: s.rows - Math.floor(index / s.slots) // rows .. 1, top to bottom |
| 23 | readonly property int vi: s.values.length - s.slots + col |
| 24 | readonly property real v: vi >= 0 && vi < s.values.length ? s.values[vi] : 0 |
| 25 | readonly property int h: Math.max(1, Math.round(v * s.rows)) |
| 26 | width: s.d |
| 27 | height: s.d |
| 28 | radius: s.d / 2 |
| 29 | color: up === h ? Theme.fill : up < h ? Theme.fade(Theme.fill, 0.45) : Theme.s2 |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | } |