v1.3.0: live-bind display mode to config (dialog changes apply without restart); add configurable split-flap cascade seconds
This commit is contained in:
@@ -13,6 +13,8 @@ Row {
|
||||
// wired by the parent loader
|
||||
property string display: "--"
|
||||
property color trendColor: "#9e9e9e"
|
||||
// seconds over which the cascade to a new price is spread
|
||||
property int flapSeconds: 3
|
||||
|
||||
spacing: height * 0.06
|
||||
|
||||
@@ -20,6 +22,8 @@ Row {
|
||||
property bool ready: false
|
||||
readonly property real cellFont: height * 0.72
|
||||
readonly property real cellWidth: cellFont * 0.80
|
||||
// one flap open+close takes 260 ms; keep delays above that
|
||||
readonly property int flapDuration: 260
|
||||
|
||||
Component.onCompleted: {
|
||||
chars = display.split("");
|
||||
@@ -32,14 +36,21 @@ Row {
|
||||
}
|
||||
var nc = display.split("");
|
||||
var n = Math.max(chars.length, nc.length);
|
||||
// spread the changed cells evenly across flapSeconds
|
||||
var changed = [];
|
||||
for (var i = 0; i < n; i++) {
|
||||
var from = i < chars.length ? chars[i] : "";
|
||||
var to = i < nc.length ? nc[i] : "";
|
||||
if (from !== to) {
|
||||
var cell = rep.itemAt(i);
|
||||
if (cell) {
|
||||
cell.flipTo(to, i * 45);
|
||||
}
|
||||
changed.push([i, to]);
|
||||
}
|
||||
}
|
||||
var span = Math.max(1, flapSeconds) * 1000 - flapDuration;
|
||||
var step = changed.length > 1 ? Math.max(0, Math.floor(span / (changed.length - 1))) : 0;
|
||||
for (var j = 0; j < changed.length; j++) {
|
||||
var cell = rep.itemAt(changed[j][0]);
|
||||
if (cell) {
|
||||
cell.flipTo(changed[j][1], j * step);
|
||||
}
|
||||
}
|
||||
chars = nc;
|
||||
|
||||
Reference in New Issue
Block a user